Chameleon Applications

Chameleon Applications Svn Source Tree

Root/trunk/ChameleonPrefPane/Sources/PropertyList.h

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 */
20bool 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 */
30class PropertyList
31{
32
33public:
34PropertyList() : _proplistRef(0), _CFURLRef(0) {}
35virtual ~PropertyList();
36
37bool open(const char *propListPath, CFStringRef* errString,
38 AuthorizationRef auth=NULL, AuthorizationFlags flags=kAuthorizationFlagDefaults);
39bool save(AuthorizationRef auth=NULL, AuthorizationFlags flags=kAuthorizationFlagDefaults);
40bool isValid() const { return _proplistRef!=NULL;}
41
42const char * getStringForKey(const char *key);
43bool setStringForKey(const char* key, const char* value);
44const char * propFilePath() const {return _propFilePath.c_str(); }
45
46static bool chmodFile(const char * path, const char * chmodMask,
47 AuthorizationRef auth, AuthorizationFlags flags=kAuthorizationFlagDefaults);
48protected:
49CFPropertyListRef _proplistRef;
50CFURLRef _CFURLRef;
51std::string _propFilePath; // keep a track of the proplist filename
52};
53
54#endif
55

Archive Download this file

Revision: 47