From 7c67f70b684870920af46c1561eedc475c4ad31f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 16 May 2008 10:19:23 +0000 Subject: Implement support for disabling specific plugins from loading --- hcid/plugin.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'hcid/plugin.c') diff --git a/hcid/plugin.c b/hcid/plugin.c index f99966bf..acebed61 100644 --- a/hcid/plugin.c +++ b/hcid/plugin.c @@ -64,10 +64,39 @@ static gboolean add_plugin(GModule *module, struct bluetooth_plugin_desc *desc) return TRUE; } -gboolean plugin_init(void) +static gboolean is_disabled(const char *name, char **list) +{ + int i; + + for (i = 0; list[i] != NULL; i++) { + char *str; + gboolean equal; + + str = g_strdup_printf("lib%s.so", list[i]); + + equal = g_str_equal(str, name); + + g_free(str); + + if (equal) + return TRUE; + } + + return FALSE; +} + +gboolean plugin_init(GKeyFile *config) { GDir *dir; const gchar *file; + gchar **disabled; + + if (config) + disabled = g_key_file_get_string_list(config, "General", + "DisablePlugins", + NULL, NULL); + else + disabled = NULL; debug("Loading plugins %s", PLUGINDIR); @@ -85,6 +114,9 @@ gboolean plugin_init(void) g_str_has_suffix(file, ".so") == FALSE) continue; + if (disabled && is_disabled(file, disabled)) + continue; + filename = g_build_filename(PLUGINDIR, file, NULL); if (stat(filename, &st) < 0) { @@ -125,6 +157,8 @@ gboolean plugin_init(void) g_dir_close(dir); + g_strfreev(disabled); + return TRUE; } -- cgit