libpurple/protocols/gg/roster.c

Fri, 01 Oct 2021 05:09:16 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 01 Oct 2021 05:09:16 -0500
changeset 41071
f4f7d9f816f9
parent 40708
53a26c29d26c
child 41091
fa2d6b0a4912
permissions
-rw-r--r--

move the gadu-gadu protocol plugins icons to a resource in the plugin

Testing Done:
Ran in devenv with a logo inverted (which was reverted before committing).

Reviewed at https://reviews.imfreedom.org/r/976/

33348
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
1 /* purple
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
2 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
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: 33326
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: 33326
diff changeset
5 * source distribution.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
6 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
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: 33326
diff changeset
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
9 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
10 * Previously implemented by:
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
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: 33326
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: 33326
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: 33326
diff changeset
14 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
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: 33326
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: 33326
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: 33326
diff changeset
18 * (at your option) any later version.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
19 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
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: 33326
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: 33326
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: 33326
diff changeset
23 * GNU General Public License for more details.
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
24 *
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
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: 33326
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: 33326
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: 33326
diff changeset
28 */
2394cd23ce8f Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33326
diff changeset
29
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
30 #include "roster.h"
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
31
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
32 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
33
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
34 #include "gg.h"
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
35 #include "xml.h"
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
36 #include "utils.h"
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
37 #include "purplew.h"
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
38
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
39 #define GGP_ROSTER_SYNC_SETT "gg-synchronized"
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
40 #define GGP_ROSTER_DEBUG 0
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
41 #define GGP_ROSTER_GROUPID_DEFAULT "00000000-0000-0000-0000-000000000000"
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
42 #define GGP_ROSTER_GROUPID_BOTS "0b345af6-0001-0000-0000-000000000004"
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
43
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
44 /* TODO: ignored contacts synchronization (?) */
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
45
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
46 typedef struct
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
47 {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
48 int version;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
49
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
50 PurpleXmlNode *xml;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
51
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
52 PurpleXmlNode *groups_node, *contacts_node;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
53
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
54 /**
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
55 * Key: (uin_t) user identifier
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
56 * Value: (PurpleXmlNode*) xml node for contact
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
57 */
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
58 GHashTable *contact_nodes;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
59
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
60 /**
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
61 * Key: (gchar*) group id
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
62 * Value: (PurpleXmlNode*) xml node for group
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
63 */
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
64 GHashTable *group_nodes;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
65
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
66 /**
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
67 * Key: (gchar*) group name
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
68 * Value: (gchar*) group id
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
69 */
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
70 GHashTable *group_ids;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
71
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
72 /**
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
73 * Key: (gchar*) group id
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
74 * Value: (gchar*) group name
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
75 */
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
76 GHashTable *group_names;
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
77
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
78 gchar *bots_group_id;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
79
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
80 gboolean needs_update;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
81 } ggp_roster_content;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
82
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
83 typedef struct
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
84 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
85 enum
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
86 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
87 GGP_ROSTER_CHANGE_CONTACT_UPDATE,
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
88 GGP_ROSTER_CHANGE_CONTACT_REMOVE,
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
89 GGP_ROSTER_CHANGE_GROUP_RENAME,
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
90 } type;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
91 union
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
92 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
93 uin_t uin;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
94 struct
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
95 {
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
96 gchar *old_name;
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
97 gchar *new_name;
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
98 } group_rename;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
99 } data;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
100 } ggp_roster_change;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
101
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
102 static inline ggp_roster_session_data *
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
103 ggp_roster_get_rdata(PurpleConnection *gc);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
104 static void ggp_roster_content_free(ggp_roster_content *content);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
105 static void ggp_roster_change_free(gpointer change);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
106 static int ggp_roster_get_version(PurpleConnection *gc);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
107 static gboolean ggp_roster_timer_cb(gpointer _gc);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
108 #if GGP_ROSTER_DEBUG
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
109 static void ggp_roster_dump(ggp_roster_content *content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
110 #endif
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
111
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
112 /* synchronization control */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
113 static gboolean ggp_roster_is_synchronized(PurpleBuddy *buddy);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
114 static void ggp_roster_set_synchronized(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
115 PurpleBuddy *buddy, gboolean synchronized);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
116
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
117 /* buddy list import */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
118 static gboolean ggp_roster_reply_list_read_group(PurpleXmlNode *node,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
119 ggp_roster_content *content);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
120 static gboolean ggp_roster_reply_list_read_buddy(PurpleConnection *gc,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
121 PurpleXmlNode *node, ggp_roster_content *content, GHashTable *remove_buddies);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
122 static void ggp_roster_reply_list(PurpleConnection *gc, uint32_t version,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
123 const char *reply);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
124
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
125 /* buddy list export */
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
126 static const gchar * ggp_roster_send_update_group_add(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
127 ggp_roster_content *content, PurpleGroup *group);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
128 static gboolean ggp_roster_send_update_contact_update(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
129 ggp_roster_change *change);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
130 static gboolean ggp_roster_send_update_contact_remove(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
131 ggp_roster_change *change);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
132 static gboolean ggp_roster_send_update_group_rename(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
133 ggp_roster_change *change);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
134 static void ggp_roster_send_update(PurpleConnection *gc);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
135 static void ggp_roster_reply_ack(PurpleConnection *gc, uint32_t version);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
136 static void ggp_roster_reply_reject(PurpleConnection *gc, uint32_t version);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
137
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
138 /******************************************************************************/
33319
8321461fa2be Gadu-Gadu: roster - disable, when not supported
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33318
diff changeset
139
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
140 static inline ggp_roster_session_data *
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
141 ggp_roster_get_rdata(PurpleConnection *gc)
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
142 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
143 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
144 return &accdata->roster_data;
35358
7beae478c905 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35356
diff changeset
145 }
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
146
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
147 static void ggp_roster_content_free(ggp_roster_content *content)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
148 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
149 if (content == NULL)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
150 return;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
151 if (content->xml)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
152 purple_xmlnode_free(content->xml);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
153 if (content->contact_nodes)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
154 g_hash_table_destroy(content->contact_nodes);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
155 if (content->group_nodes)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
156 g_hash_table_destroy(content->group_nodes);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
157 if (content->group_ids)
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
158 g_hash_table_destroy(content->group_ids);
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
159 if (content->group_names)
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
160 g_hash_table_destroy(content->group_names);
37426
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 36068
diff changeset
161 g_free(content->bots_group_id);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
162 g_free(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
163 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
164
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
165 static void ggp_roster_change_free(gpointer _change)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
166 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
167 ggp_roster_change *change = _change;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
168
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
169 if (change->type == GGP_ROSTER_CHANGE_GROUP_RENAME) {
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
170 g_free(change->data.group_rename.old_name);
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
171 g_free(change->data.group_rename.new_name);
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
172 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
173
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
174 g_free(change);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
175 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
176
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
177 static int ggp_roster_get_version(PurpleConnection *gc)
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
178 {
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
179 ggp_roster_content *content = ggp_roster_get_rdata(gc)->content;
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
180 if (content == NULL)
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
181 return 0;
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
182 return content->version;
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
183 }
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
184
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
185 static gboolean ggp_roster_timer_cb(gpointer _gc)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
186 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
187 PurpleConnection *gc = _gc;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
188
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35958
diff changeset
189 PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
190
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
191 ggp_roster_send_update(gc);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
192
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
193 return TRUE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
194 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
195
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
196 #if GGP_ROSTER_DEBUG
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
197 static void ggp_roster_dump(ggp_roster_content *content)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
198 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
199 char *str;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
200 int len;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
201
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
202 g_return_if_fail(content != NULL);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
203 g_return_if_fail(content->xml != NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
204
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
205 str = purple_xmlnode_to_formatted_str(content->xml, &len);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
206 purple_debug_misc("gg", "ggp_roster_dump: [%s]\n", str);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
207 g_free(str);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
208 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
209 #endif
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
210
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
211 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
212 * Setup.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
213 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
214
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
215 gboolean ggp_roster_enabled(void)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
216 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
217 static gboolean checked = FALSE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
218 static gboolean enabled;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
219
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
220 if (!checked) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
221 enabled = gg_libgadu_check_feature(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
222 GG_LIBGADU_FEATURE_USERLIST100);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
223 checked = TRUE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
224 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
225 return enabled;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
226 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
227
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
228 void ggp_roster_setup(PurpleConnection *gc)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
229 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
230 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
231
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
232 rdata->content = NULL;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
233 rdata->sent_updates = NULL;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
234 rdata->pending_updates = NULL;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
235 rdata->timer = 0;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
236 rdata->is_updating = FALSE;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
237
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
238 if (ggp_roster_enabled())
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 37523
diff changeset
239 rdata->timer = g_timeout_add_seconds(2,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
240 ggp_roster_timer_cb, gc);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
241 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
242
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
243 void ggp_roster_cleanup(PurpleConnection *gc)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
244 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
245 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
246
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
247 if (rdata->timer)
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 37523
diff changeset
248 g_source_remove(rdata->timer);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
249 ggp_roster_content_free(rdata->content);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
250 g_list_free_full(rdata->sent_updates, ggp_roster_change_free);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
251 g_list_free_full(rdata->pending_updates, ggp_roster_change_free);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
252 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
253
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
254 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
255 * Synchronization control.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
256 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
257
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
258 static gboolean ggp_roster_is_synchronized(PurpleBuddy *buddy)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
259 {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
260 gboolean ret = purple_blist_node_get_bool(PURPLE_BLIST_NODE(buddy),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
261 GGP_ROSTER_SYNC_SETT);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
262 return ret;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
263 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
264
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
265 static void ggp_roster_set_synchronized(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
266 PurpleBuddy *buddy, gboolean synchronized)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
267 {
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
268 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
269 uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
270 ggp_roster_change *change;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
271
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
272 purple_blist_node_set_bool(PURPLE_BLIST_NODE(buddy),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
273 GGP_ROSTER_SYNC_SETT, synchronized);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
274 if (!synchronized) {
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
275 change = g_new0(ggp_roster_change, 1);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
276 change->type = GGP_ROSTER_CHANGE_CONTACT_UPDATE;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
277 change->data.uin = uin;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
278 rdata->pending_updates =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
279 g_list_append(rdata->pending_updates, change);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
280 }
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
281 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
282
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
283 void ggp_roster_request_update(PurpleConnection *gc)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
284 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
285 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
286 int local_version = ggp_roster_get_version(gc);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
287
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
288 if (!ggp_roster_enabled()) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
289 purple_debug_warning("gg", "ggp_roster_request_update: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
290 "feature disabled\n");
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
291 return;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
292 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
293
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
294 purple_debug_info("gg", "ggp_roster_request_update: local=%u\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
295 local_version);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
296
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
297 gg_userlist100_request(accdata->session, GG_USERLIST100_GET,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
298 local_version, GG_USERLIST100_FORMAT_TYPE_GG100, NULL);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
299 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
300
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
301 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
302 * Libgadu callbacks.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
303 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
304
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
305 void ggp_roster_reply(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
306 struct gg_event_userlist100_reply *reply)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
307 {
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
308 if (GG_USERLIST100_FORMAT_TYPE_GG100 != reply->format_type) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
309 purple_debug_warning("gg", "ggp_roster_reply: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
310 "unsupported format type (%x)\n", reply->format_type);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
311 return;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
312 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
313
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
314 if (reply->type == GG_USERLIST100_REPLY_LIST)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
315 ggp_roster_reply_list(gc, reply->version, reply->reply);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
316 else if (reply->type == 0x01) /* list up to date (TODO: push to libgadu) */
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
317 purple_debug_info("gg", "ggp_roster_reply: list up to date\n");
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
318 else if (reply->type == GG_USERLIST100_REPLY_ACK)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
319 ggp_roster_reply_ack(gc, reply->version);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
320 else if (reply->type == GG_USERLIST100_REPLY_REJECT)
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
321 ggp_roster_reply_reject(gc, reply->version);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
322 else
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
323 purple_debug_error("gg", "ggp_roster_reply: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
324 "unsupported reply (%x)\n", reply->type);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
325 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
326
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
327 void ggp_roster_version(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
328 struct gg_event_userlist100_version *version)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
329 {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
330 int local_version = ggp_roster_get_version(gc);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
331 int remote_version = version->version;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
332
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
333 purple_debug_info("gg", "ggp_roster_version: local=%u, remote=%u\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
334 local_version, remote_version);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
335
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
336 if (local_version < remote_version)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
337 ggp_roster_request_update(gc);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
338 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
339
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
340 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
341 * Libpurple callbacks.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
342 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
343
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
344 void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
345 ggp_roster_alias_buddy(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
346 PurpleConnection *gc, const gchar *who,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
347 const gchar *alias)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
348 {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
349 PurpleBuddy *buddy;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
350
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
351 g_return_if_fail(who != NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
352
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
353 if (!ggp_roster_enabled())
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
354 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
355
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
356 purple_debug_misc("gg", "ggp_roster_alias_buddy(\"%s\", \"%s\")\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
357 who, alias);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
358
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
359 buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
360 g_return_if_fail(buddy != NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
361
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
362 ggp_roster_set_synchronized(gc, buddy, FALSE);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
363 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
364
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
365 void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
366 ggp_roster_group_buddy(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
367 PurpleConnection *gc, const gchar *who,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
368 const gchar *old_group, const gchar *new_group)
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
369 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
370 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
35629
5aecb81f23ab Fix memory leaks in Gadu-Gadu prpl. Fixes #16129
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35361
diff changeset
371 ggp_roster_change *change;
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
372
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
373 if (!ggp_roster_enabled())
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
374 return;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
375 if (rdata->is_updating)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
376 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
377
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
378 purple_debug_misc("gg", "ggp_roster_group_buddy: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
379 "who=\"%s\", group=\"%s\" -> \"%s\")\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
380 who, old_group, new_group);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
381
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
382 /* purple_blist_find_buddy(..., who) is not accessible at this moment */
35629
5aecb81f23ab Fix memory leaks in Gadu-Gadu prpl. Fixes #16129
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35361
diff changeset
383 change = g_new0(ggp_roster_change, 1);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
384 change->type = GGP_ROSTER_CHANGE_CONTACT_UPDATE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
385 change->data.uin = ggp_str_to_uin(who);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
386 rdata->pending_updates = g_list_append(rdata->pending_updates, change);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
387 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
388
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
389 void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
390 ggp_roster_rename_group(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
391 PurpleConnection *gc, const gchar *old_name,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
392 PurpleGroup *group, GList *moved_buddies)
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
393 {
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
394 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
35629
5aecb81f23ab Fix memory leaks in Gadu-Gadu prpl. Fixes #16129
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35361
diff changeset
395 ggp_roster_change *change;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
396
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
397 if (!ggp_roster_enabled())
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
398 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
399
35629
5aecb81f23ab Fix memory leaks in Gadu-Gadu prpl. Fixes #16129
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35361
diff changeset
400 change = g_new0(ggp_roster_change, 1);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
401 change->type = GGP_ROSTER_CHANGE_GROUP_RENAME;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
402 change->data.group_rename.old_name = g_strdup(old_name);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
403 change->data.group_rename.new_name =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
404 g_strdup(purple_group_get_name(group));
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
405 rdata->pending_updates = g_list_append(rdata->pending_updates, change);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
406 }
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
407
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
408 void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
409 ggp_roster_add_buddy(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
410 PurpleConnection *gc, PurpleBuddy *buddy,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
411 PurpleGroup *group, const gchar *message)
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
412 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
413 g_return_if_fail(gc != NULL);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
414 g_return_if_fail(buddy != NULL);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
415
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
416 if (!ggp_roster_enabled())
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
417 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
418
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
419 ggp_roster_set_synchronized(gc, buddy, FALSE);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
420 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
421
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
422 void
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
423 ggp_roster_remove_buddy(PurpleProtocolServer *protocol_server,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
424 PurpleConnection *gc, PurpleBuddy *buddy,
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
425 PurpleGroup *group)
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
426 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
427 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
35629
5aecb81f23ab Fix memory leaks in Gadu-Gadu prpl. Fixes #16129
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35361
diff changeset
428 ggp_roster_change *change;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
429
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
430 if (!ggp_roster_enabled())
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
431 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
432
35629
5aecb81f23ab Fix memory leaks in Gadu-Gadu prpl. Fixes #16129
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35361
diff changeset
433 change = g_new0(ggp_roster_change, 1);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
434 change->type = GGP_ROSTER_CHANGE_CONTACT_REMOVE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
435 change->data.uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
436 rdata->pending_updates = g_list_append(rdata->pending_updates, change);
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
437 }
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
438
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
439 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
440 * Buddy list import.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
441 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
442
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
443 static gboolean ggp_roster_reply_list_read_group(PurpleXmlNode *node,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
444 ggp_roster_content *content)
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
445 {
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
446 char *name, *id;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
447 gboolean removable;
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
448 gboolean succ = TRUE, is_bot, is_default;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
449
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
450 succ &= ggp_xml_get_string(node, "Id", &id);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
451 succ &= ggp_xml_get_string(node, "Name", &name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
452 succ &= ggp_xml_get_bool(node, "IsRemovable", &removable);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
453
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
454 if (!succ) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
455 g_free(id);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
456 g_free(name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
457 g_return_val_if_reached(FALSE);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
458 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
459
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
460 is_bot = (strcmp(id, GGP_ROSTER_GROUPID_BOTS) == 0 ||
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
461 g_strcmp0(name, "Pomocnicy") == 0);
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
462 is_default = (strcmp(id, GGP_ROSTER_GROUPID_DEFAULT) == 0 ||
35958
1d8446f396b6 blist: define default group better
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35758
diff changeset
463 g_strcmp0(name, PURPLE_BLIST_DEFAULT_GROUP_NAME) == 0 ||
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
464 g_strcmp0(name, "[default]") == 0);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
465
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
466 if (!content->bots_group_id && is_bot)
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
467 content->bots_group_id = g_strdup(id);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
468
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
469 if (!removable || is_bot || is_default) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
470 g_free(id);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
471 g_free(name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
472 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
473 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
474
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
475 g_hash_table_insert(content->group_nodes, g_strdup(id), node);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
476 g_hash_table_insert(content->group_ids, g_strdup(name), g_strdup(id));
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
477 g_hash_table_insert(content->group_names, id, name);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
478
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
479 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
480 }
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
481
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
482 static gboolean ggp_roster_reply_list_read_buddy(PurpleConnection *gc,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
483 PurpleXmlNode *node, ggp_roster_content *content, GHashTable *remove_buddies)
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
484 {
34377
5ba37b370be6 Initialize value
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
485 gchar *alias, *group_name = NULL;
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
486 uin_t uin;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
487 gboolean succ = TRUE;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
488 PurpleXmlNode *group_list, *group_elem;
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
489 PurpleBuddy *buddy = NULL;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
490 PurpleGroup *group = NULL;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
491 PurpleGroup *currentGroup;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
492 gboolean alias_changed;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
493 PurpleAccount *account = purple_connection_get_account(gc);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
494
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
495 succ &= ggp_xml_get_string(node, "ShowName", &alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
496 succ &= ggp_xml_get_uint(node, "GGNumber", &uin);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
497
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
498 group_list = purple_xmlnode_get_child(node, "Groups");
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
499 succ &= (group_list != NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
500
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
501 if (!succ) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
502 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
503 g_return_val_if_reached(FALSE);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
504 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
505
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
506 g_hash_table_insert(content->contact_nodes, GINT_TO_POINTER(uin), node);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
507
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
508 /* check, if alias is set */
37523
02346b6472b3 Simplify checks for empty strings
Michael McConville <mmcconville@mykolab.com>
parents: 37426
diff changeset
509 if (*alias == '\0' ||
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
510 strcmp(alias, ggp_uin_to_str(uin)) == 0)
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
511 {
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
512 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
513 alias = NULL;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
514 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
515
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
516 /* getting (eventually creating) group */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
517 group_elem = purple_xmlnode_get_child(group_list, "GroupId");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
518 while (group_elem != NULL) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
519 gchar *id;
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
520 gboolean isbot;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
521
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
522 if (!ggp_xml_get_string(group_elem, NULL, &id))
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
523 continue;
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
524 isbot = (0 == g_strcmp0(id, content->bots_group_id));
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
525 group_name = g_hash_table_lookup(content->group_names, id);
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
526 g_free(id);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
527
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
528 /* we don't want to import bots;
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
529 * they are inserted to roster by default
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
530 */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
531 if (isbot) {
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
532 g_free(alias);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
533 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
534 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
535
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
536 if (group_name != NULL)
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
537 break;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
538
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
539 group_elem = purple_xmlnode_get_next_twin(group_elem);
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
540 }
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
541 if (group_name) {
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
542 group = purple_blist_find_group(group_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
543 if (!group) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
544 group = purple_group_new(group_name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
545 purple_blist_add_group(group, NULL);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
546 }
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
547 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
548
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
549 /* add buddy, if doesn't exists */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
550 buddy = purple_blist_find_buddy(account, ggp_uin_to_str(uin));
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
551 g_hash_table_remove(remove_buddies, GINT_TO_POINTER(uin));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
552 if (!buddy) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
553 purple_debug_info("gg", "ggp_roster_reply_list_read_buddy: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
554 "adding %u (%s) to buddy list\n", uin, alias);
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
555 buddy = purple_buddy_new(account, ggp_uin_to_str(uin), alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
556 purple_blist_add_buddy(buddy, NULL, group, NULL);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
557 ggp_roster_set_synchronized(gc, buddy, TRUE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
558
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
559 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
560 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
561 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
562
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
563 /* buddy exists, but is not synchronized - local list has priority */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
564 if (!ggp_roster_is_synchronized(buddy)) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
565 purple_debug_misc("gg", "ggp_roster_reply_list_read_buddy: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
566 "ignoring not synchronized %u (%s)\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
567 uin, purple_buddy_get_name(buddy));
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
568 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
569 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
570 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
571
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
572 currentGroup = ggp_purplew_buddy_get_group_only(buddy);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
573 alias_changed =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
574 (0 != g_strcmp0(alias, purple_buddy_get_alias_only(buddy)));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
575
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
576 if (currentGroup == group && !alias_changed) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
577 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
578 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
579 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
580
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
581 purple_debug_misc("gg", "ggp_roster_reply_list_read_buddy: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
582 "updating %u (%s) - alias=\"%s\"->\"%s\", group=%p->%p (%s)\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
583 uin, purple_buddy_get_name(buddy),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
584 purple_buddy_get_alias(buddy), alias,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
585 currentGroup, group, group_name);
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
586 if (alias_changed)
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
587 purple_buddy_set_local_alias(buddy, alias);
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
588 if (currentGroup != group)
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
589 purple_blist_add_buddy(buddy, NULL, group, NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
590
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
591 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
592 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
593 }
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
594
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
595 static void ggp_roster_reply_list(PurpleConnection *gc, uint32_t version,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
596 const char *data)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
597 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
598 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
599 PurpleXmlNode *xml, *xml_it;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
600 PurpleAccount *account;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
601 GSList *local_buddies;
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
602 GHashTable *remove_buddies;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
603 GList *update_buddies = NULL, *local_groups, *it, *table_values;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
604 ggp_roster_content *content;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
605
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
606 g_return_if_fail(gc != NULL);
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
607 g_return_if_fail(data != NULL);
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
608
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
609 account = purple_connection_get_account(gc);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
610
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
611 purple_debug_info("gg", "ggp_roster_reply_list: got list, version=%u\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
612 version);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
613
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
614 xml = purple_xmlnode_from_str(data, -1);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
615 if (xml == NULL) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
616 purple_debug_warning("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
617 "invalid xml\n");
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
618 return;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
619 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
620
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
621 ggp_roster_content_free(rdata->content);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
622 rdata->content = NULL;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
623 rdata->is_updating = TRUE;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
624 content = g_new0(ggp_roster_content, 1);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
625 content->version = version;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
626 content->xml = xml;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
627 content->contact_nodes = g_hash_table_new(NULL, NULL);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
628 content->group_nodes = g_hash_table_new_full(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
629 g_str_hash, g_str_equal, g_free, NULL);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
630 content->group_ids = g_hash_table_new_full(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
631 g_str_hash, g_str_equal, g_free, g_free);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
632 content->group_names = g_hash_table_new_full(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
633 g_str_hash, g_str_equal, g_free, g_free);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
634
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
635 #if GGP_ROSTER_DEBUG
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
636 ggp_roster_dump(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
637 #endif
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
638
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
639 /* reading groups */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
640 content->groups_node = purple_xmlnode_get_child(xml, "Groups");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
641 if (content->groups_node == NULL) {
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
642 ggp_roster_content_free(content);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
643 g_return_if_reached();
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
644 }
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
645 xml_it = purple_xmlnode_get_child(content->groups_node, "Group");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
646 while (xml_it != NULL) {
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
647 if (!ggp_roster_reply_list_read_group(xml_it, content)) {
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
648 ggp_roster_content_free(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
649 g_return_if_reached();
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
650 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
651
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
652 xml_it = purple_xmlnode_get_next_twin(xml_it);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
653 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
654
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
655 /* dumping current group list */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
656 local_groups = ggp_purplew_account_get_groups(account, TRUE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
657
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
658 /* dumping current buddy list
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
659 * we will:
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
660 * - remove synchronized ones, if not found in list at server
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
661 * - upload not synchronized ones
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
662 */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
663 local_buddies = purple_blist_find_buddies(account, NULL);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
664 remove_buddies = g_hash_table_new(g_direct_hash, g_direct_equal);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
665 while (local_buddies) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
666 PurpleBuddy *buddy = local_buddies->data;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
667 uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
668 local_buddies =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
669 g_slist_delete_link(local_buddies, local_buddies);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
670
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
671 if (!uin)
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
672 continue;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
673
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
674 if (ggp_roster_is_synchronized(buddy))
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
675 g_hash_table_insert(remove_buddies,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
676 GINT_TO_POINTER(uin), buddy);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
677 else
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
678 update_buddies = g_list_append(update_buddies, buddy);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
679 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
680
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
681 /* reading buddies */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
682 content->contacts_node = purple_xmlnode_get_child(xml, "Contacts");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
683 if (content->contacts_node == NULL) {
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
684 g_hash_table_destroy(remove_buddies);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
685 g_list_free(update_buddies);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
686 ggp_roster_content_free(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
687 g_return_if_reached();
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
688 }
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
689 xml_it = purple_xmlnode_get_child(content->contacts_node, "Contact");
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
690 while (xml_it != NULL) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
691 if (!ggp_roster_reply_list_read_buddy(gc, xml_it, content,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
692 remove_buddies))
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
693 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
694 g_hash_table_destroy(remove_buddies);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
695 g_list_free(update_buddies);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
696 ggp_roster_content_free(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
697 g_return_if_reached();
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
698 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
699
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
700 xml_it = purple_xmlnode_get_next_twin(xml_it);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
701 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
702
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
703 /* removing buddies, which are not present in roster */
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
704 table_values = g_hash_table_get_values(remove_buddies);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
705 it = g_list_first(table_values);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
706 while (it) {
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
707 PurpleBuddy *buddy = it->data;
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
708 it = g_list_next(it);
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
709 if (!ggp_roster_is_synchronized(buddy))
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
710 continue;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
711 purple_debug_info("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
712 "removing %s from buddy list\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
713 purple_buddy_get_name(buddy));
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
714 purple_blist_remove_buddy(buddy);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
715 }
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
716 g_list_free(table_values);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
717 g_hash_table_destroy(remove_buddies);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
718
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
719 /* remove groups, which are empty, but had contacts before
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
720 * synchronization
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
721 */
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
722 it = g_list_first(local_groups);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
723 while (it) {
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
724 PurpleGroup *group = it->data;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
725 it = g_list_next(it);
34723
b496dd569514 Refactored libpurple plugins and protocols according to the blist API changes
Ankit Vani <a@nevitus.org>
parents: 33368
diff changeset
726 if (purple_counting_node_get_total_size(PURPLE_COUNTING_NODE(group)) != 0)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
727 continue;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
728 purple_debug_info("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
729 "removing group %s\n", purple_group_get_name(group));
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
730 purple_blist_remove_group(group);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
731 }
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
732 g_list_free(local_groups);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
733
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
734 /* adding not synchronized buddies */
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
735 it = g_list_first(update_buddies);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
736 while (it) {
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
737 PurpleBuddy *buddy = it->data;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
738 uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
739 ggp_roster_change *change;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
740
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
741 it = g_list_next(it);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
742 g_assert(uin > 0);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
743
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
744 purple_debug_misc("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
745 "adding change of %u for roster\n", uin);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
746 change = g_new0(ggp_roster_change, 1);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
747 change->type = GGP_ROSTER_CHANGE_CONTACT_UPDATE;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
748 change->data.uin = uin;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
749 rdata->pending_updates =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
750 g_list_append(rdata->pending_updates, change);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
751 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
752 g_list_free(update_buddies);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
753
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
754 rdata->content = content;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
755 rdata->is_updating = FALSE;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
756 purple_debug_info("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
757 "import done, version=%u\n", version);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
758 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
759
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
760 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
761 * Buddy list export.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
762 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
763
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
764 static const gchar * ggp_roster_send_update_group_add(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
765 ggp_roster_content *content, PurpleGroup *group)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
766 {
39491
0dfac00d800e Replace g_snprintf+g_strdup by g_strdup_printf.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38433
diff changeset
767 gchar *id;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
768 const char *id_existing, *group_name;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
769 PurpleXmlNode *group_node;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
770 gboolean succ = TRUE;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
771
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
772 if (group) {
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
773 group_name = purple_group_get_name(group);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
774 id_existing =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
775 g_hash_table_lookup(content->group_ids, group_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
776 } else
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
777 id_existing = GGP_ROSTER_GROUPID_DEFAULT;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
778 if (id_existing)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
779 return id_existing;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
780
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
781 purple_debug_info("gg", "ggp_roster_send_update_group_add: adding %s\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
782 purple_group_get_name(group));
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
783
40519
974dbfd7e52f Remove and replace a number of the purple utility functions
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
784 id = g_uuid_string_random();
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
785
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
786 group_node = purple_xmlnode_new_child(content->groups_node, "Group");
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
787 succ &= ggp_xml_set_string(group_node, "Id", id);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
788 succ &= ggp_xml_set_string(group_node, "Name", group_name);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
789 succ &= ggp_xml_set_string(group_node, "IsExpanded", "true");
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
790 succ &= ggp_xml_set_string(group_node, "IsRemovable", "true");
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
791 content->needs_update = TRUE;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
792
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
793 g_hash_table_insert(content->group_ids, g_strdup(group_name),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
794 g_strdup(id));
39491
0dfac00d800e Replace g_snprintf+g_strdup by g_strdup_printf.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38433
diff changeset
795 g_hash_table_replace(content->group_nodes, id, group_node);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
796
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
797 g_return_val_if_fail(succ, NULL);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
798
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
799 return id;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
800 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
801
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
802 static gboolean ggp_roster_send_update_contact_update(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
803 ggp_roster_change *change)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
804 {
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
805 PurpleAccount *account = purple_connection_get_account(gc);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
806 ggp_roster_content *content = ggp_roster_get_rdata(gc)->content;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
807 uin_t uin = change->data.uin;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
808 PurpleBuddy *buddy;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
809 PurpleXmlNode *buddy_node, *contact_groups;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
810 gboolean succ = TRUE;
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
811 const gchar *group_id;
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
812 gchar *guid;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
813
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
814 g_return_val_if_fail(change->type == GGP_ROSTER_CHANGE_CONTACT_UPDATE,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
815 FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
816
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
817 buddy = purple_blist_find_buddy(account, ggp_uin_to_str(uin));
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
818 if (!buddy)
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
819 return TRUE;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
820 buddy_node = g_hash_table_lookup(content->contact_nodes,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
821 GINT_TO_POINTER(uin));
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
822
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
823 group_id = ggp_roster_send_update_group_add(content,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
824 ggp_purplew_buddy_get_group_only(buddy));
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
825
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
826 if (buddy_node) { /* update existing */
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
827 purple_debug_misc("gg", "ggp_roster_send_update_contact_update:"
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
828 " updating %u...\n", uin);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
829
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
830 succ &= ggp_xml_set_string(buddy_node, "ShowName",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
831 purple_buddy_get_alias(buddy));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
832
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
833 contact_groups = purple_xmlnode_get_child(buddy_node, "Groups");
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
834 g_assert(contact_groups);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
835 ggp_xmlnode_remove_children(contact_groups);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
836 succ &= ggp_xml_set_string(contact_groups, "GroupId", group_id);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
837
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
838 g_return_val_if_fail(succ, FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
839
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
840 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
841 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
842
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
843 /* add new */
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
844 guid = g_uuid_string_random();
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
845 purple_debug_misc("gg", "ggp_roster_send_update_contact_update: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
846 "adding %u...\n", uin);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
847 buddy_node = purple_xmlnode_new_child(content->contacts_node, "Contact");
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
848 succ &= ggp_xml_set_string(buddy_node, "Guid", guid);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
849 succ &= ggp_xml_set_uint(buddy_node, "GGNumber", uin);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
850 succ &= ggp_xml_set_string(buddy_node, "ShowName",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
851 purple_buddy_get_alias(buddy));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
852
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
853 contact_groups = purple_xmlnode_new_child(buddy_node, "Groups");
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
854 g_assert(contact_groups);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
855 succ &= ggp_xml_set_string(contact_groups, "GroupId", group_id);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
856
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
857 purple_xmlnode_new_child(buddy_node, "Avatars");
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
858 succ &= ggp_xml_set_bool(buddy_node, "FlagBuddy", TRUE);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
859 succ &= ggp_xml_set_bool(buddy_node, "FlagNormal", TRUE);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
860 succ &= ggp_xml_set_bool(buddy_node, "FlagFriend", TRUE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
861
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
862 /* we don't use Guid, so update is not needed
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
863 * content->needs_update = TRUE;
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
864 */
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
865 g_free(guid);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
866
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
867 g_hash_table_insert(content->contact_nodes, GINT_TO_POINTER(uin),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
868 buddy_node);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
869
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
870 g_return_val_if_fail(succ, FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
871
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
872 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
873 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
874
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
875 static gboolean ggp_roster_send_update_contact_remove(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
876 ggp_roster_change *change)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
877 {
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
878 PurpleAccount *account = purple_connection_get_account(gc);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
879 ggp_roster_content *content = ggp_roster_get_rdata(gc)->content;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
880 uin_t uin = change->data.uin;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
881 PurpleBuddy *buddy;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
882 PurpleXmlNode *buddy_node;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
883
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
884 g_return_val_if_fail(change->type == GGP_ROSTER_CHANGE_CONTACT_REMOVE,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
885 FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
886
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
887 buddy = purple_blist_find_buddy(account, ggp_uin_to_str(uin));
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
888 if (buddy) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
889 purple_debug_info("gg", "ggp_roster_send_update_contact_remove:"
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
890 " contact %u re-added\n", uin);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
891 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
892 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
893
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
894 buddy_node = g_hash_table_lookup(content->contact_nodes,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
895 GINT_TO_POINTER(uin));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
896 if (!buddy_node) /* already removed */
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
897 return TRUE;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
898
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
899 purple_debug_info("gg", "ggp_roster_send_update_contact_remove: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
900 "removing %u\n", uin);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
901 purple_xmlnode_free(buddy_node);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
902 g_hash_table_remove(content->contact_nodes, GINT_TO_POINTER(uin));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
903
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
904 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
905 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
906
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
907 static gboolean ggp_roster_send_update_group_rename(PurpleConnection *gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
908 ggp_roster_change *change)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
909 {
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
910 PurpleAccount *account = purple_connection_get_account(gc);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
911 ggp_roster_content *content = ggp_roster_get_rdata(gc)->content;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
912 const char *old_name = change->data.group_rename.old_name;
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
913 const char *new_name = change->data.group_rename.new_name;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
914 PurpleXmlNode *group_node;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
915 const char *group_id;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
916
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
917 g_return_val_if_fail(change->type == GGP_ROSTER_CHANGE_GROUP_RENAME,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
918 FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
919
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
920 purple_debug_misc("gg", "ggp_roster_send_update_group_rename: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
921 "\"%s\"->\"%s\"\n", old_name, new_name);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
922
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
923 /* moving to or from default group instead of renaming it */
35958
1d8446f396b6 blist: define default group better
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35758
diff changeset
924 if (0 == g_strcmp0(old_name, PURPLE_BLIST_DEFAULT_GROUP_NAME) ||
1d8446f396b6 blist: define default group better
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35758
diff changeset
925 0 == g_strcmp0(new_name, PURPLE_BLIST_DEFAULT_GROUP_NAME))
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
926 {
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
927 PurpleGroup *group;
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
928 GList *group_buddies;
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
929 group = purple_blist_find_group(new_name);
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
930 if (!group)
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
931 return TRUE;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
932 purple_debug_info("gg", "ggp_roster_send_update_group_rename: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
933 "invalidating buddies in default group\n");
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
934 group_buddies = ggp_purplew_group_get_buddies(group, account);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
935 while (group_buddies) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
936 ggp_roster_set_synchronized(gc, group_buddies->data,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
937 FALSE);
35758
87c51487e197 Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35629
diff changeset
938 group_buddies = g_list_delete_link(group_buddies,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
939 group_buddies);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
940 }
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
941 return TRUE;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
942 }
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
943 group_id = g_hash_table_lookup(content->group_ids, old_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
944 if (!group_id) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
945 purple_debug_info("gg", "ggp_roster_send_update_group_rename: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
946 "%s is not present at roster\n", old_name);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
947 return TRUE;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
948 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
949
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
950 group_node = g_hash_table_lookup(content->group_nodes, group_id);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
951 if (!group_node) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
952 purple_debug_error("gg", "ggp_roster_send_update_group_rename: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
953 "node for %s not found, id=%s\n", old_name, group_id);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
954 g_hash_table_remove(content->group_ids, old_name);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
955 return TRUE;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
956 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
957
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
958 g_hash_table_remove(content->group_ids, old_name);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
959 g_hash_table_insert(content->group_ids, g_strdup(new_name),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
960 g_strdup(group_id));
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
961 g_hash_table_insert(content->group_nodes, g_strdup(group_id),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
962 group_node);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
963 return ggp_xml_set_string(group_node, "Name", new_name);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
964 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
965
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
966 static void ggp_roster_send_update(PurpleConnection *gc)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
967 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
968 GGPInfo *accdata = purple_connection_get_protocol_data(gc);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
969 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
970 ggp_roster_content *content = rdata->content;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
971 GList *updates_it;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
972 gchar *str;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
973 int len;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
974
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
975 /* an update is running now */
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
976 if (rdata->sent_updates)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
977 return;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
978
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
979 /* no pending updates found */
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
980 if (!rdata->pending_updates)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
981 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
982
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
983 /* not initialized */
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
984 if (!content)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
985 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
986
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
987 purple_debug_info("gg", "ggp_roster_send_update: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
988 "pending updates found\n");
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
989
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
990 rdata->sent_updates = rdata->pending_updates;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
991 rdata->pending_updates = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
992
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
993 updates_it = g_list_first(rdata->sent_updates);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
994 while (updates_it) {
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
995 ggp_roster_change *change = updates_it->data;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
996 gboolean succ = FALSE;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
997 updates_it = g_list_next(updates_it);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
998
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
999 if (change->type == GGP_ROSTER_CHANGE_CONTACT_UPDATE)
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1000 succ = ggp_roster_send_update_contact_update(gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1001 change);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1002 else if (change->type == GGP_ROSTER_CHANGE_CONTACT_REMOVE)
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1003 succ = ggp_roster_send_update_contact_remove(gc,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1004 change);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1005 else if (change->type == GGP_ROSTER_CHANGE_GROUP_RENAME)
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1006 succ = ggp_roster_send_update_group_rename(gc, change);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1007 else
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1008 purple_debug_fatal("gg", "ggp_roster_send_update: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1009 "not handled\n");
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1010 g_return_if_fail(succ);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1011 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1012
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1013 #if GGP_ROSTER_DEBUG
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1014 ggp_roster_dump(content);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1015 #endif
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1016
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1017 str = purple_xmlnode_to_str(content->xml, &len);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1018 gg_userlist100_request(accdata->session, GG_USERLIST100_PUT,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1019 content->version, GG_USERLIST100_FORMAT_TYPE_GG100, str);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1020 g_free(str);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
1021 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
1022
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1023 static void ggp_roster_reply_ack(PurpleConnection *gc, uint32_t version)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
1024 {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1025 PurpleAccount *account = purple_connection_get_account(gc);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1026 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1027 ggp_roster_content *content = rdata->content;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1028 GList *updates_it;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1029
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1030 purple_debug_info("gg", "ggp_roster_reply_ack: version=%u\n", version);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1031
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1032 /* set synchronization flag for all buddies, that were updated at roster */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1033 updates_it = g_list_first(rdata->sent_updates);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
1034 while (updates_it) {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1035 ggp_roster_change *change = updates_it->data;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1036 PurpleBuddy *buddy;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1037 updates_it = g_list_next(updates_it);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1038
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1039 if (change->type != GGP_ROSTER_CHANGE_CONTACT_UPDATE)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1040 continue;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1041
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
1042 buddy = purple_blist_find_buddy(account,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1043 ggp_uin_to_str(change->data.uin));
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1044 if (buddy)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1045 ggp_roster_set_synchronized(gc, buddy, TRUE);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1046 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1047
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1048 /* we need to remove "synchronized" flag for all contacts, that have
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1049 * beed modified between roster update start and now
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1050 */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1051 updates_it = g_list_first(rdata->pending_updates);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
1052 while (updates_it) {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1053 ggp_roster_change *change = updates_it->data;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1054 PurpleBuddy *buddy;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1055 updates_it = g_list_next(updates_it);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1056
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1057 if (change->type != GGP_ROSTER_CHANGE_CONTACT_UPDATE)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1058 continue;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1059
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
1060 buddy = purple_blist_find_buddy(account,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1061 ggp_uin_to_str(change->data.uin));
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1062 if (buddy && ggp_roster_is_synchronized(buddy))
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1063 ggp_roster_set_synchronized(gc, buddy, FALSE);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1064 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1065
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1066 g_list_free_full(rdata->sent_updates, ggp_roster_change_free);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1067 rdata->sent_updates = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1068
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1069 /* bump roster version or update it, if needed */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1070 g_return_if_fail(content != NULL);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
1071 if (content->needs_update) {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1072 ggp_roster_content_free(rdata->content);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1073 rdata->content = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1074 /* we have to wait for gg_event_userlist100_version
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1075 * ggp_roster_request_update(gc);
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1076 */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1077 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1078 else
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1079 content->version = version;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1080 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1081
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1082 static void ggp_roster_reply_reject(PurpleConnection *gc, uint32_t version)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1083 {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
1084 ggp_roster_session_data *rdata = ggp_roster_get_rdata(gc);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
1085
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1086 purple_debug_info("gg", "ggp_roster_reply_reject: version=%u\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1087 version);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1088
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1089 g_return_if_fail(rdata->sent_updates);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1090
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1091 rdata->pending_updates = g_list_concat(rdata->pending_updates,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1092 rdata->sent_updates);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1093 rdata->sent_updates = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1094
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1095 ggp_roster_content_free(rdata->content);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1096 rdata->content = NULL;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1097 ggp_roster_request_update(gc);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1098 }
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1099
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1100 /******************************************************************************/

mercurial