pidgin.vv: 35d58b1f: Add functions for more easily creating s...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Tue Mar 17 06:20:43 EDT 2009


-----------------------------------------------------------------
Revision: 35d58b1fc34550022acd6be280ab6ce5a2614975
Ancestor: 24451793eefe89a0ce1a97de546721121cd37cb4
Author: maiku at soc.pidgin.im
Date: 2009-03-17T04:40:25
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/35d58b1fc34550022acd6be280ab6ce5a2614975

Modified files:
        libpurple/protocols/jabber/jingle/rtp.c
        libpurple/protocols/jabber/jingle/session.c
        libpurple/protocols/jabber/jingle/session.h

ChangeLog: 

Add functions for more easily creating session-terminate packets.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	d40f2703bf52428de34fdbce6851780d936d8dfe
+++ libpurple/protocols/jabber/jingle/rtp.c	0d00b133968013ba6a75d480b7010fc1e9864838
@@ -372,8 +372,8 @@ jingle_rtp_state_changed_cb(PurpleMedia 
 	if ((type == PURPLE_MEDIA_STATE_CHANGED_REJECTED ||
 			type == PURPLE_MEDIA_STATE_CHANGED_HANGUP) &&
 			sid == NULL && name == NULL) {
-		jabber_iq_send(jingle_session_to_packet(session,
-				JINGLE_SESSION_TERMINATE));
+		jabber_iq_send(jingle_session_terminate_packet(
+				session, "success"));
 		g_object_unref(session);
 	}
 }
@@ -616,8 +616,8 @@ jingle_rtp_handle_action_internal(Jingle
 
 			if (jingle_rtp_init_media(content) == FALSE) {
 				/* XXX: send error */
-				jabber_iq_send(jingle_session_to_packet(session,
-						 JINGLE_SESSION_TERMINATE));
+				jabber_iq_send(jingle_session_terminate_packet(
+						session, "general-error"));
 				g_object_unref(session);
 				break;
 			}
============================================================
--- libpurple/protocols/jabber/jingle/session.c	6c2a9e3d215e811884a0f2c687510d4cadbdc977
+++ libpurple/protocols/jabber/jingle/session.c	23ee6c3c312b31bf43e394626e5436b28061dff9
@@ -590,3 +590,38 @@ jingle_session_accept_session(JingleSess
 	session->priv->state = TRUE;
 }
 
+JabberIq *
+jingle_session_terminate_packet(JingleSession *session, const gchar *reason)
+{
+	JabberIq *iq = jingle_session_to_packet(session,
+			JINGLE_SESSION_TERMINATE);
+	xmlnode *jingle = xmlnode_get_child(iq->node, "jingle");
+
+	if (reason != NULL) {
+		JabberIq *reason_node;
+		reason_node = xmlnode_new_child(jingle, "reason");
+		xmlnode_new_child(reason_node, reason);
+	}
+	return iq;
+}
+
+JabberIq *
+jingle_session_redirect_packet(JingleSession *session, const gchar *sid)
+{
+	JabberIq *iq = jingle_session_terminate_packet(session,
+			"alternative-session");
+	xmlnode *alt_session;
+
+	if (sid == NULL)
+		return iq;
+
+	alt_session = xmlnode_get_child(iq->node,
+			"jingle/reason/alternative-session");
+
+	if (alt_session != NULL) {
+		xmlnode *sid_node = xmlnode_new_child(alt_session, "sid");
+		xmlnode_insert_data(sid_node, sid, -1);
+	}
+	return iq;
+}
+
============================================================
--- libpurple/protocols/jabber/jingle/session.h	9fce12430e57096761a8ace03df6b1b28934be7a
+++ libpurple/protocols/jabber/jingle/session.h	632354c61c6d9e4d55a831241a52ff6c66117fc0
@@ -102,6 +102,8 @@ void jingle_session_accept_session(Jingl
 void jingle_session_remove_pending_content(JingleSession *session, const gchar *name, const gchar *creator);
 void jingle_session_accept_content(JingleSession *session, const gchar *name, const gchar *creator);
 void jingle_session_accept_session(JingleSession *session);
+JabberIq *jingle_session_terminate_packet(JingleSession *session, const gchar *reason);
+JabberIq *jingle_session_redirect_packet(JingleSession *session, const gchar *sid);
 
 #ifdef __cplusplus
 }


More information about the Commits mailing list