diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-09-27 16:53:49 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-09-28 11:32:20 +0100 |
commit | 855af5f3bb9f70aaa59768dbeaf50edf68198675 (patch) | |
tree | 96fe67aa8c4dce50726e96d7eda9d1f733e4f531 | |
parent | 68d883e4d7488bd2c692c8bc85e5b8f77950ba01 (diff) |
Account: when reconnecting, use RequestedPresence if possible
Previously, if an account was taken offline due to the internet
connection disappearing, when it was brought back up the
AutomaticPresence would be used, trampling on whatever the user had put
into RequestedPresence.
I guess this was deliberate … but it doesn't seem like very useful
behaviour. If I've explicitly set my presence to ('available', 'you can
talk to me now'), despite my AutomaticPresence being ('busy', 'probably
doing something else'), I don't see why a network connection blip should
cause my lovingly-written presence to be discarded.
-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. |