This commit is contained in:
opa334
2022-09-03 18:49:53 +02:00
parent 068f735233
commit c2a5e5b988
12 changed files with 353 additions and 131 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
+1
View File
@@ -14,6 +14,7 @@
- (NSString*)displayNameForAppPath:(NSString*)appPath;
- (NSError*)errorForCode:(int)code;
- (int)installIpa:(NSString*)pathToIpa force:(BOOL)force;
- (int)installIpa:(NSString*)pathToIpa;
- (int)uninstallApp:(NSString*)appId;
+16 -3
View File
@@ -67,7 +67,7 @@
errorDescription = @"Failed to create container for app bundle.";
break;
case 171:
errorDescription = @"A non-TrollStore app with the same identifier is already installed. If you are absolutely sure it is not, try refreshing icon cache in TrollStore settings or try rebooting your device.";
errorDescription = @"A non-TrollStore app with the same identifier is already installed. If you are absolutely sure it is not, you can force install it.";
break;
case 172:
errorDescription = @"The app does not seem to contain an Info.plist";
@@ -78,13 +78,26 @@
return error;
}
- (int)installIpa:(NSString*)pathToIpa
- (int)installIpa:(NSString*)pathToIpa force:(BOOL)force
{
int ret = spawnRoot(helperPath(), @[@"install", pathToIpa]);
int ret;
if(force)
{
ret = spawnRoot(helperPath(), @[@"install", pathToIpa, @"force"]);
}
else
{
ret = spawnRoot(helperPath(), @[@"install", pathToIpa]);
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"ApplicationsChanged" object:nil];
return ret;
}
- (int)installIpa:(NSString*)pathToIpa
{
return [self installIpa:pathToIpa force:NO];
}
- (int)uninstallApp:(NSString*)appId
{
int ret = spawnRoot(helperPath(), @[@"uninstall", appId]);
+59 -35
View File
@@ -5,7 +5,7 @@
@implementation TSSceneDelegate
- (void)handleURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts scene:(UIWindowScene*)scene
- (void)doIPAInstall:(NSString*)ipaPath scene:(UIWindowScene*)scene force:(BOOL)force completion:(void (^)(void))completion
{
UIWindow* keyWindow = nil;
for(UIWindow* window in scene.windows)
@@ -17,6 +17,60 @@
}
}
UIAlertController* infoAlert = [UIAlertController alertControllerWithTitle:@"Installing" message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIActivityIndicatorView* activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(5,5,50,50)];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium;
[activityIndicator startAnimating];
[infoAlert.view addSubview:activityIndicator];
[keyWindow.rootViewController presentViewController:infoAlert animated:YES completion:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
// Install IPA
int ret = [[TSApplicationsManager sharedInstance] installIpa:ipaPath force:force];
NSError* error = [[TSApplicationsManager sharedInstance] errorForCode:ret];
NSLog(@"installed app! ret:%d, error: %@", ret, error);
dispatch_async(dispatch_get_main_queue(), ^
{
[infoAlert dismissViewControllerAnimated:YES completion:^
{
if(ret != 0)
{
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Install Error %d", ret] message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
{
if(ret == 171)
{
completion();
}
}];
if(ret == 171)
{
UIAlertAction* forceInstallAction = [UIAlertAction actionWithTitle:@"Force Installation" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
{
[self doIPAInstall:ipaPath scene:scene force:YES completion:completion];
}];
[errorAlert addAction:forceInstallAction];
}
[errorAlert addAction:closeAction];
[keyWindow.rootViewController presentViewController:errorAlert animated:YES completion:nil];
}
if(ret != 171)
{
completion();
}
}];
});
});
}
- (void)handleURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts scene:(UIWindowScene*)scene
{
for(UIOpenURLContext* context in URLContexts)
{
NSLog(@"openURLContexts %@", context.URL);
@@ -39,43 +93,13 @@
respring();
exit(0);
}
};
};
if ([url.pathExtension isEqualToString:@"ipa"])
{
UIAlertController* infoAlert = [UIAlertController alertControllerWithTitle:@"Installing" message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIActivityIndicatorView* activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(5,5,50,50)];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium;
[activityIndicator startAnimating];
[infoAlert.view addSubview:activityIndicator];
[keyWindow.rootViewController presentViewController:infoAlert animated:YES completion:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
// Install IPA
int ret = [[TSApplicationsManager sharedInstance] installIpa:tmpCopyURL.path];
NSError* error = [[TSApplicationsManager sharedInstance] errorForCode:ret];
NSLog(@"installed app! ret:%d, error: %@", ret, error);
dispatch_async(dispatch_get_main_queue(), ^
{
[infoAlert dismissViewControllerAnimated:YES completion:^
{
if(ret != 0)
{
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Install Error %d", ret] message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil];
[errorAlert addAction:closeAction];
[keyWindow.rootViewController presentViewController:errorAlert animated:YES completion:nil];
}
doneBlock(NO);
}];
});
});
[self doIPAInstall:url.path scene:(UIWindowScene*)scene force:NO completion:^{
doneBlock(NO);
}];
}
else if([url.pathExtension isEqualToString:@"tar"])
{
+1 -1
View File
@@ -1,6 +1,6 @@
Package: com.opa334.trollstore
Name: TrollStore
Version: 1.0.1
Version: 1.0.2
Architecture: iphoneos-arm
Description: An awesome application!
Maintainer: opa334