diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2010-07-10 01:46:50 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2010-07-10 01:46:50 +0100 |
commit | 2f95a521d64460a6d81e1d764f040961fb52b027 (patch) | |
tree | 3b88d0f6608c48e48eb616a55e28de22e0fc3d3d | |
parent | bdfeaa99b30b1e0ed89fe222edf4f0fbacb21494 (diff) |
Pull conn parameters out of the dict using tp_asv_*
This makes the function smaller and more tolerant to minor type
variations. Perhaps such a minor type variation is coming up...
-rw-r--r-- | src/connection.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/src/connection.c b/src/connection.c index 93bbaec..7bcb2a2 100644 --- a/src/connection.c +++ b/src/connection.c @@ -312,35 +312,30 @@ set_option ( const PurpleAccountOption *option, GHashTable *params) { - GValue *value = g_hash_table_lookup (params, option->pref_name); + if (g_hash_table_lookup (params, option->pref_name) == NULL) + return; - if (!value) - return; - - switch (option->type) + switch (option->type) { - case PURPLE_PREF_BOOLEAN: - g_assert (G_VALUE_TYPE (value) == G_TYPE_BOOLEAN); - purple_account_set_bool (account, option->pref_name, - g_value_get_boolean (value)); - break; - case PURPLE_PREF_INT: - g_assert (G_VALUE_TYPE (value) == G_TYPE_INT); - purple_account_set_int (account, option->pref_name, - g_value_get_int (value)); - break; - case PURPLE_PREF_STRING: - case PURPLE_PREF_STRING_LIST: - g_assert (G_VALUE_TYPE (value) == G_TYPE_STRING); - purple_account_set_string (account, option->pref_name, - g_value_get_string (value)); - break; - default: - g_warning ("option '%s' has unhandled type %u", - option->pref_name, option->type); + case PURPLE_PREF_BOOLEAN: + purple_account_set_bool (account, option->pref_name, + tp_asv_get_boolean (params, option->pref_name, NULL)); + break; + case PURPLE_PREF_INT: + purple_account_set_int (account, option->pref_name, + tp_asv_get_int32 (params, option->pref_name, NULL)); + break; + case PURPLE_PREF_STRING: + case PURPLE_PREF_STRING_LIST: + purple_account_set_string (account, option->pref_name, + tp_asv_get_string (params, option->pref_name)); + break; + default: + g_warning ("option '%s' has unhandled type %u", + option->pref_name, option->type); } - g_hash_table_remove (params, option->pref_name); + g_hash_table_remove (params, option->pref_name); } /** |