X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/471937c64902a6ef7bbc2b28bd51adf485e494fc..24fb80c19c6695f8a5f32d3492e30b07033ed8a1:/MobileCydia.mm diff --git a/MobileCydia.mm b/MobileCydia.mm index a9c4adaf..10c610a4 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -293,6 +293,7 @@ static _finline void UpdateExternalStatus(uint64_t newStatus) { @end /* }}} */ +/* Cydia Action Sheet {{{ */ @interface CYActionSheet : UIAlertView { unsigned button_; } @@ -339,6 +340,7 @@ static _finline void UpdateExternalStatus(uint64_t newStatus) { } @end +/* }}} */ /* NSForcedOrderingSearch doesn't work on the iPhone */ static const NSStringCompareOptions MatchCompareOptions_ = NSLiteralSearch | NSCaseInsensitiveSearch; @@ -380,12 +382,10 @@ static const CFStringCompareFlags LaxCompareFlags_ = kCFCompareCaseInsensitive | #define ForSaurik (0 && !ForRelease) #define LogBrowser (0 && !ForRelease) #define TrackResize (0 && !ForRelease) -#define ManualRefresh (0 && !ForRelease) +#define ManualRefresh (1 && !ForRelease) #define ShowInternals (0 && !ForRelease) #define IgnoreInstall (0 && !ForRelease) -#define RecycleWebViews 0 -#define RecyclePackageViews (0 && ForRelease) -#define AlwaysReload (1 && !ForRelease) +#define AlwaysReload (0 && !ForRelease) #if !TraceLogging #undef _trace @@ -1074,10 +1074,6 @@ static bool Changed_; static NSDate *now_; static bool IsWildcat_; - -#if RecycleWebViews -static NSMutableArray *Documents_; -#endif /* }}} */ /* Display Helpers {{{ */ @@ -3695,14 +3691,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return @"getPackageById"; else if (selector == @selector(installPackages:)) return @"installPackages"; - else if (selector == @selector(setAutoPopup:)) - return @"setAutoPopup"; else if (selector == @selector(setButtonImage:withStyle:toFunction:)) return @"setButtonImage"; else if (selector == @selector(setButtonTitle:withStyle:toFunction:)) return @"setButtonTitle"; - else if (selector == @selector(setFinishHook:)) - return @"setFinishHook"; else if (selector == @selector(setPopupHook:)) return @"setPopupHook"; else if (selector == @selector(setSpecial:)) @@ -3813,10 +3805,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [delegate_ performSelectorOnMainThread:@selector(installPackages:) withObject:packages waitUntilDone:NO]; } -- (void) setAutoPopup:(BOOL)popup { - [indirect_ setAutoPopup:popup]; -} - - (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function { [indirect_ setButtonImage:button withStyle:style toFunction:function]; } @@ -3838,10 +3826,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { Changed_ = true; } -- (void) setFinishHook:(id)function { - [indirect_ setFinishHook:function]; -} - - (void) setPopupHook:(id)function { [indirect_ setPopupHook:function]; } @@ -3887,8 +3871,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) setHeaders:(NSDictionary *)headers forHost:(NSString *)host { } -- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { - [super webView:sender didClearWindowObject:window forFrame:frame]; +- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { + [super webView:view didClearWindowObject:window forFrame:frame]; WebDataSource *source([frame dataSource]); NSURLResponse *response([source response]); @@ -3924,8 +3908,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [request setValue:Role_ forHTTPHeaderField:@"X-Role"]; } -- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source { - NSMutableURLRequest *copy = [request mutableCopy]; +- (NSURLRequest *) webView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source { + NSMutableURLRequest *copy([[super webView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source] mutableCopy]); [self _setMoreHeaders:copy]; return copy; } @@ -3939,7 +3923,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if ((self = [super initWithWidth:0 ofClass:[CYBrowserController class]]) != nil) { cydia_ = [[CydiaObject alloc] initWithDelegate:indirect_]; - WebView *webview([document_ webView]); + WebView *webview([[webview_ _documentView] webView]); Package *package([[Database sharedInstance] packageWithName:@"cydia"]); @@ -4015,15 +3999,18 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } } -- (id) invokeDefaultMethodWithArguments:(NSArray *)args { +- (void) _doContinue { [self dismissModalViewControllerAnimated:YES]; [delegate_ cancelAndClear:NO]; +} +- (id) invokeDefaultMethodWithArguments:(NSArray *)args { + [self performSelectorOnMainThread:@selector(_doContinue) withObject:nil waitUntilDone:NO]; return nil; } -- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { - [super webView:sender didClearWindowObject:window forFrame:frame]; +- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { + [super webView:view didClearWindowObject:window forFrame:frame]; [window setValue:changes_ forKey:@"changes"]; [window setValue:issues_ forKey:@"issues"]; [window setValue:sizes_ forKey:@"sizes"]; @@ -4299,7 +4286,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { CGRect prgrect = {{ (bounds.size.width - prgsize.width) / 2, - bounds.size.height - prgsize.height - 64 + bounds.size.height - prgsize.height - 20 }, prgsize}; float closewidth = bounds.size.width - 20; @@ -4308,7 +4295,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [progress_ setFrame:prgrect]; [status_ setFrame:CGRectMake( 10, - bounds.size.height - prgsize.height - 94, + bounds.size.height - prgsize.height - 50, bounds.size.width - 20, 24 )]; @@ -4316,11 +4303,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { 10, 20, bounds.size.width - 20, - bounds.size.height - 106 + bounds.size.height - 62 )]; [close_ setFrame:CGRectMake( (bounds.size.width - closewidth) / 2, - bounds.size.height - prgsize.height - 94, + bounds.size.height - prgsize.height - 50, closewidth, 32 + prgsize.height )]; @@ -4968,6 +4955,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } [self setAccessoryType:editing ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator]; + [self setSelectionStyle:editing ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleBlue]; + [content_ setNeedsDisplay]; } @@ -5134,6 +5123,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { NSString *name_; bool commercial_; NSMutableArray *buttons_; + UIBarButtonItem *button_; } - (id) initWithDatabase:(Database *)database; @@ -5148,7 +5138,12 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [package_ release]; if (name_ != nil) [name_ release]; + [buttons_ release]; + + if (button_ != nil) + [button_ release]; + [super dealloc]; } @@ -5186,12 +5181,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } } -- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { - return [super webView:sender didFinishLoadForFrame:frame]; -} - -- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { - [super webView:sender didClearWindowObject:window forFrame:frame]; +- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { + [super webView:view didClearWindowObject:window forFrame:frame]; [window setValue:package_ forKey:@"package"]; } @@ -5248,13 +5239,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (UIBarButtonItem *) rightButton { - int count = [buttons_ count]; - return [[[UIBarButtonItem alloc] - initWithTitle:count == 0 ? nil : count != 1 ? UCLocalize("MODIFY") : [buttons_ objectAtIndex:0] - style:UIBarButtonItemStylePlain - target:self - action:@selector(customButtonClicked) - ] autorelease]; + return button_; } #endif @@ -5297,30 +5282,24 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [buttons_ addObject:UCLocalize("REINSTALL")]; if (![package_ uninstalled]) [buttons_ addObject:UCLocalize("REMOVE")]; + } - if (special_ != NULL) { - CGRect frame([document_ frame]); - frame.size.height = 0; - [document_ setFrame:frame]; - - if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)]) - [scroller_ scrollPointVisibleAtTopLeft:CGPointZero]; - else - [scroller_ scrollRectToVisible:CGRectZero animated:NO]; - - WebThreadLock(); - [[[document_ webView] windowScriptObject] setValue:package_ forKey:@"package"]; - - [self setButtonTitle:nil withStyle:nil toFunction:nil]; - - [self setFinishHook:nil]; - [self setPopupHook:nil]; - WebThreadUnlock(); + if (button_ != nil) + [button_ release]; - //[self yieldToSelector:@selector(callFunction:) withObject:special_]; - [super callFunction:special_]; - } + NSString *title; + switch ([buttons_ count]) { + case 0: title = nil; break; + case 1: title = [buttons_ objectAtIndex:0]; break; + default: title = UCLocalize("MODIFY"); break; } + + button_ = [[UIBarButtonItem alloc] + initWithTitle:title + style:UIBarButtonItemStylePlain + target:self + action:@selector(customButtonClicked) + ]; } - (bool) isLoading { @@ -6321,6 +6300,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) _setMoreHeaders:(NSMutableURLRequest *)request { [super _setMoreHeaders:request]; + if (ChipID_ != nil) [request setValue:ChipID_ forHTTPHeaderField:@"X-Chip-ID"]; if (UniqueID_ != nil) @@ -6328,7 +6308,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) aboutButtonClicked { - UIAlertView *alert = [[[UIAlertView alloc] init] autorelease]; + UIAlertView *alert([[[UIAlertView alloc] init] autorelease]); + [alert setTitle:UCLocalize("ABOUT_CYDIA")]; [alert addButtonWithTitle:UCLocalize("CLOSE")]; [alert setCancelButtonIndex:0]; @@ -6345,24 +6326,22 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[self navigationController] setNavigationBarHidden:YES animated:animated]; + //[[self navigationController] setNavigationBarHidden:YES animated:animated]; } - (void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[self navigationController] setNavigationBarHidden:NO animated:animated]; + //[[self navigationController] setNavigationBarHidden:NO animated:animated]; } - (id) init { if ((self = [super init]) != nil) { - UIBarButtonItem *aboutItem = [[UIBarButtonItem alloc] + [[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithTitle:UCLocalize("ABOUT") style:UIBarButtonItemStylePlain target:self action:@selector(aboutButtonClicked) - ]; - [[self navigationItem] setLeftBarButtonItem:aboutItem]; - [aboutItem release]; + ] autorelease]]; } return self; } @@ -6787,6 +6766,9 @@ freeing the view controllers on tab change */ } - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (editing_) + return; + Section *section = [self sectionAtIndexPath:indexPath]; NSString *name = [section name]; NSString *title; @@ -7044,7 +7026,7 @@ freeing the view controllers on tab change */ - (void) refreshButtonClicked { [delegate_ beginUpdate]; - [[self navigationItem] setLeftBarButtonItem:nil]; + [[self navigationItem] setLeftBarButtonItem:nil animated:YES]; } - (void) upgradeButtonClicked { @@ -7096,7 +7078,7 @@ freeing the view controllers on tab change */ UIProgressHUD *hud([delegate_ addProgressHUD]); // XXX: localize [hud setText:@"Loading Changes"]; - NSLog(@"HUD:%@::%@", delegate_, hud); + //NSLog(@"HUD:%@::%@", delegate_, hud); [self yieldToSelector:@selector(_reloadPackages:) withObject:packages]; [delegate_ removeProgressHUD:hud]; @@ -7401,7 +7383,6 @@ freeing the view controllers on tab change */ @end /* }}} */ - /* Signature Controller {{{ */ @interface SignatureController : CYBrowserController { _transient Database *database_; @@ -7419,9 +7400,9 @@ freeing the view controllers on tab change */ [super dealloc]; } -- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { +- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { // XXX: dude! - [super webView:sender didClearWindowObject:window forFrame:frame]; + [super webView:view didClearWindowObject:window forFrame:frame]; } - (id) initWithDatabase:(Database *)database package:(NSString *)package { @@ -7438,6 +7419,7 @@ freeing the view controllers on tab change */ @end /* }}} */ + /* Role Controller {{{ */ @interface RoleController : CYViewController < UITableViewDataSource, @@ -7606,6 +7588,68 @@ freeing the view controllers on tab change */ else return nil; } +@end +/* }}} */ +/* Stash Controller {{{ */ +@interface CYStashController : CYViewController { + UIActivityIndicatorView *spinner_; + UILabel *status_; + UILabel *caption_; +} +@end + +@implementation CYStashController +- (id) init { + if ((self = [super init])) { + [[self view] setBackgroundColor:[UIColor viewFlipsideBackgroundColor]]; + + spinner_ = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + CGRect spinrect = [spinner_ frame]; + spinrect.origin.x = ([[self view] frame].size.width / 2) - (spinrect.size.width / 2); + spinrect.origin.y = [[self view] frame].size.height - 80.0f; + [spinner_ setFrame:spinrect]; + [spinner_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin]; + [[self view] addSubview:spinner_]; + [spinner_ release]; + [spinner_ startAnimating]; + + CGRect captrect; + captrect.size.width = [[self view] frame].size.width; + captrect.size.height = 40.0f; + captrect.origin.x = 0; + captrect.origin.y = ([[self view] frame].size.height / 2) - (captrect.size.height * 2); + caption_ = [[UILabel alloc] initWithFrame:captrect]; + [caption_ setText:@"Initializing Filesystem"]; + [caption_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin]; + [caption_ setFont:[UIFont boldSystemFontOfSize:28.0f]]; + [caption_ setTextColor:[UIColor whiteColor]]; + [caption_ setBackgroundColor:[UIColor clearColor]]; + [caption_ setShadowColor:[UIColor blackColor]]; + [caption_ setTextAlignment:UITextAlignmentCenter]; + [[self view] addSubview:caption_]; + [caption_ release]; + + CGRect statusrect; + statusrect.size.width = [[self view] frame].size.width; + statusrect.size.height = 30.0f; + statusrect.origin.x = 0; + statusrect.origin.y = ([[self view] frame].size.height / 2) - statusrect.size.height; + status_ = [[UILabel alloc] initWithFrame:statusrect]; + [status_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin]; + [status_ setText:@"(Cydia will exit when complete.)"]; + [status_ setFont:[UIFont systemFontOfSize:16.0f]]; + [status_ setTextColor:[UIColor whiteColor]]; + [status_ setBackgroundColor:[UIColor clearColor]]; + [status_ setShadowColor:[UIColor blackColor]]; + [status_ setTextAlignment:UITextAlignmentCenter]; + [[self view] addSubview:status_]; + [status_ release]; + } return self; +} + +- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { + return IsWildcat_ || orientation == UIInterfaceOrientationPortrait; +} @end /* }}} */ @@ -7659,7 +7703,7 @@ freeing the view controllers on tab change */ } - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { - return IsWildcat_; + return IsWildcat_ || orientation == UIInterfaceOrientationPortrait; } - (void) setTabBarController:(UITabBarController *)controller { @@ -7697,6 +7741,7 @@ freeing the view controllers on tab change */ } - (void) completeUpdate { + if (!updating_) return; updating_ = false; [self raiseBar:YES]; @@ -7705,8 +7750,10 @@ freeing the view controllers on tab change */ } - (void) cancelUpdate { - [refreshbar_ cancel]; - [self completeUpdate]; + updating_ = false; + [self raiseBar:YES]; + [refreshbar_ stop]; + [updatedelegate_ performSelector:@selector(updateData) withObject:nil afterDelay:0]; } - (void) cancelPressed { @@ -7882,7 +7929,6 @@ typedef enum { > { UIWindow *window_; CYContainer *container_; - id tabbar_; NSMutableArray *essential_; @@ -7903,9 +7949,7 @@ typedef enum { InstalledController *installed_; id queueDelegate_; -#if RecyclePackageViews - NSMutableArray *details_; -#endif + CYStashController *stash_; bool loaded_; } @@ -8010,6 +8054,30 @@ static _finline void _setHomePage(Cydia *self) { - (void) _refreshIfPossible { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + bool recently = false; + NSDate *update([Metadata_ objectForKey:@"LastUpdate"]); + if (update != nil) { + NSTimeInterval interval([update timeIntervalSinceNow]); + if (interval <= 0 && interval > -(15*60)) + recently = true; + } + + // Don't automatic refresh if: + // - We already refreshed recently. + // - We already auto-refreshed this launch. + // - Auto-refresh is disabled. + if (recently || loaded_ || ManualRefresh) { + [self performSelectorOnMainThread:@selector(_loaded) withObject:nil waitUntilDone:NO]; + + // If we are cancelling due to ManualRefresh or a recent refresh + // we need to make sure it knows it's already loaded. + loaded_ = true; + return; + } else { + // We are going to load, so remember that. + loaded_ = true; + } + SCNetworkReachabilityFlags flags; { SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(NULL, "cydia.saurik.com")); SCNetworkReachabilityGetFlags(reachability, &flags); @@ -8028,21 +8096,9 @@ static _finline void _setHomePage(Cydia *self) { ) ); - if (loaded_ || ManualRefresh || !reachable) loaded: - [self performSelectorOnMainThread:@selector(_loaded) withObject:nil waitUntilDone:NO]; - else { - loaded_ = true; - - NSDate *update([Metadata_ objectForKey:@"LastUpdate"]); - - if (update != nil) { - NSTimeInterval interval([update timeIntervalSinceNow]); - if (interval <= 0 && interval > -(15*60)) - goto loaded; - } - + // If we can reach the server, auto-refresh! + if (reachable) [container_ performSelectorOnMainThread:@selector(setUpdate:) withObject:update waitUntilDone:NO]; - } [pool release]; } @@ -8076,18 +8132,19 @@ static _finline void _setHomePage(Cydia *self) { } } + UITabBarItem *changesItem = [[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem]; if (changes != 0) { NSString *badge([[NSNumber numberWithInt:changes] stringValue]); - [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setBadgeValue:badge]; - [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setAnimatedBadge:YES]; + [changesItem setBadgeValue:badge]; + [changesItem setAnimatedBadge:[essential_ count] == 0]; if ([self respondsToSelector:@selector(setApplicationBadge:)]) [self setApplicationBadge:badge]; else [self setApplicationBadgeString:badge]; } else { - [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setBadgeValue:nil]; - [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setAnimatedBadge:NO]; + [changesItem setBadgeValue:nil]; + [changesItem setAnimatedBadge:NO]; if ([self respondsToSelector:@selector(removeApplicationBadge)]) [self removeApplicationBadge]; @@ -8343,10 +8400,6 @@ static _finline void _setHomePage(Cydia *self) { - (void) setPackageController:(PackageController *)view { WebThreadLock(); [view setPackage:nil]; -#if RecyclePackageViews - if ([details_ count] < 3) - [details_ addObject:view]; -#endif WebThreadUnlock(); } @@ -8355,25 +8408,7 @@ static _finline void _setHomePage(Cydia *self) { } - (PackageController *) packageController { -#if RecyclePackageViews - PackageController *view; - size_t count([details_ count]); - - if (count == 0) { - view = [self _packageController]; - renew: - [details_ addObject:[self _packageController]]; - } else { - view = [[[details_ lastObject] retain] autorelease]; - [details_ removeLastObject]; - if (count == 1) - goto renew; - } - - return view; -#else return [self _packageController]; -#endif } // Returns the navigation controller for the queuing badge. @@ -8467,9 +8502,16 @@ static _finline void _setHomePage(Cydia *self) { } - (void) applicationSuspend:(__GSEvent *)event { - // FIXME: This needs to be fixed, but we no longer have a progress_. - // What's the best solution? - if (hud_ == nil)// && ![progress_ isRunning]) + // Use external process status API internally. + // This is probably a really bad idea. + uint64_t status = 0; + int notify_token; + if (notify_register_check("com.saurik.Cydia.status", ¬ify_token) == NOTIFY_STATUS_OK) { + notify_get_state(notify_token, &status); + notify_cancel(notify_token); + } + + if (hud_ == nil && status == 0) [super applicationSuspend:event]; } @@ -8489,7 +8531,11 @@ static _finline void _setHomePage(Cydia *self) { [window_ setUserInteractionEnabled:NO]; [hud show:YES]; - [[container_ view] addSubview:hud]; + + UIViewController *target = container_; + while ([target modalViewController] != nil) target = [target modalViewController]; + [[target view] addSubview:hud]; + return hud; } @@ -8578,6 +8624,36 @@ static _finline void _setHomePage(Cydia *self) { [super applicationWillResignActive:application]; } +- (void) addStashController { + stash_ = [[CYStashController alloc] init]; + [window_ addSubview:[stash_ view]]; +} + +- (void) removeStashController { + [[stash_ view] removeFromSuperview]; + [stash_ release]; +} + +- (void) stash { + [self setIdleTimerDisabled:YES]; + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; + [self setStatusBarShowsProgress:YES]; + UpdateExternalStatus(1); + + [self yieldToSelector:@selector(system:) withObject:@"/usr/libexec/cydia/free.sh"]; + + UpdateExternalStatus(0); + [self setStatusBarShowsProgress:NO]; + + [self removeStashController]; + + if (ExecFork() == 0) { + execlp("launchctl", "launchctl", "stop", "com.apple.SpringBoard", NULL); + perror("launchctl stop"); + } +} + - (void) applicationDidFinishLaunching:(id)unused { [CYBrowserController _initialize]; @@ -8601,8 +8677,6 @@ static _finline void _setHomePage(Cydia *self) { [window_ makeKey:self]; [window_ setHidden:NO]; - database_ = [Database sharedInstance]; - if ( readlink("/Applications", NULL, 0) == -1 && errno == EINVAL || readlink("/Library/Ringtones", NULL, 0) == -1 && errno == EINVAL || @@ -8615,27 +8689,12 @@ static _finline void _setHomePage(Cydia *self) { //readlink("/var/lib", NULL, 0) == -1 && errno == EINVAL || false ) { - [self setIdleTimerDisabled:YES]; - - hud_ = [self addProgressHUD]; - [hud_ setText:@"Reorganizing:\n\nWill Automatically\nClose When Done"]; - [self setStatusBarShowsProgress:YES]; - - [self yieldToSelector:@selector(system:) withObject:@"/usr/libexec/cydia/free.sh"]; - - [self setStatusBarShowsProgress:NO]; - [self removeProgressHUD:hud_]; - hud_ = nil; - - if (ExecFork() == 0) { - execlp("launchctl", "launchctl", "stop", "com.apple.SpringBoard", NULL); - perror("launchctl stop"); - } - + [self addStashController]; + [self performSelector:@selector(stash) withObject:nil afterDelay:0]; return; } - _trace(); + database_ = [Database sharedInstance]; NSMutableArray *items([NSMutableArray arrayWithObjects: [[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage applicationImageNamed:@"home.png"] tag:kCydiaTag] autorelease], @@ -8669,6 +8728,9 @@ static _finline void _setHomePage(Cydia *self) { [container_ setTabBarController:tabbar_]; [window_ addSubview:[container_ view]]; + // Show pinstripes while loading data. + [[container_ view] setBackgroundColor:[UIColor performSelector:@selector(pinStripeColor)]]; + [self performSelector:@selector(loadData) withObject:nil afterDelay:0]; } @@ -8682,15 +8744,12 @@ static _finline void _setHomePage(Cydia *self) { [self reloadData]; -#if RecyclePackageViews - details_ = [[NSMutableArray alloc] initWithCapacity:4]; - [details_ addObject:[self _packageController]]; - [details_ addObject:[self _packageController]]; -#endif - PrintTimes(); _setHomePage(self); + + // XXX: does this actually slow anything down? + [[container_ view] setBackgroundColor:[UIColor clearColor]]; } - (void) showActionSheet:(UIActionSheet *)sheet fromItem:(UIBarButtonItem *)item { @@ -8931,10 +8990,6 @@ int main(int argc, char *argv[]) { _pooled } /* }}} */ -#if RecycleWebViews - Documents_ = [[[NSMutableArray alloc] initWithCapacity:4] autorelease]; -#endif - Finishes_ = [NSArray arrayWithObjects:@"return", @"reopen", @"restart", @"reload", @"reboot", nil]; if (substrate && access("/Library/MobileSubstrate/DynamicLibraries/SimulatedKeyEvents.dylib", F_OK) == 0)