2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
24 * Modification History
26 * May 19, 2001 Allan Nathanson <ajn@apple.com>
34 __SCDynamicStoreNotifyValue(SCDynamicStoreRef store
, CFStringRef key
)
36 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
37 int sc_status
= kSCStatusOK
;
39 Boolean newValue
= FALSE
;
40 CFPropertyListRef value
;
42 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("__SCDynamicStoreNotifyValue:"));
43 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" key = %@"), key
);
45 if (!store
|| (storePrivate
->server
== MACH_PORT_NULL
)) {
46 return kSCStatusNoStoreSession
; /* you must have an open session to play */
50 * 1. Ensure that we hold the lock.
52 sc_status
= __SCDynamicStoreLock(store
, TRUE
);
53 if (sc_status
!= kSCStatusOK
) {
58 * 2. Tickle the value in the dynamic store
60 dict
= CFDictionaryGetValue(storeData
, key
);
61 if (!dict
|| !CFDictionaryGetValueIfPresent(dict
, kSCDData
, (const void **)&value
)) {
62 /* key doesn't exist (or data never defined) */
63 value
= CFDateCreate(NULL
, CFAbsoluteTimeGetCurrent());
67 /* replace or store initial/temporary existing value */
68 __SCDynamicStoreSetValue(store
, key
, value
);
71 /* remove the value we just created */
72 __SCDynamicStoreRemoveValue(store
, key
);
77 * 3. Release our lock.
79 __SCDynamicStoreUnlock(store
, TRUE
);
86 _confignotify(mach_port_t server
,
87 xmlData_t keyRef
, /* raw XML bytes */
88 mach_msg_type_number_t keyLen
,
92 serverSessionRef mySession
= getSession(server
);
93 CFStringRef key
; /* key (un-serialized) */
95 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("Notify key in configuration database."));
96 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" server = %d"), server
);
98 /* un-serialize the key */
99 if (!_SCUnserialize((CFPropertyListRef
*)&key
, (void *)keyRef
, keyLen
)) {
100 *sc_status
= kSCStatusFailed
;
104 if (!isA_CFString(key
)) {
106 *sc_status
= kSCStatusInvalidArgument
;
110 *sc_status
= __SCDynamicStoreNotifyValue(mySession
->store
, key
);