#import "TSPHRootViewController.h" #import "../Helper/Shared.h" #import "../Store/TSUtil.h" @implementation TSPHRootViewController - (BOOL)isTrollStore { return NO; } - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadSpecifiers) name:UIApplicationWillEnterForegroundNotification object:nil]; fetchLatestTrollStoreVersion(^(NSString* latestVersion) { NSString* currentVersion = [self getTrollStoreVersion]; NSComparisonResult result = [currentVersion compare:latestVersion options:NSNumericSearch]; if(result == NSOrderedAscending) { _newerVersion = latestVersion; dispatch_async(dispatch_get_main_queue(), ^ { [self reloadSpecifiers]; }); } }); } - (NSMutableArray*)specifiers { if(!_specifiers) { _specifiers = [NSMutableArray new]; PSSpecifier* infoGroupSpecifier = [PSSpecifier emptyGroupSpecifier]; infoGroupSpecifier.name = @"Info"; [_specifiers addObject:infoGroupSpecifier]; PSSpecifier* infoSpecifier = [PSSpecifier preferenceSpecifierNamed:@"TrollStore" target:self set:nil get:@selector(getTrollStoreInfoString) detail:nil cell:PSTitleValueCell edit:nil]; infoSpecifier.identifier = @"info"; [infoSpecifier setProperty:@YES forKey:@"enabled"]; [_specifiers addObject:infoSpecifier]; BOOL isInstalled = trollStoreAppPath(); if(_newerVersion && isInstalled) { // Update TrollStore PSSpecifier* updateTrollStoreSpecifier = [PSSpecifier preferenceSpecifierNamed:[NSString stringWithFormat:@"Update TrollStore to %@", _newerVersion] target:self set:nil get:nil detail:nil cell:PSButtonCell edit:nil]; updateTrollStoreSpecifier.identifier = @"updateTrollStore"; [updateTrollStoreSpecifier setProperty:@YES forKey:@"enabled"]; updateTrollStoreSpecifier.buttonAction = @selector(updateTrollStorePressed); [_specifiers addObject:updateTrollStoreSpecifier]; } PSSpecifier* utilitiesGroupSpecifier = [PSSpecifier emptyGroupSpecifier]; [_specifiers addObject:utilitiesGroupSpecifier]; if(isInstalled) { PSSpecifier* refreshAppRegistrationsSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Refresh App Registrations" target:self set:nil get:nil detail:nil cell:PSButtonCell edit:nil]; refreshAppRegistrationsSpecifier.identifier = @"refreshAppRegistrations"; [refreshAppRegistrationsSpecifier setProperty:@YES forKey:@"enabled"]; refreshAppRegistrationsSpecifier.buttonAction = @selector(refreshAppRegistrationsPressed); [_specifiers addObject:refreshAppRegistrationsSpecifier]; PSSpecifier* uninstallTrollStoreSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Uninstall TrollStore" target:self set:nil get:nil detail:nil cell:PSButtonCell edit:nil]; uninstallTrollStoreSpecifier.identifier = @"uninstallTrollStore"; [uninstallTrollStoreSpecifier setProperty:@YES forKey:@"enabled"]; [uninstallTrollStoreSpecifier setProperty:NSClassFromString(@"PSDeleteButtonCell") forKey:@"cellClass"]; uninstallTrollStoreSpecifier.buttonAction = @selector(uninstallTrollStorePressed); [_specifiers addObject:uninstallTrollStoreSpecifier]; } else { PSSpecifier* installTrollStoreSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Install TrollStore" target:self set:nil get:nil detail:nil cell:PSButtonCell edit:nil]; installTrollStoreSpecifier.identifier = @"installTrollStore"; [installTrollStoreSpecifier setProperty:@YES forKey:@"enabled"]; installTrollStoreSpecifier.buttonAction = @selector(installTrollStorePressed); [_specifiers addObject:installTrollStoreSpecifier]; } if(![NSBundle.mainBundle.bundleIdentifier hasPrefix:@"com.opa334."]) { [_specifiers addObject:[PSSpecifier emptyGroupSpecifier]]; PSSpecifier* uninstallPersistenceHelperSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Uninstall Persistence Helper" target:self set:nil get:nil detail:nil cell:PSButtonCell edit:nil]; uninstallPersistenceHelperSpecifier.identifier = @"uninstallPersistenceHelper"; [uninstallPersistenceHelperSpecifier setProperty:@YES forKey:@"enabled"]; [uninstallPersistenceHelperSpecifier setProperty:NSClassFromString(@"PSDeleteButtonCell") forKey:@"cellClass"]; uninstallPersistenceHelperSpecifier.buttonAction = @selector(uninstallPersistenceHelperPressed); [_specifiers addObject:uninstallPersistenceHelperSpecifier]; } } [(UINavigationItem *)self.navigationItem setTitle:@"TrollStore Helper"]; return _specifiers; } - (NSString*)getTrollStoreInfoString { NSString* version = [self getTrollStoreVersion]; if(!version) { return @"Not Installed"; } else { return [NSString stringWithFormat:@"Installed, %@", version]; } } - (void)handleUninstallation { _newerVersion = nil; [super handleUninstallation]; } @end