Moved found_in_addressbook() from plugins to core.
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 3 Feb 2017 16:48:02 +0000 (17:48 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 3 Feb 2017 16:48:02 +0000 (17:48 +0100)
Four identical copies of the same functions removed
from four plugins and put into addr_compl.[ch].

src/addr_compl.c
src/addr_compl.h
src/plugins/bogofilter/bogofilter.c
src/plugins/bsfilter/bsfilter.c
src/plugins/bsfilter/claws.def
src/plugins/dillo/dillo_viewer.c
src/plugins/spamassassin/spamassassin.c

index e78d90f..f73683e 100644 (file)
@@ -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.
  */
-
index de9d4b1..741fa43 100644 (file)
@@ -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);
index 2363848..75940df 100644 (file)
@@ -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;
index 374c1dd..07c55a2 100644 (file)
@@ -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;
index b326632..9512ffc 100644 (file)
@@ -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
index 1c63fa3..6c820f0 100644 (file)
@@ -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 
index d75c72a..59fd92a 100644 (file)
@@ -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();