From 549147aadbabcd86464e9cf924c95d8433f6ef34 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 7 Jun 2010 19:37:39 +0100 Subject: fd.o #28118: clear the 'register' flag when an account goes to CONNECTED --- src/mcd-account.c | 32 ++++++++++++++++++++++ .../account-manager/recover-from-disconnect.py | 8 ++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/mcd-account.c b/src/mcd-account.c index 2d2a5215..4e48b4fd 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -3649,6 +3649,36 @@ on_conn_status_changed (McdConnection *connection, _mcd_account_set_connection_status (account, status, reason); } +/* clear the "register" flag, if necessary */ +static void +clear_register_dup_params_cb (McdAccount *self, + GHashTable *params, + gpointer user_data) +{ + if (tp_asv_get_boolean (params, "register", NULL)) + { + GValue value = { 0 }; + + _mcd_account_set_parameter (self, "register", NULL, NULL, NULL); + + g_hash_table_remove (params, "register"); + + _mcd_account_set_parameter (self, "register", NULL, NULL, NULL); + + g_value_init (&value, TP_HASH_TYPE_STRING_VARIANT_MAP); + g_value_take_boxed (&value, params); + mcd_account_changed_property (self, "Parameters", &value); + g_value_unset (&value); + + mcd_account_manager_write_conf_async (self->priv->account_manager, + NULL, NULL); + } + else + { + g_hash_table_unref (params); + } +} + void _mcd_account_set_connection_status (McdAccount *account, TpConnectionStatus status, @@ -3660,6 +3690,8 @@ _mcd_account_set_connection_status (McdAccount *account, if (status == TP_CONNECTION_STATUS_CONNECTED) { _mcd_account_set_has_been_online (account); + _mcd_account_dup_parameters (account, clear_register_dup_params_cb, + NULL); } if (status != priv->conn_status) diff --git a/test/twisted/account-manager/recover-from-disconnect.py b/test/twisted/account-manager/recover-from-disconnect.py index 3b8cfdaa..f28411e3 100644 --- a/test/twisted/account-manager/recover-from-disconnect.py +++ b/test/twisted/account-manager/recover-from-disconnect.py @@ -32,7 +32,8 @@ def test(q, bus, mc): # Create an account params = dbus.Dictionary({"account": "someguy@example.com", - "password": "secrecy"}, signature='sv') + "password": "secrecy", + "register": True}, signature='sv') (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) @@ -89,8 +90,9 @@ def test(q, bus, mc): conn.StatusChanged(cs.CONN_STATUS_DISCONNECTED, cs.CONN_STATUS_REASON_NETWORK_ERROR) - # MC reconnects - + # MC reconnects. This time, we expect it to have deleted the 'register' + # parameter. + del params['register'] e = q.expect('dbus-method-call', method='RequestConnection', args=['fakeprotocol', params], destination=tp_name_prefix + '.ConnectionManager.fakecm', -- cgit v1.2.1