talons

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

commit 2016b17dad8b37b72ae1678c217ed06ac12966a1
parent 02a57d67867128a8aee4229eacaeecd42001f71c
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Fri,  3 Feb 2017 17:48:02 +0100

Moved found_in_addressbook() from plugins to core.

Four identical copies of the same functions removed
from four plugins and put into addr_compl.[ch].

Diffstat:
Msrc/addr_compl.c | 27++++++++++++++++++++++++++-
Msrc/addr_compl.h | 1+
Msrc/plugins/bogofilter/bogofilter.c | 27---------------------------
Msrc/plugins/bsfilter/bsfilter.c | 27---------------------------
Msrc/plugins/bsfilter/claws.def | 4+---
Msrc/plugins/dillo/dillo_viewer.c | 27---------------------------
Msrc/plugins/spamassassin/spamassassin.c | 29+----------------------------
7 files changed, 29 insertions(+), 113 deletions(-)

diff --git a/src/addr_compl.c b/src/addr_compl.c @@ -1833,8 +1833,33 @@ static gboolean addr_compl_defer_select_destruct(CompletionWindow *window) return FALSE; } +gboolean found_in_addressbook(const gchar *address) +{ + gchar *addr = NULL; + gboolean found = FALSE; + gint num_addr = 0; + + if (!address) + return FALSE; + + addr = g_strdup(address); + extract_address(addr); + num_addr = complete_address(addr); + if (num_addr > 1) { + /* skip first item (this is the search string itself) */ + int i = 1; + for (; i < num_addr && !found; i++) { + gchar *caddr = get_complete_address(i); + extract_address(caddr); + if (strcasecmp(caddr, addr) == 0) + found = TRUE; + g_free(caddr); + } + } + g_free(addr); + return found; +} /* * End of Source. */ - diff --git a/src/addr_compl.h b/src/addr_compl.h @@ -42,6 +42,7 @@ guint complete_matches_found (const gchar *str); gchar *get_complete_address (gint index); gint invalidate_address_completion (void); gint end_address_completion (void); +gboolean found_in_addressbook(const gchar *address); /* ui functions */ void address_completion_start (GtkWidget *mainwindow); diff --git a/src/plugins/bogofilter/bogofilter.c b/src/plugins/bogofilter/bogofilter.c @@ -162,33 +162,6 @@ static pthread_mutex_t wait_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t wait_cond = PTHREAD_COND_INITIALIZER; #endif -static gboolean found_in_addressbook(const gchar *address) -{ - gchar *addr = NULL; - gboolean found = FALSE; - gint num_addr = 0; - - if (!address) - return FALSE; - - addr = g_strdup(address); - extract_address(addr); - num_addr = complete_address(addr); - if (num_addr > 1) { - /* skip first item (this is the search string itself) */ - int i = 1; - for (; i < num_addr && !found; i++) { - gchar *caddr = get_complete_address(i); - extract_address(caddr); - if (strcasecmp(caddr, addr) == 0) - found = TRUE; - g_free(caddr); - } - } - g_free(addr); - return found; -} - static void bogofilter_do_filter(BogoFilterData *data) { GPid bogo_pid; diff --git a/src/plugins/bsfilter/bsfilter.c b/src/plugins/bsfilter/bsfilter.c @@ -132,33 +132,6 @@ static pthread_mutex_t wait_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t wait_cond = PTHREAD_COND_INITIALIZER; #endif -static gboolean found_in_addressbook(const gchar *address) -{ - gchar *addr = NULL; - gboolean found = FALSE; - gint num_addr = 0; - - if (!address) - return FALSE; - - addr = g_strdup(address); - extract_address(addr); - num_addr = complete_address(addr); - if (num_addr > 1) { - /* skip first item (this is the search string itself) */ - int i = 1; - for (; i < num_addr && !found; i++) { - gchar *caddr = get_complete_address(i); - extract_address(caddr); - if (strcasecmp(caddr, addr) == 0) - found = TRUE; - g_free(caddr); - } - } - g_free(addr); - return found; -} - static void bsfilter_do_filter(BsFilterData *data) { int status = 0; diff --git a/src/plugins/bsfilter/claws.def b/src/plugins/bsfilter/claws.def @@ -31,17 +31,15 @@ prefs_common_get_prefs addressbook_folder_selection alertpanel_error combobox_text_new -complete_address end_address_completion execute_command_line -extract_address folder_find_item_from_identifier folder_get_default_trash folder_item_get_identifier folder_item_get_path folder_item_remove_msg foldersel_folder_sel -get_complete_address +found_in_addressbook gtkut_get_browse_directory_btn log_error prefs_button_toggled diff --git a/src/plugins/dillo/dillo_viewer.c b/src/plugins/dillo/dillo_viewer.c @@ -76,33 +76,6 @@ static gboolean socket_destroy_cb(GtkObject *object, gpointer data) return FALSE; } -static gboolean found_in_addressbook(const gchar *address) -{ - gchar *addr = NULL; - gboolean found = FALSE; - gint num_addr = 0; - - if (!address) - return FALSE; - - addr = g_strdup(address); - extract_address(addr); - num_addr = complete_address(addr); - if (num_addr > 1) { - /* skip first item (this is the search string itself) */ - int i = 1; - for (; i < num_addr && !found; i++) { - gchar *caddr = get_complete_address(i); - extract_address(caddr); - if (strcasecmp(caddr, addr) == 0) - found = TRUE; - g_free(caddr); - } - } - g_free(addr); - return found; -} - static gboolean load_images(DilloViewer *viewer) { MessageView *messageview = ((MimeViewer *)viewer)->mimeview diff --git a/src/plugins/spamassassin/spamassassin.c b/src/plugins/spamassassin/spamassassin.c @@ -196,33 +196,6 @@ static MsgStatus msg_is_spam(FILE *fp) return is_spam ? MSG_IS_SPAM:MSG_IS_HAM; } -static gboolean sa_found_in_addressbook(const gchar *address) -{ - gchar *addr = NULL; - gboolean found = FALSE; - gint num_addr = 0; - - if (!address) - return FALSE; - - addr = g_strdup(address); - extract_address(addr); - num_addr = complete_address(addr); - if (num_addr > 1) { - /* skip first item (this is the search string itself) */ - int i = 1; - for (; i < num_addr && !found; i++) { - gchar *caddr = get_complete_address(i); - extract_address(caddr); - if (strcasecmp(caddr, addr) == 0) - found = TRUE; - g_free(caddr); - } - } - g_free(addr); - return found; -} - static gboolean mail_filtering_hook(gpointer source, gpointer data) { MailFilteringData *mail_filtering_data = (MailFilteringData *) source; @@ -262,7 +235,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data) start_address_completion(ab_folderpath); if (msginfo->from && - sa_found_in_addressbook(msginfo->from)) + found_in_addressbook(msginfo->from)) whitelisted = TRUE; end_address_completion();