X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/2e704a5fd9860a6e129b543178f7057a8fc6ca7d..1b9ba5964135b35d5fc2357d05e1754f0b97d479:/MobileCydia.mm?ds=sidebyside diff --git a/MobileCydia.mm b/MobileCydia.mm index fffbc7fd..b7050fc6 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1355,6 +1355,8 @@ typedef std::map< unsigned long, _H > SourceMap; int cydiafd_; int statusfd_; FILE *input_; + + std::map > sections_; } + (Database *) sharedInstance; @@ -1388,6 +1390,9 @@ typedef std::map< unsigned long, _H > SourceMap; - (void) setDelegate:(id)delegate; - (Source *) getSource:(pkgCache::PkgFileIterator)file; + +- (NSString *) mappedSectionForPointer:(const char *)pointer; + @end /* }}} */ /* Delegate Helpers {{{ */ @@ -1825,7 +1830,8 @@ struct ParsedPackage { }; @interface Package : NSObject { - uint32_t era_ : 29; + uint32_t era_ : 26; + uint32_t role_ : 3; uint32_t essential_ : 1; uint32_t obsolete_ : 1; uint32_t ignored_ : 1; @@ -1844,7 +1850,7 @@ struct ParsedPackage { CYString latest_; CYString installed_; - CYString section_; + const char *section_; _transient NSString *section$_; Source *source_; @@ -1853,7 +1859,6 @@ struct ParsedPackage { ParsedPackage *parsed_; NSMutableArray *tags_; - NSString *role_; } - (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database; @@ -1915,7 +1920,6 @@ struct ParsedPackage { - (NSArray *) applications; - (Source *) source; -- (NSString *) role; - (BOOL) matches:(NSString *)text; @@ -2076,15 +2080,10 @@ struct PackageNameOrdering : - (void) dealloc { if (parsed_ != NULL) delete parsed_; - if (source_ != nil) [source_ release]; - if (tags_ != nil) [tags_ release]; - if (role_ != nil) - [role_ release]; - [super dealloc]; } @@ -2218,8 +2217,18 @@ struct PackageNameOrdering : const char *name(tag.Name()); [tags_ addObject:[(NSString *)CYStringCreate(name) autorelease]]; - if (role_ == nil && strncmp(name, "role::", 6) == 0 /*&& strcmp(name, "role::leaper") != 0*/) - role_ = (NSString *) CYStringCreate(name + 6); + if (role_ == 0 && strncmp(name, "role::", 6) == 0 /*&& strcmp(name, "role::leaper") != 0*/) { + if (strcmp(name + 6, "enduser") == 0) + role_ = 1; + else if (strcmp(name + 6, "hacker") == 0) + role_ = 2; + else if (strcmp(name + 6, "developer") == 0) + role_ = 3; + else if (strcmp(name + 6, "cydia") == 0) + role_ = 7; + else + role_ = 4; + } if (strncmp(name, "cydia::", 7) == 0) { if (strcmp(name + 7, "essential") == 0) @@ -2267,7 +2276,7 @@ struct PackageNameOrdering : _end _profile(Package$initWithVersion$Section) - section_.set(NULL, iterator.Section()); + section_ = iterator.Section(); _end _profile(Package$initWithVersion$Flags) @@ -2315,13 +2324,11 @@ struct PackageNameOrdering : - (NSString *) section { if (section$_ == nil) { - if (section_.empty()) + if (section_ == NULL) return nil; - _profile(Package$section) - std::replace(section_.data(), section_.data() + section_.size(), '_', ' '); - NSString *name(section_); - section$_ = [SectionMap_ objectForKey:name] ?: name; + _profile(Package$section$mappedSectionForPointer) + section$_ = [database_ mappedSectionForPointer:section_]; _end } return section$_; } @@ -2471,12 +2478,12 @@ struct PackageNameOrdering : - (BOOL) unfiltered { _profile(Package$unfiltered$obsolete) - if (obsolete_) + if (_unlikely(obsolete_)) return false; _end _profile(Package$unfiltered$hasSupportingRole) - if (![self hasSupportingRole]) + if (_unlikely(![self hasSupportingRole])) return false; _end @@ -2487,7 +2494,11 @@ struct PackageNameOrdering : if (![self unfiltered]) return false; - NSString *section([self section]); + NSString *section; + + _profile(Package$visible$section) + section = [self section]; + _end _profile(Package$visible$isSectionVisible) if (section != nil && !isSectionVisible(section)) @@ -2710,10 +2721,6 @@ struct PackageNameOrdering : return source_ == (Source *) [NSNull null] ? nil : source_; } -- (NSString *) role { - return role_; -} - - (BOOL) matches:(NSString *)text { if (text == nil) return NO; @@ -2736,17 +2743,17 @@ struct PackageNameOrdering : } - (bool) hasSupportingRole { - if (role_ == nil) + if (role_ == 0) return true; - if ([role_ isEqualToString:@"enduser"]) + if (role_ == 1) return true; if ([Role_ isEqualToString:@"User"]) return false; - if ([role_ isEqualToString:@"hacker"]) + if (role_ == 2) return true; if ([Role_ isEqualToString:@"Hacker"]) return false; - if ([role_ isEqualToString:@"developer"]) + if (role_ == 3) return true; if ([Role_ isEqualToString:@"Developer"]) return false; @@ -2868,7 +2875,7 @@ struct PackageNameOrdering : } - (bool) isInstalledAndUnfiltered:(NSNumber *)number { - return ![self uninstalled] && (![number boolValue] && ![role_ isEqualToString:@"cydia"] || [self unfiltered]); + return ![self uninstalled] && (![number boolValue] && role_ != 7 || [self unfiltered]); } - (bool) isVisibleInSection:(NSString *)name { @@ -3677,6 +3684,37 @@ static NSString *Warning_; return i == sources_.end() ? nil : i->second; } +- (NSString *) mappedSectionForPointer:(const char *)section { + _H *mapped; + + _profile(Database$mappedSectionForPointer$Cache) + mapped = §ions_[section]; + _end + + if (*mapped == NULL) { + size_t length(strlen(section)); + char spaced[length + 1]; + + _profile(Database$mappedSectionForPointer$Replace) + for (size_t index(0); index != length; ++index) + spaced[index] = section[index] == '_' ? ' ' : section[index]; + spaced[length] = '\0'; + _end + + NSString *string; + + _profile(Database$mappedSectionForPointer$stringWithUTF8String) + string = [NSString stringWithUTF8String:spaced]; + _end + + _profile(Database$mappedSectionForPointer$Map) + string = [SectionMap_ objectForKey:string] ?: string; + _end + + *mapped = string; + } return *mapped; +} + @end /* }}} */ @@ -5144,7 +5182,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) drawContentRect:(CGRect)rect { - bool highlighted(highlighted_); + bool highlighted(highlighted_ && !editing_); [icon_ drawInRect:CGRectMake(8, 7, 32, 32)]; @@ -5406,7 +5444,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) reloadButtonClicked { - // Don't reload a package view by clicking the button. + // Don't reload a commerical package by tapping the loading button, + // but if it's not an Install button, we should forward it on. + if (![package_ uninstalled]) + [self _customButtonClicked]; } - (void) applyLoadingTitle { @@ -6498,6 +6539,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @implementation HomeController ++ (BOOL)shouldHideNavigationBar { + return NO; +} + - (void) _setMoreHeaders:(NSMutableURLRequest *)request { [super _setMoreHeaders:request]; @@ -6528,12 +6573,16 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - //[[self navigationController] setNavigationBarHidden:YES animated:animated]; + + if ([[self class] shouldHideNavigationBar]) + [[self navigationController] setNavigationBarHidden:YES animated:animated]; } - (void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - //[[self navigationController] setNavigationBarHidden:NO animated:animated]; + + if ([[self class] shouldHideNavigationBar]) + [[self navigationController] setNavigationBarHidden:NO animated:animated]; } - (id) init {