[Telepathy-commits] [telepathy-gabble/master] Add a straw-man API for requestotron-capable channels
Simon McVittie
simon.mcvittie at collabora.co.uk
Tue Aug 19 10:54:19 PDT 2008
20080724172700-53eee-04e4eed48957dd258db10b6b571f766e90fd7290.gz
---
src/Makefile.am | 2 +
src/exportable-channel.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++
src/exportable-channel.h | 54 +++++++++++++++++++
3 files changed, 188 insertions(+), 0 deletions(-)
create mode 100644 src/exportable-channel.c
create mode 100644 src/exportable-channel.h
diff --git a/src/Makefile.am b/src/Makefile.am
index a08c5ec..b16c3b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,6 +51,8 @@ libgabble_convenience_la_our_sources = \
disco.c \
error.c \
error.h \
+ exportable-channel.c \
+ exportable-channel.h \
gabble.c \
gabble.h \
im-channel.h \
diff --git a/src/exportable-channel.c b/src/exportable-channel.c
new file mode 100644
index 0000000..f8693af
--- /dev/null
+++ b/src/exportable-channel.c
@@ -0,0 +1,132 @@
+/*
+ * 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>
+
+enum {
+ CLOSED,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0 };
+
+
+static void
+exportable_channel_base_init (gpointer klass)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized)
+ {
+ GParamSpec *param_spec;
+
+ initialized = TRUE;
+
+ /**
+ * GabbleExportableChannel: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);
+
+ /**
+ * GabbleExportableChannel: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_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);
+
+ /**
+ * GabbleExportableChannel:channel-destroyed:
+ *
+ * If true, the closed signal 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);
+
+ /**
+ * GabbleExportableChannel::closed:
+ *
+ * The channel has "closed" for the purposes of the D-Bus API. However,
+ * if channel-destroyed is false, the Connection should immediately
+ * signal that it has been re-created.
+ */
+ signals[CLOSED] = g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ }
+}
+
+GType
+gabble_exportable_channel_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ static const GTypeInfo info = {
+ sizeof (GabbleExportableChannelIface),
+ 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,
+ "GabbleExportableChannel", &info, 0);
+ }
+
+ return type;
+}
diff --git a/src/exportable-channel.h b/src/exportable-channel.h
new file mode 100644
index 0000000..bbe3e80
--- /dev/null
+++ b/src/exportable-channel.h
@@ -0,0 +1,54 @@
+/*
+ * 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 GABBLE_EXPORTABLE_CHANNEL_H
+#define GABBLE_EXPORTABLE_CHANNEL_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GABBLE_TYPE_EXPORTABLE_CHANNEL (gabble_exportable_channel_get_type ())
+
+#define GABBLE_EXPORTABLE_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ GABBLE_TYPE_EXPORTABLE_CHANNEL, GabbleExportableChannel))
+
+#define GABBLE_IS_EXPORTABLE_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ GABBLE_TYPE_EXPORTABLE_CHANNEL))
+
+#define GABBLE_EXPORTABLE_CHANNEL_GET_INTERFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+ GABBLE_TYPE_EXPORTABLE_CHANNEL, GabbleExportableChannelIface))
+
+typedef struct _GabbleExportableChannel GabbleExportableChannel;
+typedef struct _GabbleExportableChannelIface GabbleExportableChannelIface;
+
+struct _GabbleExportableChannelIface {
+ GTypeInterface parent;
+};
+
+GType gabble_exportable_channel_get_type (void);
+
+G_END_DECLS
+
+#endif
--
1.5.6.3
More information about the Telepathy-commits
mailing list