0.8.8claws2
authorChristoph Hohmann <reboot@gmx.ch>
Thu, 26 Dec 2002 15:36:46 +0000 (15:36 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Thu, 26 Dec 2002 15:36:46 +0000 (15:36 +0000)
* configure.in
        sort configure checks into common / gtk / plugins
* po/POTFILES.in
        add src/prefs_gtk.c
* src/Makefile.am
        add plugins SUBDIR
* src/main.c
* src/common/sylpheed.[ch]
        added now sylpheed_done function for shutdown
* src/common/Makefile.am
* src/common/plugin.[ch]                ** NEW **
        plugin loader and unloader
* src/plugins/.cvsignore                ** NEW **
* src/plugins/Makefile.am               ** NEW **
        build plugins
* src/plugins/demo/.cvsignore           ** NEW **
* src/plugins/demo/Makefile.am          ** NEW **
* src/plugins/demo/demo.c               ** NEW **
        small demo plugin that installs a logtext hook and
        outputs the log text to stdout

15 files changed:
ChangeLog.claws
configure.in
po/POTFILES.in
src/Makefile.am
src/common/Makefile.am
src/common/plugin.c [new file with mode: 0644]
src/common/plugin.h [new file with mode: 0644]
src/common/sylpheed.c
src/common/sylpheed.h
src/main.c
src/plugins/.cvsignore [new file with mode: 0644]
src/plugins/Makefile.am [new file with mode: 0644]
src/plugins/demo/.cvsignore [new file with mode: 0644]
src/plugins/demo/Makefile.am [new file with mode: 0644]
src/plugins/demo/demo.c [new file with mode: 0644]

index d2f6553..b58d70d 100644 (file)
@@ -1,3 +1,26 @@
+2002-12-26 [christoph] 0.8.8claws2
+
+       * configure.in
+               sort configure checks into common / gtk / plugins
+       * po/POTFILES.in
+               add src/prefs_gtk.c
+       * src/Makefile.am
+               add plugins SUBDIR
+       * src/main.c
+       * src/common/sylpheed.[ch]
+               added now sylpheed_done function for shutdown
+       * src/common/Makefile.am
+       * src/common/plugin.[ch]                ** NEW **
+               plugin loader and unloader
+       * src/plugins/.cvsignore                ** NEW **
+       * src/plugins/Makefile.am               ** NEW **
+               build plugins
+       * src/plugins/demo/.cvsignore           ** NEW **
+       * src/plugins/demo/Makefile.am          ** NEW **
+       * src/plugins/demo/demo.c               ** NEW **
+               small demo plugin that installs a logtext hook and
+               outputs the log text to stdout
+
 2002-12-26 [paul]      0.8.8claws1
 
        * po/es.po
index 2ecae78..eb5f197 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws1
+EXTRA_VERSION=claws2
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
@@ -95,10 +95,118 @@ else
   AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}", PACKAGE_DATA_DIR)
 fi
 
