]> git.saurik.com Git - cydia.git/blobdiff - MobileCydia.mm
Add back a documentation warning from the old BrowserView.
[cydia.git] / MobileCydia.mm
index bee208010a59598d9ef6721ec0f35c5e922db590..3ec3cebaeba70646efa01f3da64f6ef34fb93d0b 100644 (file)
@@ -790,6 +790,10 @@ class CYString {
     _finline operator id() {
         return (NSString *) static_cast<CFStringRef>(*this);
     }
+
+    _finline operator const char *() {
+        return reinterpret_cast<const char *>(data_);
+    }
 };
 /* }}} */
 /* C++ NSString Algorithm Adapters {{{ */
@@ -1050,7 +1054,7 @@ static _transient NSMutableDictionary *Packages_;
 static _transient NSMutableDictionary *Sections_;
 static _transient NSMutableDictionary *Sources_;
 static bool Changed_;
-static NSDate *now_;
+static time_t now_;
 
 static bool IsWildcat_;
 /* }}} */
@@ -1710,7 +1714,7 @@ typedef std::map< unsigned long, _H<Source> > SourceMap;
     bool essential_;
     bool obsolete_;
 
-    NSString *latest_;
+    CYString latest_;
     CYString installed_;
 
     CYString id_;
@@ -1732,8 +1736,8 @@ typedef std::map< unsigned long, _H<Source> > SourceMap;
     NSString *role_;
 
     NSMutableDictionary *metadata_;
-    _transient NSDate *firstSeen_;
-    _transient NSDate *lastSeen_;
+    time_t firstSeen_;
+    time_t lastSeen_;
     bool subscribed_;
     bool ignored_;
 }
@@ -1759,7 +1763,7 @@ typedef std::map< unsigned long, _H<Source> > SourceMap;
 - (unichar) index;
 
 - (NSMutableDictionary *) metadata;
-- (NSDate *) seen;
+- (time_t) seen;
 - (BOOL) subscribed;
 - (BOOL) ignored;
 
@@ -1838,7 +1842,7 @@ uint32_t PackageChangesRadix(Package *self, void *) {
         value.bits.ignored = [self ignored] ? 0 : 1;
         value.bits.upgradable = 1;
     } else {
-        value.bits.timestamp = static_cast<uint32_t>([[self seen] timeIntervalSince1970]) >> 2;
+        value.bits.timestamp = static_cast<uint32_t>([self seen]) >> 2;
         value.bits.ignored = 0;
         value.bits.upgradable = 0;
     }
@@ -1959,9 +1963,6 @@ struct PackageNameOrdering :
     if (source_ != nil)
         [source_ release];
 
-    if (latest_ != nil)
-        [latest_ release];
-
     if (sponsor$_ != nil)
         [sponsor$_ release];
     if (author$_ != nil)
@@ -2079,8 +2080,7 @@ struct PackageNameOrdering :
         database_ = database;
 
         _profile(Package$initWithVersion$Latest)
-            const char *latest(StripVersion_(version_.VerStr()));
-            latest_ = (NSString *) CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const uint8_t *>(latest), strlen(latest), kCFStringEncodingASCII, NO);
+            latest_.set(pool_, StripVersion_(version_.VerStr()));
         _end
 
         pkgCache::VerIterator current;
@@ -2132,23 +2132,23 @@ struct PackageNameOrdering :
                 firstSeen_ = now_;
 
                 metadata_ = [[NSMutableDictionary dictionaryWithObjectsAndKeys:
-                    firstSeen_, @"FirstSeen",
-                    latest_, @"LastVersion",
+                    [NSDate dateWithTimeIntervalSince1970:firstSeen_], @"FirstSeen",
+                    static_cast<id>(latest_), @"LastVersion",
                 nil] mutableCopy];
 
                 changed = true;
             } else {
-                firstSeen_ = [metadata_ objectForKey:@"FirstSeen"];
-                lastSeen_ = [metadata_ objectForKey:@"LastSeen"];
+                firstSeen_ = [[metadata_ objectForKey:@"FirstSeen"] timeIntervalSince1970];
+                lastSeen_ = [[metadata_ objectForKey:@"LastSeen"] timeIntervalSince1970];
 
                 if (NSNumber *subscribed = [metadata_ objectForKey:@"IsSubscribed"])
                     subscribed_ = [subscribed boolValue];
 
                 NSString *version([metadata_ objectForKey:@"LastVersion"]);
 
-                if (firstSeen_ == nil) {
-                    firstSeen_ = lastSeen_ == nil ? now_ : lastSeen_;
-                    [metadata_ setObject:firstSeen_ forKey:@"FirstSeen"];
+                if (firstSeen_ == 0) {
+                    firstSeen_ = lastSeen_ == 0 ? now_ : lastSeen_;
+                    [metadata_ setObject:[NSDate dateWithTimeIntervalSince1970:firstSeen_] forKey:@"FirstSeen"];
                     changed = true;
                 }
 
@@ -2158,7 +2158,7 @@ struct PackageNameOrdering :
                 } else if (![version isEqualToString:latest_]) {
                     [metadata_ setObject:latest_ forKey:@"LastVersion"];
                     lastSeen_ = now_;
-                    [metadata_ setObject:lastSeen_ forKey:@"LastSeen"];
+                    [metadata_ setObject:[NSDate dateWithTimeIntervalSince1970:lastSeen_] forKey:@"LastSeen"];
                     changed = true;
                 }
             }
