[next] telepathy-glib: base-client: warn if user try to add/ remove iface when registered
Simon McVittie
smcv at kemper.freedesktop.org
Wed Sep 17 06:17:26 PDT 2014
Module: telepathy-glib
Branch: next
Commit: 654962f11dd1d89f96ad4a0f47dff8cbab2f45bf
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=654962f11dd1d89f96ad4a0f47dff8cbab2f45bf
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Wed May 14 11:08:09 2014 +0200
base-client: warn if user try to add/remove iface when registered
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77882
Reviewed-by: Simon McVittie
---
telepathy-glib/base-client.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/telepathy-glib/base-client.c b/telepathy-glib/base-client.c
index a604a9d..13102c4 100644
--- a/telepathy-glib/base-client.c
+++ b/telepathy-glib/base-client.c
@@ -1258,6 +1258,30 @@ tp_base_client_set_property (GObject *object,
}
}
+/* User data for interface-added and interface-removed signals, with vaguely
+ * mnemonic values */
+#define INTERFACE_ADDED (GINT_TO_POINTER(1))
+#define INTERFACE_REMOVED (GINT_TO_POINTER(-1))
+
+static void
+tp_base_client_interface_changed_cb (TpBaseClient *self,
+ GDBusInterface *interface,
+ gpointer user_data)
+{
+ GDBusInterfaceInfo *info = g_dbus_interface_get_info (interface);
+ const gchar *verb = (user_data == INTERFACE_ADDED ? "add" : "remove");
+
+ g_assert (user_data == INTERFACE_ADDED || user_data == INTERFACE_REMOVED);
+
+ if (self->priv->registered)
+ {
+ WARNING ("Adding or removing Client interfaces after the client "
+ "has been registered is not supported. "
+ "(Tried to %s %s %p, \"%s\")",
+ verb, G_OBJECT_TYPE_NAME (interface), interface, info->name);
+ }
+}
+
static void
tp_base_client_constructed (GObject *object)
{
@@ -1307,6 +1331,13 @@ tp_base_client_constructed (GObject *object)
g_strdelimit (self->priv->object_path, ".", '/');
self->priv->bus_name = g_string_free (string, FALSE);
+
+ g_signal_connect (self, "interface-added",
+ G_CALLBACK (tp_base_client_interface_changed_cb),
+ INTERFACE_ADDED);
+ g_signal_connect (self, "interface-removed",
+ G_CALLBACK (tp_base_client_interface_changed_cb),
+ INTERFACE_REMOVED);
}
static void
More information about the telepathy-commits
mailing list