2009-05-10 [holger] 3.7.1cvs53
authorHolger Berndt <hb@claws-mail.org>
Sun, 10 May 2009 20:08:52 +0000 (20:08 +0000)
committerHolger Berndt <hb@claws-mail.org>
Sun, 10 May 2009 20:08:52 +0000 (20:08 +0000)
* src/addr_compl.c
* src/addr_compl.h
Add a hook to make it possible for plugins to
modify the address completion list

ChangeLog
PATCHSETS
configure.ac
src/addr_compl.c
src/addr_compl.h

index 45c53f0e72126cc5677eaf113e02c24098a89fc3..d68f4723ffcb62a9d7b8efc760ff25d8c9c6176f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-10 [holger]    3.7.1cvs53
+
+       * src/addr_compl.c
+       * src/addr_compl.h
+               Add a hook to make it possible for plugins to
+               modify the address completion list
+
 2009-05-06 [paul]      3.7.1cvs52
 
        * src/folder.c
index 1f317d17eb415fff013149bd311a950c1a7d23b6..4d84b8737e879236b60e514fba8917de2649adde 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.36.2.169 -r 1.36.2.170 src/common/utils.c;  ) > 3.7.1cvs50.patchset
 ( cvs diff -u -r 1.36.2.170 -r 1.36.2.171 src/common/utils.c;  ) > 3.7.1cvs51.patchset
 ( cvs diff -u -r 1.213.2.193 -r 1.213.2.194 src/folder.c;  cvs diff -u -r 1.83.2.154 -r 1.83.2.155 src/mimeview.c;  ) > 3.7.1cvs52.patchset
+( cvs diff -u -r 1.27.2.45 -r 1.27.2.46 src/addr_compl.c;  cvs diff -u -r 1.8.2.12 -r 1.8.2.13 src/addr_compl.h;  ) > 3.7.1cvs53.patchset
index c81c0b94faf7630a346515a1dfa7b867e972b508..bd9f222846a5a895e51dc1ba568d5c06d47f95d4 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=7
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=52
+EXTRA_VERSION=53
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index d16eb349e9f1e473bfdf9c25ed46cda198baa97f..e16d33c3ba1ab9f71e7672a843c9acddfb10a856 100644 (file)
@@ -40,6 +40,7 @@
 #include "utils.h"
 #include "prefs_common.h"
 #include "claws.h"
+#include "hooks.h"
 #include <pthread.h>
 
 /*!
@@ -69,18 +70,7 @@ enum {
  * addresses a little more (e.g. break up alfons@proteus.demon.nl into
  * something like alfons, proteus, demon, nl; and then completing on
  * any of those words).
- */ 
-       
-/**
- * address_entry - structure which refers to the original address entry in the
- * address book .
  */
-typedef struct
-{
-       gchar *name;
-       gchar *address;
-       GList *grp_emails;
-} address_entry;
 
 /**
  * completion_entry - structure used to complete addresses, with a reference
@@ -230,7 +220,7 @@ static void free_all(void)
  * \param str Index string value.
  * \param ae  Entry containing address data.
  */
-static void add_address1(const char *str, address_entry *ae)
+void addr_compl_add_address1(const char *str, address_entry *ae)
 {
        completion_entry *ce1;
        ce1 = g_new0(completion_entry, 1),
@@ -270,19 +260,19 @@ static gint add_address(const gchar *name, const gchar *address,
        cm_return_val_if_fail(ae != NULL, -1);
 
        ae->name    = g_strdup(name);
-       ae->address = g_strdup(address);                
+       ae->address = g_strdup(address);
        ae->grp_emails = grp_emails;
        g_address_list = g_list_prepend(g_address_list, ae);
 
-       add_address1(name, ae);
+       addr_compl_add_address1(name, ae);
        if (address != NULL && *address != '\0')
-               add_address1(address, ae);
-       
+               addr_compl_add_address1(address, ae);
+
        if (nick != NULL && *nick != '\0')
-               add_address1(nick, ae);
-       
+               addr_compl_add_address1(nick, ae);
+
        if ( alias != NULL && *alias != '\0') {
-               add_address1(alias, ae);
+               addr_compl_add_address1(alias, ae);
        }
 
        return 0;
@@ -296,13 +286,17 @@ static void read_address_book(gchar *folderpath) {
        free_completion_list();
 
        addrindex_load_completion( add_address, folderpath );
+
+       /* plugins may hook in here to modify/extend the completion list */
+       hooks_invoke(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, &g_address_list);
+
        g_address_list = g_list_reverse(g_address_list);
        g_completion_list = g_list_reverse(g_completion_list);
        /* merge the completion entry list into g_completion */
        if (g_completion_list) {
                g_completion_add_items(g_completion, g_completion_list);
                if (debug_get_mode())
-                       debug_print("read %d items in %s\n", 
+                       debug_print("read %d items in %s\n",
                                g_list_length(g_completion_list),
                                folderpath?folderpath:"(null)");
        }
@@ -1681,11 +1675,11 @@ static gboolean addr_compl_selected(GtkTreeSelection *selector,
         * not using a time out would result in a crash. if this doesn't work
         * safely, maybe we should set variables when receiving button presses
         * in the tree view. */
-       if (!window->destroying) {       
-               window->destroying = TRUE;       
+       if (!window->destroying) {
+               window->destroying = TRUE;
                g_idle_add((GSourceFunc) addr_compl_defer_select_destruct, data);
-       }               
-       
+       }
+
        return TRUE;
 }
 
index 88e26c42501f55d0c4747d186f27066f1b380f06..fe89d9db889481af1ccf1a0d1c85547c4e79d2c1 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  */
+
 #ifndef __ADDR_COMPL_H__
 #define __ADDR_COMPL_H__
 
 #include <gtk/gtk.h>
 
+#define ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST "address_completion_build_address_list_hooklist"
+
+/**
+ * address_entry - structure which refers to the original address entry in the
+ * address book .
+ */
+typedef struct
+{
+    gchar *name;
+    gchar *address;
+    GList *grp_emails;
+} address_entry;
+
 gint start_address_completion          (gchar *folderpath);
 guint complete_address                 (const gchar *str);
 guint complete_matches_found                           (const gchar *str);
@@ -39,4 +52,6 @@ void address_completion_end           (GtkWidget *mainwindow);
 void addrcompl_initialize      ( void );
 void addrcompl_teardown                ( void );
 
+void addr_compl_add_address1(const char *str, address_entry *ae);
+
 #endif /* __ADDR_COMPL_H__ */