[Telepathy] review: bytestream/SI

Dafydd Harries dafydd.harries at collabora.co.uk
Tue Apr 3 13:04:26 PDT 2007


Here's a review of the bytestream/SI portions of the patch at:

http://projects.collabora.co.uk/~monkey/telepathy-gabble-tubes-ibb/

Guillaume,

If there are comments which no longer apply in your version of the code,
please ignore them.

General comments:

 - s/negociate/negotiate/
 - s/\s+$//

Summary:

 - mostly cosmetic issues
 - some potential crashes
 - some API that seems strange: the role of the bytestream factory isn't very
   clear

Perhaps some of this code would be nicer if there was a general bytestream
GInterface. I don't think we can quite reduce it to GIOChannel because there's
stuff like the stream ID.

I think something similar would make sense for tubes too.

diff -rN -u -p old-tmp0ucgab/src/bytestream-factory.c new-tmp0ucgab/src/bytestream-factory.c
--- old-tmp0ucgab/src/bytestream-factory.c	1970-01-01 01:00:00.000000000 +0100
+++ new-tmp0ucgab/src/bytestream-factory.c	2007-04-03 20:06:21.482960234 +0100
@@ -0,0 +1,391 @@
+/*
+ * bytestream-factory.c - Source for GabbleBytestreamFactory
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include <loudmouth/loudmouth.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_BYTESTREAM
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "handles.h"
+#include "bytestream-ibb.h"
+#include "bytestream-factory.h"
+#include "streaminit.h"
+#include "namespaces.h"
+#include "util.h"
+#include <telepathy-glib/interfaces.h>
+
+G_DEFINE_TYPE (GabbleBytestreamFactory, gabble_bytestream_factory, G_TYPE_OBJECT)
+
+/* properties */
+enum
+{
+  PROP_CONNECTION = 1,
+  LAST_PROPERTY
+};
+
+typedef struct _GabbleBytestreamFactoryPrivate GabbleBytestreamFactoryPrivate;
+struct _GabbleBytestreamFactoryPrivate
+{
+  GabbleConnection *conn;
+  LmMessageHandler *iq_cb;
+  LmMessageHandler *message_cb;
+
+  GHashTable *ibb_bytestreams;
+
+  gboolean dispose_has_run;
+};
+
+#define GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE(obj) \
+    ((GabbleBytestreamFactoryPrivate *)obj->priv)
+
+static GObject *gabble_bytestream_factory_constructor (GType type,
+                                                       guint n_props,
+                                                       GObjectConstructParam *props);
+static LmHandlerResult
+bytestream_factory_message_cb (LmMessageHandler *handler,
+                               LmConnection *lmconn,
+                               LmMessage *message,
+                               gpointer user_data);
+
+static LmHandlerResult
+bytestream_factory_iq_cb (LmMessageHandler *handler,
+                          LmConnection *lmconn,
+                          LmMessage *message,
+                          gpointer user_data);
+
+
+static void
+gabble_bytestream_factory_init (GabbleBytestreamFactory *self)
+{
+  GabbleBytestreamFactoryPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+      GABBLE_TYPE_BYTESTREAM_FACTORY, GabbleBytestreamFactoryPrivate);
+
+  self->priv = priv;
+
+  priv->ibb_bytestreams = g_hash_table_new_full (g_str_hash, g_str_equal,
+      g_free, g_object_unref);
+
+  priv->iq_cb = NULL;
+  priv->message_cb = NULL;
+
+  priv->conn = NULL;
+  priv->dispose_has_run = FALSE;
+}
+
+static GObject *
+gabble_bytestream_factory_constructor (GType type, guint n_props,
+                                  GObjectConstructParam *props)

Please fix indentation.

+{
+  GObject *obj;
+  GabbleBytestreamFactory *self;
+  GabbleBytestreamFactoryPrivate *priv;
+
+  obj = G_OBJECT_CLASS (gabble_bytestream_factory_parent_class)->
+           constructor (type, n_props, props);
+
+  self = GABBLE_BYTESTREAM_FACTORY (obj);
+  priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+
+  priv->message_cb = lm_message_handler_new (bytestream_factory_message_cb,
+      self, NULL);
+  lm_connection_register_message_handler (priv->conn->lmconn, priv->message_cb,
+      LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_FIRST);
+
+  priv->iq_cb = lm_message_handler_new (bytestream_factory_iq_cb, self, NULL);
+  lm_connection_register_message_handler (priv->conn->lmconn, priv->iq_cb,
+      LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_FIRST);
+
+  return obj;
+}

WTF.

