1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // macOS framework bindings
17 //-----------------------------------------------------------------------------
19 #import "util_darwin.h"
21 #import <Foundation/NSString.h>
22 #import <Foundation/NSProcessInfo.h>
25 #import <UIKit/UIKit.h>
27 #import <AppKit/NSApplication.h>
30 #if !defined(USING_ARC)
31 # if __has_feature(objc_arc)
36 #elif EMPTY_DEFINE(USING_ARC)
41 static id activity = nil;
43 //OS X Version 10.10 is defined in OS X 10.10 and later
44 #if defined(MAC_OS_X_VERSION_10_10)
46 @implementation AppDelegate {
47 id <NSObject> activity;
49 void disableAppNap(const char* reason) {
51 //NSLog(@"disableAppNap: %@", @(reason));
52 activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground reason:@(reason)];
58 //NSLog(@"enableAppNap");
59 [[NSProcessInfo processInfo] endActivity:activity];
65 void disableAppNap(const char* reason) {
67 //NSLog(@"disableAppNap: %@", @(reason));
68 activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground reason:@(reason)];
75 //NSLog(@"enableAppNap");
76 [[NSProcessInfo processInfo] endActivity:activity];
84 void disableAppNap(const char* reason) { }
85 void enableAppNap() { }
90 void makeUnfocusable() { }
91 void makeFocusable() { }
92 //OS X Version 10.6 is defined in OS X 10.6 and later
93 #elif defined(MAC_OS_X_VERSION_10_6)
94 void makeUnfocusable() {
95 [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
97 void makeFocusable() {
98 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
101 void makeUnfocusable() { }
102 void makeFocusable() { }