/*
- * Copyright (c) 2004,2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
CFDictionaryRef config,
Boolean keepInactive)
{
- CFMutableDictionaryRef newConfig;
- Boolean ok;
+ CFMutableDictionaryRef newConfig = NULL;
+ Boolean ok = FALSE;
- if (!isA_CFDictionary(config)) {
- _SCErrorSet(kSCStatusInvalidArgument);
- return FALSE;
+ if (config != NULL) {
+ if (!isA_CFDictionary(config)) {
+ _SCErrorSet(kSCStatusInvalidArgument);
+ return FALSE;
+ }
+ newConfig = CFDictionaryCreateMutableCopy(NULL, 0, config);
+ } else {
+ newConfig = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
- newConfig = CFDictionaryCreateMutableCopy(NULL, 0, config);
-
if (keepInactive) {
CFDictionaryRef curConfig;
- // preserve enabled/disabled state
+ /*
+ * preserve enabled/disabled state
+ */
+
curConfig = SCPreferencesPathGetValue(prefs, path);
if (isA_CFDictionary(curConfig) && CFDictionaryContainsKey(curConfig, kSCResvInactive)) {
// if currently disabled
}
}
- // set new configuration
- ok = SCPreferencesPathSetValue(prefs, path, newConfig);
+ /*
+ * set new configuration
+ */
- CFRelease(newConfig);
+ if (CFDictionaryGetCount(newConfig) == 0) {
+ CFRelease(newConfig);
+ newConfig = NULL;
+ }
+
+ if (newConfig == NULL) {
+ ok = SCPreferencesPathRemoveValue(prefs, path);
+ } else {
+ ok = SCPreferencesPathSetValue(prefs, path, newConfig);
+ }
+
+ if (newConfig != NULL) CFRelease(newConfig);
return ok;
}
CFMutableDictionaryRef newConfig = NULL;
Boolean ok = FALSE;
- // preserve current configuration
+ /*
+ * preserve current configuration
+ */
+
curConfig = SCPreferencesPathGetValue(prefs, path);
if (curConfig != NULL) {
if (!isA_CFDictionary(curConfig)) {
CFDictionarySetValue(newConfig, kSCResvInactive, kCFBooleanTrue);
}
- // update configuration
+ /*
+ * update configuration
+ */
+
if (CFDictionaryGetCount(newConfig) == 0) {
CFRelease(newConfig);
newConfig = NULL;
return NULL;
}
- // convert the XML data into a property list
+ /* convert the XML data into a property list */
templates = CFPropertyListCreateFromXMLData(NULL, xmlTemplates, kCFPropertyListImmutable, &xmlError);
CFRelease(xmlTemplates);
if (templates == NULL) {