static NSMutableDictionary *Metadata_;
static NSMutableDictionary *Packages_;
+static bool Changed_;
static NSDate *now_;
NSString *GetLastUpdate() {
_transient Database *database_;
pkgCache::VerIterator version_;
pkgCache::VerFileIterator file_;
+
Source *source_;
+ bool cached_;
NSString *latest_;
NSString *installed_;
@implementation Package
- (void) dealloc {
+ if (source_ != nil)
+ [source_ release];
+
[latest_ release];
if (installed_ != nil)
[installed_ release];
if (website_ != nil)
[website_ release];
- [source_ release];
-
[super dealloc];
}
version_ = version;
file_ = file;
+ latest_ = [[NSString stringWithCString:version_.VerStr()] retain];
+ installed_ = iterator_.CurrentVer().end() ? nil : [[NSString stringWithCString:iterator_.CurrentVer().VerStr()] retain];
+
pkgRecords::Parser *parser = &[database_ records]->Lookup(file_);
const char *begin, *end;
parser->GetRec(begin, end);
- latest_ = [[NSString stringWithCString:version_.VerStr()] retain];
- installed_ = iterator_.CurrentVer().end() ? nil : [[NSString stringWithCString:iterator_.CurrentVer().VerStr()] retain];
-
id_ = [[[NSString stringWithCString:iterator_.Name()] lowercaseString] retain];
name_ = Scour("Name", begin, end);
if (name_ != nil)
if (website_ != nil)
website_ = [website_ retain];
- source_ = [[database_ getSource:file_.File()] retain];
-
NSMutableDictionary *metadata = [Packages_ objectForKey:id_];
if (metadata == nil || [metadata count] == 0) {
metadata = [NSMutableDictionary dictionaryWithObjectsAndKeys:
nil];
[Packages_ setObject:metadata forKey:id_];
+ Changed_ = true;
}
} return self;
}
}
- (Source *) source {
+ if (!cached_) {
+ source_ = [[database_ getSource:file_.File()] retain];
+ cached_ = true;
+ }
+
return source_;
}
}
[Metadata_ setObject:[NSDate date] forKey:@"LastUpdate"];
+ Changed_ = true;
}
}
if (list != nil) {
[files_ addObjectsFromArray:[list componentsSeparatedByString:@"\n"]];
[files_ removeLastObject];
+ [files_ sortUsingSelector:@selector(compare:)];
}
}
[database_ reloadData];
- size_t count = 16;
-
if (Packages_ == nil) {
- Packages_ = [[NSMutableDictionary alloc] initWithCapacity:count];
+ Packages_ = [[NSMutableDictionary alloc] initWithCapacity:128];
[Metadata_ setObject:Packages_ forKey:@"Packages"];
}
[self removeApplicationBadge];
}
- _assert([Metadata_ writeToFile:@"/var/lib/cydia/metadata.plist" atomically:YES] == YES);
+ if (Changed_) {
+ _assert([Metadata_ writeToFile:@"/var/lib/cydia/metadata.plist" atomically:YES] == YES);
+ Changed_ = false;
+ }
/* XXX: this is just stupid */
if (tag_ != 2)
[search_ reloadData];
[book_ reloadData];
+
/*[hud show:NO];
[hud removeFromSuperview];*/
}
$(target)g++ -Wall -Werror -o $@ $< -framework Foundation -framework CoreFoundation -lobjc
Cydia: Cydia.mm ../uicaboodle.m/*.mm *.h makefile
- $(target)g++ -I../uicaboodle.m -fobjc-call-cxx-cdtors -g3 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework IOKit -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework GraphicsServices -framework LayerKit -lobjc -lapt-pkg -lpcre -fobjc-exceptions -I/apl/i20 -F$${PKG_ROOT}/System/Library/PrivateFrameworks
+ $(target)g++ -I../uicaboodle.m -fobjc-call-cxx-cdtors -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework IOKit -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework GraphicsServices -framework LayerKit -lobjc -lapt-pkg -lpcre -fobjc-exceptions -I/apl/i20 -F$${PKG_ROOT}/System/Library/PrivateFrameworks
.PHONY: all clean