1 | /*␊ |
2 | * property_list.h␊ |
3 | *␊ |
4 | * Created by Rekursor on 1/17/10.␊ |
5 | *␊ |
6 | */␊ |
7 | #ifndef __CHPROPERTYLIST_LIST_H␊ |
8 | #define __CHPROPERTYLIST_LIST_H␊ |
9 | ␊ |
10 | #include <CoreFoundation/CFPropertyList.h>␊ |
11 | #include <CoreFoundation/CFURLAccess.h>␊ |
12 | #include <Security/Authorization.h>␊ |
13 | #include <string>␊ |
14 | ␊ |
15 | /****************************************************************/␊ |
16 | ␊ |
17 | /**␊ |
18 | * priviledged command run for cmds like property chmods and restard command␊ |
19 | */␊ |
20 | bool executePrivilegedCmd(AuthorizationRef auth, ␊ |
21 | ␉␉␉␉␉␉ const char* pathToTool, ␊ |
22 | ␉␉␉␉␉␉ const char* args=NULL, ␊ |
23 | ␉␉␉␉␉␉ AuthorizationFlags flags=kAuthorizationFlagDefaults);␊ |
24 | ␊ |
25 | /****************************************************************/␊ |
26 | ␊ |
27 | /**␊ |
28 | * Simple PropertyList Abstraction␊ |
29 | */␊ |
30 | class PropertyList␊ |
31 | {␊ |
32 | ␉␊ |
33 | public:␊ |
34 | ␉PropertyList() : _proplistRef(0), _CFURLRef(0) {␉}␊ |
35 | ␉virtual ~PropertyList();␊ |
36 | ␉␊ |
37 | ␉bool open(const char *propListPath, CFStringRef* errString,␊ |
38 | ␉␉␉ AuthorizationRef auth=NULL, AuthorizationFlags flags=kAuthorizationFlagDefaults);␊ |
39 | ␉bool save(AuthorizationRef auth=NULL, AuthorizationFlags flags=kAuthorizationFlagDefaults);␊ |
40 | ␉bool isValid() const { return _proplistRef!=NULL;}␊ |
41 | ␉␊ |
42 | ␉const char * getStringForKey(const char *key);␊ |
43 | ␉bool setStringForKey(const char* key, const char* value);␊ |
44 | ␉const char * propFilePath() const {␉return _propFilePath.c_str(); }␊ |
45 | ␉␊ |
46 | ␉static bool chmodFile(const char * path, const char * chmodMask,␊ |
47 | ␉␉␉␉␉␉ AuthorizationRef auth, AuthorizationFlags flags=kAuthorizationFlagDefaults);␊ |
48 | protected:␊ |
49 | ␉CFPropertyListRef _proplistRef;␊ |
50 | ␉CFURLRef _CFURLRef;␊ |
51 | ␉std::string _propFilePath; // keep a track of the proplist filename␊ |
52 | };␊ |
53 | ␊ |
54 | #endif␊ |
55 | |