+2005-07-14 [colin] 1.9.12cvs49
+
+ * configure.ac
+ * src/common/Makefile.am
+ * src/common/plugin.c
+ * src/common/plugin.h
+ Add a little plugin dependancy system.
+ Plugins can ship a $plugin_name.deps file
+ (near them in PLUGINDIR) so that their
+ dependancies are loaded if possible.
+ * src/plugins/Makefile.am
+ * src/plugins/pgpcore/Makefile.am
+ * src/plugins/pgpcore/passphrase.c
+ * src/plugins/pgpcore/passphrase.h
+ * src/plugins/pgpcore/plugin.c
+ * src/plugins/pgpcore/prefs_gpg.c
+ * src/plugins/pgpcore/prefs_gpg.h
+ * src/plugins/pgpcore/select-keys.c
+ * src/plugins/pgpcore/select-keys.h
+ * src/plugins/pgpcore/sgpgme.c
+ * src/plugins/pgpcore/sgpgme.h
+ Introduce pgpcore, used by pgpmime and
+ pgpinline
+ * src/plugins/pgpmime/Makefile.am
+ * src/plugins/pgpmime/passphrase.c
+ * src/plugins/pgpmime/passphrase.h
+ * src/plugins/pgpmime/pgpmime.c
+ * src/plugins/pgpmime/pgpmime.deps
+ * src/plugins/pgpmime/plugin.c
+ * src/plugins/pgpmime/prefs_gpg.c
+ * src/plugins/pgpmime/prefs_gpg.h
+ * src/plugins/pgpmime/select-keys.c
+ * src/plugins/pgpmime/select-keys.h
+ * src/plugins/pgpmime/sgpgme.c
+ * src/plugins/pgpmime/sgpgme.h
+ Remove the core from pgpmime and add the
+ dependancy to pgpcore.
+
2005-07-14 [paul] 1.9.12cvs48
* src/stock_pixmap.c
( cvs diff -u -r 1.1.2.19 -r 1.1.2.20 src/plugins/pgpmime/pgpmime.c; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/plugins/pgpmime/sgpgme.c; ) > 1.9.12cvs46.patchset
( cvs diff -u -r 1.61.2.29 -r 1.61.2.30 src/account.c; cvs diff -u -r 1.60.2.17 -r 1.60.2.18 src/addressbook.c; cvs diff -u -r 1.382.2.141 -r 1.382.2.142 src/compose.c; cvs diff -u -r 1.50.2.9 -r 1.50.2.10 src/compose.h; cvs diff -u -r 1.26.2.16 -r 1.26.2.17 src/foldersel.c; cvs diff -u -r 1.115.2.41 -r 1.115.2.42 src/main.c; cvs diff -u -r 1.204.2.46 -r 1.204.2.47 src/prefs_common.c; cvs diff -u -r 1.395.2.92 -r 1.395.2.93 src/summaryview.c; cvs diff -u -r 1.96.2.62 -r 1.96.2.63 src/textview.c; cvs diff -u -r 1.5.2.15 -r 1.5.2.16 src/gtk/menu.c; cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/pixmaps/sylpheed_icon.xpm; ) > 1.9.12cvs47.patchset
( cvs diff -u -r 1.25.2.14 -r 1.25.2.15 src/stock_pixmap.c; ) > 1.9.12cvs48.patchset
+( cvs diff -u -r 1.654.2.683 -r 1.654.2.684 configure.ac; cvs diff -u -r 1.24.2.7 -r 1.24.2.8 src/common/Makefile.am; cvs diff -u -r 1.13.2.4 -r 1.13.2.5 src/common/plugin.c; cvs diff -u -r 1.5 -r 1.6 src/common/plugin.h; cvs diff -u -r 1.8.2.2 -r 1.8.2.3 src/plugins/Makefile.am; diff -u /dev/null src/plugins/pgpcore/Makefile.am; diff -u /dev/null src/plugins/pgpcore/passphrase.c; diff -u /dev/null src/plugins/pgpcore/passphrase.h; diff -u /dev/null src/plugins/pgpcore/plugin.c; diff -u /dev/null src/plugins/pgpcore/prefs_gpg.c; diff -u /dev/null src/plugins/pgpcore/prefs_gpg.h; diff -u /dev/null src/plugins/pgpcore/select-keys.c; diff -u /dev/null src/plugins/pgpcore/select-keys.h; diff -u /dev/null src/plugins/pgpcore/sgpgme.c; diff -u /dev/null src/plugins/pgpcore/sgpgme.h; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/pgpmime/Makefile.am; cvs diff -u -r -1.1.2.9 -r -1.1.2.10 src/plugins/pgpmime/passphrase.c; cvs diff -u -r -1.1.2.2 -r -1.1.2.3 src/plugins/pgpmime/passphrase.h; cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/plugins/pgpmime/pgpmime.c; diff -u /dev/null src/plugins/pgpmime/pgpmime.deps; cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/plugins/pgpmime/plugin.c; cvs diff -u -r -1.1.2.10 -r -1.1.2.11 src/plugins/pgpmime/prefs_gpg.c; cvs diff -u -r -1.1.2.3 -r -1.1.2.4 src/plugins/pgpmime/prefs_gpg.h; cvs diff -u -r -1.1.2.7 -r -1.1.2.8 src/plugins/pgpmime/select-keys.c; cvs diff -u -r -1.1.2.2 -r -1.1.2.3 src/plugins/pgpmime/select-keys.h; cvs diff -u -r -1.1.2.12 -r -1.1.2.13 src/plugins/pgpmime/sgpgme.c; cvs diff -u -r -1.1.2.5 -r -1.1.2.6 src/plugins/pgpmime/sgpgme.h; ) > 1.9.12cvs49.patchset
MICRO_VERSION=12
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=48
+EXTRA_VERSION=49
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
fi
AM_CONDITIONAL(BUILD_SPAMASSASSIN_PLUGIN, test x"$ac_cv_enable_spamassassin_plugin" = xyes)
-dnl --- PGP/MIME ---
+dnl --- PGP/CORE ---
+AC_ARG_ENABLE(pgpcore-plugin,
+ [ --disable-pgpcore-plugin Do not build PGP/Core plugin],
+ [ac_cv_enable_pgpcore_plugin=$enableval], [ac_cv_enable_pgpcore_plugin=yes])
+if test x"$ac_cv_enable_pgpcore_plugin" = xyes; then
+ AM_PATH_GPGME(0.4.5, AC_DEFINE(USE_GPGME, 1, Define if you use GPGME to support OpenPGP.),
+ [ac_cv_enable_pgpcore_plugin=no])
+ if test x"$ac_cv_enable_pgpcore_plugin" = xyes; then
+ PLUGINS="pgpcore $PLUGINS"
+ fi
+fi
+AM_CONDITIONAL(BUILD_PGPCORE_PLUGIN, test x"$ac_cv_enable_pgpcore_plugin" = xyes)
+
AC_ARG_ENABLE(pgpmime-plugin,
[ --disable-pgpmime-plugin Do not build PGP/MIME plugin],
[ac_cv_enable_pgpmime_plugin=$enableval], [ac_cv_enable_pgpmime_plugin=yes])
src/plugins/trayicon/Makefile
src/plugins/trayicon/libeggtrayicon/Makefile
src/plugins/clamav/Makefile
+src/plugins/pgpcore/Makefile
src/plugins/pgpmime/Makefile
doc/Makefile
doc/faq/Makefile
+PLUGINDIR = $(pkglibdir)/plugins/
noinst_LTLIBRARIES = libsylpheedcommon.la
libsylpheedcommon_la_SOURCES = \
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(OPENSSL_CFLAGS) \
- -DLOCALEDIR=\""$(localedir)"\"
+ -DLOCALEDIR=\""$(localedir)"\" \
+ -DPLUGINDIR=\"$(PLUGINDIR)\"
libsylpheedcommon_la_LIBADD = \
$(GLIB_LIBS) \
const gchar *(*name) (void);
const gchar *(*desc) (void);
const gchar *(*type) (void);
+ GSList *rdeps;
};
/**
g_return_val_if_fail(plugin, 1);
g_return_val_if_fail(plugin->filename, 1);
g_return_val_if_fail(filename, 1);
-
return strcmp(filename, plugin->filename);
}
}
}
+static gboolean plugin_is_loaded(const gchar *filename)
+{
+ return (g_slist_find_custom(plugins, filename,
+ (GCompareFunc)list_find_by_plugin_filename) != NULL);
+}
+
+static Plugin *plugin_get_by_filename(const gchar *filename)
+{
+ GSList *cur = plugins;
+ for(; cur; cur = cur->next) {
+ Plugin *p = (Plugin *)cur->data;
+ if (!strcmp(p->filename, filename)) {
+ return p;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * Loads a plugin dependancies
+ *
+ * Plugin dependancies are, optionnaly, listed in a file in
+ * PLUGINDIR/$pluginname.deps.
+ * \param filename The filename of the plugin for which we have to load deps
+ * \param error The location where an error string can be stored
+ * \return 0 on success, -1 otherwise
+ */
+static gint plugin_load_deps(const gchar *filename, gchar **error)
+{
+ gchar *tmp = g_strdup(filename);
+ gchar *deps_file = NULL;
+ FILE *fp = NULL;
+ gchar buf[BUFFSIZE];
+
+ *strrchr(tmp, '.') = '\0';
+ deps_file = g_strconcat(tmp, ".deps", NULL);
+ g_free(tmp);
+
+ fp = fopen(deps_file, "rb");
+ g_free(deps_file);
+
+ if (!fp)
+ return 0;
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ Plugin *dep_plugin = NULL;
+ gchar *path = NULL;
+ buf[strlen(buf)-1]='\0'; /* chop off \n */
+ path = g_strconcat(PLUGINDIR, buf,
+ ".", G_MODULE_SUFFIX, NULL);
+ if ((dep_plugin = plugin_get_by_filename(path)) == NULL) {
+ debug_print("trying to load %s\n", path);
+ dep_plugin = plugin_load(path, error);
+ if (dep_plugin == NULL) {
+ g_free(path);
+ return -1;
+ }
+ }
+ if (!g_slist_find_custom(dep_plugin->rdeps,
+ (gpointer) filename, list_find_by_string)) {
+ debug_print("adding %s to %s rdeps\n",
+ filename,
+ dep_plugin->filename);
+ dep_plugin->rdeps =
+ g_slist_append(dep_plugin->rdeps,
+ g_strdup(filename));
+ }
+ }
+ fclose(fp);
+ return 0;
+}
+
+static void plugin_unload_rdeps(Plugin *plugin)
+{
+ GSList *cur = plugin->rdeps;
+ debug_print("removing %s rdeps\n", plugin->filename);
+ while (cur) {
+ gchar *file = (gchar *)cur->data;
+ Plugin *rdep_plugin = file?plugin_get_by_filename(file):NULL;
+ debug_print(" rdep %s: %p\n", file, rdep_plugin);
+ if (rdep_plugin) {
+ plugin_unload(rdep_plugin);
+ }
+ g_free(file);
+ cur = cur->next;
+ }
+ g_slist_free(plugin->rdeps);
+ plugin->rdeps = NULL;
+}
/**
* 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
+ * \return the plugin on success, NULL otherwise
*/
-gint plugin_load(const gchar *filename, gchar **error)
+Plugin *plugin_load(const gchar *filename, gchar **error)
{
Plugin *plugin;
gint (*plugin_init) (gchar **error);
const gchar *(*plugin_type)(void);
gint ok;
- g_return_val_if_fail(filename != NULL, -1);
- g_return_val_if_fail(error != NULL, -1);
+ g_return_val_if_fail(filename != NULL, NULL);
+ g_return_val_if_fail(error != NULL, NULL);
/* check duplicate plugin path name */
- if (g_slist_find_custom(plugins, filename,
- (GCompareFunc)list_find_by_plugin_filename)) {
+ if (plugin_is_loaded(filename)) {
*error = g_strdup(_("Plugin already loaded"));
- return -1;
+ return NULL;
}
+ if (plugin_load_deps(filename, error) < 0)
+ return NULL;
plugin = g_new0(Plugin, 1);
if (plugin == NULL) {
*error = g_strdup(_("Failed to allocate memory for Plugin"));
- return -1;
+ return NULL;
}
plugin->module = g_module_open(filename, 0);
if (plugin->module == NULL) {
*error = g_strdup(g_module_error());
g_free(plugin);
- return -1;
+ return NULL;
}
if (!g_module_symbol(plugin->module, "plugin_name", &plugin_name) ||
*error = g_strdup(g_module_error());
g_module_close(plugin->module);
g_free(plugin);
- return -1;
+ return NULL;
}
if (!strcmp(plugin_type(), "GTK")) {
*error = g_strdup(_("This module is for Sylpheed-Claws GTK1."));
g_module_close(plugin->module);
g_free(plugin);
- return -1;
+ return NULL;
}
if ((ok = plugin_init(error)) < 0) {
g_module_close(plugin->module);
g_free(plugin);
- return ok;
+ return NULL;
}
plugin->name = plugin_name;
debug_print("Plugin %s (from file %s) loaded\n", plugin->name(), filename);
- return 0;
+ return plugin;
}
void plugin_unload(Plugin *plugin)
{
void (*plugin_done) (void);
+ plugin_unload_rdeps(plugin);
+
if (g_module_symbol(plugin->module, "plugin_done", (gpointer *)&plugin_done)) {
plugin_done();
}
break;
g_strstrip(buf);
- if ((buf[0] != '\0') && (plugin_load(buf, &error) < 0)) {
+ if ((buf[0] != '\0') && (plugin_load(buf, &error) == NULL)) {
g_warning("plugin loading error: %s\n", error);
g_free(error);
}
const gchar *plugin_desc (void);
/* Functions by the sylpheed plugin system */
-gint plugin_load (const gchar *filename,
+Plugin *plugin_load (const gchar *filename,
gchar **error);
void plugin_unload (Plugin *plugin);
void plugin_load_all (const gchar *type);
clamav_dir = clamav
endif
+if BUILD_PGPCORE_PLUGIN
+pgpcore_dir = pgpcore
if BUILD_PGPMIME_PLUGIN
pgpmime_dir = pgpmime
endif
+endif
SUBDIRS = $(demo_dir) \
$(spamassasssin_dir) \
$(dillo_viewer_dir) \
$(trayicon_dir) \
$(clamav_dir) \
+ $(pgpcore_dir) \
$(pgpmime_dir)
--- /dev/null
+plugindir = $(pkglibdir)/plugins
+
+plugin_LTLIBRARIES = pgpcore.la
+
+pgpcore_la_SOURCES = \
+ passphrase.c \
+ plugin.c \
+ prefs_gpg.c \
+ select-keys.c \
+ sgpgme.c
+
+pluginincludedir = $(pkgincludedir)/plugins/pgpcore
+plugininclude_HEADERS = \
+ passphrase.h \
+ prefs_gpg.h \
+ select-keys.h \
+ sgpgme.h
+
+pgpcore_la_LDFLAGS = \
+ -avoid-version -module
+
+INCLUDES = \
+ -I../../ \
+ -I../../common \
+ -I../../gtk
+
+AM_CPPFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(GPGME_CFLAGS)
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stddef.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include "version.h"
+#include "common/sylpheed.h"
+#include "sgpgme.h"
+#include "prefs_gpg.h"
+
+gint plugin_init(gchar **error)
+{
+ if ((sylpheed_get_version() > VERSION_NUMERIC)) {
+ *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
+ return -1;
+ }
+
+ if ((sylpheed_get_version() < MAKE_NUMERIC_VERSION(1, 9, 12, 40))) {
+ *error = g_strdup("Your sylpheed version is too old");
+ return -1;
+ }
+
+ sgpgme_init();
+ prefs_gpg_init();
+
+ return 0;
+}
+
+void plugin_done(void)
+{
+ prefs_gpg_done();
+ sgpgme_done();
+}
+
+const gchar *plugin_name(void)
+{
+ return _("PGP/Core");
+}
+
+const gchar *plugin_desc(void)
+{
+ return _("This plugin handles PGP core operations. It is used by other\n"
+ "plugins, like PGP/Mime.\n\n"
+ "GPGME is copyright 2001 by Werner Koch <dd9jn@gnu.org>\n");
+}
+
+const gchar *plugin_type(void)
+{
+ return "GTK2";
+}
plugindir = $(pkglibdir)/plugins
+plugin_DATA=pgpmime.deps
plugin_LTLIBRARIES = pgpmime.la
+EXTRA_DIST=pgpmime.deps
+
pgpmime_la_SOURCES = \
- passphrase.c \
plugin.c \
- pgpmime.c \
- prefs_gpg.c \
- select-keys.c \
- sgpgme.c
+ pgpmime.c
pluginincludedir = $(pkgincludedir)/plugins/pgpmime
plugininclude_HEADERS = \
- passphrase.h \
- pgpmime.h \
- prefs_gpg.h \
- select-keys.h \
- sgpgme.h
+ pgpmime.h
pgpmime_la_LDFLAGS = \
-avoid-version -module
#include "utils.h"
#include "privacy.h"
#include "procmime.h"
+
#include "pgpmime.h"
-#include "sgpgme.h"
+#include <plugins/pgpcore/sgpgme.h>
+#include <plugins/pgpcore/prefs_gpg.h>
+#include <plugins/pgpcore/passphrase.h>
+
#include "prefs_common.h"
-#include "prefs_gpg.h"
-#include "passphrase.h"
typedef struct _PrivacyDataPGP PrivacyDataPGP;
#include "version.h"
#include "common/sylpheed.h"
-#include "sgpgme.h"
#include "pgpmime.h"
-#include "prefs_gpg.h"
gint plugin_init(gchar **error)
{
return -1;
}
- sgpgme_init();
pgpmime_init();
- prefs_gpg_init();
return 0;
}
void plugin_done(void)
{
- prefs_gpg_done();
pgpmime_done();
- sgpgme_done();
}
const gchar *plugin_name(void)