X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/6220fd7da99b2edf6b1c6e98e65b45216a32e7af..caa861bdca0452534fccc101228458f5cc6f41f2:/MobileCydia.mm diff --git a/MobileCydia.mm b/MobileCydia.mm index 2a694ee6..0485f54f 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -53,7 +53,6 @@ #include #include -#include #include #include @@ -1135,6 +1134,7 @@ typedef std::map< unsigned long, _H > SourceMap; + (Database *) sharedInstance; - (unsigned) era; +- (bool) hasPackages; - (void) _readCydia:(NSNumber *)fd; - (void) _readStatus:(NSNumber *)fd; @@ -1420,14 +1420,14 @@ struct PackageValue : char version_[8]; char name_[]; -}; +} _packed; struct MetaValue : Cytore::Block { uint32_t active_; Cytore::Offset packages_[1 << 16]; -}; +} _packed; static Cytore::File MetaFile_; // }}} @@ -3523,6 +3523,10 @@ class CydiaLogCleaner : CFArrayRemoveAllValues(packages_); } +- (bool) hasPackages { + return CFArrayGetCount(packages_) != 0; +} + - (void) dealloc { // XXX: actually implement this thing _assert(false); @@ -3869,7 +3873,7 @@ class CydiaLogCleaner : opened = cache_.Open(progress, false); _end if (!opened) { - // XXX: what if there are errors, but Open() == true? this should be merged with popError: + // XXX: this block should probably be merged with popError: in some way while (!_error->empty()) { std::string error; bool warning(!_error->PopMessage(error)); @@ -3897,7 +3901,8 @@ class CydiaLogCleaner : } return; - } + } else if ([self popErrorWithTitle:title forOperation:true]) + return; _trace(); unlink("/tmp/cydia.chk"); @@ -4856,10 +4861,16 @@ static _H Diversions_; } - (NSString *) substitutePackageNames:(NSString *)message { + auto database([Database sharedInstance]); + + // XXX: this check is less racy than you'd expect, but this entire concept is a little awkward + if (![database hasPackages]) + return message; + NSMutableArray *words([[[message componentsSeparatedByString:@" "] mutableCopy] autorelease]); for (size_t i(0), e([words count]); i != e; ++i) { NSString *word([words objectAtIndex:i]); - if (Package *package = [[Database sharedInstance] packageWithName:word]) + if (Package *package = [database packageWithName:word]) [words replaceObjectAtIndex:i withObject:[package name]]; } @@ -5612,7 +5623,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/#!/progress/", UI_]]]; - [scroller_ setBackgroundColor:[UIColor blackColor]]; + [self setPageColor:[UIColor blackColor]]; [[self navigationItem] setHidesBackButton:YES]; @@ -8531,8 +8542,7 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi [Sources_ removeObjectForKey:[source key]]; - [delegate_ _saveConfig]; - [delegate_ reloadDataWithInvocation:nil]; + [delegate_ syncData]; } } @@ -8844,7 +8854,7 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi [alert setNumberOfRows:1]; [alert addTextFieldWithValue:@"http://" label:@""]; - UITextInputTraits *traits = [[alert textField] textInputTraits]; + NSObject *traits = [[alert textField] textInputTraits]; [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone]; [traits setAutocorrectionType:UITextAutocorrectionTypeNo]; [traits setKeyboardType:UIKeyboardTypeURL]; @@ -9118,9 +9128,9 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi - (void) reloadSpringBoard { if (kCFCoreFoundationVersionNumber >= 700) // XXX: iOS 6.x - system("/bin/launchctl stop com.apple.backboardd"); + system("/usr/libexec/cydia/cydo /bin/launchctl stop com.apple.backboardd"); else - system("/bin/launchctl stop com.apple.SpringBoard"); + system("/usr/libexec/cydia/cydo /bin/launchctl stop com.apple.SpringBoard"); sleep(15); system("/usr/bin/killall backboardd SpringBoard"); } @@ -9594,7 +9604,7 @@ _end [super applicationSuspend]; } -- (void) applicationSuspend:(__GSEvent *)event { +- (void) applicationSuspend:(GSEventRef)event { if ([self isSafeToSuspend]) [super applicationSuspend:event]; } @@ -10325,7 +10335,7 @@ int main(int argc, char *argv[]) { } languages += "en"; - NSLog(@"Setting Language: %s", languages.c_str()); + NSLog(@"Setting Language: [%s] %s", translation, languages.c_str()); /* }}} */ /* Index Collation {{{ */ if (Class $UILocalizedIndexedCollation = objc_getClass("UILocalizedIndexedCollation")) { @try { @@ -10579,8 +10589,7 @@ int main(int argc, char *argv[]) { if (translation != NULL) _config->Set("APT::Acquire::Translation", translation); - if (!languages.empty()) - _config->Set("Acquire::Languages", languages); + _config->Set("Acquire::Languages", languages); // XXX: this timeout might be important :( //_config->Set("Acquire::http::Timeout", 15);