diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-24 06:53:10 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-07 02:41:15 -0800 |
commit | 8a12607430c49711a957509c72036c76b0658dfd (patch) | |
tree | 4f96154e198870147a44a8e6544e0bf8049cc391 /MobileCydia.mm | |
parent | 00984204443f80489556c5344e1d214310004785 (diff) |
Allow JavaScript to swap in package names for ids.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 5b4dc06..015e071 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -4113,6 +4113,8 @@ static NSString *Warning_; return @"refreshSources"; else if (selector == @selector(removeButton)) return @"removeButton"; + else if (selector == @selector(substitutePackageNames:)) + return @"substitutePackageNames"; else if (selector == @selector(scrollToBottom:)) return @"scrollToBottom"; else if (selector == @selector(setButtonImage:withStyle:toFunction:)) @@ -4279,6 +4281,17 @@ static NSString *Warning_; [delegate_ performSelectorOnMainThread:@selector(installPackages:) withObject:packages waitUntilDone:NO]; } +- (NSString *) substitutePackageNames:(NSString *)message { + NSMutableArray *words([[message componentsSeparatedByString:@" "] mutableCopy]); + for (size_t i(0), e([words count]); i != e; ++i) { + NSString *word([words objectAtIndex:i]); + if (Package *package = [[Database sharedInstance] packageWithName:word]) + [words replaceObjectAtIndex:i withObject:[package name]]; + } + + return [words componentsJoinedByString:@" "]; +} + - (void) removeButton { [indirect_ removeButton]; } |