2 * Copyright (c) 2000 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@
27 _SCDNotifierGetChanges(SCDSessionRef session
, CFArrayRef
*notifierKeys
)
29 SCDSessionPrivateRef sessionPrivate
= (SCDSessionPrivateRef
)session
;
30 CFStringRef sessionKey
;
32 CFMutableDictionaryRef newInfo
;
34 SCDLog(LOG_DEBUG
, CFSTR("_SCDNotifierGetChanges:"));
36 if ((session
== NULL
) || (sessionPrivate
->server
== MACH_PORT_NULL
)) {
40 sessionKey
= CFStringCreateWithFormat(NULL
, NULL
, CFSTR("%d"), sessionPrivate
->server
);
41 info
= CFDictionaryGetValue(sessionData
, sessionKey
);
43 (CFDictionaryContainsKey(info
, kSCDChangedKeys
) == FALSE
)) {
44 CFRelease(sessionKey
);
45 *notifierKeys
= CFArrayCreate(NULL
, NULL
, 0, &kCFTypeArrayCallBacks
);;
48 newInfo
= CFDictionaryCreateMutableCopy(NULL
, 0, info
);
50 *notifierKeys
= CFDictionaryGetValue(newInfo
, kSCDChangedKeys
);
51 CFRetain(*notifierKeys
);
53 CFDictionaryRemoveValue(newInfo
, kSCDChangedKeys
);
54 if (CFDictionaryGetCount(newInfo
) > 0) {
55 CFDictionarySetValue(sessionData
, sessionKey
, newInfo
);
57 CFDictionaryRemoveValue(sessionData
, sessionKey
);
60 CFRelease(sessionKey
);
67 _notifychanges(mach_port_t server
,
68 xmlDataOut_t
*listRef
, /* raw XML bytes */
69 mach_msg_type_number_t
*listLen
,
74 serverSessionRef mySession
= getSession(server
);
75 CFArrayRef notifierKeys
; /* array of CFStringRef's */
76 CFDataRef xmlList
; /* list (XML serialized) */
78 SCDLog(LOG_DEBUG
, CFSTR("List notification keys which have changed."));
79 SCDLog(LOG_DEBUG
, CFSTR(" server = %d"), server
);
81 *scd_status
= _SCDNotifierGetChanges(mySession
->session
, ¬ifierKeys
);
82 if (*scd_status
!= SCD_OK
) {
89 * serialize the array, copy it into an allocated buffer which will be
90 * released when it is returned as part of a Mach message.
92 xmlList
= CFPropertyListCreateXMLData(NULL
, notifierKeys
);
93 CFRelease(notifierKeys
);
94 *listLen
= CFDataGetLength(xmlList
);
95 status
= vm_allocate(mach_task_self(), (void *)listRef
, *listLen
, TRUE
);
96 if (status
!= KERN_SUCCESS
) {
97 SCDLog(LOG_DEBUG
, CFSTR("vm_allocate(): %s"), mach_error_string(status
));
101 *scd_status
= SCD_FAILED
;
105 bcopy((char *)CFDataGetBytePtr(xmlList
), *listRef
, *listLen
);