[Telepathy-commits] [telepathy-glib/master] Add TpExportableChannel interface

Will Thompson will.thompson at collabora.co.uk
Thu Sep 4 01:50:23 PDT 2008


---
 telepathy-glib/Makefile.am          |    2 +
 telepathy-glib/exportable-channel.c |  150 +++++++++++++++++++++++++++++++++++
 telepathy-glib/exportable-channel.h |   61 ++++++++++++++
 3 files changed, 213 insertions(+), 0 deletions(-)
 create mode 100644 telepathy-glib/exportable-channel.c
 create mode 100644 telepathy-glib/exportable-channel.h

diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am
index 288c3e0..df5639d 100644
--- a/telepathy-glib/Makefile.am
+++ b/telepathy-glib/Makefile.am
@@ -112,6 +112,7 @@ tpginclude_HEADERS = \
     debug-ansi.h \
     enums.h \
     errors.h \
+    exportable-channel.h \
     group-mixin.h \
     gtypes.h \
     handle.h \
@@ -215,6 +216,7 @@ libtelepathy_glib_internal_la_SOURCES = \
     interfaces.c \
     debug-internal.h \
     errors.c \
+    exportable-channel.c \
     group-mixin.c \
     gtypes.c \
     handle.c \
diff --git a/telepathy-glib/exportable-channel.c b/telepathy-glib/exportable-channel.c
new file mode 100644
index 0000000..56e885c
--- /dev/null
+++ b/telepathy-glib/exportable-channel.c
@@ -0,0 +1,150 @@
+/*
+ * exportable-channel.c - A channel usable with the Channel Manager
+ *
+ * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "exportable-channel.h"
+
+#include <telepathy-glib/gtypes.h>
+#include <telepathy-glib/svc-channel.h>
+#include <telepathy-glib/util.h>
+
+
+static void
+exportable_channel_base_init (gpointer klass)
+{
+  static gboolean initialized = FALSE;
+
+  if (!initialized)
+    {
+      GParamSpec *param_spec;
+
+      initialized = TRUE;
+
+      /**
+       * TpExportableChannel:object-path:
+       *
+       * The D-Bus object path used for this object on the bus. Read-only
+       * except during construction.
+       */
+      param_spec = g_param_spec_string ("object-path", "D-Bus object path",
+          "The D-Bus object path used for this object on the bus.", NULL,
+          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+          G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK);
+      g_object_interface_install_property (klass, param_spec);
+
+      /**
+       * TpExportableChannel:channel-properties:
+       *
+       * The D-Bus properties to be announced in the NewChannels signal
+       * and in the Channels property, as a map from
+       * inter.face.name.propertyname to GValue.
+       *
+       * This can only change when the closed signal is emitted.
+       */
+      param_spec = g_param_spec_boxed ("channel-properties",
+          "Channel properties",
+          "The channel properties",
+          TP_HASH_TYPE_QUALIFIED_PROPERTY_VALUE_MAP,
+          G_PARAM_READABLE |
+          G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK);
+      g_object_interface_install_property (klass, param_spec);
+
+      /**
+       * TpExportableChannel:channel-destroyed:
+       *
+       * If true, the closed signal on the Channel interface indicates that
+       * the channel can go away.
+       *
+       * If false, the closed signal indicates that the channel should
+       * appear to go away and be re-created.
+       */
+      param_spec = g_param_spec_boolean ("channel-destroyed",
+          "Destroyed?",
+          "If true, the channel has *really* closed, rather than just "
+          "appearing to do so",
+          FALSE,
+          G_PARAM_READABLE |
+          G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK);
+      g_object_interface_install_property (klass, param_spec);
+    }
+}
+
+GType
+tp_exportable_channel_get_type (void)
+{
+  static GType type = 0;
+
+  if (G_UNLIKELY (type == 0))
+    {
+      static const GTypeInfo info = {
+        sizeof (TpExportableChannelIface),
+        exportable_channel_base_init,   /* base_init */
+        NULL,   /* base_finalize */
+        NULL,   /* class_init */
+        NULL,   /* class_finalize */
+        NULL,   /* class_data */
+        0,
+        0,      /* n_preallocs */
+        NULL    /* instance_init */
+      };
+
+      type = g_type_register_static (G_TYPE_INTERFACE,
+          "TpExportableChannel", &info, 0);
+
+      g_type_interface_add_prerequisite (type, TP_TYPE_SVC_CHANNEL);
+    }
+
+  return type;
+}
+
+GHashTable *
+tp_dbus_properties_mixin_make_properties_hash (
+    GObject *object,
+    const gchar *first_interface,
+    const gchar *first_property,
+    ...)
+{
+  va_list ap;
+  GHashTable *table;
+  const gchar *interface, *property;
+
+  table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
+      (GDestroyNotify) tp_g_value_slice_free);
+
+  va_start (ap, first_property);
+
+  for (interface = first_interface, property = first_property;
+       interface != NULL;
+       interface = va_arg (ap, gchar *), property = va_arg (ap, gchar *))
+    {
+      GValue *value = g_slice_new0 (GValue);
+
+      tp_dbus_properties_mixin_get (object, interface, property,
+            value, NULL);
+      /* Fetching our immutable properties had better not fail... */
+      g_assert (G_IS_VALUE (value));
+
+      g_hash_table_insert (table,
+          g_strdup_printf ("%s.%s", interface, property), value);
+    }
+
+  return table;
+}
diff --git a/telepathy-glib/exportable-channel.h b/telepathy-glib/exportable-channel.h
new file mode 100644
index 0000000..b09142e
--- /dev/null
+++ b/telepathy-glib/exportable-channel.h
@@ -0,0 +1,61 @@
+/*
+ * exportable-channel.h - A channel usable with the Channel Manager
+ *
+ * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef TP_EXPORTABLE_CHANNEL_H
+#define TP_EXPORTABLE_CHANNEL_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TP_TYPE_EXPORTABLE_CHANNEL (tp_exportable_channel_get_type ())
+
+#define TP_EXPORTABLE_CHANNEL(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  TP_TYPE_EXPORTABLE_CHANNEL, TpExportableChannel))
+
+#define TP_IS_EXPORTABLE_CHANNEL(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  TP_TYPE_EXPORTABLE_CHANNEL))
+
+#define TP_EXPORTABLE_CHANNEL_GET_INTERFACE(obj) \
+  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+  TP_TYPE_EXPORTABLE_CHANNEL, TpExportableChannelIface))
+
+typedef struct _TpExportableChannel TpExportableChannel;
+typedef struct _TpExportableChannelIface TpExportableChannelIface;
+
+typedef void (*TpExportableChannelFunc) (TpExportableChannel *channel,
+    gpointer user_data);
+
+struct _TpExportableChannelIface {
+    GTypeInterface parent;
+};
+
+GType tp_exportable_channel_get_type (void);
+
+GHashTable *tp_dbus_properties_mixin_make_properties_hash (
+    GObject *object, const gchar *first_interface,
+    const gchar *first_property, ...) G_GNUC_NULL_TERMINATED;
+
+G_END_DECLS
+
+#endif
-- 
1.5.6.5




More information about the Telepathy-commits mailing list