| 184 |
182 |
| 185 pref = &prefs; |
183 pref = &prefs; |
| 186 |
184 |
| 187 /* Create the root preference node */ |
185 /* Create the root preference node */ |
| 188 node = purple_xmlnode_new("pref"); |
186 node = purple_xmlnode_new("pref"); |
| 189 purple_xmlnode_set_attrib(node, "version", PREFS_XML_VERSION); |
187 purple_xmlnode_set_attrib(node, "version", "1"); |
| 190 purple_xmlnode_set_attrib(node, "name", "/"); |
188 purple_xmlnode_set_attrib(node, "name", "/"); |
| 191 |
189 |
| 192 /* All My Children */ |
190 /* All My Children */ |
| 193 for (child = pref->first_child; child != NULL; child = child->sibling) |
191 for (child = pref->first_child; child != NULL; child = child->sibling) |
| 194 pref_to_xmlnode(node, child); |
192 pref_to_xmlnode(node, child); |
| 239 /********************************************************************* |
237 /********************************************************************* |
| 240 * Reading from disk * |
238 * Reading from disk * |
| 241 *********************************************************************/ |
239 *********************************************************************/ |
| 242 |
240 |
| 243 static GList *prefs_stack = NULL; |
241 static GList *prefs_stack = NULL; |
| 244 static gchar *xml_version = NULL; |
|
| 245 |
242 |
| 246 static void |
243 static void |
| 247 prefs_start_element_handler (GMarkupParseContext *context, |
244 prefs_start_element_handler (GMarkupParseContext *context, |
| 248 const gchar *element_name, |
245 const gchar *element_name, |
| 249 const gchar **attribute_names, |
246 const gchar **attribute_names, |
| 279 pref_type = PURPLE_PREF_PATH_LIST; |
276 pref_type = PURPLE_PREF_PATH_LIST; |
| 280 else |
277 else |
| 281 return; |
278 return; |
| 282 } else if(purple_strequal(attribute_names[i], "value")) { |
279 } else if(purple_strequal(attribute_names[i], "value")) { |
| 283 pref_value = attribute_values[i]; |
280 pref_value = attribute_values[i]; |
| 284 } else if(purple_strequal(attribute_names[i], "version")) { |
|
| 285 g_free(xml_version); |
|
| 286 xml_version = g_strdup(attribute_values[i]); |
|
| 287 if (purple_version_strcmp(xml_version, PREFS_XML_VERSION) > 0) |
|
| 288 purple_debug_warning("prefs", "prefs.xml on disk is for a " |
|
| 289 "newer version of libpurple"); |
|
| 290 } |
281 } |
| 291 } |
282 } |
| 292 |
283 |
| 293 if ((pref_type == PURPLE_PREF_BOOLEAN || pref_type == PURPLE_PREF_INT) && |
284 if ((pref_type == PURPLE_PREF_BOOLEAN || pref_type == PURPLE_PREF_INT) && |
| 294 pref_value == NULL) { |
285 pref_value == NULL) { |
| 1334 list = g_list_append(list, g_strdup_printf("%s%s%s", name, sep, child->name)); |
1325 list = g_list_append(list, g_strdup_printf("%s%s%s", name, sep, child->name)); |
| 1335 } |
1326 } |
| 1336 return list; |
1327 return list; |
| 1337 } |
1328 } |
| 1338 |
1329 |
| 1339 static void |
1330 void |
| 1340 update_old_prefs(void) |
1331 purple_prefs_update_old() |
| 1341 { |
1332 { |
| 1342 purple_prefs_rename("/core", "/purple"); |
1333 purple_prefs_rename("/core", "/purple"); |
| 1343 |
1334 |
| 1344 /* Remove some no-longer-used prefs */ |
1335 /* Remove some no-longer-used prefs */ |
| 1345 purple_prefs_remove("/purple/away/auto_response/enabled"); |
1336 purple_prefs_remove("/purple/away/auto_response/enabled"); |
| 1440 purple_prefs_remove("/purple/contact/offline_score"); |
1431 purple_prefs_remove("/purple/contact/offline_score"); |
| 1441 purple_prefs_remove("/purple/contact/away_score"); |
1432 purple_prefs_remove("/purple/contact/away_score"); |
| 1442 purple_prefs_remove("/purple/contact/idle_score"); |
1433 purple_prefs_remove("/purple/contact/idle_score"); |
| 1443 |
1434 |
| 1444 purple_prefs_load(); |
1435 purple_prefs_load(); |
| 1445 |
1436 purple_prefs_update_old(); |
| 1446 if (purple_version_strcmp(xml_version, "1.1") < 0) { |
|
| 1447 purple_debug_info("prefs", "Migrating prefs.xml from version %s to 1.1\n", |
|
| 1448 xml_version); |
|
| 1449 update_old_prefs(); |
|
| 1450 } |
|
| 1451 |
|
| 1452 g_free(xml_version); |
|
| 1453 xml_version = NULL; |
|
| 1454 } |
1437 } |
| 1455 |
1438 |
| 1456 void |
1439 void |
| 1457 purple_prefs_uninit() |
1440 purple_prefs_uninit() |
| 1458 { |
1441 { |