annotate src/protocols/gg/buddylist.c @ 13160:1b48f0ec55e9

[gaim-migrate @ 15523] It seems more correct to work in locale format for struct tm. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 07 Feb 2006 16:29:25 +0000
parents 8724718d387f
children 41747a38a1a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
1 /**
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
2 * @file buddylist.c
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
3 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
4 * gaim
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
5 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
6 * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us>
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
7 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
12 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
17 *
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
21 */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
22
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
23
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
24 #include "lib/libgadu.h"
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
25
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
26 #include "gg.h"
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
27 #include "utils.h"
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
28 #include "buddylist.h"
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
29
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
30
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
31 /* void ggp_buddylist_send(GaimConnection *gc) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
32 void ggp_buddylist_send(GaimConnection *gc)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
33 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
34 GGPInfo *info = gc->proto_data;
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
35 GaimAccount *account = gaim_connection_get_account(gc);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
36
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
37 GaimBuddyList *blist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
38 GaimBlistNode *gnode, *cnode, *bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
39 GaimBuddy *buddy;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
40 uin_t *userlist = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
41 gchar *types = NULL;
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
42 int size = 0;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
43
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
44 if ((blist = gaim_get_blist()) == NULL)
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
45 return;
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
46
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
47 for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
48 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
49 continue;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
50
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
51 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) {
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
52 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
53 continue;
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
54
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
55 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
56 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
57 continue;
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
58
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
59 buddy = (GaimBuddy *)bnode;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
60
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
61 if (buddy->account != account)
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
62 continue;
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
63
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
64 size++;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
65 userlist = (uin_t *) g_renew(uin_t, userlist, size);
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
66 types = (gchar *) g_renew(gchar, types, size);
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
67 userlist[size - 1] = ggp_str_to_uin(buddy->name);
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
68 types[size - 1] = GG_USER_NORMAL;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
69 gaim_debug_info("gg", "ggp_buddylist_send: adding %d\n",
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
70 userlist[size - 1]);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
71 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
72 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
73 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
74
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
75 if (userlist) {
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
76 int ret = gg_notify_ex(info->session, userlist, types, size);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
77 g_free(userlist);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
78 g_free(types);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
79
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
80 gaim_debug_info("gg", "send: ret=%d; size=%d\n", ret, size);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
81 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
82 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
83 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
84
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
85 /* void ggp_buddylist_load(GaimConnection *gc, char *buddylist) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
86 void ggp_buddylist_load(GaimConnection *gc, char *buddylist)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
87 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
88 GaimBuddy *buddy;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
89 GaimGroup *group;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
90 gchar **users_tbl;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
91 int i;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
92
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
93 /*
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
94 * XXX: Limit of entries in a buddylist that will be imported.
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
95 */
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
96 users_tbl = g_strsplit(buddylist, "\r\n", 200);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
97
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
98 for (i = 0; users_tbl[i] != NULL; i++) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
99 gchar **data_tbl;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
100 gchar *name, *show, *g;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
101
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
102 if (strlen(users_tbl[i]) == 0)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
103 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
104
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
105 data_tbl = g_strsplit(users_tbl[i], ";", 8);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
106
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
107 show = charset_convert(data_tbl[3], "CP1250", "UTF-8");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
108 name = data_tbl[6];
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
109
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
110 gaim_debug_info("gg", "got buddy: name=%s show=%s\n", name, show);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
111
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
112 if (gaim_find_buddy(gaim_connection_get_account(gc), name)) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
113 g_free(show);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
114 g_strfreev(data_tbl);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
115 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
116 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
117
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
118 g = g_strdup("Gadu-Gadu");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
119
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
120 if (strlen(data_tbl[5])) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
121 /* Hard limit to at most 50 groups */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
122 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 50);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
123 if (strlen(group_tbl[0]) > 0) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
124 g_free(g);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
125 g = g_strdup(group_tbl[0]);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
126 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
127 g_strfreev(group_tbl);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
128 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
129
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
130 buddy = gaim_buddy_new(gaim_connection_get_account(gc), name,
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
131 strlen(show) ? show : NULL);
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
132
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
133 if (!(group = gaim_find_group(g))) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
134 group = gaim_group_new(g);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
135 gaim_blist_add_group(group, NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
136 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
137
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
138 gaim_blist_add_buddy(buddy, NULL, group, NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
139 g_free(g);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
140
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
141 g_free(show);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
142 g_strfreev(data_tbl);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
143 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
144 g_strfreev(users_tbl);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
145
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
146 ggp_buddylist_send(gc);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
147
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
148 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
149 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
150
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
151 /* void ggp_buddylist_offline(GaimConnection *gc) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
152 void ggp_buddylist_offline(GaimConnection *gc)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
153 {
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
154 GaimAccount *account = gaim_connection_get_account(gc);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
155 GaimBuddyList *blist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
156 GaimBlistNode *gnode, *cnode, *bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
157 GaimBuddy *buddy;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
158
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
159 if ((blist = gaim_get_blist()) == NULL)
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
160 return;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
161
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
162 for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
163 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
164 continue;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
165
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
166 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) {
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
167 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
168 continue;
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
169
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
170 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
171 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
172 continue;
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
173
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
174 buddy = (GaimBuddy *)bnode;
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
175
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
176 if (buddy->account != account)
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
177 continue;
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
178
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
179 gaim_prpl_got_user_status(
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
180 gaim_connection_get_account(gc),
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
181 buddy->name, "offline", NULL);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
182
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
183 gaim_debug_info("gg",
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
184 "ggp_buddylist_offline: gone: %s\n",
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
185 buddy->name);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
186 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
187 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
188 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
189 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
190 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
191
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
192 /* char *ggp_buddylist_dump(GaimAccount *account) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
193 char *ggp_buddylist_dump(GaimAccount *account)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
194 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
195 GaimBuddyList *blist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
196 GaimBlistNode *gnode, *cnode, *bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
197 GaimGroup *group;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
198 GaimBuddy *buddy;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
199
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
200 char *buddylist = g_strdup("");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
201 char *ptr;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
202
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
203 if ((blist = gaim_get_blist()) == NULL)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
204 return NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
205
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
206 for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
207 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
208 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
209
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
210 group = (GaimGroup *)gnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
211
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
212 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
213 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
214 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
215
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
216 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
217 gchar *newdata, *name, *alias, *gname;
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
218 gchar *cp_alias, *cp_gname;
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
219
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
220 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
221 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
222
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
223 buddy = (GaimBuddy *)bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
224 if (buddy->account != account)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
225 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
226
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
227 name = buddy->name;
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
228 alias = buddy->alias ? buddy->alias : buddy->name;
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
229 gname = group->name;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
230
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
231 cp_gname = charset_convert(gname, "UTF-8", "CP1250");
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
232 cp_alias = charset_convert(alias, "UTF-8", "CP1250");
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
233 newdata = g_strdup_printf(
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
234 "%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
235 cp_alias, cp_alias, cp_alias, cp_alias,
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
236 "", cp_gname, name, "", "");
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
237
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
238 ptr = buddylist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
239 buddylist = g_strconcat(ptr, newdata, NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
240
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
241 g_free(newdata);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
242 g_free(ptr);
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
243 g_free(cp_gname);
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
244 g_free(cp_alias);
11414
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
245 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
246 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
247 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
248
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
249 return buddylist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
250 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
251 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
252
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
253
12007
8724718d387f [gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11414
diff changeset
254 /* vim: set ts=8 sts=0 sw=8 noet: */