X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/8944281a96724ef2fe20b0e07ea4e099be25afac..81bf90f6b33e7d58719923c8e1260bd2b4ff9907:/Cydia.mm diff --git a/Cydia.mm b/Cydia.mm index 71a57df9..a4b2e600 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -229,18 +229,13 @@ extern NSString * const kCAFilterNearest; @implementation PopTransitionView -- (void) transitionViewDidComplete:(UITransitionView*)view fromView:(UIView*)from toView:(UIView*)to { +- (void) transitionViewDidComplete:(UITransitionView *)view fromView:(UIView *)from toView:(UIView *)to { if (from != nil && to == nil) [self removeFromSuperview]; } @end -@interface UIView (PopUpView) -- (void) popFromSuperviewAnimated:(BOOL)animated; -- (void) popSubview:(UIView *)view; -@end - @implementation UIView (PopUpView) - (void) popFromSuperviewAnimated:(BOOL)animated { @@ -262,12 +257,17 @@ extern NSString * const kCAFilterNearest; #define lprintf(args...) fprintf(stderr, args) -#define ForRelease 0 +#define ForRelease 1 #define ForSaurik (1 && !ForRelease) #define IgnoreInstall (0 && !ForRelease) #define RecycleWebViews 0 #define AlwaysReload (1 && !ForRelease) +#if ForRelease +#undef _trace +#define _trace(args...) +#endif + /* Radix Sort {{{ */ @interface NSMutableArray (Radix) - (void) radixSortUsingSelector:(SEL)selector withObject:(id)object; @@ -617,9 +617,7 @@ static NSString *Home_; static BOOL Sounds_Keyboard_; static BOOL Advanced_; -#if !ForSaurik static BOOL Loaded_; -#endif static BOOL Ignored_; static UIFont *Font12_; @@ -640,7 +638,6 @@ bool reload_; static NSDictionary *SectionMap_; static NSMutableDictionary *Metadata_; -static NSMutableDictionary *Indices_; static _transient NSMutableDictionary *Settings_; static _transient NSString *Role_; static _transient NSMutableDictionary *Packages_; @@ -912,6 +909,7 @@ class Progress : - (pkgRecords *) records; - (pkgProblemResolver *) resolver; - (pkgAcquire &) fetcher; +- (pkgSourceList &) list; - (NSArray *) packages; - (NSArray *) sources; - (void) reloadData; @@ -971,24 +969,26 @@ class Progress : @implementation Source -- (void) dealloc { - [uri_ release]; - [distribution_ release]; - [type_ release]; +#define _clear(field) \ + if (field != nil) \ + [field release]; \ + field = nil; - if (description_ != nil) - [description_ release]; - if (label_ != nil) - [label_ release]; - if (origin_ != nil) - [origin_ release]; - if (version_ != nil) - [version_ release]; - if (defaultIcon_ != nil) - [defaultIcon_ release]; - if (record_ != nil) - [record_ release]; +- (void) _clear { + _clear(uri_) + _clear(distribution_) + _clear(type_) + _clear(description_) + _clear(label_) + _clear(origin_) + _clear(version_) + _clear(defaultIcon_) + _clear(record_) +} + +- (void) dealloc { + [self _clear]; [super dealloc]; } @@ -1004,44 +1004,50 @@ class Progress : return ![[self _attributeKeys] containsObject:[NSString stringWithUTF8String:name]] && [super isKeyExcludedFromWebScript:name]; } -- (Source *) initWithMetaIndex:(metaIndex *)index { - if ((self = [super init]) != nil) { - trusted_ = index->IsTrusted(); - - uri_ = [[NSString stringWithUTF8String:index->GetURI().c_str()] retain]; - distribution_ = [[NSString stringWithUTF8String:index->GetDist().c_str()] retain]; - type_ = [[NSString stringWithUTF8String:index->GetType()] retain]; - - debReleaseIndex *dindex(dynamic_cast(index)); - if (dindex != NULL) { - std::ifstream release(dindex->MetaIndexFile("Release").c_str()); - std::string line; - while (std::getline(release, line)) { - std::string::size_type colon(line.find(':')); - if (colon == std::string::npos) - continue; +- (void) setMetaIndex:(metaIndex *)index { + [self _clear]; - std::string name(line.substr(0, colon)); - std::string value(line.substr(colon + 1)); - while (!value.empty() && value[0] == ' ') - value = value.substr(1); - - if (name == "Default-Icon") - defaultIcon_ = [[NSString stringWithUTF8String:value.c_str()] retain]; - else if (name == "Description") - description_ = [[NSString stringWithUTF8String:value.c_str()] retain]; - else if (name == "Label") - label_ = [[NSString stringWithUTF8String:value.c_str()] retain]; - else if (name == "Origin") - origin_ = [[NSString stringWithUTF8String:value.c_str()] retain]; - else if (name == "Version") - version_ = [[NSString stringWithUTF8String:value.c_str()] retain]; - } + trusted_ = index->IsTrusted(); + + uri_ = [[NSString stringWithUTF8String:index->GetURI().c_str()] retain]; + distribution_ = [[NSString stringWithUTF8String:index->GetDist().c_str()] retain]; + type_ = [[NSString stringWithUTF8String:index->GetType()] retain]; + + debReleaseIndex *dindex(dynamic_cast(index)); + if (dindex != NULL) { + std::ifstream release(dindex->MetaIndexFile("Release").c_str()); + std::string line; + while (std::getline(release, line)) { + std::string::size_type colon(line.find(':')); + if (colon == std::string::npos) + continue; + + std::string name(line.substr(0, colon)); + std::string value(line.substr(colon + 1)); + while (!value.empty() && value[0] == ' ') + value = value.substr(1); + + if (name == "Default-Icon") + defaultIcon_ = [[NSString stringWithUTF8String:value.c_str()] retain]; + else if (name == "Description") + description_ = [[NSString stringWithUTF8String:value.c_str()] retain]; + else if (name == "Label") + label_ = [[NSString stringWithUTF8String:value.c_str()] retain]; + else if (name == "Origin") + origin_ = [[NSString stringWithUTF8String:value.c_str()] retain]; + else if (name == "Version") + version_ = [[NSString stringWithUTF8String:value.c_str()] retain]; } + } + + record_ = [Sources_ objectForKey:[self key]]; + if (record_ != nil) + record_ = [record_ retain]; +} - record_ = [Sources_ objectForKey:[self key]]; - if (record_ != nil) - record_ = [record_ retain]; +- (Source *) initWithMetaIndex:(metaIndex *)index { + if ((self = [super init]) != nil) { + [self setMetaIndex:index]; } return self; } @@ -1194,6 +1200,8 @@ class Progress : - (NSString *) section; - (NSString *) simpleSection; +- (NSString *) uri; + - (Address *) maintainer; - (size_t) size; - (NSString *) description; @@ -1235,7 +1243,6 @@ class Progress : - (Source *) source; - (NSString *) role; -- (NSString *) rating; - (BOOL) matches:(NSString *)text; @@ -1298,7 +1305,7 @@ class Progress : } + (NSArray *) _attributeKeys { - return [NSArray arrayWithObjects:@"applications", @"author", @"depiction", @"description", @"essential", @"homepage", @"icon", @"id", @"installed", @"latest", @"maintainer", @"name", @"purposes", @"rating", @"section", @"size", @"source", @"sponsor", @"tagline", @"warnings", nil]; + return [NSArray arrayWithObjects:@"applications", @"author", @"depiction", @"description", @"essential", @"homepage", @"icon", @"id", @"installed", @"latest", @"maintainer", @"name", @"purposes", @"section", @"size", @"source", @"sponsor", @"tagline", @"warnings", nil]; } - (NSArray *) attributeKeys { @@ -1500,14 +1507,27 @@ class Progress : return Simplify(section); else return nil; +} +- (NSString *) uri { + return nil; +#if 0 + pkgIndexFile *index; + pkgCache::PkgFileIterator file(file_.File()); + if (![database_ list].FindIndex(file, index)) + return nil; + return [NSString stringWithUTF8String:iterator_->Path]; + //return [NSString stringWithUTF8String:file.Site()]; + //return [NSString stringWithUTF8String:index->ArchiveURI(file.FileName()).c_str()]; +#endif } - (Address *) maintainer { if (file_.end()) return nil; pkgRecords::Parser *parser = &[database_ records]->Lookup(file_); - return [Address addressWithString:[NSString stringWithUTF8String:parser->Maintainer().c_str()]]; + const std::string &maintainer(parser->Maintainer()); + return maintainer.empty() ? nil : [Address addressWithString:[NSString stringWithUTF8String:maintainer.c_str()]]; } - (size_t) size { @@ -1582,10 +1602,12 @@ class Progress : - (BOOL) upgradableAndEssential:(BOOL)essential { pkgCache::VerIterator current = iterator_.CurrentVer(); + bool value; if (current.end()) - return essential && [self essential]; + value = essential && [self essential]; else - return !version_.end() && version_ != current; + value = !version_.end() && version_ != current;// && (!essential || ![database_ cache][iterator_].Keep()); + return value; } - (BOOL) essential { @@ -1673,12 +1695,14 @@ class Progress : NSString *section = [self simpleSection]; UIImage *icon(nil); - if (NSString *icon = icon_) - icon = [UIImage imageAtPath:[icon_ substringFromIndex:6]]; + if (icon_ != nil) + if ([icon_ hasPrefix:@"file:///"]) + icon = [UIImage imageAtPath:[icon_ substringFromIndex:7]]; if (icon == nil) if (section != nil) icon = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]]; - if (icon == nil) if (source_ != nil) if (NSString *icon = [source_ defaultIcon]) - icon = [UIImage imageAtPath:[icon substringFromIndex:6]]; + if (icon == nil) if (source_ != nil) if (NSString *dicon = [source_ defaultIcon]) + if ([dicon hasPrefix:@"file:///"]) + icon = [UIImage imageAtPath:[dicon substringFromIndex:7]]; if (icon == nil) icon = [UIImage applicationImageNamed:@"unknown.png"]; return icon; @@ -1812,13 +1836,6 @@ class Progress : return role_; } -- (NSString *) rating { - if (NSString *rating = [Indices_ objectForKey:@"Rating"]) - return [rating stringByReplacingOccurrencesOfString:@"@P" withString:[id_ stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; - else - return nil; -} - - (BOOL) matches:(NSString *)text { if (text == nil) return NO; @@ -1921,9 +1938,10 @@ class Progress : } bits; } value; - value.bits.upgradable = [self upgradableAndEssential:YES] ? 1 : 0; + bool upgradable([self upgradableAndEssential:YES]); + value.bits.upgradable = upgradable ? 1 : 0; - if ([self upgradableAndEssential:YES]) { + if (upgradable) { value.bits.timestamp = 0; value.bits.ignored = [self ignored] ? 0 : 1; value.bits.upgradable = 1; @@ -2237,6 +2255,10 @@ static NSArray *Finishes_; return *fetcher_; } +- (pkgSourceList &) list { + return *list_; +} + - (NSArray *) packages { return packages_; } @@ -2463,7 +2485,9 @@ static NSArray *Finishes_; failed = true; [delegate_ performSelectorOnMainThread:@selector(_setProgressError:) - withObject:[NSArray arrayWithObjects:[NSString stringWithUTF8String:error.c_str()], nil] + withObject:[NSArray arrayWithObjects: + [NSString stringWithUTF8String:error.c_str()], + nil] waitUntilDone:YES ]; } @@ -3099,7 +3123,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button { NSString *context([sheet context]); - if ([context isEqualToString:@"conffile"]) { + if ([context isEqualToString:@"error"]) + [sheet dismiss]; + else if ([context isEqualToString:@"conffile"]) { FILE *input = [database_ input]; switch (button) { @@ -3993,17 +4019,14 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @interface PackageTable : RVPage { _transient Database *database_; NSString *title_; - SEL filter_; - id object_; NSMutableArray *packages_; NSMutableArray *sections_; UISectionList *list_; } -- (id) initWithBook:(RVBook *)book database:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object; +- (id) initWithBook:(RVBook *)book database:(Database *)database title:(NSString *)title; - (void) setDelegate:(id)delegate; -- (void) setObject:(id)object; - (void) reloadData; - (void) resetCursor; @@ -4020,8 +4043,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [list_ setDataSource:nil]; [title_ release]; - if (object_ != nil) - [object_ release]; [packages_ release]; [sections_ release]; [list_ release]; @@ -4065,18 +4086,17 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return; Package *package = [packages_ objectAtIndex:row]; + package = [database_ packageWithName:[package id]]; PackageView *view = [[[PackageView alloc] initWithBook:book_ database:database_] autorelease]; - [view setDelegate:delegate_]; [view setPackage:package]; + [view setDelegate:delegate_]; [book_ pushPage:view]; } -- (id) initWithBook:(RVBook *)book database:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object { +- (id) initWithBook:(RVBook *)book database:(Database *)database title:(NSString *)title { if ((self = [super initWithBook:book]) != nil) { database_ = database; title_ = [title retain]; - filter_ = filter; - object_ = object == nil ? nil : [object retain]; packages_ = [[NSMutableArray arrayWithCapacity:16] retain]; sections_ = [[NSMutableArray arrayWithCapacity:16] retain]; @@ -4097,7 +4117,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [table setReusesTableCells:YES]; [self addSubview:list_]; - [self reloadData]; [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; [list_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; @@ -4108,13 +4127,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { delegate_ = delegate; } -- (void) setObject:(id)object { - if (object_ != nil) - [object_ release]; - if (object == nil) - object_ = nil; - else - object_ = [object retain]; +- (bool) hasPackage:(Package *)package { + return true; } - (void) reloadData { @@ -4125,7 +4139,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { for (size_t i(0); i != [packages count]; ++i) { Package *package([packages objectAtIndex:i]); - if ([package valid] && [[package performSelector:filter_ withObject:object_] boolValue]) + if ([self hasPackage:package]) [packages_ addObject:package]; } @@ -4166,6 +4180,50 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [list_ setShouldHideHeaderInShortLists:hide]; } +@end +/* }}} */ +/* Filtered Package Table {{{ */ +@interface FilteredPackageTable : PackageTable { + SEL filter_; + id object_; +} + +- (void) setObject:(id)object; + +- (id) initWithBook:(RVBook *)book database:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object; + +@end + +@implementation FilteredPackageTable + +- (void) dealloc { + if (object_ != nil) + [object_ release]; + [super dealloc]; +} + +- (void) setObject:(id)object { + if (object_ != nil) + [object_ release]; + if (object == nil) + object_ = nil; + else + object_ = [object retain]; +} + +- (bool) hasPackage:(Package *)package { + return [package valid] && [[package performSelector:filter_ withObject:object_] boolValue]; +} + +- (id) initWithBook:(RVBook *)book database:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object { + if ((self = [super initWithBook:book database:database title:title]) != nil) { + filter_ = filter; + object_ = object == nil ? nil : [object retain]; + + [self reloadData]; + } return self; +} + @end /* }}} */ @@ -4362,7 +4420,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { Source *source = [sources_ objectAtIndex:row]; - PackageTable *packages = [[[PackageTable alloc] + PackageTable *packages = [[[FilteredPackageTable alloc] initWithBook:book_ database:database_ title:[source label] @@ -4634,7 +4692,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { /* Installed View {{{ */ @interface InstalledView : RVPage { _transient Database *database_; - PackageTable *packages_; + FilteredPackageTable *packages_; BOOL expert_; } @@ -4653,7 +4711,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if ((self = [super initWithBook:book]) != nil) { database_ = database; - packages_ = [[PackageTable alloc] + packages_ = [[FilteredPackageTable alloc] initWithBook:book database:database title:nil @@ -4790,43 +4848,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Indirect Delegate {{{ */ -@interface IndirectDelegate : NSProxy { - _transient volatile id delegate_; -} - -- (void) setDelegate:(id)delegate; -- (id) initWithDelegate:(id)delegate; -@end - -@implementation IndirectDelegate - -- (void) setDelegate:(id)delegate { - delegate_ = delegate; -} - -- (id) initWithDelegate:(id)delegate { - delegate_ = delegate; - return self; -} - -- (NSMethodSignature*) methodSignatureForSelector:(SEL)sel { - if (delegate_ != nil) - if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel]) - return sig; - // XXX: I fucking hate Apple so very very bad - return [NSMethodSignature signatureWithObjCTypes:"v@:"]; -} - -- (void) forwardInvocation:(NSInvocation *)inv { - SEL sel = [inv selector]; - if (delegate_ != nil && [delegate_ respondsToSelector:sel]) - [inv invokeWithTarget:delegate_]; -} - -@end -/* }}} */ - #include /* Cydia Book {{{ */ @@ -5107,12 +5128,16 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request { id client([self client]); - NSData *data(UIImagePNGRepresentation(icon)); + if (icon == nil) + [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]]; + else { + NSData *data(UIImagePNGRepresentation(icon)); - NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]); - [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed]; - [client URLProtocol:self didLoadData:data]; - [client URLProtocolDidFinishLoading:self]; + NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]); + [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed]; + [client URLProtocol:self didLoadData:data]; + [client URLProtocolDidFinishLoading:self]; + } } - (void) startLoading { @@ -5180,8 +5205,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Install View {{{ */ -@interface InstallView : RVPage { +/* Sections View {{{ */ +@interface SectionsView : RVPage { _transient Database *database_; NSMutableArray *sections_; NSMutableArray *filtered_; @@ -5197,7 +5222,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@implementation InstallView +@implementation SectionsView - (void) dealloc { [list_ setDataSource:nil]; @@ -5262,7 +5287,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } } - PackageTable *table = [[[PackageTable alloc] + PackageTable *table = [[[FilteredPackageTable alloc] initWithBook:book_ database:database_ title:title @@ -5523,7 +5548,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if ( [package installed] == nil && [package valid] && [package visible] || - [package upgradableAndEssential:NO] + [package upgradableAndEssential:YES] ) [packages_ addObject:package]; } @@ -5614,7 +5639,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { UIView *accessory_; UISearchField *field_; UITransitionView *transition_; - PackageTable *table_; + FilteredPackageTable *table_; UIPreferencesTable *advanced_; UIView *dimmed_; bool flipped_; @@ -5745,7 +5770,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { CGColor dimmed(space_, 0, 0, 0, 0.5); [dimmed_ setBackgroundColor:[UIColor colorWithCGColor:dimmed]]; - table_ = [[PackageTable alloc] + table_ = [[FilteredPackageTable alloc] initWithBook:book database:database title:nil @@ -6120,7 +6145,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { UIKeyboard *keyboard_; UIProgressHUD *hud_; - InstallView *install_; + SectionsView *sections_; ChangesView *changes_; ManageView *manage_; SearchView *search_; @@ -6206,17 +6231,21 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [self updateData]; -#if !ForSaurik + // XXX: what is this line of code for? if ([packages count] == 0); - else if (Loaded_) -#endif + else if (Loaded_) loaded: [self _loaded]; -#if !ForSaurik else { Loaded_ = YES; + + if (NSDate *update = [Metadata_ objectForKey:@"LastUpdate"]) { + NSTimeInterval interval([update timeIntervalSinceNow]); + if (interval <= 0 && interval > -600) + goto loaded; + } + [book_ update]; } -#endif /*[hud show:NO]; [hud removeFromSuperview];*/ @@ -6235,8 +6264,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [self _saveConfig]; /* XXX: this is just stupid */ - if (tag_ != 2 && install_ != nil) - [install_ reloadData]; + if (tag_ != 2 && sections_ != nil) + [sections_ reloadData]; if (tag_ != 3 && changes_ != nil) [changes_ reloadData]; if (tag_ != 5 && search_ != nil) @@ -6293,17 +6322,25 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { _error->Discard(); } +- (void) popUpBook:(RVBook *)book { + [underlay_ popSubview:book]; +} + +- (CGRect) popUpBounds { + return [underlay_ bounds]; +} + - (void) perform { [database_ prepare]; - confirm_ = [[RVBook alloc] initWithFrame:[underlay_ bounds]]; + confirm_ = [[RVBook alloc] initWithFrame:[self popUpBounds]]; [confirm_ setDelegate:self]; ConfirmationView *page([[[ConfirmationView alloc] initWithBook:confirm_ database:database_] autorelease]); [page setDelegate:self]; [confirm_ setPage:page]; - [underlay_ popSubview:confirm_]; + [self popUpBook:confirm_]; } - (void) installPackage:(Package *)package { @@ -6398,12 +6435,12 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [book_ resetViewAnimated:YES]; return; } else if (tag_ == 2 && tag != 2) - [install_ resetView]; + [sections_ resetView]; switch (tag) { case 1: [self _setHomePage]; break; - case 2: [self setPage:install_]; break; + case 2: [self setPage:sections_]; break; case 3: [self setPage:changes_]; break; case 4: [self setPage:manage_]; break; case 5: [self setPage:search_]; break; @@ -6559,7 +6596,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [self reloadData]; - install_ = [[InstallView alloc] initWithBook:book_ database:database_]; + sections_ = [[SectionsView alloc] initWithBook:book_ database:database_]; changes_ = [[ChangesView alloc] initWithBook:book_ database:database_]; search_ = [[SearchView alloc] initWithBook:book_ database:database_]; @@ -6577,7 +6614,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button { NSString *context([sheet context]); - if ([context isEqualToString:@"fixhalf"]) { + if ([context isEqualToString:@"missing"]) + [sheet dismiss]; + else if ([context isEqualToString:@"fixhalf"]) { switch (button) { case 1: @synchronized (self) { @@ -6729,31 +6768,39 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (RVPage *) pageForURL:(NSURL *)url hasTag:(int *)tag { - NSString *href = [url absoluteString]; - if (tag != NULL) tag = 0; - if ([href isEqualToString:@"cydia://add-source"]) + NSString *scheme([[url scheme] lowercaseString]); + if (![scheme isEqualToString:@"cydia"]) + return nil; + NSString *path([url absoluteString]); + if ([path length] < 8) + return nil; + path = [path substringFromIndex:8]; + if (![path hasPrefix:@"/"]) + path = [@"/" stringByAppendingString:path]; + + if ([path isEqualToString:@"/add-source"]) return [[[AddSourceView alloc] initWithBook:book_ database:database_] autorelease]; - else if ([href isEqualToString:@"cydia://storage"]) + else if ([path isEqualToString:@"/storage"]) return [self _pageForURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"storage" ofType:@"html"]] withClass:[BrowserView class]]; - else if ([href isEqualToString:@"cydia://sources"]) + else if ([path isEqualToString:@"/sources"]) return [[[SourceTable alloc] initWithBook:book_ database:database_] autorelease]; - else if ([href isEqualToString:@"cydia://packages"]) + else if ([path isEqualToString:@"/packages"]) return [[[InstalledView alloc] initWithBook:book_ database:database_] autorelease]; - else if ([href hasPrefix:@"cydia://url/"]) - return [self _pageForURL:[NSURL URLWithString:[href substringFromIndex:12]] withClass:[BrowserView class]]; - else if ([href hasPrefix:@"cydia://launch/"]) - [self launchApplicationWithIdentifier:[href substringFromIndex:15] suspended:NO]; - else if ([href hasPrefix:@"cydia://package-settings/"]) - return [[[SettingsView alloc] initWithBook:book_ database:database_ package:[href substringFromIndex:25]] autorelease]; - else if ([href hasPrefix:@"cydia://package-signature/"]) - return [[[SignatureView alloc] initWithBook:book_ database:database_ package:[href substringFromIndex:26]] autorelease]; - else if ([href hasPrefix:@"cydia://package/"]) - return [self pageForPackage:[href substringFromIndex:16]]; - else if ([href hasPrefix:@"cydia://files/"]) { - NSString *name = [href substringFromIndex:14]; + else if ([path hasPrefix:@"/url/"]) + return [self _pageForURL:[NSURL URLWithString:[path substringFromIndex:5]] withClass:[BrowserView class]]; + else if ([path hasPrefix:@"/launch/"]) + [self launchApplicationWithIdentifier:[path substringFromIndex:8] suspended:NO]; + else if ([path hasPrefix:@"/package-settings/"]) + return [[[SettingsView alloc] initWithBook:book_ database:database_ package:[path substringFromIndex:18]] autorelease]; + else if ([path hasPrefix:@"/package-signature/"]) + return [[[SignatureView alloc] initWithBook:book_ database:database_ package:[path substringFromIndex:19]] autorelease]; + else if ([path hasPrefix:@"/package/"]) + return [self pageForPackage:[path substringFromIndex:9]]; + else if ([path hasPrefix:@"/files/"]) { + NSString *name = [path substringFromIndex:7]; if (Package *package = [database_ packageWithName:name]) { FileTable *files = [[[FileTable alloc] initWithBook:book_ database:database_] autorelease]; @@ -6921,6 +6968,7 @@ id Dealloc_(id self, SEL selector) { }*/ int main(int argc, char *argv[]) { _pooled + _trace(); class_addMethod(objc_getClass("DOMNodeList"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &DOMNodeList$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16"); bool substrate(false); @@ -7003,15 +7051,11 @@ int main(int argc, char *argv[]) { _pooled /*AddPreferences(@"/Applications/Preferences.app/Settings-iPhone.plist"); AddPreferences(@"/Applications/Preferences.app/Settings-iPod.plist");*/ - /*if ((Indices_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/indices.plist"]) == NULL) - Indices_ = [[NSMutableDictionary alloc] init];*/ - - Indices_ = [NSMutableDictionary dictionaryWithObjectsAndKeys: - @"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/server/rating/@", @"Rating", - @"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/repotag/@", @"RepoTag", - nil]; + _trace(); + Metadata_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"]; + _trace(); - if ((Metadata_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"]) == NULL) + if (Metadata_ == NULL) Metadata_ = [[NSMutableDictionary alloc] initWithCapacity:2]; else { Settings_ = [Metadata_ objectForKey:@"Settings"]; @@ -7048,8 +7092,11 @@ int main(int argc, char *argv[]) { _pooled /*if (substrate && access("/Library/MobileSubstrate/MobileSubstrate.dylib", F_OK) == 0) dlopen("/Library/MobileSubstrate/MobileSubstrate.dylib", RTLD_LAZY | RTLD_GLOBAL);*/ - if (access("/User", F_OK) != 0) + if (access("/User", F_OK) != 0) { + _trace(); system("/usr/libexec/cydia/firmware.sh"); + _trace(); + } _assert([[NSFileManager defaultManager] createDirectoryAtPath:@"/var/cache/apt/archives/partial" @@ -7074,6 +7121,7 @@ int main(int argc, char *argv[]) { _pooled UIApplicationUseLegacyEvents(YES); UIKeyboardDisableAutomaticAppearance(); + _trace(); int value = UIApplicationMain(argc, argv, @"Cydia", @"Cydia"); CGColorSpaceRelease(space_);