From 8a12607430c49711a957509c72036c76b0658dfd Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 24 Feb 2011 06:53:10 -0800 Subject: Allow JavaScript to swap in package names for ids. --- MobileCydia.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'MobileCydia.mm') 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]; } -- cgit v1.2.3