libpurple/protocols/gg/roster.c

Fri, 17 Aug 2012 11:00:00 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Fri, 17 Aug 2012 11:00:00 +0200
branch
soc.2012.gg
changeset 33340
5f00ed891179
parent 33326
dbcdbdf2f02b
child 33348
2394cd23ce8f
permissions
-rw-r--r--

Gadu-Gadu: status refactoring - done

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

mercurial