diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-09-27 17:16:31 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-09-28 11:32:20 +0100 |
commit | 928fbad1c14cde84758b45dd392eb1e20c150fa0 (patch) | |
tree | 2815675c0d0354d7f94ad12b26c1cbb25c6f3cb7 | |
parent | ca9833b3d208fa4f4f3af333ebca54178c5c62da (diff) |
Account: reconnect if RequestedPresence is not offline
Previously, when a network connection came back up, only accounts with
ConnectAutomatically set would be re-connected. But if RequestedPresence
is something online-flavoured, I think it makes sense to bring such
accounts back online, too: if the user has asked to be online, a network
blip shouldn't affect that.
-rw-r--r-- | src/mcd-account.c | 8 | ||||
-rw-r--r-- | tests/twisted/account-manager/connectivity.py | 16 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/mcd-account.c b/src/mcd-account.c index 53b70156..d43a69a3 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -3417,9 +3417,13 @@ mcd_account_would_like_to_connect (McdAccount *account) return FALSE; } - if (!priv->connect_automatically) + if (!priv->connect_automatically && + !_presence_type_is_online (priv->req_presence_type)) { - DEBUG ("%s does not ConnectAutomatically", priv->unique_name); + DEBUG ("%s does not ConnectAutomatically, and its RequestedPresence " + "(%u, '%s', '%s') doesn't indicate the user wants to be online", + priv->unique_name, priv->req_presence_type, + priv->req_presence_status, priv->req_presence_message); return FALSE; } diff --git a/tests/twisted/account-manager/connectivity.py b/tests/twisted/account-manager/connectivity.py index 0749061c..0f1c3407 100644 --- a/tests/twisted/account-manager/connectivity.py +++ b/tests/twisted/account-manager/connectivity.py @@ -73,6 +73,12 @@ def test(q, bus, mc): call_async(q, account.Properties, 'Set', cs.ACCOUNT, 'ConnectAutomatically', True) q.expect('dbus-return', method='Set') + # (but actually let's turn ConnectAutomatically off: we want to check that + # MC continues to try to apply RequestedPresence if the network connection + # goes away and comes back again, regardless of this setting) + call_async(q, account.Properties, 'Set', cs.ACCOUNT, 'ConnectAutomatically', + False) + q.expect('dbus-return', method='Set') sync_dbus(bus, q, mc) q.unforbid_events(request_connection_event) @@ -118,5 +124,15 @@ def test(q, bus, mc): q.expect('dbus-method-call', method='Disconnect') + # So now the user gives up and sets their RequestedPresence to offline. + # Because this account does not ConnectAutomatically, if the network + # connection comes back up the account should not be brought back online. + q.forbid_events(request_connection_event) + account.Properties.Set(cs.ACCOUNT, 'RequestedPresence', + (dbus.UInt32(cs.PRESENCE_TYPE_OFFLINE), 'offline', '')) + mc.connectivity.go_online() + # Make sure MC has noticed that the network connection has come back. + sync_connectivity_state(mc) + if __name__ == '__main__': exec_test(test, initially_online=False) |