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 e78d90f6972d14568c3591563ed3e913e926ea00..f73683e73c9e2e8ac64152f24160ac9c347e2993 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 de9d4b1b5a3d8fcfbf762b6de8ce47726d710d90..741fa43bf8e8a599221ab6748d51c1fdd0b59394 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 2363848fa2d0836c9ffbbd7891b303ec3bb486c7..75940df165a960ca3e72aa6f6c352a9c7dd60e6c 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 374c1dd01edd8cf5a3eef35dfcc67e6242d4e65f..07c55a22b98eab0b0dc633f2b5ffe66166526aa6 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 b32663297f4142d9186ed5e5855c2f3cb7454b75..9512ffc9c9676889d38d75fc3c9e06ebedf05a99 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 1c63fa3b205af408ba3747801358e93cc80c3fa3..6c820f0ef3e9b5f48a08b4946f1cbb74d90de3c5 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 d75c72a30b3c2521ecffd11b0436348f1d4431ca..59fd92a67cfcaa07fbdcd5f99256aa5e5f390690 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();