pidgin/gtkconv.c

changeset 24832
c0c176845e54
parent 24600
e757835a3b39
child 24856
e44f55c3f6af
child 25000
64c498855e85
equal deleted inserted replaced
24831:735338087cc3 24832:c0c176845e54
2757 static void 2757 static void
2758 saveicon_writefile_cb(void *user_data, const char *filename) 2758 saveicon_writefile_cb(void *user_data, const char *filename)
2759 { 2759 {
2760 PidginConversation *gtkconv = (PidginConversation *)user_data; 2760 PidginConversation *gtkconv = (PidginConversation *)user_data;
2761 PurpleConversation *conv = gtkconv->active_conv; 2761 PurpleConversation *conv = gtkconv->active_conv;
2762 FILE *fp;
2763 PurpleBuddyIcon *icon; 2762 PurpleBuddyIcon *icon;
2764 const void *data; 2763 const void *data;
2765 size_t len; 2764 size_t len;
2766 2765
2767 if ((fp = g_fopen(filename, "wb")) == NULL) {
2768 purple_notify_error(gtkconv, NULL, _("Unable to open file."), NULL);
2769 return;
2770 }
2771
2772 icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv)); 2766 icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
2773 data = purple_buddy_icon_get_data(icon, &len); 2767 data = purple_buddy_icon_get_data(icon, &len);
2774 2768
2775 if ((len <= 0) || (data == NULL) || (fwrite(data, 1, len, fp) != len)) { 2769 if ((len <= 0) || (data == NULL) || !purple_util_write_data_to_file_absolute(filename, data, len)) {
2776 purple_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL); 2770 purple_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL);
2777 fclose(fp); 2771 }
2778 g_unlink(filename);
2779 return;
2780 }
2781 fclose(fp);
2782 } 2772 }
2783 2773
2784 static void 2774 static void
2785 custom_icon_sel_cb(const char *filename, gpointer data) 2775 custom_icon_sel_cb(const char *filename, gpointer data)
2786 { 2776 {

mercurial