libpurple/protocols/gg/xml.c

Fri, 01 May 2020 04:42:52 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 01 May 2020 04:42:52 -0500
changeset 40358
e6fe6fc1f516
parent 35361
efdbd45604f1
child 40520
eae11ccb1bef
permissions
-rw-r--r--

move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually

33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
1 /* purple
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
2 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
5 * source distribution.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
6 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
7 * Rewritten from scratch during Google Summer of Code 2012
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
9 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
10 * Previously implemented by:
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
11 * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001);
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
12 * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005;
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
13 * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
14 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
15 * This program is free software; you can redistribute it and/or modify
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
16 * it under the terms of the GNU General Public License as published by
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
17 * the Free Software Foundation; either version 2 of the License, or
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
18 * (at your option) any later version.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
19 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
20 * This program is distributed in the hope that it will be useful,
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
23 * GNU General Public License for more details.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
24 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
25 * You should have received a copy of the GNU General Public License
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
26 * along with this program; if not, write to the Free Software
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
28 */
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33343
diff changeset
29
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
30 #include "xml.h"
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
31
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
32 gboolean ggp_xml_get_string(const PurpleXmlNode *xml, gchar *childName, gchar **var)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
33 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
34 char *str;
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
35
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
36 g_return_val_if_fail(xml != NULL, FALSE);
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
37 g_return_val_if_fail(var != NULL, FALSE);
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
38
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35357
diff changeset
39 if (childName != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
40 xml = purple_xmlnode_get_child(xml, childName);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
41 if (xml == NULL)
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
42 return FALSE;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
43 }
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
44
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
45 str = purple_xmlnode_get_data(xml);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
46 if (str == NULL)
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
47 return FALSE;
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
48
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
49 *var = str;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
50 return TRUE;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
51 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
52
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
53 gboolean ggp_xml_get_bool(const PurpleXmlNode *xml, gchar *childName, gboolean *var)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
54 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
55 char *str;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
56 gboolean succ;
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
57
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
58 succ = ggp_xml_get_string(xml, childName, &str);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
59 if (!succ)
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
60 return FALSE;
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
61
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
62 *var = (strcmp(str, "true") == 0 ||
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
63 strcmp(str, "True") == 0 ||
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
64 strcmp(str, "TRUE") == 0 ||
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
65 strcmp(str, "1") == 0);
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
66 g_free(str);
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
67
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
68 return TRUE;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
69 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
70
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
71 gboolean ggp_xml_get_uint(const PurpleXmlNode *xml, gchar *childName, unsigned int *var)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
72 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
73 char *str, *endptr;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
74 gboolean succ;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
75 unsigned int val;
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
76
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
77 succ = ggp_xml_get_string(xml, childName, &str);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
78 if (!succ)
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
79 return FALSE;
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
80
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
81 errno = 0;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
82 val = strtoul(str, &endptr, 10);
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
83
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
84 succ = (errno != ERANGE && endptr[0] == '\0');
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
85 g_free(str);
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
86
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
87 if (succ)
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
88 *var = val;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
89 return succ;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
90 }
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
91
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
92 gboolean ggp_xml_set_string(PurpleXmlNode *xml, gchar *childName, const gchar *val)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
93 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
94 g_return_val_if_fail(xml != NULL, FALSE);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
95 g_return_val_if_fail(val != NULL, FALSE);
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
96
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35357
diff changeset
97 if (childName != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
98 PurpleXmlNode *child = purple_xmlnode_get_child(xml, childName);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
99 if (child == NULL)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
100 child = purple_xmlnode_new_child(xml, childName);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
101 xml = child;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
102 }
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
103
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
104 ggp_xmlnode_remove_children(xml);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
105 purple_xmlnode_insert_data(xml, val, -1);
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
106
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
107 return TRUE;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
108 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
109
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
110 gboolean ggp_xml_set_bool(PurpleXmlNode *xml, gchar *childName, gboolean val)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
111 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
112 return ggp_xml_set_string(xml, childName, val ? "true" : "false");
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
113 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
114
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
115 gboolean ggp_xml_set_uint(PurpleXmlNode *xml, gchar *childName, unsigned int val)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
116 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
117 gchar buff[20];
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
118 g_snprintf(buff, sizeof(buff), "%u", val);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
119 return ggp_xml_set_string(xml, childName, buff);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
120 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
121
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
122 void ggp_xmlnode_remove_children(PurpleXmlNode *xml)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
123 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
124 PurpleXmlNode *child = xml->child;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35357
diff changeset
125 while (child) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
126 PurpleXmlNode *next = child->next;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
127 if (child->type != PURPLE_XMLNODE_TYPE_ATTRIB)
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
128 purple_xmlnode_free(child);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
129 child = next;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
130 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
131 }
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
132
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
133 unsigned int ggp_xml_child_count(PurpleXmlNode *xml, const gchar *childName)
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
134 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
135 PurpleXmlNode *child;
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
136 unsigned int count = 0;
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
137
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
138 g_return_val_if_fail(xml != NULL, 0);
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
139
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35357
diff changeset
140 if (childName) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
141 child = purple_xmlnode_get_child(xml, childName);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35357
diff changeset
142 while (child) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33348
diff changeset
143 child = purple_xmlnode_get_next_twin(child);
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
144 count++;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
145 }
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35357
diff changeset
146 } else {
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
147 child = xml->child;
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35357
diff changeset
148 while (child) {
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
149 child = child->next;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
150 count++;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
151 }
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
152 }
35357
389e413e3414 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34935
diff changeset
153
33343
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
154 return count;
09f740724036 Gadu-Gadu: extended OAuth support, initial support for gg10.5 public directory
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33315
diff changeset
155 }

mercurial