From: Jay Freeman (saurik) Date: Tue, 14 Oct 2008 08:51:19 +0000 (+0000) Subject: Added LastSeen support (for Subscriptions). X-Git-Url: https://git.saurik.com/cydia.git/commitdiff_plain/6b92acabc8c971bc5e1a0d3a5f8cc9b4e19e93fb Added LastSeen support (for Subscriptions). --- diff --git a/Cydia.app/Sections/WebClips.png b/Cydia.app/Sections/WebClips.png new file mode 100644 index 00000000..7ed4053c Binary files /dev/null and b/Cydia.app/Sections/WebClips.png differ diff --git a/Cydia.mm b/Cydia.mm index 52b7fc90..55048243 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -1194,7 +1194,12 @@ NSString *Scour(const char *field, const char *begin, const char *end) { database_ = database; version_ = [database_ policy]->GetCandidateVer(iterator_); - latest_ = version_.end() ? nil : [StripVersion([NSString stringWithUTF8String:version_.VerStr()]) retain]; + NSString *latest = version_.end() ? nil : [NSString stringWithUTF8String:version_.VerStr()]; + latest_ = [StripVersion(latest) retain]; + + pkgCache::VerIterator current = iterator_.CurrentVer(); + NSString *installed = current.end() ? nil : [NSString stringWithUTF8String:current.VerStr()]; + installed_ = [StripVersion(installed) retain]; if (!version_.end()) file_ = version_.FileList(); @@ -1203,9 +1208,6 @@ NSString *Scour(const char *field, const char *begin, const char *end) { file_ = pkgCache::VerFileIterator(cache, cache.VerFileP); } - pkgCache::VerIterator current = iterator_.CurrentVer(); - installed_ = current.end() ? nil : [StripVersion([NSString stringWithUTF8String:current.VerStr()]) retain]; - id_ = [[[NSString stringWithUTF8String:iterator_.Name()] lowercaseString] retain]; if (!file_.end()) { @@ -1251,12 +1253,42 @@ NSString *Scour(const char *field, const char *begin, const char *end) { } } + NSString *solid(latest == nil ? installed : latest); + bool changed(false); + NSMutableDictionary *metadata = [Packages_ objectForKey:id_]; - if (metadata == nil || [metadata count] == 0) { + if (metadata == nil) { metadata = [NSMutableDictionary dictionaryWithObjectsAndKeys: now_, @"FirstSeen", nil]; + if (solid != nil) + [metadata setObject:solid forKey:@"LastVersion"]; + changed = true; + } else { + NSDate *first([metadata objectForKey:@"FirstSeen"]); + NSDate *last([metadata objectForKey:@"LastSeen"]); + NSString *version([metadata objectForKey:@"LastVersion"]); + + if (first == nil) { + first = last == nil ? now_ : last; + [metadata setObject:first forKey:@"FirstSeen"]; + changed = true; + } + + if (solid != nil) + if (version == nil) { + [metadata setObject:solid forKey:@"LastVersion"]; + changed = true; + } else if (![version isEqualToString:solid]) { + [metadata setObject:solid forKey:@"LastVersion"]; + last = now_; + [metadata setObject:last forKey:@"LastSeen"]; + changed = true; + } + } + + if (changed) { [Packages_ setObject:metadata forKey:id_]; Changed_ = true; } @@ -1328,7 +1360,16 @@ NSString *Scour(const char *field, const char *begin, const char *end) { } - (NSDate *) seen { - return [[Packages_ objectForKey:id_] objectForKey:@"FirstSeen"]; + NSDictionary *metadata([Packages_ objectForKey:id_]); + bool subscribed; + if (NSNumber *isSubscribed = [metadata objectForKey:@"IsSubscribed"]) + subscribed = [isSubscribed boolValue]; + else + subscribed = false; + if (subscribed) + if (NSDate *last = [metadata objectForKey:@"LastSeen"]) + return last; + return [metadata objectForKey:@"FirstSeen"]; } - (NSString *) latest {