This commit is contained in:
opa334
2022-09-03 03:08:59 +02:00
parent a8e72590a5
commit ee08cfeb1d
12 changed files with 179 additions and 74 deletions
+2 -2
View File
@@ -50,7 +50,7 @@
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.0.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
@@ -215,7 +215,7 @@
</dict>
</array>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<false/>
<key>TSRootBinaries</key>
<array>
<string>trollstorehelper</string>
+5 -2
View File
@@ -6,7 +6,10 @@
- (void)reloadTable
{
[self.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^
{
[self.tableView reloadData];
});
}
- (void)loadView
@@ -52,7 +55,7 @@
{
NSString* appPath = [[TSApplicationsManager sharedInstance] installedAppPaths][indexPath.row];
NSString* appId = [[TSApplicationsManager sharedInstance] appIdForAppPath:appPath];
[[TSApplicationsManager sharedInstance] uninstallApp:appId error:nil];
[[TSApplicationsManager sharedInstance] uninstallApp:appId];
}
}
+3 -2
View File
@@ -13,7 +13,8 @@
- (NSString*)appIdForAppPath:(NSString*)appPath;
- (NSString*)displayNameForAppPath:(NSString*)appPath;
- (int)installIpa:(NSString*)pathToIpa error:(NSError**)error;
- (int)uninstallApp:(NSString*)appId error:(NSError**)error;
- (NSError*)errorForCode:(int)code;
- (int)installIpa:(NSString*)pathToIpa;
- (int)uninstallApp:(NSString*)appId;
@end
+32 -4
View File
@@ -2,6 +2,8 @@
#import "TSUtil.h"
#import "../Helper/Shared.h"
#define TrollStoreErrorDomain @"TrollStoreErrorDomain"
@implementation TSApplicationsManager
+ (instancetype)sharedInstance
@@ -50,16 +52,42 @@
return displayName;
}
- (int)installIpa:(NSString*)pathToIpa error:(NSError**)error
- (NSError*)errorForCode:(int)code
{
int ret = spawnRoot(helperPath(), @[@"install", pathToIpa]) == 0;
NSString* errorDescription = @"Unknown Error";
switch(code)
{
case 166:
errorDescription = @"The IPA file does not exist or is not accessible.";
break;
case 167:
errorDescription = @"The IPA file does not appear to contain an app.";
break;
case 170:
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.";
break;
case 172:
errorDescription = @"The app does not seem to contain an Info.plist";
break;
}
NSError* error = [NSError errorWithDomain:TrollStoreErrorDomain code:code userInfo:@{NSLocalizedDescriptionKey : errorDescription}];
return error;
}
- (int)installIpa:(NSString*)pathToIpa
{
int ret = spawnRoot(helperPath(), @[@"install", pathToIpa]);
[[NSNotificationCenter defaultCenter] postNotificationName:@"ApplicationsChanged" object:nil];
return ret;
}
- (int)uninstallApp:(NSString*)appId error:(NSError**)error
- (int)uninstallApp:(NSString*)appId
{
int ret = spawnRoot(helperPath(), @[@"uninstall", appId]) == 0;
int ret = spawnRoot(helperPath(), @[@"uninstall", appId]);
[[NSNotificationCenter defaultCenter] postNotificationName:@"ApplicationsChanged" object:nil];
return ret;
}
+67 -26
View File
@@ -5,45 +5,86 @@
@implementation TSSceneDelegate
- (void)handleURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts
- (void)handleURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts scene:(UIWindowScene*)scene
{
UIWindow* keyWindow = nil;
for(UIWindow* window in scene.windows)
{
if(window.isKeyWindow)
{
keyWindow = window;
break;
}
}
for(UIOpenURLContext* context in URLContexts)
{
NSLog(@"openURLContexts %@", context.URL);
NSURL* url = context.URL;
if (url != nil && [url isFileURL]) {
BOOL shouldExit = NO;
[url startAccessingSecurityScopedResource];
NSURL* tmpCopyURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:url.lastPathComponent]];
[[NSFileManager defaultManager] copyItemAtURL:url toURL:tmpCopyURL error:nil];
void (^doneBlock)(BOOL) = ^(BOOL shouldExit)
{
[[NSFileManager defaultManager] removeItemAtURL:tmpCopyURL error:nil];
[url stopAccessingSecurityScopedResource];
[[NSFileManager defaultManager] removeItemAtURL:url error:nil];
if(shouldExit)
{
NSLog(@"Respring + Exit");
respring();
exit(0);
}
};
if ([url.pathExtension isEqualToString:@"ipa"]) {
// Install IPA
NSError* error;
int ret = [[TSApplicationsManager sharedInstance] installIpa:tmpCopyURL.path error:&error];
NSLog(@"installed app! ret:%d, error: %@", ret, error);
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);
}];
});
});
}
else if([url.pathExtension isEqualToString:@"tar"])
{
// Update TrollStore itself
NSLog(@"Updating TrollStore...");
int ret = spawnRoot(helperPath(), @[@"install-trollstore", tmpCopyURL.path]);
if(ret == 0) shouldExit = YES;
doneBlock(ret == 0);
NSLog(@"Updated TrollStore!");
}
[[NSFileManager defaultManager] removeItemAtURL:tmpCopyURL error:nil];
[url stopAccessingSecurityScopedResource];
if(shouldExit)
{
NSLog(@"Respring + Exit");
respring();
exit(0);
}
}
}
}
@@ -55,16 +96,16 @@
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
NSLog(@"scene:%@ willConnectToSession:%@ options:%@", scene, session, connectionOptions);
if(connectionOptions.URLContexts.count)
{
[self handleURLContexts:connectionOptions.URLContexts];
}
UIWindowScene* windowScene = (UIWindowScene*)scene;
_window = [[UIWindow alloc] initWithWindowScene:windowScene];
_rootViewController = [[TSRootViewController alloc] init];
_window.rootViewController = _rootViewController;
[_window makeKeyAndVisible];
if(connectionOptions.URLContexts.count)
{
[self handleURLContexts:connectionOptions.URLContexts scene:(UIWindowScene*)scene];
}
}
@@ -103,7 +144,7 @@
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts
{
NSLog(@"scene:%@ openURLContexts:%@", scene, URLContexts);
[self handleURLContexts:URLContexts];
[self handleURLContexts:URLContexts scene:(UIWindowScene*)scene];
}
@end
+3 -1
View File
@@ -103,6 +103,7 @@
detail:nil
cell:PSStaticTextCell
edit:nil];
[ldidInstalledSpecifier setProperty:@NO forKey:@"enabled"];
ldidInstalledSpecifier.identifier = @"ldidInstalled";
[_specifiers addObject:ldidInstalledSpecifier];
}
@@ -135,6 +136,7 @@
detail:nil
cell:PSStaticTextCell
edit:nil];
[installedPersistenceHelperSpecifier setProperty:@NO forKey:@"enabled"];
installedPersistenceHelperSpecifier.identifier = @"persistenceHelperInstalled";
[_specifiers addObject:installedPersistenceHelperSpecifier];
}
@@ -153,7 +155,7 @@
detail:nil
cell:PSStaticTextCell
edit:nil];
[installedPersistenceHelperSpecifier setProperty:@NO forKey:@"enabled"];
installedPersistenceHelperSpecifier.identifier = @"persistenceHelperInstalled";
[_specifiers addObject:installedPersistenceHelperSpecifier];
+1 -1
View File
@@ -56,7 +56,7 @@ int spawnRoot(NSString* path, NSArray* args)
do
{
if (waitpid(task_pid, &status, 0) != -1) {
printf("Child status %dn", WEXITSTATUS(status));
NSLog(@"Child status %d", WEXITSTATUS(status));
} else
{
perror("waitpid");
+1 -1
View File
@@ -1,6 +1,6 @@
Package: com.opa334.trollstore
Name: TrollStore
Version: 1.0
Version: 1.0.1
Architecture: iphoneos-arm
Description: An awesome application!
Maintainer: opa334