libpurple/protocols/gg/roster.c

Tue, 07 Mar 2023 01:04:42 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 07 Mar 2023 01:04:42 -0600
changeset 42128
118067ca0367
parent 42085
a76f1668564c
child 42172
7c2d151b410d
permissions
-rw-r--r--

Convert PurpleRequestPage into a GObject

And rename it from `PurpleRequestFields`.

Also, implements `GListModel` for the groups, but nothing uses it that way get.

Testing Done:
Compiled, and opened Request Fields from Demo protocol.

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

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
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
345 ggp_roster_alias_buddy(G_GNUC_UNUSED PurpleProtocolServer *protocol_server,
40708
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
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
366 ggp_roster_group_buddy(G_GNUC_UNUSED PurpleProtocolServer *protocol_server,
40708
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
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
390 ggp_roster_rename_group(G_GNUC_UNUSED PurpleProtocolServer *protocol_server,
40708
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,
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
392 PurpleGroup *group, G_GNUC_UNUSED 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
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
409 ggp_roster_add_buddy(G_GNUC_UNUSED PurpleProtocolServer *protocol_server,
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
410 PurpleConnection *gc, PurpleBuddy *buddy,
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
411 G_GNUC_UNUSED PurpleGroup *group,
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
412 G_GNUC_UNUSED const gchar *message)
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
413 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
414 g_return_if_fail(gc != NULL);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
415 g_return_if_fail(buddy != NULL);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
416
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
417 if (!ggp_roster_enabled())
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
418 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
419
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
420 ggp_roster_set_synchronized(gc, buddy, FALSE);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
421 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
422
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
423 void
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
424 ggp_roster_remove_buddy(G_GNUC_UNUSED PurpleProtocolServer *protocol_server,
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40520
diff changeset
425 PurpleConnection *gc, PurpleBuddy *buddy,
42085
a76f1668564c Make the gadu gadu protocol plugin clean for warning level 2
Gary Kramlich <grim@reaperworld.com>
parents: 41091
diff changeset
426 G_GNUC_UNUSED PurpleGroup *group)
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
427 {
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
428 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
429 ggp_roster_change *change;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
430
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
431 if (!ggp_roster_enabled())
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
432 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
433
35629
5aecb81f23ab Fix memory leaks in Gadu-Gadu prpl. Fixes #16129
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35361
diff changeset
434 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
435 change->type = GGP_ROSTER_CHANGE_CONTACT_REMOVE;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
436 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
437 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
438 }
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
439
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
440 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
441 * Buddy list import.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
442 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
443
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
444 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
445 ggp_roster_content *content)
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
446 {
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
447 char *name, *id;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
448 gboolean removable;
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
449 gboolean succ = TRUE, is_bot, is_default;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
450
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
451 succ &= ggp_xml_get_string(node, "Id", &id);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
452 succ &= ggp_xml_get_string(node, "Name", &name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
453 succ &= ggp_xml_get_bool(node, "IsRemovable", &removable);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
454
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
455 if (!succ) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
456 g_free(id);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
457 g_free(name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
458 g_return_val_if_reached(FALSE);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
459 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
460
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
461 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
462 g_strcmp0(name, "Pomocnicy") == 0);
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
463 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
464 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
465 g_strcmp0(name, "[default]") == 0);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
466
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
467 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
468 content->bots_group_id = g_strdup(id);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
469
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
470 if (!removable || is_bot || is_default) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
471 g_free(id);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
472 g_free(name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
473 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
474 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
475
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
476 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
477 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
478 g_hash_table_insert(content->group_names, id, name);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
479
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
480 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
481 }
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
482
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
483 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
484 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
485 {
34377
5ba37b370be6 Initialize value
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33368
diff changeset
486 gchar *alias, *group_name = NULL;
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
487 uin_t uin;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
488 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
489 PurpleXmlNode *group_list, *group_elem;
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
490 PurpleBuddy *buddy = NULL;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
491 PurpleGroup *group = NULL;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
492 PurpleGroup *currentGroup;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
493 gboolean alias_changed;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
494 PurpleAccount *account = purple_connection_get_account(gc);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
495
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
496 succ &= ggp_xml_get_string(node, "ShowName", &alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
497 succ &= ggp_xml_get_uint(node, "GGNumber", &uin);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
498
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
499 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
500 succ &= (group_list != NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
501
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
502 if (!succ) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
503 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
504 g_return_val_if_reached(FALSE);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
505 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
506
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
507 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
508
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
509 /* check, if alias is set */
37523
02346b6472b3 Simplify checks for empty strings
Michael McConville <mmcconville@mykolab.com>
parents: 37426
diff changeset
510 if (*alias == '\0' ||
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
511 strcmp(alias, ggp_uin_to_str(uin)) == 0)
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
512 {
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
513 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
514 alias = NULL;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
515 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
516
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
517 /* 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
518 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
519 while (group_elem != NULL) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
520 gchar *id;
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
521 gboolean isbot;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
522
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
523 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
524 continue;
33321
432a6a8a5ce5 Gadu-Gadu: roster - group issues, update reject handling
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33320
diff changeset
525 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
526 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
527 g_free(id);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
528
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
529 /* we don't want to import bots;
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
530 * they are inserted to roster by default
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
531 */
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
532 if (isbot) {
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
533 g_free(alias);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
534 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
535 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
536
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
537 if (group_name != NULL)
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
538 break;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
539
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
540 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
541 }
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
542 if (group_name) {
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
543 group = purple_blist_find_group(group_name);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
544 if (!group) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
545 group = purple_group_new(group_name);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
546 purple_blist_add_group(group, NULL);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
547 }
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
548 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
549
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
550 /* 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
551 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
552 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
553 if (!buddy) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
554 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
555 "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
556 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
557 purple_blist_add_buddy(buddy, NULL, group, NULL);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
558 ggp_roster_set_synchronized(gc, buddy, TRUE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
559
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
560 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
561 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
562 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
563
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
564 /* 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
565 if (!ggp_roster_is_synchronized(buddy)) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
566 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
567 "ignoring not synchronized %u (%s)\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
568 uin, purple_buddy_get_name(buddy));
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
569 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
570 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
571 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
572
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
573 currentGroup = ggp_purplew_buddy_get_group_only(buddy);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
574 alias_changed =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
575 (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
576
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
577 if (currentGroup == group && !alias_changed) {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
578 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
579 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
580 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
581
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
582 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
583 "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
584 uin, purple_buddy_get_name(buddy),
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
585 purple_buddy_get_alias(buddy), alias,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
586 currentGroup, group, group_name);
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
587 if (alias_changed)
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
588 purple_buddy_set_local_alias(buddy, alias);
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
589 if (currentGroup != group)
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
590 purple_blist_add_buddy(buddy, NULL, group, NULL);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
591
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
592 g_free(alias);
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
593 return TRUE;
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
594 }
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
595
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
596 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
597 const char *data)
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
598 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
599 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
600 PurpleXmlNode *xml, *xml_it;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
601 PurpleAccount *account;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
602 GSList *local_buddies;
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
603 GHashTable *remove_buddies;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
604 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
605 ggp_roster_content *content;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
606
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
607 g_return_if_fail(gc != NULL);
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
608 g_return_if_fail(data != NULL);
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
609
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
610 account = purple_connection_get_account(gc);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
611
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
612 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
613 version);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
614
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
615 xml = purple_xmlnode_from_str(data, -1);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
616 if (xml == NULL) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
617 purple_debug_warning("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
618 "invalid xml\n");
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
619 return;
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
620 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
621
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
622 ggp_roster_content_free(rdata->content);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
623 rdata->content = NULL;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
624 rdata->is_updating = TRUE;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
625 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
626 content->version = version;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
627 content->xml = xml;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
628 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
629 content->group_nodes = g_hash_table_new_full(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
630 g_str_hash, g_str_equal, g_free, NULL);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
631 content->group_ids = g_hash_table_new_full(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
632 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
633 content->group_names = g_hash_table_new_full(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
634 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
635
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
636 #if GGP_ROSTER_DEBUG
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
637 ggp_roster_dump(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
638 #endif
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
639
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
640 /* reading groups */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
641 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
642 if (content->groups_node == NULL) {
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
643 ggp_roster_content_free(content);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
644 g_return_if_reached();
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
645 }
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
646 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
647 while (xml_it != NULL) {
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
648 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
649 ggp_roster_content_free(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
650 g_return_if_reached();
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
651 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
652
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
653 xml_it = purple_xmlnode_get_next_twin(xml_it);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
654 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
655
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
656 /* dumping current group list */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
657 local_groups = ggp_purplew_account_get_groups(account, TRUE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
658
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
659 /* dumping current buddy list
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
660 * we will:
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
661 * - remove synchronized ones, if not found in list at server
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
662 * - upload not synchronized ones
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
663 */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
664 local_buddies = purple_blist_find_buddies(account, NULL);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
665 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
666 while (local_buddies) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
667 PurpleBuddy *buddy = local_buddies->data;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
668 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
669 local_buddies =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
670 g_slist_delete_link(local_buddies, local_buddies);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
671
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
672 if (!uin)
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
673 continue;
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
674
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
675 if (ggp_roster_is_synchronized(buddy))
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
676 g_hash_table_insert(remove_buddies,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
677 GINT_TO_POINTER(uin), buddy);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
678 else
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
679 update_buddies = g_list_append(update_buddies, buddy);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
680 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
681
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
682 /* reading buddies */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
683 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
684 if (content->contacts_node == NULL) {
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
685 g_hash_table_destroy(remove_buddies);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
686 g_list_free(update_buddies);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
687 ggp_roster_content_free(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
688 g_return_if_reached();
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
689 }
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
690 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
691 while (xml_it != NULL) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
692 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
693 remove_buddies))
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
694 {
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
695 g_hash_table_destroy(remove_buddies);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
696 g_list_free(update_buddies);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
697 ggp_roster_content_free(content);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
698 g_return_if_reached();
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
699 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
700
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
701 xml_it = purple_xmlnode_get_next_twin(xml_it);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
702 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
703
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
704 /* removing buddies, which are not present in roster */
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
705 table_values = g_hash_table_get_values(remove_buddies);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
706 it = g_list_first(table_values);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
707 while (it) {
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
708 PurpleBuddy *buddy = it->data;
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
709 it = g_list_next(it);
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
710 if (!ggp_roster_is_synchronized(buddy))
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
711 continue;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
712 purple_debug_info("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
713 "removing %s from buddy list\n",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
714 purple_buddy_get_name(buddy));
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
715 purple_blist_remove_buddy(buddy);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
716 }
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
717 g_list_free(table_values);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
718 g_hash_table_destroy(remove_buddies);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
719
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
720 /* remove groups, which are empty, but had contacts before
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
721 * synchronization
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
722 */
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
723 it = g_list_first(local_groups);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
724 while (it) {
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
725 PurpleGroup *group = it->data;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
726 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
727 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
728 continue;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
729 purple_debug_info("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
730 "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
731 purple_blist_remove_group(group);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
732 }
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
733 g_list_free(local_groups);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
734
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
735 /* adding not synchronized buddies */
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
736 it = g_list_first(update_buddies);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
737 while (it) {
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
738 PurpleBuddy *buddy = it->data;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
739 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
740 ggp_roster_change *change;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
741
33323
533c270f6f1d Gadu-Gadu: roster - remove emptied groups
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33321
diff changeset
742 it = g_list_next(it);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
743 g_assert(uin > 0);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
744
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
745 purple_debug_misc("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
746 "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
747 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
748 change->type = GGP_ROSTER_CHANGE_CONTACT_UPDATE;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
749 change->data.uin = uin;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
750 rdata->pending_updates =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
751 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
752 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
753 g_list_free(update_buddies);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
754
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
755 rdata->content = content;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
756 rdata->is_updating = FALSE;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
757 purple_debug_info("gg", "ggp_roster_reply_list: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
758 "import done, version=%u\n", version);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
759 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
760
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
761 /*******************************************************************************
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
762 * Buddy list export.
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
763 ******************************************************************************/
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
764
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
765 static const gchar * ggp_roster_send_update_group_add(
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
766 ggp_roster_content *content, PurpleGroup *group)
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
767 {
39491
0dfac00d800e Replace g_snprintf+g_strdup by g_strdup_printf.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38433
diff changeset
768 gchar *id;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
769 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
770 PurpleXmlNode *group_node;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
771 gboolean succ = TRUE;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
772
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
773 if (group) {
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
774 group_name = purple_group_get_name(group);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
775 id_existing =
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
776 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
777 } else
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
778 id_existing = GGP_ROSTER_GROUPID_DEFAULT;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
779 if (id_existing)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
780 return id_existing;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
781
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
782 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
783 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
784
40519
974dbfd7e52f Remove and replace a number of the purple utility functions
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
785 id = g_uuid_string_random();
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
786
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
787 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
788 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
789 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
790 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
791 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
792 content->needs_update = TRUE;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
793
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
794 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
795 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
796 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
797
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
798 g_return_val_if_fail(succ, NULL);
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
799
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
800 return id;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
801 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
802
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
803 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
804 ggp_roster_change *change)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
805 {
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
806 PurpleAccount *account = purple_connection_get_account(gc);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
807 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
808 uin_t uin = change->data.uin;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
809 PurpleBuddy *buddy;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
810 PurpleXmlNode *buddy_node, *contact_groups;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
811 gboolean succ = TRUE;
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
812 const gchar *group_id;
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
813 gchar *guid;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
814
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
815 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
816 FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
817
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
818 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
819 if (!buddy)
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
820 return TRUE;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
821 buddy_node = g_hash_table_lookup(content->contact_nodes,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
822 GINT_TO_POINTER(uin));
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
823
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
824 group_id = ggp_roster_send_update_group_add(content,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
825 ggp_purplew_buddy_get_group_only(buddy));
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
826
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
827 if (buddy_node) { /* update existing */
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
828 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
829 " updating %u...\n", uin);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
830
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
831 succ &= ggp_xml_set_string(buddy_node, "ShowName",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
832 purple_buddy_get_alias(buddy));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
833
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
834 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
835 g_assert(contact_groups);
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
836 ggp_xmlnode_remove_children(contact_groups);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
837 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
838
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
839 g_return_val_if_fail(succ, FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
840
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
841 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
842 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
843
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
844 /* add new */
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
845 guid = g_uuid_string_random();
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
846 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
847 "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
848 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
849 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
850 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
851 succ &= ggp_xml_set_string(buddy_node, "ShowName",
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
852 purple_buddy_get_alias(buddy));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
853
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
854 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
855 g_assert(contact_groups);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
856 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
857
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
858 purple_xmlnode_new_child(buddy_node, "Avatars");
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
859 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
860 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
861 succ &= ggp_xml_set_bool(buddy_node, "FlagFriend", TRUE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
862
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
863 /* we don't use Guid, so update is not needed
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
864 * content->needs_update = TRUE;
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
865 */
40520
eae11ccb1bef Fix some ggp_xml stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40519
diff changeset
866 g_free(guid);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
867
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
868 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
869 buddy_node);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
870
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
871 g_return_val_if_fail(succ, FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
872
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
873 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
874 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
875
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
876 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
877 ggp_roster_change *change)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
878 {
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
879 PurpleAccount *account = purple_connection_get_account(gc);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
880 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
881 uin_t uin = change->data.uin;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
882 PurpleBuddy *buddy;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
883 PurpleXmlNode *buddy_node;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
884
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
885 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
886 FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
887
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
888 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
889 if (buddy) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
890 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
891 " contact %u re-added\n", uin);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
892 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
893 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
894
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
895 buddy_node = g_hash_table_lookup(content->contact_nodes,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
896 GINT_TO_POINTER(uin));
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
897 if (!buddy_node) /* already removed */
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
898 return TRUE;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
899
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
900 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
901 "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
902 purple_xmlnode_free(buddy_node);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
903 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
904
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
905 return TRUE;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
906 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
907
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
908 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
909 ggp_roster_change *change)
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
910 {
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
911 PurpleAccount *account = purple_connection_get_account(gc);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
912 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
913 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
914 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
915 PurpleXmlNode *group_node;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
916 const char *group_id;
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
917
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
918 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
919 FALSE);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
920
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
921 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
922 "\"%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
923
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
924 /* 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
925 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
926 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
927 {
33324
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
928 PurpleGroup *group;
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
929 GList *group_buddies;
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
930 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
931 if (!group)
103df11c3ff8 Gadu-Gadu: roster - default group rename
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33323
diff changeset
932 return TRUE;
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
933 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
934 "invalidating buddies in default group\n");
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
935 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
936 while (group_buddies) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
937 ggp_roster_set_synchronized(gc, group_buddies->data,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
938 FALSE);
35758
87c51487e197 Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35629
diff changeset
939 group_buddies = g_list_delete_link(group_buddies,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
940 group_buddies);
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
941 }
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
942 return TRUE;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
943 }
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
944 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
945 if (!group_id) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
946 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
947 "%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
948 return TRUE;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
949 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
950
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
951 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
952 if (!group_node) {
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
953 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
954 "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
955 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
956 return TRUE;
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
957 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
958
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
959 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
960 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
961 g_strdup(group_id));
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
962 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
963 group_node);
33320
f0ac6497f256 Gadu-Gadu: roster - fix synchronization for multiple gg accounts
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33319
diff changeset
964 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
965 }
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
966
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
967 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
968 {
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
969 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
970 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
971 ggp_roster_content *content = rdata->content;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
972 GList *updates_it;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
973 gchar *str;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
974 int len;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
975
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
976 /* an update is running now */
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
977 if (rdata->sent_updates)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
978 return;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
979
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
980 /* no pending updates found */
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
981 if (!rdata->pending_updates)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
982 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
983
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
984 /* not initialized */
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
985 if (!content)
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
986 return;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
987
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
988 purple_debug_info("gg", "ggp_roster_send_update: "
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
989 "pending updates found\n");
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
990
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
991 rdata->sent_updates = rdata->pending_updates;
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
992 rdata->pending_updates = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
993
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
994 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
995 while (updates_it) {
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
996 ggp_roster_change *change = updates_it->data;
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
997 gboolean succ = FALSE;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
998 updates_it = g_list_next(updates_it);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
999
41091
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1000 if (change->type == GGP_ROSTER_CHANGE_CONTACT_UPDATE) {
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1001 succ = ggp_roster_send_update_contact_update(gc, change);
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1002 } else if (change->type == GGP_ROSTER_CHANGE_CONTACT_REMOVE) {
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1003 succ = ggp_roster_send_update_contact_remove(gc, change);
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1004 } else if (change->type == GGP_ROSTER_CHANGE_GROUP_RENAME) {
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1005 succ = ggp_roster_send_update_group_rename(gc, change);
41091
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1006 } else {
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1007 purple_debug_error("gg", "ggp_roster_send_update: not handled");
fa2d6b0a4912 Use purple_debug_fatal only if actually fatal
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40708
diff changeset
1008 }
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1009 g_return_if_fail(succ);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1010 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1011
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1012 #if GGP_ROSTER_DEBUG
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1013 ggp_roster_dump(content);
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1014 #endif
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1015
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1016 str = purple_xmlnode_to_str(content->xml, &len);
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1017 gg_userlist100_request(accdata->session, GG_USERLIST100_PUT,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1018 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
1019 g_free(str);
33314
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
1020 }
57013b9e1a8e Gadu-Gadu: roster - downloading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
1021
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1022 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
1023 {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1024 PurpleAccount *account = purple_connection_get_account(gc);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1025 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
1026 ggp_roster_content *content = rdata->content;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1027 GList *updates_it;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1028
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1029 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
1030
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1031 /* 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
1032 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
1033 while (updates_it) {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1034 ggp_roster_change *change = updates_it->data;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1035 PurpleBuddy *buddy;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1036 updates_it = g_list_next(updates_it);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1037
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1038 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
1039 continue;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1040
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
1041 buddy = purple_blist_find_buddy(account,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1042 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
1043 if (buddy)
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1044 ggp_roster_set_synchronized(gc, buddy, TRUE);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1045 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1046
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1047 /* 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
1048 * beed modified between roster update start and now
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1049 */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1050 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
1051 while (updates_it) {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1052 ggp_roster_change *change = updates_it->data;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1053 PurpleBuddy *buddy;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1054 updates_it = g_list_next(updates_it);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1055
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1056 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
1057 continue;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1058
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34723
diff changeset
1059 buddy = purple_blist_find_buddy(account,
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1060 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
1061 if (buddy && ggp_roster_is_synchronized(buddy))
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1062 ggp_roster_set_synchronized(gc, buddy, FALSE);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1063 }
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1064
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1065 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
1066 rdata->sent_updates = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1067
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1068 /* 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
1069 g_return_if_fail(content != NULL);
35361
efdbd45604f1 Style: fix gg braces (part 2)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35358
diff changeset
1070 if (content->needs_update) {
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1071 ggp_roster_content_free(rdata->content);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1072 rdata->content = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1073 /* we have to wait for gg_event_userlist100_version
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1074 * ggp_roster_request_update(gc);
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1075 */
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1076 }
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1077 else
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1078 content->version = version;
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1079 }
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1080
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1081 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
1082 {
33317
ceebe795b644 Gadu-Gadu: roster - code cleanup
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33316
diff changeset
1083 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
1084
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1085 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
1086 version);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1087
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1088 g_return_if_fail(rdata->sent_updates);
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1089
33326
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1090 rdata->pending_updates = g_list_concat(rdata->pending_updates,
dbcdbdf2f02b Gadu-Gadu: roster - tidying
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33325
diff changeset
1091 rdata->sent_updates);
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1092 rdata->sent_updates = NULL;
35356
3a71df246d07 Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34999
diff changeset
1093
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1094 ggp_roster_content_free(rdata->content);
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1095 rdata->content = NULL;
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1096 ggp_roster_request_update(gc);
33315
42bbe5b85df8 Gadu-Gadu: roster - uploading/synchronization - part1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33314
diff changeset
1097 }
33318
636bfc28f2cf Gadu-Gadu: roster - finally working
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33317
diff changeset
1098
33325
63bf52ec9e1e Gadu-Gadu: roster - tidying. Fixes #9463
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33324
diff changeset
1099 /******************************************************************************/

mercurial