# HG changeset patch # User Stu Tomlinson # Date 1194804706 0 # Node ID 6e23ec8b1634e68a99a1bf39510c9e502e80b9eb # Parent 48c6c89a815861a475e6a27a9f239c7ca19f5cfc# Parent a97f24eda509903c52ac04e50b42e61a7b3bdb4e merge of '0f99eebc17d3efab8dac3d72feb857ab25b06cb7' and 'a179eb8d8fc4c8bc156bdf775c617e04119282da' diff -r a97f24eda509 -r 6e23ec8b1634 libpurple/protocols/gg/gg.c --- a/libpurple/protocols/gg/gg.c Sun Nov 11 18:09:33 2007 +0000 +++ b/libpurple/protocols/gg/gg.c Sun Nov 11 18:11:46 2007 +0000 @@ -254,16 +254,14 @@ /* */ /* static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *file) {{{ */ -static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *file) +static void ggp_callback_buddylist_save_ok(PurpleConnection *gc, const char *filename) { PurpleAccount *account = purple_connection_get_account(gc); - FILE *fh; char *buddylist = ggp_buddylist_dump(account); - gchar *msg; purple_debug_info("gg", "Saving...\n"); - purple_debug_info("gg", "file = %s\n", file); + purple_debug_info("gg", "file = %s\n", filename); if (buddylist == NULL) { purple_notify_info(account, _("Save Buddylist..."), @@ -272,30 +270,18 @@ return; } - if ((fh = g_fopen(file, "wb")) == NULL) { - msg = g_strconcat(_("Couldn't open file"), ": ", file, "\n", NULL); - purple_debug_error("gg", "Could not open file: %s\n", file); - purple_notify_error(account, _("Couldn't open file"), msg, NULL); - g_free(msg); - g_free(buddylist); - return; + if(purple_util_write_data_to_file_absolute(filename, buddylist, -1)) { + purple_notify_info(account, _("Save Buddylist..."), + _("Buddylist saved successfully!"), NULL); + } else { + gchar *primary = g_strdup_printf( + _("Couldn't write buddy list for %s to %s"), + purple_account_get_username(account), filename); + purple_notify_error(account, _("Save Buddylist..."), + primary, NULL); + g_free(primary); } - if (!fwrite(buddylist, strlen(buddylist), 1, fh)) { - const gchar *err = g_strerror(errno); - gchar *title = g_strdup_printf( - _("Couldn't write buddylist to %s"), err); - - purple_debug_error("gg", "Error writing %s: %s\n", file, err); - purple_notify_error(account, title, title, err); - - g_free(title); - } else { - purple_notify_info(account, _("Save Buddylist..."), - _("Buddylist saved successfully!"), NULL); - } - - fclose(fh); g_free(buddylist); } /* }}} */