-dnl Checks for libraries.
+AC_CHECK_LIB(xpg4, setlocale)
+
+dnl for GThread support (currently disabled)
+dnl AC_ARG_ENABLE(threads,
+dnl    [  --enable-threads        Enable multithread support [default=no]],
+dnl    [use_threads=$enableval], [use_threads=no])
+
+AC_MSG_CHECKING([whether to use threads])
+if test x"$use_threads" = xyes ; then
+       AC_MSG_RESULT(yes)
+       if test ! -z `$GLIB_CONFIG --help 2>&1 |grep 'gthread'` ; then
+               CFLAGS="$CFLAGS `$GLIB_CONFIG --cflags gthread`"
+               LIBS="$LIBS `$GLIB_CONFIG --libs gthread`"
+               AC_DEFINE(USE_THREADS, 1, Whether to use multithread or not)
+       else
+               AC_MSG_ERROR([Sylpheed requires GThread from GLib to use threading.])
+       fi
+else
+       AC_MSG_RESULT(no)
+fi
+
+dnl Checks for header files.
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(fcntl.h sys/file.h unistd.h paths.h \
+                sys/param.h sys/utsname.h sys/select.h \
+                wchar.h wctype.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_STRUCT_TM
+
+dnl AC_CHECK_TYPE(wint_t, unsigned int) does not work because wint_t
+dnl may be defined only in wchar.h (this happens with gcc-2.96).
+dnl So we need to use this extended macro.
+SYLPHEED_CHECK_TYPE(wint_t, unsigned int,
+[
+#if HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+], Define to `unsigned int' if <stddef.h> or <wchar.h> doesn't define.)
+
+GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF, Used to test for a u32 typedef)
+AC_CHECK_SIZEOF(unsigned short, 2)
+AC_CHECK_SIZEOF(unsigned int, 4)
+AC_CHECK_SIZEOF(unsigned long, 4)
+
+dnl Checks for library functions.
+AC_FUNC_ALLOCA
+AC_CHECK_FUNCS(gethostname mkdir mktime socket strstr strchr \
+              wcsstr wcswcs iswalnum iswspace towlower \
+              wcslen wcscpy wcsncpy \
+              uname flock lockf inet_aton inet_addr \
+              fchmod mkstemp)
+
+dnl *****************
+dnl ** common code **
+dnl *****************
+
+dnl check for glib
 AM_PATH_GLIB(1.2.6,,
        AC_MSG_ERROR(Test for GLIB failed. See the file 'INSTALL' for help.),
        gthread)
+
+dnl check for IPv6 option
+AC_ARG_ENABLE(ipv6,
+       [  --enable-ipv6           Enable IPv6 support [default=no]],
+       [ac_cv_enable_ipv6=$enableval], [ac_cv_enable_ipv6=no])
+
+dnl automated checks for IPv6 support.
+AC_MSG_CHECKING([whether to use IPv6])
+if test x"$ac_cv_enable_ipv6" = xyes; then
+       AC_MSG_RESULT(yes)
+       AC_MSG_CHECKING([for IPv6 support])
+       AC_CACHE_VAL(ac_cv_ipv6,[
+               AC_TRY_COMPILE([#define INET6
+                               #include <sys/types.h>
+                               #include <netinet/in.h>],
+                       [int x = IPPROTO_IPV6; struct in6_addr a;],
+                       ac_cv_ipv6=yes, ac_cv_ipv6=no)
+       ])
+       AC_MSG_RESULT($ac_cv_ipv6)
+       if test $ac_cv_ipv6 = yes; then
+               AC_DEFINE(INET6, 1, Define if you want IPv6 support.)
+       else
+               AC_MSG_WARN(*** IPv6 will not be supported ***)
+               ac_cv_enable_ipv6=no
+       fi
+else
+       AC_MSG_RESULT(no)
+fi
+
+dnl Check for OpenSSL
+AM_PATH_OPENSSL
+
+dnl Check for libjconv
+AC_ARG_ENABLE(jconv,
+       [  --disable-jconv         Do not use libjconv],
+       [ac_cv_enable_jconv=$enableval], [ac_cv_enable_jconv=yes])
+if test "$ac_cv_enable_jconv" = yes; then
+       AC_CHECK_LIB(jconv, jconv_alloc_conv,,[ac_cv_enable_jconv=no])
+fi
+
+dnl ************************
+dnl ** GTK user interface **
+dnl ************************
+
+dnl Checks for GTK
 AM_PATH_GTK(1.2.6,,
        AC_MSG_ERROR(Test for GTK failed. See the file 'INSTALL' for help.))
 
@@ -119,66 +227,39 @@ fi
 CFLAGS="$CFLAGS_SAVE"
 LDFLAGS="$LDFLAGS_SAVE"
 
-dnl Check for built-in image view support
-AC_ARG_ENABLE(gdk-pixbuf,
-       [  --disable-gdk-pixbuf    Do not use gdk-pixbuf],
-       [ac_cv_enable_gdk_pixbuf=$enableval], [ac_cv_enable_gdk_pixbuf=yes])
-AC_ARG_ENABLE(imlib,
-       [  --disable-imlib         Do not use imlib],
-       [ac_cv_enable_imlib=$enableval], [ac_cv_enable_imlib=yes])
-
-if test "$ac_cv_enable_gdk_pixbuf" = yes; then
-       AM_PATH_GDK_PIXBUF(0.8.0,
-               [AC_DEFINE(HAVE_GDK_PIXBUF, 1, Define if you use gdk-pixbuf to support image view)
-                ac_cv_enable_imlib=no], [ac_cv_enable_gdk_pixbuf=no])
-fi
-if test "$ac_cv_enable_imlib" = yes; then
-       AM_PATH_GDK_IMLIB(1.9,
-               AC_DEFINE(HAVE_GDK_IMLIB, 1, Define if you use gdk_imlib to support image view),
-               [ac_cv_enable_imlib=no])
-fi
-if test "$ac_cv_enable_gdk_pixbuf" = no -a "$ac_cv_enable_imlib" = no; then
-       AC_MSG_WARN(*** Built-in image view will not be supported ***)
-fi
-
-dnl GPGME is used to support OpenPGP 
-AC_ARG_ENABLE(gpgme,
-       [  --enable-gpgme          Enable GnuPG support using GPGME [default=no]],
-       [ac_cv_enable_gpgme=$enableval], [ac_cv_enable_gpgme=no])
-AC_MSG_CHECKING([whether to use GPGME])
-if test $ac_cv_enable_gpgme = yes; then
+dnl GNU/Aspell is used for spell checking
+AC_ARG_ENABLE(aspell,
+       [  --enable-aspell         Enable GNU/aspell support [default=no]],
+       [ac_cv_enable_aspell=$enableval], [ac_cv_enable_aspell=no])
+AC_MSG_CHECKING([whether to use GNU/aspell])
+if test $ac_cv_enable_aspell = yes; then
        AC_MSG_RESULT(yes)
-       AM_PATH_GPGME(0.3.10, AC_DEFINE(USE_GPGME, 1, Define if you use GPGME to support OpenPGP.),
-                     [use_gpgme=no
-                      ac_cv_enable_gpgme=no])
+       AM_PATH_ASPELL(0.50, AC_DEFINE(USE_ASPELL, 1, Define if you use ASPELL to support spell checking),
+                     [use_aspell=no ac_cv_enable_aspell=no])
 else
        AC_MSG_RESULT(no)
 fi
 
-dnl for JPilot support in addressbook
-dnl no check for libraries; these are dynamically loaded
-AC_ARG_ENABLE(jpilot,
-       [  --enable-jpilot         Enable JPilot support [default=no]],
-       [ac_cv_enable_jpilot=$enableval], [ac_cv_enable_jpilot=no])
-AC_MSG_CHECKING([whether to use JPilot])
-if test "$ac_cv_enable_jpilot" = yes; then
-       AC_MSG_RESULT(yes)
-       AC_CHECK_HEADERS(pi-args.h pi-appinfo.h pi-address.h,
-                        [ AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ],
-                        [ ac_cv_enable_jpilot=no ])
-       if test "$ac_cv_enable_jpilot" = no; then
-               AC_CHECK_HEADERS(libpisock/pi-args.h libpisock/pi-appinfo.h libpisock/pi-address.h,
-                                [ ac_cv_enable_jpilot=yes
-                                  AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ])
+dnl want crash dialog
+AC_ARG_ENABLE(crash-dialog,
+       [  --enable-crash-dialog   Enable crash dialog [default=no]],
+       [ac_cv_enable_crash_dialog=$enableval], [ac_cv_enable_crash_dialog=no])
+if test $ac_cv_enable_crash_dialog = yes; then
+dnl check if GDB is somewhere
+       AC_CHECK_PROG(ac_cv_enable_crash_dialog, gdb, yes, no)
+       AC_MSG_CHECKING([whether to use crash dialog])
+       if test $ac_cv_enable_crash_dialog = yes; then
+               AC_DEFINE(CRASH_DIALOG, 1, Pop up crash dialog)
        fi
-       AC_MSG_CHECKING([whether jpilot is available])
-       AC_MSG_RESULT($ac_cv_enable_jpilot)
+       AC_MSG_RESULT($ac_cv_enable_crash_dialog)
+fi
 
-       if test "$ac_cv_enable_jpilot" = yes; then
-               LIBS="$LIBS -lpisock"
-       fi
-else
-       AC_MSG_RESULT(no)
+dnl Check for X-Face support
+AC_ARG_ENABLE(compface,
+       [  --disable-compface      Do not use compface (X-Face)],
+       [ac_cv_enable_compface=$enableval], [ac_cv_enable_compface=yes])
+if test "$ac_cv_enable_compface" = yes; then
+       AC_CHECK_LIB(compface, uncompface,,[ac_cv_enable_compface=no])
 fi
 
 dnl for LDAP support in addressbook
@@ -225,138 +306,89 @@ else
        AC_MSG_RESULT(no)
 fi
 
-dnl Check for OpenSSL
-AM_PATH_OPENSSL
-
-dnl Check for X-Face support
-AC_ARG_ENABLE(compface,
-       [  --disable-compface      Do not use compface (X-Face)],
-       [ac_cv_enable_compface=$enableval], [ac_cv_enable_compface=yes])
-if test "$ac_cv_enable_compface" = yes; then
-       AC_CHECK_LIB(compface, uncompface,,[ac_cv_enable_compface=no])
-fi
-
-dnl Check for libjconv
-AC_ARG_ENABLE(jconv,
-       [  --disable-jconv         Do not use libjconv],
-       [ac_cv_enable_jconv=$enableval], [ac_cv_enable_jconv=yes])
-if test "$ac_cv_enable_jconv" = yes; then
-       AC_CHECK_LIB(jconv, jconv_alloc_conv,,[ac_cv_enable_jconv=no])
-fi
-
-AC_CHECK_LIB(xpg4, setlocale)
-
-dnl for GThread support (currently disabled)
-dnl AC_ARG_ENABLE(threads,
-dnl    [  --enable-threads        Enable multithread support [default=no]],
-dnl    [use_threads=$enableval], [use_threads=no])
-
-AC_MSG_CHECKING([whether to use threads])
-if test x"$use_threads" = xyes ; then
+dnl for JPilot support in addressbook
+dnl no check for libraries; these are dynamically loaded
+AC_ARG_ENABLE(jpilot,
+       [  --enable-jpilot         Enable JPilot support [default=no]],
+       [ac_cv_enable_jpilot=$enableval], [ac_cv_enable_jpilot=no])
+AC_MSG_CHECKING([whether to use JPilot])
+if test "$ac_cv_enable_jpilot" = yes; then
        AC_MSG_RESULT(yes)
-       if test ! -z `$GLIB_CONFIG --help 2>&1 |grep 'gthread'` ; then
-               CFLAGS="$CFLAGS `$GLIB_CONFIG --cflags gthread`"
-               LIBS="$LIBS `$GLIB_CONFIG --libs gthread`"
-               AC_DEFINE(USE_THREADS, 1, Whether to use multithread or not)
-       else
-               AC_MSG_ERROR([Sylpheed requires GThread from GLib to use threading.])
+       AC_CHECK_HEADERS(pi-args.h pi-appinfo.h pi-address.h,
+                        [ AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ],
+                        [ ac_cv_enable_jpilot=no ])
+       if test "$ac_cv_enable_jpilot" = no; then
+               AC_CHECK_HEADERS(libpisock/pi-args.h libpisock/pi-appinfo.h libpisock/pi-address.h,
+                                [ ac_cv_enable_jpilot=yes
+                                  AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ])
+       fi
+       AC_MSG_CHECKING([whether jpilot is available])
+       AC_MSG_RESULT($ac_cv_enable_jpilot)
+
+       if test "$ac_cv_enable_jpilot" = yes; then
+               LIBS="$LIBS -lpisock"
        fi
 else
        AC_MSG_RESULT(no)
 fi
 
-dnl check for IPv6 option
-AC_ARG_ENABLE(ipv6,
-       [  --enable-ipv6           Enable IPv6 support [default=no]],
-       [ac_cv_enable_ipv6=$enableval], [ac_cv_enable_ipv6=no])
+dnl Check for built-in image view support
+AC_ARG_ENABLE(gdk-pixbuf,
+       [  --disable-gdk-pixbuf    Do not use gdk-pixbuf],
+       [ac_cv_enable_gdk_pixbuf=$enableval], [ac_cv_enable_gdk_pixbuf=yes])
+AC_ARG_ENABLE(imlib,
+       [  --disable-imlib         Do not use imlib],
+       [ac_cv_enable_imlib=$enableval], [ac_cv_enable_imlib=yes])
 
-dnl automated checks for IPv6 support.
-AC_MSG_CHECKING([whether to use IPv6])
-if test x"$ac_cv_enable_ipv6" = xyes; then
-       AC_MSG_RESULT(yes)
-       AC_MSG_CHECKING([for IPv6 support])
-       AC_CACHE_VAL(ac_cv_ipv6,[
-               AC_TRY_COMPILE([#define INET6
-                               #include <sys/types.h>
-                               #include <netinet/in.h>],
-                       [int x = IPPROTO_IPV6; struct in6_addr a;],
-                       ac_cv_ipv6=yes, ac_cv_ipv6=no)
-       ])
-       AC_MSG_RESULT($ac_cv_ipv6)
-       if test $ac_cv_ipv6 = yes; then
-               AC_DEFINE(INET6, 1, Define if you want IPv6 support.)
-       else
-               AC_MSG_WARN(*** IPv6 will not be supported ***)
-               ac_cv_enable_ipv6=no
-       fi
-else
-       AC_MSG_RESULT(no)
+if test "$ac_cv_enable_gdk_pixbuf" = yes; then
+       AM_PATH_GDK_PIXBUF(0.8.0,
+               [AC_DEFINE(HAVE_GDK_PIXBUF, 1, Define if you use gdk-pixbuf to support image view)
+                ac_cv_enable_imlib=no], [ac_cv_enable_gdk_pixbuf=no])
+fi
+if test "$ac_cv_enable_imlib" = yes; then
+       AM_PATH_GDK_IMLIB(1.9,
+               AC_DEFINE(HAVE_GDK_IMLIB, 1, Define if you use gdk_imlib to support image view),
+               [ac_cv_enable_imlib=no])
+fi
+if test "$ac_cv_enable_gdk_pixbuf" = no -a "$ac_cv_enable_imlib" = no; then
+       AC_MSG_WARN(*** Built-in image view will not be supported ***)
 fi
 
-dnl GNU/Aspell is used for spell checking
-AC_ARG_ENABLE(aspell,
-       [  --enable-aspell         Enable GNU/aspell support [default=no]],
-       [ac_cv_enable_aspell=$enableval], [ac_cv_enable_aspell=no])
-AC_MSG_CHECKING([whether to use GNU/aspell])
-if test $ac_cv_enable_aspell = yes; then
+dnl GPGME is used to support OpenPGP 
+AC_ARG_ENABLE(gpgme,
+       [  --enable-gpgme          Enable GnuPG support using GPGME [default=no]],
+       [ac_cv_enable_gpgme=$enableval], [ac_cv_enable_gpgme=no])
+AC_MSG_CHECKING([whether to use GPGME])
+if test $ac_cv_enable_gpgme = yes; then
        AC_MSG_RESULT(yes)
-       AM_PATH_ASPELL(0.50, AC_DEFINE(USE_ASPELL, 1, Define if you use ASPELL to support spell checking),
-                     [use_aspell=no ac_cv_enable_aspell=no])
+       AM_PATH_GPGME(0.3.10, AC_DEFINE(USE_GPGME, 1, Define if you use GPGME to support OpenPGP.),
+                     [use_gpgme=no
+                      ac_cv_enable_gpgme=no])
 else
        AC_MSG_RESULT(no)
 fi
 
-dnl want crash dialog
-AC_ARG_ENABLE(crash-dialog,
-       [  --enable-crash-dialog   Enable crash dialog [default=no]],
-       [ac_cv_enable_crash_dialog=$enableval], [ac_cv_enable_crash_dialog=no])
-if test $ac_cv_enable_crash_dialog = yes; then
-dnl check if GDB is somewhere
-       AC_CHECK_PROG(ac_cv_enable_crash_dialog, gdb, yes, no)
-       AC_MSG_CHECKING([whether to use crash dialog])
-       if test $ac_cv_enable_crash_dialog = yes; then
-               AC_DEFINE(CRASH_DIALOG, 1, Pop up crash dialog)
-       fi
-       AC_MSG_RESULT($ac_cv_enable_crash_dialog)
-fi
+dnl *************************
+dnl ** section for plugins **
+dnl *************************
 
-dnl Checks for header files.
-AC_HEADER_DIRENT
-AC_HEADER_STDC
-AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(fcntl.h sys/file.h unistd.h paths.h \
-                sys/param.h sys/utsname.h sys/select.h \
-                wchar.h wctype.h)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_OFF_T
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_STRUCT_TM
+PLUGINS=""
+PLUGINDIR=${prefix}/${DATADIRNAME}/${PACKAGE}/plugins
 
-dnl AC_CHECK_TYPE(wint_t, unsigned int) does not work because wint_t
-dnl may be defined only in wchar.h (this happens with gcc-2.96).
-dnl So we need to use this extended macro.
-SYLPHEED_CHECK_TYPE(wint_t, unsigned int,
-[
-#if HAVE_WCHAR_H
-#include <wchar.h>
-#endif
-], Define to `unsigned int' if <stddef.h> or <wchar.h> doesn't define.)
+AC_ARG_ENABLE(demo-plugin,
+       [  --enable-demo-plugin    Build demo plugin [default=no]],
+       [ac_cv_enable_demo_plugin=$enableval], [ac_cv_enable_demo_plugin=no])
+if test x"$ac_cv_enable_demo_plugin" = xyes; then
+       PLUGINS="demo $PLUGINS"
+fi
 
-GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF, Used to test for a u32 typedef)
-AC_CHECK_SIZEOF(unsigned short, 2)
-AC_CHECK_SIZEOF(unsigned int, 4)
-AC_CHECK_SIZEOF(unsigned long, 4)
+AC_SUBST(PLUGINS)
+AC_SUBST(PLUGINDIR)
+AC_DEFINE(PLUGINDIR, "$PLUGINDIR", Path where plugins will be installed)
 
-dnl Checks for library functions.
-AC_FUNC_ALLOCA
-AC_CHECK_FUNCS(gethostname mkdir mktime socket strstr strchr \
-              wcsstr wcswcs iswalnum iswspace towlower \
-              wcslen wcscpy wcsncpy \
-              uname flock lockf inet_aton inet_addr \
-              fchmod mkstemp)
+dnl ****************************
+dnl ** Final configure output **
+dnl ****************************
 
 AC_OUTPUT([
 Makefile
@@ -368,6 +400,8 @@ src/common/version.h
 src/Makefile
 src/common/Makefile
 src/gtk/Makefile
+src/plugins/Makefile
+src/plugins/demo/Makefile
 faq/Makefile
 faq/de/Makefile
 faq/en/Makefile
@@ -405,6 +439,7 @@ echo "libjconv      : $ac_cv_enable_jconv"
 echo "IPv6          : $ac_cv_enable_ipv6"
 echo "GNU/aspell    : $ac_cv_enable_aspell"
 echo "Crash dialog  : $ac_cv_enable_crash_dialog"
+echo "Plugins       : $PLUGINS"
 echo ""
 echo "The binary will be installed in $prefix/bin"
 echo ""
index fcfab40..e30cd8a 100644 (file)
@@ -50,6 +50,7 @@ src/mimeview.c
 src/news.c
 src/passphrase.c
 src/pop.c
+src/prefs_gtk.c
 src/prefs_account.c
 src/prefs_actions.c
 src/prefs_common.c
index e677a5f..bd572eb 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = common gtk
+SUBDIRS = common gtk plugins
 
 bin_PROGRAMS = sylpheed
 
index 76f9b68..2400b87 100644 (file)
@@ -8,6 +8,7 @@ libsylpheedcommon_la_SOURCES = \
        log.c log.h \
        md5.c md5.h \
        nntp.c nntp.h \
+       plugin.c plugin.h \
        prefs.c prefs.h \
        quoted-printable.c quoted-printable.h \
        session.c session.h \
@@ -21,11 +22,9 @@ libsylpheedcommon_la_SOURCES = \
        version.h \
        uuencode.c uuencode.h
 
-INCLUDES = \
-       $(GLIB_CFLAGS) \
-       $(OPENSSL_CFLAGS)
-
 CPPFLAGS = \
+       $(GLIB_CFLAGS) \
+       $(OPENSSL_CFLAGS) \
        -DLOCALEDIR=\""$(localedir)"\"
 
 libsylpheedcommon_la_LIBADD = \
diff --git a/src/common/plugin.c b/src/common/plugin.c
new file mode 100644 (file)
index 0000000..b378794
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+
+#include <glib.h>
+#include <gmodule.h>
+
+#include "intl.h"
+#include "defs.h"
+#include "utils.h"
+#include "plugin.h"
+#include "prefs.h"
+
+struct _Plugin
+{
+       gchar   *filename;
+       gchar   *name;
+       GModule *module;
+       gchar   *desc;
+};
+
+/**
+ * List of all loaded plugins
+ */
+GSList *plugins = NULL;
+
+void plugin_save_list()
+{
+       gchar *rcpath;
+       PrefFile *pfile;
+       GSList *cur;
+       Plugin *plugin;
+
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "pluginsrc", NULL);
+       if ((pfile = prefs_write_open(rcpath)) == NULL) {
+               g_warning("failed to write plugin list\n");
+               g_free(rcpath);
+               return;
+       }
+
+       for (cur = plugins; cur != NULL; cur = g_slist_next(cur)) {
+               plugin = (Plugin *)cur->data;
+                       
+               fprintf(pfile->fp, "%s\n", plugin->filename);
+       }
+
+       if (prefs_write_close(pfile) < 0)
+               g_warning("failed to write plugin list\n");
+
+       g_free(rcpath); 
+}
+
+/**
+ * Loads a plugin
+ *
+ * \param filename The filename of the plugin to load
+ * \param error The location where an error string can be stored
+ * \return 0 on success, -1 otherwise
+ */
+gint plugin_load(const gchar *filename, gchar **error)
+{
+       Plugin *plugin;
+       gint (*plugin_init) (gchar **error);
+       gint ok;
+
+       g_return_val_if_fail(filename != NULL, -1);
+       g_return_val_if_fail(error != NULL, -1);
+       
+       plugin = g_new0(Plugin, 1);
+       if (plugin == NULL) {
+               *error = g_strdup(_("Failed to allocate memory for Plugin"));
+               return -1;
+       }
+
+       plugin->module = g_module_open(filename, 0);
+       if (plugin->module == NULL) {
+               *error = g_strdup(g_module_error());
+               g_free(plugin);
+               return -1;
+       }
+
+       if (!g_module_symbol(plugin->module, "plugin_name", (gpointer *)&plugin->name) ||
+           !g_module_symbol(plugin->module, "plugin_desc", (gpointer *)&plugin->desc) ||
+           !g_module_symbol(plugin->module, "plugin_init", (gpointer *)&plugin_init)) {
+               *error = g_strdup(g_module_error());
+               g_module_close(plugin->module);
+               g_free(plugin);
+               return -1;
+       }
+
+       if ((ok = plugin_init(error)) < 0) {
+               g_module_close(plugin->module);
+               g_free(plugin);
+               return ok;
+       }
+
+       plugins = g_slist_append(plugins, plugin);
+
+       return 0;
+}
+
+void plugin_unload(Plugin *plugin)
+{
+       void (*plugin_done) ();
+
+       if (g_module_symbol(plugin->module, "plugin_done", (gpointer *)&plugin_done)) {
+               plugin_done();
+       }
+
+       g_module_close(plugin->module);
+       g_free(plugin);
+}
+
+void plugin_load_all()
+{
+       gchar *rcpath;
+       gchar buf[BUFFSIZE];
+       FILE *fp;
+
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "pluginsrc", NULL);       
+       if ((fp = fopen(rcpath, "rb")) != NULL) {
+               gchar *error;
+
+               while(fgets(buf, sizeof(buf), fp) != NULL) {
+                       g_strstrip(buf);
+                       
+                       if (plugin_load(buf, &error) < 0) {
+                               debug_print("plugin loading error: %s\n", error);
+                               g_free(error);
+                       }
+               }
+
+               fclose(fp);
+       }
+
+       g_free(rcpath);
+}
+
+void plugin_unload_all()
+{
+       GSList *cur;
+
+       for (cur = plugins; cur != NULL; cur = g_slist_next(cur)) {
+               plugin_unload((Plugin *)cur->data);
+       }
+       g_slist_free(plugins);
+       plugins = NULL;
+}
+
+GSList *plugin_get_list()
+{
+       return g_slist_copy(plugins);
+}
+
+const gchar *plugin_get_name(Plugin *plugin)
+{
+       return plugin->name;
+}
+
+const gchar *plugin_get_desc(Plugin *plugin)
+{
+       return plugin->desc;
+}
diff --git a/src/common/plugin.h b/src/common/plugin.h
new file mode 100644 (file)
index 0000000..28b291a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PLUGIN_H
+#define PLUGIN_H 1
+
+#include <glib.h>
+
+typedef struct _Plugin Plugin;
+
+/* Functions to implement by the plugin */
+gint plugin_init               (gchar          **error);
+void plugin_done               ();
+
+/* Functions by the sylpheed plugin system */
+gint plugin_load               (const gchar     *filename,
+                                gchar          **error);
+void plugin_unload             (Plugin          *plugin);
+void plugin_load_all           ();
+void plugin_unload_all         ();
+void plugin_save_list          ();
+
+GSList *plugin_get_list                ();
+const gchar *plugin_get_name   (Plugin          *plugin);
+const gchar *plugin_get_desc   (Plugin          *plugin);
+
+#endif
index 1dd0a89..67d5e7a 100644 (file)
@@ -33,6 +33,7 @@
 #include "utils.h"
 #include "ssl.h"
 #include "version.h"
+#include "plugin.h"
 
 static gboolean sylpheed_initialized = FALSE;
 
@@ -53,13 +54,24 @@ gboolean sylpheed_init(int *argc, char ***argv)
                }
        }
 
+       srandom((gint)time(NULL));
+
 #if USE_OPENSSL
        ssl_init();
 #endif
 
-       srandom((gint)time(NULL));
+       plugin_load_all();
 
        sylpheed_initialized = TRUE;
 
        return TRUE;
 }
+
+void sylpheed_done()
+{
+       plugin_unload_all();
+
+#if USE_OPENSSL
+       ssl_done();
+#endif
+}
index c50de47..ffb927d 100644 (file)
@@ -18,3 +18,4 @@
  */
 
 gboolean sylpheed_init (int *argc, char ***argv);
+void sylpheed_done     ();
index 4c463cd..9fcf093 100644 (file)
@@ -360,6 +360,7 @@ int main(int argc, char *argv[])
 #if USE_ASPELL       
        gtkaspell_checkers_delete();
 #endif
+       sylpheed_done();
 
        return 0;
 }
@@ -592,10 +593,6 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        if (!cmd.crash)
                unlink(get_crashfile_name());
 
-#if USE_OPENSSL
-       ssl_done();
-#endif
-
        gtk_main_quit();
 }
 
diff --git a/src/plugins/.cvsignore b/src/plugins/.cvsignore
new file mode 100644 (file)
index 0000000..282522d
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
new file mode 100644 (file)
index 0000000..244cb60
--- /dev/null
@@ -0,0 +1,2 @@
+SUBDIRS = $(PLUGINS)
+
diff --git a/src/plugins/demo/.cvsignore b/src/plugins/demo/.cvsignore
new file mode 100644 (file)
index 0000000..2a6ab49
--- /dev/null
@@ -0,0 +1,7 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.o
+*.lo
+*.la
diff --git a/src/plugins/demo/Makefile.am b/src/plugins/demo/Makefile.am
new file mode 100644 (file)
index 0000000..49c7e03
--- /dev/null
@@ -0,0 +1,15 @@
+libdir = $(PLUGINDIR)
+
+lib_LTLIBRARIES = demo.la
+
+demo_la_SOURCES = \
+       demo.c
+
+demo_la_LDFLAGS = \
+       -avoid-version -module
+
+INCLUDES = \
+       -I../../common
+
+CPPFLAGS = \
+       $(GLIB_CFLAGS)
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
new file mode 100644 (file)
index 0000000..2636a84
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "plugin.h"
+#include "utils.h"
+#include "hooks.h"
+#include "log.h"
+
+gchar *plugin_name = "Dummy plugin";
+gchar *plugin_desc = "Plugin that does nothing and never loads";
+
+gboolean my_log_hook(gpointer source, gpointer data)
+{
+       LogText *logtext = (LogText *)source;
+
+       printf("*** Demo Plugin log: %s\n", logtext->text);
+
+       return FALSE;
+}
+
+static guint hook_id;
+
+gint plugin_init(gchar **error)
+{
+       hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, my_log_hook, NULL);
+       if (hook_id == -1) {
+               *error = g_strdup("Failed to register log text hook");
+               return -1;
+       }
+
+       printf("Demo plugin loaded\n");
+
+       return 0;
+}
+
+void plugin_done()
+{
+       hooks_unregister_hook(LOG_APPEND_TEXT_HOOKLIST, hook_id);
+
+       printf("Demo plugin unloaded\n");
+}