[Telepathy-commits] [telepathy-salut/master] Implement 1-1 tubes

Alban Crequy alban.crequy at collabora.co.uk
Tue Nov 25 03:59:12 PST 2008


20080519172143-a41c0-dc1b60332b846aba2555f416fc0fb8999a8a173d.gz
---
 src/salut-bytestream-manager.c |   22 +++++++++++++++++-----
 src/salut-tubes-manager.c      |   28 ++++++++++++++++++++++++++++
 src/salut-tubes-manager.h      |    4 ++++
 3 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/src/salut-bytestream-manager.c b/src/salut-bytestream-manager.c
index 55d3a45..7f53bd5 100644
--- a/src/salut-bytestream-manager.c
+++ b/src/salut-bytestream-manager.c
@@ -32,6 +32,7 @@
 
 #include "salut-im-manager.h"
 #include "salut-muc-manager.h"
+#include "salut-tubes-manager.h"
 
 #define DEBUG_FLAG DEBUG_BYTESTREAM_MGR
 #include "debug.h"
@@ -379,11 +380,8 @@ si_request_cb (SalutXmppConnectionManager *xcm,
    *  - a muc tube extra bytestream offer
    */
 
-  /* TODO: implement 1-1 tubes */
-
-  node = gibber_xmpp_node_get_child_ns (si, "muc-stream",
-        GIBBER_TELEPATHY_NS_TUBES);
-  if (node != NULL)
+  if ((node = gibber_xmpp_node_get_child_ns (si, "muc-stream",
+          GIBBER_TELEPATHY_NS_TUBES)))
     {
       const gchar *muc;
       TpHandle room_handle;
@@ -412,6 +410,20 @@ si_request_cb (SalutXmppConnectionManager *xcm,
           bytestream, room_handle, stream_id, stanza);
       g_object_unref (muc_mgr);
     }
+  else if ((node = gibber_xmpp_node_get_child_ns (si, "stream",
+          GIBBER_TELEPATHY_NS_TUBES)))
+    {
+      SalutTubesManager *tubes_mgr;
+
+      g_object_get (priv->connection, "tubes-manager", &tubes_mgr, NULL);
+      g_assert (tubes_mgr != NULL);
+
+      /* The SI request is an extra bytestream for a 1-1 tube */
+      salut_tubes_manager_handle_si_stream_request (
+          tubes_mgr, bytestream, peer_handle, stream_id, stanza);
+
+      g_object_unref (tubes_mgr);
+    }
   else
     {
       GError e = { GIBBER_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
diff --git a/src/salut-tubes-manager.c b/src/salut-tubes-manager.c
index e577700..2dd7242 100644
--- a/src/salut-tubes-manager.c
+++ b/src/salut-tubes-manager.c
@@ -665,6 +665,34 @@ salut_tubes_manager_handle_tube_request (
   salut_tubes_channel_bytestream_offered (chan, bytestream, msg);
 }
 
+void salut_tubes_manager_handle_si_stream_request (SalutTubesManager *self,
+    GibberBytestreamIface *bytestream, TpHandle contact_handle,
+    const gchar *stream_id, GibberXmppStanza *msg)
+{
+  SalutTubesManagerPrivate *priv = SALUT_TUBES_MANAGER_GET_PRIVATE (self);
+  TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+     (TpBaseConnection*) &priv->conn->parent, TP_HANDLE_TYPE_CONTACT);
+  SalutTubesChannel *chan = NULL;
+
+  g_return_if_fail (tp_handle_is_valid (contact_repo, contact_handle, NULL));
+
+#ifdef ENABLE_DBUS_TUBES
+  chan = g_hash_table_lookup (priv->channels,
+      GUINT_TO_POINTER (contact_handle));
+#endif
+  if (chan == NULL)
+    {
+      GError e = { GIBBER_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+          "No tubes channel available for this contact" };
+
+      DEBUG ("tubes channel doesn't exist for contact %d", contact_handle);
+      gibber_bytestream_iface_close (bytestream, &e);
+      return;
+    }
+
+  salut_tubes_channel_bytestream_offered (chan, bytestream, msg);
+}
+
 SalutTubesManager *
 salut_tubes_manager_new (
     SalutConnection *conn,
diff --git a/src/salut-tubes-manager.h b/src/salut-tubes-manager.h
index 462e213..137f164 100644
--- a/src/salut-tubes-manager.h
+++ b/src/salut-tubes-manager.h
@@ -67,6 +67,10 @@ SalutTubesManager * salut_tubes_manager_new (
     SalutContactManager *contact_manager,
     SalutXmppConnectionManager *xmpp_connection_manager);
 
+void salut_tubes_manager_handle_si_stream_request (SalutTubesManager *self,
+    GibberBytestreamIface *bytestream, TpHandle contact_handle,
+    const gchar *stream_id, GibberXmppStanza *msg);
+
 G_END_DECLS
 
 #endif /* #ifndef __SALUT_TUBES_MANAGER_H__ */
-- 
1.5.6.5




More information about the Telepathy-commits mailing list