Mercurial > pidgin.yaz
changeset 6486:fab81e4b885c
[gaim-migrate @ 7000]
Added support for plugin dependencis.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 18 Aug 2003 01:37:17 +0000 |
parents | 70d5122bc3ff |
children | af83c7b6af00 |
files | ChangeLog plugins/signals-test.c src/plugin.c src/plugin.h |
diffstat | 4 files changed, 73 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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
--- 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; }
--- 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. */