]> git.saurik.com Git - cydia.git/blobdiff - MobileCydia.mm
Add /usr/share/bigboss/icons from the bigboss package.
[cydia.git] / MobileCydia.mm
index 55553282cbf7f0e2c18e7debe98fc0a595d7c4f6..a54c7b7332d8ca6b3cd27b36c394c8b937ba8840 100644 (file)
@@ -929,6 +929,7 @@ class Status :
     }
 
     virtual void IMSHit(pkgAcquire::ItemDesc &item) {
+        Done(item);
     }
 
     virtual void Fetch(pkgAcquire::ItemDesc &item) {
@@ -938,6 +939,9 @@ class Status :
     }
 
     virtual void Done(pkgAcquire::ItemDesc &item) {
+        NSString *name([NSString stringWithUTF8String:item.ShortDesc.c_str()]);
+        CydiaProgressEvent *event([CydiaProgressEvent eventWithMessage:[NSString stringWithFormat:Colon_, UCLocalize("DONE"), name] ofType:kCydiaProgressEventTypeStatus forItem:item]);
+        [delegate_ performSelectorOnMainThread:@selector(addProgressEvent:) withObject:event waitUntilDone:YES];
     }
 
     virtual void Fail(pkgAcquire::ItemDesc &item) {
@@ -5366,79 +5370,83 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     badge_ = nil;
     placard_ = nil;
 
-    [package parse];
+    if (package == nil)
+        [content_ setBackgroundColor:[UIColor whiteColor]];
+    else {
+        [package parse];
+
+        Source *source = [package source];
 
-    Source *source = [package source];
+        icon_ = [package icon];
 
-    icon_ = [package icon];
+        if (NSString *name = [package name])
+            name_ = [NSString stringWithString:name];
 
-    if (NSString *name = [package name])
-        name_ = [NSString stringWithString:name];
+        NSString *description(nil);
 
-    NSString *description(nil);
+        if (description == nil && IsWildcat_)
+            description = [package longDescription];
+        if (description == nil)
+            description = [package shortDescription];
 
-    if (description == nil && IsWildcat_)
-        description = [package longDescription];
-    if (description == nil)
-        description = [package shortDescription];
+        if (description != nil)
+            description_ = [NSString stringWithString:description];
 
-    if (description != nil)
-        description_ = [NSString stringWithString:description];
+        commercial_ = [package isCommercial];
 
-    commercial_ = [package isCommercial];
+        NSString *label = nil;
+        bool trusted = false;
 
-    NSString *label = nil;
-    bool trusted = false;
+        if (source != nil) {
+            label = [source label];
+            trusted = [source trusted];
+        } else if ([[package id] isEqualToString:@"firmware"])
+            label = UCLocalize("APPLE");
+        else
+            label = [NSString stringWithFormat:UCLocalize("SLASH_DELIMITED"), UCLocalize("UNKNOWN"), UCLocalize("LOCAL")];
 
-    if (source != nil) {
-        label = [source label];
-        trusted = [source trusted];
-    } else if ([[package id] isEqualToString:@"firmware"])
-        label = UCLocalize("APPLE");
-    else
-        label = [NSString stringWithFormat:UCLocalize("SLASH_DELIMITED"), UCLocalize("UNKNOWN"), UCLocalize("LOCAL")];
+        NSString *from(label);
 
-    NSString *from(label);
+        NSString *section = [package simpleSection];
+        if (section != nil && ![section isEqualToString:label]) {
+            section = [[NSBundle mainBundle] localizedStringForKey:section value:nil table:@"Sections"];
+            from = [NSString stringWithFormat:UCLocalize("PARENTHETICAL"), from, section];
+        }
 
-    NSString *section = [package simpleSection];
-    if (section != nil && ![section isEqualToString:label]) {
-        section = [[NSBundle mainBundle] localizedStringForKey:section value:nil table:@"Sections"];
-        from = [NSString stringWithFormat:UCLocalize("PARENTHETICAL"), from, section];
-    }
+        source_ = [NSString stringWithFormat:UCLocalize("FROM"), from];
 
-    source_ = [NSString stringWithFormat:UCLocalize("FROM"), from];
+        if (NSString *purpose = [package primaryPurpose])
+            badge_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Purposes/%@.png", App_, purpose]];
 
-    if (NSString *purpose = [package primaryPurpose])
-        badge_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Purposes/%@.png", App_, purpose]];
+        UIColor *color;
+        NSString *placard;
 
-    UIColor *color;
-    NSString *placard;
+        if (NSString *mode = [package mode]) {
+            if ([mode isEqualToString:@"REMOVE"] || [mode isEqualToString:@"PURGE"]) {
+                color = RemovingColor_;
+                //placard = @"removing";
+            } else {
+                color = InstallingColor_;
+                //placard = @"installing";
+            }
 
-    if (NSString *mode = [package mode]) {
-        if ([mode isEqualToString:@"REMOVE"] || [mode isEqualToString:@"PURGE"]) {
-            color = RemovingColor_;
-            //placard = @"removing";
+            // XXX: the removing/installing placards are not @2x
+            placard = nil;
         } else {
-            color = InstallingColor_;
-            //placard = @"installing";
+            color = [UIColor whiteColor];
+
+            if ([package installed] != nil)
+                placard = @"installed";
+            else
+                placard = nil;
         }
 
-        // XXX: the removing/installing placards are not @2x
-        placard = nil;
-    } else {
-        color = [UIColor whiteColor];
+        [content_ setBackgroundColor:color];
 
-        if ([package installed] != nil)
-            placard = @"installed";
-        else
-            placard = nil;
+        if (placard != nil)
+            placard_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/%@.png", App_, placard]];
     }
 
-    [content_ setBackgroundColor:color];
-
-    if (placard != nil)
-        placard_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/%@.png", App_, placard]];
-
     [self setNeedsDisplay];
     [content_ setNeedsDisplay];
 }
@@ -5723,14 +5731,15 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 - (void) releaseSubviews {
     list_ = nil;
 
+    package_ = nil;
+    files_ = nil;
+
     [super releaseSubviews];
 }
 
 - (id) initWithDatabase:(Database *)database {
     if ((self = [super init]) != nil) {
         database_ = database;
-
-        files_ = [NSMutableArray arrayWithCapacity:32];
     } return self;
 }
 
@@ -5738,7 +5747,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     package_ = nil;
     name_ = nil;
 
-    [files_ removeAllObjects];
+    files_ = [NSMutableArray arrayWithCapacity:32];
 
     if (package != nil) {
         package_ = package;
@@ -5894,7 +5903,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     if ((self = [super init]) != nil) {
         database_ = database;
         buttons_ = [NSMutableArray arrayWithCapacity:4];
-        name_ = [NSString stringWithString:name];
+        name_ = name == nil ? @"" : [NSString stringWithString:name];
         [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/#!/package/%@", UI_, (id) name_]]];
     } return self;
 }
@@ -6150,18 +6159,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
         database_ = database;
         title_ = [title copy];
         [[self navigationItem] setTitle:title_];
-
-#if TryIndexedCollation
-        if ([[self class] hasIndexedCollation])
-            index_ = [[objc_getClass("UILocalizedIndexedCollation") currentCollation] sectionIndexTitles];
-        else
-#endif
-            index_ = [NSMutableArray arrayWithCapacity:32];
-
-        indices_ = [NSMutableDictionary dictionaryWithCapacity:32];
-
-        packages_ = [NSArray array];
-        sections_ = [NSMutableArray arrayWithCapacity:16];
     } return self;
 }
 
@@ -6184,6 +6181,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 - (void) releaseSubviews {
     list_ = nil;
 
+    packages_ = nil;
+    sections_ = nil;
+    index_ = nil;
+    indices_ = nil;
+
     [super releaseSubviews];
 }
 
@@ -6240,13 +6242,15 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 
     packages_ = packages;
 
-    [indices_ removeAllObjects];
-    [sections_ removeAllObjects];
+    indices_ = [NSMutableDictionary dictionaryWithCapacity:32];
+    sections_ = [NSMutableArray arrayWithCapacity:16];
 
     Section *section = nil;
 
 #if TryIndexedCollation
     if ([[self class] hasIndexedCollation]) {
+        index_ = [[objc_getClass("UILocalizedIndexedCollation") currentCollation] sectionIndexTitles];
+
         id collation = [objc_getClass("UILocalizedIndexedCollation") currentCollation];
         NSArray *titles = [collation sectionIndexTitles];
         int secidx = -1;
@@ -6279,7 +6283,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     } else
 #endif
     {
-        [index_ removeAllObjects];
+        index_ = [NSMutableArray arrayWithCapacity:32];
 
         bool sectioned([self showsSections]);
         if (!sectioned) {
@@ -6325,7 +6329,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 
 - (void) reloadData {
     [super reloadData];
-    [self performSelector:@selector(_reloadData) withObject:nil afterDelay:0];
+
+    if ([self shouldYield])
+        [self performSelector:@selector(_reloadData) withObject:nil afterDelay:0];
+    else
+        [self _reloadData];
 }
 
 - (void) resetCursor {
@@ -7240,15 +7248,15 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 - (void) releaseSubviews {
     list_ = nil;
 
+    sections_ = nil;
+    filtered_ = nil;
+
     [super releaseSubviews];
 }
 
 - (id) initWithDatabase:(Database *)database {
     if ((self = [super init]) != nil) {
         database_ = database;
-
-        sections_ = [NSMutableArray arrayWithCapacity:16];
-        filtered_ = [NSMutableArray arrayWithCapacity:16];
     } return self;
 }
 
@@ -7257,8 +7265,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 
     NSArray *packages = [database_ packages];
 
-    [sections_ removeAllObjects];
-    [filtered_ removeAllObjects];
+    sections_ = [NSMutableArray arrayWithCapacity:16];
+    filtered_ = [NSMutableArray arrayWithCapacity:16];
 
     NSMutableDictionary *sections([NSMutableDictionary dictionaryWithCapacity:32]);
 
@@ -7422,15 +7430,15 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 - (void) releaseSubviews {
     list_ = nil;
 
+    packages_ = nil;
+    sections_ = nil;
+
     [super releaseSubviews];
 }
 
 - (id) initWithDatabase:(Database *)database {
     if ((self = [super init]) != nil) {
         database_ = database;
-
-        packages_ = [NSArray array];
-        sections_ = [NSMutableArray arrayWithCapacity:16];
     } return self;
 }
 
@@ -7475,7 +7483,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
         goto reload;
 
     packages_ = packages;
-    [sections_ removeAllObjects];
+    sections_ = [NSMutableArray arrayWithCapacity:16];
 
     Section *upgradable = [[[Section alloc] initWithName:UCLocalize("AVAILABLE_UPGRADES") localize:NO] autorelease];
     Section *ignored = nil;
@@ -8054,7 +8062,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 @implementation SourceController
 
 - (NSURL *) navigationURL {
-    return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://sources/%@", [source_ name]]];
+    return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://sources/%@", [key_ stringByAddingPercentEscapesIncludingReserved]]];
 }
 
 - (id) initWithDatabase:(Database *)database source:(Source *)source {
@@ -8419,13 +8427,14 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 - (void) releaseSubviews {
     list_ = nil;
 
+    sources_ = nil;
+
     [super releaseSubviews];
 }
 
 - (id) initWithDatabase:(Database *)database {
     if ((self = [super init]) != nil) {
         database_ = database;
-        sources_ = [NSMutableArray arrayWithCapacity:16];
     } return self;
 }
 
@@ -8436,7 +8445,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     if ([database_ popErrorWithTitle:UCLocalize("SOURCES") forOperation:list.ReadMainList()])
         return;
 
-    [sources_ removeAllObjects];
+    sources_ = [NSMutableArray arrayWithCapacity:16];
     [sources_ addObjectsFromArray:[database_ sources]];
     _trace();
     [sources_ sortUsingSelector:@selector(compareByNameAndType:)];
@@ -9481,7 +9490,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
                 controller = [[[SourcesController alloc] initWithDatabase:database_] autorelease];
                 [(SourcesController *)controller showAddSourcePrompt];
             } else {
-                Source *source = [database_ sourceWithKey:argument];
+                Source *source = [database_ sourceWithKey:[argument stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                 controller = [[[SourceController alloc] initWithDatabase:database_ source:source] autorelease];
             }
         }
@@ -10215,6 +10224,8 @@ int main(int argc, char *argv[]) {
         Version_ = [NSNumber numberWithUnsignedInt:1];
         [Metadata_ setObject:Version_ forKey:@"Version"];
 
+        [Metadata_ removeObjectForKey:@"LastUpdate"];
+
         Changed_ = true;
     }
     /* }}} */