]> git.saurik.com Git - cydia.git/blobdiff - MobileCydia.mm
Support missing version information in metadata.
[cydia.git] / MobileCydia.mm
index d6adebabcdab5d134d16279ea7b55783603d80c5..8212c6cb15bc3d5db8471b6b7764c007c4d8a816 100644 (file)
@@ -276,8 +276,6 @@ static _finline void UpdateExternalStatus(uint64_t newStatus) {
 }
 
 - (id) yieldToSelector:(SEL)selector withObject:(id)object {
-    /*return [self performSelector:selector withObject:object];*/
-
     volatile bool stopped(false);
 
     NSMutableArray *context([NSMutableArray arrayWithObjects:
@@ -1499,25 +1497,32 @@ static void PackageImport(const void *key, const void *value, void *context) {
             metadata->first_ = time;
     }
 
+    bool versioned(false);
+
     if (NSDate *date = [package objectForKey:@"LastSeen"]) {
         time_t time([date timeIntervalSince1970]);
         if (metadata->last_ < time || metadata->last_ == 0) {
             metadata->last_ = time;
-            goto last;
+            versioned = true;
         }
-    } else if (metadata->last_ == 0) last: {
-        NSString *version([package objectForKey:@"LastVersion"]);
-        if (CFStringGetCString((CFStringRef) version, buffer, sizeof(buffer), kCFStringEncodingUTF8)) {
-            size_t length(strlen(buffer));
-            uint16_t vhash(hashlittle(buffer, length));
+    } else if (metadata->last_ == 0) {
+        metadata->last_ = metadata->first_;
+        if (metadata->version_[0] == '\0')
+            versioned = true;
+    }
 
-            size_t capped(std::min<size_t>(8, length));
-            char *latest(buffer + length - capped);
+    if (versioned)
+        if (NSString *version = [package objectForKey:@"LastVersion"])
+            if (CFStringGetCString((CFStringRef) version, buffer, sizeof(buffer), kCFStringEncodingUTF8)) {
+                size_t length(strlen(buffer));
+                uint16_t vhash(hashlittle(buffer, length));
 
-            strncpy(metadata->version_, latest, sizeof(metadata->version_));
-            metadata->vhash_ = vhash;
-        }
-    }
+                size_t capped(std::min<size_t>(8, length));
+                char *latest(buffer + length - capped);
+
+                strncpy(metadata->version_, latest, sizeof(metadata->version_));
+                metadata->vhash_ = vhash;
+            }
 }
 // }}}
 
@@ -1968,9 +1973,6 @@ uint32_t PackageChangesRadix(Package *self, void *) {
     return _not(uint32_t) - value.key;
 }
 
-_finline static void Stifle(uint8_t &value) {
-}
-
 uint32_t PackagePrefixRadix(Package *self, void *context) {
     size_t offset(reinterpret_cast<size_t>(context));
     CYString &name([self cyname]);
@@ -1993,8 +1995,6 @@ uint32_t PackagePrefixRadix(Package *self, void *context) {
 
     uint8_t data[4];
 
-    // 0.607997
-
     if (offset == 0 && zeros != 0) {
         memset(data, '0', zeros);
         memcpy(data + zeros, text, 4 - zeros);
@@ -2266,12 +2266,15 @@ 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) {
-                metadata->last_ = now_;
+                if (metadata->version_[0] != '\0')
+                    metadata->last_ = now_;
                 strncpy(metadata->version_, latest, sizeof(metadata->version_));
                 metadata->vhash_ = vhash;
-            } else if (metadata->last_ == 0)
-                metadata->last_ = metadata->first_;
+            }
         _end
 
         _profile(Package$initWithVersion$Section)
@@ -8009,6 +8012,9 @@ typedef enum {
 - (void) setPage:(CYViewController *)page;
 - (void) loadData;
 
+// XXX: I hate prototypes
+- (id) queueBadgeController;
+
 @end
 
 static _finline void _setHomePage(Cydia *self) {
@@ -8093,6 +8099,9 @@ static _finline void _setHomePage(Cydia *self) {
         [search_ reloadData];
 
     [(CYNavigationController *)[tabbar_ selectedViewController] reloadData];
+
+    [queueDelegate_ queueStatusDidChange];
+    [[[self queueBadgeController] tabBarItem] setBadgeValue:(Queuing_ ? UCLocalize("Q_D") : nil)];
 }
 
 - (int)indexOfTabWithTag:(int)tag {
@@ -8340,6 +8349,8 @@ static _finline void _setHomePage(Cydia *self) {
 }
 
 - (void) confirmWithNavigationController:(UINavigationController *)navigation {
+    Queuing_ = false;
+
     ProgressController *progress = [[[ProgressController alloc] initWithDatabase:database_ delegate:self] autorelease];
 
     if (navigation != nil) {
@@ -8484,18 +8495,12 @@ static _finline void _setHomePage(Cydia *self) {
     @synchronized (self) {
         if (clear) {
             [database_ clear];
-
-            // Stop queuing.
             Queuing_ = false;
-            [[[self queueBadgeController] tabBarItem] setBadgeValue:nil];
         } else {
-            // Start queuing.
             Queuing_ = true;
-            [[[self queueBadgeController] tabBarItem] setBadgeValue:UCLocalize("Q_D")];
         }
 
         [self _updateData];
-        [queueDelegate_ queueStatusDidChange];
     }
 }