Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #676 from xrubioj/accessibility-verification
Browse files Browse the repository at this point in the history
Adds a verification on whether the process is trusted for Accessibility
  • Loading branch information
jacobwgillespie authored Nov 18, 2018
2 parents 870ad05 + 7796877 commit 1ae4ab7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions radiant-player-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ - (void)RadiantScreenUnlocked {
*/
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

[self verifyAccessibility];

[window setDelegate:self];

// Load the user preferences.
Expand Down Expand Up @@ -622,6 +625,30 @@ - (void) ddhidAppleMikey:(DDHidAppleMikey *)mikey press:(unsigned)usageId upOrDo
}
}

#pragma mark - Accessibility

- (void) verifyAccessibility
{
Boolean trusted = AXIsProcessTrusted();
NSLog(@"Accessibility: process is trusted check: %s", (trusted ? "YES" : "NO"));
if (trusted) {
return;
}

NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Media keys"];
[alert setInformativeText:@"Radiant Player needs Accessibility permission to be able to listen for media keys. You will need to enable it from System Preferences.\n\nIf you\'ve updated Radiant Player and you\'re seeing this message, you will have to disable and reenable the permission in order for Radiant Player to work properly.\n\nRadiant Player will now close, and you will have to restart it after enabling the permission."];
[alert addButtonWithTitle:@"Close"];
[alert runModal];

const void *tkeys[1] = { kAXTrustedCheckOptionPrompt };
const void *tvalues[1] = { kCFBooleanTrue };
CFDictionaryRef options = CFDictionaryCreate(NULL, tkeys, tvalues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
NSLog(@"Accessibility: process is trusted check with prompt: %s", (AXIsProcessTrustedWithOptions(options) ? "YES" : "NO"));

exit(1);
}

#pragma mark - Web Browser Actions

- (void) load:(id)sender
Expand Down

0 comments on commit 1ae4ab7

Please sign in to comment.