From a30c20bd2fa64ce4459d95d39d64b729563ed289 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 1 Jul 2008 16:52:27 +0000 Subject: [PATCH 01/16] UICaboodle could use _packed. --- UICaboodle/UICaboodle.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UICaboodle/UICaboodle.h b/UICaboodle/UICaboodle.h index e0b9af8f..2f636bd4 100644 --- a/UICaboodle/UICaboodle.h +++ b/UICaboodle/UICaboodle.h @@ -26,3 +26,6 @@ while (false) #define _label__(x) _label ## x #define _label_(y) _label__(y) #define _label _label_(__LINE__) + +#define _packed \ + __attribute__((packed)) -- 2.47.2 From aa5e5990e17da617b0e95c962e86924bc9b99b50 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 11 Jul 2008 23:18:30 +0000 Subject: [PATCH 02/16] Stash folders were supposed to be named, added support for Pwnage 2.0, bootup sysctl -w hack, just deleting the stupid package caches, and resurrected some of the Source editor. --- Cydia.mm | 285 +++++++++++++++++- .../com.saurik.Cydia.Startup | 4 +- Library/move.sh | 2 +- Library/startup | 6 + 4 files changed, 285 insertions(+), 12 deletions(-) rename Library/com.saurik.Cydia.Firmware => LaunchDaemons/com.saurik.Cydia.Startup (74%) create mode 100755 Library/startup diff --git a/Cydia.mm b/Cydia.mm index 129ba0eb..975c184f 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -3772,6 +3772,235 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); @end +/* Source Cell {{{ */ +@interface SourceCell : UITableCell { + UITextLabel *description_; + UIRightTextLabel *label_; + UITextLabel *origin_; +} + +- (void) dealloc; + +- (SourceCell *) initWithSource:(Source *)source; + +- (void) _setSelected:(float)fraction; +- (void) setSelected:(BOOL)selected; +- (void) setSelected:(BOOL)selected withFade:(BOOL)fade; +- (void) _setSelectionFadeFraction:(float)fraction; + +@end + +@implementation SourceCell + +- (void) dealloc { + [description_ release]; + [label_ release]; + [origin_ release]; + [super dealloc]; +} + +- (SourceCell *) initWithSource:(Source *)source { + if ((self = [super init]) != nil) { + GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 20); + GSFontRef small = GSFontCreateWithName("Helvetica", kGSFontTraitNone, 14); + + CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); + float clear[] = {0, 0, 0, 0}; + + NSString *description = [source description]; + if (description == nil) + description = [source uri]; + + description_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 7, 270, 25)]; + [description_ setBackgroundColor:CGColorCreate(space, clear)]; + [description_ setFont:bold]; + [description_ setText:description]; + + NSString *label = [source label]; + if (label == nil) + label = [source type]; + + label_ = [[UIRightTextLabel alloc] initWithFrame:CGRectMake(290, 32, 90, 25)]; + [label_ setBackgroundColor:CGColorCreate(space, clear)]; + [label_ setFont:small]; + [label_ setText:label]; + + NSString *origin = [source origin]; + if (origin == nil) + origin = [source distribution]; + + origin_ = [[UITextLabel alloc] initWithFrame:CGRectMake(13, 35, 315, 20)]; + [origin_ setBackgroundColor:CGColorCreate(space, clear)]; + [origin_ setFont:small]; + [origin_ setText:origin]; + + [self addSubview:description_]; + [self addSubview:label_]; + [self addSubview:origin_]; + + CFRelease(small); + CFRelease(bold); + } return self; +} + +- (void) _setSelected:(float)fraction { + CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); + + float black[] = { + Interpolate(0.0, 1.0, fraction), + Interpolate(0.0, 1.0, fraction), + Interpolate(0.0, 1.0, fraction), + 1.0}; + + float blue[] = { + Interpolate(0.2, 1.0, fraction), + Interpolate(0.2, 1.0, fraction), + Interpolate(1.0, 1.0, fraction), + 1.0}; + + float gray[] = { + Interpolate(0.4, 1.0, fraction), + Interpolate(0.4, 1.0, fraction), + Interpolate(0.4, 1.0, fraction), + 1.0}; + + [description_ setColor:CGColorCreate(space, black)]; + [label_ setColor:CGColorCreate(space, blue)]; + [origin_ setColor:CGColorCreate(space, gray)]; +} + +- (void) setSelected:(BOOL)selected { + [self _setSelected:(selected ? 1.0 : 0.0)]; + [super setSelected:selected]; +} + +- (void) setSelected:(BOOL)selected withFade:(BOOL)fade { + if (!fade) + [self _setSelected:(selected ? 1.0 : 0.0)]; + [super setSelected:selected withFade:fade]; +} + +- (void) _setSelectionFadeFraction:(float)fraction { + [self _setSelected:fraction]; + [super _setSelectionFadeFraction:fraction]; +} + +@end +/* }}} */ +/* Source Table {{{ */ +@interface SourceTable : RVPage { + _transient Database *database_; + UISectionList *list_; + NSMutableArray *sources_; + UIAlertSheet *alert_; +} + +- (id) initWithBook:(RVBook *)book database:(Database *)database; + +@end + +@implementation SourceTable + +- (void) dealloc { + [list_ setDataSource:nil]; + + if (sources_ != nil) + [sources_ release]; + [list_ release]; + [super dealloc]; +} + +- (int) numberOfSectionsInSectionList:(UISectionList *)list { + return 1; +} + +- (NSString *) sectionList:(UISectionList *)list titleForSection:(int)section { + return @"Sources"; +} + +- (int) sectionList:(UISectionList *)list rowForSection:(int)section { + return 0; +} + +- (int) numberOfRowsInTable:(UITable *)table { + return [sources_ count]; +} + +- (float) table:(UITable *)table heightForRow:(int)row { + return 64; +} + +- (UITableCell *) table:(UITable *)table cellForRow:(int)row column:(UITableColumn *)col { + return [[[SourceCell alloc] initWithSource:[sources_ objectAtIndex:row]] autorelease]; +} + +- (BOOL) table:(UITable *)table showDisclosureForRow:(int)row { + return NO; +} + +- (void) tableRowSelected:(NSNotification*)notification { + UITable *table([list_ table]); + int row([table selectedRow]); + if (row == INT_MAX) + return; + + [table selectRow:-1 byExtendingSelection:NO withFade:YES]; +} + +- (id) initWithBook:(RVBook *)book database:(Database *)database { + if ((self = [super initWithBook:book]) != nil) { + database_ = database; + sources_ = nil; + + list_ = [[UISectionList alloc] initWithFrame:[self bounds]]; + + [self addSubview:list_]; + + [list_ setDataSource:self]; + [list_ setShouldHideHeaderInShortLists:NO]; + + UITableColumn *column = [[UITableColumn alloc] + initWithTitle:@"Name" + identifier:@"name" + width:[self frame].size.width + ]; + + UITable *table = [list_ table]; + [table setSeparatorStyle:1]; + [table addTableColumn:column]; + [table setDelegate:self]; + } return self; +} + +- (void) reloadData { + pkgSourceList list; + _assert(list.ReadMainList()); + + if (sources_ != nil) + [sources_ release]; + + sources_ = [[NSMutableArray arrayWithCapacity:16] retain]; + for (pkgSourceList::const_iterator source = list.begin(); source != list.end(); ++source) + [sources_ addObject:[[[Source alloc] initWithMetaIndex:*source] autorelease]]; + + [list_ reloadData]; +} + +- (void) resetViewAnimated:(BOOL)animated { + [list_ resetViewAnimated:animated]; +} + +- (NSString *) leftTitle { + return @"Refresh All"; +} + +- (NSString *) rightTitle { + return @"Edit"; +} + +@end +/* }}} */ + /* Install View {{{ */ @interface InstallView : RVPage { _transient Database *database_; @@ -4122,7 +4351,10 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); @end /* }}} */ /* Manage View {{{ */ -@interface ManageView : PackageTable { +@interface ManageView : RVPage { + _transient Database *database_; + PackageTable *packages_; + SourceTable *sources_; } - (id) initWithBook:(RVBook *)book database:(Database *)database; @@ -4131,23 +4363,49 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); @implementation ManageView +- (void) dealloc { + [packages_ release]; + [sources_ release]; + [super dealloc]; +} + - (id) initWithBook:(RVBook *)book database:(Database *)database { - if ((self = [super - initWithBook:book - database:database - title:nil - filter:@selector(isInstalledInSection:) - with:nil - ]) != nil) { + if ((self = [super initWithBook:book]) != nil) { + database_ = database; + + packages_ = [[PackageTable alloc] + initWithBook:book + database:database + title:nil + filter:@selector(isInstalledInSection:) + with:nil + ]; + + sources_ = [[SourceTable alloc] + initWithBook:book + database:database + ]; + + [self addSubview:packages_]; } return self; } +- (void) resetViewAnimated:(BOOL)animated { + [packages_ resetViewAnimated:animated]; + [sources_ resetViewAnimated:animated]; +} + +- (void) reloadData { + [packages_ reloadData]; + [sources_ reloadData]; +} + - (NSString *) title { return @"Installed Packages"; } - (NSString *) backButtonTitle { - return @"All Packages"; + return @"Packages"; } @end @@ -5187,6 +5445,15 @@ int main(int argc, char *argv[]) { setuid(0); setgid(0); + int error; + + error = unlink("/var/cache/apt/pkgcache.bin"); + if (error != 0) + _assert(error == ENOENT); + error = unlink("/var/cache/apt/srcpkgcache.bin"); + if (error != 0) + _assert(error == ENOENT); + /*Method alloc = class_getClassMethod([NSObject class], @selector(alloc)); alloc_ = alloc->method_imp; alloc->method_imp = (IMP) &Alloc_;*/ diff --git a/Library/com.saurik.Cydia.Firmware b/LaunchDaemons/com.saurik.Cydia.Startup similarity index 74% rename from Library/com.saurik.Cydia.Firmware rename to LaunchDaemons/com.saurik.Cydia.Startup index 6fdcf33e..0a94d2e0 100644 --- a/Library/com.saurik.Cydia.Firmware +++ b/LaunchDaemons/com.saurik.Cydia.Startup @@ -3,9 +3,9 @@ Label - com.saurik.Cydia.Firmware + com.saurik.Cydia.Startup Program - /usr/libexec/cydia/firmware.sh + /usr/libexec/cydia/startup RunAtLoad diff --git a/Library/move.sh b/Library/move.sh index f264dcdd..0b9e09d2 100755 --- a/Library/move.sh +++ b/Library/move.sh @@ -14,7 +14,7 @@ function mv_() { src=$1 mkdir -p /var/stash - dst=$(mktemp -d /var/stash/$(basename "${dir}").XXXXXX) + dst=$(mktemp -d /var/stash/$(basename "${src}").XXXXXX) if [[ -e ${src} ]]; then chmod --reference="${src}" "${dst}" diff --git a/Library/startup b/Library/startup new file mode 100755 index 00000000..b75654f3 --- /dev/null +++ b/Library/startup @@ -0,0 +1,6 @@ +#!/bin/bash +sysctl -w security.mac.proc_enforce=0 security.mac.vnode_enforce=0 &>/dev/null +/usr/libexec/cydia/firmware.sh +for deb in /var/mobile/Media/Cydia/AutoInstall/*.deb; do + /usr/bin/dpkg -i "${deb}" && /bin/rm "${deb}" +done -- 2.47.2 From aa629131c0a605bd5e2c716a6cadca5a3badf500 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 13 Jul 2008 11:41:31 +0000 Subject: [PATCH 03/16] OMG I AM STUPID --- Cydia.mm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index 975c184f..27113ffc 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -5445,14 +5445,10 @@ int main(int argc, char *argv[]) { setuid(0); setgid(0); - int error; - - error = unlink("/var/cache/apt/pkgcache.bin"); - if (error != 0) - _assert(error == ENOENT); - error = unlink("/var/cache/apt/srcpkgcache.bin"); - if (error != 0) - _assert(error == ENOENT); + if (unlink("/var/cache/apt/pkgcache.bin") == -1) + _assert(errno == ENOENT); + if (unlink("/var/cache/apt/srcpkgcache.bin") == -1) + _assert(errno == ENOENT); /*Method alloc = class_getClassMethod([NSObject class], @selector(alloc)); alloc_ = alloc->method_imp; -- 2.47.2 From f5ba824fce801461fd4b4d9749aa9d4382f6ce81 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 13 Jul 2008 11:43:15 +0000 Subject: [PATCH 04/16] Fixed filename of launchdaemon. --- .../{com.saurik.Cydia.Startup => com.saurik.Cydia.Startup.plist} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LaunchDaemons/{com.saurik.Cydia.Startup => com.saurik.Cydia.Startup.plist} (100%) diff --git a/LaunchDaemons/com.saurik.Cydia.Startup b/LaunchDaemons/com.saurik.Cydia.Startup.plist similarity index 100% rename from LaunchDaemons/com.saurik.Cydia.Startup rename to LaunchDaemons/com.saurik.Cydia.Startup.plist -- 2.47.2 From a781cf0d59966f9a6ada482efddc1c1b2990c92b Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 13 Jul 2008 12:18:54 +0000 Subject: [PATCH 05/16] Fixed dependencies during AutioInstall. --- Library/startup | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/startup b/Library/startup index b75654f3..552dcb0b 100755 --- a/Library/startup +++ b/Library/startup @@ -1,6 +1,7 @@ #!/bin/bash +export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin sysctl -w security.mac.proc_enforce=0 security.mac.vnode_enforce=0 &>/dev/null /usr/libexec/cydia/firmware.sh -for deb in /var/mobile/Media/Cydia/AutoInstall/*.deb; do - /usr/bin/dpkg -i "${deb}" && /bin/rm "${deb}" -done +debs=/var/root/Media/Cydia/AutoInstall/*.deb +dpkg -i ${debs} +rm -f ${debs} -- 2.47.2 From a0376fc1d4363de162d93b372b3aaed7d7415632 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 19 Jul 2008 23:28:55 +0000 Subject: [PATCH 06/16] Fixed browser links and modify delegates. --- Cydia.mm | 75 +++++++++++++++++++++++++++++----------- UICaboodle/BrowserView.h | 2 ++ 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index 27113ffc..26a92759 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -3517,6 +3517,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); } - (void) loadRequest:(NSURLRequest *)request { + pushed_ = true; [webview_ loadRequest:request]; } @@ -3538,27 +3539,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [self view:sender didSetFrame:frame]; } -- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource { - return [self _addHeadersToRequest:request]; -} - -- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request { - if ([[[request URL] scheme] isEqualToString:@"apptapp"]) - return nil; - [self setBackButtonTitle:title_]; - BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease]; - [browser setDelegate:delegate_]; - [book_ pushPage:browser]; - [browser loadRequest:[self _addHeadersToRequest:request]]; - return [browser webView]; -} - -- (void) webView:(WebView *)sender willClickElement:(id)element { - if (![element respondsToSelector:@selector(href)]) - return; - NSString *href = [element href]; - if (href == nil) - return; +- (void) getAppTapp:(NSString *)href { if ([href hasPrefix:@"apptapp://package/"]) { NSString *name = [href substringFromIndex:18]; Package *package = [database_ packageWithName:name]; @@ -3586,6 +3567,48 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); } } +- (void) webView:(WebView *)sender willClickElement:(id)element { + if (![element respondsToSelector:@selector(href)]) + return; + NSString *href = [element href]; + if (href == nil) + return; + if ([href hasPrefix:@"apptapp://package/"]) + [self getAppTapp:href]; +} + +- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource { + if ([[[request URL] scheme] isEqualToString:@"apptapp"]) { + [self getAppTapp:[[request URL] absoluteString]]; + return nil; + } + + if (!pushed_) { + pushed_ = true; + [book_ pushPage:self]; + } + + return [self _addHeadersToRequest:request]; +} + +- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request { + if (request != nil && [[[request URL] scheme] isEqualToString:@"apptapp"]) + return nil; + else { + [self setBackButtonTitle:title_]; + + BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease]; + [browser setDelegate:delegate_]; + + if (request != nil) { + [browser loadRequest:[self _addHeadersToRequest:request]]; + [book_ pushPage:browser]; + } + + return [browser webView]; + } +} + - (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame { title_ = [title retain]; [self setTitle:title]; @@ -3752,6 +3775,10 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); - (void) resetViewAnimated:(BOOL)animated { } +- (void) setPushed:(bool)pushed { + pushed_ = pushed; +} + @end /* }}} */ @@ -4408,6 +4435,12 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); return @"Packages"; } +- (void) setDelegate:(id)delegate { + [super setDelegate:delegate]; + [packages_ setDelegate:delegate]; + [sources_ setDelegate:delegate]; +} + @end /* }}} */ /* Search View {{{ */ diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h index a58a5b7b..c9a1f7d7 100644 --- a/UICaboodle/BrowserView.h +++ b/UICaboodle/BrowserView.h @@ -21,6 +21,8 @@ NSString *title_; bool loading_; bool reloading_; + + bool pushed_; } - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy; -- 2.47.2 From 717d8c858e632b9f27f6f1c300ec36820f32b13a Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 19 Jul 2008 23:29:35 +0000 Subject: [PATCH 07/16] Fixed a stupid WiFi breaking issues (thanks a ton Apple...). --- Library/startup | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/startup b/Library/startup index 552dcb0b..7ee6cd3e 100755 --- a/Library/startup +++ b/Library/startup @@ -1,6 +1,5 @@ #!/bin/bash export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin -sysctl -w security.mac.proc_enforce=0 security.mac.vnode_enforce=0 &>/dev/null /usr/libexec/cydia/firmware.sh debs=/var/root/Media/Cydia/AutoInstall/*.deb dpkg -i ${debs} -- 2.47.2 From dc548dd13fc3f1ce1cdfc4b71783c127399898f2 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 19 Jul 2008 23:57:19 +0000 Subject: [PATCH 08/16] Fixed exit launchctl on 2.0. --- Cydia.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index 26a92759..0382a7ee 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -5219,17 +5219,23 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [database_ clean]; - if (reload_) { + if (true) { pid_t pid = ExecFork(); if (pid == 0) { +#ifndef __OBJC2__ sleep(1); - if (pid_t child = fork()) +#endif + + if (pid_t child = fork()) { waitpid(child, NULL, 0); - else { + } else { execlp("launchctl", "launchctl", "unload", SpringBoard_, NULL); + perror("launchctl unload"); exit(0); } + execlp("launchctl", "launchctl", "load", SpringBoard_, NULL); + perror("launchctl load"); exit(0); } } -- 2.47.2 From 1ef3da8cf14a6f67b04a4c38b76fd59010d11700 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 20 Jul 2008 00:00:24 +0000 Subject: [PATCH 09/16] Removed some stupid debugging logic ;P. --- Cydia.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cydia.mm b/Cydia.mm index 0382a7ee..e6f81400 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -5219,7 +5219,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [database_ clean]; - if (true) { + if (reload_) { pid_t pid = ExecFork(); if (pid == 0) { #ifndef __OBJC2__ -- 2.47.2 From d4b6208d03a2b0521c9770ed931115bc88db1eb6 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 20 Jul 2008 05:09:31 +0000 Subject: [PATCH 10/16] Dealing with disk space issues. --- Library/move.sh | 11 +++++++++-- Library/space.sh | 12 ++++++++++++ Library/startup | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 Library/space.sh diff --git a/Library/move.sh b/Library/move.sh index 0b9e09d2..3cbe7994 100755 --- a/Library/move.sh +++ b/Library/move.sh @@ -2,6 +2,13 @@ shopt -s extglob nullglob +if [[ ${1:0:1} == - ]]; then + v=$1 + shift 1 +else + v= +fi + function df_() { free=$(df -B1 "$1") free=${free% *%*} @@ -20,12 +27,12 @@ function mv_() { chmod --reference="${src}" "${dst}" chown --reference="${src}" "${dst}" - cp -aT "${src}" "${dst}" || { + cp -aT $v "${src}" "${dst}" || { rm -rf "${dst}" exit 1 } - rm -rf "${src}" + rm -rf $v "${src}" else chmod 775 "${dst}" chown root.admin "${dst}" diff --git a/Library/space.sh b/Library/space.sh new file mode 100755 index 00000000..953ae579 --- /dev/null +++ b/Library/space.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +for dir in \ + /Applications \ + /Library/Ringtones \ + /Library/Wallpaper \ + /System/Library/Fonts \ + /System/Library/TextInput \ + /usr/share +do + . /usr/libexec/cydia/move.sh -v "${dir}" +done diff --git a/Library/startup b/Library/startup index 7ee6cd3e..6efc471d 100755 --- a/Library/startup +++ b/Library/startup @@ -1,6 +1,7 @@ #!/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} -- 2.47.2 From bd150f541dd0f3000aed7fbd16967980fb8e5123 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 20 Jul 2008 13:52:22 +0000 Subject: [PATCH 11/16] 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 e6f81400..b100e59b 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 3cbe7994..635c1539 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 953ae579..3be1f0d4 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 6efc471d..7ee6cd3e 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} -- 2.47.2 From e64882de7837474aab0fd108a480b7ee2ead46a6 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 20 Jul 2008 14:11:55 +0000 Subject: [PATCH 12/16] Finished HUD interface. --- Cydia.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index b100e59b..64ba78a1 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -5379,8 +5379,8 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); - (void) reorganize { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - //system("/usr/libexec/cydia/free.sh"); - //[self performSelectorOnMainThread:@selector(finish) withObject:nil waitUntilDone:NO]; + system("/usr/libexec/cydia/free.sh"); + [self performSelectorOnMainThread:@selector(finish) withObject:nil waitUntilDone:NO]; [pool release]; } @@ -5424,7 +5424,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); readlink("/Library/Wallpapers", NULL, 0) == -1 && errno == EINVAL ) { hud_ = [[UIProgressHUD alloc] initWithWindow:window_]; - [hud_ setText:@"Reorganizing\nOne Minute!"]; + [hud_ setText:@"Reorganizing\nOne Minute!\nPlease Wait...\nDO NOT STOP"]; [hud_ show:YES]; [underlay_ addSubview:hud_]; -- 2.47.2 From f9d1e9a0e6d987d713b7ee0b83ea262944115491 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 20 Jul 2008 14:19:32 +0000 Subject: [PATCH 13/16] I hate SpringBoard ;P. --- Cydia.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cydia.mm b/Cydia.mm index 64ba78a1..a9ad0dcb 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -5264,6 +5264,10 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [hud_ removeFromSuperview]; [hud_ autorelease]; hud_ = nil; + + reload_ = true; + [self suspendWithAnimation:YES]; + return; } overlay_ = [[UIView alloc] initWithFrame:[underlay_ bounds]]; -- 2.47.2 From 74370d2dd405035ced068f92bc8f36f2f7c51c59 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 20 Jul 2008 14:32:41 +0000 Subject: [PATCH 14/16] OMG, I forgot a file. --- Library/free.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 Library/free.sh diff --git a/Library/free.sh b/Library/free.sh new file mode 100755 index 00000000..b18b9fd5 --- /dev/null +++ b/Library/free.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +for dir in \ + /usr/share \ + /Applications \ + /Library/Wallpaper \ + /Library/Ringtones \ +; do + . /usr/libexec/cydia/move.sh "$@" "${dir}" +done -- 2.47.2 From eeb9b1124a630aaa8c4f52ca4ac4d77fd1070732 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 22 Jul 2008 15:11:27 +0000 Subject: [PATCH 15/16] I hate doing this. --- Cydia.mm | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index a9ad0dcb..f3057b38 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -1738,18 +1738,50 @@ NSString *Scour(const char *field, const char *begin, const char *end) { [before addObject:[NSString stringWithUTF8String:(*source)->GetURI().c_str()]]; } - if (fetcher_->Run(PulseInterval_) != pkgAcquire::Continue) + if (fetcher_->Run(PulseInterval_) != pkgAcquire::Continue) { + _trace(); return; + } + + bool failed = false; + for (pkgAcquire::ItemIterator item = fetcher_->ItemsBegin(); item != fetcher_->ItemsEnd(); item++) { + if ((*item)->Status == pkgAcquire::Item::StatDone && (*item)->Complete) + continue; + + std::string uri = (*item)->DescURI(); + std::string error = (*item)->ErrorText; + + fprintf(stderr, "pAf:%s:%s\n", uri.c_str(), error.c_str()); + failed = true; + + [delegate_ performSelectorOnMainThread:@selector(_setProgressError:) + withObject:[NSArray arrayWithObjects:[NSString stringWithUTF8String:error.c_str()], nil] + waitUntilDone:YES + ]; + } + + if (failed) { + _trace(); + return; + } _system->UnLock(); pkgPackageManager::OrderResult result = manager_->DoInstall(statusfd_); - if (result == pkgPackageManager::Failed) + if (_error->PendingError()) { + _trace(); return; - if (_error->PendingError()) + } + + if (result == pkgPackageManager::Failed) { + _trace(); return; - if (result != pkgPackageManager::Completed) + } + + if (result != pkgPackageManager::Completed) { + _trace(); return; + } NSMutableArray *after = [NSMutableArray arrayWithCapacity:16]; { pkgSourceList list; @@ -2344,6 +2376,8 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [status_ removeFromSuperview]; [delegate_ setStatusBarShowsProgress:NO]; + //[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; + running_ = NO; } @@ -5229,12 +5263,13 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); } - (void) applicationWillSuspend { - _trace(); - [super applicationWillSuspend]; - [database_ clean]; if (reload_) { +#ifdef __OBJC2__ + notify_post("com.apple.mobile.application_installed"); + notify_post("com.apple.mobile.application_uninstalled"); +#else pid_t pid = ExecFork(); if (pid == 0) { #ifndef __OBJC2__ @@ -5253,7 +5288,10 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); perror("launchctl load"); exit(0); } +#endif } + + [super applicationWillSuspend]; } - (void) finish { @@ -5391,7 +5429,6 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); - (void) applicationSuspend:(__GSEvent *)event { if (hud_ == nil && ![progress_ isRunning]) [super applicationSuspend:event]; - _trace(); } - (void) applicationDidFinishLaunching:(id)unused { -- 2.47.2 From c4ce98df82d3ed1c8f40dbb7cd10664218c87599 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 23 Jul 2008 19:07:44 +0000 Subject: [PATCH 16/16] Removed Reorganize (temporary) and sped up notify_post. --- Cydia.mm | 57 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index f3057b38..1f6e1755 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -2375,6 +2375,10 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [progress_ removeFromSuperview]; [status_ removeFromSuperview]; +#ifdef __OBJC2__ + notify_post("com.apple.mobile.application_installed"); +#endif + [delegate_ setStatusBarShowsProgress:NO]; //[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; @@ -2517,7 +2521,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); } - (BOOL) isRunning { - return NO; + return running_; } @end @@ -5262,34 +5266,33 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); tag_ = tag; } +- (void) fixSpringBoard { + pid_t pid = ExecFork(); + if (pid == 0) { + sleep(1); + + if (pid_t child = fork()) { + waitpid(child, NULL, 0); + } else { + execlp("launchctl", "launchctl", "unload", SpringBoard_, NULL); + perror("launchctl unload"); + exit(0); + } + + execlp("launchctl", "launchctl", "load", SpringBoard_, NULL); + perror("launchctl load"); + exit(0); + } +} + - (void) applicationWillSuspend { [database_ clean]; if (reload_) { -#ifdef __OBJC2__ - notify_post("com.apple.mobile.application_installed"); - notify_post("com.apple.mobile.application_uninstalled"); -#else - pid_t pid = ExecFork(); - if (pid == 0) { #ifndef __OBJC2__ - sleep(1); + [self fixSpringBoard]; #endif - - if (pid_t child = fork()) { - waitpid(child, NULL, 0); - } else { - execlp("launchctl", "launchctl", "unload", SpringBoard_, NULL); - perror("launchctl unload"); - exit(0); - } - - execlp("launchctl", "launchctl", "load", SpringBoard_, NULL); - perror("launchctl load"); - exit(0); - } -#endif - } +} [super applicationWillSuspend]; } @@ -5304,7 +5307,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); hud_ = nil; reload_ = true; - [self suspendWithAnimation:YES]; + [self fixSpringBoard]; return; } @@ -5458,11 +5461,11 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); [progress_ resetView]; - if ( + /*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 + readlink("/Library/Wallpaper", NULL, 0) == -1 && errno == EINVAL ) { hud_ = [[UIProgressHUD alloc] initWithWindow:window_]; [hud_ setText:@"Reorganizing\nOne Minute!\nPlease Wait...\nDO NOT STOP"]; @@ -5476,7 +5479,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$"); toTarget:self withObject:nil ]; - } else + } else*/ [self finish]; } -- 2.47.2