X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/a020a50efa5435fc5c7317297399196cd35d2c61..958ded7e72adfd81ecf4db8565429c40fbe02b40:/MobileCydia.mm diff --git a/MobileCydia.mm b/MobileCydia.mm index 20d82bbc..f113a80c 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -121,6 +121,7 @@ extern "C" { #include #include "UICaboodle/BrowserView.h" +#include "SDURLCache/SDURLCache.h" #include "substrate.h" /* }}} */ @@ -1196,7 +1197,6 @@ bool isSectionVisible(NSString *section) { - (void) syncData; - (void) showSettings; - (UIProgressHUD *) addProgressHUD; -- (BOOL) hudIsShowing; - (void) removeProgressHUD:(UIProgressHUD *)hud; - (CYViewController *) pageForPackage:(NSString *)name; - (PackageController *) packageController; @@ -2206,7 +2206,6 @@ struct PackageNameOrdering : _end _profile(Package$initWithVersion$Cache) - id_.set(NULL, iterator.Name()); name_.set(NULL, iterator.Display()); latest_.set(NULL, StripVersion_(version_.VerStr())); @@ -2216,19 +2215,6 @@ struct PackageNameOrdering : installed_.set(NULL, StripVersion_(current.VerStr())); _end - _profile(Package$initWithVersion$Lower) - // XXX: do not use tolower() as this is not locale-specific? :( - char *data(id_.data()); - for (size_t i(0), e(id_.size()); i != e; ++i) - if ((data[i] & 0x20) == 0) { - id_.copy(pool); - data = id_.data(); - for (; i != e; ++i) - data[i] |= 0x20; - break; - } - _end - _profile(Package$initWithVersion$Tags) pkgCache::TagIterator tag(iterator.TagList()); if (!tag.end()) { @@ -2253,9 +2239,19 @@ struct PackageNameOrdering : _end _profile(Package$initWithVersion$Metadata) - PackageValue *metadata(PackageFind(id_.data(), id_.size())); + const char *mixed(iterator.Name()); + size_t size(strlen(mixed)); + char lower[size + 1]; + + for (size_t i(0); i != size; ++i) + lower[i] = mixed[i] | 0x20; + lower[size] = '\0'; + + PackageValue *metadata(PackageFind(lower, size)); metadata_ = metadata; + id_.set(NULL, metadata->name_, size); + const char *latest(version_.VerStr()); size_t length(strlen(latest)); @@ -5418,6 +5414,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { UITableViewDelegate > { _transient Database *database_; + unsigned era_; NSMutableArray *packages_; NSMutableArray *sections_; UITableView *list_; @@ -5475,11 +5472,15 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (Package *) packageAtIndexPath:(NSIndexPath *)path { +@synchronized (database_) { + if ([database_ era] != era_) + return nil; + Section *section([sections_ objectAtIndex:[path section]]); NSInteger row([path row]); Package *package([packages_ objectAtIndex:([section row] + row)]); - return package; -} + return [[package retain] autorelease]; +} } - (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path { PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]); @@ -5544,6 +5545,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) reloadData { + era_ = [database_ era]; NSArray *packages = [database_ packages]; [packages_ removeAllObjects]; @@ -6670,7 +6672,7 @@ freeing the view controllers on tab change */ } - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { - return ![updatedelegate_ hudIsShowing] && (IsWildcat_ || orientation == UIInterfaceOrientationPortrait); + return IsWildcat_ || orientation == UIInterfaceOrientationPortrait; } - (void) setUpdate:(NSDate *)date { @@ -7249,6 +7251,7 @@ freeing the view controllers on tab change */ UITableViewDelegate > { _transient Database *database_; + unsigned era_; CFMutableArrayRef packages_; NSMutableArray *sections_; UITableView *list_; @@ -7306,10 +7309,14 @@ freeing the view controllers on tab change */ } - (Package *) packageAtIndexPath:(NSIndexPath *)path { +@synchronized (database_) { + if ([database_ era] != era_) + return nil; + Section *section([sections_ objectAtIndex:[path section]]); NSInteger row([path row]); - return [self packageAtIndex:([section row] + row)]; -} + return [[[self packageAtIndex:([section row] + row)] retain] autorelease]; +} } - (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path { PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]); @@ -7376,6 +7383,7 @@ freeing the view controllers on tab change */ } - (void) reloadData { + era_ = [database_ era]; NSArray *packages = [database_ packages]; CFArrayRemoveAllValues(packages_); @@ -7980,7 +7988,7 @@ typedef enum { Database *database_; int tag_; - int hudcount_; + unsigned locked_; NSURL *starturl_; SectionsController *sections_; @@ -8356,9 +8364,12 @@ static _finline void _setHomePage(Cydia *self) { withObject:nil title:UCLocalize("RUNNING") ]; + + ++locked_; } - (void) progressControllerIsComplete:(ProgressController *)progress { + --locked_; [self complete]; } @@ -8545,13 +8556,10 @@ static _finline void _setHomePage(Cydia *self) { [super applicationWillSuspend]; } -- (BOOL) hudIsShowing { - return (hudcount_ > 0); -} - -- (void) applicationSuspend:(__GSEvent *)event { +- (BOOL) isSafeToSuspend { // Use external process status API internally. // This is probably a really bad idea. + // XXX: what is the point of this? does this solve anything at all? uint64_t status = 0; int notify_token; if (notify_register_check("com.saurik.Cydia.status", ¬ify_token) == NOTIFY_STATUS_OK) { @@ -8559,17 +8567,21 @@ static _finline void _setHomePage(Cydia *self) { notify_cancel(notify_token); } - if (![self hudIsShowing] && status == 0) + return locked_ == 0 && status == 0; +} + +- (void) applicationSuspend:(__GSEvent *)event { + if ([self isSafeToSuspend]) [super applicationSuspend:event]; } - (void) _animateSuspension:(BOOL)arg0 duration:(double)arg1 startTime:(double)arg2 scale:(float)arg3 { - if (![self hudIsShowing]) + if ([self isSafeToSuspend]) [super _animateSuspension:arg0 duration:arg1 startTime:arg2 scale:arg3]; } - (void) _setSuspended:(BOOL)value { - if (![self hudIsShowing]) + if ([self isSafeToSuspend]) [super _setSuspended:value]; } @@ -8584,7 +8596,7 @@ static _finline void _setHomePage(Cydia *self) { while ([target modalViewController] != nil) target = [target modalViewController]; [[target view] addSubview:hud]; - hudcount_++; + ++locked_; return hud; } @@ -8592,7 +8604,7 @@ static _finline void _setHomePage(Cydia *self) { [hud show:NO]; [hud removeFromSuperview]; [window_ setUserInteractionEnabled:YES]; - hudcount_--; + --locked_; } - (CYViewController *) pageForPackage:(NSString *)name { @@ -8688,6 +8700,7 @@ static _finline void _setHomePage(Cydia *self) { } - (void) addStashController { + ++locked_; stash_ = [[CYStashController alloc] init]; [window_ addSubview:[stash_ view]]; } @@ -8695,6 +8708,7 @@ static _finline void _setHomePage(Cydia *self) { - (void) removeStashController { [[stash_ view] removeFromSuperview]; [stash_ release]; + --locked_; } - (void) stash { @@ -8748,6 +8762,12 @@ static _finline void _setHomePage(Cydia *self) { - (void) applicationDidFinishLaunching:(id)unused { _trace(); + [NSURLCache setSharedURLCache:[[[SDURLCache alloc] + initWithMemoryCapacity:524288 + diskCapacity:10485760 + diskPath:[NSString stringWithFormat:@"%@/Library/Caches/com.saurik.Cydia/SDURLCache", @"/var/root"] + ] autorelease]]; + [CYBrowserController _initialize]; [NSURLProtocol registerClass:[CydiaURLProtocol class]];