From ccc168af8292c966f304a7197396ea332f82f96a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 9 Sep 2013 17:19:58 +0100 Subject: [PATCH 4/6] McdConnection: use tp_simple_client_factory_ensure_connection This means we need to pass the client factory through the McdManager from the McdMaster, so, do. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55391 --- src/mcd-connection.c | 36 ++++++++++++++++++------------------ src/mcd-manager.c | 36 ++++++++++++++++++++---------------- src/mcd-manager.h | 2 +- src/mcd-master.c | 2 +- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/mcd-connection.c b/src/mcd-connection.c index 0d231df..c103e9a 100644 --- a/src/mcd-connection.c +++ b/src/mcd-connection.c @@ -75,8 +75,8 @@ G_DEFINE_TYPE (McdConnection, mcd_connection, MCD_TYPE_OPERATION); /* Private */ struct _McdConnectionPrivate { - /* DBUS connection */ - TpDBusDaemon *dbus_daemon; + /* Factory for TpConnection objects */ + TpSimpleClientFactory *client_factory; /* Channel dispatcher */ McdDispatcher *dispatcher; @@ -146,7 +146,7 @@ typedef struct enum { PROP_0, - PROP_DBUS_DAEMON, + PROP_CLIENT_FACTORY, PROP_TP_MANAGER, PROP_TP_CONNECTION, PROP_ACCOUNT, @@ -1697,7 +1697,7 @@ _mcd_connection_dispose (GObject * object) tp_clear_object (&priv->tp_conn_mgr); tp_clear_object (&priv->dispatcher); - tp_clear_object (&priv->dbus_daemon); + tp_clear_object (&priv->client_factory); G_OBJECT_CLASS (mcd_connection_parent_class)->dispose (object); } @@ -1723,10 +1723,12 @@ _mcd_connection_set_property (GObject * obj, guint prop_id, tp_clear_object (&priv->dispatcher); priv->dispatcher = dispatcher; break; - case PROP_DBUS_DAEMON: - tp_clear_object (&priv->dbus_daemon); - priv->dbus_daemon = TP_DBUS_DAEMON (g_value_dup_object (val)); - break; + + case PROP_CLIENT_FACTORY: + g_assert (priv->client_factory == NULL); /* construct-only */ + priv->client_factory = g_value_dup_object (val); + break; + case PROP_TP_MANAGER: tp_conn_mgr = g_value_get_object (val); g_object_ref (tp_conn_mgr); @@ -1761,9 +1763,6 @@ _mcd_connection_get_property (GObject * obj, guint prop_id, switch (prop_id) { - case PROP_DBUS_DAEMON: - g_value_set_object (val, priv->dbus_daemon); - break; case PROP_ACCOUNT: g_value_set_object (val, priv->account); break; @@ -1905,11 +1904,12 @@ mcd_connection_class_init (McdConnectionClass * klass) "Dispatcher", MCD_TYPE_DISPATCHER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property - (object_class, PROP_DBUS_DAEMON, - g_param_spec_object ("dbus-daemon", "DBus daemon", "DBus daemon", - TP_TYPE_DBUS_DAEMON, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property (object_class, PROP_CLIENT_FACTORY, + g_param_spec_object ("client-factory", "Client factory", + "Client factory", TP_TYPE_SIMPLE_CLIENT_FACTORY, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (object_class, PROP_TP_MANAGER, g_param_spec_object ("tp-manager", @@ -2261,8 +2261,8 @@ _mcd_connection_set_tp_connection (McdConnection *connection, } g_assert (priv->tp_conn == NULL); - priv->tp_conn = tp_connection_new (priv->dbus_daemon, bus_name, - obj_path, &inner_error); + priv->tp_conn = tp_simple_client_factory_ensure_connection ( + priv->client_factory, obj_path, NULL, &inner_error); DEBUG ("new connection is %p", priv->tp_conn); if (!priv->tp_conn) { diff --git a/src/mcd-manager.c b/src/mcd-manager.c index 39d09ea..5ad8684 100644 --- a/src/mcd-manager.c +++ b/src/mcd-manager.c @@ -58,6 +58,7 @@ struct _McdManagerPrivate { gchar *name; TpDBusDaemon *dbus_daemon; + TpSimpleClientFactory *client_factory; McdDispatcher *dispatcher; TpConnectionManager *tp_conn_mgr; @@ -73,7 +74,7 @@ enum PROP_0, PROP_NAME, PROP_DISPATCHER, - PROP_DBUS_DAEMON, + PROP_CLIENT_FACTORY }; static GQuark readiness_quark = 0; @@ -122,6 +123,7 @@ _mcd_manager_dispose (GObject * object) tp_clear_object (&priv->dispatcher); tp_clear_object (&priv->tp_conn_mgr); + tp_clear_object (&priv->client_factory); tp_clear_object (&priv->dbus_daemon); tp_clear_object (&priv->slacker); @@ -229,10 +231,14 @@ _mcd_manager_set_property (GObject * obj, guint prop_id, tp_clear_object (&priv->dispatcher); priv->dispatcher = dispatcher; break; - case PROP_DBUS_DAEMON: - tp_clear_object (&priv->dbus_daemon); - priv->dbus_daemon = TP_DBUS_DAEMON (g_value_dup_object (val)); - break; + + case PROP_CLIENT_FACTORY: + g_assert (priv->client_factory == NULL); /* construct-only */ + priv->client_factory = g_value_dup_object (val); + priv->dbus_daemon = g_object_ref ( + tp_simple_client_factory_get_dbus_daemon (priv->client_factory)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -250,9 +256,6 @@ _mcd_manager_get_property (GObject * obj, guint prop_id, case PROP_DISPATCHER: g_value_set_object (val, priv->dispatcher); break; - case PROP_DBUS_DAEMON: - g_value_set_object (val, priv->dbus_daemon); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -289,11 +292,11 @@ mcd_manager_class_init (McdManagerClass * klass) "Dispatcher", MCD_TYPE_DISPATCHER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property - (object_class, PROP_DBUS_DAEMON, - g_param_spec_object ("dbus-daemon", "DBus daemon", "DBus daemon", - TP_TYPE_DBUS_DAEMON, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, PROP_CLIENT_FACTORY, + g_param_spec_object ("client-factory", "Client factory", + "Client factory", TP_TYPE_SIMPLE_CLIENT_FACTORY, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); readiness_quark = g_quark_from_static_string ("mcd_manager_got_info"); } @@ -313,13 +316,14 @@ mcd_manager_init (McdManager *manager) McdManager * mcd_manager_new (const gchar *unique_name, McdDispatcher *dispatcher, - TpDBusDaemon *dbus_daemon) + TpSimpleClientFactory *client_factory) { McdManager *obj; obj = MCD_MANAGER (g_object_new (MCD_TYPE_MANAGER, "name", unique_name, "dispatcher", dispatcher, - "dbus-daemon", dbus_daemon, NULL)); + "client-factory", client_factory, + NULL)); return obj; } @@ -386,7 +390,7 @@ mcd_manager_create_connection (McdManager *manager, McdAccount *account) g_return_val_if_fail (manager->priv->tp_conn_mgr != NULL, NULL); connection = g_object_new (MCD_TYPE_CONNECTION, - "dbus-daemon", manager->priv->dbus_daemon, + "client-factory", manager->priv->client_factory, "tp-manager", manager->priv->tp_conn_mgr, "dispatcher", manager->priv->dispatcher, "account", account, diff --git a/src/mcd-manager.h b/src/mcd-manager.h index 8300663..a919395 100644 --- a/src/mcd-manager.h +++ b/src/mcd-manager.h @@ -62,7 +62,7 @@ struct _McdManagerClass GType mcd_manager_get_type (void); McdManager *mcd_manager_new (const gchar *unique_name, McdDispatcher *dispatcher, - TpDBusDaemon *dbus_daemon); + TpSimpleClientFactory *client_factory); const gchar *mcd_manager_get_name (McdManager *manager); diff --git a/src/mcd-master.c b/src/mcd-master.c index b123fab..37c127b 100644 --- a/src/mcd-master.c +++ b/src/mcd-master.c @@ -315,7 +315,7 @@ _mcd_master_lookup_manager (McdMaster *master, manager = mcd_manager_new (unique_name, master->priv->dispatcher, - master->priv->dbus_daemon); + master->priv->client_factory); if (G_UNLIKELY (!manager)) g_warning ("Manager %s not created", unique_name); else -- 1.8.4.rc3