Don't save libravatarr avatars to addressbook
authorColin Leroy <colin@colino.net>
Wed, 30 Apr 2014 18:35:47 +0000 (20:35 +0200)
committerColin Leroy <colin@colino.net>
Wed, 30 Apr 2014 18:35:47 +0000 (20:35 +0200)
src/avatars.c
src/avatars.h
src/plugins/libravatar/libravatar.c
src/textview.c
src/textview.h

index 51acba4..a68286d 100644 (file)
@@ -39,6 +39,7 @@ AvatarRender *avatars_avatarrender_new(MsgInfo *msginfo)
        AvatarRender *ar = g_new0(AvatarRender, 1);
        ar->full_msginfo = msginfo;
        ar->image = NULL;
+       ar->type = 0;
 
        return ar;
 }
@@ -76,12 +77,14 @@ gboolean avatars_internal_rendering_hook(gpointer source, gpointer data)
        aface = procmsg_msginfo_get_avatar(avatarr->full_msginfo, AVATAR_FACE);
        if (aface) {
                avatarr->image = face_get_from_header(aface);
+               avatarr->type  = AVATAR_FACE;
        }
 #if HAVE_LIBCOMPFACE
        else {
                aface = procmsg_msginfo_get_avatar(avatarr->full_msginfo, AVATAR_XFACE);
                if (aface) {
                        avatarr->image = xface_get_from_header(aface);
+                       avatarr->type  = AVATAR_XFACE;
                }
        }
 #endif
index d6f304a..c7ac1c9 100644 (file)
@@ -33,6 +33,7 @@ struct _AvatarRender
 {
        MsgInfo *full_msginfo;
        GtkWidget *image;
+       gint type;
 };
 
 AvatarRender *avatars_avatarrender_new         (MsgInfo *msginfo);
index 48d3bf3..9f225bb 100644 (file)
@@ -275,6 +275,7 @@ static gboolean libravatar_image_render_hook(gpointer source, gpointer data)
                        if (ar->image) /* previous plugin set one */
                                gtk_widget_destroy(ar->image);
                        ar->image = image;
+                       ar->type  = AVATAR_LIBRAVATAR;
                        return FALSE;
                }
                /* not cached copy: try network */
@@ -291,6 +292,7 @@ static gboolean libravatar_image_render_hook(gpointer source, gpointer data)
                                if (ar->image) /* previous plugin set one */
                                        gtk_widget_destroy(ar->image);
                                ar->image = image;
+                               ar->type  = AVATAR_LIBRAVATAR;
                        }
                }
                g_free(base);
index ef50dd8..e5cdb66 100644 (file)
@@ -1757,6 +1757,7 @@ void textview_clear(TextView *textview)
        if (textview->image) 
                gtk_widget_destroy(textview->image);
        textview->image = NULL;
+       textview->avatar_type = 0;
 
        if (textview->messageview->mainwin->cursor_count == 0) {
                textview_set_cursor(window, text_cursor);
@@ -1987,6 +1988,7 @@ static void textview_show_avatar(TextView *textview)
                gtk_widget_destroy(textview->image);
        
        textview->image = avatarr->image;
+       textview->avatar_type = avatarr->type;
        avatarr->image = NULL; /* avoid destroying */
        avatars_avatarrender_free(avatarr);
 
@@ -2005,6 +2007,7 @@ bail:
        if (textview->image) 
                gtk_widget_destroy(textview->image);
        textview->image = NULL; 
+       textview->avatar_type = 0;
 }
 
 void textview_show_icon(TextView *textview, const gchar *stock_id)
@@ -2044,6 +2047,9 @@ static void textview_save_contact_pic(TextView *textview)
        if (!msginfo->extradata || !msginfo->extradata->avatars)
                return;
 
+       if (textview->avatar_type > AVATAR_FACE)
+               return;
+
        if (textview->image) 
                picture = gtk_image_get_pixbuf(GTK_IMAGE(textview->image));
 
@@ -2132,6 +2138,7 @@ bail:
        if (textview->image) 
                gtk_widget_destroy(textview->image);
        textview->image = NULL;
+       textview->avatar_type = 0;
 #else
        /* new address book */
 #endif 
index ed36b0b..5d478fd 100644 (file)
@@ -78,6 +78,7 @@ struct _TextView
        GtkTextIter uri_hover_start_iter;
        GtkTextIter uri_hover_end_iter;
        GtkWidget *image;
+       gint avatar_type;
        gboolean loading;
        gboolean stop_loading;
        gint prev_quote_level;