Mercurial > pidgin
changeset 21327:48c6c89a8158
merge of '0d945ca4ad9da6d9547272ea91c99f3dc3909ac6'
and '521a02708a29c2d4c933477bab544075f089526f'
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Sun, 11 Nov 2007 16:56:03 +0000 |
parents | 93e9e022a470 (diff) 97dc2a474513 (current diff) |
children | 6e23ec8b1634 be50064a83e0 |
files | libpurple/protocols/gg/gg.c |
diffstat | 1 files changed, 12 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/gg/gg.c Sun Nov 11 15:57:35 2007 +0000 +++ b/libpurple/protocols/gg/gg.c Sun Nov 11 16:56:03 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); } /* }}} */