From: Jay Freeman (saurik) Date: Mon, 6 Jun 2011 08:37:47 +0000 (-0700) Subject: Merge branch 'master' of git.saurik.com:cydia X-Git-Tag: v1.1.2~7 X-Git-Url: https://git.saurik.com/cydia.git/commitdiff_plain/111ee7bc600f63fee72bef7ab614f37aa6419491?hp=-c Merge branch 'master' of git.saurik.com:cydia --- 111ee7bc600f63fee72bef7ab614f37aa6419491 diff --combined MobileCydia.mm index ea858e99,a6b61fed..1acb5eac --- a/MobileCydia.mm +++ b/MobileCydia.mm @@@ -1338,7 -1338,6 +1338,7 @@@ static void PackageImport(const void *k - (NSString *) depictionForPackage:(NSString *)package; - (NSString *) supportForPackage:(NSString *)package; +- (metaIndex *) metaIndex; - (NSDictionary *) record; - (BOOL) trusted; @@@ -1427,10 -1426,6 +1427,10 @@@ return ![[self _attributeKeys] containsObject:[NSString stringWithUTF8String:name]] && [super isKeyExcludedFromWebScript:name]; } +- (metaIndex *) metaIndex { + return index_; +} + - (void) setMetaIndex:(metaIndex *)index inPool:(apr_pool_t *)pool { [self _clear]; @@@ -2378,7 -2373,7 +2378,7 @@@ struct PackageNameOrdering _end _profile(Package$initWithVersion$Section) - section_ = iterator.Section(); + section_ = version_.Section(); _end _profile(Package$initWithVersion$Flags) @@@ -3544,47 -3539,29 +3544,47 @@@ class CydiaLogCleaner NSString *title(UCLocalize("DATABASE")); + list_ = new pkgSourceList(); + if ([self popErrorWithTitle:title forOperation:list_->ReadMainList()]) + return; + + for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) { + Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:pool_] autorelease]); + [sourceList_ addObject:object]; + } + _trace(); OpProgress progress; - while (!cache_.Open(progress, true)) { pop: - std::string error; - bool warning(!_error->PopMessage(error)); - lprintf("cache_.Open():[%s]\n", error.c_str()); - - if (error == "dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. ") - [delegate_ repairWithSelector:@selector(configure)]; - else if (error == "The package lists or status file could not be parsed or opened.") - [delegate_ repairWithSelector:@selector(update)]; - // else if (error == "Could not get lock /var/lib/dpkg/lock - open (35 Resource temporarily unavailable)") - // else if (error == "Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)") - // else if (error == "Malformed Status line") - // else if (error == "The list of sources could not be read.") - else { + open: + if (!cache_.Open(progress, true)) { + // XXX: what if there are errors, but Open() == true? this should be merged with popError: + while (!_error->empty()) { + std::string error; + bool warning(!_error->PopMessage(error)); + + lprintf("cache_.Open():[%s]\n", error.c_str()); + [delegate_ addProgressEventOnMainThread:[CydiaProgressEvent eventWithMessage:[NSString stringWithUTF8String:error.c_str()] ofType:(warning ? kCydiaProgressEventTypeWarning : kCydiaProgressEventTypeError)] forTask:title]; - return; + + SEL repair(NULL); + if (false); + else if (error == "dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. ") + repair = @selector(configure); + //else if (error == "The package lists or status file could not be parsed or opened.") + // repair = @selector(update); + // else if (error == "Could not get lock /var/lib/dpkg/lock - open (35 Resource temporarily unavailable)") + // else if (error == "Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)") + // else if (error == "Malformed Status line") + // else if (error == "The list of sources could not be read.") + + if (repair != NULL) { + _error->Discard(); + [delegate_ repairWithSelector:repair]; + goto open; + } } - if (warning) - goto pop; - _error->Discard(); + return; } _trace(); @@@ -3598,6 -3575,10 +3598,6 @@@ fetcher_ = new pkgAcquire(&status_); lock_ = NULL; - list_ = new pkgSourceList(); - if ([self popErrorWithTitle:title forOperation:list_->ReadMainList()]) - return; - if (cache_->DelCount() != 0 || cache_->InstCount() != 0) { [delegate_ addProgressEventOnMainThread:[CydiaProgressEvent eventWithMessage:UCLocalize("COUNTS_NONZERO_EX") ofType:kCydiaProgressEventTypeError] forTask:title]; return; @@@ -3619,9 -3600,11 +3619,9 @@@ return; } - for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) { - Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:pool_] autorelease]); - [sourceList_ addObject:object]; - - std::vector *indices = (*source)->GetIndexFiles(); + for (Source *object in (id) sourceList_) { + metaIndex *source([object metaIndex]); + std::vector *indices = source->GetIndexFiles(); for (std::vector::const_iterator index = indices->begin(); index != indices->end(); ++index) // XXX: this could be more intelligent if (dynamic_cast(*index) != NULL) { @@@ -4470,7 -4453,7 +4470,7 @@@ static _H Diversions_ } - (NSString *) substitutePackageNames:(NSString *)message { - NSMutableArray *words([[message componentsSeparatedByString:@" "] mutableCopy]); + 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]) @@@ -4646,7 -4629,7 +4646,7 @@@ } + (NSURLRequest *) requestWithHeaders:(NSURLRequest *)request { - NSMutableURLRequest *copy([request mutableCopy]); + NSMutableURLRequest *copy([[request mutableCopy] autorelease]); NSURL *url([copy URL]); NSString *href([url absoluteString]); @@@ -5341,6 -5324,12 +5341,6 @@@ bool DepSubstrate(const pkgCache::VerIt ] autorelease]; } -- (void) uicache { - _trace(); - system("su -c /usr/bin/uicache mobile"); - _trace(); -} - - (void) invoke:(NSInvocation *)invocation withTitle:(NSString *)title { UpdateExternalStatus(1); @@@ -5418,6 -5407,11 +5418,6 @@@ case 4: [progress_ setFinish:UCLocalize("REBOOT_DEVICE")]; break; } - UIProgressHUD *hud([delegate_ addProgressHUD]); - [hud setText:UCLocalize("LOADING")]; - [self yieldToSelector:@selector(uicache)]; - [delegate_ removeProgressHUD:hud]; - UpdateExternalStatus(Finish_ == 0 ? 0 : 2); [progress_ setRunning:false]; @@@ -6902,7 -6896,7 +6902,7 @@@ static void HomeControllerReachabilityC } return; } - NSMutableArray *controllers = [[self viewControllers] mutableCopy]; + NSMutableArray *controllers = [[[self viewControllers] mutableCopy] autorelease]; if (transient != nil) { UINavigationController *navigation([[[UINavigationController alloc] init] autorelease]); [navigation setViewControllers:[NSArray arrayWithObject:transient]]; @@@ -8916,6 -8910,10 +8916,6 @@@ @synchronized (database_) { era_ = [database_ era]; - pkgSourceList list; - if ([database_ popErrorWithTitle:UCLocalize("SOURCES") forOperation:list.ReadMainList()]) - return; - sources_ = [NSMutableArray arrayWithCapacity:16]; [sources_ addObjectsFromArray:[database_ sources]]; _trace(); @@@ -9688,23 -9686,9 +9688,23 @@@ } } +- (void) _uicache { + _trace(); + system("su -c /usr/bin/uicache mobile"); + _trace(); +} + +- (void) uicache { + UIProgressHUD *hud([self addProgressHUD]); + [hud setText:UCLocalize("LOADING")]; + [self yieldToSelector:@selector(_uicache)]; + [self removeProgressHUD:hud]; +} + - (void) perform_ { [database_ perform]; [self performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES]; + [self performSelectorOnMainThread:@selector(uicache) withObject:nil waitUntilDone:YES]; } - (void) confirmWithNavigationController:(UINavigationController *)navigation { @@@ -10254,7 -10238,7 +10254,7 @@@ _trace() [self disemulate]; int savedIndex = [[Metadata_ objectForKey:@"InterfaceIndex"] intValue]; - NSArray *saved = [[Metadata_ objectForKey:@"InterfaceState"] mutableCopy]; + NSArray *saved = [[[Metadata_ objectForKey:@"InterfaceState"] mutableCopy] autorelease]; int standardIndex = 0; NSArray *standard = [self defaultStartPages]; @@@ -10407,7 -10391,7 +10407,7 @@@ MSHook(void *, CFXPreferencesPropertyLi Class $NSURLConnection; MSHook(id, NSURLConnection$init$, NSURLConnection *self, SEL _cmd, NSURLRequest *request, id delegate, BOOL usesCache, int64_t maxContentLength, BOOL startImmediately, NSDictionary *connectionProperties) { - NSMutableURLRequest *copy([request mutableCopy]); + NSMutableURLRequest *copy([[request mutableCopy] autorelease]); NSURL *url([copy URL]);