[next] telepathy-glib: DebugClient: add a Core feature.
Simon McVittie
smcv at kemper.freedesktop.org
Wed Apr 25 07:26:07 PDT 2012
Module: telepathy-glib
Branch: next
Commit: e8bb33b6c8213d82562d4b8436a2a4de0ffde172
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=e8bb33b6c8213d82562d4b8436a2a4de0ffde172
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Sat Nov 27 00:04:25 2010 +0000
DebugClient: add a Core feature.
This feature basically just checks that the thing at the other end
actually supports the Debug interface.
---
telepathy-glib/debug-client.c | 88 ++++++++++++++++++++++++++++++++++++++++-
telepathy-glib/debug-client.h | 4 ++
2 files changed, 91 insertions(+), 1 deletions(-)
diff --git a/telepathy-glib/debug-client.c b/telepathy-glib/debug-client.c
index 46a5d8a..0789f0f 100644
--- a/telepathy-glib/debug-client.c
+++ b/telepathy-glib/debug-client.c
@@ -27,6 +27,7 @@
#define DEBUG_FLAG TP_DEBUG_DEBUGGER
#include "telepathy-glib/debug-internal.h"
+#include "telepathy-glib/proxy-internal.h"
#include "telepathy-glib/_gen/tp-cli-debug-body.h"
@@ -68,6 +69,12 @@ struct _TpDebugClient {
TpDebugClientPrivate *priv;
};
+struct _TpDebugClientPrivate {
+ gboolean enabled;
+};
+
+static const TpProxyFeature *tp_debug_client_list_features (TpProxyClass *klass);
+static void tp_debug_client_prepare_core (TpDebugClient *self);
static void name_owner_changed_cb (TpDBusDaemon *bus,
const gchar *name,
const gchar *new_owner,
@@ -78,27 +85,38 @@ G_DEFINE_TYPE (TpDebugClient, tp_debug_client, TP_TYPE_PROXY)
static void
tp_debug_client_init (TpDebugClient *self)
{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TYPE_DEBUG_CLIENT,
+ TpDebugClientPrivate);
}
static void
tp_debug_client_constructed (GObject *object)
{
+ TpDebugClient *self = TP_DEBUG_CLIENT (object);
TpProxy *proxy = TP_PROXY (object);
+ GObjectClass *parent_class = G_OBJECT_CLASS (tp_debug_client_parent_class);
+
+ if (parent_class->constructed != NULL)
+ parent_class->constructed (object);
tp_dbus_daemon_watch_name_owner (
tp_proxy_get_dbus_daemon (proxy), tp_proxy_get_bus_name (proxy),
name_owner_changed_cb, object, NULL);
+ tp_debug_client_prepare_core (self);
}
static void
tp_debug_client_dispose (GObject *object)
{
TpProxy *proxy = TP_PROXY (object);
+ GObjectClass *parent_class = G_OBJECT_CLASS (tp_debug_client_parent_class);
tp_dbus_daemon_cancel_name_owner_watch (
tp_proxy_get_dbus_daemon (proxy), tp_proxy_get_bus_name (proxy),
name_owner_changed_cb, object);
- G_OBJECT_CLASS (tp_debug_client_parent_class)->dispose (object);
+
+ if (parent_class->dispose != NULL)
+ parent_class->dispose (object);
}
static void
@@ -112,9 +130,18 @@ tp_debug_client_class_init (TpDebugClientClass *klass)
proxy_class->must_have_unique_name = TRUE;
proxy_class->interface = TP_IFACE_QUARK_DEBUG;
+ proxy_class->list_features = tp_debug_client_list_features;
+
+ g_type_class_add_private (klass, sizeof (TpDebugClientPrivate));
tp_debug_client_init_known_interfaces ();
}
+GQuark
+tp_debug_client_get_feature_quark_core (void)
+{
+ return g_quark_from_static_string ("tp-debug-client-feature-core");
+}
+
static void
name_owner_changed_cb (
TpDBusDaemon *bus,
@@ -136,6 +163,65 @@ name_owner_changed_cb (
}
}
+static void
+got_enabled_cb (
+ TpProxy *proxy,
+ const GValue *value,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ TpDebugClient *self = TP_DEBUG_CLIENT (proxy);
+
+ if (error != NULL)
+ {
+ tp_proxy_invalidate (proxy, error);
+ }
+ else if (!G_VALUE_HOLDS_BOOLEAN (value))
+ {
+ GError *e = g_error_new (TP_ERRORS,
+ TP_ERROR_NOT_IMPLEMENTED,
+ "this service doesn't implement the Debug interface correctly "
+ "(the Enabled property is not a boolean, but a %s)",
+ G_VALUE_TYPE_NAME (value));
+
+ tp_proxy_invalidate (proxy, e);
+ g_error_free (e);
+ }
+ else
+ {
+ self->priv->enabled = g_value_get_boolean (value);
+ /* FIXME: we have no change notification for Enabled. */
+ _tp_proxy_set_feature_prepared (proxy, TP_DEBUG_CLIENT_FEATURE_CORE,
+ TRUE);
+ }
+}
+
+static void
+tp_debug_client_prepare_core (TpDebugClient *self)
+{
+ tp_cli_dbus_properties_call_get (self, -1, TP_IFACE_DEBUG, "Enabled",
+ got_enabled_cb, NULL, NULL, NULL);
+}
+
+static const TpProxyFeature *
+tp_debug_client_list_features (TpProxyClass *klass)
+{
+ static gsize once = 0;
+ static TpProxyFeature features[] = {
+ { 0, TRUE },
+ { 0 }
+ };
+
+ if (g_once_init_enter (&once))
+ {
+ features[0].name = TP_DEBUG_CLIENT_FEATURE_CORE;
+ g_once_init_leave (&once, 1);
+ }
+
+ return features;
+}
+
/**
* tp_debug_client_init_known_interfaces:
*
diff --git a/telepathy-glib/debug-client.h b/telepathy-glib/debug-client.h
index a575eb9..a804cb9 100644
--- a/telepathy-glib/debug-client.h
+++ b/telepathy-glib/debug-client.h
@@ -35,6 +35,10 @@ TpDebugClient *tp_debug_client_new (
const gchar *unique_name,
GError **error);
+#define TP_DEBUG_CLIENT_FEATURE_CORE \
+ (tp_debug_client_get_feature_quark_core ())
+GQuark tp_debug_client_get_feature_quark_core (void) G_GNUC_CONST;
+
/* Tedious GObject boilerplate */
GType tp_debug_client_get_type (void);
More information about the telepathy-commits
mailing list