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 41de3b50c89ad81b5cd437e068175844fa2c7214..ca2b3609b67e5d7bd655c456339baab16affb3b3 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 d69f5c88a8ff88dc7687d569c968571f3cc2eb22..c9a3aba77698ac397b0e6228fc225c35b22f1601 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 cadce5a05c78116f8a4b5372177eea2da2dfa120..acb860c6ec833c47188bbe30345de1db3a7d0f04 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 8287f947ad125f924e2c7998884f50c254a37373..3dfb0b9122d7ee1ed07a72866f5a2e8cfa445310 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 1dd18c29db2e849b23b5940320a957d3f676d0ba..5f671f8acc06120594e1b8392a543e9a2ea785db 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 1441e7efd3c327df4fb87f3e3531e06edf9d3d1b..9047c60c74d1d2cde6ce2923f5e07e2dae46a47b 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 6561eba53ff6dad76d7abe71fef4dfad8c5b8f8e..9f4b2d33971ac239dccc1a70c223acc13caf9488 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 2766372dbfed47945b7505e6a70e20d58dfea8bf..a223df8288e627ce760f9022a87abda4b28be16a 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 36c9f2ab7575df864fc4c5e4ed2fdc7cf26afa0b..7dae013865ac5f4c4f03cb279fb71f0a4c2d35ca 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 be342f4f078149e243e7337198c44ce2526e330c..ade59756db40a88b3bcf755e8e6b1e1d28b609de 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 c5279809ddf3f05f743bb71cf0c6c42115b2d7f7..af2c4babfb2ec006d0266307a8c4267ca84bc2e0 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 6e3026fbda5720bf88758bb1cbec586049fb871b..3f4a29f7d602e8caedaa54258ee4bb2584d2650c 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 dca3c1fd9a0984f8d16d38fdc60563ef9320d09e..116d19a4e9e1fe1f094870b88351f92369b680ac 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 613ebe6a5cc9710e28e7a4f146eae8a35e8ef3e7..40958aba04bfce44f4618700bc88a9af75dd401a 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 270fd08fcfa8e0cae073262655965ae1646a35b1..979ff1e1283fa7de1c127fc90708c1e3272a8006 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) {