diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2008-05-16 10:19:23 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2008-05-16 10:19:23 +0000 |
commit | 7c67f70b684870920af46c1561eedc475c4ad31f (patch) | |
tree | 23c02801402cebdfb875c4570614ee0a96d748a0 /hcid/plugin.c | |
parent | 4de66ff306262950a6da54399cef89a9134247f0 (diff) |
Implement support for disabling specific plugins from loading
Diffstat (limited to 'hcid/plugin.c')
-rw-r--r-- | hcid/plugin.c | 36 |
1 files changed, 35 insertions, 1 deletions
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; } |