X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/7ce4709707e9db576d48daf00389a2f3b9c8b7ea..5e61e76c2791ccb7a31bf411aaf8fce470c1ffef:/MobileCydia.mm?ds=sidebyside diff --git a/MobileCydia.mm b/MobileCydia.mm index dd77a84c..932b4714 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -102,6 +102,7 @@ #include #include #include +#include #include #include @@ -1490,7 +1491,7 @@ static void PackageImport(const void *key, const void *value, void *context) { NSDictionary *package((NSDictionary *) value); if (NSNumber *subscribed = [package objectForKey:@"IsSubscribed"]) - if ([subscribed boolValue]) + if ([subscribed boolValue] && !metadata->subscribed_) metadata->subscribed_ = true; if (NSDate *date = [package objectForKey:@"FirstSeen"]) { @@ -1499,22 +1500,12 @@ static void PackageImport(const void *key, const void *value, void *context) { metadata->first_ = time; } - bool versioned(false); + NSDate *date([package objectForKey:@"LastSeen"]); + NSString *version([package objectForKey:@"LastVersion"]); - if (NSDate *date = [package objectForKey:@"LastSeen"]) { + if (date != nil && version != nil) { time_t time([date timeIntervalSince1970]); - if (metadata->last_ < time || metadata->last_ == 0) { - metadata->last_ = time; - versioned = true; - } - } else if (metadata->last_ == 0) { - metadata->last_ = metadata->first_; - if (metadata->version_[0] == '\0') - versioned = true; - } - - if (versioned) - if (NSString *version = [package objectForKey:@"LastVersion"]) + if (metadata->last_ < time || metadata->last_ == 0) if (CFStringGetCString((CFStringRef) version, buffer, sizeof(buffer), kCFStringEncodingUTF8)) { size_t length(strlen(buffer)); uint16_t vhash(hashlittle(buffer, length)); @@ -1524,7 +1515,10 @@ static void PackageImport(const void *key, const void *value, void *context) { strncpy(metadata->version_, latest, sizeof(metadata->version_)); metadata->vhash_ = vhash; + + metadata->last_ = time; } + } } // }}} @@ -2264,15 +2258,12 @@ struct PackageNameOrdering : if (metadata->first_ == 0) metadata->first_ = now_; - if (metadata->last_ == 0) - metadata->last_ = metadata->first_; - if (metadata->vhash_ != vhash || strncmp(metadata->version_, latest, sizeof(metadata->version_)) != 0) { - if (metadata->version_[0] != '\0') - metadata->last_ = now_; strncpy(metadata->version_, latest, sizeof(metadata->version_)); metadata->vhash_ = vhash; - } + metadata->last_ = now_; + } else if (metadata->last_ == 0) + metadata->last_ = metadata->first_; _end _profile(Package$initWithVersion$Section) @@ -3507,7 +3498,9 @@ static NSString *Warning_; - (void) configure { NSString *dpkg = [NSString stringWithFormat:@"dpkg --configure -a --status-fd %u", statusfd_]; + _trace(); system([dpkg UTF8String]); + _trace(); } - (bool) clean { @@ -4441,15 +4434,24 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { break; case 2: - system("launchctl stop com.apple.SpringBoard"); - break; + _trace(); + goto reload; case 3: - system("launchctl unload "SpringBoard_"; launchctl load "SpringBoard_); + _trace(); + goto reload; + + reload: + system("/usr/bin/sbreload"); + _trace(); break; case 4: - system("reboot"); + _trace(); + if (void (*SBReboot)(mach_port_t) = reinterpret_cast(dlsym(RTLD_DEFAULT, "SBReboot"))) + SBReboot(SBSSpringBoardServerPort()); + else + reboot2(RB_AUTOBOOT); break; } } @@ -4498,7 +4500,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { case 4: [close_ setTitle:UCLocalize("REBOOT_DEVICE")]; break; } + _trace(); system("su -c /usr/bin/uicache mobile"); + _trace(); UpdateExternalStatus(Finish_ == 0 ? 2 : 0); @@ -7944,7 +7948,7 @@ freeing the view controllers on tab change */ captrect.origin.x = 0; captrect.origin.y = ([[self view] frame].size.height / 2) - (captrect.size.height * 2); caption_ = [[[UILabel alloc] initWithFrame:captrect] autorelease]; - [caption_ setText:@"Initializing Filesystem"]; + [caption_ setText:UCLocalize("PREPARING_FILESYSTEM")]; [caption_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin]; [caption_ setFont:[UIFont boldSystemFontOfSize:28.0f]]; [caption_ setTextColor:[UIColor whiteColor]]; @@ -7960,7 +7964,7 @@ freeing the view controllers on tab change */ statusrect.origin.y = ([[self view] frame].size.height / 2) - statusrect.size.height; status_ = [[[UILabel alloc] initWithFrame:statusrect] autorelease]; [status_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin]; - [status_ setText:@"(Cydia will exit when complete.)"]; + [status_ setText:UCLocalize("EXIT_WHEN_COMPLETE")]; [status_ setFont:[UIFont systemFontOfSize:16.0f]]; [status_ setTextColor:[UIColor whiteColor]]; [status_ setBackgroundColor:[UIColor clearColor]]; @@ -8210,24 +8214,20 @@ static _finline void _setHomePage(Cydia *self) { } } + NSLog(@"changes:#%u", changes); + UITabBarItem *changesItem = [[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem]; if (changes != 0) { + _trace(); NSString *badge([[NSNumber numberWithInt:changes] stringValue]); [changesItem setBadgeValue:badge]; [changesItem setAnimatedBadge:([essential_ count] > 0)]; - - if ([self respondsToSelector:@selector(setApplicationBadge:)]) - [self setApplicationBadge:badge]; - else - [self setApplicationBadgeString:badge]; + [self setApplicationIconBadgeNumber:changes]; } else { + _trace(); [changesItem setBadgeValue:nil]; [changesItem setAnimatedBadge:NO]; - - if ([self respondsToSelector:@selector(removeApplicationBadge)]) - [self removeApplicationBadge]; - else // XXX: maybe use setApplicationBadgeString also? - [self setApplicationIconBadgeNumber:0]; + [self setApplicationIconBadgeNumber:0]; } [self _updateData]; @@ -8576,7 +8576,9 @@ static _finline void _setHomePage(Cydia *self) { } - (void) system:(NSString *)command { _pooled + _trace(); system([command UTF8String]); + _trace(); } - (void) applicationWillSuspend {