cpw.malu.xmpp.google_ft: 48e79fbc: First steps to support Google Talk file ...

malu at pidgin.im malu at pidgin.im
Mon Sep 6 17:50:42 EDT 2010


----------------------------------------------------------------------
Revision: 48e79fbc52b2e71828b53c72a7f4a122542c1ea1
Parent:   7b998c02b684a694f1089bee715e4a3952bbcf08
Author:   malu at pidgin.im
Date:     09/06/10 17:47:23
Branch:   im.pidgin.cpw.malu.xmpp.google_ft
URL: http://d.pidgin.im/viewmtn/revision/info/48e79fbc52b2e71828b53c72a7f4a122542c1ea1

Changelog: 

First steps to support Google Talk file transfer. Detect support for libnice 0.0.11 (to use pseudo-tcp), advertise caps to annonce support. Does NOT yet work :). Refs #1507

Changes against parent 7b998c02b684a694f1089bee715e4a3952bbcf08

  patched  configure.ac
  patched  libpurple/protocols/jabber/disco.c
  patched  libpurple/protocols/jabber/jabber.c
  patched  libpurple/protocols/jabber/namespaces.h
  patched  libpurple/protocols/jabber/presence.c

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	f4de9f9146812cca9194ceff2eeb1fa53ff63c8a
+++ libpurple/protocols/jabber/jabber.c	34829a96870db555f76a98fef04248288c273b0a
@@ -3827,6 +3827,11 @@ jabber_do_init(void)
 			G_CALLBACK(jabber_caps_broadcast_change), NULL);
 #endif
 
+	/* support for Google file transfer (using pseudo-tcp) */
+#ifdef USE_LIBNICE
+	jabber_add_feature(NS_GOOGLE_SHARE, 0);
+#endif
+	                   
 	/* reverse order of unload_plugin */
 	jabber_iq_init();
 	jabber_presence_init();
============================================================
--- configure.ac	f81eb8e7c52d6ed93e0b7d777edc9ed6c169c5b7
+++ configure.ac	588b6af6d7add7024959e82533cc5f697567dae0
@@ -867,6 +867,32 @@ dnl ####################################
 fi
 
 dnl #######################################################################
