talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 066e76a2863a8468b8fd491e50396661b62174e6
parent 13272035f8a0399a71b7dc6e412fff9eac00b822
Author: Ricardo Mones <ricardo@mones.org>
Date:   Mon,  3 Jul 2017 21:55:23 +0200

Fix bug #3348 ‘Contact pictures not deleted when contact is deleted’

Based on original patch submitted by Charles Lehner (thanks!)

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

diff --git 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 @@ -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 @@ -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 @@ -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 );