+- (void) reorganize {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ //system("/usr/libexec/cydia/free.sh");
+ //[self performSelectorOnMainThread:@selector(finish) withObject:nil waitUntilDone:NO];
+ [pool release];
+}
+
+- (void) applicationSuspend:(__GSEvent *)event {
+ if (hud_ == nil && ![progress_ isRunning])
+ [super applicationSuspend:event];
+ _trace();
+}
+
+- (void) applicationDidFinishLaunching:(id)unused {
+ _assert(pkgInitConfig(*_config));
+ _assert(pkgInitSystem(*_config, _system));
+
+ confirm_ = nil;
+ tag_ = 1;
+
+ essential_ = [[NSMutableArray alloc] initWithCapacity:4];
+ broken_ = [[NSMutableArray alloc] initWithCapacity:4];
+
+ CGRect screenrect = [UIHardware fullScreenApplicationContentRect];
+ window_ = [[UIWindow alloc] initWithContentRect:screenrect];
+
+ [window_ orderFront: self];
+ [window_ makeKey: self];
+ [window_ _setHidden: NO];
+
+ database_ = [[Database alloc] init];
+ progress_ = [[ProgressView alloc] initWithFrame:[window_ bounds] database:database_ delegate:self];
+ [database_ setDelegate:progress_];
+ [window_ setContentView:progress_];
+
+ underlay_ = [[UIView alloc] initWithFrame:[progress_ bounds]];
+ [progress_ setContentView:underlay_];
+
+ [progress_ resetView];
+
+ if (
+ readlink("/Applications", NULL, 0) == -1 && errno == EINVAL ||
+ readlink("/usr/share", NULL, 0) == -1 && errno == EINVAL ||
+ readlink("/Library/Ringtones", NULL, 0) == -1 && errno == EINVAL ||
+ readlink("/Library/Wallpapers", NULL, 0) == -1 && errno == EINVAL
+ ) {
+ hud_ = [[UIProgressHUD alloc] initWithWindow:window_];
+ [hud_ setText:@"Reorganizing\nOne Minute!"];
+ [hud_ show:YES];
+ [underlay_ addSubview:hud_];
+
+ [self setStatusBarShowsProgress:YES];
+
+ [NSThread
+ detachNewThreadSelector:@selector(reorganize)
+ toTarget:self
+ withObject:nil
+ ];
+ } else
+ [self finish];
+}
+