changeset 23847:4e3cc48cdace

Further decouple Jingle from iq.c
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 10 Jul 2008 22:49:52 +0000
parents 86f05fa8a90a
children dfa7c7f676b2
files libpurple/protocols/jabber/iq.c libpurple/protocols/jabber/jingle.c libpurple/protocols/jabber/jingle.h
diffstat 3 files changed, 38 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/iq.c	Sat Jun 28 17:42:31 2008 +0000
+++ b/libpurple/protocols/jabber/iq.c	Thu Jul 10 22:49:52 2008 +0000
@@ -360,31 +360,9 @@
 	}
 	
 #ifdef USE_VV
-	/* handle session initiate XEP 0167 */
-	if (type && !strcmp(type, "set")) {
-		/* is this a Jingle package? */
-		xmlnode *jingle = xmlnode_get_child(packet, "jingle");
-		if (jingle) {
-			const char *action = xmlnode_get_attrib(jingle, "action");
-			purple_debug_info("jabber", "got Jingle package action = %s\n",
-							  action);
-			if (!strcmp(action, "session-initiate")) {
-				jabber_jingle_session_handle_session_initiate(js, packet);
-			} else if (!strcmp(action, "session-accept")
-					   || !strcmp(action, "content-accept")) {
-				jabber_jingle_session_handle_session_accept(js, packet);
-			} else if (!strcmp(action, "session-info")) {
-				jabber_jingle_session_handle_session_info(js, packet);
-			} else if (!strcmp(action, "session-terminate")) {
-				jabber_jingle_session_handle_session_terminate(js, packet);
-			} else if (!strcmp(action, "transport-info")) {
-				jabber_jingle_session_handle_transport_info(js, packet);
-			} else if (!strcmp(action, "content-replace")) {
-				jabber_jingle_session_handle_content_replace(js, packet);
-			}
-
-			return;
-		}
+	if (xmlnode_get_child_with_namespace(packet, "jingle", "urn:xmpp:tmp:jingle")) {
+		jabber_jingle_session_parse(js, packet);
+		return;
 	}
 #endif
 
@@ -427,6 +405,7 @@
 	jabber_iq_register_handler("http://jabber.org/protocol/disco#items", jabber_disco_items_parse);
 	jabber_iq_register_handler("jabber:iq:register", jabber_register_parse);
 	jabber_iq_register_handler("urn:xmpp:ping", urn_xmpp_ping_parse);
+	jabber_iq_register_handler("urn:xmpp:tmp:jingle", jabber_jingle_session_parse);
 }
 
 void jabber_iq_uninit(void)
--- a/libpurple/protocols/jabber/jingle.c	Sat Jun 28 17:42:31 2008 +0000
+++ b/libpurple/protocols/jabber/jingle.c	Thu Jul 10 22:49:52 2008 +0000
@@ -1394,5 +1394,37 @@
 	}
 }
 
+void
+jabber_jingle_session_parse(JabberStream *js, xmlnode *packet)
+{
+	const gchar *type = xmlnode_get_attrib(packet, "type");
+
+	if (type && !strcmp(type, "set")) {
+		/* is this a Jingle package? */
+		xmlnode *jingle = xmlnode_get_child(packet, "jingle");
+		if (jingle) {
+			const char *action = xmlnode_get_attrib(jingle, "action");
+			purple_debug_info("jabber", "got Jingle package action = %s\n",
+							  action);
+			if (!strcmp(action, "session-initiate")) {
+				jabber_jingle_session_handle_session_initiate(js, packet);
+			} else if (!strcmp(action, "session-accept")
+					   || !strcmp(action, "content-accept")) {
+				jabber_jingle_session_handle_session_accept(js, packet);
+			} else if (!strcmp(action, "session-info")) {
+				jabber_jingle_session_handle_session_info(js, packet);
+			} else if (!strcmp(action, "session-terminate")) {
+				jabber_jingle_session_handle_session_terminate(js, packet);
+			} else if (!strcmp(action, "transport-info")) {
+				jabber_jingle_session_handle_transport_info(js, packet);
+			} else if (!strcmp(action, "content-replace")) {
+				jabber_jingle_session_handle_content_replace(js, packet);
+			}
+
+			return;
+		}
+	}
+}
+
 #endif /* USE_VV */
 
--- a/libpurple/protocols/jabber/jingle.h	Sat Jun 28 17:42:31 2008 +0000
+++ b/libpurple/protocols/jabber/jingle.h	Thu Jul 10 22:49:52 2008 +0000
@@ -33,6 +33,8 @@
 
 G_BEGIN_DECLS
 
+void jabber_jingle_session_parse(JabberStream *js, xmlnode *packet);
+
 PurpleMedia *jabber_jingle_session_initiate_media(JabberStream *js,
 						  const char *who,
 						  PurpleMediaStreamType type);