diff src/plugin.c @ 7033:cf1126ba1834

[gaim-migrate @ 7596] Multiple copies of gaim installed at different locations no longer attempt to load the same, possibly incompatible plugins. It does this by saving the base filenames of the plugins, rather than the full names, and attempts to load them at the particular copy's plugin directory. Now a released gaim in the system default prefix and a development gaim in a home directory will no longer try to load each other's plugins. They'll each load their own versions of each. Thanks to Robot101 for the patch. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 29 Sep 2003 22:46:15 +0000
parents 083d1e4a9c78
children 6d5dc6a65c47
line wrap: on
line diff
--- a/src/plugin.c	Mon Sep 29 22:34:32 2003 +0000
+++ b/src/plugin.c	Mon Sep 29 22:46:15 2003 +0000
@@ -765,8 +765,28 @@
 
 	files = gaim_prefs_get_string_list(key);
 
-	for (f = files; f; f = f->next) {
-		gaim_plugin_load(gaim_plugin_probe(f->data));
+	for (f = files; f; f = f->next)
+	{
+		char *filename = g_path_get_basename(f->data);
+		GaimPlugin *plugin = NULL;
+
+		if (filename != NULL)
+		{
+			if ((plugin = gaim_plugins_find_with_basename(filename)) != NULL)
+			{
+				gaim_debug_info("plugins", "Loading saved plugin %s\n",
+								filename);
+				gaim_plugin_load(plugin);
+			}
+			else
+			{
+				gaim_debug_error("plugins", "Unable to find saved plugin %s\n",
+								 filename);
+			}
+
+			g_free(filename);
+		}
+
 		g_free(f->data);
 	}
 
@@ -989,6 +1009,33 @@
 }
 
 GaimPlugin *
+gaim_plugins_find_with_basename(const char *basename)
+{
+	GaimPlugin *plugin;
+	GList *l;
+
+	g_return_val_if_fail(basename != NULL, NULL);
+
+	for (l = plugins; l != NULL; l = l->next)
+	{
+		char *tmp;
+
+		plugin = (GaimPlugin *)l->data;
+
+		if (plugin->path != NULL &&
+			(tmp = g_strrstr(plugin->path, basename)) != NULL)
+		{
+			tmp += strlen(basename);
+
+			if (*tmp == '\0')
+				return plugin;
+		}
+	}
+
+	return NULL;
+}
+
+GaimPlugin *
 gaim_plugins_find_with_id(const char *id)
 {
 	GaimPlugin *plugin;