[Commits] plugin.c 1.13.2.47 1.13.2.48

mones at claws-mail.org mones at claws-mail.org
Fri Nov 30 19:57:23 CET 2012


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

Modified Files:
      Tag: gtk2
	plugin.c 
Log Message:
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. 

Index: plugin.c
===================================================================
RCS file: /home/claws-mail/claws/src/common/plugin.c,v
retrieving revision 1.13.2.47
retrieving revision 1.13.2.48
diff -u -d -r1.13.2.47 -r1.13.2.48
--- plugin.c	14 Nov 2012 10:16:11 -0000	1.13.2.47
+++ plugin.c	30 Nov 2012 18:57:21 -0000	1.13.2.48
@@ -58,6 +58,7 @@
 	GSList *rdeps;
 	gchar *error;
 	gboolean unloaded_hidden;
+	gboolean in_prefix_dir;
 };
 
 const gchar *plugin_feature_names[] =
@@ -119,6 +120,21 @@
 	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 @@
 			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 @@
 			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 @@
 				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 @@
 	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 @@
 	if (plugin) {
 		g_free(*error);
 		*error = NULL;
+		plugin->in_prefix_dir = TRUE;
+
 	} else {
 		g_free(default_error);
 	}
@@ -434,7 +457,9 @@
 			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) ||



More information about the Commits mailing list