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