+dnl # Check for libnice pseudo-tcp support (for Google file transfer)
+dnl #######################################################################
+
+AC_ARG_ENABLE(libnice,
+	[AC_HELP_STRING([--disable-libnice],
+		[compile without libnice support])],
+		[enable_libnice="$enablelibnice" force_libnice=$enablelibnice],
+		[enable_libnice="yes" force_libnice=no])
+if test "x$enablelibnice" != "xno"; then
+	PKG_CHECK_MODULES(LIBNICE, nice >= 0.0.11, [
+		AC_DEFINE(USE_LIBNICE, 1, [Use libnice for pseudo-tcp support])
+		AC_SUBST(LIBNICE_CFLAGS)
+		AC_SUBST(LIBNICE_LIBS)
+	], [
+		AC_MSG_RESULT(no)
+		enable_libnice="no"
+		if test "x$force_deps" = "xyes" ; then
+			AC_MSG_ERROR([
+Libnice development headers (version 0.0.11 or later) not found.
+Use --disable-libnice if you don't need it.
+])
+		fi
+	])
+fi
+
+dnl #######################################################################
 dnl # Check for Meanwhile headers (for Sametime)
 dnl #######################################################################
 AC_ARG_ENABLE(meanwhile,
@@ -2639,6 +2665,7 @@ echo Build with voice and video.... : $e
 echo Build with GStreamer support.. : $enable_gst
 echo Build with D-Bus support...... : $enable_dbus
 echo Build with voice and video.... : $enable_vv
+echo Build with libnice support.... : $enable_libnice
 if test "x$enable_dbus" = "xyes" ; then
 	eval eval echo D-Bus services directory...... : $DBUS_SERVICES_DIR
 fi
============================================================
--- libpurple/protocols/jabber/presence.c	ed4c461fe70b553d0caeefc07b0b949649f10d7e
+++ libpurple/protocols/jabber/presence.c	10c44a90e41acce88a5318eb441c2fbcd8e027a0
@@ -311,6 +311,7 @@ xmlnode *jabber_presence_create_js(Jabbe
 #ifdef USE_VV
 	gboolean audio_enabled, video_enabled;
 #endif
+	GString *ext = g_string_new("");
 
 	presence = xmlnode_new("presence");
 
@@ -372,14 +373,27 @@ xmlnode *jabber_presence_create_js(Jabbe
 	audio_enabled = jabber_audio_enabled(js, NULL /* unused */);
 	video_enabled = jabber_video_enabled(js, NULL /* unused */);
 
-	if (audio_enabled && video_enabled)
-		xmlnode_set_attrib(c, "ext", "voice-v1 camera-v1 video-v1");
-	else if (audio_enabled)
-		xmlnode_set_attrib(c, "ext", "voice-v1");
-	else if (video_enabled)
-		xmlnode_set_attrib(c, "ext", "camera-v1 video-v1");
+	if (audio_enabled)
+	    ext = g_string_append(ext, "voice-v1");
+	if (ext->len > 0)
+	    ext = g_string_append(ext, " ");
+	if (video_enabled)
+	    ext = g_string_append(ext, "camera-v1 video-v1");
 #endif
-
+#ifdef USE_LIBNICE
+	/*
+	 * See above, hack to make Google file transfer advertised
+	 */
+	if (ext->len > 0)
+	   ext = g_string_append(ext, " ");
+	ext = g_string_append(ext, "share-v1");
+#endif
+	purple_debug_info("jabber", "include ext: %s\n", ext->str);
+	if (ext->len > 0)
+		xmlnode_set_attrib(c, "ext", g_string_free(ext, FALSE));
+	else
+	    g_string_free(ext, TRUE);
+	                      
 	return presence;
 }
 
============================================================
--- libpurple/protocols/jabber/disco.c	0e8c66e2234a79292863c97d46264a79b9690d40
+++ libpurple/protocols/jabber/disco.c	d3335a2eb3309fab4e75100e367b295e40ceb0ee
@@ -180,6 +180,20 @@ void jabber_disco_info_parse(JabberStrea
 			xmlnode *feature = xmlnode_new_child(query, "feature");
 			xmlnode_set_attrib(feature, "var", NS_GOOGLE_CAMERA);
 #endif
+#ifdef USE_LIBNICE
+		} else if (g_str_equal(node, CAPS0115_NODE "#" "share-v1")) {
+			/*
+			 * HUGE HACK! We advertise this ext (see jabber_presence_create_js
+			 * where we add <c/> to the <presence/>) for the Google Talk
+			 * clients that don't actually check disco#info features.
+			 *
+			 * This specific feature is redundant but is what
+			 * node='http://mail.google.com/xmpp/client/caps', ver='1.1'
+			 * advertises as 'share-v1'.
+			 */
+			xmlnode *feature = xmlnode_new_child(query, "feature");
+			xmlnode_set_attrib(feature, "var", NS_GOOGLE_SHARE);
+#endif
 		} else {
 			xmlnode *error, *inf;
 
============================================================
--- libpurple/protocols/jabber/namespaces.h	3390412e0ed6ef353763f53f07781fa21c0b2d2c
+++ libpurple/protocols/jabber/namespaces.h	2ba3db33d9998e901bffb79fc011b16490832704
@@ -99,6 +99,7 @@
 #define NS_GOOGLE_CAMERA "http://www.google.com/xmpp/protocol/camera/v1"
 #define NS_GOOGLE_VIDEO "http://www.google.com/xmpp/protocol/video/v1"
 #define NS_GOOGLE_VOICE "http://www.google.com/xmpp/protocol/voice/v1"
+#define NS_GOOGLE_SHARE "http://www.google.com/xmpp/protocol/share/v1"
 #define NS_GOOGLE_JINGLE_INFO "google:jingleinfo"
 
 #define NS_GOOGLE_MAIL_NOTIFY "google:mail:notify"


More information about the Commits mailing list