]> git.saurik.com Git - cydia.git/commitdiff
Allow JavaScript to swap in package names for ids.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 24 Feb 2011 14:53:10 +0000 (06:53 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 7 Mar 2011 10:41:15 +0000 (02:41 -0800)
MobileCydia.mm

index 5b4dc06c9aee6f47128f657e0adb85fafcf6e1cb..015e071fc0c6cea68b9fc3636879d5a57aa959d1 100644 (file)
@@ -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];
 }