[Commits] plugin.c 1.13.2.46 1.13.2.47

colin at claws-mail.org colin at claws-mail.org
Wed Nov 14 11:16:13 CET 2012


Update of /home/claws-mail/claws/src/common
In directory srv:/tmp/cvs-serv12886/src/common

Modified Files:
      Tag: gtk2
	plugin.c 
Log Message:
2012-11-14 [colin]	3.8.1cvs119

	* src/common/plugin.c
		If plugin fails to load from absolute path, try from
		default plugin path. 
		Fixes bug #1137, 'loading plugins with same profile on different archs'
		Fixes bug #2777, 'Installing latest cvs116 package 14 Windows version
		results in wrong paths in clawsrc'

Index: plugin.c
===================================================================
RCS file: /home/claws-mail/claws/src/common/plugin.c,v
retrieving revision 1.13.2.46
retrieving revision 1.13.2.47
diff -u -d -r1.13.2.46 -r1.13.2.47
--- plugin.c	7 Jul 2012 07:09:31 -0000	1.13.2.46
+++ plugin.c	14 Nov 2012 10:16:11 -0000	1.13.2.47
@@ -351,6 +351,38 @@
 	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;
+	gchar *filename_default_dir = NULL;
+	gchar *default_error = NULL;
+	gchar *plugin_name = g_path_get_basename(filename);
+
+	filename_default_dir = g_strconcat(get_plugin_dir(), plugin_name, NULL);
+
+	debug_print("trying to load %s in default plugin directory %s\n",
+		    plugin_name, get_plugin_dir());
+
+	g_free(plugin_name);
+
+	plugin = plugin_load(filename_default_dir, &default_error);
+	
+	g_free(filename_default_dir);
+	
+	if (plugin) {
+		g_free(*error);
+		*error = NULL;
+	} else {
+		g_free(default_error);
+	}
+
+	return plugin;
+}
+
 /**
  * Loads a plugin
  *
@@ -398,7 +430,10 @@
 	if (plugin->module == NULL) {
 		*error = g_strdup(g_module_error());
 		g_free(plugin);
-		return NULL;
+		if (!plugin_filename_is_standard_dir(filename))
+			return plugin_load_in_default_dir(filename, error);
+		else
+			return NULL;
 	}
 
 init_plugin:



More information about the Commits mailing list