aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-05 02:49:15 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-09 19:02:18 +0800
commitcb117f3038211d0ca8fe416c77fe47b588d8304f (patch)
treead3cf40d7736247c52cd89fcd37c45c59a20bb06
parentd2d8c7d06ac924b2b4113b46cda916bbf2fb7b98 (diff)
downloadgsoc2013-empathy-cb117f3038211d0ca8fe416c77fe47b588d8304f.tar
gsoc2013-empathy-cb117f3038211d0ca8fe416c77fe47b588d8304f.tar.gz
gsoc2013-empathy-cb117f3038211d0ca8fe416c77fe47b588d8304f.tar.bz2
gsoc2013-empathy-cb117f3038211d0ca8fe416c77fe47b588d8304f.tar.lz
gsoc2013-empathy-cb117f3038211d0ca8fe416c77fe47b588d8304f.tar.xz
gsoc2013-empathy-cb117f3038211d0ca8fe416c77fe47b588d8304f.tar.zst
gsoc2013-empathy-cb117f3038211d0ca8fe416c77fe47b588d8304f.zip
TpContactFactory: wait that the connection is ready before using it
-rw-r--r--libempathy/empathy-tp-contact-factory.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index 6683b5936..2acbdd991 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -1281,32 +1281,32 @@ tp_contact_factory_finalize (GObject *object)
G_OBJECT_CLASS (empathy_tp_contact_factory_parent_class)->finalize (object);
}
-static GObject *
-tp_contact_factory_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props)
+static void
+connection_ready_cb (TpConnection *connection,
+ const GError *error,
+ gpointer user_data)
{
- GObject *tp_factory;
- EmpathyTpContactFactoryPriv *priv;
+ EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (user_data);
+ EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- tp_factory = G_OBJECT_CLASS (empathy_tp_contact_factory_parent_class)->constructor (type, n_props, props);
- priv = GET_PRIV (tp_factory);
+ if (error != NULL)
+ goto out;
/* FIXME: This should be moved to TpContact */
tp_cli_connection_interface_avatars_connect_to_avatar_updated (priv->connection,
tp_contact_factory_avatar_updated_cb,
NULL, NULL,
- tp_factory,
+ G_OBJECT (tp_factory),
NULL);
tp_cli_connection_interface_avatars_connect_to_avatar_retrieved (priv->connection,
tp_contact_factory_avatar_retrieved_cb,
NULL, NULL,
- tp_factory,
+ G_OBJECT (tp_factory),
NULL);
tp_cli_connection_interface_capabilities_connect_to_capabilities_changed (priv->connection,
tp_contact_factory_capabilities_changed_cb,
NULL, NULL,
- tp_factory,
+ G_OBJECT (tp_factory),
NULL);
@@ -1316,18 +1316,40 @@ tp_contact_factory_constructor (GType type,
G_OBJECT (tp_factory),
NULL);
- /* FIXME: This should be moved to TpConnection */
+
tp_cli_connection_interface_avatars_call_get_avatar_requirements (priv->connection,
-1,
tp_contact_factory_got_avatar_requirements_cb,
NULL, NULL,
- tp_factory);
+ G_OBJECT (tp_factory));
+
tp_cli_dbus_properties_call_get (priv->connection, -1,
TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
"RequestableChannelClasses",
get_requestable_channel_classes_cb, NULL, NULL,
G_OBJECT (tp_factory));
+out:
+ g_object_unref (tp_factory);
+}
+
+static GObject *
+tp_contact_factory_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *tp_factory;
+ EmpathyTpContactFactoryPriv *priv;
+
+ tp_factory = G_OBJECT_CLASS (empathy_tp_contact_factory_parent_class)->constructor (type, n_props, props);
+ priv = GET_PRIV (tp_factory);
+
+ /* Ensure to keep the self object alive while the call_when_ready is
+ * running */
+ g_object_ref (tp_factory);
+ tp_connection_call_when_ready (priv->connection, connection_ready_cb,
+ tp_factory);
+
return tp_factory;
}