From bd150f541dd0f3000aed7fbd16967980fb8e5123 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 20 Jul 2008 13:52:22 +0000 Subject: Checkpointing a bad Cydia build (why not?). --- Cydia.mm | 116 ++++++++++++++++++++++++++++++++++++++++++------------- Library/move.sh | 2 +- Library/space.sh | 2 +- Library/startup | 1 - 4 files changed, 91 insertions(+), 30 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index e6f8140..b100e59 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -2157,6 +2157,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); UITextLabel *status_; UIPushButton *close_; id delegate_; + BOOL running_; } - (void) transitionViewDidComplete:(UITransitionView*)view fromView:(UIView*)from toView:(UIView*)to; @@ -2169,6 +2170,8 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); - (void) _detachNewThreadData:(ProgressData *)data; - (void) detachNewThreadSelector:(SEL)selector toTarget:(id)target withObject:(id)object title:(NSString *)title; +- (BOOL) isRunning; + @end @protocol ProgressViewDelegate @@ -2339,6 +2342,9 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [overlay_ addSubview:close_]; [progress_ removeFromSuperview]; [status_ removeFromSuperview]; + + [delegate_ setStatusBarShowsProgress:NO]; + running_ = NO; } - (void) _detachNewThreadData:(ProgressData *)data { @@ -2364,6 +2370,9 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [overlay_ addSubview:progress_]; [overlay_ addSubview:status_]; + [delegate_ setStatusBarShowsProgress:YES]; + running_ = YES; + [transition_ transition:6 toView:overlay_]; [NSThread @@ -2473,6 +2482,10 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [output_ scrollRectToVisible:rect animated:YES]; } +- (BOOL) isRunning { + return NO; +} + @end /* }}} */ @@ -4892,6 +4905,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); unsigned tag_; UIKeyboard *keyboard_; + UIProgressHUD *hud_; InstallView *install_; ChangesView *changes_; @@ -5215,6 +5229,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); } - (void) applicationWillSuspend { + _trace(); [super applicationWillSuspend]; [database_ clean]; @@ -5241,36 +5256,19 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); } } -- (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]; +- (void) finish { + if (hud_ != nil) { + [self setStatusBarShowsProgress:NO]; - 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_]; + [hud_ show:NO]; + [hud_ removeFromSuperview]; + [hud_ autorelease]; + hud_ = nil; + } overlay_ = [[UIView alloc] initWithFrame:[underlay_ bounds]]; - if (!bootstrap_) - [underlay_ addSubview:overlay_]; - + CGRect screenrect = [UIHardware fullScreenApplicationContentRect]; book_ = [[CYBook alloc] initWithFrame:CGRectMake( 0, 0, screenrect.size.width, screenrect.size.height - 48 ) database:database_]; @@ -5368,7 +5366,9 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); manage_ = [[ManageView alloc] initWithBook:book_ database:database_]; search_ = [[SearchView alloc] initWithBook:book_ database:database_]; - [progress_ resetView]; + if (!bootstrap_) + [underlay_ addSubview:overlay_]; + [self reloadData]; if (bootstrap_) @@ -5377,6 +5377,68 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [self _setHomePage]; } +- (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]; +} + - (void) showKeyboard:(BOOL)show { CGSize keysize = [UIKeyboard defaultSize]; CGRect keydown = {{0, [overlay_ bounds].size.height}, keysize}; diff --git a/Library/move.sh b/Library/move.sh index 3cbe799..635c153 100755 --- a/Library/move.sh +++ b/Library/move.sh @@ -21,7 +21,7 @@ function mv_() { src=$1 mkdir -p /var/stash - dst=$(mktemp -d /var/stash/$(basename "${src}").XXXXXX) + dst=$(mktemp -d /var/stash/"${src##*/}".XXXXXX) if [[ -e ${src} ]]; then chmod --reference="${src}" "${dst}" diff --git a/Library/space.sh b/Library/space.sh index 953ae57..3be1f0d 100755 --- a/Library/space.sh +++ b/Library/space.sh @@ -8,5 +8,5 @@ for dir in \ /System/Library/TextInput \ /usr/share do - . /usr/libexec/cydia/move.sh -v "${dir}" + . /usr/libexec/cydia/move.sh "$@" "${dir}" done diff --git a/Library/startup b/Library/startup index 6efc471..7ee6cd3 100755 --- a/Library/startup +++ b/Library/startup @@ -1,7 +1,6 @@ #!/bin/bash export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin /usr/libexec/cydia/firmware.sh -/usr/libexec/cydia/space.sh debs=/var/root/Media/Cydia/AutoInstall/*.deb dpkg -i ${debs} rm -f ${debs} -- cgit v1.2.3