2006-08-27 [colin] 2.4.0cvs97
authorColin Leroy <colin@colino.net>
Sun, 27 Aug 2006 09:48:26 +0000 (09:48 +0000)
committerColin Leroy <colin@colino.net>
Sun, 27 Aug 2006 09:48:26 +0000 (09:48 +0000)
* src/msgcache.c
Disable mmaped caches - huge metadata loss
here after a power failure.
* src/summaryview.c
Add quicksearch timing
* src/common/plugin.c
* src/common/plugin.h
Implement an interface to tell what plugins
provide. Prevent loading of similar plugins.
* src/plugins/clamav/clamav_plugin.c
* src/plugins/demo/demo.c
* src/plugins/dillo_viewer/dillo_viewer.c
* src/plugins/pgpcore/plugin.c
* src/plugins/pgpinline/pgpinline.c
* src/plugins/pgpmime/pgpmime.c
* src/plugins/spamassassin/spamassassin.c
* src/plugins/trayicon/trayicon.c
Implement plugin_provides()

15 files changed:
ChangeLog
PATCHSETS
configure.ac
src/common/plugin.c
src/common/plugin.h
src/msgcache.c
src/plugins/clamav/clamav_plugin.c
src/plugins/demo/demo.c
src/plugins/dillo_viewer/dillo_viewer.c
src/plugins/pgpcore/plugin.c
src/plugins/pgpinline/pgpinline.c
src/plugins/pgpmime/pgpmime.c
src/plugins/spamassassin/spamassassin.c
src/plugins/trayicon/trayicon.c
src/summaryview.c

index 41de3b5..ca2b360 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2006-08-27 [colin]     2.4.0cvs97
+
+       * src/msgcache.c
+               Disable mmaped caches - huge metadata loss
+               here after a power failure.
+       * src/summaryview.c
+               Add quicksearch timing
+       * src/common/plugin.c
+       * src/common/plugin.h
+               Implement an interface to tell what plugins
+               provide. Prevent loading of similar plugins.
+       * src/plugins/clamav/clamav_plugin.c
+       * src/plugins/demo/demo.c
+       * src/plugins/dillo_viewer/dillo_viewer.c
+       * src/plugins/pgpcore/plugin.c
+       * src/plugins/pgpinline/pgpinline.c
+       * src/plugins/pgpmime/pgpmime.c
+       * src/plugins/spamassassin/spamassassin.c
+       * src/plugins/trayicon/trayicon.c
+               Implement plugin_provides()
+
 2006-08-27 [colin]     2.4.0cvs96
 
        * configure.ac
index d69f5c8..c9a3aba 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.12 -r 1.1.2.13 manual/glossary.xml;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 manual/handling.xml;  cvs diff -u -r 1.1.2.13 -r 1.1.2.14 manual/plugins.xml;  cvs diff -u -r 1.1.2.7 -r 1.1.2.8 manual/starting.xml;  ) > 2.4.0cvs94.patchset
 ( cvs diff -u -r 1.1.2.10 -r 1.1.2.11 manual/handling.xml;  ) > 2.4.0cvs95.patchset
 ( cvs diff -u -r 1.654.2.1834 -r 1.654.2.1835 configure.ac;  cvs diff -u -r 1.8.2.5 -r 1.8.2.6 src/plugins/Makefile.am;  diff -u /dev/null src/plugins/bogofilter/.cvsignore;  diff -u /dev/null src/plugins/bogofilter/Makefile.am;  diff -u /dev/null src/plugins/bogofilter/bogofilter.c;  diff -u /dev/null src/plugins/bogofilter/bogofilter.h;  diff -u /dev/null src/plugins/bogofilter/bogofilter_gtk.c;  ) > 2.4.0cvs96.patchset
+( cvs diff -u -r 1.16.2.37 -r 1.16.2.38 src/msgcache.c;  cvs diff -u -r 1.395.2.235 -r 1.395.2.236 src/summaryview.c;  cvs diff -u -r 1.13.2.19 -r 1.13.2.20 src/common/plugin.c;  cvs diff -u -r 1.5.2.6 -r 1.5.2.7 src/common/plugin.h;  cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/common/timing.h;  cvs diff -u -r 1.13.2.22 -r 1.13.2.23 src/plugins/clamav/clamav_plugin.c;  cvs diff -u -r 1.13.2.7 -r 1.13.2.8 src/plugins/demo/demo.c;  cvs diff -u -r 1.12.2.13 -r 1.12.2.14 src/plugins/dillo_viewer/dillo_viewer.c;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/plugins/pgpcore/plugin.c;  cvs diff -u -r 1.1.2.16 -r 1.1.2.17 src/plugins/pgpinline/pgpinline.c;  cvs diff -u -r 1.1.2.37 -r 1.1.2.38 src/plugins/pgpmime/pgpmime.c;  cvs diff -u -r 1.18.2.36 -r 1.18.2.37 src/plugins/spamassassin/spamassassin.c;  cvs diff -u -r 1.14.2.36 -r 1.14.2.37 src/plugins/trayicon/trayicon.c;  ) > 2.4.0cvs97.patchset
index cadce5a..acb860c 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=96
+EXTRA_VERSION=97
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8287f94..3dfb0b9 100644 (file)
@@ -42,10 +42,23 @@ struct _Plugin
        const gchar *(*version) (void);
        const gchar *(*type) (void);
        const gchar *(*licence) (void);
