cpw.malu.xmpp.jingle_ft: e29115f1: A first shot a supporting Jingle file tr...

malu at pidgin.im malu at pidgin.im
Mon Mar 16 16:50:28 EDT 2009


-----------------------------------------------------------------
Revision: e29115f1b59b7b26e05784a49625bfae6ebbc265
Ancestor: 6733a54a9c1b0ab68c8b924c82783cc4af588952
Author: malu at pidgin.im
Date: 2009-03-16T20:44:59
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/e29115f1b59b7b26e05784a49625bfae6ebbc265

Modified files:
        configure.ac libpurple/protocols/jabber/Makefile.am
        libpurple/protocols/jabber/Makefile.mingw
        libpurple/protocols/jabber/disco.c
        libpurple/protocols/jabber/ibb.c
        libpurple/protocols/jabber/ibb.h
        libpurple/protocols/jabber/iq.c
        libpurple/protocols/jabber/jingle/jingle.c
        libpurple/protocols/jabber/jingle/jingle.h
        libpurple/protocols/jabber/libxmpp.c
        libpurple/protocols/jabber/si.c

ChangeLog: 

A first shot a supporting Jingle file transfers on XMPP.
Only supports IBB so far
TODO: add support for S5B (socks5)
Refs #8623

-------------- next part --------------
============================================================
--- configure.ac	68cb17a59f48c12468855c3bca1e2e540f657db2
+++ configure.ac	b3cafbc31b882965d66e497084592dff312dc495
@@ -47,7 +47,7 @@ m4_define([purple_micro_version], [0])
 m4_define([purple_major_version], [2])
 m4_define([purple_minor_version], [6])
 m4_define([purple_micro_version], [0])
-m4_define([purple_version_suffix], [vv-devel])
+m4_define([purple_version_suffix], [devel])
 m4_define([purple_version],
           [purple_major_version.purple_minor_version.purple_micro_version])
 m4_define([purple_display_version], purple_version[]m4_ifdef([purple_version_suffix],[purple_version_suffix]))
@@ -56,7 +56,7 @@ m4_define([gnt_micro_version], [0])
 m4_define([gnt_major_version], [2])
 m4_define([gnt_minor_version], [6])
 m4_define([gnt_micro_version], [0])
-m4_define([gnt_version_suffix], [vv-devel])
+m4_define([gnt_version_suffix], [devel])
 m4_define([gnt_version],
           [gnt_major_version.gnt_minor_version.gnt_micro_version])
 m4_define([gnt_display_version], gnt_version[]m4_ifdef([gnt_version_suffix],[gnt_version_suffix]))
@@ -788,7 +788,7 @@ AC_ARG_ENABLE(vv,
 dnl #######################################################################
 AC_ARG_ENABLE(vv,
 	[AC_HELP_STRING([--disable-vv], [compile without voice and video support])],
-	enable_vv="$enableval", enable_vv="yes")
+	enable_vv="$enableval", enable_vv="no")
 if test "x$enable_vv" != "xno"; then
 	if test "x$enable_farsight" != "xno" -a "x$enable_gstprops" != "xno"; then
 		AC_DEFINE(USE_VV, 1, [Use voice and video])
============================================================
--- libpurple/protocols/jabber/Makefile.am	8b4fa1d880af09b80cb4f120a7c1c8a3bae6f098
+++ libpurple/protocols/jabber/Makefile.am	0d2f16fe14690024b8619ee7ec3f023afb2ac1ed
@@ -27,6 +27,10 @@ JABBERSOURCES = auth.c \
 			  jingle/jingle.h \
 			  jingle/content.c \
 			  jingle/content.h \
+			  jingle/file-transfer.c \
+			  jingle/file-transfer.h \
+			  jingle/ibbs.c \
+			  jingle/ibbs.h \
 			  jingle/iceudp.c \
 			  jingle/iceudp.h \
 			  jingle/rawudp.c \
@@ -66,7 +70,9 @@ JABBERSOURCES = auth.c \
 			  usernick.c \
 			  usernick.h \
 			  usertune.c \
