summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-05-16 12:49:57 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2008-05-16 12:49:57 +0000
commit86ca72eb302bc00c6c58b56d20ba06f1d7000214 (patch)
tree701c46e649900612db60097aaac74acdcbc50447
parent3642221a7953346bb326b5aa23075e96e4cf5e0b (diff)
Use g_key_file_get_string_list instead of g_key_file_get_string
-rw-r--r--audio/manager.c78
-rw-r--r--network/main.c19
2 files changed, 47 insertions, 50 deletions
diff --git a/audio/manager.c b/audio/manager.c
index 33a0d501..bf2b89ea 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -1460,53 +1460,47 @@ static void server_exit(void)
int audio_manager_init(DBusConnection *conn, GKeyFile *config)
{
- char *str;
- GError *err = NULL;
+ char **list;
+ int i;
connection = dbus_connection_ref(conn);
- if (config) {
- str = g_key_file_get_string(config, "General", "Enable", &err);
-
- if (err) {
- debug("audio.conf: %s", err->message);
- g_error_free(err);
- err = NULL;
- } else {
- if (strstr(str, "Headset"))
- enabled.headset = TRUE;
- if (strstr(str, "Gateway"))
- enabled.gateway = TRUE;
- if (strstr(str, "Sink"))
- enabled.sink = TRUE;
- if (strstr(str, "Source"))
- enabled.source = TRUE;
- if (strstr(str, "Control"))
- enabled.control = TRUE;
- g_free(str);
- }
-
- str = g_key_file_get_string(config, "General", "Disable", &err);
-
- if (err) {
- debug("audio.conf: %s", err->message);
- g_error_free(err);
- err = NULL;
- } else {
- if (strstr(str, "Headset"))
- enabled.headset = FALSE;
- if (strstr(str, "Gateway"))
- enabled.gateway = FALSE;
- if (strstr(str, "Sink"))
- enabled.sink = FALSE;
- if (strstr(str, "Source"))
- enabled.source = FALSE;
- if (strstr(str, "Control"))
- enabled.control = FALSE;
- g_free(str);
- }
+ if (!config)
+ goto proceed;
+
+ list = g_key_file_get_string_list(config, "General", "Enable",
+ NULL, NULL);
+ for (i = 0; list && list[i] != NULL; i++) {
+ if (g_str_equal(list[i], "Headset"))
+ enabled.headset = TRUE;
+ else if (g_str_equal(list[i], "Gateway"))
+ enabled.gateway = TRUE;
+ else if (g_str_equal(list[i], "Sink"))
+ enabled.sink = TRUE;
+ else if (g_str_equal(list[i], "Source"))
+ enabled.source = TRUE;
+ else if (g_str_equal(list[i], "Control"))
+ enabled.control = TRUE;
+ }
+ g_strfreev(list);
+
+ list = g_key_file_get_string_list(config, "General", "Disable",
+ NULL, NULL);
+ for (i = 0; list && list[i] != NULL; i++) {
+ if (g_str_equal(list[i], "Headset"))
+ enabled.headset = FALSE;
+ else if (g_str_equal(list[i], "Gateway"))
+ enabled.gateway = FALSE;
+ else if (g_str_equal(list[i], "Sink"))
+ enabled.sink = FALSE;
+ else if (g_str_equal(list[i], "Source"))
+ enabled.source = FALSE;
+ else if (g_str_equal(list[i], "Control"))
+ enabled.control = FALSE;
}
+ g_strfreev(list);
+proceed:
if (!dbus_connection_create_object_path(conn, AUDIO_MANAGER_PATH,
NULL, manager_unregister)) {
error("D-Bus failed to register %s path", AUDIO_MANAGER_PATH);
diff --git a/network/main.c b/network/main.c
index f710080f..02c3fcc8 100644
--- a/network/main.c
+++ b/network/main.c
@@ -68,7 +68,7 @@ static void read_config(const char *file)
{
GKeyFile *keyfile;
GError *err = NULL;
- char *disabled;
+ char **disabled;
keyfile = g_key_file_new();
@@ -78,19 +78,22 @@ static void read_config(const char *file)
goto done;
}
- disabled = g_key_file_get_string(keyfile, "General",
- "Disable", &err);
+ disabled = g_key_file_get_string_list(keyfile, "General",
+ "Disable", NULL, &err);
if (err) {
debug("%s: %s", file, err->message);
g_error_free(err);
err = NULL;
} else {
- if (strstr(disabled, "Connection"))
- conf.connection_enabled = FALSE;
- if (strstr(disabled, "Server"))
- conf.server_enabled = FALSE;
+ int i;
+ for (i = 0; disabled[i] != NULL; i++) {
+ if (g_str_equal(disabled[i], "Connection"))
+ conf.connection_enabled = FALSE;
+ else if (g_str_equal(disabled[i], "Server"))
+ conf.server_enabled = FALSE;
+ }
+ g_strfreev(disabled);
}
- g_free(disabled);
conf.security = !g_key_file_get_boolean(keyfile, "General",
"DisableSecurity", &err);