summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-09-16 18:23:05 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2010-09-16 18:33:09 +0100
commit1e93089a8d05c2a60da177d0025dec1f031d3dbe (patch)
tree144bba42d7b5768bf16f23122a40a8f089d0b9b2
parentf02defd4f8053c62aafc867954474b4c97bae178 (diff)
downloadtelepathy-mission-control-1e93089a8d05c2a60da177d0025dec1f031d3dbe.tar.gz
Set CurrentPresence to Unset if online without SimplePresence
The spec says: If the connection is online but does not support the SimplePresence interface, this should be (Connection_Presence_Type_Unset, "", ""). But previously we only updated CurrentPresence in response to PresencesChanged being emitted for our self handle, which it obviously never is by connections which don't implement SimplePresence. (Actually, this was right by accident until my previous commit, because CurrentPresence was initialized to (0, NULL, NULL).) Fixes: <https://bugs.freedesktop.org/show_bug.cgi?id=24779>
-rw-r--r--src/mcd-account.c42
-rw-r--r--test/twisted/account-manager/request-online.py18
2 files changed, 46 insertions, 14 deletions
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 027e86de..a09de8e8 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -3212,13 +3212,11 @@ mcd_account_request_presence (McdAccount *account,
}
static void
-on_conn_self_presence_changed (McdConnection *connection,
- TpConnectionPresenceType presence,
- const gchar *status,
- const gchar *message,
- gpointer user_data)
+mcd_account_update_self_presence (McdAccount *account,
+ TpConnectionPresenceType presence,
+ const gchar *status,
+ const gchar *message)
{
- McdAccount *account = MCD_ACCOUNT (user_data);
McdAccountPrivate *priv = account->priv;
gboolean changed = FALSE;
GValue value = { 0 };
@@ -3243,7 +3241,7 @@ on_conn_self_presence_changed (McdConnection *connection,
changed = TRUE;
}
- if (_mcd_connection_presence_info_is_ready (connection))
+ if (_mcd_connection_presence_info_is_ready (priv->connection))
{
_mcd_account_set_changing_presence (account, FALSE);
}
@@ -3261,6 +3259,21 @@ on_conn_self_presence_changed (McdConnection *connection,
g_value_unset (&value);
}
+
+static void
+on_conn_self_presence_changed (McdConnection *connection,
+ TpConnectionPresenceType presence,
+ const gchar *status,
+ const gchar *message,
+ gpointer user_data)
+{
+ McdAccount *account = MCD_ACCOUNT (user_data);
+ McdAccountPrivate *priv = account->priv;
+
+ g_assert (priv->connection == connection);
+ mcd_account_update_self_presence (account, presence, status, message);
+}
+
/* TODO: remove when the relative members will become public */
void
mcd_account_get_requested_presence (McdAccount *account,
@@ -4084,6 +4097,21 @@ mcd_account_connection_ready_cb (McdAccount *account,
}
g_free (nickname);
+
+ if (!tp_proxy_has_interface_by_id (tp_connection,
+ TP_IFACE_QUARK_CONNECTION_INTERFACE_SIMPLE_PRESENCE))
+ {
+ /* This connection doesn't have SimplePresence, but it's online.
+ * TpConnection only emits connection-ready when the account is online
+ * and we've introspected it, so we know that if this interface isn't
+ * present now, it's not going to appear.
+ *
+ * So, the spec says that we should set CurrentPresence to Unset.
+ */
+ mcd_account_update_self_presence (account,
+ TP_CONNECTION_PRESENCE_TYPE_UNSET, "", "");
+ }
+
}
void
diff --git a/test/twisted/account-manager/request-online.py b/test/twisted/account-manager/request-online.py
index 90fb4cd3..83f34f43 100644
--- a/test/twisted/account-manager/request-online.py
+++ b/test/twisted/account-manager/request-online.py
@@ -124,9 +124,13 @@ def test(q, bus, mc):
properties = account.GetAll(cs.ACCOUNT,
dbus_interface=cs.PROPERTIES_IFACE)
assert properties is not None
- assert properties.get('HasBeenOnline') == True
- assert properties.get('RequestedPresence') == requested_presence, \
- properties.get('RequestedPresence')
+ assert properties.get('HasBeenOnline')
+ assertEquals(requested_presence, properties.get('RequestedPresence'))
+
+ # Since this Connection doesn't support SimplePresence, but it's online,
+ # the spec says that CurrentPresence should be Unset.
+ assertEquals((cs.PRESENCE_TYPE_UNSET, "", ""),
+ properties.get('CurrentPresence'))
new_channel = http_fixed_properties
buddy_handle = conn.ensure_handle(cs.HT_CONTACT, "buddy")
@@ -157,10 +161,10 @@ def test(q, bus, mc):
# path=chan.object_path, handled=True)
properties = account.GetAll(cs.ACCOUNT, dbus_interface=cs.PROPERTIES_IFACE)
- assert properties['Connection'] == '/'
- assert properties['ConnectionStatus'] == cs.CONN_STATUS_DISCONNECTED
- assert properties['CurrentPresence'] == requested_presence
- assert properties['RequestedPresence'] == requested_presence
+ assertEquals('/', properties['Connection'])
+ assertEquals(cs.CONN_STATUS_DISCONNECTED, properties['ConnectionStatus'])
+ assertEquals(requested_presence, properties['CurrentPresence'])
+ assertEquals(requested_presence, properties['RequestedPresence'])
if __name__ == '__main__':
exec_test(test, {})