From e5ef463558668995c614f22f940c2ba43ae86680 Mon Sep 17 00:00:00 2001 From: Dre Dall'Ara <42755661+singlekeycap@users.noreply.github.com> Date: Wed, 13 Sep 2023 09:47:02 -0400 Subject: [PATCH 1/2] Do it a less stupid way --- vaonprefs/VaonRootListController.m | 36 ++++-------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/vaonprefs/VaonRootListController.m b/vaonprefs/VaonRootListController.m index 1da89f1..9cef6ab 100644 --- a/vaonprefs/VaonRootListController.m +++ b/vaonprefs/VaonRootListController.m @@ -6,22 +6,6 @@ NSArray *rootPreferenceKeys; NSArray *batteryPreferenceKeys; -//Function to check if an alias exists at a path -BOOL aliasExistsAtPath(NSString *path) { - NSURL *url = [NSURL fileURLWithPath:path]; - NSError *error; - BOOL isAlias = [url checkResourceIsReachableAndReturnError:&error]; - - if (isAlias) { - return YES; - } else if (!isAlias && error.code == NSFileReadNoSuchFileError) { - return NO; - } else { - NSLog(@"Error: %@", error); - return NO; - } -} - @implementation BatteryColorPreferenceController // -(id)init { @@ -43,11 +27,7 @@ -(void)viewDidLoad { -(void)respring { pid_t pid; const char* args[] = {"killall", "-9", "backboardd", NULL}; - if (aliasExistsAtPath(@"/var/jb")){ - posix_spawn(&pid, "/var/jb/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); - } else{ - posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); - } + posix_spawn(&pid, ROOT_PATH("/usr/bin/killall"), NULL, NULL, (char* const*)args, NULL); } -(void)askBeforeRespring { @@ -113,11 +93,7 @@ -(void)viewDidLoad { -(void)respring { pid_t pid; const char* args[] = {"killall", "-9", "backboardd", NULL}; - if (aliasExistsAtPath(@"/var/jb")){ - posix_spawn(&pid, "/var/jb/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); - } else{ - posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); - } + posix_spawn(&pid, ROOT_PATH("/usr/bin/killall"), NULL, NULL, (char* const*)args, NULL); } -(void)askBeforeRespring { @@ -206,11 +182,7 @@ -(NSArray *)specifiers { -(void)respring { pid_t pid; const char* args[] = {"killall", "-9", "backboardd", NULL}; - if (aliasExistsAtPath(@"/var/jb")){ - posix_spawn(&pid, "/var/jb/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); - } else{ - posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); - } + posix_spawn(&pid, ROOT_PATH("/usr/bin/killall"), NULL, NULL, (char* const*)args, NULL); } -(void)askBeforeRespring { UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Are you sure you want to respring?" message:@"" preferredStyle:UIAlertControllerStyleAlert]; @@ -330,4 +302,4 @@ - (CGFloat)preferredHeightForWidth:(CGFloat)width { // Return a custom cell height. return 100.f; } -@end \ No newline at end of file +@end From 5fcdc8aae843d8dd6c255e1963a5b0ca09f42ae9 Mon Sep 17 00:00:00 2001 From: Dre Dall'Ara <42755661+singlekeycap@users.noreply.github.com> Date: Wed, 13 Sep 2023 09:47:25 -0400 Subject: [PATCH 2/2] Do it a less stupid way --- vaonprefs/VaonRootListController.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vaonprefs/VaonRootListController.h b/vaonprefs/VaonRootListController.h index 512885e..92016eb 100644 --- a/vaonprefs/VaonRootListController.h +++ b/vaonprefs/VaonRootListController.h @@ -1,6 +1,7 @@ #import #import #import +#import #import @interface VaonRootListController : PSListController @@ -21,4 +22,4 @@ UIImageView *imageView; UIImage *image; } -@end \ No newline at end of file +@end