From f02defd4f8053c62aafc867954474b4c97bae178 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 16 Sep 2010 18:21:32 +0100 Subject: Correctly initialize Account.CurrentPresence The spec says that CurrentPresence being 'Unset' (which is value 0, hence the default if we don't change it) means that the connection is online, but doesn't support SimplePresence. --- src/mcd-account.c | 4 +++ test/twisted/account-manager/request-online.py | 37 ++++++++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/mcd-account.c b/src/mcd-account.c index 74af7280..027e86de 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -2977,6 +2977,10 @@ mcd_account_init (McdAccount *account) priv->min_presence_status = NULL; priv->min_presence_message = NULL; + priv->curr_presence_type = TP_CONNECTION_PRESENCE_TYPE_OFFLINE; + priv->curr_presence_status = g_strdup ("offline"); + priv->curr_presence_status = g_strdup (""); + combine_presences (account); priv->always_on = FALSE; diff --git a/test/twisted/account-manager/request-online.py b/test/twisted/account-manager/request-online.py index 08be67aa..90fb4cd3 100644 --- a/test/twisted/account-manager/request-online.py +++ b/test/twisted/account-manager/request-online.py @@ -1,5 +1,6 @@ -# Copyright (C) 2009 Nokia Corporation -# Copyright (C) 2009 Collabora Ltd. +# Python is really rubbish. vim: set fileencoding=utf-8 : +# Copyright © 2009–2010 Nokia Corporation +# Copyright © 2009–2010 Collabora Ltd. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -19,9 +20,13 @@ import dbus import dbus.service -from servicetest import EventPattern, tp_name_prefix, tp_path_prefix -from mctest import exec_test, SimulatedConnection, create_fakecm_account,\ - SimulatedChannel, SimulatedClient, expect_client_setup +from servicetest import ( + EventPattern, tp_name_prefix, tp_path_prefix, assertEquals, +) +from mctest import ( + exec_test, SimulatedConnection, create_fakecm_account, + SimulatedChannel, SimulatedClient, expect_client_setup, +) import constants as cs def test(q, bus, mc): @@ -47,11 +52,14 @@ def test(q, bus, mc): "password": "secrecy"}, signature='sv') (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) - # The account is initially valid but disabled - assert not account.Get(cs.ACCOUNT, 'Enabled', - dbus_interface=cs.PROPERTIES_IFACE) - assert account.Get(cs.ACCOUNT, 'Valid', - dbus_interface=cs.PROPERTIES_IFACE) + # The account is initially valid but disabled, and hence offline + props = account.GetAll(cs.ACCOUNT, dbus_interface=cs.PROPERTIES_IFACE) + assert not props['Enabled'] + assert props['Valid'] + # The spec says it should be (Offline, "", "") but I don't think the + # strings really matter. If anything, the second one should start out at + # "offline". + assertEquals(cs.PRESENCE_TYPE_OFFLINE, props['CurrentPresence'][0]) # Enable the account account.Set(cs.ACCOUNT, 'Enabled', True, @@ -61,10 +69,11 @@ def test(q, bus, mc): signal='AccountPropertyChanged', interface=cs.ACCOUNT) - assert account.Get(cs.ACCOUNT, 'Enabled', - dbus_interface=cs.PROPERTIES_IFACE) - assert account.Get(cs.ACCOUNT, 'Valid', - dbus_interface=cs.PROPERTIES_IFACE) + props = account.GetAll(cs.ACCOUNT, dbus_interface=cs.PROPERTIES_IFACE) + assert props['Enabled'] + assert props['Valid'] + # Ditto above re. string fields. + assertEquals(cs.PRESENCE_TYPE_OFFLINE, props['CurrentPresence'][0]) # Go online requested_presence = dbus.Struct((dbus.UInt32(2L), dbus.String(u'brb'), -- cgit v1.2.3 From 1e93089a8d05c2a60da177d0025dec1f031d3dbe Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 16 Sep 2010 18:23:05 +0100 Subject: 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: --- src/mcd-account.c | 42 +++++++++++++++++++++----- test/twisted/account-manager/request-online.py | 18 ++++++----- 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, {}) -- cgit v1.2.3 From 438826eb7970d706a8bcb6c6ed79590a885ff761 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 16 Sep 2010 18:48:55 +0100 Subject: Clean up SimplePresence-building code. --- src/mcd-account.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mcd-account.c b/src/mcd-account.c index a09de8e8..de0c7915 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -3220,8 +3220,6 @@ mcd_account_update_self_presence (McdAccount *account, McdAccountPrivate *priv = account->priv; gboolean changed = FALSE; GValue value = { 0 }; - GType type; - GValueArray *va; if (priv->curr_presence_type != presence) { @@ -3248,13 +3246,13 @@ mcd_account_update_self_presence (McdAccount *account, if (!changed) return; - type = TP_STRUCT_TYPE_SIMPLE_PRESENCE; - g_value_init (&value, type); - g_value_take_boxed (&value, dbus_g_type_specialized_construct (type)); - va = (GValueArray *) g_value_get_boxed (&value); - g_value_set_uint (va->values, presence); - g_value_set_static_string (va->values + 1, status); - g_value_set_static_string (va->values + 2, message); + g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE); + g_value_take_boxed (&value, + tp_value_array_build (3, + G_TYPE_UINT, presence, + G_TYPE_STRING, status, + G_TYPE_STRING, message, + G_TYPE_INVALID)); mcd_account_changed_property (account, "CurrentPresence", &value); g_value_unset (&value); } -- cgit v1.2.3 From 1164508b9633b352440c880ccccda20f904adf3c Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 30 Nov 2010 18:05:29 +0000 Subject: mc-tool: Improve error message for nonexistant accounts. Reviewed-by: Simon McVittie --- util/mc-tool.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/mc-tool.c b/util/mc-tool.c index 4073649c..e69c6bb2 100644 --- a/util/mc-tool.c +++ b/util/mc-tool.c @@ -1267,10 +1267,10 @@ void account_ready (GObject *account, GError *error = NULL; if (!tp_proxy_prepare_finish (account, res, &error)) { - fprintf (stderr, "%s: %s: %s\n", - app_name, skip_prefix (command.common.account), - error->message); - g_error_free (error); + fprintf (stderr, "%s: couldn't load account '%s': %s\n", app_name, + skip_prefix (command.common.account), error->message); + fprintf (stderr, "Try '%s list' to list known accounts.\n", app_name); + g_error_free (error); } else { /* not all properties are exposed through TpAccount, request the -- cgit v1.2.3 From 3a63c47fa84a7a3d20e2274cd8c8c94771c02736 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 1 Dec 2010 19:00:50 +0000 Subject: NEWS for fd.o #24779. --- NEWS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index de17cf43..eb7e3272 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,10 @@ telepathy-mission-control 5.6.2 (UNRELEASED) ============================================ -… +Fixes: + +• fd.o #24779: CurrentPresence is Offline for online connections not + implementing SimplePresence (wjt) telepathy-mission-control 5.6.1 (2010-11-17) ============================================ -- cgit v1.2.3