[Telepathy-commits] [telepathy-gabble/master] bytestream-multiple: implement block_reading

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Tue Mar 3 07:26:30 PST 2009


---
 src/bytestream-multiple.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/bytestream-multiple.c b/src/bytestream-multiple.c
index 1184577..2d08ea9 100644
--- a/src/bytestream-multiple.c
+++ b/src/bytestream-multiple.c
@@ -75,6 +75,7 @@ struct _GabbleBytestreamMultiplePrivate
   /* List of (gchar *) containing the NS of a stream method */
   GList *fallback_stream_methods;
   GabbleBytestreamIface *active_bytestream;
+  gboolean read_blocked;
 
   gboolean dispose_has_run;
 };
@@ -562,6 +563,10 @@ bytestream_activate_next (GabbleBytestreamMultiple *self)
 
   g_free (stream_method);
 
+  /* block the new bytestream if needed */
+  gabble_bytestream_iface_block_reading (priv->active_bytestream,
+      priv->read_blocked);
+
   g_signal_connect (priv->active_bytestream, "connection-error",
       G_CALLBACK (bytestream_connection_error_cb), self);
   g_signal_connect (priv->active_bytestream, "data-received",
@@ -610,6 +615,23 @@ gabble_bytestream_multiple_has_stream_method (GabbleBytestreamMultiple *self)
 }
 
 static void
+gabble_bytestream_multiple_block_reading (GabbleBytestreamIface *iface,
+                                          gboolean block)
+{
+  GabbleBytestreamMultiple *self = GABBLE_BYTESTREAM_MULTIPLE (iface);
+  GabbleBytestreamMultiplePrivate *priv =
+    GABBLE_BYTESTREAM_MULTIPLE_GET_PRIVATE (self);
+
+  if (priv->read_blocked == block)
+    return;
+
+  priv->read_blocked = block;
+
+  g_assert (priv->active_bytestream != NULL);
+  gabble_bytestream_iface_block_reading (priv->active_bytestream, block);
+}
+
+static void
 bytestream_iface_init (gpointer g_iface,
                        gpointer iface_data)
 {
@@ -619,4 +641,5 @@ bytestream_iface_init (gpointer g_iface,
   klass->send = gabble_bytestream_multiple_send;
   klass->close = gabble_bytestream_multiple_close;
   klass->accept = gabble_bytestream_multiple_accept;
+  klass->block_reading = gabble_bytestream_multiple_block_reading;
 }
-- 
1.5.6.5




More information about the telepathy-commits mailing list