diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-02-09 18:39:48 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-02-09 18:39:48 +0000 |
commit | 1cd35ab86d03cb76152363e33a2b85a1484c44e5 (patch) | |
tree | 799c862a4ac8039f6ce5323508d198e9b59212bd /src | |
parent | 73ffa39f6fa7406c1d225deee2b6876079cf708a (diff) |
detect gconf error using GError instead of NULL strings... (these will always be NULL for new users?)
Diffstat (limited to 'src')
-rw-r--r-- | src/trg-client.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/trg-client.c b/src/trg-client.c index 6b1ac6b..71b365b 100644 --- a/src/trg-client.c +++ b/src/trg-client.c @@ -34,6 +34,8 @@ trg_client *trg_init_client() return client; } +#define check_for_error(error) if (error) { g_error_free(error); return FALSE; } + gboolean trg_client_populate_with_settings(trg_client * tc, GConfClient * gconf) { @@ -51,30 +53,19 @@ gboolean trg_client_populate_with_settings(trg_client * tc, tc->password = NULL; port = gconf_client_get_int(gconf, TRG_GCONF_KEY_PORT, &error); - if (error != NULL) { - g_error_free(error); - return FALSE; - } - - if ((host = - gconf_client_get_string(gconf, TRG_GCONF_KEY_HOSTNAME, - NULL)) == NULL) { - return FALSE; - } else { - tc->url = - g_strdup_printf("http://%s:%d/transmission/rpc", host, port); + check_for_error(error); + + host = gconf_client_get_string(gconf, TRG_GCONF_KEY_HOSTNAME, &error); + check_for_error(error); + + tc->url = g_strdup_printf("http://%s:%d/transmission/rpc", host, port); g_free(host); - } - if ((tc->username = - gconf_client_get_string(gconf, TRG_GCONF_KEY_USERNAME, - NULL)) == NULL) - return FALSE; + tc->username = gconf_client_get_string(gconf, TRG_GCONF_KEY_USERNAME, &error); + check_for_error(error); - if ((tc->password = - gconf_client_get_string(gconf, TRG_GCONF_KEY_PASSWORD, - NULL)) == NULL) - return FALSE; + tc->password = gconf_client_get_string(gconf, TRG_GCONF_KEY_PASSWORD, &error); + check_for_error(error); return TRUE; } |