+static void
+gabble_bytestream_factory_dispose (GObject *object)
+{
+  GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (object);
+  GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+
+  if (priv->dispose_has_run)
+    return;
+
+  DEBUG ("dispose called");
+  priv->dispose_has_run = TRUE;
+
+  lm_connection_unregister_message_handler (priv->conn->lmconn,
+      priv->message_cb, LM_MESSAGE_TYPE_MESSAGE);
+  lm_message_handler_unref (priv->message_cb);
+
+  lm_connection_unregister_message_handler (priv->conn->lmconn,
+      priv->iq_cb, LM_MESSAGE_TYPE_IQ);
+  lm_message_handler_unref (priv->iq_cb);
+
+  g_hash_table_destroy (priv->ibb_bytestreams);
+  priv->ibb_bytestreams = NULL;
+
+  if (G_OBJECT_CLASS (gabble_bytestream_factory_parent_class)->dispose)
+    G_OBJECT_CLASS (gabble_bytestream_factory_parent_class)->dispose (object);
+}
+
+static void
+gabble_bytestream_factory_get_property (GObject    *object,
+                                        guint       property_id,
+                                        GValue     *value,
+                                        GParamSpec *pspec)

Please, no extra spaces between type and name.

+{
+  GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (object);
+  GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+
+  switch (property_id) {

Opening bracket should be on next line.

+    case PROP_CONNECTION:
+      g_value_set_object (value, priv->conn);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void
+gabble_bytestream_factory_set_property (GObject      *object,
+                                        guint         property_id,
+                                        const GValue *value,
+                                        GParamSpec   *pspec)

Whitespace.

+{
+  GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (object);
+  GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+
+  switch (property_id) {

Indentation.

+    case PROP_CONNECTION:
+      priv->conn = g_value_get_object (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void
+gabble_bytestream_factory_class_init (GabbleBytestreamFactoryClass *gabble_bytestream_factory_class)

Please wrap this line.

+{
+  GObjectClass *object_class = G_OBJECT_CLASS (gabble_bytestream_factory_class);
+  GParamSpec *param_spec;
+
+  g_type_class_add_private (gabble_bytestream_factory_class, sizeof (GabbleBytestreamFactoryPrivate));
+
+  object_class->constructor = gabble_bytestream_factory_constructor;
+  object_class->dispose = gabble_bytestream_factory_dispose;
+
+  object_class->get_property = gabble_bytestream_factory_get_property;
+  object_class->set_property = gabble_bytestream_factory_set_property;
+
+  param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+                                    "Gabble connection object that owns this "
+                                    "Bytestream channel factory object.",
+                                    GABBLE_TYPE_CONNECTION,
+                                    G_PARAM_CONSTRUCT_ONLY |
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB);

I think this should be indented to +4 characters like other long function
calls. There's a lot of code that doesn't do this yet, but we should use it
for new code.

"Gabble connection objhect that owns this Bytestream channel factory object."

 - this is not a channel factory
 - "Bytestream" should not be capitalised

+  g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+}
+
+/**
+ * bytestream_factory_iq_cb:
+ *
+ * Called by loudmouth when we get an incoming <message>.
+ * This handler is concerned with Stream Initiation requests.
+ *
+ */
+
+static LmHandlerResult
+bytestream_factory_iq_cb (LmMessageHandler *handler,
+                          LmConnection *lmconn,
+                          LmMessage *message,
+                          gpointer user_data)
+{
+  // TODO remove from tubes factory !
+  /*
+  GabbleBytestreamFactory *fac = GABBLE_BYTESTREAM_FACTORY (user_data);
+  GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (fac);
+  TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+      (TpBaseConnection *)priv->conn, TP_HANDLE_TYPE_CONTACT);
+
+  const gchar *from, *profile, *stream_id, *mime_type;
+  GSList *stream_methods = NULL;
+  TpHandle handle;
+
+  if (!gabble_streaminit_parse_message(message, &profile, &from, &stream_id,
+        &mime_type, &stream_methods))
+    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+  if (strcmp (profile, NS_SI_BYTESTREAM) != 0)
+    {
+      g_slist_free (stream_methods);
+      return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+    }
+
+  handle = tp_handle_lookup (contact_repo, from, NULL, NULL);
+
+  */
+  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}

WTF

+/**
+ * bytestream_factory_message_cb
+ *
+ * Called by loudmouth when we get an incoming <message>.
+ */
+static LmHandlerResult
+bytestream_factory_message_cb (LmMessageHandler *handler,
+                               LmConnection *lmconn,
+                               LmMessage *msg,
+                               gpointer user_data)
+{
+  GabbleBytestreamFactory *self = user_data;
+  GabbleBytestreamFactoryPrivate *priv;
+  GabbleBytestreamIBB *bytestream;
+  LmMessageNode *data;
+  const gchar *stream_id;
+
+  priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+
+  //g_print("RECEIVED\n%s\n", lm_message_node_to_string (msg->node));
+
+  data = lm_message_node_get_child_with_namespace (msg->node, "data", NS_IBB);
+
+  if (data == NULL)
+    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+  stream_id = lm_message_node_get_attribute (data, "sid");
+
+  bytestream = g_hash_table_lookup (priv->ibb_bytestreams, stream_id);
+
+  if (bytestream == NULL)
+    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+
+  gabble_bytestream_ibb_receive (bytestream, msg);
+  
+  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+GabbleBytestreamFactory*

Space before * please.

+gabble_bytestream_factory_new (GabbleConnection *conn)
+{
+  GabbleBytestreamFactory *factory;
+
+  g_return_val_if_fail (GABBLE_IS_CONNECTION (conn), NULL);
+
+  factory = GABBLE_BYTESTREAM_FACTORY (
+      g_object_new (GABBLE_TYPE_BYTESTREAM_FACTORY,
+        "connection", conn,
+        NULL));
+  
+  return factory;
+}
+
+static void
+bytestream_closed_cb (GabbleBytestreamIBB *bytestream, gpointer user_data)
+{
+  GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
+  GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE
+    (self);
+
+  if (priv->ibb_bytestreams != NULL)
+    {
+      gchar *stream_id;
+
+      g_object_get (bytestream, "stream-id", &stream_id, NULL);
+
+      g_hash_table_remove (priv->ibb_bytestreams, stream_id);
+
+      g_free (stream_id);
+    }

I think these extra blank lines between function calls can be removed.

+}
+
+GabbleBytestreamIBB*

Space before *.

+gabble_bytestream_factory_create_ibb (GabbleBytestreamFactory *self,
+                                      TpHandle peer_handle,
+                                      TpHandleType peer_handle_type)
+{
+  GabbleBytestreamFactoryPrivate *priv;
+  GabbleBytestreamIBB *ibb;
+  gchar *stream_id;
+  time_t curtime;
+  struct tm *loctime;
+  gchar stamp[20];
+
+  g_return_val_if_fail (GABBLE_IS_BYTESTREAM_FACTORY (self), NULL);
+  priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+
+  /* Generate the stream ID */
+  curtime = time (NULL);
+  loctime = localtime (&curtime);
+  strftime (stamp, sizeof (stamp), "%s", loctime);
+  stream_id = g_strdup_printf ("%s%d", stamp, g_random_int());
+
+  /* XXX for private streams, the bytestream should come from SI */
+  ibb = g_object_new (GABBLE_TYPE_BYTESTREAM_IBB,
+                      "connection", priv->conn,
+                      "peer-handle", peer_handle,
+                      "peer-handle-type", peer_handle_type,
+                      "stream-id", stream_id,
+                      NULL);

Hmm, how is the stream ID going to get passed in?

+
+  g_signal_connect (ibb, "closed", G_CALLBACK (bytestream_closed_cb), self);
+
+  g_hash_table_insert (priv->ibb_bytestreams, stream_id, ibb);
+
+  return ibb;
+}
+
+void
+gabble_bytestream_factory_negociate_stream (GabbleBytestreamFactory *self,
+                                            TpHandle peer_handle,
+                                            TpHandleType peer_handle_type,
+                                            GObject *obj,
+                                            gpointer user_data,
+                                            GabbleBytestreamFactoryNegociateReplyFunc func)
+{
+  GabbleBytestreamFactoryPrivate *priv;
+
+  g_return_if_fail (GABBLE_IS_BYTESTREAM_FACTORY (self));
+  priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (self);
+
+  if (peer_handle_type == TP_HANDLE_TYPE_ROOM)
+    {
+      /* MUC streams don't need negociation step */
+      GabbleBytestreamIBB *ibb;
+
+      ibb = gabble_bytestream_factory_create_ibb (self, peer_handle,
+          peer_handle_type);
+      func (obj, ibb, peer_handle, peer_handle_type, user_data);
+    }
+}

This function seems odd.

 - Why have the callback if it's always called synchronously?
 - There's no way for the function called to know if the negotiation failed.
 - I don't think this is the right place to encode special knowledge of room
   vs. non-room streams.

I think this API needs a bit more thought.

diff -rN -u -p old-tmp0ucgab/src/bytestream-factory.h new-tmp0ucgab/src/bytestream-factory.h
--- old-tmp0ucgab/src/bytestream-factory.h	1970-01-01 01:00:00.000000000 +0100
+++ new-tmp0ucgab/src/bytestream-factory.h	2007-04-03 20:06:21.482960234 +0100
@@ -0,0 +1,79 @@
+/*
+ * bytestream-factory.h - Header for GabbleBytestreamFactory
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __BYTESTREAM_FACTORY_H__
+#define __BYTESTREAM_FACTORY_H__
+
+#include <glib-object.h>
+#include "gabble-connection.h"
+#include "bytestream-ibb.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleBytestreamFactory GabbleBytestreamFactory;
+typedef struct _GabbleBytestreamFactoryClass GabbleBytestreamFactoryClass;
+
+struct _GabbleBytestreamFactoryClass {
+  GObjectClass parent_class;
+};
+
+struct _GabbleBytestreamFactory {
+  GObject parent;
+
+  gpointer priv;
+};
+
+GType gabble_bytestream_factory_get_type(void);

Space before ( please.

+/* TYPE MACROS */

No need for shouting.

+#define GABBLE_TYPE_BYTESTREAM_FACTORY \
+  (gabble_bytestream_factory_get_type())
+#define GABBLE_BYTESTREAM_FACTORY(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_BYTESTREAM_FACTORY, GabbleBytestreamFactory))
+#define GABBLE_BYTESTREAM_FACTORY_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_BYTESTREAM_FACTORY, GabbleBytestreamFactoryClass))
+#define GABBLE_IS_BYTESTREAM_FACTORY(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_BYTESTREAM_FACTORY))
+#define GABBLE_IS_BYTESTREAM_FACTORY_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_BYTESTREAM_FACTORY))
+#define GABBLE_BYTESTREAM_FACTORY_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_BYTESTREAM_FACTORY, GabbleBytestreamFactoryClass))
+
+typedef void (* GabbleBytestreamFactoryNegociateReplyFunc) (GObject *obj,
+                                                            GabbleBytestreamIBB *bytestream,
+                                                            TpHandle peer_handle,
+                                                            TpHandleType peer_handle_type,
+                                                            gpointer user_data);
+
+GabbleBytestreamFactory* gabble_bytestream_factory_new (GabbleConnection *);
+
+GabbleBytestreamIBB* gabble_bytestream_factory_create_ibb (GabbleBytestreamFactory *,
+                                                           TpHandle peer_handle,
+                                                           TpHandleType peer_handle_type);
+
+void gabble_bytestream_factory_negociate_stream (GabbleBytestreamFactory *,
+                                                 TpHandle peer_handle,
+                                                 TpHandleType peer_handle_type,
+                                                 GObject *obj,
+                                                 gpointer user_data,
+                                                 GabbleBytestreamFactoryNegociateReplyFunc func);
+G_END_DECLS

All these long lines should be wrapped. Wrap like:

function_name (
    Type parameter,
    Type parameter);

diff -rN -u -p old-tmp0ucgab/src/bytestream-ibb.c new-tmp0ucgab/src/bytestream-ibb.c
--- old-tmp0ucgab/src/bytestream.... .......... ..-ibb.c	1970-01-01 01:00:00.000000000 +0100
+++ new-tmp0ucgab/src/bytestream-ibb.c	2007-04-03 20:06:21.402960234 +0100
@@ -0,0 +1,410 @@
+/*
+ * bytestream-ibb.c - Source for GabbleBytestreamIBB
+ * Copyright (C) 2007 Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include. <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include <loudmouth/loudmouth.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_TUBES
+
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "handles.h"
+#include "namespaces.h"
+#include <telepathy-glib/interfaces.h>
+#include "util.h"
+#include "base64.h"
+#include "gabble-signals-marshal.h"
+#include "bytestream-ibb.h"
+
+G_DEFINE_TYPE (GabbleBytestreamIBB, gabble_bytestream_ibb, G_TYPE_OBJECT)
+
+#define TUBE_PARAMETERS_TYPE dbus_g_type_get_map\
+    ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)

I think this would look better like this:

#define TUBE_PARAMETERS_TYPE \
  dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)

+/* signals */
+enum
+{
+  DATA_RECEIVED,
+  CLOSED,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+/* properties */
+enum
+{
+  PROP_CONNECTION = 1,
+  PROP_PEER_HANDLE,
+  PROP_PEER_HANDLE_TYPE,
+  PROP_STREAM_ID,
+  LAST_PROPERTY
+};
+
+typedef struct _GabbleBytestreamIBBPrivate GabbleBytestreamIBBPrivate;
+struct _GabbleBytestreamIBBPrivate
+{
+  GabbleConnection *conn;
+  TpHandle peer_handle;
+  TpHandleType peer_handle_type;
+  gchar *stream_id;
+
+  guint16 seq;
+  guint16 last_seq_recv;
+
+  gboolean dispose_has_run;
+};
+
+#define GABBLE_BYTESTREAM_IBB_GET_PRIVATE(obj) \
+    ((GabbleBytestreamIBBPrivate *)obj->priv)

Space after ) for casts, please.

+static GObject *gabble_bytestream_ibb_constructor (GType type, guint n_props,
+                                    GObjectConstructParam *props);
+
+static void
+gabble_bytestream_ibb_init (GabbleBytestreamIBB *self)
+{
+  GabbleBytestreamIBBPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+      GABBLE_TYPE_BYTESTREAM_IBB, GabbleBytestreamIBBPrivate);
+
+  self->priv = priv;
+
+  priv->seq = 0;
+  priv->last_seq_recv = 0;
+
+  priv->dispose_has_run = FALSE;
+}
+
+static GObject *
+gabble_bytestream_ibb_constructor (GType type, guint n_props,
+                                   GObjectConstructParam *props)
+{
+  GObject *obj;
+  GabbleBytestreamIBB *self;
+  GabbleBytestreamIBBPrivate *priv;
+
+  obj = G_OBJECT_CLASS (gabble_bytestream_ibb_parent_class)->
+           constructor (type, n_props, props);
+
+  self = GABBLE_BYTESTREAM_IBB (obj);
+  priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+
+  return obj;
+}

This constructor seems unnecessary.

+static void
+gabble_bytestream_ibb_dispose (GObject *object)
+{
+  GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (object);
+  GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+
+  if (priv->dispose_has_run)
+    return;
+
+  priv->dispose_has_run = TRUE;
+
+  if (G_OBJECT_CLASS (gabble_bytestream_ibb_parent_class)->dispose)
+    G_OBJECT_CLASS (gabble_bytestream_ibb_parent_class)->dispose (object);
+}

Likewise this...

+
+static void
+gabble_bytestream_ibb_finalize (GObject *object)
+{
+  //GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (object);
+  //GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PR...IVATE (self);
+
+  G_OBJECT_CLASS (gabble_bytestream_ibb_parent_class)->finalize (object);
+}


...and this.

+static void
+gabble_bytestream_ibb_get_property (GObject    *object,
+                                    guint       property_id,
+                                    GValue     *value,
+                                    GParamSpec *pspec)

Whitespace.

+{
+  GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (object);
+  GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+
+  switch (property_id) {

Indentation.

+    case PROP_CONNECTION:
+      g_value_set_object (value, priv->conn);
+      break;
+    case PROP_PEER_HANDLE:
+      g_value_set_uint (value, priv->peer_handle);
+      break;
+    case PROP_PEER_HANDLE_TYPE:
+      g_value_set_uint (value, priv->peer_handle_type);
+      break;
+    case PROP_STREAM_ID:
+      g_value_set_string (value, priv->stream_id);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void
+gabble_bytestream_ibb_set_property (GObject      *object,
+                                    guint         property_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)

Whitespace.

+{
+  GabbleBytestreamIBB *self = GABBLE_BYTESTREAM_IBB (object);
+  GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+
+  switch (property_id) {

Indentation.

+    case PROP_CONNECTION:
+      priv->conn = g_value_get_object (value);
+      break;
+    case PROP_PEER_HANDLE:
+      priv->peer_handle = g_value_get_uint (value);
+      break;
+    case PROP_PEER_HANDLE_TYPE:
+      priv->peer_handle_type = g_value_get_uint (value);
+      break;
+    case PROP_STREAM_ID:
+      g_free (priv->stream_id);
+      priv->stream_id = g_value_dup_string (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void
+gabble_bytestream_ibb_class_init (GabbleBytestreamIBBClass *gabble_bytestream_ibb_class)

Wrap long line.

+{
+  GObjectClass *object_class = G_OBJECT_CLASS (gabble_bytestream_ibb_class);
+  GParamSpec *param_spec;
+
+  g_type_class_add_private (gabble_bytestream_ibb_class, sizeof (GabbleBytestreamIBBPrivate));
+
+  object_class->constructor = gabble_bytestream_ibb_constructor;
+  object_class->dispose = gabble_bytestream_ibb_dispose;
+  object_class->finalize = gabble_bytestream_ibb_finalize;
+
+  object_class->get_property = gabble_bytestream_ibb_get_property;
+  object_class->set_property = gabble_bytestream_ibb_set_property;
+
+  param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+                                    "Gabble connection object that owns this "
+                                    "DBus tube object.",
+                                    GABBLE_TYPE_CONNECTION,
+                                    G_PARAM_CONSTRUCT_ONLY |
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);

All these should be indented to +4 chars.

+
+  param_spec = g_param_spec_uint ("peer-handle", "Peer handle",
+                                  "The TpHandle of the remote peer involved in"
+                                  "this bytestream",
+                                  0, G_MAXUINT32, 0,
+                                  G_PARAM_CONSTRUCT_ONLY |
+                                  G_PARAM_READWRITE |
+                                  G_PARAM_STATIC_NICK |
+                                  G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_PEER_HANDLE, param_spec);
+
+  param_spec = g_param_spec_uint ("peer-handle-type", "Peer handle type",
+                                  "The TpHandleType of the remote peer's"
+                                  "associated handle",
+                                  0, G_MAXUINT32, 0,
+                                  G_PARAM_CONSTRUCT_ONLY |
+                                  G_PARAM_READWRITE |
+                                  G_PARAM_STATIC_NICK |
+                                  G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_PEER_HANDLE_TYPE, param_spec);
+
+  param_spec = g_param_spec_string ("stream-id", "stream ID",
+                                    "the ID of the stream",
+                                    "",
+                                    G_PARAM_CONSTRUCT_ONLY |
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_STREAM_ID, param_spec);
+
+  signals[DATA_RECEIVED] =
+    g_signal_new ("data-received",
+                  G_OBJECT_CLASS_TYPE (gabble_bytestream_ibb_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                  0,
+                  NULL, NULL,
+                  gabble_marshal_VOID__STRING,
+                  G_TYPE_NONE, 1, G_TYPE_STRING);
+
+  signals[CLOSED] =
+    g_signal_new ("closed",
+                  G_OBJECT_CLASS_TYPE (gabble_bytestream_ibb_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                  0,
+                  NULL, NULL,
+                  gabble_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+}
+
+gboolean
+gabble_bytestream_ibb_send (GabbleBytestreamIBB *self, GString *str)
+{
+  GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+  TpHandleRepoIface *handles_repo = tp_base_connection_get_handles (
+      (TpBaseConnection *)priv->conn, priv->peer_handle_type);

Space after cast.

+  LmMessage *msg;
+  LmMessageNode *node, *amp;
+  gchar *seq, *encoded;
+  const gchar *to;
+  gboolean ret;
+  
+  //g_print ("IBB send %s\n", str->str);
+
+  priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+
+  to = tp_handle_inspect (handles_repo, priv->peer_handle);
+  seq = g_strdup_printf ("%u", priv->seq++);
+
+  encoded = base64_encode (str);
+
+  msg = lm_message_new (to, LM_MESSAGE_TYPE_MESSAGE);
+
+  if (priv->peer_handle_type == TP_HANDLE_TYPE_ROOM)
+    {
+      lm_message_node_set_attribute (msg->node, "type", "groupchat");
+    }
+
+  node = lm_message_node_add_child (msg->node, "data", encoded);
+  lm_message_node_set_attribute (node, "xmlns", NS_IBB);
+  lm_message_node_set_attribute (node, "sid", priv->stream_id);
+  lm_message_node_set_attribute (node, "seq", seq);

You can use lm_message_node_set_attributes here:

lm_message_node_set_attributess (node,
    "xmlns", NS_IBB,
    "sid", priv->stream_id,
    "seq", seq,
    NULL);

+  amp = lm_message_node_add_child (msg->node, "amp", NULL);
+  lm_message_node_set_attribute (amp, "xmlns", NS_AMP);
+
+  node = lm_message_node_add_child (amp, "rule", NULL);
+  lm_message_node_set_attribute (node, "condition", "deliver-at");
+  lm_message_node_set_attribute (node, "value", "stored");
+  lm_message_node_set_attribute (node, "action", "error");
+
+  node = lm_message_node_add_child (amp, "rule", NULL);
+  lm_message_node_set_attribute (node, "condition", "match-resource");
+  lm_message_node_set_attribute (node, "value", "exact");
+  lm_message_node_set_attribute (node, "action", "error");
+
+  //g_print ("%s\n", lm_message_node_to_string (msg->node));
+
+  ret = _gabble_connection_send (priv->conn, msg, NULL);
+
+  lm_message_unref (msg);
+  g_free (encoded);
+  g_free (seq);
+
+  return ret;
+}
+
+void
+gabble_bytestream_ibb_close (GabbleBytestreamIBB *self)
+{
+  g_signal_emit (G_OBJECT (self), signals[CLOSED], 0);
+}
+
+gboolean
+gabble_bytestream_ibb_receive (GabbleBytestreamIBB *self, LmMessage *msg)
+{
+  GabbleBytestreamIBBPrivate *priv = GABBLE_BYTESTREAM_IBB_GET_PRIVATE (self);
+  LmMessageNode *data;
+  GString *str;
+  const gchar *from, *msg_type;
+
+  data = lm_message_node_get_child_with_namespace (msg->node, "data", NS_IBB);
+
+  from = lm_message_node_get_attribute (msg->node, "from");
+
+  if (from == NULL)
+    {
+      NODE_DEBUG (msg->node, "got a message without a from field, ignoring");
+      return FALSE;
+    }
+
+  msg_type = lm_message_node_get_attribute (msg->node, "type");
+  
+  if (msg_type != NULL && strcmp (msg_type, "groupchat") == 0)
+    {
+      /* multi users stream */
+      gchar *room, *service, *room_jid;
+      TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
+          (TpBaseConnection *)priv->conn, TP_HANDLE_TYPE_ROOM);
+      TpHandle room_handle;
+
+      if (priv->peer_handle_type != TP_HANDLE_TYPE_ROOM)
+        return FALSE;
+
+      gabble_decode_jid (from, &room, &service, NULL);
+      room_jid = g_strdup_printf ("%s@%s", room, service);
+
+      room_handle = tp_handle_lookup (room_repo, room_jid, NULL, NULL);

You could use gabble_jid_remove_resource here. This is changed in my tubes
branch.

+      
+      g_free (room);
+      g_free (service);
+      g_free (room_jid);
+
+      if (room_handle != priv->peer_handle)
+        /* Data are not for this stream */
+        return FALSE;
+
+      // XXX discard data messages sended by local user

s/sended/sent/

+    }
+  else
+    {
+      /* 2 users stream */
+      TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+          (TpBaseConnection *)priv->conn, TP_HANDLE_TYPE_CONTACT);
+      TpHandle handle;
+
+      if (priv->peer_handle_type != TP_HANDLE_TYPE_CONTACT)
+        return FALSE;
+
+      handle = tp_handle_lookup (contact_repo, from, NULL, NULL);
+
+      if (priv->peer_handle != handle)
+        return FALSE;
+
+      // XXX check sequence nb
+    }
+  
+  str = base64_decode (lm_message_node_get_value (data));

You should check that str != NULL. This is fixed in my tubes branch.

+  g_signal_emit (G_OBJECT (self), signals[DATA_RECEIVED], 0, str->str);
+
+  g_string_free (str, TRUE);
+
+  return TRUE;
+}

Again, unnecessary blank lines here.

diff -rN -u -p old-tmp0ucgab/src/bytestream-ibb.h new-tmp0ucgab/src/bytestream-ibb.h
--- old-tmp0ucgab/src/bytestream-ibb.h	1970-01-01 01:00:00.000000000 +0100
+++ new-tmp0ucgab/src/bytestream-ibb.h	2007-04-03 20:06:21.402960234 +0100
@@ -0,0 +1,62 @@
+/*
+ * bytestreal-ibb.h - Header for GabbleBytestreamIBB
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __GABBLE_BYTESTREAM_IBB_H__
+#define __GABBLE_BYTESTREAM_IBB_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleBytestreamIBB GabbleBytestreamIBB;
+typedef struct _GabbleBytestreamIBBClass GabbleBytestreamIBBClass;
+
+struct _GabbleBytestreamIBBClass {
+  GObjectClass parent_class;
+};
+
+struct _GabbleBytestreamIBB {
+  GObject parent;
+
+  gpointer priv;
+};
+
+GType gabble_bytestream_ibb_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_BYTESTREAM_IBB \
+  (gabble_bytestream_ibb_get_type())
+#define GABBLE_BYTESTREAM_IBB(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_BYTESTREAM_IBB, GabbleBytestreamIBB))
+#define GABBLE_BYTESTREAM_IBB_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_BYTESTREAM_IBB, GabbleBytestreamIBBClass))
+#define GABBLE_IS_BYTESTREAM_IBB(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_BYTESTREAM_IBB))
+#define GABBLE_IS_BYTESTREAM_IBB_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_BYTESTREAM_IBB))
+#define GABBLE_BYTESTREAM_IBB_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_BYTESTREAM_IBB, GabbleBytestreamIBBClass))
+
+gboolean gabble_bytestream_ibb_send (GabbleBytestreamIBB *ibb, GString *str);
+void gabble_bytestream_ibb_close (GabbleBytestreamIBB *ibb);
+gboolean gabble_bytestream_ibb_receive (GabbleBytestreamIBB *ibb, LmMessage *msg);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_BYTESTREAM_IBB_H__ */
diff -rN -u -p old-tmp0ucgab/src/gabble-connection.c new-tmp0ucgab/src/gabble-connection.c
--- old-tmp0ucgab/src/gabble-connection.c	2007-04-03 20:06:20.852960234 +0100
+++ new-tmp0ucgab/src/gabble-connection.c	2007-04-03 20:06:21.282960234 +0100
@@ -64,6 +64,7 @@
 #include "roster.h"
 #include "util.h"
 #include "vcard-manager.h"
+#include "tubes-factory.h"
 
 #include "gabble-media-channel.h"
 #include "gabble-roomlist-channel.h"
@@ -206,6 +207,10 @@ _gabble_connection_create_channel_factor
                                  "connection", self,
                                  NULL));
 
+  g_ptr_array_add (channel_factories,
+                   g_object_new (GABBLE_TYPE_TUBES_FACTORY,
+                                 "connection", self,
+                                 NULL));

Indent to +4 chars.

+   return channel_factories;
+ }
 
@@ -236,6 +241,8 @@ gabble_connection_constructor (GType typ
+  conn_avatars_init (self);
+  conn_presence_init (self);
+
+  self->bytestream_factory = gabble_bytestream_factory_new (self);
+
+   return (GObject *)self;
+ }
 
@@ -710,6 +717,9 @@ gabble_connection_dispose (GObject *obje
+  g_object_unref (self->presence_cache);
+  self->presence_cache = NULL;
+ 
+  g_object_unref (self->bytestream_factory);
+  self->bytestream_factory = NULL;
+
+  /* if this is not already the case, we'll crash anyway */
+  g_assert (!lm_connection_is_open (self->lmconn));
 
diff -rN -u -p old-tmp0ucgab/src/streaminit.c new-tmp0ucgab/src/streaminit.c
--- old-tmp0ucgab/src/streaminit.c	1970-01-01 01:00:00.000000000 +0100
+++ new-tmp0ucgab/src/streaminit.c	2007-04-03 20:06:21.402960234 +0100
@@ -0,0 +1,185 @@
+/*
+ * streaminit.c - Source for Stream Initiation (XEP-095)
+ * Copyright (C) 2006 Mads Chr. Olesen
+ * Copyright (C) 2007 Collabora Ltd.
+ *   @author Mads Chr. Olesen <shiyee at shiyee.dk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "streaminit.h"
+#include "gabble-error.h"
+#include "namespaces.h"
+#include "util.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_BYTESTREAM
+#include "debug.h"
+
+/**
+ * gabble_streaminit_parse_request
+ *
+ * Parses an stream initiation request, or returns FALSE
+ * if it could not be parsed.
+ */
+gboolean
+gabble_streaminit_parse_message (LmMessage *message,
+                                 const gchar **profile,
+                                 const gchar **from,
+                                 const gchar **stream_id,
+                                 const gchar **mime_type,
+                                 GSList **stream_methods)
+{
+  LmMessageNode *iq, *si, *feature, *x, *field, *stream_method, *value;
+
+  if (lm_message_get_sub_type (message) != LM_MESSAGE_SUB_TYPE_SET)
+    return FALSE;
+
+  iq = lm_message_get_node (message);
+
+  *from = lm_message_node_get_attribute (message->node, "from");
+  if (*from == NULL)
+    {
+      NODE_DEBUG (message->node, "got a message without a from field");
+      return FALSE;
+    }
+
+  /* Parse <si> */
+  si = lm_message_node_get_child_with_namespace (iq, "si", NS_STREAMINIT);
+  if (si == NULL)
+    return FALSE;
+
+  *stream_id = lm_message_node_get_attribute (si, "id");
+  if (*stream_id == NULL)
+    {
+      NODE_DEBUG (message->node, "got a SI request without a stream id field");
+      return FALSE;
+    }
+
+  *mime_type = lm_message_node_get_attribute (si, "mime-type");
+  /* if no mime_type is defined, we assume "binary/octect-stream" */
+  
+  *profile = lm_message_node_get_attribute (si, "profile");
+  if (*profile == NULL)
+    {
+      NODE_DEBUG (message->node, "got a SI request without a profile field");
+      return FALSE;
+    }
+
+  /* Parse <feature> */
+  feature = lm_message_node_get_child_with_namespace (si, "feature",
+      NS_FEATURENEG);
+  if (feature == NULL)
+    {
+      NODE_DEBUG (message->node, "got a SI request without a feature field");
+      return FALSE;
+    }
+
+  x = lm_message_node_get_child_with_namespace (feature, "x", NS_DATA);
+  if (x == NULL)
+    {
+      NODE_DEBUG (message->node, "got a SI request without a X data field");
+      return FALSE;
+    }
+  
+  field = lm_message_node_get_child (x, "field");
+  if (field == NULL)
+    {
+      NODE_DEBUG (message->node, "got a SI request without stream method list");
+      return FALSE;
+    }
+
+  if (strcmp (lm_message_node_get_attribute (field, "var"), "stream-method")
+      != 0)

strcmp() is not NULL-safe, and lm_message_node_get_attribute can return NULL.
Use tp_strdiff instead.

+    {
+      NODE_DEBUG (message->node, "got a SI request without stream method list");
+      return FALSE;
+    }
+
+  if (strcmp (lm_message_node_get_attribute (field, "type"), "list-single")
+      != 0)

tp_strdiff.

+    {
+      NODE_DEBUG (message->node, "got a SI request without stream method list");
+      return FALSE;
+    }
+
+  /* Get the stream methods offered */
+  *stream_methods = NULL;
+  for (stream_method = field->children; stream_method;
+      stream_method = stream_method->next)
+    {
+      value = lm_message_node_get_child (stream_method, "value");

Declare value locally here.

+      if (value != NULL) 
+        {
+          const gchar *stream_method;
+
+          stream_method = lm_message_node_get_value (value);
+          DEBUG ("Got stream-method %s", stream_method);

Check that stream_method != "".

+          /* Append to the stream_methods list */
+          *stream_methods = g_slist_append (*stream_methods,
+              (gchar*) stream_method);
+        }
+    }
+
+  if (*stream_methods == NULL)
+    {
+      NODE_DEBUG (message->node,
+          "got a SI request without stream method proposed");
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+LmMessage*
+gabble_streaminit_create_offer (const gchar* full_jid, const gchar* stream_id) 

 - Why the "full" in "full_jid"?
 - * should be with name, not type

+{
+  LmMessage *msg;
+  LmMessageNode *lm_node;
+  LmMessageNode *field;
+ 
+  /* Send an accept Stream Initiation message */
+  msg = lm_message_new_with_sub_type (full_jid, LM_MESSAGE_TYPE_IQ,
+                                           LM_MESSAGE_SUB_TYPE_SET);
+
+  lm_node = lm_message_node_add_child (msg->node, "si", NULL);
+  lm_message_node_set_attribute (lm_node, "xmlns", NS_STREAMINIT);
+  lm_message_node_set_attribute (lm_node, "id", stream_id);
+
+  lm_node = lm_message_node_add_child (lm_node, "feature", NULL);
+  lm_message_node_set_attribute (lm_node, "xmlns", NS_FEATURENEG);
+  
+  lm_node = lm_message_node_add_child (lm_node, "x", NULL);
+  lm_message_node_set_attribute (lm_node, "xmlns", NS_DATA);
+  lm_message_node_set_attribute (lm_node, "type", "form");
+  
+  field = lm_message_node_add_child (lm_node, "field", NULL);
+  lm_message_node_set_attribute (field, "var", "stream-method");
+  lm_message_node_set_attribute (field, "type", "list-single");
+
+  /* Available bytestream methods: */
+  /* Socks5 bytestreams */
+  /*
+  lm_node = lm_message_node_add_child (field, "option", NULL);
+  lm_message_node_add_child (lm_node, "value", NS_BYTESTREAMS);
+  */
+  lm_node = lm_message_node_add_child (field, "option", NULL);
+  lm_message_node_add_child (lm_node, "value", NS_IBB);
+  
+  return msg;
+}

-- 
Dafydd


More information about the Telepathy mailing list