# HG changeset patch # User Christian Hammond # Date 1061170637 0 # Node ID fab81e4b885c74ff67b027429a8de0b1ef9f873c # Parent 70d5122bc3ff78705e6b9612b0d41b6a5c1bac3b [gaim-migrate @ 7000] Added support for plugin dependencis. committer: Tailor Script diff -r 70d5122bc3ff -r fab81e4b885c ChangeLog --- a/ChangeLog Mon Aug 18 01:03:43 2003 +0000 +++ b/ChangeLog Mon Aug 18 01:37:17 2003 +0000 @@ -3,6 +3,7 @@ version 0.68: * Removed the old event system and replaced it with a much better signal system. + * Added plugin dependency support. version 0.67 (08/14/2003): * Brought back the message notification plugin (Brian Tarricone) diff -r 70d5122bc3ff -r fab81e4b885c plugins/signals-test.c --- a/plugins/signals-test.c Mon Aug 18 01:03:43 2003 +0000 +++ b/plugins/signals-test.c Mon Aug 18 01:37:17 2003 +0000 @@ -211,7 +211,7 @@ "displaying-chat-msg (%s, %s)\n", gaim_conversation_get_name(conv), *buffer); - return FALES; + return FALSE; } static void diff -r 70d5122bc3ff -r fab81e4b885c src/plugin.c --- a/src/plugin.c Mon Aug 18 01:03:43 2003 +0000 +++ b/src/plugin.c Mon Aug 18 01:37:17 2003 +0000 @@ -234,12 +234,79 @@ gaim_plugin_load(GaimPlugin *plugin) { #ifdef GAIM_PLUGINS + GList *dep_list = NULL; + GList *l; + g_return_val_if_fail(plugin != NULL, FALSE); g_return_val_if_fail(plugin->error == NULL, FALSE); if (gaim_plugin_is_loaded(plugin)) return TRUE; + /* + * Go through the list of the plugin's dependencies. + * + * First pass: Make sure all the plugins needed are probed. + */ + for (l = plugin->info->dependencies; l != NULL; l = l->next) + { + const char *dep_name = (const char *)l->data; + GaimPlugin *dep_plugin; + + dep_plugin = gaim_plugins_find_with_id(dep_name); + + if (dep_plugin == NULL) + { + char buf[BUFSIZ]; + + g_snprintf(buf, sizeof(buf), + _("The required plugin %s was not found. " + "Please install this plugin and try again."), + dep_name); + + gaim_notify_error(NULL, NULL, + _("Gaim was unable to load your plugin."), + buf); + + if (dep_list != NULL) + g_list_free(dep_list); + + return FALSE; + } + + dep_list = g_list_append(dep_list, dep_plugin); + } + + /* Second pass: load all the required plugins. */ + for (l = dep_list; l != NULL; l = l->next) + { + GaimPlugin *dep_plugin = (GaimPlugin *)l->data; + + if (!gaim_plugin_is_loaded(dep_plugin)) + { + if (!gaim_plugin_load(dep_plugin)) + { + char buf[BUFSIZ]; + + g_snprintf(buf, sizeof(buf), + _("The required plugin %s was unable to load."), + plugin->info->name); + + gaim_notify_error(NULL, NULL, + _("Gaim was unable to load your plugin."), + buf); + + if (dep_list != NULL) + g_list_free(dep_list); + + return FALSE; + } + } + } + + if (dep_list != NULL) + g_list_free(dep_list); + if (plugin->native_plugin) { if (plugin->info != NULL) { if (plugin->info->load != NULL) @@ -703,10 +770,11 @@ g_return_val_if_fail(id != NULL, NULL); - for (l = plugins; l != NULL; l = l->next) { + for (l = plugins; l != NULL; l = l->next) + { plugin = l->data; - if (!strcmp(plugin->info->id, id)) + if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) return plugin; } diff -r 70d5122bc3ff -r fab81e4b885c src/plugin.h --- a/src/plugin.h Mon Aug 18 01:03:43 2003 +0000 +++ b/src/plugin.h Mon Aug 18 01:37:17 2003 +0000 @@ -47,8 +47,6 @@ #define GAIM_PRIORITY_HIGHEST 9999 #define GAIM_PRIORITY_LOWEST -9999 -#define GAIM_PLUGIN_ID_UNSET { 0, 0, 0, 0 } - /** * Detailed information about a plugin. * @@ -200,7 +198,7 @@ * Reloads a plugin. * * @param plugin The old plugin handle. - * + * * @return @c TRUE if successful, or @c FALSE otherwise. * * @see gaim_plugin_load() @@ -244,7 +242,6 @@ */ void gaim_plugins_unload_all(void); - /** * Destroys all registered plugins. */