diff --git a/Pref360Control/Pref360ControlPref.m b/Pref360Control/Pref360ControlPref.m index 22b15a57..88d243a9 100644 --- a/Pref360Control/Pref360ControlPref.m +++ b/Pref360Control/Pref360ControlPref.m @@ -34,6 +34,7 @@ #import "MyAnalogStick.h" #define NO_ITEMS @"No devices found" +#define SystemPolicyNeeded 27 @interface NSLayoutConstraint (Description) @@ -1014,17 +1015,32 @@ - (BOOL)runInlineAppleScript:(NSString *)scriptString // successful execution if (kAENullEvent != [returnDescriptor descriptorType]) { - return YES; /* Uncomment this to handle the returned values */ -// // script returned an AppleScript result -// if (cAEList == [returnDescriptor descriptorType]) -// { -// // result is a list of other descriptors -// } -// else -// { -// // coerce the result to the appropriate ObjC type -// } + // script returned an AppleScript result + if (cAEList == [returnDescriptor descriptorType]) + { + // result is a list of other descriptors + } + else + { + // coerce the result to the appropriate ObjC type + int retVal = [returnDescriptor int32Value]; + if (retVal == SystemPolicyNeeded) { + NSAlert *alrt = [[NSAlert alloc] init]; + alrt.alertStyle = NSAlertStyleCritical; + alrt.messageText = NSLocalizedStringFromTableInBundle(@"System Policy Needed", @"Localizable", self.bundle, @"System Policy Needed for kext loading"); + alrt.informativeText = NSLocalizedStringFromTableInBundle(@"In order to use this software, your computer must be able to load the kernel extension driver.", @"Localizable", self.bundle, @""); //TODO: better description + [alrt addButtonWithTitle:NSLocalizedStringFromTableInBundle(@"Open Security", @"Localizable", self.bundle, @"")]; + [alrt addButtonWithTitle:NSLocalizedStringFromTableInBundle(@"Cancel", @"Localizable", self.bundle, @"Cancel")]; + + [alrt beginSheetModalForWindow:self.mainView.window completionHandler:^(NSModalResponse returnCode) { + if (returnCode == NSAlertFirstButtonReturn) { + // TODO: implement + } + }]; + } + } + return YES; } } else @@ -1059,9 +1075,9 @@ - (IBAction)toggleDriverEnabled:(NSButton *)sender // The driver should be enabled NSLog(@"Will Enable Driver..."); script = - @"do shell script \"\ + @"return do shell script \"\ cd \\\"/Library/Extensions\\\"\n\ - kextload \\\"360Controller.kext\\\"\n\ + return kextload \\\"360Controller.kext\\\"\n\ \" with administrator privileges\n"; } else if (sender.state == NSOffState) {