2011-11-30 [mir] 0.6.0cvs34
authorMichael Rasmussen <mir@datanom.net>
Wed, 30 Nov 2011 23:35:12 +0000 (23:35 +0000)
committerMichael Rasmussen <mir@datanom.net>
Wed, 30 Nov 2011 23:35:12 +0000 (23:35 +0000)
* Makefile.am
* TODO
* configure.ac
* extensions/.cvsignore
* extensions/Makefile.am
* extensions/export/.cvsignore
* extensions/export/Makefile.am
* extensions/export/ldifexport_extension.c
* extensions/import/.cvsignore
* extensions/import/Makefile.am
* extensions/import/ldifimport_extension.c
* src/Makefile.am
* src/claws-contacts.c
* src/extension-loader.c
* src/extension-loader.h
* src/extension.c
* src/extension.h
* src/mainwindow.c
* src/mainwindow.h
    Begin implementing plugable extension feature.

21 files changed:
ChangeLog
Makefile.am
PATCHSETS
TODO
configure.ac
extensions/.cvsignore [new file with mode: 0644]
extensions/Makefile.am [new file with mode: 0644]
extensions/export/.cvsignore [new file with mode: 0644]
extensions/export/Makefile.am [new file with mode: 0644]
extensions/export/ldifexport_extension.c [new file with mode: 0644]
extensions/import/.cvsignore [new file with mode: 0644]
extensions/import/Makefile.am [new file with mode: 0644]
extensions/import/ldifimport_extension.c [new file with mode: 0644]
src/Makefile.am
src/claws-contacts.c
src/extension-loader.c [new file with mode: 0644]
src/extension-loader.h [new file with mode: 0644]
src/extension.c [new file with mode: 0644]
src/extension.h [new file with mode: 0644]
src/mainwindow.c
src/mainwindow.h

index c336340fe4380fa7b83d4f9256069d0ec14ab296..abe7e019566fee5aa02f0355b444a28a1848016b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2011-11-30 [mir]       0.6.0cvs34
+
+       * Makefile.am
+       * TODO
+       * configure.ac
+       * extensions/.cvsignore
+       * extensions/Makefile.am
+       * extensions/export/.cvsignore
+       * extensions/export/Makefile.am
+       * extensions/export/ldifexport_extension.c
+       * extensions/import/.cvsignore
+       * extensions/import/Makefile.am
+       * extensions/import/ldifimport_extension.c
+       * src/Makefile.am
+       * src/claws-contacts.c
+       * src/extension-loader.c
+       * src/extension-loader.h
+       * src/extension.c
+       * src/extension.h
+       * src/mainwindow.c
+       * src/mainwindow.h
+           Begin implementing plugable extension feature.
+
 2011-11-30 [mir]       0.6.0cvs33
 
        * src/contactwindow.c
index 842431df2832988c73e82a1f12d186ea3dd2e2c5..a7af9d326d5eb2c79638e637eb95169f78383af3 100644 (file)
@@ -12,6 +12,7 @@ SUBDIRS = \
          xmllib \
          plugins \
          src \
+         extensions \
          ${DBUS_CLIENT}
 
 DOCS = \
index 64e7e060dc8b125c3fa3f198ac072a4791e2d77b..21027c2f293424703e19e7e690618e4aa551096a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -31,3 +31,4 @@
 ( cvs diff -u -r 1.8 -r 1.9 src/utils.c;  cvs diff -u -r 1.1 -r 1.2 src/dbus/dbus-contact.h;  cvs diff -u -r 1.3 -r 1.4 src/dbus/server-object.c;  ) > 0.6.0cvs31.patchset
 ( cvs diff -u -r 1.11 -r 1.12 plugins/ldap/ldap-plugin.c;  cvs diff -u -r 1.2 -r 1.3 src/dbus/dbus-service.c;  ) > 0.6.0cvs32.patchset
 ( cvs diff -u -r 1.10 -r 1.11 src/contactwindow.c;  ) > 0.6.0cvs33.patchset
