[next] telepathy-glib: Tp(Base)Connection: Requests and Contacts ifaces are now mandatory

Xavier Claessens xclaesse at kemper.freedesktop.org
Thu Sep 13 01:27:13 PDT 2012


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

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Thu Sep  6 11:39:44 2012 +0200

Tp(Base)Connection: Requests and Contacts ifaces are now mandatory

https://bugs.freedesktop.org/show_bug.cgi?id=54321

---

 telepathy-glib/base-connection.c |   25 +++++++++++++++++++++++--
 telepathy-glib/connection.c      |    7 +++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index 22a1e3c..52e2c37 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -895,6 +895,8 @@ tp_base_connection_create_interfaces_array (TpBaseConnection *self)
   TpBaseConnectionPrivate *priv = self->priv;
   TpBaseConnectionClass *klass = TP_BASE_CONNECTION_GET_CLASS (self);
   GPtrArray *always;
+  gboolean has_requests = FALSE;
+  gboolean has_contacts = FALSE;
   guint i;
 
   g_assert (priv->interfaces == NULL);
@@ -905,8 +907,19 @@ tp_base_connection_create_interfaces_array (TpBaseConnection *self)
       always->len);
   for (i = 0; i < always->len; i++)
     {
-      g_array_append_val (priv->interfaces,
-          g_ptr_array_index (always, i));
+      const gchar *iface = g_ptr_array_index (always, i);
+
+      if (!tp_strdiff (iface, TP_IFACE_CONNECTION_INTERFACE_REQUESTS))
+        has_requests = TRUE;
+      else if (!tp_strdiff (iface, TP_IFACE_CONNECTION_INTERFACE_CONTACTS))
+        has_contacts = TRUE;
+
+      g_array_append_val (priv->interfaces, iface);
+    }
+
+  if (!has_requests || !has_contacts)
+    {
+      g_critical ("Requests and Contacts interfaces must always be present");
     }
 
   g_ptr_array_unref (always);
@@ -928,6 +941,14 @@ tp_base_connection_constructor (GType type, guint n_construct_properties,
   g_assert (cls->shut_down != NULL);
   g_assert (cls->start_connecting != NULL);
 
+  if (!TP_IS_SVC_CONNECTION_INTERFACE_CONTACTS (self) ||
+      !TP_IS_SVC_CONNECTION_INTERFACE_REQUESTS (self))
+    {
+      g_critical ("Connection must always implement "
+          "TpSvcConnectionInterfaceContacts and "
+          "TpSvcConnectionInterfaceRequests");
+    }
+
   /* if we fail to connect to D-Bus here, we'll return an error from
    * register */
   tp_base_connection_ensure_dbus (self, NULL);
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 834fd87..704e0d3 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -1063,6 +1063,13 @@ _tp_connection_got_properties (TpProxy *proxy,
   if (interfaces == NULL)
     goto error;
 
+  if (!tp_strv_contains (interfaces, TP_IFACE_CONNECTION_INTERFACE_REQUESTS) ||
+      !tp_strv_contains (interfaces, TP_IFACE_CONNECTION_INTERFACE_CONTACTS))
+    {
+      DEBUG ("Connection does not have Requests/Contacts interface - Broken CM");
+      goto error;
+    }
+
   tp_proxy_add_interfaces (proxy, interfaces);
   self->priv->ready_enough_for_contacts = TRUE;
 



More information about the telepathy-commits mailing list