diff libpurple/protocols/jabber/parser.c @ 25237:401f548e3544

propagate from branch 'im.pidgin.pidgin' (head df6eba32e5b6b34d7483cbfb7e9f2e4c836ac35f) to branch 'org.darkrain42.pidgin.buddy-add' (head 6831808999a270f8c1a128c7430a73d3dc0bfae2)
author Paul Aurich <paul@darkrain42.org>
date Sun, 21 Dec 2008 18:32:37 +0000
parents f5c0cdaef99a
children ee9b00cc4298
line wrap: on
line diff
--- a/libpurple/protocols/jabber/parser.c	Sat Nov 29 18:46:49 2008 +0000
+++ b/libpurple/protocols/jabber/parser.c	Sun Dec 21 18:32:37 2008 +0000
@@ -37,7 +37,7 @@
 {
 	JabberStream *js = user_data;
 	xmlnode *node;
-	int i;
+	int i, j;
 
 	if(!element_name) {
 		return;
@@ -57,7 +57,7 @@
 				g_free(js->stream_id);
 				js->stream_id = attrib;
 			} else {
-				g_free(attrib);	
+				g_free(attrib);
 			}
 		}
 		if(js->protocol_version == JABBER_PROTO_0_9)
@@ -72,8 +72,21 @@
 		else
 			node = xmlnode_new((const char*) element_name);
 		xmlnode_set_namespace(node, (const char*) namespace);
+		xmlnode_set_prefix(node, (const char *)prefix);
 
+		if (nb_namespaces != 0) {
+			node->namespace_map = g_hash_table_new_full(
+				g_str_hash, g_str_equal, g_free, g_free);
+
+			for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
+				const char *key = (const char *)namespaces[j];
+				const char *val = (const char *)namespaces[j + 1];
+				g_hash_table_insert(node->namespace_map,
+					g_strdup(key ? key : ""), g_strdup(val ? val : ""));
+			}
+		}
 		for(i=0; i < nb_attributes * 5; i+=5) {
+			const char *prefix = (const char *)attributes[i + 1];
 			char *txt;
 			int attrib_len = attributes[i+4] - attributes[i+3];
 			char *attrib = g_malloc(attrib_len + 1);
@@ -90,6 +103,9 @@
 			attrib = purple_unescape_html(txt);
 			g_free(txt);
 			xmlnode_set_attrib_with_namespace(node, (const char*) attributes[i], attrib_ns, attrib);
+			if (prefix && *prefix) {
+				node->prefix = g_strdup(prefix);
+			}
 			g_free(attrib);
 			g_free(attrib_ns);
 		}