-
- /* Need to regenerate the new configuration for new model */
- if (new_model != NULL) {
- CFStringRef old_model;
-
- old_model = SCPreferencesGetValue(prefs, MODEL);
- if ((old_model != NULL) && !_SC_CFEqual(old_model, new_model)) {
- CFIndex count;
- CFIndex index;
- CFArrayRef keys;
-
- keys = SCPreferencesCopyKeyList(prefs);
- count = (keys != NULL) ? CFArrayGetCount(keys) : 0;
- // if new hardware
- for (index = 0; index < count; index++) {
- CFStringRef existing_key;
-
- existing_key = CFArrayGetValueAtIndex(keys, index);
- if (isA_CFString(existing_key) != NULL) {
- CFStringRef new_key;
- CFPropertyListRef value;
-
- /* If it already contains a Model
- or if it already contains a MODEL:KEY key skip it*/
- if (CFEqual(existing_key, MODEL)
- || CFStringFind(existing_key, CFSTR(":"), 0).location
- != kCFNotFound) {
- continue;
- }
-
- value = SCPreferencesGetValue(prefs, existing_key);
-
- /* Create a new key as OLD_MODEL:OLD_KEY */
- new_key = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@:%@"),
- old_model, existing_key);
- SCPreferencesSetValue(prefs, new_key, value);
- if (!CFEqual(existing_key, kSCPrefSystem)) {
- /* preserve existing host names */
- SCPreferencesRemoveValue(prefs, existing_key);
- }
- CFRelease(new_key);
- }
- }
-
- if (keys != NULL) {
- CFRelease(keys);
- }
- }
- /* Set the new model */
- SCPreferencesSetValue(prefs, MODEL, new_model);
+ if ((old_model != NULL) && !_SC_CFEqual(old_model, new_model)) {
+ SC_log(LOG_NOTICE, "Hardware model changed\n"
+ " created on \"%@\"\n"
+ " now on \"%@\"",
+ old_model,
+ new_model);
+
+ // save (and clean) the configuration that was created for "other" hardware
+ savePastConfiguration(old_model);