cpw.malu.xmpp.jingle_ft: d20d0df3: Set the "sid" attribute on the S5B <tran...

malu at pidgin.im malu at pidgin.im
Mon Mar 30 15:50:47 EDT 2009


-----------------------------------------------------------------
Revision: d20d0df3fba9e39aad8a71e0f25ce51ef7a87d20
Ancestor: 12c14e4835c36f346e8ff814bedc7e5b5862a89a
Author: malu at pidgin.im
Date: 2009-03-30T19:48:24
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/d20d0df3fba9e39aad8a71e0f25ce51ef7a87d20

Modified files:
        libpurple/protocols/jabber/jingle/file-transfer.c
        libpurple/protocols/jabber/jingle/s5b.c
        libpurple/protocols/jabber/jingle/s5b.h

ChangeLog: 

Set the "sid" attribute on the S5B <transport/> element

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c	9ba95a8304ca12c8f8e249f48fa1bc6624d3d7bd
+++ libpurple/protocols/jabber/jingle/file-transfer.c	1644f917d8c3c9313d0e73af9e4c869da9d09931
@@ -440,6 +440,10 @@ jingle_file_transfer_xfer_init(PurpleXfe
 			jabber_iq_send(jingle_session_to_packet(session, 
 				JINGLE_SESSION_INITIATE));
 		} else if (JINGLE_IS_S5B(transport)) {
+			/* generate a new sid to set for the transport */
+			sid = jabber_get_next_id(js);
+			jingle_s5b_set_sid(JINGLE_S5B(transport), sid);
+			g_free(sid);
 			/* start local listen on the S5B transport */
 			jingle_s5b_gather_streamhosts(session, JINGLE_S5B(transport));
 		}	
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c	34815a3ac1dd2e4dad3b4d5daa0a9f39c0dc9e13
+++ libpurple/protocols/jabber/jingle/s5b.c	006452258b1cb5e77c9266de3062004b056989bd
@@ -112,6 +112,7 @@ struct _JingleS5BPrivate {
 
 struct _JingleS5BPrivate {
 	/* S5B stuff here... */
+	gchar *sid;
 	guint fd;
 	guint local_fd;
 	guint remote_fd;
@@ -134,7 +135,8 @@ enum {
 static JingleTransportClass *parent_class = NULL;
 
 enum {
-	PROP_0
+	PROP_0,
+	PROP_SID
 };
 
 GType
@@ -173,6 +175,13 @@ jingle_s5b_class_init (JingleS5BClass *k
 	klass->parent_class.parse = jingle_s5b_parse_internal;
 	klass->parent_class.transport_type = JINGLE_TRANSPORT_S5B;
 
+	g_object_class_install_property(gobject_class, PROP_SID,
+		g_param_spec_string("sid",
+		"Session ID",
+		"The unique session ID of the S5B transport.",
+		NULL,
+		G_PARAM_READWRITE));
+	
 	g_type_class_add_private(klass, sizeof(JingleS5BPrivate));
 }
 
@@ -186,6 +195,7 @@ jingle_s5b_init (JingleS5B *s5b)
 	s5b->priv->fd = 0;
 	s5b->priv->local_fd = 0;
 	s5b->priv->remote_fd = 0;
+	s5b->priv->sid = NULL;
 }
 
 static void
@@ -194,6 +204,9 @@ jingle_s5b_finalize (GObject *s5b)
 	JingleS5BPrivate *priv = JINGLE_S5B_GET_PRIVATE(s5b);
 	purple_debug_info("jingle-s5b","jingle_s5b_finalize\n");
 	
+	if (priv->sid)
+		g_free(priv->sid);
+	
 	/* free the local streamhosts */
 	while (priv->local_streamhosts) {
 		jingle_s5b_streamhost_destroy(
@@ -223,6 +236,10 @@ jingle_s5b_set_property (GObject *object
 	s5b = JINGLE_S5B(object);
 
 	switch (prop_id) {
+		case PROP_SID:
+			g_free(s5b->priv->sid);
+			s5b->priv->sid = g_value_dup_string(value);
+			break;	
 		default:	
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;
@@ -239,12 +256,29 @@ jingle_s5b_get_property (GObject *object
 	s5b = JINGLE_S5B(object);
 
 	switch (prop_id) {
+		case PROP_SID:
+			g_value_set_string(value, s5b->priv->sid);
+			break;
 		default:	
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);	
 			break;
 	}
 }
 
+const gchar *
+jingle_s5b_get_sid(const JingleS5B *s5b)
+{
+	gchar *sid;
+	g_object_get((gpointer) s5b, "sid", &sid, NULL);
+	return sid;
+}
+
+void
+jingle_s5b_set_sid(JingleS5B *s5b, const gchar *sid)
+{
+	g_object_set(s5b, "sid", sid, NULL);
+}
+
 static JingleTransport *
 jingle_s5b_parse_internal(xmlnode *s5b)
 {
@@ -252,6 +286,10 @@ jingle_s5b_parse_internal(xmlnode *s5b)
 	JingleS5BPrivate *priv = JINGLE_S5B_GET_PRIVATE(transport);
 	xmlnode *streamhost;
 	
+	/* set the sid from the incoming transport */
+	jingle_s5b_set_sid(JINGLE_S5B(transport), 
+		xmlnode_get_attrib(s5b, "sid"));
+	
 	for (streamhost = xmlnode_get_child(s5b, "streamhost");
 		 streamhost;
 		 streamhost = xmlnode_get_next_twin(streamhost)) {
@@ -281,6 +319,8 @@ jingle_s5b_to_xml_internal(JingleTranspo
 	
 	purple_debug_info("jingle", "jingle_s5b_to_xml_internal\n");
 
+	xmlnode_set_attrib(node, "sid", jingle_s5b_get_sid(s5b));
+	
 	/* always set "mode" to "tcp" */
 	xmlnode_set_attrib(node, "mode", "tcp");
 
============================================================
--- libpurple/protocols/jabber/jingle/s5b.h	4e6fd5070a99265110276fb2557cf518a00ffe36
+++ libpurple/protocols/jabber/jingle/s5b.h	acde221857e73e00253201bf3ed8f38de8c44599
@@ -65,6 +65,9 @@ GType jingle_s5b_get_type(void);
  */
 GType jingle_s5b_get_type(void);
 
+const gchar *jingle_s5b_get_sid(const JingleS5B *s5b);
+void jingle_s5b_set_sid(JingleS5B *s5b, const gchar *sid);
+
 /* start discovering streamhosts, initiator will send session-initiate when
 	done, receiver will send transport-info */
 void jingle_s5b_gather_streamhosts(JingleSession *session, JingleS5B *s5b);


More information about the Commits mailing list