commit fa93b1c280c712db87a14061732940891cc7c5aa
parent f1c08b4f36d9ed5fa62672f1d0e060fb59c282b4
Author: Ricardo Mones <mones@claws-mail.org>
Date: Fri, 30 Nov 2012 18:57:21 +0000
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.
Diffstat:
4 files changed, 48 insertions(+), 10 deletions(-)
diff --git 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
diff --git a/PATCHSETS b/PATCHSETS
@@ -4530,3 +4530,4 @@
( 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
diff --git a/configure.ac b/configure.ac
@@ -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=
diff --git a/src/common/plugin.c b/src/common/plugin.c
@@ -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) ||