[telepathy-mission-control/master] mcd_account_request_presence_int: allow same presence to be re-requested

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Jun 5 05:43:57 PDT 2009


Also, only emit AccountPropertyChanged for RequestedPresence if it
actually changed, and add a regression test for both.

Transport plugins provide a hook for MC to communicate with connectivity
mechanisms like NetworkManager, Maemo's ConIc or Moblin's ConnMan to
request an Internet connection when signing on to IM protocols.

If the user sets online presence but the Internet connection fails, the
RequestedPresence will still be online. As a result, the user can only
retry connection by setting their presence to offline and back to online,
which is deeply unintuitive.

Removing the check for a no-op means that the UI re-requesting an online
presence will trigger another attempt to connect to the Internet; this one
might succeed.

Also, if a protocol has side-effects from re-requesting the same presence
(e.g. it records the time at which the current presence was requested),
this change will make it behave according to the user's input.
---
 src/mcd-account.c                        |    6 ++----
 test/twisted/account-manager/presence.py |   25 ++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/mcd-account.c b/src/mcd-account.c
index bd72eda..d7db7a2 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -501,9 +501,6 @@ mcd_account_request_presence_int (McdAccount *account,
 	changed = TRUE;
     }
 
-    if (!(changed || priv->temporary_presence))
-        return FALSE;
-
     if (priv->connection == NULL)
     {
         if (type >= TP_CONNECTION_PRESENCE_TYPE_AVAILABLE)
@@ -516,7 +513,8 @@ mcd_account_request_presence_int (McdAccount *account,
         _mcd_connection_request_presence (priv->connection,
                                           type, status, message);
     }
-    return TRUE;
+
+    return changed;
 }
 
 void
diff --git a/test/twisted/account-manager/presence.py b/test/twisted/account-manager/presence.py
index b68cff0..f4ebb94 100644
--- a/test/twisted/account-manager/presence.py
+++ b/test/twisted/account-manager/presence.py
@@ -2,7 +2,7 @@ import dbus
 import dbus.service
 
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
-        call_async
+        call_async, sync_dbus
 from mctest import exec_test, create_fakecm_account, enable_fakecm_account
 import constants as cs
 
@@ -54,5 +54,28 @@ def test(q, bus, mc):
             interface=cs.ACCOUNT, signal='AccountPropertyChanged',
             predicate=lambda e: e.args[0].get('CurrentPresence') == presence)
 
+    # Setting RequestedPresence=RequestedPresence causes a (possibly redundant)
+    # call to the CM, so we get any side-effects there might be, either in the
+    # CM or in MC (e.g. asking connectivity services to go online). However,
+    # AccountPropertyChanged is not emitted for RequestedPresence.
+
+    sync_dbus(bus, q, mc)
+    events = [EventPattern('dbus-signal', signal='AccountPropertyChanged',
+        predicate=lambda e: e.args[0].get('RequestedPresence') is not None)]
+    q.forbid_events(events)
+
+    presence = dbus.Struct((dbus.UInt32(cs.PRESENCE_TYPE_AWAY), 'away',
+            'In Hong Kong'), signature='uss')
+    call_async(q, account_props, 'Set', cs.ACCOUNT, 'RequestedPresence',
+            presence)
+
+    e = q.expect('dbus-method-call',
+        interface=cs.CONN_IFACE_SIMPLE_PRESENCE, method='SetPresence',
+        args=list(presence[1:]),
+        handled=True)
+
+    sync_dbus(bus, q, mc)
+    q.unforbid_events(events)
+
 if __name__ == '__main__':
     exec_test(test, {})
-- 
1.5.6.5




More information about the telepathy-commits mailing list