]> git.saurik.com Git - cydia.git/blobdiff - Cydia.mm
Added icon for the sources tab on the iPad.
[cydia.git] / Cydia.mm
index 55627d374effa3b71d1eed8ff68982c2edd7484d..1dfe4313ddaf2cce36e2f08046dc077507108161 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -311,7 +311,7 @@ static _finline void UpdateExternalStatus(uint64_t newStatus) {
     } return self;
 }
 
-- (void)_updateFrameForDisplay {
+- (void) _updateFrameForDisplay {
     [super _updateFrameForDisplay];
     if ([self cancelButtonIndex] == -1) {
         NSArray *buttons = [self buttons];
@@ -618,7 +618,9 @@ void CFArrayInsertionSortValues(CFMutableArrayRef array, CFRange range, CFCompar
 @end
 /* }}} */
 
-NSUInteger WebScriptObject$countByEnumeratingWithState$objects$count$(WebScriptObject *self, SEL sel, NSFastEnumerationState *state, id *objects, NSUInteger count) {
+@implementation WebScriptObject (NSFastEnumeration)
+
+- (NSUInteger) countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)objects count:(NSUInteger)count {
     size_t length([self count] - state->state);
     if (length <= 0)
         return 0;
@@ -631,6 +633,8 @@ NSUInteger WebScriptObject$countByEnumeratingWithState$objects$count$(WebScriptO
     return length;
 }
 
+@end
+
 NSUInteger DOMNodeList$countByEnumeratingWithState$objects$count$(DOMNodeList *self, SEL sel, NSFastEnumerationState *state, id *objects, NSUInteger count) {
     size_t length([self length] - state->state);
     if (length <= 0)
@@ -1046,14 +1050,14 @@ static UIFont *Font18Bold_;
 static UIFont *Font22Bold_;
 
 static const char *Machine_ = NULL;
-static const NSString *System_ = NULL;
-static const NSString *SerialNumber_ = nil;
-static const NSString *ChipID_ = nil;
-static const NSString *Token_ = nil;
-static const NSString *UniqueID_ = nil;
-static const NSString *Build_ = nil;
-static const NSString *Product_ = nil;
-static const NSString *Safari_ = nil;
+static NSString *System_ = nil;
+static NSString *SerialNumber_ = nil;
+static NSString *ChipID_ = nil;
+static NSString *Token_ = nil;
+static NSString *UniqueID_ = nil;
+static NSString *Build_ = nil;
+static NSString *Product_ = nil;
+static NSString *Safari_ = nil;
 
 static CFLocaleRef Locale_;
 static NSArray *Languages_;
@@ -7817,7 +7821,7 @@ freeing the view controllers on tab change */
     [super dealloc];
 }
 
-- (id) initWithDatabase: (Database *)database {
+- (id) initWithDatabase:(Database *)database {
     if ((self = [super init]) != nil) {
         database_ = database;
 
@@ -8342,29 +8346,40 @@ static _finline void _setHomePage(Cydia *self) {
 #endif
 }
 
+// Returns the navigation controller for the queuing badge.
+- (id) queueBadgeController {
+    int index = [self indexOfTabWithTag:kManageTag];
+    if (index == -1) index = [self indexOfTabWithTag:kInstalledTag];
+    
+    return [[tabbar_ viewControllers] objectAtIndex:index];
+}
+
 - (void) cancelAndClear:(bool)clear {
     @synchronized (self) {
         if (clear) {
-            /* XXX: clear marks instead of reloading data */
-            /*pkgCacheFile &cache([database_ cache]);
+            // Clear all marks.
+            pkgCacheFile &cache([database_ cache]);
             for (pkgCache::PkgIterator iterator = cache->PkgBegin(); !iterator.end(); ++iterator) {
-                if (!cache[iterator].Keep()) cache->MarkKeep(iterator, false, false);
+                // Unmark method taken from Synaptic Package Manager.
+                               // Thanks for being sane, unlike Aptitude.
+                               if (!cache[iterator].Keep()) {
+                                       cache->MarkKeep(iterator, false);
+                                       cache->SetReInstall(iterator, false);
+                               }
             }
 
-            [self updateData];
-
+                       // Stop queuing.
             Queuing_ = false;
-            [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:nil];
-            [queueDelegate_ queueStatusDidChange];*/
-            [self reloadData];
+            [[[self queueBadgeController] tabBarItem] setBadgeValue:nil];
         } else {
+                       // Start queuing.
             Queuing_ = true;
-
-            [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:UCLocalize("Q_D")];
-            [(CYNavigationController *)[tabbar_ selectedViewController] reloadData];
-
-            [queueDelegate_ queueStatusDidChange];
-        }
+            [[[self queueBadgeController] tabBarItem] setBadgeValue:UCLocalize("Q_D")];
+               }
+        
+               // Show the changes in the current view.
+        [(CYNavigationController *) [tabbar_ selectedViewController] reloadData];
+        [queueDelegate_ queueStatusDidChange];
     }
 }
 
@@ -8713,7 +8728,6 @@ int main(int argc, char *argv[]) { _pooled
     PackageName = reinterpret_cast<CYString &(*)(Package *, SEL)>(method_getImplementation(class_getInstanceMethod([Package class], @selector(cyname))));
 
     /* Library Hacks {{{ */
-    class_addMethod(objc_getClass("WebScriptObject"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &WebScriptObject$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16");
     class_addMethod(objc_getClass("DOMNodeList"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &DOMNodeList$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16");
 
     $WebDefaultUIKitDelegate = objc_getClass("WebDefaultUIKitDelegate");