Mercurial > pidgin
annotate libpurple/xmlnode.c @ 32777:3b1070cb4f29
jabber: Validate user moods, and make the /mood cmd behave flexibly.
A user in Pidgin running "/mood ?" or "/mood -" would result in invalid
XML being sent to the server (similar to #14342, except '<-/>' or '<?/>').
Prevent this by ensuring the user is specifying something from the list.
The /mood command will also now try to treat its entire arguments as
a single string, and set that as the mood -- I figure this is what a
user would expect?
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 23 May 2012 05:01:14 +0000 |
parents | 8d3b5853b017 |
children |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file xmlnode.c XML DOM functions |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19697
diff
changeset
|
3 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19697
diff
changeset
|
4 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19697
diff
changeset
|
5 /* purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * |
15822 | 7 * Purple is the legal property of its developers, whose names are too numerous |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * 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
|
17 * 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
|
18 * 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
|
19 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * 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
|
22 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19643
diff
changeset
|
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 /* A lot of this code at least resembles the code in libxode, but since |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 * libxode uses memory pools that we simply have no need for, I decided to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 * write my own stuff. Also, re-writing this lets me be as lightweight |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 * as I want to be. Thank you libxode for giving me a good starting point */ |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
30 #define _PURPLE_XMLNODE_C_ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 |
28647
f1437342cc0e
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
32 #include "internal.h" |
15914
8bcd5840fb12
Don't advertise that we support the adverts, invite and translate
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
33 #include "debug.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include <libxml/parser.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 #include <string.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 #include <glib.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include "dbus-maybe.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #include "xmlnode.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 # define NEWLINE_S "\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 # define NEWLINE_S "\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 static xmlnode* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 new_node(const char *name, XMLNodeType type) |
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 xmlnode *node = g_new0(xmlnode, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 node->name = g_strdup(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 node->type = type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
15822 | 57 PURPLE_DBUS_REGISTER_POINTER(node, xmlnode); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 return node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 } |
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 xmlnode* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 xmlnode_new(const char *name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 { |
31720
979bab4c3bca
jabber: Check for empty string when setting mood.
Paul Aurich <paul@darkrain42.org>
parents:
31348
diff
changeset
|
65 g_return_val_if_fail(name != NULL && *name != '\0', NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 return new_node(name, XMLNODE_TYPE_TAG); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 xmlnode * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 xmlnode_new_child(xmlnode *parent, const char *name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 xmlnode *node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 g_return_val_if_fail(parent != NULL, NULL); |
31720
979bab4c3bca
jabber: Check for empty string when setting mood.
Paul Aurich <paul@darkrain42.org>
parents:
31348
diff
changeset
|
76 g_return_val_if_fail(name != NULL && *name != '\0', NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 node = new_node(name, XMLNODE_TYPE_TAG); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 xmlnode_insert_child(parent, node); |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
81 #if 0 |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
82 /* This would give xmlnodes more appropriate namespacing |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
83 * when creating them. Otherwise, unless an explicit namespace |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
84 * is set, xmlnode_get_namespace() will return NULL, when |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
85 * there may be a default namespace. |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
86 * |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
87 * I'm unconvinced that it's useful, and concerned it may break things. |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
88 * |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
89 * _insert_child would need the same thing, probably (assuming |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
90 * xmlns->node == NULL) |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
91 */ |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
92 xmlnode_set_namespace(node, xmlnode_get_default_namespace(node)) |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
93 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 return node; |
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 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 xmlnode_insert_child(xmlnode *parent, xmlnode *child) |
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 g_return_if_fail(parent != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 g_return_if_fail(child != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 child->parent = parent; |
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 if(parent->lastchild) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 parent->lastchild->next = child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 parent->child = child; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 parent->lastchild = child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 xmlnode_insert_data(xmlnode *node, const char *data, gssize size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 xmlnode *child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 gsize real_size; |
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 g_return_if_fail(node != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 g_return_if_fail(data != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 g_return_if_fail(size != 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 real_size = size == -1 ? strlen(data) : size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 child = new_node(NULL, XMLNODE_TYPE_DATA); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 child->data = g_memdup(data, real_size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 child->data_sz = real_size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 xmlnode_insert_child(node, child); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 xmlnode_remove_attrib(xmlnode *node, const char *attr) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 xmlnode *attr_node, *sibling = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 g_return_if_fail(node != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 g_return_if_fail(attr != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
143 attr_node = node->child; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
144 while (attr_node) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 if(attr_node->type == XMLNODE_TYPE_ATTRIB && |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
146 purple_strequal(attr_node->name, attr)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 if (node->lastchild == attr_node) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 node->lastchild = sibling; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 } |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
151 if (sibling == NULL) { |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
152 node->child = attr_node->next; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
153 xmlnode_free(attr_node); |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
154 attr_node = node->child; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
155 } else { |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
156 sibling->next = attr_node->next; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
157 sibling = attr_node->next; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
158 xmlnode_free(attr_node); |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
159 attr_node = sibling; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
160 } |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
161 } |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
162 else |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
163 { |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
164 attr_node = attr_node->next; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 sibling = attr_node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 xmlnode *attr_node, *sibling = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 g_return_if_fail(node != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 g_return_if_fail(attr != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 for(attr_node = node->child; attr_node; attr_node = attr_node->next) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 if(attr_node->type == XMLNODE_TYPE_ATTRIB && |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
181 purple_strequal(attr, attr_node->name) && |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
182 purple_strequal(xmlns, attr_node->xmlns)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 { |
20336
b93e7be3847b
applied changes from 9d35dde0c779cca73548172223ba557f27d61882
Luke Schierer <lschiere@pidgin.im>
parents:
20332
diff
changeset
|
184 if(sibling == NULL) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 node->child = attr_node->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 sibling->next = attr_node->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 if (node->lastchild == attr_node) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 node->lastchild = sibling; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 xmlnode_free(attr_node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 sibling = attr_node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 } |
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 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 xmlnode_remove_attrib(node, attr); |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
203 xmlnode_set_attrib_full(node, attr, NULL, NULL, value); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 void |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
207 xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, const char *prefix, const char *value) |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
208 { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 xmlnode *attrib_node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 g_return_if_fail(node != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 g_return_if_fail(attr != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 g_return_if_fail(value != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 xmlnode_remove_attrib_with_namespace(node, attr, xmlns); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); |
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 attrib_node->data = g_strdup(value); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 attrib_node->xmlns = g_strdup(xmlns); |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
220 attrib_node->prefix = g_strdup(prefix); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
221 |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
222 xmlnode_insert_child(node, attrib_node); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
223 } |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
224 |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
225 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 const char * |
30257
77cd42f08ba1
const-ify the xmlnode* parameter to xmlnode_get_attrib(_with_namespace)
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
227 xmlnode_get_attrib(const xmlnode *node, const char *attr) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 xmlnode *x; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 g_return_val_if_fail(node != NULL, NULL); |
24418 | 232 g_return_val_if_fail(attr != NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 for(x = node->child; x; x = x->next) { |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
235 if(x->type == XMLNODE_TYPE_ATTRIB && purple_strequal(attr, x->name)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 return x->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 const char * |
30257
77cd42f08ba1
const-ify the xmlnode* parameter to xmlnode_get_attrib(_with_namespace)
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
244 xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 { |
30257
77cd42f08ba1
const-ify the xmlnode* parameter to xmlnode_get_attrib(_with_namespace)
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
246 const xmlnode *x; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 g_return_val_if_fail(node != NULL, NULL); |
24418 | 249 g_return_val_if_fail(attr != NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 for(x = node->child; x; x = x->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 if(x->type == XMLNODE_TYPE_ATTRIB && |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
253 purple_strequal(attr, x->name) && |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
254 purple_strequal(xmlns, x->xmlns)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 return x->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 void xmlnode_set_namespace(xmlnode *node, const char *xmlns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 { |
32038
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
265 char *tmp; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 g_return_if_fail(node != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
32038
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
268 tmp = node->xmlns; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 node->xmlns = g_strdup(xmlns); |
32038
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
270 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
271 if (node->namespace_map) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
272 g_hash_table_insert(node->namespace_map, |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
273 g_strdup(""), g_strdup(xmlns)); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
274 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
275 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
276 g_free(tmp); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
279 const char *xmlnode_get_namespace(const xmlnode *node) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 g_return_val_if_fail(node != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 return node->xmlns; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
286 const char *xmlnode_get_default_namespace(const xmlnode *node) |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
287 { |
32038
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
288 const xmlnode *current_node; |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
289 const char *ns = NULL; |
32038
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
290 |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
291 g_return_val_if_fail(node != NULL, NULL); |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
292 |
32038
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
293 current_node = node; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
294 while (current_node) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
295 /* If this node does *not* have a prefix, node->xmlns is the default |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
296 * namespace. Otherwise, it's the prefix namespace. |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
297 */ |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
298 if (!current_node->prefix && current_node->xmlns) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
299 return current_node->xmlns; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
300 } else if (current_node->namespace_map) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
301 ns = g_hash_table_lookup(current_node->namespace_map, ""); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
302 if (ns && *ns) |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
303 return ns; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
304 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
305 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
306 current_node = current_node->parent; |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
307 } |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
308 |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
309 return ns; |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
310 } |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
311 |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
312 void xmlnode_set_prefix(xmlnode *node, const char *prefix) |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
313 { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
314 g_return_if_fail(node != NULL); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
315 |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
316 g_free(node->prefix); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
317 node->prefix = g_strdup(prefix); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
318 } |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
319 |
25414
efde7e6ed5f2
There's no reason for these to not be const is there? This doesn't
Mark Doliner <mark@kingant.net>
parents:
24866
diff
changeset
|
320 const char *xmlnode_get_prefix(const xmlnode *node) |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
321 { |
21642
372711300f57
Fix the namespace_map being leaked.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21318
diff
changeset
|
322 g_return_val_if_fail(node != NULL, NULL); |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
323 return node->prefix; |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
324 } |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
325 |
32038
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
326 const char *xmlnode_get_prefix_namespace(const xmlnode *node, const char *prefix) |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
327 { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
328 const xmlnode *current_node; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
329 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
330 g_return_val_if_fail(node != NULL, NULL); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
331 g_return_val_if_fail(prefix != NULL, xmlnode_get_default_namespace(node)); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
332 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
333 current_node = node; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
334 while (current_node) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
335 if (current_node->prefix && g_str_equal(prefix, current_node->prefix) && |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
336 current_node->xmlns) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
337 return current_node->xmlns; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
338 } else if (current_node->namespace_map) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
339 const char *ns = g_hash_table_lookup(current_node->namespace_map, prefix); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
340 if (ns && *ns) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
341 return ns; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
342 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
343 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
344 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
345 current_node = current_node->parent; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
346 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
347 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
348 return NULL; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
349 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
350 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
351 void xmlnode_strip_prefixes(xmlnode *node) |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
352 { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
353 xmlnode *child; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
354 const char *prefix; |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
355 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
356 g_return_if_fail(node != NULL); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
357 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
358 for (child = node->child; child; child = child->next) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
359 if (child->type == XMLNODE_TYPE_TAG) |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
360 xmlnode_strip_prefixes(child); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
361 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
362 |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
363 prefix = xmlnode_get_prefix(node); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
364 if (prefix) { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
365 const char *ns = xmlnode_get_prefix_namespace(node, prefix); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
366 xmlnode_set_namespace(node, ns); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
367 xmlnode_set_prefix(node, NULL); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
368 } else { |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
369 xmlnode_set_namespace(node, xmlnode_get_default_namespace(node)); |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
370 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
371 } |
8d3b5853b017
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <paul@darkrain42.org>
parents:
32037
diff
changeset
|
372 |
23850
84c7bb2ca41f
Added xmlnode_get_parent.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
21955
diff
changeset
|
373 xmlnode *xmlnode_get_parent(const xmlnode *child) |
84c7bb2ca41f
Added xmlnode_get_parent.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
21955
diff
changeset
|
374 { |
84c7bb2ca41f
Added xmlnode_get_parent.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
21955
diff
changeset
|
375 g_return_val_if_fail(child != NULL, NULL); |
84c7bb2ca41f
Added xmlnode_get_parent.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
21955
diff
changeset
|
376 return child->parent; |
84c7bb2ca41f
Added xmlnode_get_parent.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
21955
diff
changeset
|
377 } |
84c7bb2ca41f
Added xmlnode_get_parent.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
21955
diff
changeset
|
378 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 xmlnode_free(xmlnode *node) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 xmlnode *x, *y; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 g_return_if_fail(node != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 |
18257
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
386 /* if we're part of a tree, remove ourselves from the tree first */ |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
387 if(NULL != node->parent) { |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
388 if(node->parent->child == node) { |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
389 node->parent->child = node->next; |
19388
1c97caf1ebbb
xmlnode bugfix patch from Mauro Brasil
Sean Egan <seanegan@gmail.com>
parents:
18257
diff
changeset
|
390 if (node->parent->lastchild == node) |
1c97caf1ebbb
xmlnode bugfix patch from Mauro Brasil
Sean Egan <seanegan@gmail.com>
parents:
18257
diff
changeset
|
391 node->parent->lastchild = node->next; |
18257
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
392 } else { |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
393 xmlnode *prev = node->parent->child; |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
394 while(prev && prev->next != node) { |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
395 prev = prev->next; |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
396 } |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
397 if(prev) { |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
398 prev->next = node->next; |
19388
1c97caf1ebbb
xmlnode bugfix patch from Mauro Brasil
Sean Egan <seanegan@gmail.com>
parents:
18257
diff
changeset
|
399 if (node->parent->lastchild == node) |
1c97caf1ebbb
xmlnode bugfix patch from Mauro Brasil
Sean Egan <seanegan@gmail.com>
parents:
18257
diff
changeset
|
400 node->parent->lastchild = prev; |
18257
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
401 } |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
402 } |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
403 } |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
404 |
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
405 /* now free our children */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 x = node->child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 while(x) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 y = x->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 xmlnode_free(x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 x = y; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 |
18257
6050348614ab
fix a buddy icon bug in jabber
Nathan Walp <nwalp@pidgin.im>
parents:
18072
diff
changeset
|
413 /* now dispose of ourselves */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 g_free(node->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 g_free(node->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 g_free(node->xmlns); |
21942 | 417 g_free(node->prefix); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 |
21642
372711300f57
Fix the namespace_map being leaked.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21318
diff
changeset
|
419 if(node->namespace_map) |
372711300f57
Fix the namespace_map being leaked.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21318
diff
changeset
|
420 g_hash_table_destroy(node->namespace_map); |
372711300f57
Fix the namespace_map being leaked.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21318
diff
changeset
|
421 |
15822 | 422 PURPLE_DBUS_UNREGISTER_POINTER(node); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 g_free(node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 xmlnode* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 xmlnode_get_child(const xmlnode *parent, const char *name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 return xmlnode_get_child_with_namespace(parent, name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 xmlnode * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *ns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 xmlnode *x, *ret = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 char **names; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 char *parent_name, *child_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 g_return_val_if_fail(parent != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 g_return_val_if_fail(name != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 names = g_strsplit(name, "/", 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 parent_name = names[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 child_name = names[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 for(x = parent->child; x; x = x->next) { |
20332
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
447 /* XXX: Is it correct to ignore the namespace for the match if none was specified? */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 const char *xmlns = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 if(ns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 xmlns = xmlnode_get_namespace(x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
452 if(x->type == XMLNODE_TYPE_TAG && purple_strequal(parent_name, x->name) |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
453 && purple_strequal(ns, xmlns)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 ret = x; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 if(child_name && ret) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 ret = xmlnode_get_child(ret, child_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 g_strfreev(names); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 char * |
27121
350f097019eb
These parameters aren't modified
Mark Doliner <mark@kingant.net>
parents:
26686
diff
changeset
|
467 xmlnode_get_data(const xmlnode *node) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 GString *str = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 xmlnode *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 g_return_val_if_fail(node != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 for(c = node->child; c; c = c->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 if(c->type == XMLNODE_TYPE_DATA) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 if(!str) |
18072
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
477 str = g_string_new_len(c->data, c->data_sz); |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
478 else |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
479 str = g_string_append_len(str, c->data, c->data_sz); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 if (str == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 return g_string_free(str, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 |
18072
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
489 char * |
27121
350f097019eb
These parameters aren't modified
Mark Doliner <mark@kingant.net>
parents:
26686
diff
changeset
|
490 xmlnode_get_data_unescaped(const xmlnode *node) |
18072
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
491 { |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
492 char *escaped = xmlnode_get_data(node); |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
493 |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
494 char *unescaped = escaped ? purple_unescape_html(escaped) : NULL; |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
495 |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
496 g_free(escaped); |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
497 |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
498 return unescaped; |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
499 } |
3fc94e7c7056
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
17457
diff
changeset
|
500 |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
501 static void |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
502 xmlnode_to_str_foreach_append_ns(const char *key, const char *value, |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
503 GString *buf) |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
504 { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
505 if (*key) { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
506 g_string_append_printf(buf, " xmlns:%s='%s'", key, value); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
507 } else { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
508 g_string_append_printf(buf, " xmlns='%s'", value); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
509 } |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
510 } |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
511 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 static char * |
25414
efde7e6ed5f2
There's no reason for these to not be const is there? This doesn't
Mark Doliner <mark@kingant.net>
parents:
24866
diff
changeset
|
513 xmlnode_to_str_helper(const xmlnode *node, int *len, gboolean formatting, int depth) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 GString *text = g_string_new(""); |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
516 const char *prefix; |
25414
efde7e6ed5f2
There's no reason for these to not be const is there? This doesn't
Mark Doliner <mark@kingant.net>
parents:
24866
diff
changeset
|
517 const xmlnode *c; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 char *node_name, *esc, *esc2, *tab = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 gboolean need_end = FALSE, pretty = formatting; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 g_return_val_if_fail(node != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 if(pretty && depth) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 tab = g_strnfill(depth, '\t'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 text = g_string_append(text, tab); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 node_name = g_markup_escape_text(node->name, -1); |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
529 prefix = xmlnode_get_prefix(node); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
531 if (prefix) { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
532 g_string_append_printf(text, "<%s:%s", prefix, node_name); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
533 } else { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
534 g_string_append_printf(text, "<%s", node_name); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
535 } |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
536 |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
537 if (node->namespace_map) { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
538 g_hash_table_foreach(node->namespace_map, |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
539 (GHFunc)xmlnode_to_str_foreach_append_ns, text); |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
540 } else { |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
541 /* Figure out if this node has a different default namespace from parent */ |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
542 const char *xmlns = NULL; |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
543 const char *parent_xmlns = NULL; |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
544 if (!prefix) |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
545 xmlns = node->xmlns; |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
546 |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
547 if (!xmlns) |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
548 xmlns = xmlnode_get_default_namespace(node); |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
549 if (node->parent) |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
550 parent_xmlns = xmlnode_get_default_namespace(node->parent); |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
551 if (!purple_strequal(xmlns, parent_xmlns)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 { |
32037
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
553 char *escaped_xmlns = g_markup_escape_text(xmlns, -1); |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
554 g_string_append_printf(text, " xmlns='%s'", escaped_xmlns); |
114a98da1a5f
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <paul@darkrain42.org>
parents:
32029
diff
changeset
|
555 g_free(escaped_xmlns); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 for(c = node->child; c; c = c->next) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 if(c->type == XMLNODE_TYPE_ATTRIB) { |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
561 const char *aprefix = xmlnode_get_prefix(c); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 esc = g_markup_escape_text(c->name, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 esc2 = g_markup_escape_text(c->data, -1); |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
564 if (aprefix) { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
565 g_string_append_printf(text, " %s:%s='%s'", aprefix, esc, esc2); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
566 } else { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
567 g_string_append_printf(text, " %s='%s'", esc, esc2); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
568 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 g_free(esc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 g_free(esc2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 } else if(c->type == XMLNODE_TYPE_TAG || c->type == XMLNODE_TYPE_DATA) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 if(c->type == XMLNODE_TYPE_DATA) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 pretty = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 need_end = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 if(need_end) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 g_string_append_printf(text, ">%s", pretty ? NEWLINE_S : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 for(c = node->child; c; c = c->next) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 if(c->type == XMLNODE_TYPE_TAG) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 int esc_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 esc = xmlnode_to_str_helper(c, &esc_len, pretty, depth+1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 text = g_string_append_len(text, esc, esc_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 g_free(esc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 } else if(c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 esc = g_markup_escape_text(c->data, c->data_sz); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 text = g_string_append(text, esc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 g_free(esc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 if(tab && pretty) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 text = g_string_append(text, tab); |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
597 if (prefix) { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
598 g_string_append_printf(text, "</%s:%s>%s", prefix, node_name, formatting ? NEWLINE_S : ""); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
599 } else { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
600 g_string_append_printf(text, "</%s>%s", node_name, formatting ? NEWLINE_S : ""); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
601 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 g_string_append_printf(text, "/>%s", formatting ? NEWLINE_S : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 g_free(node_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 g_free(tab); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 if(len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 *len = text->len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 return g_string_free(text, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 char * |
25414
efde7e6ed5f2
There's no reason for these to not be const is there? This doesn't
Mark Doliner <mark@kingant.net>
parents:
24866
diff
changeset
|
617 xmlnode_to_str(const xmlnode *node, int *len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 return xmlnode_to_str_helper(node, len, FALSE, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 char * |
25414
efde7e6ed5f2
There's no reason for these to not be const is there? This doesn't
Mark Doliner <mark@kingant.net>
parents:
24866
diff
changeset
|
623 xmlnode_to_formatted_str(const xmlnode *node, int *len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 char *xml, *xml_with_declaration; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 g_return_val_if_fail(node != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 xml = xmlnode_to_str_helper(node, len, TRUE, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 xml_with_declaration = |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 g_strdup_printf("<?xml version='1.0' encoding='UTF-8' ?>" NEWLINE_S NEWLINE_S "%s", xml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 g_free(xml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 |
21955
feb92c44db87
Patch from QuLogic to correctly set the length. Closes #4515.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21942
diff
changeset
|
634 if (len) |
feb92c44db87
Patch from QuLogic to correctly set the length. Closes #4515.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21942
diff
changeset
|
635 *len += sizeof("<?xml version='1.0' encoding='UTF-8' ?>" NEWLINE_S NEWLINE_S) - 1; |
feb92c44db87
Patch from QuLogic to correctly set the length. Closes #4515.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21942
diff
changeset
|
636 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 return xml_with_declaration; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 struct _xmlnode_parser_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 xmlnode *current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 gboolean error; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 xmlnode_parser_element_start_libxml(void *user_data, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 const xmlChar *element_name, const xmlChar *prefix, const xmlChar *xmlns, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 int nb_namespaces, const xmlChar **namespaces, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 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
|
650 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 struct _xmlnode_parser_data *xpd = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 xmlnode *node; |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
653 int i, j; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 if(!element_name || xpd->error) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 if(xpd->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 node = xmlnode_new_child(xpd->current, (const char*) element_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 node = xmlnode_new((const char *) element_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 xmlnode_set_namespace(node, (const char *) xmlns); |
21285
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
664 xmlnode_set_prefix(node, (const char *)prefix); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
665 |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
666 if (nb_namespaces != 0) { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
667 node->namespace_map = g_hash_table_new_full( |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
668 g_str_hash, g_str_equal, g_free, g_free); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
669 |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
670 for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) { |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
671 const char *key = (const char *)namespaces[j]; |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
672 const char *val = (const char *)namespaces[j + 1]; |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
673 g_hash_table_insert(node->namespace_map, |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
674 g_strdup(key ? key : ""), g_strdup(val ? val : "")); |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
675 } |
78f3361f5e62
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@hxbc.us>
parents:
20336
diff
changeset
|
676 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 for(i=0; i < nb_attributes * 5; i+=5) { |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
679 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:
25947
diff
changeset
|
680 const char *prefix = (const char *)attributes[i+1]; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 char *txt; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 int attrib_len = attributes[i+4] - attributes[i+3]; |
28739 | 683 char *attrib = g_strndup((const char *)attributes[i+3], attrib_len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 txt = attrib; |
29006
e1c01f236674
Correctly parse "<br>" in an XML attribute. Closes #11318.
Paul Aurich <paul@darkrain42.org>
parents:
28739
diff
changeset
|
685 attrib = purple_unescape_text(txt); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 g_free(txt); |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25947
diff
changeset
|
687 xmlnode_set_attrib_full(node, name, NULL, prefix, attrib); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 g_free(attrib); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 xpd->current = node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 xmlnode_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
|
697 const xmlChar *prefix, const xmlChar *xmlns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 struct _xmlnode_parser_data *xpd = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 |
31348
c9244d8303ce
Change space indentation to tab indentation on a line
Mark Doliner <mark@kingant.net>
parents:
30257
diff
changeset
|
701 if(!element_name || !xpd->current || xpd->error) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 if(xpd->current->parent) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
705 if(!xmlStrcmp((xmlChar*) xpd->current->name, element_name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 xpd->current = xpd->current->parent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 xmlnode_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
|
712 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
713 struct _xmlnode_parser_data *xpd = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
715 if(!xpd->current || xpd->error) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 return; |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
717 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 if(!text || !text_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 xmlnode_insert_data(xpd->current, (const char*) text, text_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 xmlnode_parser_error_libxml(void *user_data, const char *msg, ...) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 struct _xmlnode_parser_data *xpd = user_data; |
19643
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
728 char errmsg[2048]; |
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
729 va_list args; |
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
730 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 xpd->error = TRUE; |
19643
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
732 |
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
733 va_start(args, msg); |
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
734 vsnprintf(errmsg, sizeof(errmsg), msg, args); |
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
735 va_end(args); |
077c2df60c38
Print an error when there was a problem parsing some XML
Mark Doliner <mark@kingant.net>
parents:
19388
diff
changeset
|
736 |
24866
667b8ae0fcee
Error messages from libxml contain their own newlines
Mark Doliner <mark@kingant.net>
parents:
24418
diff
changeset
|
737 purple_debug_error("xmlnode", "Error parsing xml file: %s", errmsg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 |
25586
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
740 static void |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
741 xmlnode_parser_structural_error_libxml(void *user_data, xmlErrorPtr error) |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
742 { |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
743 struct _xmlnode_parser_data *xpd = user_data; |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
744 |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
745 if (error && (error->level == XML_ERR_ERROR || |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
746 error->level == XML_ERR_FATAL)) { |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
747 xpd->error = TRUE; |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
748 purple_debug_error("xmlnode", "XML parser error for xmlnode %p: " |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
749 "Domain %i, code %i, level %i: %s", |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
750 user_data, error->domain, error->code, error->level, |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
751 error->message ? error->message : "(null)\n"); |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
752 } else if (error) |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
753 purple_debug_warning("xmlnode", "XML parser error for xmlnode %p: " |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
754 "Domain %i, code %i, level %i: %s", |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
755 user_data, error->domain, error->code, error->level, |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
756 error->message ? error->message : "(null)\n"); |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
757 else |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
758 purple_debug_warning("xmlnode", "XML parser error for xmlnode %p\n", |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
759 user_data); |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
760 } |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
761 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 static xmlSAXHandler xmlnode_parser_libxml = { |
17457
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
763 NULL, /* internalSubset */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
764 NULL, /* isStandalone */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
765 NULL, /* hasInternalSubset */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
766 NULL, /* hasExternalSubset */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
767 NULL, /* resolveEntity */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
768 NULL, /* getEntity */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
769 NULL, /* entityDecl */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
770 NULL, /* notationDecl */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
771 NULL, /* attributeDecl */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
772 NULL, /* elementDecl */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
773 NULL, /* unparsedEntityDecl */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
774 NULL, /* setDocumentLocator */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
775 NULL, /* startDocument */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
776 NULL, /* endDocument */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
777 NULL, /* startElement */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
778 NULL, /* endElement */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
779 NULL, /* reference */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
780 xmlnode_parser_element_text_libxml, /* characters */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
781 NULL, /* ignorableWhitespace */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
782 NULL, /* processingInstruction */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
783 NULL, /* comment */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
784 NULL, /* warning */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
785 xmlnode_parser_error_libxml, /* error */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
786 NULL, /* fatalError */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
787 NULL, /* getParameterEntity */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
788 NULL, /* cdataBlock */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
789 NULL, /* externalSubset */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
790 XML_SAX2_MAGIC, /* initialized */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
791 NULL, /* _private */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
792 xmlnode_parser_element_start_libxml, /* startElementNs */ |
905d69a0ffd7
Kill a C99 struct initialization.
Richard Laager <rlaager@wiktel.com>
parents:
15916
diff
changeset
|
793 xmlnode_parser_element_end_libxml, /* endElementNs */ |
25586
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25414
diff
changeset
|
794 xmlnode_parser_structural_error_libxml, /* serror */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 xmlnode * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 xmlnode_from_str(const char *str, gssize size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 struct _xmlnode_parser_data *xpd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 xmlnode *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 gsize real_size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 real_size = size < 0 ? strlen(str) : size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 xpd = g_new0(struct _xmlnode_parser_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 if (xmlSAXUserParseMemory(&xmlnode_parser_libxml, xpd, str, real_size) < 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 while(xpd->current && xpd->current->parent) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 xpd->current = xpd->current->parent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 if(xpd->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 xmlnode_free(xpd->current); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 xpd->current = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 ret = xpd->current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 if (xpd->error) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 ret = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 if (xpd->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 xmlnode_free(xpd->current); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 g_free(xpd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 |
25114
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
827 xmlnode * |
25122
9525fb966efb
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25114
diff
changeset
|
828 xmlnode_from_file(const char *dir,const char *filename, const char *description, const char *process) |
25114
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
829 { |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
830 gchar *filename_full; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
831 GError *error = NULL; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
832 gchar *contents = NULL; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
833 gsize length; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
834 xmlnode *node = NULL; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
835 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
836 g_return_val_if_fail(dir != NULL, NULL); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
837 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
838 purple_debug_info(process, "Reading file %s from directory %s\n", |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
839 filename, dir); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
840 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
841 filename_full = g_build_filename(dir, filename, NULL); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
842 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
843 if (!g_file_test(filename_full, G_FILE_TEST_EXISTS)) |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
844 { |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
845 purple_debug_info(process, "File %s does not exist (this is not " |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
846 "necessarily an error)\n", filename_full); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
847 g_free(filename_full); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
848 return NULL; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
849 } |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
850 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
851 if (!g_file_get_contents(filename_full, &contents, &length, &error)) |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
852 { |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
853 purple_debug_error(process, "Error reading file %s: %s\n", |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
854 filename_full, error->message); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
855 g_error_free(error); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
856 } |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
857 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
858 if ((contents != NULL) && (length > 0)) |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
859 { |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
860 node = xmlnode_from_str(contents, length); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
861 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
862 /* If we were unable to parse the file then save its contents to a backup file */ |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
863 if (node == NULL) |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
864 { |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
865 gchar *filename_temp, *filename_temp_full; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
866 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
867 filename_temp = g_strdup_printf("%s~", filename); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
868 filename_temp_full = g_build_filename(dir, filename_temp, NULL); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
869 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
870 purple_debug_error("util", "Error parsing file %s. Renaming old " |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
871 "file to %s\n", filename_full, filename_temp); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
872 purple_util_write_data_to_file_absolute(filename_temp_full, contents, length); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
873 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
874 g_free(filename_temp_full); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
875 g_free(filename_temp); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
876 } |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
877 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
878 g_free(contents); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
879 } |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
880 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
881 /* If we could not parse the file then show the user an error message */ |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
882 if (node == NULL) |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
883 { |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
884 gchar *title, *msg; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
885 title = g_strdup_printf(_("Error Reading %s"), filename); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
886 msg = g_strdup_printf(_("An error was encountered reading your " |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
887 "%s. The file has not been loaded, and the old file " |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
888 "has been renamed to %s~."), description, filename_full); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
889 purple_notify_error(NULL, NULL, title, msg); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
890 g_free(title); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
891 g_free(msg); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
892 } |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
893 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
894 g_free(filename_full); |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
895 |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
896 return node; |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
897 } |
2d419a0fc0e4
partially working status icon theme stuff
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
25112
diff
changeset
|
898 |
23509
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
899 static void |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
900 xmlnode_copy_foreach_ns(gpointer key, gpointer value, gpointer user_data) |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
901 { |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
902 GHashTable *ret = (GHashTable *)user_data; |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
903 g_hash_table_insert(ret, g_strdup(key), g_strdup(value)); |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
904 } |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
905 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
906 xmlnode * |
15547
c2d75b47198d
sf patch #1647731, from Markus Elfring
Mark Doliner <mark@kingant.net>
parents:
15373
diff
changeset
|
907 xmlnode_copy(const xmlnode *src) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 xmlnode *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
910 xmlnode *child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 xmlnode *sibling = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 g_return_val_if_fail(src != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 ret = new_node(src->name, src->type); |
17891
9d02fefaa589
Fixed a bug in xmlnode_copy, it didn't preserve the namespace in the copy.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15916
diff
changeset
|
916 ret->xmlns = g_strdup(src->xmlns); |
23509
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
917 if (src->data) { |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
918 if (src->data_sz) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 ret->data = g_memdup(src->data, src->data_sz); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 ret->data_sz = src->data_sz; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 ret->data = g_strdup(src->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 } |
23509
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
925 ret->prefix = g_strdup(src->prefix); |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
926 if (src->namespace_map) { |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
927 ret->namespace_map = g_hash_table_new_full(g_str_hash, g_str_equal, |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
928 g_free, g_free); |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
929 g_hash_table_foreach(src->namespace_map, xmlnode_copy_foreach_ns, ret->namespace_map); |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
930 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 |
23509
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
932 for (child = src->child; child; child = child->next) { |
c4ec724b3b53
Make sure xmlnode_copy also copies the prefix and namespace_map from
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21955
diff
changeset
|
933 if (sibling) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
934 sibling->next = xmlnode_copy(child); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
935 sibling = sibling->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 ret->child = xmlnode_copy(child); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 sibling = ret->child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 sibling->parent = ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 ret->lastchild = sibling; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 xmlnode * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 xmlnode_get_next_twin(xmlnode *node) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 xmlnode *sibling; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 const char *ns = xmlnode_get_namespace(node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 g_return_val_if_fail(node != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 g_return_val_if_fail(node->type == XMLNODE_TYPE_TAG, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 for(sibling = node->next; sibling; sibling = sibling->next) { |
20332
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
958 /* XXX: Is it correct to ignore the namespace for the match if none was specified? */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 const char *xmlns = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 if(ns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 xmlns = xmlnode_get_namespace(sibling); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
963 if(sibling->type == XMLNODE_TYPE_TAG && purple_strequal(node->name, sibling->name) && |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
964 purple_strequal(ns, xmlns)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 return sibling; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 } |