changeset 26539:20743d9bd62d

Fix allowing gmail user to initiate voice call by advertising a specific ext From xep-0115 v1.3: "The names of the feature bundles MUST NOT be used for semantic purposes: they are merely opaque identifiers that will be used in other use cases."
author Paul Aurich <paul@darkrain42.org>
date Sat, 04 Apr 2009 17:01:59 +0000
parents a9d5067ad6e7
children f25410b0827c
files libpurple/protocols/jabber/caps.c libpurple/protocols/jabber/disco.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/presence.c
diffstat 5 files changed, 41 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/caps.c	Sat Apr 04 07:29:50 2009 +0000
+++ b/libpurple/protocols/jabber/caps.c	Sat Apr 04 17:01:59 2009 +0000
@@ -552,7 +552,7 @@
 	jabber_caps_cbplususerdata *userdata;
 
 	if (ext && *ext && hash)
-		purple_debug_warning("jabber", "Ignoring exts in new-style caps from %s\n",
+		purple_debug_info("jabber", "Ignoring exts in new-style caps from %s\n",
 		                     who);
 
 	/* Using this in a read-only fashion, so the cast is OK */
--- a/libpurple/protocols/jabber/disco.c	Sat Apr 04 07:29:50 2009 +0000
+++ b/libpurple/protocols/jabber/disco.c	Sat Apr 04 17:01:59 2009 +0000
@@ -148,6 +148,20 @@
 					xmlnode_set_attrib(feature, "var", feat->namespace);
 				}	
 			}
+#ifdef USE_VV
+		} else if (g_str_equal(node, CAPS0115_NODE "#" "voice-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 'voice-v1'.
+			 */
+			xmlnode *feature = xmlnode_new_child(query, "feature");
+			xmlnode_set_attrib(feature, "var", "http://www.google.com/xmpp/protocol/voice/v1");
+#endif
 		} else {
 			xmlnode *error, *inf;
 				
--- a/libpurple/protocols/jabber/jabber.c	Sat Apr 04 07:29:50 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat Apr 04 17:01:59 2009 +0000
@@ -2730,8 +2730,8 @@
 }
 
 #ifdef USE_VV
-static gboolean
-feature_audio_enabled(JabberStream *js, const char *namespace)
+gboolean
+jabber_audio_enabled(JabberStream *js, const char *namespace)
 {
 	PurpleMediaManager *manager = purple_media_manager_get();
 	PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
@@ -2740,7 +2740,7 @@
 }
 
 static gboolean
-feature_video_enabled(JabberStream *js, const char *namespace)
+jabber_video_enabled(JabberStream *js, const char *namespace)
 {
 	PurpleMediaManager *manager = purple_media_manager_get();
 	PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
@@ -2749,7 +2749,7 @@
 }
 
 static gboolean
-feature_ice_transmitter_present(JabberStream *js, const char *namespace)
+jabber_ice_transmitter_present(JabberStream *js, const char *namespace)
 {
 	return purple_media_transmitter_exists("nice");
 }
@@ -3189,11 +3189,11 @@
 	jabber_add_feature(JINGLE_TRANSPORT_RAWUDP, 0);
 
 #ifdef USE_VV
-	jabber_add_feature("http://www.google.com/xmpp/protocol/session", feature_audio_enabled);
-	jabber_add_feature("http://www.google.com/xmpp/protocol/voice/v1", feature_audio_enabled);
-	jabber_add_feature(JINGLE_APP_RTP_SUPPORT_AUDIO, feature_audio_enabled);
-	jabber_add_feature(JINGLE_APP_RTP_SUPPORT_VIDEO, feature_video_enabled);
-	jabber_add_feature(JINGLE_TRANSPORT_ICEUDP, feature_ice_transmitter_present);
+	jabber_add_feature("http://www.google.com/xmpp/protocol/session", jabber_audio_enabled);
+	jabber_add_feature("http://www.google.com/xmpp/protocol/voice/v1", jabber_audio_enabled);
+	jabber_add_feature(JINGLE_APP_RTP_SUPPORT_AUDIO, jabber_audio_enabled);
+	jabber_add_feature(JINGLE_APP_RTP_SUPPORT_VIDEO, jabber_video_enabled);
+	jabber_add_feature(JINGLE_TRANSPORT_ICEUDP, jabber_ice_transmitter_present);
 #endif
 
 	/* IPC functions */
--- a/libpurple/protocols/jabber/jabber.h	Sat Apr 04 07:29:50 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Sat Apr 04 17:01:59 2009 +0000
@@ -355,9 +355,12 @@
 gboolean jabber_offline_message(const PurpleBuddy *buddy);
 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len);
 GList *jabber_actions(PurplePlugin *plugin, gpointer context);
+
+gboolean jabber_audio_enabled(JabberStream *js, const char *unused);
 gboolean jabber_initiate_media(PurpleConnection *gc, const char *who,
 		PurpleMediaSessionType type);
 PurpleMediaCaps jabber_get_media_caps(PurpleConnection *gc, const char *who);
+
 void jabber_register_commands(void);
 
 void jabber_init_plugin(PurplePlugin *plugin);
--- a/libpurple/protocols/jabber/presence.c	Sat Apr 04 07:29:50 2009 +0000
+++ b/libpurple/protocols/jabber/presence.c	Sat Apr 04 17:01:59 2009 +0000
@@ -273,6 +273,20 @@
 	xmlnode_set_attrib(c, "hash", "sha-1");
 	xmlnode_set_attrib(c, "ver", jabber_caps_get_own_hash(js));
 
+#ifdef USE_VV
+	/*
+	 * MASSIVE HUGE DISGUSTING HACK
+	 * This is a huge hack. As far as I can tell, Google Talk's gmail client
+	 * doesn't bother to check the actual features we advertise; they
+	 * just assume that if we advertise a 'voice-v1' ext (ignoring that
+	 * these are to be assigned no semantic value). We need to advertise
+	 * this for the gmail web interface chat client to allow the mail user
+	 * to start a voice chat with us. Boo.
+	 */
+	if (jabber_audio_enabled(js, NULL /* unused */))
+		xmlnode_set_attrib(c, "ext", "voice-v1");
+#endif
+
 	return presence;
 }