diff options
-rw-r--r-- | src/mcd-account.c | 19 | ||||
-rw-r--r-- | tests/twisted/account-manager/connectivity.py | 10 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/mcd-account.c b/src/mcd-account.c index e6672bea..53b70156 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -4015,8 +4015,12 @@ mcd_account_check_validity (McdAccount *account, /* * _mcd_account_connect_with_auto_presence: * @account: the #McdAccount. + * @user_initiated: %TRUE if the connection attempt is in response to a user + * request (like a request for a channel) + * + * Request the account to go back online with the current RequestedPresence, if + * it is not Offline, or with the configured AutomaticPresence otherwise. * - * Request the account to go online with the configured AutomaticPresence. * This is appropriate in these situations: * - going online automatically because we've gained connectivity * - going online automatically in order to request a channel @@ -4027,11 +4031,14 @@ _mcd_account_connect_with_auto_presence (McdAccount *account, { McdAccountPrivate *priv = account->priv; - mcd_account_request_presence_int (account, - priv->auto_presence_type, - priv->auto_presence_status, - priv->auto_presence_message, - user_initiated); + if (_presence_type_is_online (priv->req_presence_type)) + mcd_account_rerequest_presence (account, user_initiated); + else + mcd_account_request_presence_int (account, + priv->auto_presence_type, + priv->auto_presence_status, + priv->auto_presence_message, + user_initiated); } /* diff --git a/tests/twisted/account-manager/connectivity.py b/tests/twisted/account-manager/connectivity.py index 913e1809..e102a26e 100644 --- a/tests/twisted/account-manager/connectivity.py +++ b/tests/twisted/account-manager/connectivity.py @@ -20,7 +20,7 @@ import dbus import dbus.service from servicetest import ( - EventPattern, call_async, sync_dbus, + EventPattern, call_async, sync_dbus, assertEquals, ) from mctest import ( exec_test, create_fakecm_account, expect_fakecm_connection, @@ -83,6 +83,14 @@ def test(q, bus, mc): mc.connectivity.go_online() e = q.expect('dbus-method-call', method='RequestConnection') + # In the process, our RequestedPresence should not have been trampled on. + # (Historically, MC would replace it with the AutomaticPresence, but that + # behaviour was unexpected: if the user explicitly set a status or message, + # why should the network connection cutting out and coming back up cause + # that to be lost?) + assertEquals(requested_presence, + account.Properties.Get(cs.ACCOUNT, 'RequestedPresence')) + # But if we get disconnected before RequestConnection returns, MC should # clean up the new connection when it does, rather than trying to sign it # in. |