comparison 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
comparison
equal deleted inserted replaced
25172:125cac3e24ee 25237:401f548e3544
35 int nb_namespaces, const xmlChar **namespaces, 35 int nb_namespaces, const xmlChar **namespaces,
36 int nb_attributes, int nb_defaulted, const xmlChar **attributes) 36 int nb_attributes, int nb_defaulted, const xmlChar **attributes)
37 { 37 {
38 JabberStream *js = user_data; 38 JabberStream *js = user_data;
39 xmlnode *node; 39 xmlnode *node;
40 int i; 40 int i, j;
41 41
42 if(!element_name) { 42 if(!element_name) {
43 return; 43 return;
44 } else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) { 44 } else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) {
45 js->protocol_version = JABBER_PROTO_0_9; 45 js->protocol_version = JABBER_PROTO_0_9;
55 g_free(attrib); 55 g_free(attrib);
56 } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) { 56 } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) {
57 g_free(js->stream_id); 57 g_free(js->stream_id);
58 js->stream_id = attrib; 58 js->stream_id = attrib;
59 } else { 59 } else {
60 g_free(attrib); 60 g_free(attrib);
61 } 61 }
62 } 62 }
63 if(js->protocol_version == JABBER_PROTO_0_9) 63 if(js->protocol_version == JABBER_PROTO_0_9)
64 js->auth_type = JABBER_AUTH_IQ_AUTH; 64 js->auth_type = JABBER_AUTH_IQ_AUTH;
65 65
70 if(js->current) 70 if(js->current)
71 node = xmlnode_new_child(js->current, (const char*) element_name); 71 node = xmlnode_new_child(js->current, (const char*) element_name);
72 else 72 else
73 node = xmlnode_new((const char*) element_name); 73 node = xmlnode_new((const char*) element_name);
74 xmlnode_set_namespace(node, (const char*) namespace); 74 xmlnode_set_namespace(node, (const char*) namespace);
75 75 xmlnode_set_prefix(node, (const char *)prefix);
76
77 if (nb_namespaces != 0) {
78 node->namespace_map = g_hash_table_new_full(
79 g_str_hash, g_str_equal, g_free, g_free);
80
81 for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
82 const char *key = (const char *)namespaces[j];
83 const char *val = (const char *)namespaces[j + 1];
84 g_hash_table_insert(node->namespace_map,
85 g_strdup(key ? key : ""), g_strdup(val ? val : ""));
86 }
87 }
76 for(i=0; i < nb_attributes * 5; i+=5) { 88 for(i=0; i < nb_attributes * 5; i+=5) {
89 const char *prefix = (const char *)attributes[i + 1];
77 char *txt; 90 char *txt;
78 int attrib_len = attributes[i+4] - attributes[i+3]; 91 int attrib_len = attributes[i+4] - attributes[i+3];
79 char *attrib = g_malloc(attrib_len + 1); 92 char *attrib = g_malloc(attrib_len + 1);
80 char *attrib_ns = NULL; 93 char *attrib_ns = NULL;
81 94
88 101
89 txt = attrib; 102 txt = attrib;
90 attrib = purple_unescape_html(txt); 103 attrib = purple_unescape_html(txt);
91 g_free(txt); 104 g_free(txt);
92 xmlnode_set_attrib_with_namespace(node, (const char*) attributes[i], attrib_ns, attrib); 105 xmlnode_set_attrib_with_namespace(node, (const char*) attributes[i], attrib_ns, attrib);
106 if (prefix && *prefix) {
107 node->prefix = g_strdup(prefix);
108 }
93 g_free(attrib); 109 g_free(attrib);
94 g_free(attrib_ns); 110 g_free(attrib_ns);
95 } 111 }
96 112
97 js->current = node; 113 js->current = node;