summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-16 18:37:09 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-16 18:37:09 +0100
commitcd6059e686d95fb1d8d9f080abedce6ab95a9c82 (patch)
tree9b18e6f704a1ede798516ef54c98049ef26753c3 /src
parent6ff9e1a08d0a3c24e68cb1b65289eb95e7060359 (diff)
room-config: simplify password protection validation
Yeah okay I might have been calling tp_asv_get_* a little too many times... Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/room-config.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/room-config.c b/src/room-config.c
index 27f0c9b..ceeeddc 100644
--- a/src/room-config.c
+++ b/src/room-config.c
@@ -181,12 +181,16 @@ idle_room_config_update_configuration_async (
GSimpleAsyncResult *result = g_simple_async_result_new ((GObject *) self,
callback, user_data, idle_room_config_update_configuration_async);
gboolean present = FALSE;
+ gboolean password_protected = FALSE;
+ const gchar *password = NULL;
+
+ password_protected = tp_asv_get_boolean (validated_properties,
+ GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD_PROTECTED), &present);
+ password = tp_asv_get_string (validated_properties,
+ GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD));
/* first, do sanity checking for Password & PasswordProtected */
- if (tp_asv_get_boolean (validated_properties,
- GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD_PROTECTED), NULL)
- && tp_str_empty (tp_asv_get_string (validated_properties,
- GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD))))
+ if (password_protected && tp_str_empty (password))
{
g_simple_async_result_set_error (result, TP_ERROR,
TP_ERROR_INVALID_ARGUMENT,
@@ -204,11 +208,7 @@ idle_room_config_update_configuration_async (
* http://i.imgur.com/FIOwY.jpg
*/
- if (!tp_asv_get_boolean (validated_properties,
- GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD_PROTECTED), &present)
- && present
- && tp_asv_get_string (validated_properties,
- GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD)) != NULL)
+ if (!password_protected && present && password != NULL)
{
g_simple_async_result_set_error (result, TP_ERROR,
TP_ERROR_INVALID_ARGUMENT,
@@ -257,11 +257,8 @@ idle_room_config_update_configuration_async (
}
/* set a new password */
- if (g_hash_table_lookup (validated_properties,
- GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD)) != NULL)
+ if (password != NULL)
{
- const gchar *password = tp_asv_get_string (validated_properties,
- GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD));
gchar *cmd;
/* we've already validated this; either PasswordProtected was
@@ -279,9 +276,7 @@ idle_room_config_update_configuration_async (
}
/* unset a password */
- if (!tp_asv_get_boolean (validated_properties,
- GUINT_TO_POINTER (TP_BASE_ROOM_CONFIG_PASSWORD_PROTECTED), &present)
- && present)
+ if (!password_protected && present)
{
gchar *cmd;