+( cvs diff -u -r 1.2 -r 1.3 Makefile.am;  cvs diff -u -r 1.1 -r 1.2 TODO;  cvs diff -u -r 1.34 -r 1.35 configure.ac;  diff -u /dev/null extensions/.cvsignore;  diff -u /dev/null extensions/Makefile.am;  diff -u /dev/null extensions/export/.cvsignore;  diff -u /dev/null extensions/export/Makefile.am;  diff -u /dev/null extensions/export/ldifexport_extension.c;  diff -u /dev/null extensions/import/.cvsignore;  diff -u /dev/null extensions/import/Makefile.am;  diff -u /dev/null extensions/import/ldifimport_extension.c;  cvs diff -u -r 1.2 -r 1.3 src/Makefile.am;  cvs diff -u -r 1.2 -r 1.3 src/claws-contacts.c;  diff -u /dev/null src/extension-loader.c;  diff -u /dev/null src/extension-loader.h;  diff -u /dev/null src/extension.c;  diff -u /dev/null src/extension.h;  cvs diff -u -r 1.4 -r 1.5 src/mainwindow.c;  cvs diff -u -r 1.2 -r 1.3 src/mainwindow.h;  ) > 0.6.0cvs34.patchset
diff --git a/TODO b/TODO
index 1020db9978873b42e7950e284e1b5b31dfe9170c..c64196b910f65e6bf46d206c9e9d61236d97da1e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
 $Id$
 
  1) Remove annoying compile time warnings DONE
- 2) Complete example plugin with user documentation
+ 2) Complete example plugin with user documentation DONE
  3) Implement basic search   DONE
  4) Implement advanced search DONE
  5) Implement application preferences Partly DONE
@@ -12,6 +12,7 @@ $Id$
 10) Apply compile time selection between old and new address
        book into Claws-mail as well as compile time switches
        to remove all old address book code from binary DONE
-11) Develop LDAP plugin
+11) Develop LDAP plugin DONE
 12) Bug hunt Never DONE
-13) Improve tab-completion search in claws
+13) Improve tab-completion search in claws DONE
+14) Implement plugable extension interface
index e152dcb11b8f2d828b290bda340ad87e4b558246..ca3e0e456dd1b556f50773e808cd983c5906f9b8 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=6
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=33
+EXTRA_VERSION=34
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
@@ -44,6 +44,7 @@ if test "x$USE_MAINTAINER_MODE" = "xyes"; then
     AC_DEFINE_UNQUOTED(BINDIR, "$BINDIR", [Where is binary installed])
     AC_DEFINE_UNQUOTED(PIXDIR, "${ac_pwd}/pixmaps", [Directory with various pixmaps])
     PLUGINDIR="${ac_pwd}/plugins"
+       EXTENSIONDIR="${ac_pwd}/extensions"
 else
     if test "x$prefix" = "xNONE"; then
        prefix=$ac_default_prefix
@@ -53,8 +54,10 @@ else
     AC_DEFINE_UNQUOTED(BINDIR, "$BINDIR", [Where is binary installed])
     AC_DEFINE_UNQUOTED(PIXDIR, "${prefix}/share/claws-contacts/pixmaps", [Directory with various pixmaps])
     PLUGINDIR="${prefix}/lib/claws-contacts/plugins"
+       EXTENSIONDIR="${prefix}/lib/claws-contacts/extensions"
 fi
 AC_SUBST(PLUGINDIR)
+AC_SUBST(EXTENSIONDIR)
 AC_SUBST(BINDIR)
 
 GLIB_REQUIRED=2.16.0
@@ -249,6 +252,9 @@ AC_CONFIG_FILES([
                  plugins/example/Makefile
                  plugins/xml/Makefile
                  plugins/ldap/Makefile
+                                extensions/Makefile
+                                extensions/import/Makefile
+                                extensions/export/Makefile
 ])
 
 AC_OUTPUT
