]> git.0d.be Git - empathy.git/commitdiff
EmpathyTpContactFactory: split on-ready code out of got_self_handle_cb
authorXavier Claessens <xclaesse@src.gnome.org>
Tue, 11 Nov 2008 15:25:48 +0000 (15:25 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 11 Nov 2008 15:25:48 +0000 (15:25 +0000)
svn path=/trunk/; revision=1671

libempathy/empathy-tp-contact-factory.c

index b8e2ca37efd1fcac18f93be57ee2d1e4bc7edab8..85921d0b24782b8bb7a3ffb9165657832a25338a 100644 (file)
@@ -60,6 +60,10 @@ enum {
        PROP_READY
 };
 
+/* Prototypes */
+static void tp_contact_factory_maybe_ready (EmpathyTpContactFactory *tp_factory);
+
+
 static EmpathyContact *
 tp_contact_factory_find_by_handle (EmpathyTpContactFactory *tp_factory,
                                   guint                    handle)
@@ -725,6 +729,21 @@ tp_contact_factory_got_self_handle_cb (TpConnection *proxy,
                                       const GError *error,
                                       gpointer      user_data,
                                       GObject      *tp_factory)
+{
+       EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
+
+       if (error) {
+               DEBUG ("Failed to get self handles: %s", error->message);
+               return;
+       }
+
+       empathy_contact_set_handle (priv->user, handle);
+
+       tp_contact_factory_maybe_ready (EMPATHY_TP_CONTACT_FACTORY (tp_factory));
+}
+
+static void
+tp_contact_factory_maybe_ready (EmpathyTpContactFactory *tp_factory)
 {
        EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
        GList                       *l;
@@ -733,16 +752,15 @@ tp_contact_factory_got_self_handle_cb (TpConnection *proxy,
        GList                       *handle_needed_contacts = NULL;
        GList                       *id_needed_contacts = NULL;
 
-       if (error) {
-               DEBUG ("Failed to get self handles: %s", error->message);
+       if (empathy_contact_get_handle (priv->user) == 0) {
+               DEBUG ("Connection not ready: still waiting for self handle");
                return;
        }
 
        DEBUG ("Connection ready");
 
-       empathy_contact_set_handle (priv->user, handle);
        priv->ready = TRUE;
-       g_object_notify (tp_factory, "ready");
+       g_object_notify (G_OBJECT (tp_factory), "ready");
 
        /* Connect signals */
        tp_cli_connection_interface_aliasing_connect_to_aliases_changed (priv->connection,