+       struct PluginFeature *(*provides) (void);
+       
        GSList *rdeps;
        gchar *error;
 };
 
+const gchar *plugin_feature_names[] =
+       { N_("Nothing"),
+         N_("a viewer"),
+         N_("folders"),
+         N_("filtering"),
+         N_("a privacy interface"),
+         N_("a notifier"),
+         N_("an utility"),
+         N_("things"),
+         NULL };
+
 /**
  * List of all loaded plugins
  */
@@ -227,6 +240,32 @@ static void plugin_remove_from_unloaded_list (const gchar *filename)
        }
 }
 
+static gchar *plugin_check_features(struct PluginFeature *features) {
+       int i = 0, j = 0;
+       GSList *cur = plugins;
+
+       if (features == NULL)
+               return NULL;
+       for(; cur; cur = cur->next) {
+               Plugin *p = (Plugin *)cur->data;
+               struct PluginFeature *cur_features = p->provides();
+               for (j = 0; cur_features[j].type != PLUGIN_NOTHING; j++) {
+                       for (i = 0; features[i].type != PLUGIN_NOTHING; i++) {
+                               if (cur_features[j].type == features[i].type &&
+                                   !strcmp(cur_features[j].subtype, features[i].subtype)) {
+                                       return g_strdup_printf(_(
+                                               "This plugin provides %s (%s), which is "
+                                               "already provided by the %s plugin."),
+                                               _(plugin_feature_names[features[i].type]), 
+                                               _(features[i].subtype),
+                                               p->name());
+                               }
+                       }
+               }
+       }
+
+       return NULL;
+}
 /**
  * Loads a plugin
  *
@@ -241,6 +280,8 @@ Plugin *plugin_load(const gchar *filename, gchar **error)
        gpointer plugin_name, plugin_desc, plugin_version;
        const gchar *(*plugin_type)(void);
        const gchar *(*plugin_licence)(void);
+       struct PluginFeature *(*plugin_provides)(void);
+
        gint ok;
 
        g_return_val_if_fail(filename != NULL, NULL);
@@ -275,6 +316,7 @@ Plugin *plugin_load(const gchar *filename, gchar **error)
            !g_module_symbol(plugin->module, "plugin_version", &plugin_version) ||
            !g_module_symbol(plugin->module, "plugin_type", (gpointer)&plugin_type) ||
            !g_module_symbol(plugin->module, "plugin_licence", (gpointer)&plugin_licence) ||
+           !g_module_symbol(plugin->module, "plugin_provides", (gpointer)&plugin_provides) ||
            !g_module_symbol(plugin->module, "plugin_init", (gpointer)&plugin_init)) {
                *error = g_strdup(g_module_error());
                g_module_close(plugin->module);
@@ -297,11 +339,17 @@ Plugin *plugin_load(const gchar *filename, gchar **error)
                return NULL;
        }
 
+       if ((*error = plugin_check_features(plugin_provides())) != NULL) {
+               g_module_close(plugin->module);
+               g_free(plugin);
+               return NULL;
+       }
        plugin->name = plugin_name;
        plugin->desc = plugin_desc;
        plugin->version = plugin_version;
        plugin->type = plugin_type;
        plugin->licence = plugin_licence;
+       plugin->provides = plugin_provides;
        plugin->filename = g_strdup(filename);
        plugin->error = NULL;
        if ((ok = plugin_init(error)) < 0) {
index 1dd18c2..5f671f8 100644 (file)
 
 typedef struct _Plugin Plugin;
 
+typedef enum {
+       PLUGIN_NOTHING,
+       PLUGIN_MIMEVIEWER,
+       PLUGIN_FOLDERCLASS,
+       PLUGIN_FILTERING,
+       PLUGIN_PRIVACY,
+       PLUGIN_NOTIFIER,
+       PLUGIN_UTILITY,
+       PLUGIN_OTHER
+} PluginFeatureType;
+
+struct PluginFeature {
+       PluginFeatureType type;
+       const gchar *subtype;
+};
+
 /* Functions to implement by the plugin */
 gint plugin_init               (gchar          **error);
 void plugin_done               (void);
 const gchar *plugin_name       (void);
 const gchar *plugin_desc       (void);
 const gchar *plugin_version    (void);