-			  usertune.h
+			  usertune.h \
+			  xfer.c \
+			  xfer.h
 
 AM_CFLAGS = $(st)
 
============================================================
--- libpurple/protocols/jabber/Makefile.mingw	31da9f1d268e8c695dea98bb4c4a567b17aba779
+++ libpurple/protocols/jabber/Makefile.mingw	13dde37ebec9e8c76db86b6f0fa7f500b6954e83
@@ -56,6 +56,8 @@ C_SRC =	\
 			jabber.c \
 			jingle/jingle.c \
 			jingle/content.c \
+			jingle/file-transfer.c \
+			jingle/ibbs.c \
 			jingle/iceudp.c \
 			jingle/rawudp.c \
 			jingle/rtp.c \
@@ -74,6 +76,7 @@ C_SRC =	\
 			usernick.c \
 			usertune.c \
 			xdata.c \
+			xfer.c \
 			win32/posix.uname.c
 
 OBJECTS = $(C_SRC:%.c=%.o)
============================================================
--- libpurple/protocols/jabber/disco.c	1f9d1587de4799423ca96ff96ec1a64ee01c7536
+++ libpurple/protocols/jabber/disco.c	b73258ecd67112416a054920848bbc5d5bfcb9f4
@@ -141,7 +141,8 @@ void jabber_disco_info_parse(JabberStrea
 			SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im")
 			SUPPORT_FEATURE("urn:xmpp:ping")
 			SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0199.html#ns")
-
+			SUPPORT_FEATURE(JINGLE_APP_FT)
+							
 			if(!node) { /* non-caps disco#info, add all enabled extensions */
 				GList *features;
 				for(features = jabber_features; features; features = features->next) {
============================================================
--- libpurple/protocols/jabber/ibb.c	154ededf518a249217e348d11844dee18ef27868
+++ libpurple/protocols/jabber/ibb.c	37ea7f5cb5b4832f62c5b3392d58d9b9515c1e24
@@ -139,6 +139,13 @@ jabber_ibb_session_get_state(const Jabbe
 	return sess->state;
 }
 
+void
+jabber_ibb_session_set_state(JabberIBBSession *sess, 
+	JabberIBBSessionState state)
+{
+	sess->state = state;
+}
+
 gsize
 jabber_ibb_session_get_block_size(const JabberIBBSession *sess)
 {
============================================================
--- libpurple/protocols/jabber/ibb.h	4a5131f44dea294228092fc83ace02651e10b962
+++ libpurple/protocols/jabber/ibb.h	603001cb291cdcfb25f278f1caf5c9f2b89f03a8
@@ -100,6 +100,8 @@ JabberIBBSessionState jabber_ibb_session
 guint16 jabber_ibb_session_get_recv_seq(const JabberIBBSession *sess);
 
 JabberIBBSessionState jabber_ibb_session_get_state(const JabberIBBSession *sess);
+void jabber_ibb_session_set_state(JabberIBBSession *sess, 
+	JabberIBBSessionState state);
 
 gsize jabber_ibb_session_get_block_size(const JabberIBBSession *sess);
 void jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size);
============================================================
--- libpurple/protocols/jabber/iq.c	f47c301f9f8462103aaddd817af993499c99b27f
+++ libpurple/protocols/jabber/iq.c	547bd76cd34c0c603113dd71887f8724ea9b6fdb
@@ -407,12 +407,10 @@ void jabber_iq_parse(JabberStream *js, x
 		return;
 	}
 	
-#ifdef USE_VV
 	if (xmlnode_get_child_with_namespace(packet, "jingle", JINGLE)) {
 		jingle_parse(js, packet);
 		return;
 	}
-#endif
 
 	/* If we get here, send the default error reply mandated by XMPP-CORE */
 	if(!strcmp(type, "set") || !strcmp(type, "get")) {
============================================================
--- libpurple/protocols/jabber/jingle/jingle.c	9820d1527648eacb6ee55ae8be58e300f1642180
+++ libpurple/protocols/jabber/jingle/jingle.c	8b9c86fef949ee059bdf955ef296ea94548ced41
@@ -24,6 +24,8 @@
 
 #include "content.h"
 #include "debug.h"
+#include "file-transfer.h"
+#include "ibbs.h"
 #include "jingle.h"
 #include <string.h>
 #include "session.h"
@@ -113,16 +115,16 @@ jingle_get_type(const gchar *type)
 #if 0
 	else if (!strcmp(type, JINGLE_TRANSPORT_SOCKS))
 		return JINGLE_TYPE_SOCKS;
+#endif
 	else if (!strcmp(type, JINGLE_TRANSPORT_IBB))
 		return JINGLE_TYPE_IBB;
-#endif
 #ifdef USE_VV
 	else if (!strcmp(type, JINGLE_APP_RTP))
 		return JINGLE_TYPE_RTP;
 #endif
-#if 0
 	else if (!strcmp(type, JINGLE_APP_FT))
 		return JINGLE_TYPE_FT;
+#if 0
 	else if (!strcmp(type, JINGLE_APP_XML))
 		return JINGLE_TYPE_XML;
 #endif
============================================================
--- libpurple/protocols/jabber/jingle/jingle.h	fd797e5eb954cf605877c5d8446c4513aa847d00
+++ libpurple/protocols/jabber/jingle/jingle.h	5c360be9392e24461287b84fc5e7edb212a335dc
@@ -30,7 +30,7 @@ extern "C" {
 extern "C" {
 #endif
 
-#define JINGLE "urn:xmpp:jingle:0"
+#define JINGLE "urn:xmpp:jingle:1"
 #define JINGLE_ERROR "urn:xmpp:jingle:errors:0"
 #define JINGLE_APP_FT "urn:xmpp:jingle:apps:file-transfer:1"
 #define JINGLE_APP_RTP "urn:xmpp:jingle:apps:rtp:1"
@@ -40,8 +40,8 @@ extern "C" {
 #define JINGLE_APP_RTP_SUPPORT_VIDEO "urn:xmpp:jingle:apps:rtp:video"
 #define JINGLE_APP_XML "urn:xmpp:tmp:jingle:apps:xmlstream"
 #define JINGLE_DTMF "urn:xmpp:jingle:dtmf:0"
-#define JINGLE_TRANSPORT_S5B "urn:xmpp:jingle:transports:s5b:0"
-#define JINGLE_TRANSPORT_IBB "urn:xmpp:jingle:transports:ibb:0"
+#define JINGLE_TRANSPORT_S5B "urn:xmpp:jingle:transports:s5b:1"
+#define JINGLE_TRANSPORT_IBB "urn:xmpp:jingle:transports:ibb:1"
 #define JINGLE_TRANSPORT_ICEUDP "urn:xmpp:jingle:transports:ice-udp:0"
 #define JINGLE_TRANSPORT_RAWUDP "urn:xmpp:jingle:transports:raw-udp:1"
 
============================================================
--- libpurple/protocols/jabber/libxmpp.c	fa043b1f5afe35d48893e52f7eb9df685fd9a2e7
+++ libpurple/protocols/jabber/libxmpp.c	ed7d8ec3588157e2e5624e12ae61642b0219ca97
@@ -45,6 +45,8 @@
 #include "caps.h"
 #include "data.h"
 #include "ibb.h"
+#include "xfer.h"
+#include "jingle/jingle.h"
 
 static PurplePluginProtocolInfo prpl_info =
 {
@@ -108,8 +110,8 @@ static PurplePluginProtocolInfo prpl_inf
 	jabber_roomlist_cancel,			/* roomlist_cancel */
 	NULL,							/* roomlist_expand_category */
 	NULL,							/* can_receive_file */
-	jabber_si_xfer_send,			/* send_file */
-	jabber_si_new_xfer,				/* new_xfer */
+	jabber_xfer_send,				/* send_file */
+	jabber_xfer_new,				/* new_xfer */
 	jabber_offline_message,			/* offline_message */
 	NULL,							/* whiteboard_prpl_ops */
 	jabber_prpl_send_raw,			/* send_raw */
@@ -306,6 +308,7 @@ init_plugin(PurplePlugin *plugin)
 #ifdef USE_VV
 	jabber_add_feature("voice-v1", "http://www.xmpp.org/extensions/xep-0167.html#ns", NULL);
 #endif
+	/*jabber_add_feature("jingle-ft", JINGLE_APP_FT, NULL);*/
 }
 
 
============================================================
--- libpurple/protocols/jabber/si.c	a4ac8333ece742e060e6f912f9a66681993e832f
+++ libpurple/protocols/jabber/si.c	7ce820988b51d93017cb4ec5aaff37fda0892ade
@@ -35,6 +35,7 @@
 #include "ibb.h"
 #include "iq.h"
 #include "si.h"
+#include "xfer.h"
 
 #define STREAMHOST_CONNECT_TIMEOUT 15
 
@@ -1239,8 +1240,7 @@ static void jabber_si_xfer_send_request(
 {
 	JabberSIXfer *jsx = xfer->data;
 	JabberIq *iq;
-	xmlnode *si, *file, *feature, *x, *field, *option, *value;
-	char buf[32];
+	xmlnode *si, *feature, *x, *field, *option, *value;
 
 	xfer->filename = g_path_get_basename(xfer->local_filename);
 
@@ -1253,13 +1253,7 @@ static void jabber_si_xfer_send_request(
 	xmlnode_set_attrib(si, "profile",
 			"http://jabber.org/protocol/si/profile/file-transfer");
 
-	file = xmlnode_new_child(si, "file");
-	xmlnode_set_namespace(file,
-			"http://jabber.org/protocol/si/profile/file-transfer");
-	xmlnode_set_attrib(file, "name", xfer->filename);
-	g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, xfer->size);
-	xmlnode_set_attrib(file, "size", buf);
-	/* maybe later we'll do hash and date attribs */
+	xmlnode_insert_child(si, jabber_xfer_create_file_element(xfer));
 
 	feature = xmlnode_new_child(si, "feature");
 	xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
@@ -1589,7 +1583,7 @@ void jabber_si_parse(JabberStream *js, x
 	JabberSIXfer *jsx;
 	PurpleXfer *xfer;
 	xmlnode *si, *file, *feature, *x, *field, *option, *value;
-	const char *stream_id, *filename, *filesize_c, *profile, *from;
+	const char *stream_id, *profile, *from;
 	size_t filesize = 0;
 
 	if(!(si = xmlnode_get_child(packet, "si")))
@@ -1605,12 +1599,6 @@ void jabber_si_parse(JabberStream *js, x
 	if(!(file = xmlnode_get_child(si, "file")))
 		return;
 
-	if(!(filename = xmlnode_get_attrib(file, "name")))
-		return;
-
-	if((filesize_c = xmlnode_get_attrib(file, "size")))
-		filesize = atoi(filesize_c);
-
 	if(!(feature = xmlnode_get_child(si, "feature")))
 		return;
 
@@ -1660,15 +1648,9 @@ void jabber_si_parse(JabberStream *js, x
 	jsx->stream_id = g_strdup(stream_id);
 	jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
 
-	xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from);
+	xfer = jabber_xfer_create_from_xml(js->gc->account, file, from, jsx);
 	if (xfer)
 	{
-		xfer->data = jsx;
-
-		purple_xfer_set_filename(xfer, filename);
-		if(filesize > 0)
-			purple_xfer_set_size(xfer, filesize);
-
 		purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
 		purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied);
 		purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv);
@@ -1677,6 +1659,8 @@ void jabber_si_parse(JabberStream *js, x
 		js->file_transfers = g_list_append(js->file_transfers, xfer);
 
 		purple_xfer_request(xfer);
+	} else {
+		jabber_si_xfer_free(jsx);
 	}
 }
 


More information about the Commits mailing list