diff --git a/extensions/.cvsignore b/extensions/.cvsignore
new file mode 100644 (file)
index 0000000..e4c7e1e
--- /dev/null
@@ -0,0 +1,28 @@
+contacts.geany
+stamp-h1
+COPYING
+INSTALL
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+auxdir
+*.bz2
+claws-contacts.desktop
+claws-contacts.pc
+config
+config.h
+config.h.in
+config.log
+config.status
+configure
+libtool
+m4
+org.clawsmail.ClawsContact.service
+.deps
+.libs
+*.lo
+*.la
+claws-contacts
+server-bindings.h
+
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
new file mode 100644 (file)
index 0000000..6ded603
--- /dev/null
@@ -0,0 +1,9 @@
+# $Id$
+AUTOMAKE_OPTIONS = gnu
+
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = \
+         export \
+         import
+
diff --git a/extensions/export/.cvsignore b/extensions/export/.cvsignore
new file mode 100644 (file)
index 0000000..e4c7e1e
--- /dev/null
@@ -0,0 +1,28 @@
+contacts.geany
+stamp-h1
+COPYING
+INSTALL
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+auxdir
+*.bz2
+claws-contacts.desktop
+claws-contacts.pc
+config
+config.h
+config.h.in
+config.log
+config.status
+configure
+libtool
+m4
+org.clawsmail.ClawsContact.service
+.deps
+.libs
+*.lo
+*.la
+claws-contacts
+server-bindings.h
+
diff --git a/extensions/export/Makefile.am b/extensions/export/Makefile.am
new file mode 100644 (file)
index 0000000..a624197
--- /dev/null
@@ -0,0 +1,26 @@
+# $Id$
+AUTOMAKE_OPTIONS = gnu
+
+extensiondir = $(pkglibdir)/extensions
+
+extension_LTLIBRARIES = ldifexport-extension.la
+
+ldifexport_extension_la_LDFLAGS = \
+       -avoid-version -module
+
+INCLUDES = \
+          -I${top_srcdir} \
+          -I${top_srcdir}/src \
+          -I${top_builddir} \
+          @GLIB_CFLAGS@ \
+          @GTK_CFLAGS@
+
+AM_CPPFLAGS = \
+               -DG_LOG_DOMAIN=\"Claws-Contacts\"
+
+ldifexport_extension_la_SOURCES = \
+                   ldifexport_extension.c
+
+ldifexport_extension_la_LIBADD= \
+                  @GLIB_LIBS@ \
+                  @GTK_LIBS@
diff --git a/extensions/export/ldifexport_extension.c b/extensions/export/ldifexport_extension.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/extensions/import/.cvsignore b/extensions/import/.cvsignore
new file mode 100644 (file)
index 0000000..e4c7e1e
--- /dev/null
@@ -0,0 +1,28 @@
+contacts.geany
+stamp-h1
+COPYING
+INSTALL
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+auxdir
+*.bz2
+claws-contacts.desktop
+claws-contacts.pc
+config
+config.h
+config.h.in
+config.log
+config.status
+configure
+libtool
+m4
+org.clawsmail.ClawsContact.service
+.deps
+.libs
+*.lo
+*.la
+claws-contacts
+server-bindings.h
+
diff --git a/extensions/import/Makefile.am b/extensions/import/Makefile.am
new file mode 100644 (file)
index 0000000..8f0bede
--- /dev/null
@@ -0,0 +1,26 @@
+# $Id$
+AUTOMAKE_OPTIONS = gnu
+
+extensiondir = $(pkglibdir)/extensions
+
+extension_LTLIBRARIES = ldifimport-extension.la
+
+ldifimport_extension_la_LDFLAGS = \
+       -avoid-version -module
+
+INCLUDES = \
+          -I${top_srcdir} \
+          -I${top_srcdir}/src \
+          -I${top_builddir} \
+          @GLIB_CFLAGS@ \
+          @GTK_CFLAGS@
+
+AM_CPPFLAGS = \
+               -DG_LOG_DOMAIN=\"Claws-Contacts\"
+
+ldifimport_extension_la_SOURCES = \
+                   ldifimport_extension.c
+
+ldifimport_extension_la_LIBADD= \
+                  @GLIB_LIBS@ \
+                  @GTK_LIBS@
diff --git a/extensions/import/ldifimport_extension.c b/extensions/import/ldifimport_extension.c
new file mode 100644 (file)
index 0000000..e69de29
index aa7a75436b28632c0efd5f0411cb12c3e96a67d1..32c95b534418ae3685f5ab3f2aba8ff16fd4744e 100644 (file)
@@ -17,12 +17,12 @@ INCLUDES = \
 AM_CPPFLAGS = \
                -DG_LOG_DOMAIN=\"Claws-Contacts\" \
                -DPLUGINDIR=\"@PLUGINDIR@\" \
+               -DEXTENSIONDIR=\"@EXTENSIONDIR@\" \
                $(LIBGCRYPT_CFLAGS)
 
 claws_contacts_SOURCES = \
                    claws-contacts.c \
                    mainwindow.c \