+struct PluginFeature *plugin_provides (void);
 
 /* Functions by the sylpheed plugin system */
 Plugin *plugin_load            (const gchar     *filename,
index 1441e7e..9047c60 100644 (file)
@@ -65,7 +65,7 @@ static gboolean msgcache_use_mmap = FALSE;
         ((x[2]&0xff) << 16) |          \
         ((x[3]&0xff) << 24))
 
-static gboolean msgcache_use_mmap = TRUE;
+static gboolean msgcache_use_mmap = FALSE;
 #endif
 
 static gboolean swapping = TRUE;
index 6561eba..9f4b2d3 100644 (file)
@@ -276,3 +276,11 @@ const gchar *plugin_version(void)
 {
        return VERSION;
 }
+
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_FILTERING, N_("Virus detection")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
index 2766372..a223df8 100644 (file)
@@ -96,3 +96,11 @@ const gchar *plugin_version(void)
 {
        return VERSION;
 }
+
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_OTHER, N_("Demo")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
index 36c9f2a..7dae013 100644 (file)
@@ -216,3 +216,11 @@ const gchar *plugin_version(void)
 {
        return VERSION;
 }
+
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_MIMEVIEWER, N_("text/html")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
index be342f4..ade5975 100644 (file)
@@ -29,6 +29,7 @@
 #include "common/sylpheed.h"
 #include "sgpgme.h"
 #include "prefs_gpg.h"
+#include "plugin.h"
 
 gint plugin_init(gchar **error)
 {
@@ -87,3 +88,10 @@ const gchar *plugin_version(void)
        return VERSION;
 }
 
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_PRIVACY, N_("Core operations")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
index c527980..af2c4ba 100644 (file)
@@ -40,6 +40,7 @@
 #include "quoted-printable.h"
 #include "base64.h"
 #include "codeconv.h"
+#include "plugin.h"
 
 extern struct GPGConfig prefs_gpg;
 
@@ -739,4 +740,11 @@ void pgpinline_done()
        privacy_unregister_system(&pgpinline_system);
 }
 
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_PRIVACY, N_("PGP/Inline")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
 #endif /* USE_GPGME */
index 6e3026f..3f4a29f 100644 (file)
@@ -33,6 +33,7 @@
 #include "utils.h"
 #include "privacy.h"
 #include "procmime.h"
+#include "plugin.h"
 
 #include "pgpmime.h"
 #include <plugins/pgpcore/sgpgme.h>
@@ -697,4 +698,11 @@ void pgpmime_done()
        privacy_unregister_system(&pgpmime_system);
 }
 
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_PRIVACY, N_("PGP/Mime")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
 #endif /* USE_GPGME */
index dca3c1f..116d19a 100644 (file)
@@ -545,6 +545,15 @@ const gchar *plugin_version(void)
        return VERSION;
 }
 
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_FILTERING, N_("Spam detection")},
+                 {PLUGIN_FILTERING, N_("Spam learning")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
+
 void spamassassin_register_hook(void)
 {
        hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
index 613ebe6..40958ab 100644 (file)
@@ -388,3 +388,11 @@ static void trayicon_exit_cb( gpointer data, guint action, GtkWidget *widget )
                app_exit_cb(mainwin, 0, NULL);
        }
 }
+
+struct PluginFeature *plugin_provides(void)
+{
+       static struct PluginFeature features[] = 
+               { {PLUGIN_NOTIFIER, N_("Trayicon")},
+                 {PLUGIN_NOTHING, NULL}};
+       return features;
+}
index 270fd08..979ff1e 100644 (file)
@@ -1001,6 +1001,7 @@ START_TIMING("--------- summary_show");
 
        if (quicksearch_is_active(summaryview->quicksearch)) {
                GSList *not_killed;
+               START_TIMING("quicksearch");
                gint num = 0, total = summaryview->folder_item->total_msgs;
                statusbar_print_all(_("Searching in %s... \n"), 
                        summaryview->folder_item->path ? 
@@ -1037,6 +1038,7 @@ START_TIMING("--------- summary_show");
                }
                g_slist_free(mlist);
                mlist = not_killed;
+               END_TIMING();
        }
 
        if (!hidden_removed) {