comparison src/gaimrc.c @ 4898:bd37db7531e4

[gaim-migrate @ 5230] I Nathan D. Walped the gaimrc file so that it writes a .gaimrc.save file and then renames it to .gaimrc, in the hopes of avoiding the loss of this data in a time that could be crucial to forward progress. Or something. I tested it with and without specifying -f I added a "Status: Not Available" (or whatever) string to ICQ tooltips. This should help at least until we get some new icons. AHEM. And then I dunno, I was planning on taking it out after that, but it could be useful. Also updated some comments and var names in oscar.c to keep things accurate, because I'm one of those people that actually does that. Go ask your Goddess if you've served her well committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 27 Mar 2003 21:41:21 +0000
parents 78d5be1af6a6
children 5fe846b7603f
comparison
equal deleted inserted replaced
4897:65a0a360e8c4 4898:bd37db7531e4
1396 } 1396 }
1397 1397
1398 void save_prefs() 1398 void save_prefs()
1399 { 1399 {
1400 FILE *f; 1400 FILE *f;
1401 char buf[BUF_LONG]; 1401 gchar *filename;
1402 gchar *filename_temp;
1402 1403
1403 debug_printf("enter save_prefs\n"); 1404 debug_printf("enter save_prefs\n");
1404 if (is_loading_prefs) { 1405 if (is_loading_prefs) {
1405 request_save_prefs = 1; 1406 request_save_prefs = 1;
1406 debug_printf("currently loading, will request save\n"); 1407 debug_printf("currently loading, will request save\n");
1407 return; 1408 return;
1408 } 1409 }
1409 1410
1410 if (opt_rcfile_arg) { 1411 if (opt_rcfile_arg)
1411 g_snprintf(buf, sizeof(buf), "%s", opt_rcfile_arg); 1412 filename = g_build_filename(opt_rcfile_arg, NULL);
1412 } 1413 else if (gaim_home_dir())
1413 else if (gaim_home_dir()) { 1414 filename = g_build_filename(gaim_home_dir(), ".gaimrc", NULL);
1414 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S ".gaimrc", gaim_home_dir()); 1415 else
1415 }
1416 else {
1417 return; 1416 return;
1418 } 1417 filename_temp = g_strdup_printf("%s.save", filename);
1419 if ((f = fopen(buf, "w"))) { 1418
1419 if ((f = fopen(filename_temp, "w"))) {
1420 is_saving_prefs = 1; 1420 is_saving_prefs = 1;
1421 fprintf(f, "# .gaimrc v%d\n", 4); 1421 fprintf(f, "# .gaimrc v%d\n", 4);
1422 gaimrc_write_users(f); 1422 gaimrc_write_users(f);
1423 gaimrc_write_options(f); 1423 gaimrc_write_options(f);
1424 gaimrc_write_sounds(f); 1424 gaimrc_write_sounds(f);
1427 #ifdef GAIM_PLUGINS 1427 #ifdef GAIM_PLUGINS
1428 gaimrc_write_plugins(f); 1428 gaimrc_write_plugins(f);
1429 #endif 1429 #endif
1430 gaimrc_write_proxy(f); 1430 gaimrc_write_proxy(f);
1431 fclose(f); 1431 fclose(f);
1432 1432 chmod(filename, S_IRUSR | S_IWUSR);
1433 chmod(buf, S_IRUSR | S_IWUSR); 1433 if (rename(filename_temp, filename) < 0)
1434 debug_printf("error renaming %s to %s\n", filename_temp, filename);
1434 is_saving_prefs = 0; 1435 is_saving_prefs = 0;
1435 } 1436 } else
1436 else 1437 debug_printf("error opening %s\n", filename_temp);
1437 debug_printf("Error opening .gaimrc\n"); 1438
1438 if (request_load_prefs) { 1439 if (request_load_prefs) {
1439 debug_printf("loading prefs on request\n"); 1440 debug_printf("loading prefs on request\n");
1440 load_prefs(); 1441 load_prefs();
1441 request_load_prefs = 0; 1442 request_load_prefs = 0;
1442 } 1443 }
1444
1445 g_free(filename);
1446 g_free(filename_temp);
1443 debug_printf("exit save_prefs\n"); 1447 debug_printf("exit save_prefs\n");
1444 } 1448 }
1445
1446 1449
1447 1450
1448 /* This function is called by g_slist_insert_sorted to compare the item 1451 /* This function is called by g_slist_insert_sorted to compare the item
1449 * being compared to the rest of the items on the list. 1452 * being compared to the rest of the items on the list.
1450 */ 1453 */