mirror of
https://github.com/opa334/TrollStore.git
synced 2026-08-17 07:26:08 +08:00
Add enable-jit URL scheme endpoint
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#import "TSSceneDelegate.h"
|
||||
#import "TSRootViewController.h"
|
||||
#import "TSUtil.h"
|
||||
#import "TSApplicationsManager.h"
|
||||
#import "TSInstallationController.h"
|
||||
#import <TSPresentationDelegate.h>
|
||||
|
||||
@@ -67,11 +68,64 @@
|
||||
[TSInstallationController handleAppInstallFromRemoteURL:URLToInstall completion:nil];
|
||||
}
|
||||
}
|
||||
else if([components.host isEqualToString:@"enable-jit"])
|
||||
{
|
||||
NSString* BundleIDToEnableJIT;
|
||||
|
||||
for(NSURLQueryItem* queryItem in components.queryItems)
|
||||
{
|
||||
if([queryItem.name isEqualToString:@"bundle-id"])
|
||||
{
|
||||
BundleIDToEnableJIT = queryItem.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(BundleIDToEnableJIT && [BundleIDToEnableJIT isKindOfClass:NSString.class])
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self handleEnableJITForBundleID:BundleIDToEnableJIT];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleEnableJITForBundleID:(NSString *)appId
|
||||
{
|
||||
TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance];
|
||||
|
||||
BOOL didOpen = [appsManager openApplicationWithBundleID:appId];
|
||||
|
||||
// if we failed to open the app, show an alert
|
||||
if(!didOpen)
|
||||
{
|
||||
NSString* failMessage = @"";
|
||||
// we don't have TSAppInfo here so we cannot check the registration state
|
||||
|
||||
NSString* failTitle = [NSString stringWithFormat:@"Failed to open %@", appId];
|
||||
UIAlertController* didFailController = [UIAlertController alertControllerWithTitle:failTitle message:failMessage preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
|
||||
|
||||
[didFailController addAction:cancelAction];
|
||||
[TSPresentationDelegate presentViewController:didFailController animated:YES completion:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
int ret = [appsManager enableJITForBundleID:appId];
|
||||
if (ret != 0)
|
||||
{
|
||||
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:@"Error" message:[NSString stringWithFormat:@"Error enabling JIT: trollstorehelper returned %d", ret] preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil];
|
||||
[errorAlert addAction:closeAction];
|
||||
[TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We want to auto install ldid if either it doesn't exist
|
||||
// or if it's the one from an old TrollStore version that's no longer supported
|
||||
- (void)handleLdidCheck
|
||||
|
||||
@@ -291,7 +291,7 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
||||
|
||||
PSSpecifier* installationSettingsGroupSpecifier = [PSSpecifier emptyGroupSpecifier];
|
||||
installationSettingsGroupSpecifier.name = @"Security";
|
||||
[installationSettingsGroupSpecifier setProperty:@"The URL Scheme, when enabled, will allow apps and websites to trigger TrollStore installations through the apple-magnifier://install?url=<IPA_URL> URL scheme." forKey:@"footerText"];
|
||||
[installationSettingsGroupSpecifier setProperty:@"The URL Scheme, when enabled, will allow apps and websites to trigger TrollStore installations through the apple-magnifier://install?url=<IPA_URL> URL scheme and enable JIT through the apple-magnifier://enable-jit?bundle-id=<BUNDLE_ID> URL scheme." forKey:@"footerText"];
|
||||
|
||||
[_specifiers addObject:installationSettingsGroupSpecifier];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user