+SCNetworkSetRef
+_SCNetworkSetCreateDefault(SCPreferencesRef prefs)
+{
+ CFStringRef model;
+ Boolean ok = TRUE;
+ SCNetworkSetRef set;
+ CFStringRef setName = NULL;
+
+ set = SCNetworkSetCopyCurrent(prefs);
+ if (set != NULL) {
+ SC_log(LOG_NOTICE, "creating default set w/already existing set");
+ CFRelease(set);
+ _SCErrorSet(kSCStatusKeyExists);
+ return NULL;
+ }
+
+ // create a new ("Automatic") set
+ set = SCNetworkSetCreate(prefs);
+ if (set == NULL) {
+ SC_log(LOG_NOTICE, "could not create \"new\" set: %s",
+ SCErrorString(SCError()));
+ goto done;
+ }
+
+ setName = copy_default_set_name(TRUE);
+ ok = SCNetworkSetSetName(set, setName);
+ CFRelease(setName);
+ if (!ok) {
+ // if we could not save the new set's "name"
+ SC_log(LOG_NOTICE, "could not save the new set's name: %s",
+ SCErrorString(SCError()));
+ goto done;
+ }
+
+ ok = SCNetworkSetSetCurrent(set);
+ if (!ok) {
+ // if we could not make this the "current" set
+ SC_log(LOG_NOTICE, "could not establish new set as current: %s",
+ SCErrorString(SCError()));
+// goto done;
+ }
+
+ model = SCPreferencesGetValue(prefs, MODEL);
+ if (model == NULL) {
+ model = _SC_hw_model(FALSE);
+ SCPreferencesSetValue(prefs, MODEL, model);
+ }
+
+ done :
+
+ if (!ok && (set != NULL)) {
+ SCNetworkSetRemove(set);
+ CFRelease(set);
+ set = NULL;
+ }
+ return set;
+}
+
+