]> git.saurik.com Git - apple/cf.git/blob - CFPreferences.h
CF-550.tar.gz
[apple/cf.git] / CFPreferences.h
1 /*
2 * Copyright (c) 2009 Apple Inc. All rights reserved.
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 */
23 /* CFPreferences.h
24 Copyright (c) 1998-2009, Apple Inc. All rights reserved.
25 */
26
27 #if !defined(__COREFOUNDATION_CFPREFERENCES__)
28 #define __COREFOUNDATION_CFPREFERENCES__ 1
29
30 #include <CoreFoundation/CFBase.h>
31 #include <CoreFoundation/CFArray.h>
32 #include <CoreFoundation/CFString.h>
33
34 CF_EXTERN_C_BEGIN
35
36 CF_EXPORT
37 const CFStringRef kCFPreferencesAnyApplication;
38 CF_EXPORT
39 const CFStringRef kCFPreferencesCurrentApplication;
40 CF_EXPORT
41 const CFStringRef kCFPreferencesAnyHost;
42 CF_EXPORT
43 const CFStringRef kCFPreferencesCurrentHost;
44 CF_EXPORT
45 const CFStringRef kCFPreferencesAnyUser;
46 CF_EXPORT
47 const CFStringRef kCFPreferencesCurrentUser;
48
49 /* NOTE: All CFPropertyListRef values returned from
50 CFPreferences API should be assumed to be immutable.
51 */
52
53 /* The "App" functions search the various sources of defaults that
54 apply to the given application, and should never be called with
55 kCFPreferencesAnyApplication - only kCFPreferencesCurrentApplication
56 or an application's ID (its bundle identifier).
57 */
58
59 /* Searches the various sources of application defaults to find the
60 value for the given key. key must not be NULL. If a value is found,
61 it returns it; otherwise returns NULL. Caller must release the
62 returned value */
63 CF_EXPORT
64 CFPropertyListRef CFPreferencesCopyAppValue(CFStringRef key, CFStringRef applicationID);
65
66 /* Convenience to interpret a preferences value as a boolean directly.
67 Returns false if the key doesn't exist, or has an improper format; under
68 those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */
69 CF_EXPORT
70 Boolean CFPreferencesGetAppBooleanValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat);
71
72 /* Convenience to interpret a preferences value as an integer directly.
73 Returns 0 if the key doesn't exist, or has an improper format; under
74 those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */
75 CF_EXPORT
76 CFIndex CFPreferencesGetAppIntegerValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat);
77
78 /* Sets the given value for the given key in the "normal" place for
79 application preferences. key must not be NULL. If value is NULL,
80 key is removed instead. */
81 CF_EXPORT
82 void CFPreferencesSetAppValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID);
83
84 /* Adds the preferences for the given suite to the app preferences for
85 the specified application. To write to the suite domain, use
86 CFPreferencesSetValue(), below, using the suiteName in place
87 of the appName */
88 CF_EXPORT
89 void CFPreferencesAddSuitePreferencesToApp(CFStringRef applicationID, CFStringRef suiteID);
90
91 CF_EXPORT
92 void CFPreferencesRemoveSuitePreferencesFromApp(CFStringRef applicationID, CFStringRef suiteID);
93
94 /* Writes all changes in all sources of application defaults.
95 Returns success or failure. */
96 CF_EXPORT
97 Boolean CFPreferencesAppSynchronize(CFStringRef applicationID);
98
99 /* The primitive get mechanism; all arguments must be non-NULL
100 (use the constants above for common values). Only the exact
101 location specified by app-user-host is searched. The returned
102 CFType must be released by the caller when it is finished with it. */
103 CF_EXPORT
104 CFPropertyListRef CFPreferencesCopyValue(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName);
105
106 /* Convenience to fetch multiple keys at once. Keys in
107 keysToFetch that are not present in the returned dictionary
108 are not present in the domain. If keysToFetch is NULL, all
109 keys are fetched. */
110 CF_EXPORT
111 CFDictionaryRef CFPreferencesCopyMultiple(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName);
112
113 /* The primitive set function; all arguments except value must be
114 non-NULL. If value is NULL, the given key is removed */
115 CF_EXPORT
116 void CFPreferencesSetValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName);
117
118 /* Convenience to set multiple values at once. Behavior is undefined
119 if a key is in both keysToSet and keysToRemove */
120 CF_EXPORT
121 void CFPreferencesSetMultiple(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName);
122
123 CF_EXPORT
124 Boolean CFPreferencesSynchronize(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName);
125
126 /* Constructs and returns the list of the name of all applications
127 which have preferences in the scope of the given user and host.
128 The returned value must be released by the caller; neither argument
129 may be NULL. */
130 CF_EXPORT
131 CFArrayRef CFPreferencesCopyApplicationList(CFStringRef userName, CFStringRef hostName);
132
133 /* Constructs and returns the list of all keys set in the given
134 location. The returned value must be released by the caller;
135 all arguments must be non-NULL */
136 CF_EXPORT
137 CFArrayRef CFPreferencesCopyKeyList(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName);
138
139
140 CF_EXTERN_C_END
141
142 #endif /* ! __COREFOUNDATION_CFPREFERENCES__ */
143