[gnome-shell] add shell-tp-client
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] add shell-tp-client
- Date: Wed, 27 Apr 2011 08:46:12 +0000 (UTC)
commit 145bf19636a5ba73f8e8382783e6905a6fdc811b
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Mon Mar 14 12:38:06 2011 +0100
add shell-tp-client
https://bugzilla.gnome.org/show_bug.cgi?id=645585
src/Makefile.am | 2 +
src/shell-tp-client.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++
src/shell-tp-client.h | 61 ++++++++++++++++++++++++
3 files changed, 188 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 31ff58b..cdb3173 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -100,6 +100,7 @@ shell_public_headers_h = \
shell-perf-log.h \
shell-slicer.h \
shell-stack.h \
+ shell-tp-client.h \
shell-tray-icon.h \
shell-tray-manager.h \
shell-util.h \
@@ -134,6 +135,7 @@ libgnome_shell_la_SOURCES = \
shell-polkit-authentication-agent.c \
shell-slicer.c \
shell-stack.c \
+ shell-tp-client.c \
shell-tray-icon.c \
shell-tray-manager.c \
shell-util.c \
diff --git a/src/shell-tp-client.c b/src/shell-tp-client.c
new file mode 100644
index 0000000..8270060
--- /dev/null
+++ b/src/shell-tp-client.c
@@ -0,0 +1,125 @@
+#include "shell-tp-client.h"
+
+#include <telepathy-glib/telepathy-glib.h>
+
+G_DEFINE_TYPE(ShellTpClient, shell_tp_client, TP_TYPE_BASE_CLIENT)
+
+struct _ShellTpClientPrivate
+{
+ ShellTpClientObserveChannelsImpl observe_impl;
+ gpointer user_data_obs;
+ GDestroyNotify destroy_obs;
+};
+
+/**
+ * ShellTpClientObserveChannelsImpl:
+ * @client: a #ShellTpClient instance
+ * @account: a #TpAccount having %TP_ACCOUNT_FEATURE_CORE prepared if possible
+ * @connection: a #TpConnection having %TP_CONNECTION_FEATURE_CORE prepared
+ * if possible
+ * @channels: (element-type TelepathyGLib.Channel): a #GList of #TpChannel,
+ * all having %TP_CHANNEL_FEATURE_CORE prepared if possible
+ * @dispatch_operation: (allow-none): a #TpChannelDispatchOperation or %NULL;
+ * the dispatch_operation is not guaranteed to be prepared
+ * @requests: (element-type TelepathyGLib.ChannelRequest): a #GList of
+ * #TpChannelRequest, all having their object-path defined but are not
+ * guaranteed to be prepared.
+ * @context: a #TpObserveChannelsContext representing the context of this
+ * D-Bus call
+ *
+ * Signature of the implementation of the ObserveChannels method.
+ */
+
+static void
+shell_tp_client_init (ShellTpClient *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_TP_CLIENT,
+ ShellTpClientPrivate);
+
+ /* Observer */
+
+ /* We only care about single-user text-based chats */
+ tp_base_client_take_observer_filter (TP_BASE_CLIENT (self),
+ tp_asv_new (
+ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+ TP_IFACE_CHANNEL_TYPE_TEXT,
+ TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
+ TP_HANDLE_TYPE_CONTACT,
+ NULL));
+}
+
+static void
+observe_channels (TpBaseClient *client,
+ TpAccount *account,
+ TpConnection *connection,
+ GList *channels,
+ TpChannelDispatchOperation *dispatch_operation,
+ GList *requests,
+ TpObserveChannelsContext *context)
+{
+ ShellTpClient *self = (ShellTpClient *) client;
+
+ g_assert (self->priv->observe_impl != NULL);
+
+ self->priv->observe_impl (self, account, connection, channels,
+ dispatch_operation, requests, context, self->priv->user_data_obs);
+}
+
+static void
+shell_tp_client_dispose (GObject *object)
+{
+ ShellTpClient *self = SHELL_TP_CLIENT (object);
+ void (*dispose) (GObject *) =
+ G_OBJECT_CLASS (shell_tp_client_parent_class)->dispose;
+
+ if (self->priv->destroy_obs != NULL)
+ {
+ self->priv->destroy_obs (self->priv->user_data_obs);
+ self->priv->destroy_obs = NULL;
+ }
+
+ if (dispose != NULL)
+ dispose (object);
+}
+
+static void
+shell_tp_client_class_init (ShellTpClientClass *cls)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (cls);
+ TpBaseClientClass *base_clt_cls = TP_BASE_CLIENT_CLASS (cls);
+
+ g_type_class_add_private (cls, sizeof (ShellTpClientPrivate));
+
+ object_class->dispose = shell_tp_client_dispose;
+
+ base_clt_cls->observe_channels = observe_channels;
+}
+
+/**
+ * shell_tp_client_new:
+ * @dbus: a #TpDBusDaemon object, may not be %NULL
+ *
+ * Returns: a new #ShellTpClient
+ */
+ShellTpClient *
+shell_tp_client_new (TpDBusDaemon *dbus)
+{
+ return g_object_new (SHELL_TYPE_TP_CLIENT,
+ "dbus-daemon", dbus,
+ "name", "GnomeShell",
+ "uniquify-name", TRUE,
+ NULL);
+}
+
+void
+shell_tp_client_set_observe_channels_func (ShellTpClient *self,
+ ShellTpClientObserveChannelsImpl observe_impl,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ g_assert (self->priv->observe_impl == NULL);
+
+ self->priv->observe_impl = observe_impl;
+ self->priv->user_data_obs = user_data;
+ self->priv->destroy_obs = destroy;
+}
diff --git a/src/shell-tp-client.h b/src/shell-tp-client.h
new file mode 100644
index 0000000..d9f5e18
--- /dev/null
+++ b/src/shell-tp-client.h
@@ -0,0 +1,61 @@
+#ifndef __SHELL_TP_CLIENT_H__
+#define __SHELL_TP_CLIENT_H__
+
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+
+#include <telepathy-glib/base-client.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ShellTpClient ShellTpClient;
+typedef struct _ShellTpClientClass ShellTpClientClass;
+typedef struct _ShellTpClientPrivate ShellTpClientPrivate;
+
+struct _ShellTpClientClass {
+ /*<private>*/
+ TpBaseClientClass parent_class;
+};
+
+struct _ShellTpClient {
+ /*<private>*/
+ TpBaseClient parent;
+ ShellTpClientPrivate *priv;
+};
+
+GType shell_tp_client_get_type (void);
+
+#define SHELL_TYPE_TP_CLIENT \
+ (shell_tp_client_get_type ())
+#define SHELL_TP_CLIENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHELL_TYPE_TP_CLIENT, \
+ ShellTpClient))
+#define SHELL_TP_CLIENT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_TP_CLIENT, \
+ ShellTpClientClass))
+#define SHELL_IS_TP_CLIENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHELL_TYPE_TP_CLIENT))
+#define SHELL_IS_TP_CLIENT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_TP_CLIENT))
+#define SHELL_TP_CLIENT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_TP_CLIENT, \
+ ShellTpClientClass))
+
+typedef void (*ShellTpClientObserveChannelsImpl) (ShellTpClient *client,
+ TpAccount *account,
+ TpConnection *connection,
+ GList *channels,
+ TpChannelDispatchOperation *dispatch_operation,
+ GList *requests,
+ TpObserveChannelsContext *context,
+ gpointer user_data);
+
+ShellTpClient * shell_tp_client_new (TpDBusDaemon *dbus);
+
+void shell_tp_client_set_observe_channels_func (ShellTpClient *self,
+ ShellTpClientObserveChannelsImpl observe_impl,
+ gpointer user_data,
+ GDestroyNotify destroy);
+
+G_END_DECLS
+#endif /* __SHELL_TP_CLIENT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]