Mercurial > pidgin
annotate src/blist.c @ 6641:c3a50a8ba85e
[gaim-migrate @ 7166]
Fixed a problem where pouncing two users with the same name appeared in the
same conversation window, and other related problems. Thanks Robot101.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 28 Aug 2003 01:30:42 +0000 |
parents | 314111e7b601 |
children | 0c5637b5462e |
rev | line source |
---|---|
5228 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 2003, Sean Egan <sean.egan@binghamton.edu> | |
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
22 #include "internal.h" |
5228 | 23 #include "blist.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
24 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
25 #include "debug.h" |
6034 | 26 #include "multi.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
27 #include "notify.h" |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
28 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
29 #include "privacy.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
30 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
31 #include "server.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
32 #include "signals.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
33 #include "util.h" |
5228 | 34 |
35 #define PATHSIZE 1024 | |
36 | |
37 struct gaim_buddy_list *gaimbuddylist = NULL; | |
38 static struct gaim_blist_ui_ops *blist_ui_ops = NULL; | |
39 | |
40 /***************************************************************************** | |
41 * Private Utility functions * | |
42 *****************************************************************************/ | |
43 static GaimBlistNode *gaim_blist_get_last_sibling(GaimBlistNode *node) | |
44 { | |
45 GaimBlistNode *n = node; | |
46 if (!n) | |
47 return NULL; | |
48 while (n->next) | |
49 n = n->next; | |
50 return n; | |
51 } | |
52 static GaimBlistNode *gaim_blist_get_last_child(GaimBlistNode *node) | |
53 { | |
54 if (!node) | |
55 return NULL; | |
56 return gaim_blist_get_last_sibling(node->child); | |
57 } | |
58 | |
5247 | 59 struct _gaim_hbuddy { |
60 char *name; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
61 GaimAccount *account; |
5758 | 62 GaimBlistNode *group; |
5247 | 63 }; |
64 | |
65 static guint _gaim_blist_hbuddy_hash (struct _gaim_hbuddy *hb) | |
66 { | |
67 return g_str_hash(hb->name); | |
68 } | |
69 | |
70 static guint _gaim_blist_hbuddy_equal (struct _gaim_hbuddy *hb1, struct _gaim_hbuddy *hb2) | |
71 { | |
5758 | 72 return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group); |
5247 | 73 } |
74 | |
6006 | 75 static void blist_pref_cb(const char *name, GaimPrefType typ, gpointer value, gpointer data) |
76 { | |
6012 | 77 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
78 GaimBlistNode *group, *buddy; | |
79 | |
80 if (!ops) | |
81 return; | |
82 | |
83 for(group = gaimbuddylist->root; group; group = group->next) { | |
84 if(!GAIM_BLIST_NODE_IS_GROUP(group)) | |
85 continue; | |
86 for(buddy = group->child; buddy; buddy = buddy->next) { | |
87 if(!GAIM_BLIST_NODE_IS_BUDDY(buddy)) | |
88 continue; | |
89 ops->update(gaimbuddylist, buddy); | |
90 } | |
91 } | |
6006 | 92 } |
93 | |
5228 | 94 /***************************************************************************** |
95 * Public API functions * | |
96 *****************************************************************************/ | |
97 | |
98 struct gaim_buddy_list *gaim_blist_new() | |
99 { | |
100 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1); | |
101 | |
102 gbl->ui_ops = gaim_get_blist_ui_ops(); | |
103 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
104 gbl->buddies = g_hash_table_new ((GHashFunc)_gaim_blist_hbuddy_hash, |
5247 | 105 (GEqualFunc)_gaim_blist_hbuddy_equal); |
106 | |
5228 | 107 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL) |
108 gbl->ui_ops->new_list(gbl); | |
109 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
110 gaim_prefs_connect_callback("/core/buddies/use_server_alias", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
111 blist_pref_cb, NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
112 |
6006 | 113 |
5228 | 114 return gbl; |
115 } | |
116 | |
117 void | |
118 gaim_set_blist(struct gaim_buddy_list *list) | |
119 { | |
120 gaimbuddylist = list; | |
121 } | |
122 | |
123 struct gaim_buddy_list * | |
124 gaim_get_blist(void) | |
125 { | |
126 return gaimbuddylist; | |
127 } | |
128 | |
129 void gaim_blist_show () | |
130 { | |
131 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
132 if (ops) | |
133 ops->show(gaimbuddylist); | |
134 } | |
135 | |
136 void gaim_blist_destroy() | |
137 { | |
138 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
139 if (ops) | |
140 ops->destroy(gaimbuddylist); | |
141 } | |
142 | |
143 void gaim_blist_set_visible (gboolean show) | |
144 { | |
145 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
146 if (ops) | |
147 ops->set_visible(gaimbuddylist, show); | |
148 } | |
149 | |
150 void gaim_blist_update_buddy_status (struct buddy *buddy, int status) | |
151 { | |
5266
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
152 struct gaim_blist_ui_ops *ops; |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
153 |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
154 if (buddy->uc == status) |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
155 return; |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
156 |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
157 ops = gaimbuddylist->ui_ops; |
5228 | 158 |
5305 | 159 if((status & UC_UNAVAILABLE) != (buddy->uc & UC_UNAVAILABLE)) { |
160 if(status & UC_UNAVAILABLE) | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
161 gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); |
5305 | 162 else |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
163 gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); |
5305 | 164 } |
5228 | 165 |
5305 | 166 buddy->uc = status; |
5228 | 167 if (ops) |
168 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
169 } | |
170 | |
171 static gboolean presence_update_timeout_cb(struct buddy *buddy) { | |
172 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
173 GaimConversation *conv; |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
174 |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
175 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
5228 | 176 |
177 if(buddy->present == GAIM_BUDDY_SIGNING_ON) { | |
178 buddy->present = GAIM_BUDDY_ONLINE; | |
179 } else if(buddy->present == GAIM_BUDDY_SIGNING_OFF) { | |
180 buddy->present = GAIM_BUDDY_OFFLINE; | |
181 } | |
182 | |
183 buddy->timer = 0; | |
184 | |
185 if (ops) | |
186 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
187 | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
188 if (conv) { |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
189 if (buddy->present == GAIM_BUDDY_ONLINE) |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
190 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
191 else if (buddy->present == GAIM_BUDDY_OFFLINE) |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
192 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_OFFLINE); |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
193 } |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
194 |
5228 | 195 return FALSE; |
196 } | |
197 | |
198 void gaim_blist_update_buddy_presence(struct buddy *buddy, int presence) { | |
199 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
200 gboolean do_timer = FALSE; | |
201 | |
202 if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) { | |
203 buddy->present = GAIM_BUDDY_SIGNING_ON; | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
204 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy); |
5228 | 205 do_timer = TRUE; |
5277 | 206 ((struct group *)((GaimBlistNode *)buddy)->parent)->online++; |
5228 | 207 } else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) { |
208 buddy->present = GAIM_BUDDY_SIGNING_OFF; | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
209 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy); |
5228 | 210 do_timer = TRUE; |
5394 | 211 ((struct group *)((GaimBlistNode *)buddy)->parent)->online--; |
5228 | 212 } |
213 | |
214 if(do_timer) { | |
215 if(buddy->timer > 0) | |
216 g_source_remove(buddy->timer); | |
217 buddy->timer = g_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); | |
218 } | |
219 | |
220 if (ops) | |
221 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
222 } | |
223 | |
224 | |
225 void gaim_blist_update_buddy_idle (struct buddy *buddy, int idle) | |
226 { | |
227 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
228 buddy->idle = idle; | |
229 if (ops) | |
230 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
231 } | |
232 void gaim_blist_update_buddy_evil (struct buddy *buddy, int warning) | |
233 { | |
234 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
235 buddy->evil = warning; | |
236 if (ops) | |
237 ops->update(gaimbuddylist,(GaimBlistNode*)buddy); | |
238 } | |
239 void gaim_blist_update_buddy_icon(struct buddy *buddy) { | |
240 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
241 if(ops) | |
242 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
243 } | |
244 void gaim_blist_rename_buddy (struct buddy *buddy, const char *name) | |
245 { | |
246 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
5634 | 247 g_free(buddy->name); |
5228 | 248 buddy->name = g_strdup(name); |
249 if (ops) | |
250 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
251 } | |
5234 | 252 |
253 void gaim_blist_alias_chat(struct chat *chat, const char *alias) | |
254 { | |
255 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
256 | |
5237 | 257 g_free(chat->alias); |
5234 | 258 |
5237 | 259 if(alias && strlen(alias)) |
260 chat->alias = g_strdup(alias); | |
261 else | |
262 chat->alias = NULL; | |
263 | |
5234 | 264 if(ops) |
265 ops->update(gaimbuddylist, (GaimBlistNode*)chat); | |
266 } | |
267 | |
5228 | 268 void gaim_blist_alias_buddy (struct buddy *buddy, const char *alias) |
269 { | |
270 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5634
diff
changeset
|
271 GaimConversation *conv; |
5228 | 272 |
273 g_free(buddy->alias); | |
274 | |
275 if(alias && strlen(alias)) | |
276 buddy->alias = g_strdup(alias); | |
277 else | |
278 buddy->alias = NULL; | |
279 | |
280 if (ops) | |
281 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
282 | |
283 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); | |
284 | |
285 if (conv) | |
286 gaim_conversation_autoset_title(conv); | |
287 } | |
288 | |
6058 | 289 void gaim_blist_server_alias_buddy (struct buddy *buddy, const char *alias) |
290 { | |
291 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
292 GaimConversation *conv; | |
293 | |
294 g_free(buddy->server_alias); | |
295 | |
296 if(alias && strlen(alias) && g_utf8_validate(alias, -1, NULL)) | |
297 buddy->server_alias = g_strdup(alias); | |
298 else | |
299 buddy->server_alias = NULL; | |
300 | |
301 if (ops) | |
302 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
303 | |
304 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); | |
305 | |
306 if (conv) | |
307 gaim_conversation_autoset_title(conv); | |
308 } | |
309 | |
5228 | 310 void gaim_blist_rename_group(struct group *group, const char *name) |
311 { | |
312 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
5346 | 313 struct group *dest_group; |
314 GaimBlistNode *prev, *child, *next; | |
315 GSList *accts; | |
316 | |
317 if(!name || !strlen(name) || !strcmp(name, group->name)) { | |
318 /* nothing to do here */ | |
319 return; | |
320 } else if((dest_group = gaim_find_group(name))) { | |
321 /* here we're merging two groups */ | |
322 prev = gaim_blist_get_last_child((GaimBlistNode*)dest_group); | |
323 child = ((GaimBlistNode*)group)->child; | |
324 | |
325 while(child) | |
326 { | |
327 next = child->next; | |
328 if(GAIM_BLIST_NODE_IS_BUDDY(child)) { | |
329 gaim_blist_add_buddy((struct buddy *)child, dest_group, prev); | |
330 prev = child; | |
331 } else if(GAIM_BLIST_NODE_IS_CHAT(child)) { | |
332 gaim_blist_add_chat((struct chat *)child, dest_group, prev); | |
333 prev = child; | |
334 } else { | |
335 gaim_debug(GAIM_DEBUG_ERROR, "blist", | |
336 "Unknown child type in group %s\n", group->name); | |
337 } | |
338 child = next; | |
339 } | |
340 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
341 GaimAccount *account = accts->data; |
5346 | 342 serv_rename_group(account->gc, group, name); |
343 } | |
344 gaim_blist_remove_group(group); | |
345 } else { | |
346 /* a simple rename */ | |
347 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
348 GaimAccount *account = accts->data; |
5346 | 349 serv_rename_group(account->gc, group, name); |
350 } | |
351 g_free(group->name); | |
352 group->name = g_strdup(name); | |
353 if (ops) | |
354 ops->update(gaimbuddylist, (GaimBlistNode*)group); | |
355 } | |
5228 | 356 } |
5234 | 357 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
358 struct chat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components) |
5234 | 359 { |
360 struct chat *chat; | |
361 struct gaim_blist_ui_ops *ops; | |
362 | |
5237 | 363 if(!components) |
5234 | 364 return NULL; |
365 | |
366 chat = g_new0(struct chat, 1); | |
367 chat->account = account; | |
5237 | 368 if(alias && strlen(alias)) |
369 chat->alias = g_strdup(alias); | |
5234 | 370 chat->components = components; |
5906 | 371 chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
372 g_free, g_free); | |
5234 | 373 |
374 ((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE; | |
375 | |
376 ops = gaim_get_blist_ui_ops(); | |
377 | |
378 if (ops != NULL && ops->new_node != NULL) | |
379 ops->new_node((GaimBlistNode *)chat); | |
380 | |
381 return chat; | |
382 } | |
383 | |
6036 | 384 char *gaim_chat_get_display_name(struct chat *chat) |
6034 | 385 { |
386 char *name; | |
387 | |
388 if(chat->alias){ | |
389 name = g_strdup(chat->alias); | |
390 } | |
391 else{ | |
392 GList *parts; | |
393 GaimPlugin *prpl; | |
394 GaimPluginProtocolInfo *prpl_info; | |
395 struct proto_chat_entry *pce; | |
396 | |
397 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); | |
398 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
399 | |
400 parts = prpl_info->chat_info(chat->account->gc); | |
401 | |
402 pce = parts->data; | |
403 name = g_markup_escape_text(g_hash_table_lookup(chat->components, | |
404 pce->identifier), -1); | |
405 g_list_free(parts); | |
406 } | |
407 | |
408 return name; | |
409 } | |
410 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
411 struct buddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias) |
5228 | 412 { |
413 struct buddy *b; | |
414 struct gaim_blist_ui_ops *ops; | |
415 | |
416 b = g_new0(struct buddy, 1); | |
417 b->account = account; | |
418 b->name = g_strdup(screenname); | |
419 b->alias = g_strdup(alias); | |
420 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
421 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE; | |
422 | |
423 ops = gaim_get_blist_ui_ops(); | |
424 | |
425 if (ops != NULL && ops->new_node != NULL) | |
426 ops->new_node((GaimBlistNode *)b); | |
427 | |
428 return b; | |
429 } | |
5634 | 430 |
5234 | 431 void gaim_blist_add_chat(struct chat *chat, struct group *group, GaimBlistNode *node) |
432 { | |
433 GaimBlistNode *n = node, *cnode = (GaimBlistNode*)chat; | |
434 struct group *g = group; | |
435 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
436 gboolean save = FALSE; | |
437 | |
438 if (!n) { | |
439 if (!g) { | |
440 g = gaim_group_new(_("Chats")); | |
5634 | 441 gaim_blist_add_group(g, |
442 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5234 | 443 } |
444 } else { | |
445 g = (struct group*)n->parent; | |
446 } | |
447 | |
448 /* if we're moving to overtop of ourselves, do nothing */ | |
449 if(cnode == n) | |
450 return; | |
451 | |
452 if (cnode->parent) { | |
453 /* This chat was already in the list and is | |
454 * being moved. | |
455 */ | |
5277 | 456 ((struct group *)cnode->parent)->totalsize--; |
5855 | 457 if (gaim_account_is_connected(chat->account)) { |
5287 | 458 ((struct group *)cnode->parent)->online--; |
5277 | 459 ((struct group *)cnode->parent)->currentsize--; |
5287 | 460 } |
5234 | 461 if(cnode->next) |
462 cnode->next->prev = cnode->prev; | |
463 if(cnode->prev) | |
464 cnode->prev->next = cnode->next; | |
465 if(cnode->parent->child == cnode) | |
466 cnode->parent->child = cnode->next; | |
467 | |
468 ops->remove(gaimbuddylist, cnode); | |
469 | |
470 save = TRUE; | |
471 } | |
472 | |
473 if (n) { | |
474 if(n->next) | |
475 n->next->prev = cnode; | |
476 cnode->next = n->next; | |
477 cnode->prev = n; | |
478 cnode->parent = n->parent; | |
479 n->next = cnode; | |
5277 | 480 ((struct group *)n->parent)->totalsize++; |
5855 | 481 if (gaim_account_is_connected(chat->account)) { |
5287 | 482 ((struct group *)n->parent)->online++; |
5277 | 483 ((struct group *)n->parent)->currentsize++; |
5287 | 484 } |
5234 | 485 } else { |
5634 | 486 if(((GaimBlistNode*)g)->child) |
487 ((GaimBlistNode*)g)->child->prev = cnode; | |
488 cnode->next = ((GaimBlistNode*)g)->child; | |
489 cnode->prev = NULL; | |
5234 | 490 ((GaimBlistNode*)g)->child = cnode; |
491 cnode->parent = (GaimBlistNode*)g; | |
5277 | 492 g->totalsize++; |
5855 | 493 if (gaim_account_is_connected(chat->account)) { |
5287 | 494 g->online++; |
5277 | 495 g->currentsize++; |
5287 | 496 } |
5234 | 497 } |
498 | |
499 if (ops) | |
500 ops->update(gaimbuddylist, (GaimBlistNode*)cnode); | |
501 if (save) | |
502 gaim_blist_save(); | |
503 } | |
504 | |
5228 | 505 void gaim_blist_add_buddy (struct buddy *buddy, struct group *group, GaimBlistNode *node) |
506 { | |
507 GaimBlistNode *n = node, *bnode = (GaimBlistNode*)buddy; | |
508 struct group *g = group; | |
509 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
5247 | 510 struct _gaim_hbuddy *hb; |
5228 | 511 gboolean save = FALSE; |
512 | |
513 if (!n) { | |
514 if (!g) { | |
515 g = gaim_group_new(_("Buddies")); | |
5634 | 516 gaim_blist_add_group(g, |
517 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5228 | 518 } |
519 } else { | |
520 g = (struct group*)n->parent; | |
521 } | |
522 | |
523 /* if we're moving to overtop of ourselves, do nothing */ | |
524 if(bnode == n) | |
525 return; | |
526 | |
527 if (bnode->parent) { | |
528 /* This buddy was already in the list and is | |
529 * being moved. | |
530 */ | |
5394 | 531 ((struct group *)bnode->parent)->totalsize--; |
5855 | 532 if (gaim_account_is_connected(buddy->account)) |
5277 | 533 ((struct group *)bnode->parent)->currentsize--; |
5394 | 534 if (GAIM_BUDDY_IS_ONLINE(buddy)) |
5313 | 535 ((struct group *)bnode->parent)->online--; |
5277 | 536 |
5228 | 537 if(bnode->next) |
538 bnode->next->prev = bnode->prev; | |
539 if(bnode->prev) | |
540 bnode->prev->next = bnode->next; | |
541 if(bnode->parent->child == bnode) | |
542 bnode->parent->child = bnode->next; | |
543 | |
544 ops->remove(gaimbuddylist, bnode); | |
545 | |
5277 | 546 if (bnode->parent != ((GaimBlistNode*)g)) { |
5228 | 547 serv_move_buddy(buddy, (struct group*)bnode->parent, g); |
5277 | 548 } |
5228 | 549 save = TRUE; |
550 } | |
551 | |
552 if (n) { | |
553 if(n->next) | |
554 n->next->prev = (GaimBlistNode*)buddy; | |
555 ((GaimBlistNode*)buddy)->next = n->next; | |
556 ((GaimBlistNode*)buddy)->prev = n; | |
557 ((GaimBlistNode*)buddy)->parent = n->parent; | |
558 n->next = (GaimBlistNode*)buddy; | |
5277 | 559 ((struct group *)n->parent)->totalsize++; |
5855 | 560 if (gaim_account_is_connected(buddy->account)) |
5277 | 561 ((struct group *)n->parent)->currentsize++; |
5394 | 562 if (GAIM_BUDDY_IS_ONLINE(buddy)) |
5313 | 563 ((struct group *)n->parent)->online++; |
5228 | 564 } else { |
5634 | 565 if(((GaimBlistNode*)g)->child) |
566 ((GaimBlistNode*)g)->child->prev = (GaimBlistNode*)buddy; | |
567 ((GaimBlistNode*)buddy)->prev = NULL; | |
568 ((GaimBlistNode*)buddy)->next = ((GaimBlistNode*)g)->child; | |
5228 | 569 ((GaimBlistNode*)g)->child = (GaimBlistNode*)buddy; |
570 ((GaimBlistNode*)buddy)->parent = (GaimBlistNode*)g; | |
5277 | 571 g->totalsize++; |
5855 | 572 if (gaim_account_is_connected(buddy->account)) |
5277 | 573 g->currentsize++; |
5394 | 574 if (GAIM_BUDDY_IS_ONLINE(buddy)) |
5313 | 575 g->online++; |
5228 | 576 } |
577 | |
5247 | 578 hb = g_malloc(sizeof(struct _gaim_hbuddy)); |
579 hb->name = g_strdup(normalize(buddy->name)); | |
580 hb->account = buddy->account; | |
5758 | 581 hb->group = ((GaimBlistNode*)buddy)->parent; |
5247 | 582 |
583 if (g_hash_table_lookup(gaimbuddylist->buddies, (gpointer)hb)) { | |
584 /* This guy already exists */ | |
585 g_free(hb->name); | |
586 g_free(hb); | |
587 } else { | |
588 g_hash_table_insert(gaimbuddylist->buddies, (gpointer)hb, (gpointer)buddy); | |
589 } | |
590 | |
5228 | 591 if (ops) |
592 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
593 if (save) | |
594 gaim_blist_save(); | |
595 } | |
596 | |
597 struct group *gaim_group_new(const char *name) | |
598 { | |
599 struct group *g = gaim_find_group(name); | |
600 | |
601 if (!g) { | |
602 struct gaim_blist_ui_ops *ops; | |
603 g= g_new0(struct group, 1); | |
604 g->name = g_strdup(name); | |
5277 | 605 g->totalsize = 0; |
606 g->currentsize = 0; | |
607 g->online = 0; | |
5228 | 608 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
609 g_free, g_free); | |
610 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE; | |
611 | |
612 ops = gaim_get_blist_ui_ops(); | |
613 | |
614 if (ops != NULL && ops->new_node != NULL) | |
615 ops->new_node((GaimBlistNode *)g); | |
616 | |
617 } | |
618 return g; | |
619 } | |
620 | |
621 void gaim_blist_add_group (struct group *group, GaimBlistNode *node) | |
622 { | |
623 struct gaim_blist_ui_ops *ops; | |
624 GaimBlistNode *gnode = (GaimBlistNode*)group; | |
625 gboolean save = FALSE; | |
626 | |
627 if (!gaimbuddylist) | |
628 gaimbuddylist = gaim_blist_new(); | |
629 ops = gaimbuddylist->ui_ops; | |
630 | |
631 if (!gaimbuddylist->root) { | |
632 gaimbuddylist->root = gnode; | |
633 return; | |
634 } | |
635 | |
636 /* if we're moving to overtop of ourselves, do nothing */ | |
637 if(gnode == node) | |
638 return; | |
639 | |
640 if (gaim_find_group(group->name)) { | |
641 /* This is just being moved */ | |
642 | |
643 ops->remove(gaimbuddylist, (GaimBlistNode*)group); | |
644 | |
645 if(gnode == gaimbuddylist->root) | |
646 gaimbuddylist->root = gnode->next; | |
647 if(gnode->prev) | |
648 gnode->prev->next = gnode->next; | |
649 if(gnode->next) | |
650 gnode->next->prev = gnode->prev; | |
651 | |
652 save = TRUE; | |
653 } | |
654 | |
5634 | 655 if (node) { |
656 gnode->next = node->next; | |
657 gnode->prev = node; | |
658 if(node->next) | |
659 node->next->prev = gnode; | |
660 node->next = gnode; | |
661 } else { | |
662 gaimbuddylist->root->prev = gnode; | |
663 gnode->next = gaimbuddylist->root; | |
664 gnode->prev = NULL; | |
665 gaimbuddylist->root = gnode; | |
666 } | |
667 | |
5228 | 668 |
669 if (ops) { | |
670 ops->update(gaimbuddylist, gnode); | |
671 for(node = gnode->child; node; node = node->next) | |
672 ops->update(gaimbuddylist, node); | |
673 } | |
674 if (save) | |
675 gaim_blist_save(); | |
676 } | |
677 | |
678 void gaim_blist_remove_buddy (struct buddy *buddy) | |
679 { | |
680 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
681 | |
682 GaimBlistNode *gnode, *node = (GaimBlistNode*)buddy; | |
683 struct group *group; | |
5247 | 684 struct _gaim_hbuddy hb, *key; |
685 struct buddy *val; | |
5228 | 686 |
687 gnode = node->parent; | |
688 group = (struct group *)gnode; | |
689 | |
690 if(gnode->child == node) | |
691 gnode->child = node->next; | |
692 if (node->prev) | |
693 node->prev->next = node->next; | |
694 if (node->next) | |
695 node->next->prev = node->prev; | |
5394 | 696 group->totalsize--; |
5855 | 697 if (gaim_account_is_connected(buddy->account)) |
5277 | 698 group->currentsize--; |
5394 | 699 if (GAIM_BUDDY_IS_ONLINE(buddy)) |
700 group->online--; | |
5228 | 701 |
5247 | 702 hb.name = normalize(buddy->name); |
703 hb.account = buddy->account; | |
5758 | 704 hb.group = ((GaimBlistNode*)buddy)->parent; |
5247 | 705 if (g_hash_table_lookup_extended(gaimbuddylist->buddies, &hb, (gpointer *)&key, (gpointer *)&val)) { |
706 g_hash_table_remove(gaimbuddylist->buddies, &hb); | |
707 g_free(key->name); | |
708 g_free(key); | |
709 } | |
710 | |
5292 | 711 if(buddy->timer > 0) |
712 g_source_remove(buddy->timer); | |
713 | |
5228 | 714 ops->remove(gaimbuddylist, node); |
715 g_hash_table_destroy(buddy->settings); | |
716 g_free(buddy->name); | |
717 g_free(buddy->alias); | |
718 g_free(buddy); | |
719 } | |
720 | |
5234 | 721 void gaim_blist_remove_chat (struct chat *chat) |
722 { | |
723 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
724 | |
725 GaimBlistNode *gnode, *node = (GaimBlistNode*)chat; | |
726 struct group *group; | |
727 | |
728 gnode = node->parent; | |
729 group = (struct group *)gnode; | |
730 | |
731 if(gnode->child == node) | |
732 gnode->child = node->next; | |
733 if (node->prev) | |
734 node->prev->next = node->next; | |
735 if (node->next) | |
736 node->next->prev = node->prev; | |
5277 | 737 group->totalsize--; |
5855 | 738 if (gaim_account_is_connected(chat->account)) { |
5277 | 739 group->currentsize--; |
5394 | 740 group->online--; |
741 } | |
5234 | 742 |
743 ops->remove(gaimbuddylist, node); | |
744 g_hash_table_destroy(chat->components); | |
745 g_free(chat->alias); | |
746 g_free(chat); | |
747 } | |
748 | |
5228 | 749 void gaim_blist_remove_group (struct group *group) |
750 { | |
751 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
752 GaimBlistNode *node = (GaimBlistNode*)group; | |
753 | |
754 if(node->child) { | |
755 char *buf; | |
756 int count = 0; | |
757 GaimBlistNode *child = node->child; | |
758 | |
759 while(child) { | |
760 count++; | |
761 child = child->next; | |
762 } | |
763 | |
6308 | 764 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed " |
765 "because its account was not logged in." | |
766 " This buddy and the group were not " | |
767 "removed.\n", | |
768 "%d buddies from group %s were not " | |
769 "removed because their accounts were " | |
6336 | 770 "not logged in. These buddies and " |
771 "the group were not removed.\n", count), | |
6308 | 772 count, group->name); |
5541
aee0ee458974
[gaim-migrate @ 5941]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
773 gaim_notify_error(NULL, NULL, _("Group not removed"), buf); |
5228 | 774 g_free(buf); |
775 return; | |
776 } | |
777 | |
778 if(gaimbuddylist->root == node) | |
779 gaimbuddylist->root = node->next; | |
780 if (node->prev) | |
781 node->prev->next = node->next; | |
782 if (node->next) | |
783 node->next->prev = node->prev; | |
784 | |
785 ops->remove(gaimbuddylist, node); | |
786 g_free(group->name); | |
787 g_free(group); | |
788 } | |
789 | |
790 char *gaim_get_buddy_alias_only(struct buddy *b) { | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
791 if(!b) |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
792 return NULL; |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
793 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
794 if(b->alias && b->alias[0]) { |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
795 return b->alias; |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
796 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
797 else if (b->server_alias != NULL && |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
798 gaim_prefs_get_bool("/core/buddies/use_server_alias")) { |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
799 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
800 return b->server_alias; |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
801 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
802 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
803 return NULL; |
5228 | 804 } |
805 | |
806 char * gaim_get_buddy_alias (struct buddy *buddy) | |
807 { | |
808 char *ret = gaim_get_buddy_alias_only(buddy); | |
809 | |
6036 | 810 if(!ret) |
811 return buddy ? buddy->name : _("Unknown"); | |
812 | |
813 return ret; | |
5228 | 814 } |
815 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
816 struct buddy *gaim_find_buddy(GaimAccount *account, const char *name) |
5228 | 817 { |
6245 | 818 struct buddy *buddy; |
5247 | 819 struct _gaim_hbuddy hb; |
5758 | 820 GaimBlistNode *group; |
5228 | 821 |
822 if (!gaimbuddylist) | |
823 return NULL; | |
6245 | 824 |
825 if (!name) | |
5985
60d9cbfb6bf8
[gaim-migrate @ 6433]
Christian Hammond <chipx86@chipx86.com>
parents:
5947
diff
changeset
|
826 return NULL; |
5228 | 827 |
6245 | 828 hb.name = normalize(name); |
829 hb.account = account; | |
5247 | 830 |
6245 | 831 for(group = gaimbuddylist->root; group; group = group->next) { |
5758 | 832 hb.group = group; |
5776 | 833 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) |
5758 | 834 return buddy; |
835 } | |
6245 | 836 |
5758 | 837 return NULL; |
5228 | 838 } |
839 | |
6245 | 840 GSList *gaim_find_buddies(GaimAccount *account, const char *name) |
841 { | |
842 struct buddy *buddy; | |
843 struct _gaim_hbuddy hb; | |
844 GaimBlistNode *group; | |
845 GSList *ret = NULL; | |
846 | |
847 if (!gaimbuddylist) | |
848 return NULL; | |
849 | |
850 if (!name) | |
851 return NULL; | |
852 | |
853 hb.name = normalize(name); | |
854 hb.account = account; | |
855 | |
856 for(group = gaimbuddylist->root; group; group = group->next) { | |
857 hb.group = group; | |
858 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) | |
859 ret = g_slist_append(ret, buddy); | |
860 } | |
861 | |
862 return ret; | |
863 } | |
864 | |
5228 | 865 struct group *gaim_find_group(const char *name) |
866 { | |
867 GaimBlistNode *node; | |
868 if (!gaimbuddylist) | |
869 return NULL; | |
870 node = gaimbuddylist->root; | |
871 while(node) { | |
872 if (!strcmp(((struct group*)node)->name, name)) | |
873 return (struct group*)node; | |
874 node = node->next; | |
875 } | |
876 return NULL; | |
877 } | |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
878 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
879 struct chat * |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
880 gaim_blist_find_chat(GaimAccount *account, const char *name) |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
881 { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
882 char *chat_name; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
883 struct chat *chat; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
884 GaimPlugin *prpl; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
885 GaimPluginProtocolInfo *prpl_info = NULL; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
886 struct proto_chat_entry *pce; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
887 GaimBlistNode *node, *group; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
888 GList *parts; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
889 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
890 g_return_val_if_fail(gaim_get_blist() != NULL, NULL); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
891 g_return_val_if_fail(name != NULL, NULL); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
892 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
893 for (group = gaimbuddylist->root; group != NULL; group = group->next) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
894 for (node = group->child; node != NULL; node = node->next) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
895 if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
896 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
897 chat = (struct chat *)node; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
898 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
899 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
900 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
901 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
902 parts = prpl_info->chat_info( |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
903 gaim_account_get_connection(chat->account)); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
904 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
905 pce = parts->data; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
906 chat_name = g_hash_table_lookup(chat->components, |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
907 pce->identifier); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
908 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
909 if (chat->account == account && |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
910 name != NULL && !strcmp(chat_name, name)) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
911 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
912 return chat; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
913 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
914 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
915 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
916 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
917 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
918 return NULL; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
919 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
920 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
921 struct group * |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
922 gaim_blist_chat_get_group(struct chat *chat) |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
923 { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
924 g_return_val_if_fail(chat != NULL, NULL); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
925 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
926 return (struct group *)(((GaimBlistNode *)chat)->parent); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
927 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
928 |
5228 | 929 struct group *gaim_find_buddys_group(struct buddy *buddy) |
930 { | |
931 if (!buddy) | |
932 return NULL; | |
933 return (struct group*)(((GaimBlistNode*)buddy)->parent); | |
934 } | |
935 | |
936 GSList *gaim_group_get_accounts(struct group *g) | |
937 { | |
938 GSList *l = NULL; | |
939 GaimBlistNode *child = ((GaimBlistNode *)g)->child; | |
940 | |
941 while (child) { | |
6322 | 942 GaimAccount *account = NULL; |
943 if (GAIM_BLIST_NODE_IS_BUDDY(child)) | |
944 account = ((struct buddy *)child)->account; | |
945 else if (GAIM_BLIST_NODE_IS_CHAT(child)) | |
946 account = ((struct chat *)child)->account; | |
947 if (!g_slist_find(l, account)) | |
948 l = g_slist_append(l, account); | |
5228 | 949 child = child->next; |
950 } | |
951 return l; | |
952 } | |
953 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
954 void gaim_blist_add_account(GaimAccount *account) |
5234 | 955 { |
956 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
957 GaimBlistNode *group, *buddy; | |
958 | |
959 if(!gaimbuddylist) | |
960 return; | |
961 | |
962 for(group = gaimbuddylist->root; group; group = group->next) { | |
963 if(!GAIM_BLIST_NODE_IS_GROUP(group)) | |
964 continue; | |
965 for(buddy = group->child; buddy; buddy = buddy->next) { | |
966 if(GAIM_BLIST_NODE_IS_BUDDY(buddy)) { | |
967 if (account == ((struct buddy*)buddy)->account) { | |
5277 | 968 ((struct group *)group)->currentsize++; |
5234 | 969 if(ops) |
970 ops->update(gaimbuddylist, buddy); | |
971 } | |
972 } else if(GAIM_BLIST_NODE_IS_CHAT(buddy)) { | |
973 if (account == ((struct chat*)buddy)->account) { | |
5287 | 974 ((struct group *)group)->online++; |
5277 | 975 ((struct group *)group)->currentsize++; |
5234 | 976 if(ops) |
977 ops->update(gaimbuddylist, buddy); | |
978 } | |
979 } | |
980 } | |
981 } | |
982 } | |
983 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
984 void gaim_blist_remove_account(GaimAccount *account) |
5228 | 985 { |
986 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
5234 | 987 GaimBlistNode *group, *buddy; |
988 | |
5228 | 989 if (!gaimbuddylist) |
990 return; | |
5234 | 991 |
992 for(group = gaimbuddylist->root; group; group = group->next) { | |
993 if(!GAIM_BLIST_NODE_IS_GROUP(group)) | |
994 continue; | |
995 for(buddy = group->child; buddy; buddy = buddy->next) { | |
996 if(GAIM_BLIST_NODE_IS_BUDDY(buddy)) { | |
997 if (account == ((struct buddy*)buddy)->account) { | |
5394 | 998 if (GAIM_BUDDY_IS_ONLINE((struct buddy*)buddy)) |
5277 | 999 ((struct group *)group)->online--; |
5234 | 1000 ((struct buddy*)buddy)->present = GAIM_BUDDY_OFFLINE; |
5394 | 1001 ((struct group *)group)->currentsize--; |
5234 | 1002 if(ops) |
1003 ops->remove(gaimbuddylist, buddy); | |
1004 } | |
1005 } else if(GAIM_BLIST_NODE_IS_CHAT(buddy)) { | |
1006 if (account == ((struct chat*)buddy)->account) { | |
5277 | 1007 ((struct group *)group)->online--; |
1008 ((struct group *)group)->currentsize--; | |
5234 | 1009 if(ops) |
1010 ops->remove(gaimbuddylist, buddy); | |
1011 } | |
5228 | 1012 } |
1013 } | |
1014 } | |
1015 } | |
1016 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1017 void parse_toc_buddy_list(GaimAccount *account, char *config) |
5228 | 1018 { |
1019 char *c; | |
1020 char current[256]; | |
1021 GList *bud = NULL; | |
1022 | |
1023 | |
1024 if (config != NULL) { | |
1025 | |
1026 /* skip "CONFIG:" (if it exists) */ | |
1027 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ? | |
1028 strtok(config, "\n") : | |
1029 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n"); | |
1030 do { | |
1031 if (c == NULL) | |
1032 break; | |
1033 if (*c == 'g') { | |
1034 char *utf8 = NULL; | |
1035 utf8 = gaim_try_conv_to_utf8(c + 2); | |
1036 if (utf8 == NULL) { | |
1037 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); | |
1038 } else { | |
1039 g_strlcpy(current, utf8, sizeof(current)); | |
1040 g_free(utf8); | |
1041 } | |
1042 if (!gaim_find_group(current)) { | |
1043 struct group *g = gaim_group_new(current); | |
5634 | 1044 gaim_blist_add_group(g, |
1045 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5228 | 1046 } |
1047 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ | |
1048 char nm[80], sw[388], *a, *utf8 = NULL; | |
1049 | |
1050 if ((a = strchr(c + 2, ':')) != NULL) { | |
1051 *a++ = '\0'; /* nul the : */ | |
1052 } | |
1053 | |
1054 g_strlcpy(nm, c + 2, sizeof(nm)); | |
1055 if (a) { | |
1056 utf8 = gaim_try_conv_to_utf8(a); | |
1057 if (utf8 == NULL) { | |
1058 gaim_debug(GAIM_DEBUG_ERROR, "toc blist", | |
1059 "Failed to convert alias for " | |
1060 "'%s' to UTF-8\n", nm); | |
1061 } | |
1062 } | |
1063 if (utf8 == NULL) { | |
1064 sw[0] = '\0'; | |
1065 } else { | |
1066 /* This can leave a partial sequence at the end, | |
1067 * but who cares? */ | |
1068 g_strlcpy(sw, utf8, sizeof(sw)); | |
1069 g_free(utf8); | |
1070 } | |
1071 | |
1072 if (!gaim_find_buddy(account, nm)) { | |
1073 struct buddy *b = gaim_buddy_new(account, nm, sw); | |
1074 struct group *g = gaim_find_group(current); | |
5634 | 1075 gaim_blist_add_buddy(b, g, |
1076 gaim_blist_get_last_child((GaimBlistNode*)g)); | |
5228 | 1077 bud = g_list_append(bud, g_strdup(nm)); |
1078 } | |
1079 } else if (*c == 'p') { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1080 gaim_privacy_permit_add(account, c + 2, TRUE); |
5228 | 1081 } else if (*c == 'd') { |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1082 gaim_privacy_deny_add(account, c + 2, TRUE); |
5228 | 1083 } else if (!strncmp("toc", c, 3)) { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1084 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); |
5228 | 1085 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1086 "permdeny: %d\n", account->perm_deny); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1087 if (account->perm_deny == 0) |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1088 account->perm_deny = 1; |
5228 | 1089 } else if (*c == 'm') { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1090 sscanf(c + 2, "%d", &account->perm_deny); |
5228 | 1091 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1092 "permdeny: %d\n", account->perm_deny); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1093 if (account->perm_deny == 0) |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1094 account->perm_deny = 1; |
5228 | 1095 } |
1096 } while ((c = strtok(NULL, "\n"))); | |
1097 | |
1098 if(account->gc) { | |
1099 if(bud) { | |
1100 GList *node = bud; | |
1101 serv_add_buddies(account->gc, bud); | |
1102 while(node) { | |
1103 g_free(node->data); | |
1104 node = node->next; | |
1105 } | |
1106 } | |
1107 serv_set_permit_deny(account->gc); | |
1108 } | |
1109 g_list_free(bud); | |
1110 } | |
1111 } | |
1112 | |
1113 #if 0 | |
1114 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */ | |
1115 static GString *translate_lst(FILE *src_fp) | |
1116 { | |
1117 char line[BUF_LEN], *line2; | |
1118 char *name; | |
1119 int i; | |
1120 | |
1121 GString *dest = g_string_new("m 1\n"); | |
1122 | |
1123 while (fgets(line, BUF_LEN, src_fp)) { | |
1124 line2 = g_strchug(line); | |
1125 if (strstr(line2, "group") == line2) { | |
1126 name = strpbrk(line2, " \t\n\r\f") + 1; | |
1127 dest = g_string_append(dest, "g "); | |
1128 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
1129 if (name[i] != '\"') | |
1130 dest = g_string_append_c(dest, name[i]); | |
1131 dest = g_string_append_c(dest, '\n'); | |
1132 } | |
1133 if (strstr(line2, "buddy") == line2) { | |
1134 name = strpbrk(line2, " \t\n\r\f") + 1; | |
1135 dest = g_string_append(dest, "b "); | |
1136 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
1137 if (name[i] != '\"') | |
1138 dest = g_string_append_c(dest, name[i]); | |
1139 dest = g_string_append_c(dest, '\n'); | |
1140 } | |
1141 } | |
1142 | |
1143 return dest; | |
1144 } | |
1145 | |
1146 | |
1147 /* translate an AIM 4 buddylist (*.blt) to Gaim format */ | |
1148 static GString *translate_blt(FILE *src_fp) | |
1149 { | |
1150 int i; | |
1151 char line[BUF_LEN]; | |
1152 char *buddy; | |
1153 | |
1154 GString *dest = g_string_new("m 1\n"); | |
1155 | |
1156 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL); | |
1157 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL); | |
1158 | |
1159 while (1) { | |
1160 fgets(line, BUF_LEN, src_fp); g_strchomp(line); | |
1161 if (strchr(line, '}') != NULL) | |
1162 break; | |
1163 | |
1164 if (strchr(line, '{') != NULL) { | |
1165 /* Syntax starting with "<group> {" */ | |
1166 | |
1167 dest = g_string_append(dest, "g "); | |
1168 buddy = g_strchug(strtok(line, "{")); | |
1169 for (i = 0; i < strlen(buddy); i++) | |
1170 if (buddy[i] != '\"') | |
1171 dest = g_string_append_c(dest, buddy[i]); | |
1172 dest = g_string_append_c(dest, '\n'); | |
1173 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) { | |
1174 gboolean pounce = FALSE; | |
1175 char *e; | |
1176 g_strchomp(line); | |
1177 buddy = g_strchug(line); | |
1178 gaim_debug(GAIM_DEBUG_MISC, "AIM 4 blt import", | |
1179 "buddy: \"%s\"\n", buddy); | |
1180 dest = g_string_append(dest, "b "); | |
1181 if (strchr(buddy, '{') != NULL) { | |
1182 /* buddy pounce, etc */ | |
1183 char *pos = strchr(buddy, '{') - 1; | |
1184 *pos = 0; | |
1185 pounce = TRUE; | |
1186 } | |
1187 if ((e = strchr(buddy, '\"')) != NULL) { | |
1188 *e = '\0'; | |
1189 buddy++; | |
1190 } | |
1191 dest = g_string_append(dest, buddy); | |
1192 dest = g_string_append_c(dest, '\n'); | |
1193 if (pounce) | |
1194 do | |
1195 fgets(line, BUF_LEN, src_fp); | |
1196 while (!strchr(line, '}')); | |
1197 } | |
1198 } else { | |
1199 | |
1200 /* Syntax "group buddy buddy ..." */ | |
1201 buddy = g_strchug(strtok(line, " \n")); | |
1202 dest = g_string_append(dest, "g "); | |
1203 if (strchr(buddy, '\"') != NULL) { | |
1204 dest = g_string_append(dest, &buddy[1]); | |
1205 dest = g_string_append_c(dest, ' '); | |
1206 buddy = g_strchug(strtok(NULL, " \n")); | |
1207 while (strchr(buddy, '\"') == NULL) { | |
1208 dest = g_string_append(dest, buddy); | |
1209 dest = g_string_append_c(dest, ' '); | |
1210 buddy = g_strchug(strtok(NULL, " \n")); | |
1211 } | |
1212 buddy[strlen(buddy) - 1] = '\0'; | |
1213 dest = g_string_append(dest, buddy); | |
1214 } else { | |
1215 dest = g_string_append(dest, buddy); | |
1216 } | |
1217 dest = g_string_append_c(dest, '\n'); | |
1218 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) { | |
1219 dest = g_string_append(dest, "b "); | |
1220 if (strchr(buddy, '\"') != NULL) { | |
1221 dest = g_string_append(dest, &buddy[1]); | |
1222 dest = g_string_append_c(dest, ' '); | |
1223 buddy = g_strchug(strtok(NULL, " \n")); | |
1224 while (strchr(buddy, '\"') == NULL) { | |
1225 dest = g_string_append(dest, buddy); | |
1226 dest = g_string_append_c(dest, ' '); | |
1227 buddy = g_strchug(strtok(NULL, " \n")); | |
1228 } | |
1229 buddy[strlen(buddy) - 1] = '\0'; | |
1230 dest = g_string_append(dest, buddy); | |
1231 } else { | |
1232 dest = g_string_append(dest, buddy); | |
1233 } | |
1234 dest = g_string_append_c(dest, '\n'); | |
1235 } | |
1236 } | |
1237 } | |
1238 | |
1239 return dest; | |
1240 } | |
1241 | |
1242 static GString *translate_gnomeicu(FILE *src_fp) | |
1243 { | |
1244 char line[BUF_LEN]; | |
1245 GString *dest = g_string_new("m 1\ng Buddies\n"); | |
1246 | |
1247 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL); | |
1248 | |
1249 while (fgets(line, BUF_LEN, src_fp)) { | |
1250 char *eq; | |
1251 g_strchomp(line); | |
1252 if (line[0] == '\n' || line[0] == '[') | |
1253 break; | |
1254 eq = strchr(line, '='); | |
1255 if (!eq) | |
1256 break; | |
1257 *eq = ':'; | |
1258 eq = strchr(eq, ','); | |
1259 if (eq) | |
1260 *eq = '\0'; | |
1261 dest = g_string_append(dest, "b "); | |
1262 dest = g_string_append(dest, line); | |
1263 dest = g_string_append_c(dest, '\n'); | |
1264 } | |
1265 | |
1266 return dest; | |
1267 } | |
1268 #endif | |
1269 | |
1270 static gchar *get_screenname_filename(const char *name) | |
1271 { | |
1272 gchar **split; | |
1273 gchar *good; | |
1274 gchar *ret; | |
1275 | |
1276 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1); | |
1277 good = g_strjoinv(NULL, split); | |
1278 g_strfreev(split); | |
1279 | |
1280 ret = g_utf8_strup(good, -1); | |
1281 | |
1282 g_free(good); | |
1283 | |
1284 return ret; | |
1285 } | |
1286 | |
1287 static gboolean gaim_blist_read(const char *filename); | |
1288 | |
1289 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1290 static void do_import(GaimAccount *account, const char *filename) |
5228 | 1291 { |
1292 GString *buf = NULL; | |
1293 char first[64]; | |
1294 char path[PATHSIZE]; | |
1295 int len; | |
1296 FILE *f; | |
1297 struct stat st; | |
1298 | |
1299 if (filename) { | |
1300 g_snprintf(path, sizeof(path), "%s", filename); | |
1301 } else { | |
1302 char *g_screenname = get_screenname_filename(account->username); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1303 const char *username; |
5228 | 1304 char *file = gaim_user_dir(); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1305 GaimProtocol prpl_num; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1306 int protocol; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1307 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1308 prpl_num = gaim_account_get_protocol(account); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1309 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1310 protocol = prpl_num; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1311 |
6450
e7b87c8e8c0a
[gaim-migrate @ 6959]
Christian Hammond <chipx86@chipx86.com>
parents:
6392
diff
changeset
|
1312 /* TODO Somehow move this checking into prpls */ |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1313 if (prpl_num == GAIM_PROTO_OSCAR) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1314 if ((username = gaim_account_get_username(account)) != NULL) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1315 protocol = (isalpha(*username) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1316 ? GAIM_PROTO_TOC : GAIM_PROTO_ICQ); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1317 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1318 } |
5228 | 1319 |
1320 if (file != (char *)NULL) { | |
5435 | 1321 snprintf(path, PATHSIZE, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol); |
5228 | 1322 g_free(g_screenname); |
1323 } else { | |
1324 g_free(g_screenname); | |
1325 return; | |
1326 } | |
1327 } | |
1328 | |
1329 if (stat(path, &st)) { | |
1330 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to stat %s.\n", | |
1331 path); | |
1332 return; | |
1333 } | |
1334 | |
1335 if (!(f = fopen(path, "r"))) { | |
1336 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to open %s.\n", | |
1337 path); | |
1338 return; | |
1339 } | |
1340 | |
1341 fgets(first, 64, f); | |
1342 | |
1343 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n')) | |
1344 fgets(first, 64, f); | |
1345 | |
1346 #if 0 | |
1347 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) { | |
1348 /* new gaim XML buddy list */ | |
1349 gaim_blist_read(path); | |
1350 | |
1351 /* We really don't need to bother doing stuf like translating AIM 3 buddy lists anymore */ | |
1352 | |
1353 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) { | |
1354 /* AIM 4 buddy list */ | |
1355 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 4\n"); | |
1356 rewind(f); | |
1357 buf = translate_blt(f); | |
1358 } else if (strstr(first, "group") != NULL) { | |
1359 /* AIM 3 buddy list */ | |
1360 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 3\n"); | |
1361 rewind(f); | |
1362 buf = translate_lst(f); | |
1363 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) { | |
1364 /* GnomeICU (hopefully) */ | |
1365 gaim_debug(GAIM_DEBUG_MISC, "blist import", "gnomeicu\n"); | |
1366 rewind(f); | |
1367 buf = translate_gnomeicu(f); | |
1368 | |
1369 } else | |
1370 #endif | |
1371 if (first[0] == 'm') { | |
1372 /* Gaim buddy list - no translation */ | |
1373 char buf2[BUF_LONG * 2]; | |
1374 buf = g_string_new(""); | |
1375 rewind(f); | |
1376 while (1) { | |
1377 len = fread(buf2, 1, BUF_LONG * 2 - 1, f); | |
1378 if (len <= 0) | |
1379 break; | |
1380 buf2[len] = '\0'; | |
1381 buf = g_string_append(buf, buf2); | |
1382 if (len != BUF_LONG * 2 - 1) | |
1383 break; | |
1384 } | |
1385 } | |
1386 | |
1387 fclose(f); | |
1388 | |
1389 if (buf) { | |
1390 buf = g_string_prepend(buf, "toc_set_config {"); | |
1391 buf = g_string_append(buf, "}\n"); | |
1392 parse_toc_buddy_list(account, buf->str); | |
1393 g_string_free(buf, TRUE); | |
1394 } | |
1395 } | |
1396 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1397 gboolean gaim_group_on_account(struct group *g, GaimAccount *account) { |
5228 | 1398 GaimBlistNode *bnode; |
1399 for(bnode = g->node.child; bnode; bnode = bnode->next) { | |
1400 struct buddy *b = (struct buddy *)bnode; | |
1401 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
1402 continue; | |
5855 | 1403 if((!account && gaim_account_is_connected(b->account)) |
1404 || b->account == account) | |
5228 | 1405 return TRUE; |
1406 } | |
1407 return FALSE; | |
1408 } | |
1409 | |
1410 static gboolean blist_safe_to_write = FALSE; | |
1411 | |
1412 static char *blist_parser_group_name = NULL; | |
1413 static char *blist_parser_person_name = NULL; | |
1414 static char *blist_parser_account_name = NULL; | |
1415 static int blist_parser_account_protocol = 0; | |
5234 | 1416 static char *blist_parser_chat_alias = NULL; |
1417 static char *blist_parser_component_name = NULL; | |
1418 static char *blist_parser_component_value = NULL; | |
5228 | 1419 static char *blist_parser_buddy_name = NULL; |
1420 static char *blist_parser_buddy_alias = NULL; | |
1421 static char *blist_parser_setting_name = NULL; | |
1422 static char *blist_parser_setting_value = NULL; | |
1423 static GHashTable *blist_parser_buddy_settings = NULL; | |
5906 | 1424 static GHashTable *blist_parser_chat_settings = NULL; |
5228 | 1425 static GHashTable *blist_parser_group_settings = NULL; |
5234 | 1426 static GHashTable *blist_parser_chat_components = NULL; |
5228 | 1427 static int blist_parser_privacy_mode = 0; |
1428 static GList *tag_stack = NULL; | |
1429 enum { | |
1430 BLIST_TAG_GAIM, | |
1431 BLIST_TAG_BLIST, | |
1432 BLIST_TAG_GROUP, | |
5234 | 1433 BLIST_TAG_CHAT, |
1434 BLIST_TAG_COMPONENT, | |
5228 | 1435 BLIST_TAG_PERSON, |
1436 BLIST_TAG_BUDDY, | |
1437 BLIST_TAG_NAME, | |
1438 BLIST_TAG_ALIAS, | |
1439 BLIST_TAG_SETTING, | |
1440 BLIST_TAG_PRIVACY, | |
1441 BLIST_TAG_ACCOUNT, | |
1442 BLIST_TAG_PERMIT, | |
1443 BLIST_TAG_BLOCK, | |
1444 BLIST_TAG_IGNORE | |
1445 }; | |
1446 static gboolean blist_parser_error_occurred = FALSE; | |
1447 | |
1448 static void blist_start_element_handler (GMarkupParseContext *context, | |
1449 const gchar *element_name, | |
1450 const gchar **attribute_names, | |
1451 const gchar **attribute_values, | |
1452 gpointer user_data, | |
1453 GError **error) { | |
1454 int i; | |
1455 | |
1456 if(!strcmp(element_name, "gaim")) { | |
1457 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GAIM)); | |
1458 } else if(!strcmp(element_name, "blist")) { | |
1459 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLIST)); | |
1460 } else if(!strcmp(element_name, "group")) { | |
1461 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GROUP)); | |
1462 for(i=0; attribute_names[i]; i++) { | |
1463 if(!strcmp(attribute_names[i], "name")) { | |
1464 g_free(blist_parser_group_name); | |
1465 blist_parser_group_name = g_strdup(attribute_values[i]); | |
1466 } | |
1467 } | |
1468 if(blist_parser_group_name) { | |
1469 struct group *g = gaim_group_new(blist_parser_group_name); | |
5634 | 1470 gaim_blist_add_group(g, |
1471 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5228 | 1472 } |
5234 | 1473 } else if(!strcmp(element_name, "chat")) { |
1474 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_CHAT)); | |
1475 for(i=0; attribute_names[i]; i++) { | |
1476 if(!strcmp(attribute_names[i], "account")) { | |
1477 g_free(blist_parser_account_name); | |
1478 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1479 } else if(!strcmp(attribute_names[i], "protocol")) { | |
1480 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1481 } | |
1482 } | |
5228 | 1483 } else if(!strcmp(element_name, "person")) { |
1484 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERSON)); | |
1485 for(i=0; attribute_names[i]; i++) { | |
1486 if(!strcmp(attribute_names[i], "name")) { | |
1487 g_free(blist_parser_person_name); | |
1488 blist_parser_person_name = g_strdup(attribute_values[i]); | |
1489 } | |
1490 } | |
1491 } else if(!strcmp(element_name, "buddy")) { | |
1492 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BUDDY)); | |
1493 for(i=0; attribute_names[i]; i++) { | |
1494 if(!strcmp(attribute_names[i], "account")) { | |
1495 g_free(blist_parser_account_name); | |
1496 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1497 } else if(!strcmp(attribute_names[i], "protocol")) { | |
1498 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1499 } | |
1500 } | |
1501 } else if(!strcmp(element_name, "name")) { | |
1502 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_NAME)); | |
1503 } else if(!strcmp(element_name, "alias")) { | |
1504 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ALIAS)); | |
1505 } else if(!strcmp(element_name, "setting")) { | |
1506 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_SETTING)); | |
1507 for(i=0; attribute_names[i]; i++) { | |
1508 if(!strcmp(attribute_names[i], "name")) { | |
1509 g_free(blist_parser_setting_name); | |
1510 blist_parser_setting_name = g_strdup(attribute_values[i]); | |
1511 } | |
1512 } | |
5234 | 1513 } else if(!strcmp(element_name, "component")) { |
1514 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_COMPONENT)); | |
1515 for(i=0; attribute_names[i]; i++) { | |
1516 if(!strcmp(attribute_names[i], "name")) { | |
1517 g_free(blist_parser_component_name); | |
1518 blist_parser_component_name = g_strdup(attribute_values[i]); | |
1519 } | |
1520 } | |
1521 | |
5228 | 1522 } else if(!strcmp(element_name, "privacy")) { |
1523 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PRIVACY)); | |
1524 } else if(!strcmp(element_name, "account")) { | |
1525 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ACCOUNT)); | |
1526 for(i=0; attribute_names[i]; i++) { | |
1527 if(!strcmp(attribute_names[i], "protocol")) | |
1528 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1529 else if(!strcmp(attribute_names[i], "mode")) | |
1530 blist_parser_privacy_mode = atoi(attribute_values[i]); | |
1531 else if(!strcmp(attribute_names[i], "name")) { | |
1532 g_free(blist_parser_account_name); | |
1533 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1534 } | |
1535 } | |
1536 } else if(!strcmp(element_name, "permit")) { | |
1537 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERMIT)); | |
1538 } else if(!strcmp(element_name, "block")) { | |
1539 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLOCK)); | |
1540 } else if(!strcmp(element_name, "ignore")) { | |
1541 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_IGNORE)); | |
1542 } | |
1543 } | |
1544 | |
1545 static void blist_end_element_handler(GMarkupParseContext *context, | |
1546 const gchar *element_name, gpointer user_data, GError **error) { | |
1547 if(!strcmp(element_name, "gaim")) { | |
1548 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1549 } else if(!strcmp(element_name, "blist")) { | |
1550 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1551 } else if(!strcmp(element_name, "group")) { | |
1552 if(blist_parser_group_settings) { | |
1553 struct group *g = gaim_find_group(blist_parser_group_name); | |
1554 g_hash_table_destroy(g->settings); | |
1555 g->settings = blist_parser_group_settings; | |
1556 } | |
1557 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1558 blist_parser_group_settings = NULL; | |
5234 | 1559 } else if(!strcmp(element_name, "chat")) { |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1560 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5234 | 1561 blist_parser_account_protocol); |
5237 | 1562 if(account) { |
5234 | 1563 struct chat *chat = gaim_chat_new(account, blist_parser_chat_alias, blist_parser_chat_components); |
1564 struct group *g = gaim_find_group(blist_parser_group_name); | |
5634 | 1565 gaim_blist_add_chat(chat,g, |
1566 gaim_blist_get_last_child((GaimBlistNode*)g)); | |
5906 | 1567 if(blist_parser_chat_settings) { |
1568 g_hash_table_destroy(chat->settings); | |
1569 chat->settings = blist_parser_chat_settings; | |
1570 } | |
5234 | 1571 } |
1572 g_free(blist_parser_chat_alias); | |
1573 blist_parser_chat_alias = NULL; | |
1574 g_free(blist_parser_account_name); | |
1575 blist_parser_account_name = NULL; | |
1576 blist_parser_chat_components = NULL; | |
5906 | 1577 blist_parser_chat_settings = NULL; |
5234 | 1578 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
5228 | 1579 } else if(!strcmp(element_name, "person")) { |
1580 g_free(blist_parser_person_name); | |
1581 blist_parser_person_name = NULL; | |
1582 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1583 } else if(!strcmp(element_name, "buddy")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1584 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 1585 blist_parser_account_protocol); |
1586 if(account) { | |
1587 struct buddy *b = gaim_buddy_new(account, blist_parser_buddy_name, blist_parser_buddy_alias); | |
1588 struct group *g = gaim_find_group(blist_parser_group_name); | |
5634 | 1589 gaim_blist_add_buddy(b,g, |
1590 gaim_blist_get_last_child((GaimBlistNode*)g)); | |
5228 | 1591 if(blist_parser_buddy_settings) { |
1592 g_hash_table_destroy(b->settings); | |
1593 b->settings = blist_parser_buddy_settings; | |
1594 } | |
1595 } | |
1596 g_free(blist_parser_buddy_name); | |
1597 blist_parser_buddy_name = NULL; | |
1598 g_free(blist_parser_buddy_alias); | |
1599 blist_parser_buddy_alias = NULL; | |
1600 g_free(blist_parser_account_name); | |
1601 blist_parser_account_name = NULL; | |
1602 blist_parser_buddy_settings = NULL; | |
1603 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1604 } else if(!strcmp(element_name, "name")) { | |
1605 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1606 } else if(!strcmp(element_name, "alias")) { | |
1607 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
5234 | 1608 } else if(!strcmp(element_name, "component")) { |
1609 if(!blist_parser_chat_components) | |
1610 blist_parser_chat_components = g_hash_table_new_full(g_str_hash, | |
1611 g_str_equal, g_free, g_free); | |
1612 if(blist_parser_component_name && blist_parser_component_value) { | |
1613 g_hash_table_replace(blist_parser_chat_components, | |
1614 g_strdup(blist_parser_component_name), | |
1615 g_strdup(blist_parser_component_value)); | |
1616 } | |
1617 g_free(blist_parser_component_name); | |
1618 g_free(blist_parser_component_value); | |
1619 blist_parser_component_name = NULL; | |
1620 blist_parser_component_value = NULL; | |
1621 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
5228 | 1622 } else if(!strcmp(element_name, "setting")) { |
1623 if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) { | |
1624 if(!blist_parser_buddy_settings) | |
1625 blist_parser_buddy_settings = g_hash_table_new_full(g_str_hash, | |
1626 g_str_equal, g_free, g_free); | |
1627 if(blist_parser_setting_name && blist_parser_setting_value) { | |
1628 g_hash_table_replace(blist_parser_buddy_settings, | |
1629 g_strdup(blist_parser_setting_name), | |
1630 g_strdup(blist_parser_setting_value)); | |
1631 } | |
5906 | 1632 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) { |
1633 if(!blist_parser_chat_settings) | |
1634 blist_parser_chat_settings = g_hash_table_new_full(g_str_hash, | |
1635 g_str_equal, g_free, g_free); | |
1636 if(blist_parser_setting_name && blist_parser_setting_value) { | |
6307 | 1637 g_hash_table_replace(blist_parser_chat_settings, |
5906 | 1638 g_strdup(blist_parser_setting_name), |
1639 g_strdup(blist_parser_setting_value)); | |
1640 } | |
5228 | 1641 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_GROUP) { |
1642 if(!blist_parser_group_settings) | |
1643 blist_parser_group_settings = g_hash_table_new_full(g_str_hash, | |
1644 g_str_equal, g_free, g_free); | |
1645 if(blist_parser_setting_name && blist_parser_setting_value) { | |
1646 g_hash_table_replace(blist_parser_group_settings, | |
1647 g_strdup(blist_parser_setting_name), | |
1648 g_strdup(blist_parser_setting_value)); | |
1649 } | |
1650 } | |
1651 g_free(blist_parser_setting_name); | |
1652 g_free(blist_parser_setting_value); | |
1653 blist_parser_setting_name = NULL; | |
1654 blist_parser_setting_value = NULL; | |
1655 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1656 } else if(!strcmp(element_name, "privacy")) { | |
1657 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1658 } else if(!strcmp(element_name, "account")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1659 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 1660 blist_parser_account_protocol); |
1661 if(account) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1662 account->perm_deny = blist_parser_privacy_mode; |
5228 | 1663 } |
1664 g_free(blist_parser_account_name); | |
1665 blist_parser_account_name = NULL; | |
1666 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1667 } else if(!strcmp(element_name, "permit")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1668 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 1669 blist_parser_account_protocol); |
1670 if(account) { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1671 gaim_privacy_permit_add(account, blist_parser_buddy_name, TRUE); |
5228 | 1672 } |
1673 g_free(blist_parser_buddy_name); | |
1674 blist_parser_buddy_name = NULL; | |
1675 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1676 } else if(!strcmp(element_name, "block")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1677 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 1678 blist_parser_account_protocol); |
1679 if(account) { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1680 gaim_privacy_deny_add(account, blist_parser_buddy_name, TRUE); |
5228 | 1681 } |
1682 g_free(blist_parser_buddy_name); | |
1683 blist_parser_buddy_name = NULL; | |
1684 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1685 } else if(!strcmp(element_name, "ignore")) { | |
1686 /* we'll apparently do something with this later */ | |
1687 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1688 } | |
1689 } | |
1690 | |
1691 static void blist_text_handler(GMarkupParseContext *context, const gchar *text, | |
1692 gsize text_len, gpointer user_data, GError **error) { | |
1693 switch(GPOINTER_TO_INT(tag_stack->data)) { | |
1694 case BLIST_TAG_NAME: | |
1695 blist_parser_buddy_name = g_strndup(text, text_len); | |
1696 break; | |
1697 case BLIST_TAG_ALIAS: | |
5234 | 1698 if(tag_stack->next && |
1699 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) | |
1700 blist_parser_buddy_alias = g_strndup(text, text_len); | |
1701 else if(tag_stack->next && | |
1702 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) | |
1703 blist_parser_chat_alias = g_strndup(text, text_len); | |
5228 | 1704 break; |
1705 case BLIST_TAG_PERMIT: | |
1706 case BLIST_TAG_BLOCK: | |
1707 case BLIST_TAG_IGNORE: | |
1708 blist_parser_buddy_name = g_strndup(text, text_len); | |
1709 break; | |
5234 | 1710 case BLIST_TAG_COMPONENT: |
1711 blist_parser_component_value = g_strndup(text, text_len); | |
1712 break; | |
5228 | 1713 case BLIST_TAG_SETTING: |
1714 blist_parser_setting_value = g_strndup(text, text_len); | |
1715 break; | |
1716 default: | |
1717 break; | |
1718 } | |
1719 } | |
1720 | |
1721 static void blist_error_handler(GMarkupParseContext *context, GError *error, | |
1722 gpointer user_data) { | |
1723 blist_parser_error_occurred = TRUE; | |
1724 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
1725 "Error parsing blist.xml: %s\n", error->message); | |
1726 } | |
1727 | |
1728 static GMarkupParser blist_parser = { | |
1729 blist_start_element_handler, | |
1730 blist_end_element_handler, | |
1731 blist_text_handler, | |
1732 NULL, | |
1733 blist_error_handler | |
1734 }; | |
1735 | |
1736 static gboolean gaim_blist_read(const char *filename) { | |
1737 gchar *contents = NULL; | |
1738 gsize length; | |
1739 GMarkupParseContext *context; | |
1740 GError *error = NULL; | |
1741 | |
1742 gaim_debug(GAIM_DEBUG_INFO, "blist import", | |
1743 "Reading %s\n", filename); | |
1744 if(!g_file_get_contents(filename, &contents, &length, &error)) { | |
1745 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
1746 "Error reading blist: %s\n", error->message); | |
1747 g_error_free(error); | |
1748 return FALSE; | |
1749 } | |
1750 | |
1751 context = g_markup_parse_context_new(&blist_parser, 0, NULL, NULL); | |
1752 | |
1753 if(!g_markup_parse_context_parse(context, contents, length, NULL)) { | |
1754 g_markup_parse_context_free(context); | |
1755 g_free(contents); | |
1756 return FALSE; | |
1757 } | |
1758 | |
1759 if(!g_markup_parse_context_end_parse(context, NULL)) { | |
1760 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
1761 "Error parsing %s\n", filename); | |
1762 g_markup_parse_context_free(context); | |
1763 g_free(contents); | |
1764 return FALSE; | |
1765 } | |
1766 | |
1767 g_markup_parse_context_free(context); | |
1768 g_free(contents); | |
1769 | |
1770 if(blist_parser_error_occurred) | |
1771 return FALSE; | |
1772 | |
1773 gaim_debug(GAIM_DEBUG_INFO, "blist import", "Finished reading %s\n", | |
1774 filename); | |
1775 | |
1776 return TRUE; | |
1777 } | |
1778 | |
1779 void gaim_blist_load() { | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1780 GList *accts; |
5228 | 1781 char *user_dir = gaim_user_dir(); |
1782 char *filename; | |
1783 char *msg; | |
1784 | |
1785 blist_safe_to_write = TRUE; | |
1786 | |
1787 if(!user_dir) | |
1788 return; | |
1789 | |
1790 filename = g_build_filename(user_dir, "blist.xml", NULL); | |
1791 | |
1792 if(g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
1793 if(!gaim_blist_read(filename)) { | |
1794 msg = g_strdup_printf(_("An error was encountered parsing your " | |
1795 "buddy list. It has not been loaded.")); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1796 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg); |
5228 | 1797 g_free(msg); |
1798 } | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1799 } else if(g_list_length(gaim_accounts_get_all())) { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
1800 #if 0 |
5947
ac4dd1d0ee39
[gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
1801 GMainContext *ctx; |
ac4dd1d0ee39
[gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
1802 |
5228 | 1803 /* rob wants to inform the user that their buddy lists are |
1804 * being converted */ | |
1805 msg = g_strdup_printf(_("Gaim is converting your old buddy lists " | |
1806 "to a new format, which will now be located at %s"), | |
1807 filename); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1808 gaim_notify_info(NULL, NULL, _("Converting Buddy List"), msg); |
5228 | 1809 g_free(msg); |
1810 | |
1811 /* now, let gtk actually display the dialog before we start anything */ | |
5947
ac4dd1d0ee39
[gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
1812 ctx = g_main_context_default(); |
ac4dd1d0ee39
[gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
1813 |
ac4dd1d0ee39
[gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
1814 while(g_main_context_pending(ctx)) |
ac4dd1d0ee39
[gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
1815 g_main_context_iteration(ctx, FALSE); |
6473
2311f3761ed2
[gaim-migrate @ 6982]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
1816 #endif |
5228 | 1817 |
1818 /* read in the old lists, then save to the new format */ | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1819 for(accts = gaim_accounts_get_all(); accts; accts = accts->next) { |
5228 | 1820 do_import(accts->data, NULL); |
1821 } | |
1822 gaim_blist_save(); | |
1823 } | |
1824 | |
1825 g_free(filename); | |
1826 } | |
1827 | |
1828 static void blist_print_group_settings(gpointer key, gpointer data, | |
1829 gpointer user_data) { | |
1830 char *key_val; | |
1831 char *data_val; | |
1832 FILE *file = user_data; | |
1833 | |
1834 if(!key || !data) | |
1835 return; | |
1836 | |
1837 key_val = g_markup_escape_text(key, -1); | |
1838 data_val = g_markup_escape_text(data, -1); | |
1839 | |
1840 fprintf(file, "\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
1841 data_val); | |
1842 g_free(key_val); | |
1843 g_free(data_val); | |
1844 } | |
1845 | |
1846 static void blist_print_buddy_settings(gpointer key, gpointer data, | |
1847 gpointer user_data) { | |
1848 char *key_val; | |
1849 char *data_val; | |
1850 FILE *file = user_data; | |
1851 | |
1852 if(!key || !data) | |
1853 return; | |
1854 | |
1855 key_val = g_markup_escape_text(key, -1); | |
1856 data_val = g_markup_escape_text(data, -1); | |
1857 | |
1858 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
1859 data_val); | |
1860 g_free(key_val); | |
1861 g_free(data_val); | |
1862 } | |
1863 | |
5234 | 1864 static void blist_print_chat_components(gpointer key, gpointer data, |
1865 gpointer user_data) { | |
1866 char *key_val; | |
1867 char *data_val; | |
1868 FILE *file = user_data; | |
1869 | |
1870 if(!key || !data) | |
1871 return; | |
1872 | |
1873 key_val = g_markup_escape_text(key, -1); | |
1874 data_val = g_markup_escape_text(data, -1); | |
1875 | |
1876 fprintf(file, "\t\t\t\t<component name=\"%s\">%s</component>\n", key_val, | |
1877 data_val); | |
1878 g_free(key_val); | |
1879 g_free(data_val); | |
1880 } | |
1881 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1882 static void gaim_blist_write(FILE *file, GaimAccount *exp_acct) { |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1883 GList *accounts; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1884 GSList *buds; |
5228 | 1885 GaimBlistNode *gnode,*bnode; |
1886 struct group *group; | |
1887 struct buddy *bud; | |
1888 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); | |
1889 fprintf(file, "<gaim version=\"1\">\n"); | |
1890 fprintf(file, "\t<blist>\n"); | |
1891 | |
1892 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
1893 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
1894 continue; | |
1895 group = (struct group *)gnode; | |
1896 if(!exp_acct || gaim_group_on_account(group, exp_acct)) { | |
1897 char *group_name = g_markup_escape_text(group->name, -1); | |
1898 fprintf(file, "\t\t<group name=\"%s\">\n", group_name); | |
1899 g_hash_table_foreach(group->settings, blist_print_group_settings, file); | |
1900 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
5234 | 1901 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
1902 bud = (struct buddy *)bnode; | |
1903 if(!exp_acct || bud->account == exp_acct) { | |
1904 char *bud_name = g_markup_escape_text(bud->name, -1); | |
1905 char *bud_alias = NULL; | |
1906 char *acct_name = g_markup_escape_text(bud->account->username, -1); | |
1907 if(bud->alias) | |
1908 bud_alias= g_markup_escape_text(bud->alias, -1); | |
1909 fprintf(file, "\t\t\t<person name=\"%s\">\n", | |
1910 bud_alias ? bud_alias : bud_name); | |
1911 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" " | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1912 "account=\"%s\">\n", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1913 gaim_account_get_protocol(bud->account), |
5234 | 1914 acct_name); |
1915 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name); | |
1916 if(bud_alias) { | |
1917 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n", | |
1918 bud_alias); | |
1919 } | |
1920 g_hash_table_foreach(bud->settings, | |
1921 blist_print_buddy_settings, file); | |
1922 fprintf(file, "\t\t\t\t</buddy>\n"); | |
1923 fprintf(file, "\t\t\t</person>\n"); | |
1924 g_free(bud_name); | |
1925 g_free(bud_alias); | |
1926 g_free(acct_name); | |
5228 | 1927 } |
5234 | 1928 } else if(GAIM_BLIST_NODE_IS_CHAT(bnode)) { |
1929 struct chat *chat = (struct chat *)bnode; | |
1930 if(!exp_acct || chat->account == exp_acct) { | |
1931 char *acct_name = g_markup_escape_text(chat->account->username, -1); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1932 fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1933 gaim_account_get_protocol(chat->account), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1934 acct_name); |
5237 | 1935 if(chat->alias) { |
1936 char *chat_alias = g_markup_escape_text(chat->alias, -1); | |
1937 fprintf(file, "\t\t\t\t<alias>%s</alias>\n", chat_alias); | |
1938 g_free(chat_alias); | |
1939 } | |
5234 | 1940 g_hash_table_foreach(chat->components, |
1941 blist_print_chat_components, file); | |
5906 | 1942 /* works for chats too, I don't feel like renaming */ |
1943 g_hash_table_foreach(chat->settings, | |
1944 blist_print_buddy_settings, file); | |
5234 | 1945 fprintf(file, "\t\t\t</chat>\n"); |
5237 | 1946 g_free(acct_name); |
5234 | 1947 } |
5228 | 1948 } |
1949 } | |
1950 fprintf(file, "\t\t</group>\n"); | |
1951 g_free(group_name); | |
1952 } | |
1953 } | |
1954 | |
1955 fprintf(file, "\t</blist>\n"); | |
1956 fprintf(file, "\t<privacy>\n"); | |
1957 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1958 for(accounts = gaim_accounts_get_all(); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1959 accounts != NULL; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1960 accounts = accounts->next) { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1961 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1962 GaimAccount *account = accounts->data; |
5228 | 1963 char *acct_name = g_markup_escape_text(account->username, -1); |
1964 if(!exp_acct || account == exp_acct) { | |
1965 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" " | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1966 "mode=\"%d\">\n", gaim_account_get_protocol(account), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1967 acct_name, account->perm_deny); |
5228 | 1968 for(buds = account->permit; buds; buds = buds->next) { |
1969 char *bud_name = g_markup_escape_text(buds->data, -1); | |
1970 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); | |
1971 g_free(bud_name); | |
1972 } | |
1973 for(buds = account->deny; buds; buds = buds->next) { | |
1974 char *bud_name = g_markup_escape_text(buds->data, -1); | |
1975 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name); | |
1976 g_free(bud_name); | |
1977 } | |
1978 fprintf(file, "\t\t</account>\n"); | |
1979 } | |
1980 g_free(acct_name); | |
1981 } | |
1982 | |
1983 fprintf(file, "\t</privacy>\n"); | |
1984 fprintf(file, "</gaim>\n"); | |
1985 } | |
1986 | |
1987 void gaim_blist_save() { | |
1988 FILE *file; | |
1989 char *user_dir = gaim_user_dir(); | |
1990 char *filename; | |
1991 char *filename_real; | |
1992 | |
1993 if(!user_dir) | |
1994 return; | |
1995 if(!blist_safe_to_write) { | |
1996 gaim_debug(GAIM_DEBUG_WARNING, "blist save", | |
1997 "AHH!! Tried to write the blist before we read it!\n"); | |
1998 return; | |
1999 } | |
2000 | |
2001 file = fopen(user_dir, "r"); | |
2002 if(!file) | |
2003 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR); | |
2004 else | |
2005 fclose(file); | |
2006 | |
2007 filename = g_build_filename(user_dir, "blist.xml.save", NULL); | |
2008 | |
2009 if((file = fopen(filename, "w"))) { | |
2010 gaim_blist_write(file, NULL); | |
2011 fclose(file); | |
2012 chmod(filename, S_IRUSR | S_IWUSR); | |
2013 } else { | |
2014 gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n", | |
2015 filename); | |
2016 } | |
2017 | |
2018 filename_real = g_build_filename(user_dir, "blist.xml", NULL); | |
2019 | |
2020 if(rename(filename, filename_real) < 0) | |
2021 gaim_debug(GAIM_DEBUG_ERROR, "blist save", | |
2022 "Error renaming %s to %s\n", filename, filename_real); | |
2023 | |
2024 | |
2025 g_free(filename); | |
2026 g_free(filename_real); | |
2027 } | |
2028 | |
2029 void gaim_group_set_setting(struct group *g, const char *key, | |
2030 const char *value) { | |
2031 if(!g) | |
2032 return; | |
2033 g_hash_table_replace(g->settings, g_strdup(key), g_strdup(value)); | |
2034 } | |
2035 | |
2036 char *gaim_group_get_setting(struct group *g, const char *key) { | |
2037 if(!g) | |
2038 return NULL; | |
2039 return g_strdup(g_hash_table_lookup(g->settings, key)); | |
2040 } | |
2041 | |
5906 | 2042 void gaim_chat_set_setting(struct chat *c, const char *key, |
2043 const char *value) | |
2044 { | |
2045 if(!c) | |
2046 return; | |
2047 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); | |
2048 } | |
2049 | |
2050 char *gaim_chat_get_setting(struct chat *c, const char *key) | |
2051 { | |
2052 if(!c) | |
2053 return NULL; | |
2054 return g_strdup(g_hash_table_lookup(c->settings, key)); | |
2055 } | |
2056 | |
5228 | 2057 void gaim_buddy_set_setting(struct buddy *b, const char *key, |
2058 const char *value) { | |
2059 if(!b) | |
2060 return; | |
2061 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value)); | |
2062 } | |
2063 | |
2064 char *gaim_buddy_get_setting(struct buddy *b, const char *key) { | |
2065 if(!b) | |
2066 return NULL; | |
2067 return g_strdup(g_hash_table_lookup(b->settings, key)); | |
2068 } | |
2069 | |
2070 void gaim_set_blist_ui_ops(struct gaim_blist_ui_ops *ops) | |
2071 { | |
2072 blist_ui_ops = ops; | |
2073 } | |
2074 | |
2075 struct gaim_blist_ui_ops * | |
2076 gaim_get_blist_ui_ops(void) | |
2077 { | |
2078 return blist_ui_ops; | |
2079 } | |
2080 | |
2081 int gaim_blist_get_group_size(struct group *group, gboolean offline) { | |
2082 if(!group) | |
2083 return 0; | |
2084 | |
5277 | 2085 return offline ? group->totalsize : group->currentsize; |
5228 | 2086 } |
2087 | |
2088 int gaim_blist_get_group_online_count(struct group *group) { | |
2089 if(!group) | |
2090 return 0; | |
2091 | |
5277 | 2092 return group->online; |
5228 | 2093 } |
2094 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2095 void * |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2096 gaim_blist_get_handle(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2097 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2098 static int handle; |
5228 | 2099 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2100 return &handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2101 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2102 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2103 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2104 gaim_blist_init(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2105 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2106 void *handle = gaim_blist_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2107 |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2108 gaim_signal_register(handle, "buddy-away", |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2109 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2110 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2111 GAIM_SUBTYPE_BLIST_BUDDY)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2112 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2113 gaim_signal_register(handle, "buddy-back", |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2114 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2115 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2116 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2117 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2118 gaim_signal_register(handle, "buddy-idle", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2119 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2120 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2121 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2122 gaim_signal_register(handle, "buddy-unidle", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2123 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2124 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2125 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2126 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2127 gaim_signal_register(handle, "buddy-signed-on", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2128 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2129 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2130 GAIM_SUBTYPE_BLIST_BUDDY)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2131 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2132 gaim_signal_register(handle, "buddy-signed-off", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2133 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2134 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2135 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2136 |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2137 gaim_signal_register(handle, "update-idle", gaim_marshal_VOID, NULL, 0); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2138 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2139 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2140 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2141 gaim_blist_uninit(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2142 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2143 gaim_signals_unregister_by_instance(gaim_blist_get_handle()); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2144 } |