2012-11-30 [mones] 3.9.0cvs33
authorRicardo Mones <mones@claws-mail.org>
Fri, 30 Nov 2012 18:57:21 +0000 (18:57 +0000)
committerRicardo Mones <mones@claws-mail.org>
Fri, 30 Nov 2012 18:57:21 +0000 (18:57 +0000)
* src/common/plugin.c
Fixes #1137 completely, saving path-less plugins as is
in config. With this patch user can edit plugin list on
clawsrc and remove absolute paths from shared plugins,
leaving only the "pluginname.so". Those will be tried to
load from plugin dir of the loading core. Notice that
those will also fail to load on older versions, and will
probably be removed from your config without warning by
the older version.

ChangeLog
PATCHSETS
configure.ac
src/common/plugin.c

index bcbe4cb85c2e794aabaa91c8019ab08e285a01e9..cf24f2f5a5fd4f38ab6d06adc2185ee1b35a1a0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-11-30 [mones]     3.9.0cvs33
+
+       * src/common/plugin.c
+               Fixes #1137 completely, saving path-less plugins as is
+               in config. With this patch user can edit plugin list on
+               clawsrc and remove absolute paths from shared plugins,
+               leaving only the "pluginname.so". Those will be tried to
+               load from plugin dir of the loading core. Notice that
+               those will also fail to load on older versions, and will
+               probably be removed from your config without warning by
+               the older version.
+
 2012-11-30 [wwp]       3.9.0cvs32
 
        * src/mainwindow.c
index 68f70eeb0d0daaff52396e8bb510f964ceb4998d..a78b28cd64f8287f6700e477f6e3a28d15f2deeb 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.274.2.359 -r 1.274.2.360 src/mainwindow.c;  ) > 3.9.0cvs30.patchset
 ( cvs diff -u -r 1.274.2.360 -r 1.274.2.361 src/mainwindow.c;  cvs diff -u -r 1.39.2.66 -r 1.39.2.67 src/mainwindow.h;  cvs diff -u -r 1.150.2.132 -r 1.150.2.133 src/procmsg.c;  cvs diff -u -r 1.17.2.66 -r 1.17.2.67 src/send_message.c;  cvs diff -u -r 1.1.4.13 -r 1.1.4.14 src/send_message.h;  cvs diff -u -r 1.43.2.133 -r 1.43.2.134 src/toolbar.c;  cvs diff -u -r 1.19.2.35 -r 1.19.2.36 src/toolbar.h;  ) > 3.9.0cvs31.patchset
 ( cvs diff -u -r 1.274.2.361 -r 1.274.2.362 src/mainwindow.c;  cvs diff -u -r 1.39.2.67 -r 1.39.2.68 src/mainwindow.h;  cvs diff -u -r 1.395.2.459 -r 1.395.2.460 src/summaryview.c;  cvs diff -u -r 1.43.2.134 -r 1.43.2.135 src/toolbar.c;  ) > 3.9.0cvs32.patchset
+( cvs diff -u -r 1.13.2.47 -r 1.13.2.48 src/common/plugin.c;  ) > 3.9.0cvs33.patchset
index 484f7abf27bcc4e9e0b0f44bb748c26ee33ec656..76d3d910c910b45621381a21e8aece57bdf1fc3a 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=32
+EXTRA_VERSION=33
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 9d59de1a6abe9bf3a91b7e3daae116885b8a7eff..83db8e3382032e89bc9697bafc0259f2275e6fc7 100644 (file)
@@ -58,6 +58,7 @@ struct _Plugin
        GSList *rdeps;
        gchar *error;
        gboolean unloaded_hidden;
+       gboolean in_prefix_dir;
 };
 
 const gchar *plugin_feature_names[] =
@@ -119,6 +120,21 @@ static gint list_find_by_plugin_filename(const Plugin *plugin, const gchar *file
        return strcmp(filename, plugin->filename);
 }
 
+static gboolean plugin_filename_is_standard_dir(const gchar *filename) {
+       return strncmp(filename, get_plugin_dir(), strlen(get_plugin_dir())) == 0;
+}
+
+static gchar * plugin_canonical_name(const Plugin *plugin)
+{
+       if (plugin->in_prefix_dir == TRUE) {
+               if (plugin_filename_is_standard_dir(plugin->filename) == TRUE) {
+                       gchar *plugin_name = g_path_get_basename(plugin->filename);
+                       return plugin_name;
+               }
+       }
+       return g_strdup(plugin->filename);
+}
+
 void plugin_save_list(void)
 {
        gchar *rcpath, *block;
@@ -147,9 +163,13 @@ void plugin_save_list(void)
                        if (plugin->unloaded_hidden)
                                continue;
 
-                       if (!strcmp(plugin->type(), type_cur->data))
-                               if (fprintf(pfile->fp, "%s\n", plugin->filename) < 0)
+                       if (!strcmp(plugin->type(), type_cur->data)) {
+                               gchar * name = plugin_canonical_name(plugin);
+                               int err = fprintf(pfile->fp, "%s\n", name);
+                               g_free(name);
+                               if (err < 0)
                                        goto revert;
+                       }
                }
                for (plugin_cur = unloaded_plugins; plugin_cur != NULL; plugin_cur = g_slist_next(plugin_cur)) {
                        plugin = (Plugin *) plugin_cur->data;
@@ -157,9 +177,13 @@ void plugin_save_list(void)
                        if (plugin->unloaded_hidden)
                                continue;
                        
-                       if (!strcmp(plugin->type(), type_cur->data))
-                               if (fprintf(pfile->fp, "%s\n", plugin->filename) < 0)
+                       if (!strcmp(plugin->type(), type_cur->data)) {
+                               gchar * name = plugin_canonical_name(plugin);
+                               int err = fprintf(pfile->fp, "%s\n", name);
+                               g_free(name);
+                               if (err < 0)
                                        goto revert;
+                       }
                }
                if (fprintf(pfile->fp, "\n") < 0)
                        goto revert;
@@ -241,6 +265,7 @@ static gint plugin_load_deps(const gchar *filename, gchar **error)
                                fclose(fp);
                                return -1;
                        }
+                       dep_plugin->in_prefix_dir = TRUE;
                }
                g_free(path);
                if (!g_slist_find_custom(dep_plugin->rdeps, 
@@ -351,10 +376,6 @@ static gboolean plugin_licence_check(const gchar *licence) {
        return FALSE;
 }
 
-static gboolean plugin_filename_is_standard_dir(const gchar *filename) {
-       return strncmp(filename, get_plugin_dir(), strlen(get_plugin_dir())) == 0;
-}
-
 static Plugin *plugin_load_in_default_dir(const gchar *filename, gchar **error)
 {
        Plugin *plugin = NULL;
@@ -376,6 +397,8 @@ static Plugin *plugin_load_in_default_dir(const gchar *filename, gchar **error)
        if (plugin) {
                g_free(*error);
                *error = NULL;
+               plugin->in_prefix_dir = TRUE;
+
        } else {
                g_free(default_error);
        }
@@ -434,7 +457,9 @@ Plugin *plugin_load(const gchar *filename, gchar **error)
                        return plugin_load_in_default_dir(filename, error);
                else
                        return NULL;
-       }
+       } else {
+               plugin->in_prefix_dir = FALSE;
+        }
 
 init_plugin:
        if (!g_module_symbol(plugin->module, "plugin_name", &plugin_name) ||