@@ -2307,10 +2307,8 @@ struct PackageNameOrdering :
     return metadata_;
 }
 
-- (NSDate *) seen {
-    if (subscribed_ && lastSeen_ != nil)
-        return lastSeen_;
-    return firstSeen_;
+- (time_t) seen {
+    return subscribed_ ? lastSeen_ : firstSeen_;
 }
 
 - (BOOL) subscribed {
@@ -3230,11 +3228,6 @@ static NSString *Warning_;
     delete policy_;
     policy_ = NULL;
 
-    if (now_ != nil) {
-        [now_ release];
-        now_ = nil;
-    }
-
     cache_.Close();
 
     apr_pool_clear(pool_);
@@ -3271,7 +3264,7 @@ static NSString *Warning_;
 
     unlink("/tmp/cydia.chk");
 
-    now_ = [[NSDate date] retain];
+    now_ = [[NSDate date] timeIntervalSince1970];
 
     policy_ = new pkgDepCache::Policy();
     records_ = new pkgRecords(cache_);
@@ -7021,7 +7014,7 @@ freeing the view controllers on tab change */
     Section *upgradable = [[[Section alloc] initWithName:UCLocalize("AVAILABLE_UPGRADES") localize:NO] autorelease];
     Section *ignored = nil;
     Section *section = nil;
-    NSDate *last = nil;
+    time_t last = 0;
 
     upgrades_ = 0;
     bool unseens = false;
@@ -7035,22 +7028,14 @@ freeing the view controllers on tab change */
 
         if (!uae) {
             unseens = true;
-            NSDate *seen;
+            time_t seen([package seen]);
 
-            _profile(ChangesController$reloadData$Remember)
-                seen = [package seen];
-            _end
-
-            if (section == nil || last != seen && (seen == nil || [seen compare:last] != NSOrderedSame)) {
+            if (section == nil || last != seen) {
                 last = seen;
 
                 NSString *name;
-                if (seen == nil)
-                    name = UCLocalize("UNKNOWN");
-                else {
-                    name = (NSString *) CFDateFormatterCreateStringWithDate(NULL, formatter, (CFDateRef) seen);
-                    [name autorelease];
-                }
+                name = (NSString *) CFDateFormatterCreateStringWithDate(NULL, formatter, (CFDateRef) [NSDate dateWithTimeIntervalSince1970:seen]);
+                [name autorelease];
 
                 _profile(ChangesController$reloadData$Allocate)
                     name = [NSString stringWithFormat:UCLocalize("NEW_AT"), name];
@@ -8567,8 +8552,9 @@ static _finline void _setHomePage(Cydia *self) {
     CYViewController *page = nil;
     int tag = 0;
 
-    if ((page = [self pageForURL:starturl_ hasTag:&tag])) {
-        [starturl_ release];
+    NSLog(@"open url: %@", url);
+
+    if ((page = [self pageForURL:url hasTag:&tag])) {
         [self setPage:page];
         tag_ = tag;
         [tabbar_ setSelectedViewController:(tag_ == -1 ? nil : [[tabbar_ viewControllers] objectAtIndex:tag_])];
@@ -8579,6 +8565,7 @@ static _finline void _setHomePage(Cydia *self) {
 
 - (void) applicationOpenURL:(NSURL *)url {
     [super applicationOpenURL:url];
+    NSLog(@"first: %@", url);
     if (!loaded_) starturl_ = [url retain];
     else [self openCydiaURL:url];
 }
@@ -8767,6 +8754,9 @@ _trace();
         _setHomePage(self);
     }
 
+    [starturl_ release];
+    starturl_ = nil;
+
     [window_ setUserInteractionEnabled:YES];
 
     // XXX: does this actually slow anything down?