[Commits] [SCM] claws branch, master, updated. 3.15.0-76-g066e76a

mones at claws-mail.org mones at claws-mail.org
Mon Jul 3 21:55:33 CEST 2017


The branch, master has been updated
       via  066e76a2863a8468b8fd491e50396661b62174e6 (commit)
      from  13272035f8a0399a71b7dc6e412fff9eac00b822 (commit)

Summary of changes:
 src/addrduplicates.c |    5 +----
 src/addressbook.c    |    5 +----
 src/addritem.c       |   32 ++++++++++++++++++++++++++++----
 src/addritem.h       |    6 +++---
 4 files changed, 33 insertions(+), 15 deletions(-)


- Log -----------------------------------------------------------------
commit 066e76a2863a8468b8fd491e50396661b62174e6
Author: Ricardo Mones <ricardo at mones.org>
Date:   Mon Jul 3 21:55:23 2017 +0200

    Fix bug #3348 ‘Contact pictures not deleted when contact is deleted’
    
    Based on original patch submitted by Charles Lehner (thanks!)

diff --git a/src/addrduplicates.c b/src/addrduplicates.c
index dcde08a..96fe30d 100644
--- a/src/addrduplicates.c
+++ b/src/addrduplicates.c
@@ -862,10 +862,7 @@ gboolean addrduplicates_delete_item_person(ItemPerson *item, AddressDataSource *
 #endif
 
 	if(item) {
-		gchar *filename = addritem_person_get_picture(item);
-		if (filename && is_file_exist(filename))
-			claws_unlink(filename);
-		g_free(filename);
+		addritem_person_remove_picture(item);
 		addritem_free_item_person(item);
 	}
 	return TRUE;
diff --git a/src/addressbook.c b/src/addressbook.c
index 403b556..77ddee8 100644
--- a/src/addressbook.c
+++ b/src/addressbook.c
@@ -1573,10 +1573,7 @@ static void addressbook_del_clicked(GtkButton *button, gpointer data)
 				}
 #endif
 				if( item ) {
-					gchar *filename = addritem_person_get_picture(item);
-					if (filename && is_file_exist(filename))
-						claws_unlink(filename);
-					g_free(filename);
+					addritem_person_remove_picture(item);
 					addritem_free_item_person( item );
 				}
 			}
diff --git a/src/addritem.c b/src/addritem.c
index ae3dc4e..f6d9d12 100644
--- a/src/addritem.c
+++ b/src/addritem.c
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2012 Match Grun and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2001-2017 Match Grun and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 /*
@@ -25,6 +24,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "defs.h"
 #include "utils.h"
 #include "addritem.h"
 #include "mgutils.h"
@@ -272,13 +272,37 @@ void addritem_person_set_picture( ItemPerson *person, const gchar *value ) {
 /**
  * Get picture for person object.
  * \param person Person object.
- * \param value Picture.
  */
 gchar *addritem_person_get_picture( ItemPerson *person) {
 	if (person->picture)
 		return g_strdup(person->picture);
 	return NULL;
 }
+
+/**
+ * Delete picture for person object.
+ * \param person Person object.
+ */
+void addritem_person_remove_picture( ItemPerson *person) {
+	if (person->picture) {
+		gchar *filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S,
+			ADDRBOOK_DIR, G_DIR_SEPARATOR_S, person->picture,
+			".png", NULL );
+		if (is_file_exist(filename)) {
+			debug_print("removing addressbook picture %s\n",
+				filename);
+			if (claws_unlink(filename) < 0) {
+				FILE_OP_ERROR(filename, "remove");
+				g_free(filename);
+				return;
+			}
+		}
+		g_free(person->picture);
+		person->picture = NULL;
+		g_free(filename);
+	}
+}
+
 /**
  * Specify first name for person object.
  * \param person Person object.
diff --git a/src/addritem.h b/src/addritem.h
index 82fbaf3..9bccdf8 100644
--- a/src/addritem.h
+++ b/src/addritem.h
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2012 Match Grun and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2001-2017 Match Grun and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 /*
@@ -138,6 +137,7 @@ ItemPerson *addritem_create_item_person	( void );
 ItemPerson *addritem_copy_item_person	( ItemPerson *item );
 void addritem_person_set_picture	( ItemPerson *person, const gchar *value );
 gchar *addritem_person_get_picture	( ItemPerson *person);
+void addritem_person_remove_picture	( ItemPerson *person);
 void addritem_person_set_first_name	( ItemPerson *person, const gchar *value );
 void addritem_person_set_last_name	( ItemPerson *person, const gchar *value );
 void addritem_person_set_nick_name	( ItemPerson *person, const gchar *value );

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list