annotate src/protocols/gg/buddylist.c @ 11414:d5599677bf32

[gaim-migrate @ 13651] Code split. committer: Tailor Script <tailor@pidgin.im>
author Bartoz Oler <bartosz@pidgin.im>
date Thu, 01 Sep 2005 20:05:01 +0000
parents
children 8724718d387f
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;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
35
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
36 GaimBuddyList *blist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
37 GaimBlistNode *gnode, *cnode, *bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
38 GaimBuddy *buddy;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
39 uin_t *userlist = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
40 gchar *types = NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
41 int userlist_size = 0;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
42
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
43 if ((blist = gaim_get_blist()) != NULL)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
44 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
45 for (gnode = blist->root; gnode != NULL; gnode = gnode->next)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
46 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
47 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
48 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
49 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
50 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
51 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
52 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
53 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
54 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
55 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
56 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
57 buddy = (GaimBuddy *)bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
58
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
59 if (buddy->account != gc->account)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
60 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
61
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
62 userlist_size++;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
63 userlist = (uin_t *) g_renew(uin_t, userlist, userlist_size);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
64 types = (gchar *) g_renew(gchar, types, userlist_size);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
65 userlist[userlist_size - 1] = ggp_str_to_uin(buddy->name);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
66 types[userlist_size - 1] = GG_USER_NORMAL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
67 gaim_debug_info("gg", "ggp_buddylist_send: adding %d\n", userlist[userlist_size - 1]);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
68 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
69 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
70 }
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 if (userlist) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
74 int ret = gg_notify_ex(info->session, userlist, types, userlist_size);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
75 g_free(userlist);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
76 g_free(types);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
77
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
78 gaim_debug_info("gg", "send: ret=%d; size=%d\n", ret, userlist_size);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
79 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
80 }
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 /* void ggp_buddylist_load(GaimConnection *gc, char *buddylist) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
84 void ggp_buddylist_load(GaimConnection *gc, char *buddylist)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
85 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
86 GaimBuddy *buddy;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
87 GaimGroup *group;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
88 gchar **users_tbl;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
89 int i;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
90
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
91 users_tbl = g_strsplit(buddylist, "\r\n", 200);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
92
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
93 for (i = 0; users_tbl[i] != NULL; i++) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
94 gchar **data_tbl;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
95 gchar *name, *show, *g;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
96
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
97 if (strlen(users_tbl[i]) == 0)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
98 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
99
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
100 data_tbl = g_strsplit(users_tbl[i], ";", 8);
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 show = charset_convert(data_tbl[3], "CP1250", "UTF-8");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
103 name = data_tbl[6];
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 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
106
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
107 if (gaim_find_buddy(gaim_connection_get_account(gc), name)) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
108 g_free(show);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
109 g_strfreev(data_tbl);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
110 continue;
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
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
113 g = g_strdup("Gadu-Gadu");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
114
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
115 if (strlen(data_tbl[5])) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
116 /* Hard limit to at most 50 groups */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
117 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 50);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
118 if (strlen(group_tbl[0]) > 0) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
119 g_free(g);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
120 g = g_strdup(group_tbl[0]);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
121 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
122 g_strfreev(group_tbl);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
123 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
124
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
125 buddy = gaim_buddy_new(gaim_connection_get_account(gc), name, strlen(show) ? show : NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
126 if (!(group = gaim_find_group(g))) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
127 group = gaim_group_new(g);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
128 gaim_blist_add_group(group, NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
129 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
130
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
131 gaim_blist_add_buddy(buddy, NULL, group, NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
132 g_free(g);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
133
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
134 g_free(show);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
135 g_strfreev(data_tbl);
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 g_strfreev(users_tbl);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
138
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
139 ggp_buddylist_send(gc);
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 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
142 /* }}} */
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 /* void ggp_buddylist_offline(GaimConnection *gc) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
145 void ggp_buddylist_offline(GaimConnection *gc)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
146 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
147 GaimBuddyList *blist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
148 GaimBlistNode *gnode, *cnode, *bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
149 GaimBuddy *buddy;
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 if ((blist = gaim_get_blist()) != NULL)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
152 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
153 for (gnode = blist->root; gnode != NULL; gnode = gnode->next)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
154 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
155 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
156 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
157 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
158 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
159 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
160 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
161 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
162 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
163 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
164 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
165
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
166 buddy = (GaimBuddy *)bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
167
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
168 if (buddy->account != gc->account)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
169 continue;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
170
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
171 gaim_prpl_got_user_status(
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
172 gaim_connection_get_account(gc),
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
173 buddy->name, "offline", NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
174 gaim_debug_info("gg", "ggp_buddylist_offline: gone: %s\n", buddy->name);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
175 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
176 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
177 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
178 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
179 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
180 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
181
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
182 /* char *ggp_buddylist_dump(GaimAccount *account) {{{ */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
183 char *ggp_buddylist_dump(GaimAccount *account)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
184 {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
185 GaimBuddyList *blist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
186 GaimBlistNode *gnode, *cnode, *bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
187 GaimGroup *group;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
188 GaimBuddy *buddy;
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 char *buddylist = g_strdup("");
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
191 char *ptr;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
192
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
193 if ((blist = gaim_get_blist()) == NULL)
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
194 return NULL;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
195
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
196 for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
197 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
198 continue;
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 group = (GaimGroup *)gnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
201
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
202 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
203 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
204 continue;
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 (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
207 gchar *newdata, *name, *show, *gname;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
208
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
209 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
210 continue;
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 buddy = (GaimBuddy *)bnode;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
213 if (buddy->account != account)
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 name = buddy->name;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
217 show = buddy->alias ? buddy->alias : buddy->name;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
218 gname = group->name;
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 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
221 show, show, show, show, "", gname, name, "", "");
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 ptr = buddylist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
224 buddylist = g_strconcat(ptr, newdata, NULL);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
225
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
226 g_free(newdata);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
227 g_free(ptr);
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
228 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
229 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
230 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
231
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
232 return buddylist;
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
233 }
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
234 /* }}} */
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
235
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
236
d5599677bf32 [gaim-migrate @ 13651]
Bartoz Oler <bartosz@pidgin.im>
parents:
diff changeset
237 /* vim: set ts=4 sts=0 sw=4 noet: */