diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2012-03-26 17:52:33 -0400 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2012-07-20 12:19:13 +0100 |
commit | 353db90ad65b2f5749384505bd8372ca8264f44c (patch) | |
tree | d1e6f1b57d5d1e258b8d64bdc276e5f725e5a356 /src/muc-channel.c | |
parent | f5b269b50df5b859fee0c168deafa97b107d9ad7 (diff) | |
download | telepathy-gabble-353db90ad65b2f5749384505bd8372ca8264f44c.tar.gz |
muc-channel: enable SI stream requests again
This code came from GabbleTubesChannel.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src/muc-channel.c')
-rw-r--r-- | src/muc-channel.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/muc-channel.c b/src/muc-channel.c index e8075559f..fda9200c5 100644 --- a/src/muc-channel.c +++ b/src/muc-channel.c @@ -2043,6 +2043,67 @@ gabble_muc_channel_foreach_tubes (GabbleMucChannel *gmuc, } } +void +gabble_muc_channel_handle_si_stream_request (GabbleMucChannel *self, + GabbleBytestreamIface *bytestream, + const gchar *stream_id, + WockyStanza *msg) +{ + GabbleMucChannelPrivate *priv = self->priv; + WockyNode *si_node, *stream_node; + const gchar *tmp; + gchar *endptr; + unsigned long tube_id_tmp; + guint tube_id; + GabbleTubeIface *tube; + + si_node = wocky_node_get_child_ns ( + wocky_stanza_get_top_node (msg), "si", NS_SI); + g_return_if_fail (si_node != NULL); + + stream_node = wocky_node_get_child_ns (si_node, + "muc-stream", NS_TUBES); + g_return_if_fail (stream_node != NULL); + + tmp = wocky_node_get_attribute (stream_node, "tube"); + if (tmp == NULL) + { + GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST, + "<muc-stream> has no tube attribute" }; + + NODE_DEBUG (stream_node, e.message); + gabble_bytestream_iface_close (bytestream, &e); + return; + } + tube_id_tmp = strtoul (tmp, &endptr, 10); + if (!endptr || *endptr || tube_id_tmp > G_MAXUINT32) + { + GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST, + "<muc-stream> tube attribute not numeric or > 2**32" }; + + DEBUG ("tube id is not numeric or > 2**32: %s", tmp); + gabble_bytestream_iface_close (bytestream, &e); + return; + } + tube_id = (guint) tube_id_tmp; + + tube = g_hash_table_lookup (priv->tubes, GUINT_TO_POINTER (tube_id)); + if (tube == NULL) + { + GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_BAD_REQUEST, + "<muc-stream> tube attribute points to a nonexistent " + "tube" }; + + DEBUG ("tube %u doesn't exist", tube_id); + gabble_bytestream_iface_close (bytestream, &e); + return; + } + + DEBUG ("received new bytestream request for existing tube: %u", tube_id); + + gabble_tube_iface_add_bytestream (tube, bytestream); +} + static void tubes_presence_update (GabbleMucChannel *gmuc, TpHandle contact, |