[Telepathy-commits] [telepathy-gabble/master] GabbleExportableChannel: add convenience API for implementors to use
Simon McVittie
simon.mcvittie at collabora.co.uk
Tue Aug 19 10:54:18 PDT 2008
20080725150918-53eee-d15367cc045b44cc502232c030a69a8082974e25.gz
---
src/exportable-channel.c | 35 +++++++++++++++++++++++++++++++++++
src/exportable-channel.h | 4 ++++
src/im-channel.c | 46 +++++++++-------------------------------------
3 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/src/exportable-channel.c b/src/exportable-channel.c
index d1a05e1..4738a46 100644
--- a/src/exportable-channel.c
+++ b/src/exportable-channel.c
@@ -24,6 +24,7 @@
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/svc-channel.h>
+#include <telepathy-glib/util.h>
static void
@@ -113,3 +114,37 @@ gabble_exportable_channel_get_type (void)
return type;
}
+
+GHashTable *
+gabble_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/src/exportable-channel.h b/src/exportable-channel.h
index bbe3e80..8bdd94b 100644
--- a/src/exportable-channel.h
+++ b/src/exportable-channel.h
@@ -49,6 +49,10 @@ struct _GabbleExportableChannelIface {
GType gabble_exportable_channel_get_type (void);
+GHashTable *gabble_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
diff --git a/src/im-channel.c b/src/im-channel.c
index ecab23e..8e14bb1 100644
--- a/src/im-channel.c
+++ b/src/im-channel.c
@@ -158,42 +158,6 @@ gabble_im_channel_constructor (GType type, guint n_props,
}
-static GHashTable *
-gabble_im_channel_dup_channel_properties (GabbleIMChannel *self)
-{
- static const gchar * const properties[] = {
- TP_IFACE_CHANNEL, "TargetHandle",
- TP_IFACE_CHANNEL, "TargetHandleType",
- TP_IFACE_CHANNEL, "ChannelType",
- GABBLE_IFACE_CHANNEL_FUTURE, "TargetID",
- GABBLE_IFACE_CHANNEL_FUTURE, "InitiatorHandle",
- GABBLE_IFACE_CHANNEL_FUTURE, "InitiatorID",
- GABBLE_IFACE_CHANNEL_FUTURE, "Requested",
- NULL
- };
- const gchar * const *iter;
- GHashTable *table;
-
- table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
- (GDestroyNotify) tp_g_value_slice_free);
-
- for (iter = properties; iter[0] != NULL; iter += 2)
- {
- GValue *value = g_slice_new0 (GValue);
-
- tp_dbus_properties_mixin_get ((GObject *) self, iter[0], iter[1],
- 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", iter[0], iter[1]),
- value);
- }
-
- return table;
-}
-
-
static void
gabble_im_channel_get_property (GObject *object,
guint property_id,
@@ -252,7 +216,15 @@ gabble_im_channel_get_property (GObject *object,
break;
case PROP_CHANNEL_PROPERTIES:
g_value_set_boxed (value,
- gabble_im_channel_dup_channel_properties (chan));
+ gabble_tp_dbus_properties_mixin_make_properties_hash (object,
+ TP_IFACE_CHANNEL, "TargetHandle",
+ TP_IFACE_CHANNEL, "TargetHandleType",
+ TP_IFACE_CHANNEL, "ChannelType",
+ GABBLE_IFACE_CHANNEL_FUTURE, "TargetID",
+ GABBLE_IFACE_CHANNEL_FUTURE, "InitiatorHandle",
+ GABBLE_IFACE_CHANNEL_FUTURE, "InitiatorID",
+ GABBLE_IFACE_CHANNEL_FUTURE, "Requested",
+ NULL));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
--
1.5.6.3
More information about the Telepathy-commits
mailing list