forked from akemin-dayo/PreferenceOrganizer2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPO2Common.h
45 lines (36 loc) · 1.93 KB
/
PO2Common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <version.h>
#define DPKG_PATH "/var/lib/dpkg/info/net.angelxwind.preferenceorganizer2.list"
#define NSLog(LogContents, ...) NSLog((@"PreferenceOrganizer 2: %s:%d " LogContents), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define PO2PreferencePath @"/User/Library/Preferences/net.angelxwind.preferenceorganizer2.plist"
#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)
#define PO2BoolLog(arg) PO2Log([NSString stringWithFormat:@"%s = %d", #arg, arg], shouldSyslogSpam)
#define PO2BoolPref(var, key, default) do {\
NSNumber *key = PO2Settings[@STRINGIFY(key)];\
var = key ? [key boolValue] : default;\
PO2BoolLog(var);\
} while (0)
#define PO2IntLog(arg) PO2Log([NSString stringWithFormat:@"%s = %i", #arg, arg], shouldSyslogSpam)
#define PO2IntPref(var, key, default) do {\
NSNumber *key = PO2Settings[@STRINGIFY(key)];\
var = key ? [key intValue] : default;\
PO2IntLog(var);\
} while (0)
#define PO2FloatLog(arg) PO2Log([NSString stringWithFormat:@"%s = %f", #arg, arg], shouldSyslogSpam)
#define PO2FloatPref(var, key, default) do {\
NSNumber *key = PO2Settings[@STRINGIFY(key)];\
var = key ? [key floatValue] : default;\
PO2FloatLog(var);\
} while (0)
#define PO2StringLog(arg) PO2Log([NSString stringWithFormat:@"%s = %@", #arg, arg], shouldSyslogSpam)
#define PO2StringPref(var, key, default) do {\
NSString *key = PO2Settings[@STRINGIFY(key)];\
var = ([key length] > 0) ? key : default;\
PO2StringLog(var);\
} while (0)
#define PO2Observer(funcToCall, listener) CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)funcToCall, CFSTR(listener), NULL, CFNotificationSuspensionBehaviorCoalesce);
#define PO2SyncPrefs()\
NSDictionary *PO2Settings = [NSDictionary dictionaryWithContentsOfFile:PO2PreferencePath];
#define isJonyIve() (kCFCoreFoundationVersionNumber > kCFCoreFoundationVersionNumber_iOS_6_1)