[next] telepathy-glib: pass the factory when creating TpProtocol through it

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Mon Mar 17 07:25:42 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 4567d6c51235b8bdf1a503d0f5dd78160804c919
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=4567d6c51235b8bdf1a503d0f5dd78160804c919

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Fri Mar  7 12:10:31 2014 +0100

pass the factory when creating TpProtocol through it

---

 telepathy-glib/client-factory.c     |    3 ++-
 telepathy-glib/connection-manager.c |    6 +++---
 telepathy-glib/protocol-internal.h  |    1 +
 telepathy-glib/protocol.c           |    5 +++++
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c
index de41e1b..612ee8b 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -390,7 +390,7 @@ create_protocol_impl (TpClientFactory *self,
     GVariant *immutable_properties G_GNUC_UNUSED,
     GError **error)
 {
-  return _tp_protocol_new (self->priv->dbus, cm_name, protocol_name,
+  return _tp_protocol_new (self->priv->dbus, self, cm_name, protocol_name,
       immutable_properties, error);
 }
 
@@ -1408,6 +1408,7 @@ tp_client_factory_dup_protocol_features (TpClientFactory *self,
 {
   g_return_val_if_fail (TP_IS_CLIENT_FACTORY (self), NULL);
   g_return_val_if_fail (TP_IS_PROTOCOL (protocol), NULL);
+  g_return_val_if_fail (tp_proxy_get_factory (protocol) == self, NULL);
 
   return TP_CLIENT_FACTORY_GET_CLASS (self)->dup_protocol_features (
       self, protocol);
diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c
index a68b57c..500770c 100644
--- a/telepathy-glib/connection-manager.c
+++ b/telepathy-glib/connection-manager.c
@@ -385,8 +385,8 @@ tp_connection_manager_get_all_cb (TpProxy *proxy,
               if (tp_connection_manager_check_valid_protocol_name (name, NULL))
                 {
                   TpProtocol *proto_object = _tp_protocol_new (
-                      tp_proxy_get_dbus_daemon (self), self->priv->name, name,
-                      tp_asv_to_vardict (v), NULL);
+                      tp_proxy_get_dbus_daemon (self), NULL, self->priv->name,
+                      name, tp_asv_to_vardict (v), NULL);
 
                   /* _tp_protocol_new can currently only fail because of
                    * malformed names, and we already checked for that */
@@ -627,7 +627,7 @@ tp_connection_manager_read_file (TpDBusDaemon *dbus_daemon,
       if (immutables == NULL)
         continue;
 
-      proto_object = _tp_protocol_new (dbus_daemon, cm_name, name,
+      proto_object = _tp_protocol_new (dbus_daemon, NULL, cm_name, name,
           tp_asv_to_vardict (immutables), NULL);
       g_assert (proto_object != NULL);
 
diff --git a/telepathy-glib/protocol-internal.h b/telepathy-glib/protocol-internal.h
index c6b750b..d677ed9 100644
--- a/telepathy-glib/protocol-internal.h
+++ b/telepathy-glib/protocol-internal.h
@@ -35,6 +35,7 @@ struct _TpConnectionManagerParam
 };
 
 TpProtocol * _tp_protocol_new (TpDBusDaemon *dbus,
+    TpClientFactory *factory,
     const gchar *cm_name,
     const gchar *protocol_name,
     GVariant *immutable_properties,
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index 482f992..7cdf166 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -889,6 +889,7 @@ tp_protocol_init (TpProtocol *self)
 /*
  * _tp_protocol_new:
  * @dbus: proxy for the D-Bus daemon; may not be %NULL
+ * @factory: a #TpClientFactory, or %NULL
  * @cm_name: the connection manager name (such as "gabble")
  * @protocol_name: the protocol name (such as "jabber")
  * @immutable_properties: (allow-none): the immutable D-Bus properties for this
@@ -907,6 +908,7 @@ tp_protocol_init (TpProtocol *self)
  */
 TpProtocol *
 _tp_protocol_new (TpDBusDaemon *dbus,
+    TpClientFactory *factory,
     const gchar *cm_name,
     const gchar *protocol_name,
     GVariant *immutable_properties,
@@ -920,6 +922,8 @@ _tp_protocol_new (TpDBusDaemon *dbus,
       g_variant_is_of_type (immutable_properties, G_VARIANT_TYPE_VARDICT),
       NULL);
   g_return_val_if_fail (TP_IS_DBUS_DAEMON (dbus), NULL);
+  g_return_val_if_fail (factory == NULL || TP_IS_CLIENT_FACTORY (factory),
+      NULL);
 
   if (immutable_properties == NULL)
     immutable_properties = g_variant_new ("a{sv}", NULL);
@@ -940,6 +944,7 @@ _tp_protocol_new (TpDBusDaemon *dbus,
 
   ret = TP_PROTOCOL (g_object_new (TP_TYPE_PROTOCOL,
         "dbus-daemon", dbus,
+        "factory", factory,
         "bus-name", bus_name,
         "object-path", object_path,
         "protocol-name", protocol_name,



More information about the telepathy-commits mailing list