Mercurial > audlegacy
diff src/audacious/pluginenum.c @ 3227:2619f4c62abe trunk
added Discovery plugin type
author | Cristi Magherusan <majeru@atheme-project.org> |
---|---|
date | Fri, 03 Aug 2007 07:20:58 +0300 |
parents | 8775dfc57ead |
children | 2453bf125b4f |
line wrap: on
line diff
--- a/src/audacious/pluginenum.c Thu Aug 02 17:42:38 2007 +0200 +++ b/src/audacious/pluginenum.c Fri Aug 03 07:20:58 2007 +0300 @@ -50,7 +50,7 @@ #include "input.h" #include "output.h" #include "visualization.h" - +#include "discovery.h" const gchar *plugin_dir_list[] = { PLUGINSUBS, NULL @@ -58,7 +58,6 @@ GHashTable *plugin_matrix = NULL; GList *lowlevel_list = NULL; - extern GList *vfs_transports; static gint @@ -111,6 +110,16 @@ return 0; } +static gint +discoverylist_compare_func(gconstpointer a, gconstpointer b) +{ + const DiscoveryPlugin *ap = a, *bp = b; + if(ap->description && bp->description) + return strcasecmp(ap->description, bp->description); + else + return 0; +} + static gboolean plugin_is_duplicate(const gchar * filename) { @@ -140,7 +149,11 @@ return TRUE; for (l = lowlevel_list; l; l = g_list_next(l)) - if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) + if (!strcmp(basename, g_basename(LOWLEVEL_PLUGIN(l->data)->filename))) + return TRUE; + + for (l = dp_data.discovery_list; l; l = g_list_next(l)) + if (!strcmp(basename, g_basename(DISCOVERY_PLUGIN(l->data)->filename))) return TRUE; return FALSE; @@ -200,6 +213,13 @@ vp_data.vis_list = g_list_append(vp_data.vis_list, p); } +static void +discovery_plugin_init(Plugin * plugin) +{ + DiscoveryPlugin *p = DISCOVERY_PLUGIN(plugin); + dp_data.discovery_list = g_list_append(dp_data.discovery_list, p); +} + /*******************************************************************/ static void @@ -224,6 +244,8 @@ EffectPlugin **ep_iter; GeneralPlugin **gp_iter; VisPlugin **vp_iter; + DiscoveryPlugin **dp_iter; + if (header->magic != PLUGIN_MAGIC) return plugin2_dispose(module, "plugin <%s> discarded, invalid module magic", filename); @@ -290,6 +312,17 @@ vis_plugin_init(PLUGIN(*vp_iter)); } } + + if (header->dp_list) + { + for (dp_iter = header->dp_list; *dp_iter != NULL; dp_iter++) + { + PLUGIN(*dp_iter)->filename = g_strdup(filename); + g_print("plugin2 '%s' provides DiscoveryPlugin <%p>\n", filename, *dp_iter); + discovery_plugin_init(PLUGIN(*dp_iter)); + } + } + } void @@ -374,6 +407,7 @@ OutputPlugin *op; InputPlugin *ip; LowlevelPlugin *lp; + DiscoveryPlugin *dp; gint dirsel = 0, i = 0; if (!g_module_supported()) { @@ -387,7 +421,8 @@ #ifndef DISABLE_USER_PLUGIN_DIR scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); /* - * This is in a separate loop so if the user puts them in the + * This is in a separate lo + * DiscoveryPlugin *dpop so if the user puts them in the * wrong dir we'll still get them in the right order (home dir * first) - Zinx */ @@ -423,9 +458,14 @@ vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); vp_data.enabled_list = NULL; + dp_data.discovery_list = g_list_sort(dp_data.discovery_list, discoverylist_compare_func); + dp_data.enabled_list = NULL; + + general_enable_from_stringified_list(cfg.enabled_gplugins); vis_enable_from_stringified_list(cfg.enabled_vplugins); effect_enable_from_stringified_list(cfg.enabled_eplugins); + discovery_enable_from_stringified_list(cfg.enabled_dplugins); g_free(cfg.enabled_gplugins); cfg.enabled_gplugins = NULL; @@ -436,6 +476,10 @@ g_free(cfg.enabled_eplugins); cfg.enabled_eplugins = NULL; + g_free(cfg.enabled_dplugins); + cfg.enabled_dplugins = NULL; + + for (node = op_data.output_list; node; node = g_list_next(node)) { op = OUTPUT_PLUGIN(node->data); /* @@ -455,6 +499,13 @@ ip->init(); } + for (node = dp_data.discovery_list; node; node = g_list_next(node)) { + dp = DISCOVERY_PLUGIN(node->data); + if (dp->init) + dp->init(); + } + + for (node = lowlevel_list; node; node = g_list_next(node)) { lp = LOWLEVEL_PLUGIN(node->data); if (lp->init) @@ -485,6 +536,7 @@ GeneralPlugin *gp; VisPlugin *vp; LowlevelPlugin *lp; + DiscoveryPlugin *dp; GList *node; g_message("Shutting down plugin system"); @@ -593,6 +645,28 @@ vp_data.vis_list = NULL; } + + for (node = get_discovery_list(); node; node = g_list_next(node)) { + dp = DISCOVERY_PLUGIN(node->data); + if (dp && dp->cleanup) { + dp->cleanup(); + GDK_THREADS_LEAVE(); + while (g_main_context_iteration(NULL, FALSE)); + GDK_THREADS_ENTER(); + } + + if (dp->handle) + g_module_close(dp->handle); + } + + if (dp_data.discovery_list != NULL) + { + g_list_free(dp_data.discovery_list); + dp_data.discovery_list = NULL; + } + + + for (node = lowlevel_list; node; node = g_list_next(node)) { lp = LOWLEVEL_PLUGIN(node->data); if (lp && lp->cleanup) {