[telepathy-gabble/master] Look at InitialChannels and build a set of Handles

Danielle Madeley danielle.madeley at collabora.co.uk
Fri Jan 15 08:30:40 PST 2010


---
 src/im-channel.c  |   21 +++++++++++++++++++++
 src/im-channel.h  |    5 +++++
 src/muc-factory.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/im-channel.c b/src/im-channel.c
index f4edc54..996fce1 100644
--- a/src/im-channel.c
+++ b/src/im-channel.c
@@ -806,6 +806,27 @@ gabble_im_channel_get_handle (TpSvcChannel *iface,
       priv->handle);
 }
 
+TpHandle
+gabble_im_channel_local_get_handle (GabbleIMChannel *self)
+{
+  GabbleIMChannelPrivate *priv;
+
+  g_assert (GABBLE_IS_IM_CHANNEL (self)); /* ?? */
+  priv = self->priv;
+
+  return priv->handle;
+}
+
+GabbleConnection *
+gabble_im_channel_local_get_connection (GabbleIMChannel *self)
+{
+  GabbleIMChannelPrivate *priv;
+
+  g_assert (GABBLE_IS_IM_CHANNEL (self)); /* ?? */
+  priv = self->priv;
+
+  return priv->conn;
+}
 
 /**
  * gabble_im_channel_get_interfaces
diff --git a/src/im-channel.h b/src/im-channel.h
index 2a2a2dc..e222982 100644
--- a/src/im-channel.h
+++ b/src/im-channel.h
@@ -27,6 +27,8 @@
 #include <telepathy-glib/enums.h>
 #include <telepathy-glib/message-mixin.h>
 
+#include "connection.h"
+
 G_BEGIN_DECLS
 
 typedef struct _GabbleIMChannel GabbleIMChannel;
@@ -78,6 +80,9 @@ void _gabble_im_channel_receive (GabbleIMChannel *chan,
 void _gabble_im_channel_state_receive (GabbleIMChannel *chan,
     TpChannelChatState state);
 
+TpHandle gabble_im_channel_local_get_handle (GabbleIMChannel *chan);
+GabbleConnection *gabble_im_channel_local_get_connection (GabbleIMChannel *self);
+
 G_END_DECLS
 
 #endif /* #ifndef __GABBLE_IM_CHANNEL_H__*/
diff --git a/src/muc-factory.c b/src/muc-factory.c
index c4abea3..df8c5c3 100644
--- a/src/muc-factory.c
+++ b/src/muc-factory.c
@@ -39,6 +39,7 @@
 #include "conn-olpc.h"
 #include "debug.h"
 #include "disco.h"
+#include "im-channel.h"
 #include "message-util.h"
 #include "muc-channel.h"
 #include "namespaces.h"
@@ -1134,7 +1135,51 @@ handle_conference_channel (GabbleMucFactory *self,
                            TpHandle          handle,
                            GError          **error)
 {
+  GabbleMucFactoryPrivate *priv = self->priv;
+  DBusGConnection *bus = tp_get_bus ();
+  TpIntSet *handles = tp_intset_new ();
+  GPtrArray *initial_channels;
+
   g_print ("!!! handle_conference_channel\n");
+  tp_asv_dump (request_properties);
+
+  /* look at the list of initial channels, build a set of handles to invite */
+  initial_channels = tp_asv_get_boxed (request_properties,
+      GABBLE_IFACE_CHANNEL_INTERFACE_CONFERENCE ".InitialChannels",
+      TP_ARRAY_TYPE_OBJECT_PATH_LIST);
+  if (initial_channels != NULL)
+    {
+      guint i;
+
+      for (i = 0; i < initial_channels->len; i++)
+        {
+          const char *object_path = g_ptr_array_index (initial_channels, i);
+          GObject *object;
+          GabbleIMChannel *channel;
+
+          object = dbus_g_connection_lookup_g_object (bus, object_path);
+
+          /* FIXME: work with MUC channels in the future? */
+          if (!GABBLE_IS_IM_CHANNEL (object))
+            {
+              g_warning ("Channel %s is not an ImChannel, ignoring",
+                  object_path);
+              continue;
+            }
+          channel = GABBLE_IM_CHANNEL (object);
+
+          if (gabble_im_channel_local_get_connection (channel) != priv->conn)
+            {
+              g_warning ("Channel %s is from a different Connection, ignoring",
+                  object_path);
+              continue;
+            }
+
+          tp_intset_add (handles, gabble_im_channel_local_get_handle (channel));
+        }
+    }
+
+  tp_intset_destroy (handles);
 
   g_set_error (error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
       "Conference channels not implemented yet");
-- 
1.5.6.5




More information about the telepathy-commits mailing list