From 5752178267629c2e6b706b8b2fe564a842537888 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Thu, 10 Jun 2010 19:48:12 +0300 Subject: [PATCH] connection(-manager): PurpleAccountUserSplits should be optional parameters Not all users will have to fill the additional fields, e.g. for SIPE your username (= account) can also be used for authentication. Make the fields optional and use the default contents provided by Purple if the user leaves them empty. --- src/connection-manager.c | 2 +- src/connection.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/connection-manager.c b/src/connection-manager.c index c1b3dd6..c126d3d 100644 --- a/src/connection-manager.c +++ b/src/connection-manager.c @@ -202,7 +202,7 @@ _translate_protocol_usersplits (HazeProtocolInfo *hpi, NULL, /* name */ DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, - TP_CONN_MGR_PARAM_FLAG_REQUIRED, + 0, NULL, 0, NULL, NULL, NULL, /* setter_data */ NULL diff --git a/src/connection.c b/src/connection.c index 9753ae4..93f8eba 100644 --- a/src/connection.c +++ b/src/connection.c @@ -269,13 +269,20 @@ _haze_connection_get_username (GHashTable *params, gchar *param_name = g_strdup_printf ("usersplit%d", i); GValue *value = g_hash_table_lookup (params, param_name); - /* tp-glib should guarantee that this is present and a string. */ - g_assert (value != NULL); - g_assert (G_VALUE_TYPE (value) == G_TYPE_STRING); - g_string_append_c (string, purple_account_user_split_get_separator (split)); - g_string_append (string, g_value_get_string (value)); + + if (value != NULL) + { + /* tp-glib should guarantee that this is a string. */ + g_assert (G_VALUE_TYPE (value) == G_TYPE_STRING); + g_string_append (string, g_value_get_string (value)); + } + else + { + g_string_append (string, + purple_account_user_split_get_default_value(split)); + } g_hash_table_remove (params, param_name); g_free (param_name); -- 1.7.0.1