-                   mainwindow.h \
                    callbacks.c \
                    callbacks.h \
                    utils.c \
@@ -37,14 +37,18 @@ claws_contacts_SOURCES = \
                    printing.c \
                    printing.h \
                    settings.c \
-                   settings.h
-
+                   settings.h \
+                       extension.c \
+                       extension-loader.c \
+                       extension-loader.h
 
 claws_contactsincludedir = $(pkgincludedir)
 claws_contactsinclude_HEADERS = \
                    utils.h \
                    plugin.h \
-                   gtk-utils.h
+                   gtk-utils.h \
+                   mainwindow.h \
+                       extension.h
 
 claws_contacts_LDADD= \
                   @GLIB_LIBS@ \
index 0d488845951c6b123a33ca6c86621b307e6d5b19..fe5c826b6f0e4d886fc228d191502634f63cb0fc 100644 (file)
@@ -48,6 +48,7 @@
 static gboolean compose = FALSE;
 static gboolean service = FALSE;
 static gboolean keep = FALSE;
+static gboolean no_extensions = FALSE;
 #if DEBUG
 static gboolean debug_mode = TRUE;
 #else
@@ -59,6 +60,8 @@ static GOptionEntry entries[] = {
         N_("Run in compose mode"), NULL},
     {"keep", 'k', 0, G_OPTION_ARG_NONE, &keep,
         N_("Dont fork in service mode"), NULL},
