[Telepathy-commits] [telepathy-gabble/master] Tube factory implement its part of GetContactCapabilities, reading the Presence structure
Alban Crequy
alban.crequy at collabora.co.uk
Fri Dec 5 09:42:28 PST 2008
---
src/channel-manager.c | 3 +-
src/channel-manager.h | 7 +++-
src/connection.c | 3 +-
src/im-factory.c | 1 +
src/private-tubes-factory.c | 70 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/src/channel-manager.c b/src/channel-manager.c
index 0836f4a..dd94b74 100644
--- a/src/channel-manager.c
+++ b/src/channel-manager.c
@@ -348,6 +348,7 @@ gabble_channel_manager_emit_request_failed_printf (gpointer instance,
void gabble_channel_manager_get_contact_capabilities (
GabbleChannelManager *manager,
+ GabbleConnection *conn,
TpHandle handle,
GPtrArray *arr)
{
@@ -357,7 +358,7 @@ void gabble_channel_manager_get_contact_capabilities (
if (method != NULL)
{
- method (manager, handle, arr);
+ method (manager, conn, handle, arr);
}
/* ... else assume there is not caps for this kind of channels */
}
diff --git a/src/channel-manager.h b/src/channel-manager.h
index b83c61e..d0f982d 100644
--- a/src/channel-manager.h
+++ b/src/channel-manager.h
@@ -27,6 +27,7 @@
#include <telepathy-glib/handle.h>
#include "exportable-channel.h"
+#include "types.h"
G_BEGIN_DECLS
@@ -51,10 +52,12 @@ typedef struct _GabbleChannelManagerIface GabbleChannelManagerIface;
/* virtual methods */
typedef void (*GabbleChannelManagerGetContactCapsFunc) (
- GabbleChannelManager *manager, TpHandle handle, GPtrArray *arr);
+ GabbleChannelManager *manager, GabbleConnection *conn, TpHandle handle,
+ GPtrArray *arr);
void gabble_channel_manager_get_contact_capabilities (
- GabbleChannelManager *manager, TpHandle handle, GPtrArray *arr);
+ GabbleChannelManager *manager, GabbleConnection *conn, TpHandle handle,
+ GPtrArray *arr);
typedef void (*GabbleChannelManagerForeachChannelFunc) (
GabbleChannelManager *manager, GabbleExportableChannelFunc func,
diff --git a/src/connection.c b/src/connection.c
index 69da6b2..9dab762 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2354,7 +2354,8 @@ gabble_connection_get_handle_contact_capabilities (GabbleConnection *self,
GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (
g_ptr_array_index (self->channel_managers, i));
- gabble_channel_manager_get_contact_capabilities (manager, handle, arr);
+ gabble_channel_manager_get_contact_capabilities (manager, self, handle,
+ arr);
}
}
diff --git a/src/im-factory.c b/src/im-factory.c
index d95594e..76b233d 100644
--- a/src/im-factory.c
+++ b/src/im-factory.c
@@ -455,6 +455,7 @@ connection_status_changed_cb (GabbleConnection *conn,
static void
gabble_im_factory_get_contact_caps (GabbleChannelManager *manager,
+ GabbleConnection *conn,
TpHandle handle,
GPtrArray *arr)
{
diff --git a/src/private-tubes-factory.c b/src/private-tubes-factory.c
index 85c2d2e..b49f629 100644
--- a/src/private-tubes-factory.c
+++ b/src/private-tubes-factory.c
@@ -21,6 +21,7 @@
#include "private-tubes-factory.h"
#include <string.h>
+#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
@@ -40,6 +41,7 @@
#include "muc-channel.h"
#include "muc-factory.h"
#include "namespaces.h"
+#include "presence-cache.h"
#include "tubes-channel.h"
#include "util.h"
@@ -362,6 +364,73 @@ gabble_private_tubes_factory_close_all (GabblePrivateTubesFactory *fac)
}
}
+static void
+gabble_private_tubes_factory_get_contact_caps (GabbleChannelManager *manager,
+ GabbleConnection *conn,
+ 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",
+ GABBLE_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service",
+ NULL
+ };
+ GabblePresence *presence;
+ GHashTableIter tube_caps_iter;
+ gchar *service;
+ gpointer dummy;
+
+ g_assert (handle != 0);
+
+ presence = gabble_presence_cache_get (conn->presence_cache, handle);
+
+ g_hash_table_iter_init (&tube_caps_iter, presence->stream_tube_caps);
+ while (g_hash_table_iter_next (&tube_caps_iter, &service, &dummy))
+ {
+ 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,
+ GABBLE_IFACE_CHANNEL_TYPE_STREAM_TUBE);
+ 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);
+
+ target_handle_type_value = tp_g_value_slice_new (G_TYPE_UINT);
+ g_value_set_string (target_handle_type_value, service);
+ g_hash_table_insert (fixed_properties,
+ GABBLE_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service",
+ 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
{
GabbleExportableChannelFunc foreach;
@@ -782,6 +851,7 @@ channel_manager_iface_init (gpointer g_iface,
{
GabbleChannelManagerIface *iface = g_iface;
+ iface->get_contact_caps = gabble_private_tubes_factory_get_contact_caps;
iface->foreach_channel = gabble_private_tubes_factory_foreach_channel;
iface->foreach_channel_class =
gabble_private_tubes_factory_foreach_channel_class;
--
1.5.6.5
More information about the Telepathy-commits
mailing list