]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/util_darwin.m
usb communication (device side) refactoring
[proxmark3-svn] / client / util_darwin.m
1 //-----------------------------------------------------------------------------
2 // (c) 2018 AntiCat
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //-----------------------------------------------------------------------------
8 // macOS framework bindings
9 //-----------------------------------------------------------------------------
10
11 #import "util_darwin.h"
12
13 #import <Foundation/NSString.h>
14 #import <Foundation/NSProcessInfo.h>
15 #import <AppKit/NSApplication.h>
16
17 static id activity = nil;
18
19 //OS X Version 10.10 is defined in OS X 10.10 and later
20 #if defined(MAC_OS_X_VERSION_10_10)
21 void disableAppNap(const char* reason) {
22 if(activity == nil) {
23 //NSLog(@"disableAppNap: %@", @(reason));
24 activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground reason:@(reason)];
25 [activity retain];
26 }
27 }
28
29 void enableAppNap() {
30 if(activity != nil) {
31 //NSLog(@"enableAppNap");
32 [[NSProcessInfo processInfo] endActivity:activity];
33 [activity release];
34 activity = nil;
35 }
36 }
37
38 #else
39 void disableAppNap(const char* reason) { }
40 void enableAppNap() { }
41 #endif
42
43 //OS X Version 10.6 is defined in OS X 10.6 and later
44 #if defined(MAC_OS_X_VERSION_10_6)
45 void makeUnfocusable() {
46 [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
47 }
48
49 void makeFocusable() {
50 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
51 }
52 #else
53 void makeUnfocusable() { }
54 void makeFocusable() { }
55 #endif
Impressum, Datenschutz