diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-09 15:15:53 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-09 15:15:53 -0800 |
commit | b3c8e69c20e49220c44b0d8bef0e9016a413ad52 (patch) | |
tree | 4f1bcd2cccedd96d3ed4bdd1821bea9f16df0fa3 /MobileCydia.mm | |
parent | 718c267cc5f20ad720aff5958a12f4df4d605c71 (diff) |
Add cydia.{g,s}etMetadataValue().
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 4ab0ea1..7b20df6 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -697,6 +697,7 @@ static NSMutableDictionary *Metadata_; static _transient NSMutableDictionary *Settings_; static _transient NSString *Role_; static _transient NSMutableDictionary *Packages_; +static _transient NSMutableDictionary *Values_; static _transient NSMutableDictionary *Sections_; static _transient NSMutableDictionary *Sources_; static bool Changed_; @@ -3874,6 +3875,8 @@ static _H<NSMutableSet> Diversions_; return @"getPreferredLanguages"; else if (selector == @selector(getPackageById:)) return @"getPackageById"; + else if (selector == @selector(getMetadataValue:)) + return @"getMetadataValue"; else if (selector == @selector(getSessionValue:)) return @"getSessionValue"; else if (selector == @selector(installPackages:)) @@ -3886,6 +3889,8 @@ static _H<NSMutableSet> Diversions_; return @"refreshSources"; else if (selector == @selector(removeButton)) return @"removeButton"; + else if (selector == @selector(setMetadataValue::)) + return @"setMetadataValue"; else if (selector == @selector(setSessionValue::)) return @"setSessionValue"; else if (selector == @selector(substitutePackageNames:)) @@ -3986,6 +3991,21 @@ static _H<NSMutableSet> Diversions_; return value; } +- (id) getMetadataValue:(NSString *)key { +@synchronized (Values_) { + return [Values_ objectForKey:key]; +} } + +- (void) setMetadataValue:(NSString *)key :(NSString *)value { +@synchronized (Values_) { + if (value == (id) [WebUndefined undefined]) + [Values_ removeObjectForKey:key]; + else + [Values_ setObject:value forKey:key]; + + [delegate_ performSelectorOnMainThread:@selector(updateValues) withObject:nil waitUntilDone:YES]; +} } + - (id) getSessionValue:(NSString *)key { @synchronized (SessionData_) { return [SessionData_ objectForKey:key]; @@ -8905,6 +8925,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { Changed_ = true; } +- (void) updateValues { + Changed_ = true; +} + - (void) resolve { pkgProblemResolver *resolver = [database_ resolver]; @@ -9908,6 +9932,8 @@ int main(int argc, char *argv[]) { Settings_ = [Metadata_ objectForKey:@"Settings"]; Packages_ = [Metadata_ objectForKey:@"Packages"]; + + Values_ = [Metadata_ objectForKey:@"Values"]; Sections_ = [Metadata_ objectForKey:@"Sections"]; Sources_ = [Metadata_ objectForKey:@"Sources"]; @@ -9917,6 +9943,11 @@ int main(int argc, char *argv[]) { if (Settings_ != nil) Role_ = [Settings_ objectForKey:@"Role"]; + if (Values_ == nil) { + Values_ = [[[NSMutableDictionary alloc] initWithCapacity:4] autorelease]; + [Metadata_ setObject:Values_ forKey:@"Values"]; + } + if (Sections_ == nil) { Sections_ = [[[NSMutableDictionary alloc] initWithCapacity:32] autorelease]; [Metadata_ setObject:Sections_ forKey:@"Sections"]; |