Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/parser.c @ 29309:2930170ca3c0
We allow aliasing chats. So don't show an error message when we try to.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Thu, 28 Jan 2010 21:44:16 +0000 |
parents | d558d141aaae |
children | e1c01f236674 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15823 | 2 * purple - Jabber XML parser stuff |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
28398
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27219
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27219
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27219
diff
changeset
|
6 * source distribution. |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15823
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include <libxml/parser.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "connection.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "jabber.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "parser.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "xmlnode.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 jabber_parser_element_start_libxml(void *user_data, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 const xmlChar *element_name, const xmlChar *prefix, const xmlChar *namespace, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 int nb_namespaces, const xmlChar **namespaces, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 int nb_attributes, int nb_defaulted, const xmlChar **attributes) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 JabberStream *js = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 xmlnode *node; |
24818
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
42 int i, j; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 if(!element_name) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 } else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 js->protocol_version = JABBER_PROTO_0_9; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 for(i=0; i < nb_attributes * 5; i += 5) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 int attrib_len = attributes[i+4] - attributes[i+3]; |
29108
f6f35d5960e9
Use g_strndup() for great justice.
Paul Aurich <paul@darkrain42.org>
parents:
29062
diff
changeset
|
50 char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 if(!xmlStrcmp(attributes[i], (xmlChar*) "version") |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 && !strcmp(attrib, "1.0")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 js->protocol_version = JABBER_PROTO_1_0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 g_free(attrib); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) { |
15635
baec42670246
Patch from MatsMattsson (Adium Trac #6429) which fixes a leak of attrib for any attribute that isn't 'id' or 'version'.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15498
diff
changeset
|
57 g_free(js->stream_id); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 js->stream_id = attrib; |
15635
baec42670246
Patch from MatsMattsson (Adium Trac #6429) which fixes a leak of attrib for any attribute that isn't 'id' or 'version'.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15498
diff
changeset
|
59 } else { |
24818
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
60 g_free(attrib); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 if(js->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 node = xmlnode_new_child(js->current, (const char*) element_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 node = xmlnode_new((const char*) element_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 xmlnode_set_namespace(node, (const char*) namespace); |
24818
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
70 xmlnode_set_prefix(node, (const char *)prefix); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 |
24818
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
72 if (nb_namespaces != 0) { |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
73 node->namespace_map = g_hash_table_new_full( |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
74 g_str_hash, g_str_equal, g_free, g_free); |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
75 |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
76 for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) { |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
77 const char *key = (const char *)namespaces[j]; |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
78 const char *val = (const char *)namespaces[j + 1]; |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
79 g_hash_table_insert(node->namespace_map, |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
80 g_strdup(key ? key : ""), g_strdup(val ? val : "")); |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
81 } |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24425
diff
changeset
|
82 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 for(i=0; i < nb_attributes * 5; i+=5) { |
26262
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
84 const char *name = (const char *)attributes[i]; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
85 const char *prefix = (const char *)attributes[i+1]; |
25110
b096f7fb6899
Don't set an attribute prefix on the node, and remove an unnecessary call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24898
diff
changeset
|
86 const char *attrib_ns = (const char *)attributes[i+2]; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 char *txt; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 int attrib_len = attributes[i+4] - attributes[i+3]; |
29108
f6f35d5960e9
Use g_strndup() for great justice.
Paul Aurich <paul@darkrain42.org>
parents:
29062
diff
changeset
|
89 char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 txt = attrib; |
15823 | 92 attrib = purple_unescape_html(txt); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 g_free(txt); |
26262
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25110
diff
changeset
|
94 xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 g_free(attrib); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 js->current = node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 jabber_parser_element_end_libxml(void *user_data, const xmlChar *element_name, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 const xmlChar *prefix, const xmlChar *namespace) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 JabberStream *js = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 if(!js->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 if(js->current->parent) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 if(!xmlStrcmp((xmlChar*) js->current->name, element_name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 js->current = js->current->parent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 xmlnode *packet = js->current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 js->current = NULL; |
17621
bbd92ee894f2
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17606
diff
changeset
|
117 jabber_process_packet(js, &packet); |
24425
7cf760f3560e
Don't try to free NULL xmlnodes stolen by jabber-receiving-xmlnode handlers
Will Thompson <will.thompson@collabora.co.uk>
parents:
24419
diff
changeset
|
118 if (packet != NULL) |
7cf760f3560e
Don't try to free NULL xmlnodes stolen by jabber-receiving-xmlnode handlers
Will Thompson <will.thompson@collabora.co.uk>
parents:
24419
diff
changeset
|
119 xmlnode_free(packet); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 jabber_parser_element_text_libxml(void *user_data, const xmlChar *text, int text_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 JabberStream *js = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 if(!js->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 if(!text || !text_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 xmlnode_insert_data(js->current, (const char*) text, text_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 |
23426
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
137 static void |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
138 jabber_parser_structured_error_handler(void *user_data, xmlErrorPtr error) |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
139 { |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
140 JabberStream *js = user_data; |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
141 |
24416
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
142 if (error->level == XML_ERR_WARNING && error->message != NULL |
29062 | 143 && g_str_equal(error->message, "xmlns: URI vcard-temp is not absolute\n")) |
24416
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
144 /* |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
145 * This message happens when parsing vcards, and is normal, so don't |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
146 * bother logging it because people scare easily. |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
147 */ |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
148 return; |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
149 |
29109
6ebacc1710b2
jabber: Use the error code instead of string matching.
Paul Aurich <paul@darkrain42.org>
parents:
29108
diff
changeset
|
150 if (error->level == XML_ERR_FATAL && error->code == XML_ERR_DOCUMENT_END) |
29033
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
151 /* |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
152 * This is probably more annoying than the vcard-temp error; it occurs |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
153 * because we disconnect in most cases without waiting for the receiving |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
154 * </stream:stream> (limitations of libpurple) |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
155 */ |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
156 return; |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
157 |
23426
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
158 purple_debug_error("jabber", "XML parser error for JabberStream %p: " |
24416
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23884
diff
changeset
|
159 "Domain %i, code %i, level %i: %s", |
23426
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
160 js, |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
161 error->domain, error->code, error->level, |
24419
8de8ca65e1d9
I know Mark was trying to save newlines, but I had one to spare.
Richard Laager <rlaager@wiktel.com>
parents:
24416
diff
changeset
|
162 (error->message ? error->message : "(null)\n")); |
23426
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
163 } |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
164 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 static xmlSAXHandler jabber_parser_libxml = { |
22914
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
166 NULL, /*internalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
167 NULL, /*isStandalone*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
168 NULL, /*hasInternalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
169 NULL, /*hasExternalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
170 NULL, /*resolveEntity*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
171 NULL, /*getEntity*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
172 NULL, /*entityDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
173 NULL, /*notationDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
174 NULL, /*attributeDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
175 NULL, /*elementDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
176 NULL, /*unparsedEntityDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
177 NULL, /*setDocumentLocator*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
178 NULL, /*startDocument*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
179 NULL, /*endDocument*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
180 NULL, /*startElement*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
181 NULL, /*endElement*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
182 NULL, /*reference*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
183 jabber_parser_element_text_libxml, /*characters*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
184 NULL, /*ignorableWhitespace*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
185 NULL, /*processingInstruction*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
186 NULL, /*comment*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
187 NULL, /*warning*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
188 NULL, /*error*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
189 NULL, /*fatalError*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
190 NULL, /*getParameterEntity*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
191 NULL, /*cdataBlock*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
192 NULL, /*externalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
193 XML_SAX2_MAGIC, /*initialized*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
194 NULL, /*_private*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
195 jabber_parser_element_start_libxml, /*startElementNs*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
196 jabber_parser_element_end_libxml, /*endElementNs*/ |
23426
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22914
diff
changeset
|
197 jabber_parser_structured_error_handler /*serror*/ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 jabber_parser_setup(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 /* This seems backwards, but it makes sense. The libxml code creates |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 * the parser context when you try to use it (this way, it can figure |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 * out the encoding at creation time. So, setting up the parser is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 * just a matter of destroying any current parser. */ |
17603
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15823
diff
changeset
|
207 jabber_parser_free(js); |
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15823
diff
changeset
|
208 } |
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15823
diff
changeset
|
209 |
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15823
diff
changeset
|
210 void jabber_parser_free(JabberStream *js) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 if (js->context) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 xmlParseChunk(js->context, NULL,0,1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 xmlFreeParserCtxt(js->context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 js->context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 void jabber_parser_process(JabberStream *js, const char *buf, int len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 { |
23427
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23426
diff
changeset
|
220 int ret; |
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23426
diff
changeset
|
221 |
23429 | 222 if (js->context == NULL) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 /* libxml inconsistently starts parsing on creating the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 * parser, so do a ParseChunk right afterwards to force it. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 xmlParseChunk(js->context, "", 0, 0); |
23427
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23426
diff
changeset
|
227 } else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) { |
23884
08c50482d5a2
Only disconnect xmpp connections during xml parsing if the error is an
Stu Tomlinson <stu@nosnilmot.com>
parents:
23429
diff
changeset
|
228 xmlError *err = xmlCtxtGetLastError(js->context); |
25871
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
229 /* |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
230 * libxml2 uses a global setting to determine whether or not to store |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
231 * warnings. Other libraries may set this, which causes err to be |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
232 * NULL. See #8136 for details. |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
233 */ |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
234 xmlErrorLevel level = XML_ERR_WARNING; |
23427
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23426
diff
changeset
|
235 |
25871
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
236 if (err) |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
237 level = err->level; |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
238 |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25110
diff
changeset
|
239 switch (level) { |
24898
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
240 case XML_ERR_NONE: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
241 purple_debug_info("jabber", "xmlParseChunk returned info %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
242 break; |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
243 case XML_ERR_WARNING: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
244 purple_debug_warning("jabber", "xmlParseChunk returned warning %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
245 break; |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
246 case XML_ERR_ERROR: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
247 purple_debug_error("jabber", "xmlParseChunk returned error %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
248 break; |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
249 case XML_ERR_FATAL: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
250 purple_debug_error("jabber", "xmlParseChunk returned fatal %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
251 purple_connection_error_reason (js->gc, |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
252 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
253 _("XML Parse error")); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24818
diff
changeset
|
254 break; |
23428
ce361cc8e43b
Drop and then recover from XML messages which trigger invalid character
Evan Schoenberg <evan.s@dreskin.net>
parents:
23427
diff
changeset
|
255 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 } |
28694
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
257 |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
258 if (js->protocol_version == JABBER_PROTO_0_9 && !js->gc->disconnect_timeout && |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
259 (js->state == JABBER_STREAM_INITIALIZING || |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
260 js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) { |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
261 /* |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
262 * Legacy servers don't advertise features, so if we've just gotten |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
263 * the opening <stream:stream> and there was no version, we need to |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
264 * immediately start legacy IQ auth. |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
265 */ |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
266 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28694
diff
changeset
|
267 jabber_auth_start_old(js); |
28694
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
268 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 |