cpw.malu.xmpp.jingle_ft: 9830967a: Handle change of block size for IBB in s...
malu at pidgin.im
malu at pidgin.im
Sun Feb 21 16:30:40 EST 2010
-----------------------------------------------------------------
Revision: 9830967af3f744375e141b3b4bbfb9ca309bb137
Ancestor: 67c8febab3659996ecfd7ea1f44e1f99b0543e32
Author: malu at pidgin.im
Date: 2010-02-21T21:28:58
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/9830967af3f744375e141b3b4bbfb9ca309bb137
Modified files:
libpurple/protocols/jabber/jingle/file-transfer.c
libpurple/protocols/jabber/jingle/ibbs.c
libpurple/protocols/jabber/jingle/ibbs.h
ChangeLog:
Handle change of block size for IBB in session-accept and transport-accept (for fallback from S5B)
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c 872a01aee02a172f73579c373289c4153a1b8d01
+++ libpurple/protocols/jabber/jingle/file-transfer.c 0036beded6c4defc0383009e891ff61d00e73c27
@@ -752,12 +752,20 @@ jingle_file_transfer_handle_action_inter
if (JINGLE_IS_IBB(transport)) {
JingleIBB *ibb = JINGLE_IBB(transport);
- const gchar *sid =
- xmlnode_get_attrib(xmlnode_get_child(xmlcontent,
- "transport"), "sid");
+ xmlnode *xmltransport = xmlnode_get_child(xmlcontent,
+ "transport");
+ const gchar *sid = xmlnode_get_attrib(xmltransport, "sid");
+
+
jingle_ibb_create_session(ibb, content, sid, who);
JINGLE_FT(content)->priv->ibb_buffer =
purple_circ_buffer_new(jingle_ibb_get_block_size(ibb));
+
+ if (xmltransport) {
+ jingle_ibb_handle_session_accept(JINGLE_IBB(transport),
+ xmltransport);
+ }
+
purple_xfer_set_read_fnc(xfer,
jingle_file_transfer_ibb_read);
purple_xfer_prpl_ready(xfer);
@@ -798,7 +806,7 @@ jingle_file_transfer_handle_action_inter
JingleSession *session = jingle_content_get_session(content);
JingleTransport *transport = jingle_content_get_transport(content);
xmlnode *xmltransport = xmlnode_get_child(xmlcontent, "transport");
-
+
/* we should check for "stream-host" error (in the case of S5B) and
offer a transport-replace with IBB */
if (xmltransport) {
@@ -807,7 +815,7 @@ jingle_file_transfer_handle_action_inter
session, xmltransport);
}
}
-
+
g_object_unref(transport);
g_object_unref(session);
break;
@@ -815,6 +823,7 @@ jingle_file_transfer_handle_action_inter
case JINGLE_TRANSPORT_ACCEPT: {
JingleSession *session = jingle_content_get_session(content);
JingleTransport *transport = jingle_content_get_transport(content);
+ xmlnode *xmltransport = xmlnode_get_child(xmlcontent, "transport");
PurpleXfer *xfer =
jingle_file_transfer_get_xfer(content);
@@ -823,15 +832,22 @@ jingle_file_transfer_handle_action_inter
purple_debug_info("jingle-ft",
"got transport-accept transport %p\n", transport);
- JINGLE_FT(content)->priv->ibb_buffer =
- purple_circ_buffer_new(jingle_ibb_get_block_size(JINGLE_IBB(transport)));
+ if (JINGLE_IS_IBB(transport)) {
+ JINGLE_FT(content)->priv->ibb_buffer =
+ purple_circ_buffer_new(jingle_ibb_get_block_size(JINGLE_IBB(transport)));
- purple_xfer_set_write_fnc(xfer, jingle_file_transfer_ibb_write);
+ purple_xfer_set_write_fnc(xfer, jingle_file_transfer_ibb_write);
+
+ if (xmltransport) {
+ jingle_ibb_handle_transport_accept(JINGLE_IBB(transport),
+ xmltransport);
+ }
- /* send first data */
- purple_xfer_start(xfer, -1, NULL, 0);
- purple_xfer_prpl_ready(xfer);
-
+ /* send first data */
+ purple_xfer_start(xfer, -1, NULL, 0);
+ purple_xfer_prpl_ready(xfer);
+ }
+
g_object_unref(session);
g_object_unref(transport);
break;
============================================================
--- libpurple/protocols/jabber/jingle/ibbs.c 82b348f4e4e481c564628854498d94f9088074c3
+++ libpurple/protocols/jabber/jingle/ibbs.c b09b00e193b6cfe0b45ada5051cb1399d27b0fee
@@ -331,3 +331,32 @@ jingle_ibb_get_block_size(const JingleIB
return jabber_ibb_session_get_block_size(
JINGLE_IBB_GET_PRIVATE(ibb)->session);
}
+
+static void
+jingle_ibb_set_block_size(JingleIBB *ibb, int block_size)
+{
+ if (block_size > 0) {
+ jabber_ibb_session_set_block_size(JINGLE_IBB_GET_PRIVATE(ibb)->session,
+ block_size);
+ }
+}
+
+void
+jingle_ibb_handle_session_accept(JingleIBB *ibb, xmlnode *transport)
+{
+ const gchar *block_size = xmlnode_get_attrib(transport, "block-size");
+
+ if (block_size) {
+ jingle_ibb_set_block_size(ibb, atoi(block_size));
+ }
+}
+
+void
+jingle_ibb_handle_transport_accept(JingleIBB *ibb, xmlnode *transport)
+{
+ const gchar *block_size = xmlnode_get_attrib(transport, "block-size");
+
+ if (block_size) {
+ jingle_ibb_set_block_size(ibb, atoi(block_size));
+ }
+}
============================================================
--- libpurple/protocols/jabber/jingle/ibbs.h 4cc87c1ff8904b72e6240f8cef9dfa2d6fecd770
+++ libpurple/protocols/jabber/jingle/ibbs.h 7c577f77784ac73fba9a1f6cc91baca2261ce781
@@ -86,6 +86,9 @@ gsize jingle_ibb_get_block_size(const Ji
/* get the (max) block size of the IBB session */
gsize jingle_ibb_get_block_size(const JingleIBB *ibb);
+void jingle_ibb_handle_session_accept(JingleIBB *ibb, xmlnode *transport);
+void jingle_ibb_handle_transport_accept(JingleIBB *ibb, xmlnode *transport);
+
#ifdef __cplusplus
}
#endif
More information about the Commits
mailing list