+    {"noext", 'n', 0, G_OPTION_ARG_NONE, &no_extensions,
+        N_("Avoid loading any extensions"), NULL},
     {"service", 's', 0, G_OPTION_ARG_NONE, &service,
         N_("Run as a DBus service"), NULL},
     {"debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode,
@@ -110,11 +113,13 @@ int main(int argc, char** argv) {
         return EXIT_FAILURE;
     }
     
-    if (service)
+    if (service) {
         start_service(keep);
+        //start_service(keep, no_extensions);
+    }
     else {
         gtk_init(&argc, &argv);
-        application_start(compose);
+        application_start(compose, no_extensions);
     }
 
     return EXIT_SUCCESS;
diff --git a/src/extension-loader.c b/src/extension-loader.c
new file mode 100644 (file)
index 0000000..6709ced
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * $Id$
+ */
+/* vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: */
+
+/*
+ * Claws-contacts is a proposed new design for the address book feature
+ * in Claws Mail. The goal for this new design was to create a
+ * solution more suitable for the term lightweight and to be more
+ * maintainable than the present implementation.
+ *
+ * More lightweight is achieved by design, in that sence that the whole
+ * structure is based on a plugable design.
+ *
+ * Claws Mail is Copyright (C) 1999-2011 by the Claws Mail Team and
+ * Claws-contacts is Copyright (C) 2011 by Michael Rasmussen.
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
+ */
+#ifdef HAVE_CONFIG_H
+#       include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include "mainwindow.h"
+#include "extension.h"
+#include "extension-loader.h"
+
+static const GSList* active_hooks[EXTENSION_HOOK_N];
+static const MainWindow* mainwindow = NULL;
+static gint NEXT_ID = 0;
+
+static gint next_id() {
+       gint id = NEXT_ID;
+       NEXT_ID++;
+       
+       return id;
+}
+
+Extension* extension_new(HOOKFUNC callback) {
+       Extension* extension = g_new0(Extension, 1);
+       extension->callback = callback;
+       extension->id = next_id();
+       
+       return extension;
+}
+
+void extension_free(void) {
+}
+
+gint install_hook_function(ExtensionHook hook_type,
+                                                  HOOKFUNC callback,
+                                                  gchar** error) {
+       gint result = 0;
+       Extension* extension;
+
+       if (! callback) {
+               if (error)
+                       *error = g_strdup(_("Missing reference to callback function"));
+               return TRUE;
+       }
+       
+       extension = extension_new(callback);
+       active_hooks[hook_type] = g_slist_prepend(active_hooks[hook_type], extension);
+       
+       return result;
+}
+
+void uninstall_hook_function(gint id, gchar** error) {
+       ExtensionHook i;
+       Extension* ext = NULL;
+       GSList* cur;
+       gboolean found = FALSE;
+       
+       for (i = EXTENSION_BEFORE_INIT_HOOK; i < EXTENSION_HOOK_N && ! ext; i++) {
+               cur = active_hooks[i];
+               while (cur && ! found) {
+                       ext = (Extension *) cur->data;
+                       if (ext && ext->id == id)
+                               found = TRUE;
+                       else {
+                               ext = NULL;
+                               cur = cur->next;
+                       }
+               }
+       }
+       
+       if (ext) {
+               active_hooks[i] = g_slist_remove(active_hooks[i], ext);
+               g_free(ext);
+               ext = NULL;
+       }
+       else {
+               if (error)
+                       *error = g_strdup(_("%d: Extension not found"));
+       }
+}
+
+void init_hooks(MainWindow* main) {
+       ExtensionHook i;
+       
+       mainwindow = (const MainWindow *) main;
+       for (i = EXTENSION_BEFORE_INIT_HOOK; i < EXTENSION_HOOK_N; i++)
+               active_hooks[i] = NULL;
+
+}
+
+void run_hook_callbacks(ExtensionHook hook, gpointer object) {
+       GSList* cur;
+       
+       if (! object)
+               return;
+               
+       for (cur = active_hooks[hook]; cur; cur = g_slist_next(cur)) {
+               Extension* ext = (Extension *) cur->data;
+               if (ext && ext->callback)
+                       ext->callback(mainwindow, object);
+       }
+}
diff --git a/src/extension-loader.h b/src/extension-loader.h
new file mode 100644 (file)
index 0000000..8296c1f
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * $Id$
+ */
+/* vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: */
+
+/*
+ * Claws-contacts is a proposed new design for the address book feature
+ * in Claws Mail. The goal for this new design was to create a
+ * solution more suitable for the term lightweight and to be more
+ * maintainable than the present implementation.
+ *
+ * More lightweight is achieved by design, in that sence that the whole
+ * structure is based on a plugable design.
+ *
+ * Claws Mail is Copyright (C) 1999-2011 by the Claws Mail Team and
+ * Claws-contacts is Copyright (C) 2011 by Michael Rasmussen.
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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 __EXTENSION_LOADER_H__
+#define __EXTENSION_LOADER_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#include <gtk/gtk.h>
+#include "extension.h"
+#include "mainwindow.h"
+
+typedef struct {
+       gint            id;
+       HOOKFUNC        callback;
+       gchar*          parent;
+       GtkWidget*      menu_item;
+} Extension;
+
+Extension* extension_new(HOOKFUNC callback);
+void extension_free(void);
+void init_hooks(MainWindow* main);
+void run_hook_callbacks(ExtensionHook hook, gpointer object);
+gint install_hook_function(ExtensionHook hook_type,
+                                                  HOOKFUNC callback,
+                                                  gchar** error);
+void uninstall_hook_function(gint id, gchar** error);
+
+
+G_END_DECLS
+
+#endif
diff --git a/src/extension.c b/src/extension.c
new file mode 100644 (file)
index 0000000..d6354c7
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * $Id$
+ */
+/* vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: */
+
+/*
+ * Claws-contacts is a proposed new design for the address book feature
+ * in Claws Mail. The goal for this new design was to create a
+ * solution more suitable for the term lightweight and to be more
+ * maintainable than the present implementation.
+ *
+ * More lightweight is achieved by design, in that sence that the whole
+ * structure is based on a plugable design.
+ *
+ * Claws Mail is Copyright (C) 1999-2011 by the Claws Mail Team and
+ * Claws-contacts is Copyright (C) 2011 by Michael Rasmussen.
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
+ */
+#ifdef HAVE_CONFIG_H
+#       include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include "mainwindow.h"
+#include "extension.h"
+#include "extension-loader.h"
+
+
+
diff --git a/src/extension.h b/src/extension.h
new file mode 100644 (file)
index 0000000..719368a
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * $Id$
+ */
+/* vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: */
+
+/*
+ * Claws-contacts is a proposed new design for the address book feature
+ * in Claws Mail. The goal for this new design was to create a
+ * solution more suitable for the term lightweight and to be more
+ * maintainable than the present implementation.
+ *
+ * More lightweight is achieved by design, in that sence that the whole
+ * structure is based on a plugable design.
+ *
+ * Claws Mail is Copyright (C) 1999-2011 by the Claws Mail Team and
+ * Claws-contacts is Copyright (C) 2011 by Michael Rasmussen.
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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 __EXTENSION_H__
+#define __EXTENSION_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#include "mainwindow.h"
+
+typedef enum {
+       EXTENSION_BEFORE_INIT_HOOK,
+       EXTENSION_AFTER_INIT_HOOK,
+       EXTENSION_BEFORE_OPEN_ABOOK_HOOK,
+       EXTENSION_AFTER_OPEN_ABOOK_HOOK,
+       EXTENSION_BEFORE_CLOSE_ABOOK_HOOK,
+       EXTENSION_AFTER_CLOSE_ABOOK_HOOK,
+       EXTENSION_BEFORE_DELETE_ABOOK_HOOK,
+       EXTENSION_AFTER_DELETE_ABOOK_HOOK,
+       EXTENSION_BEFORE_SEARCH_ABOOK_HOOK,
+       EXTENSION_AFTER_SEARCH_ABOOK_HOOK,
+       EXTENSION_BEFORE_ADD_ABOOK_HOOK,
+       EXTENSION_AFTER_ADD_ABOOK_HOOK,
+       EXTENSION_BEFORE_INIT_ABOOK_HOOK,
+       EXTENSION_AFTER_INIT_ABOOK_HOOK,
+       EXTENSION_BEFORE_OPEN_CONTACT_HOOK,
+       EXTENSION_AFTER_OPEN_CONTACT_HOOK,
+       EXTENSION_BEFORE_CLOSE_CONTACT_HOOK,
+       EXTENSION_AFTER_CLOSE_CONTACT_HOOK,
+       EXTENSION_BEFORE_DELETE_CONTACT_HOOK,
+       EXTENSION_AFTER_DELETE_CONTACT_HOOK,
+       EXTENSION_BEFORE_SEARCH_CONTACT_HOOK,
+       EXTENSION_AFTER_SEARCH_CONTACT_HOOK,
+       EXTENSION_BEFORE_ADD_CONTACT_HOOK,
+       EXTENSION_AFTER_ADD_CONTACT_HOOK,
+       EXTENSION_BEFORE_INIT_CONTACT_HOOK,
+       EXTENSION_AFTER_INIT_CONTACT_HOOK,
+       EXTENSION_HOOK_N
+} ExtensionHook;
+
+typedef void (*HOOKFUNC) (const MainWindow* mainwindow, gpointer object);
+
+/* Any extension must implement these functions */
+
+G_END_DECLS
+
+#endif
index 06f5365dfc2c86b41944fbb38e3cfe440642da9b..bb9c237e783760e943fe9438f1869fa3f01efb5c 100644 (file)
@@ -43,6 +43,7 @@
 #include "mainwindow.h"
 #include "callbacks.h"
 #include "utils.h"
+#include "extension-loader.h"
 
 const gchar* PIXMAPS[PIXMAP_N] = {
     PIXDIR"/claws-contacts_16x16.png",
@@ -637,12 +638,16 @@ void set_status_msg(MainWindow* mainwindow, STATUS id, const gchar* extra) {
     g_string_free(msg, TRUE);
 }
 
-void application_start(gboolean compose) {
+void application_start(gboolean compose, gboolean avoid_extensions) {
     MainWindow* mainwindow = g_new0(MainWindow, 1);
     
     mainwindow->compose_mode = compose;
     mainwindow_create(mainwindow);
 
+    if (! avoid_extensions) {
+        init_hooks(mainwindow);
+    }
+
     GList* pixmaps = load_pixmaps();
     gtk_window_set_default_icon_list(pixmaps);
     g_list_free(pixmaps);
index 501eaad8135632a8154aaf65956da764800a6c9f..3a9bc14126a2f0672305d6074c51c7fda9310298 100644 (file)
@@ -104,7 +104,7 @@ typedef enum {
     STATUS_MSG_SEARCHING
 } STATUS;
 
-void application_start(gboolean compose);
+void application_start(gboolean compose, gboolean avoid_extensions);
 void set_status_msg(MainWindow* mainwindow, STATUS id, const gchar* extra);
 
 G_END_DECLS