[Telepathy-commits] [telepathy-gabble/master] Each channel factories add its own set of caps for a contact handle
Alban Crequy
alban.crequy at collabora.co.uk
Fri Dec 5 09:42:28 PST 2008
---
src/channel-manager.c | 15 ++++++++++++++
src/channel-manager.h | 9 ++++++++
src/connection.c | 47 ++++++--------------------------------------
src/im-factory.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+), 40 deletions(-)
diff --git a/src/channel-manager.c b/src/channel-manager.c
index 230162f..0836f4a 100644
--- a/src/channel-manager.c
+++ b/src/channel-manager.c
@@ -346,6 +346,21 @@ gabble_channel_manager_emit_request_failed_printf (gpointer instance,
/* Virtual-method wrappers */
+void gabble_channel_manager_get_contact_capabilities (
+ GabbleChannelManager *manager,
+ TpHandle handle,
+ GPtrArray *arr)
+{
+ GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
+ manager);
+ GabbleChannelManagerGetContactCapsFunc method = iface->get_contact_caps;
+
+ if (method != NULL)
+ {
+ method (manager, handle, arr);
+ }
+ /* ... else assume there is not caps for this kind of channels */
+}
void
gabble_channel_manager_foreach_channel (GabbleChannelManager *manager,
diff --git a/src/channel-manager.h b/src/channel-manager.h
index 4dfb091..b83c61e 100644
--- a/src/channel-manager.h
+++ b/src/channel-manager.h
@@ -24,6 +24,7 @@
#define GABBLE_CHANNEL_MANAGER_H
#include <glib-object.h>
+#include <telepathy-glib/handle.h>
#include "exportable-channel.h"
@@ -49,6 +50,12 @@ typedef struct _GabbleChannelManagerIface GabbleChannelManagerIface;
/* virtual methods */
+typedef void (*GabbleChannelManagerGetContactCapsFunc) (
+ GabbleChannelManager *manager, TpHandle handle, GPtrArray *arr);
+
+void gabble_channel_manager_get_contact_capabilities (
+ GabbleChannelManager *manager, TpHandle handle, GPtrArray *arr);
+
typedef void (*GabbleChannelManagerForeachChannelFunc) (
GabbleChannelManager *manager, GabbleExportableChannelFunc func,
gpointer user_data);
@@ -87,6 +94,8 @@ gboolean gabble_channel_manager_request_channel (GabbleChannelManager *manager,
struct _GabbleChannelManagerIface {
GTypeInterface parent;
+ GabbleChannelManagerGetContactCapsFunc get_contact_caps;
+
GabbleChannelManagerForeachChannelFunc foreach_channel;
GabbleChannelManagerForeachChannelClassFunc foreach_channel_class;
diff --git a/src/connection.c b/src/connection.c
index fb90c41..69da6b2 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2347,48 +2347,15 @@ static void
gabble_connection_get_handle_contact_capabilities (GabbleConnection *self,
TpHandle handle, GPtrArray *arr)
{
- GValue monster = {0, };
- GHashTable *fixed_properties;
- GValue *channel_type_value;
- GValue *target_handle_type_value;
- gchar *text_allowed_properties[] =
- {
- TP_IFACE_CHANNEL ".TargetHandle",
- NULL
- };
-
- g_assert (handle != 0);
-
- g_value_init (&monster, GABBLE_STRUCT_TYPE_ENHANCED_CONTACT_CAPABILITY);
- g_value_take_boxed (&monster,
- dbus_g_type_specialized_construct (
- GABBLE_STRUCT_TYPE_ENHANCED_CONTACT_CAPABILITY));
-
- /* assume text channel */
- fixed_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- channel_type_value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (channel_type_value, TP_IFACE_CHANNEL_TYPE_TEXT);
- g_hash_table_insert (fixed_properties, TP_IFACE_CHANNEL ".ChannelType",
- channel_type_value);
-
- target_handle_type_value = tp_g_value_slice_new (G_TYPE_UINT);
- g_value_set_uint (target_handle_type_value, TP_HANDLE_TYPE_CONTACT);
- g_hash_table_insert (fixed_properties, TP_IFACE_CHANNEL ".TargetHandleType",
- target_handle_type_value);
-
- dbus_g_type_struct_set (&monster,
- 0, handle,
- 1, fixed_properties,
- 2, text_allowed_properties,
- G_MAXUINT);
-
- g_hash_table_destroy (fixed_properties);
+ guint i;
- g_ptr_array_add (arr, g_value_get_boxed (&monster));
+ for (i = 0; i < self->channel_managers->len; i++)
+ {
+ GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (
+ g_ptr_array_index (self->channel_managers, i));
- /* FIXME: each kind of caps should be filled by channel managers */
+ gabble_channel_manager_get_contact_capabilities (manager, handle, arr);
+ }
}
diff --git a/src/im-factory.c b/src/im-factory.c
index e9ac1c1..d95594e 100644
--- a/src/im-factory.c
+++ b/src/im-factory.c
@@ -32,6 +32,8 @@
#define DEBUG_FLAG GABBLE_DEBUG_IM
+#include "extensions/extensions.h"
+
#include "channel-manager.h"
#include "connection.h"
#include "debug.h"
@@ -451,6 +453,54 @@ connection_status_changed_cb (GabbleConnection *conn,
}
}
+static void
+gabble_im_factory_get_contact_caps (GabbleChannelManager *manager,
+ TpHandle handle,
+ GPtrArray *arr)
+{
+ /* We don't need to check this contact's capabilities, we assume every
+ * contact support text channels. */
+
+ GValue monster = {0, };
+ GHashTable *fixed_properties;
+ GValue *channel_type_value;
+ GValue *target_handle_type_value;
+ gchar *text_allowed_properties[] =
+ {
+ TP_IFACE_CHANNEL ".TargetHandle",
+ NULL
+ };
+
+ g_assert (handle != 0);
+
+ g_value_init (&monster, GABBLE_STRUCT_TYPE_ENHANCED_CONTACT_CAPABILITY);
+ g_value_take_boxed (&monster,
+ dbus_g_type_specialized_construct (
+ GABBLE_STRUCT_TYPE_ENHANCED_CONTACT_CAPABILITY));
+
+ fixed_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify) tp_g_value_slice_free);
+
+ channel_type_value = tp_g_value_slice_new (G_TYPE_STRING);
+ g_value_set_static_string (channel_type_value, TP_IFACE_CHANNEL_TYPE_TEXT);
+ g_hash_table_insert (fixed_properties, TP_IFACE_CHANNEL ".ChannelType",
+ channel_type_value);
+
+ target_handle_type_value = tp_g_value_slice_new (G_TYPE_UINT);
+ g_value_set_uint (target_handle_type_value, TP_HANDLE_TYPE_CONTACT);
+ g_hash_table_insert (fixed_properties, TP_IFACE_CHANNEL ".TargetHandleType",
+ target_handle_type_value);
+
+ dbus_g_type_struct_set (&monster,
+ 0, handle,
+ 1, fixed_properties,
+ 2, text_allowed_properties,
+ G_MAXUINT);
+
+ g_hash_table_destroy (fixed_properties);
+
+ g_ptr_array_add (arr, g_value_get_boxed (&monster));
+}
struct _ForeachData
{
@@ -604,6 +654,7 @@ channel_manager_iface_init (gpointer g_iface,
{
GabbleChannelManagerIface *iface = g_iface;
+ iface->get_contact_caps = gabble_im_factory_get_contact_caps;
iface->foreach_channel = gabble_im_factory_foreach_channel;
iface->foreach_channel_class = gabble_im_factory_foreach_channel_class;
iface->create_channel = gabble_im_factory_create_channel;
--
1.5.6.5
More information about the Telepathy-commits
mailing list