From b99a8b125c5d8da4c437f1634e6357420e4a7e3e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Oct 2012 16:06:43 +0100 Subject: [PATCH 2/4] TpConnection: connect to SelfHandleChanged much earlier Previously, we only connected to it just before calling GetSelfHandle - but on the "modern" code path we no longer call that, because GetAll("...Connection") is just as informative. This meant we missed self-handle changes on modern connection managers. This was masked by the fact that the self-handle regression test deliberately breaks the "modern" code path, because some of its tests rely on GetSelfHandle being called. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55666 --- telepathy-glib/connection.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c index 5fd37b1..4a98daf 100644 --- a/telepathy-glib/connection.c +++ b/telepathy-glib/connection.c @@ -935,6 +935,15 @@ on_self_handle_changed (TpConnection *self, return; } + if (self->priv->last_known_self_handle == 0) + { + /* We're going to call GetAll(Connection) anyway, or if the CM + * is sufficiently deficient, GetSelfHandle(). */ + DEBUG ("Ignoring early self-handle change to %u, we'll pick it up later", + self_handle); + return; + } + DEBUG ("SelfHandleChanged to %u, I wonder what that means?", self_handle); self->priv->last_known_self_handle = self_handle; get_self_contact (self); @@ -949,11 +958,6 @@ introspect_self_handle (TpConnection *self) return; } - /* this only happens when we introspect after CONNECTED, so there's no need - * to track whether this is the first time */ - tp_cli_connection_connect_to_self_handle_changed (self, - on_self_handle_changed, NULL, NULL, NULL, NULL); - g_assert (self->priv->introspection_call == NULL); self->priv->introspection_call = tp_cli_connection_call_get_self_handle ( self, -1, got_self_handle, NULL, NULL, NULL); @@ -1452,6 +1456,11 @@ tp_connection_constructed (GObject *object) tp_cli_connection_connect_to_connection_error (self, tp_connection_connection_error_cb, NULL, NULL, NULL, NULL); + /* We need to connect to SelfHandleChanged early, too, so that we're + * already connected before we GetAll */ + tp_cli_connection_connect_to_self_handle_changed (self, + on_self_handle_changed, NULL, NULL, NULL, NULL); + object_path = tp_proxy_get_object_path (TP_PROXY (self)); g_assert (_tp_connection_parse (object_path, '/', &(self->priv->proto_name), &(self->priv->cm_name))); -- 1.7.10.4