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 isValid() const { return _proplistRef!=NULL;}
38
39bool open(const char *propListPath, CFStringRef* errString,
40 AuthorizationRef auth=NULL, AuthorizationFlags flags=kAuthorizationFlagDefaults);
41bool save(AuthorizationRef auth=NULL, AuthorizationFlags flags=kAuthorizationFlagDefaults);
42
43const char * getStringForKey(const char *key);
44const char * getStringForKey(const std::string& key)
45{
46std::string str= key;
47return getStringForKey(str.c_str());
48}
49bool setStringForKey(const char* key, const char* value);
50bool setStringForKey(const std::string& key, const std::string& value)
51{
52return setStringForKey(key.c_str(), value.c_str());
53}
54bool removeKeyAndValue(const char *key);
55
56const char * propFilePath() const {return _propFilePath.c_str(); }
57
58static bool chmodFile(const char * path, const char * chmodMask,
59 AuthorizationRef auth, AuthorizationFlags flags=kAuthorizationFlagDefaults);
60protected:
61CFPropertyListRef _proplistRef;
62CFURLRef _CFURLRef;
63std::string _propFilePath; // keep a track of the proplist filename
64};
65
66#endif
67

Archive Download this file

Revision: 49