2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * Modification History
29 * June 1, 2001 Allan Nathanson <ajn@apple.com>
30 * - public API conversion
32 * March 24, 2000 Allan Nathanson <ajn@apple.com>
41 __SCDynamicStoreCopyNotifiedKeys(SCDynamicStoreRef store
, CFArrayRef
*notifierKeys
)
43 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
44 CFStringRef sessionKey
;
46 CFMutableDictionaryRef newInfo
;
48 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("__SCDynamicStoreCopyNotifiedKeys:"));
50 if (!store
|| (storePrivate
->server
== MACH_PORT_NULL
)) {
51 return kSCStatusNoStoreSession
; /* you must have an open session to play */
54 sessionKey
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("%d"), storePrivate
->server
);
55 info
= CFDictionaryGetValue(sessionData
, sessionKey
);
57 (CFDictionaryContainsKey(info
, kSCDChangedKeys
) == FALSE
)) {
58 CFRelease(sessionKey
);
59 *notifierKeys
= CFArrayCreate(NULL
, NULL
, 0, &kCFTypeArrayCallBacks
);;
62 newInfo
= CFDictionaryCreateMutableCopy(NULL
, 0, info
);
64 *notifierKeys
= CFDictionaryGetValue(newInfo
, kSCDChangedKeys
);
65 CFRetain(*notifierKeys
);
67 CFDictionaryRemoveValue(newInfo
, kSCDChangedKeys
);
68 if (CFDictionaryGetCount(newInfo
) > 0) {
69 CFDictionarySetValue(sessionData
, sessionKey
, newInfo
);
71 CFDictionaryRemoveValue(sessionData
, sessionKey
);
74 CFRelease(sessionKey
);
82 _notifychanges(mach_port_t server
,
83 xmlDataOut_t
*listRef
, /* raw XML bytes */
84 mach_msg_type_number_t
*listLen
,
88 serverSessionRef mySession
= getSession(server
);
89 CFArrayRef notifierKeys
; /* array of CFStringRef's */
92 if (_configd_verbose
) {
93 SCLog(TRUE
, LOG_DEBUG
, CFSTR("List notification keys which have changed."));
94 SCLog(TRUE
, LOG_DEBUG
, CFSTR(" server = %d"), server
);
101 *sc_status
= kSCStatusNoStoreSession
; /* you must have an open session to play */
105 *sc_status
= __SCDynamicStoreCopyNotifiedKeys(mySession
->store
, ¬ifierKeys
);
106 if (*sc_status
!= kSCStatusOK
) {
110 /* serialize the array of keys */
111 ok
= _SCSerialize(notifierKeys
, NULL
, (void **)listRef
, (CFIndex
*)listLen
);
112 CFRelease(notifierKeys
);
114 *sc_status
= kSCStatusFailed
;