]>
Commit | Line | Data |
---|---|---|
d8925383 | 1 | /* |
8ca704e1 | 2 | * Copyright (c) 2011 Apple Inc. All rights reserved. |
d8925383 A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
f64f9b69 | 23 | |
d8925383 | 24 | /* CFPreferences.h |
8ca704e1 | 25 | Copyright (c) 1998-2011, Apple Inc. All rights reserved. |
d8925383 A |
26 | */ |
27 | ||
28 | #if !defined(__COREFOUNDATION_CFPREFERENCES__) | |
29 | #define __COREFOUNDATION_CFPREFERENCES__ 1 | |
30 | ||
31 | #include <CoreFoundation/CFBase.h> | |
32 | #include <CoreFoundation/CFArray.h> | |
33 | #include <CoreFoundation/CFString.h> | |
34 | ||
bd5b749c | 35 | CF_EXTERN_C_BEGIN |
d8925383 A |
36 | |
37 | CF_EXPORT | |
38 | const CFStringRef kCFPreferencesAnyApplication; | |
39 | CF_EXPORT | |
40 | const CFStringRef kCFPreferencesCurrentApplication; | |
41 | CF_EXPORT | |
42 | const CFStringRef kCFPreferencesAnyHost; | |
43 | CF_EXPORT | |
44 | const CFStringRef kCFPreferencesCurrentHost; | |
45 | CF_EXPORT | |
46 | const CFStringRef kCFPreferencesAnyUser; | |
47 | CF_EXPORT | |
48 | const CFStringRef kCFPreferencesCurrentUser; | |
49 | ||
50 | /* NOTE: All CFPropertyListRef values returned from | |
51 | CFPreferences API should be assumed to be immutable. | |
52 | */ | |
53 | ||
54 | /* The "App" functions search the various sources of defaults that | |
55 | apply to the given application, and should never be called with | |
56 | kCFPreferencesAnyApplication - only kCFPreferencesCurrentApplication | |
57 | or an application's ID (its bundle identifier). | |
58 | */ | |
59 | ||
60 | /* Searches the various sources of application defaults to find the | |
61 | value for the given key. key must not be NULL. If a value is found, | |
62 | it returns it; otherwise returns NULL. Caller must release the | |
63 | returned value */ | |
64 | CF_EXPORT | |
65 | CFPropertyListRef CFPreferencesCopyAppValue(CFStringRef key, CFStringRef applicationID); | |
66 | ||
67 | /* Convenience to interpret a preferences value as a boolean directly. | |
68 | Returns false if the key doesn't exist, or has an improper format; under | |
69 | those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ | |
70 | CF_EXPORT | |
71 | Boolean CFPreferencesGetAppBooleanValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); | |
72 | ||
73 | /* Convenience to interpret a preferences value as an integer directly. | |
74 | Returns 0 if the key doesn't exist, or has an improper format; under | |
75 | those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ | |
76 | CF_EXPORT | |
77 | CFIndex CFPreferencesGetAppIntegerValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); | |
78 | ||
79 | /* Sets the given value for the given key in the "normal" place for | |
80 | application preferences. key must not be NULL. If value is NULL, | |
81 | key is removed instead. */ | |
82 | CF_EXPORT | |
83 | void CFPreferencesSetAppValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID); | |
84 | ||
85 | /* Adds the preferences for the given suite to the app preferences for | |
86 | the specified application. To write to the suite domain, use | |
87 | CFPreferencesSetValue(), below, using the suiteName in place | |
88 | of the appName */ | |
89 | CF_EXPORT | |
90 | void CFPreferencesAddSuitePreferencesToApp(CFStringRef applicationID, CFStringRef suiteID); | |
91 | ||
92 | CF_EXPORT | |
93 | void CFPreferencesRemoveSuitePreferencesFromApp(CFStringRef applicationID, CFStringRef suiteID); | |
94 | ||
95 | /* Writes all changes in all sources of application defaults. | |
96 | Returns success or failure. */ | |
97 | CF_EXPORT | |
98 | Boolean CFPreferencesAppSynchronize(CFStringRef applicationID); | |
99 | ||
100 | /* The primitive get mechanism; all arguments must be non-NULL | |
101 | (use the constants above for common values). Only the exact | |
102 | location specified by app-user-host is searched. The returned | |
103 | CFType must be released by the caller when it is finished with it. */ | |
104 | CF_EXPORT | |
105 | CFPropertyListRef CFPreferencesCopyValue(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); | |
106 | ||
107 | /* Convenience to fetch multiple keys at once. Keys in | |
108 | keysToFetch that are not present in the returned dictionary | |
109 | are not present in the domain. If keysToFetch is NULL, all | |
110 | keys are fetched. */ | |
111 | CF_EXPORT | |
112 | CFDictionaryRef CFPreferencesCopyMultiple(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); | |
113 | ||
114 | /* The primitive set function; all arguments except value must be | |
115 | non-NULL. If value is NULL, the given key is removed */ | |
116 | CF_EXPORT | |
117 | void CFPreferencesSetValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); | |
118 | ||
119 | /* Convenience to set multiple values at once. Behavior is undefined | |
120 | if a key is in both keysToSet and keysToRemove */ | |
121 | CF_EXPORT | |
122 | void CFPreferencesSetMultiple(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); | |
123 | ||
124 | CF_EXPORT | |
125 | Boolean CFPreferencesSynchronize(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); | |
126 | ||
127 | /* Constructs and returns the list of the name of all applications | |
128 | which have preferences in the scope of the given user and host. | |
129 | The returned value must be released by the caller; neither argument | |
130 | may be NULL. */ | |
131 | CF_EXPORT | |
132 | CFArrayRef CFPreferencesCopyApplicationList(CFStringRef userName, CFStringRef hostName); | |
133 | ||
134 | /* Constructs and returns the list of all keys set in the given | |
135 | location. The returned value must be released by the caller; | |
136 | all arguments must be non-NULL */ | |
137 | CF_EXPORT | |
138 | CFArrayRef CFPreferencesCopyKeyList(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); | |
139 | ||
140 | ||
bd5b749c | 141 | CF_EXTERN_C_END |
d8925383 A |
142 | |
143 | #endif /* ! __COREFOUNDATION_CFPREFERENCES__ */ | |
144 |