Mercurial > pidgin.yaz
annotate src/blist.c @ 6960:ccc0d9654098
[gaim-migrate @ 7507]
ASDG!
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 24 Sep 2003 23:41:35 +0000 |
parents | 7e18efe2944a |
children | 13da9fe5f213 |
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 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
40 |
5228 | 41 /***************************************************************************** |
42 * Private Utility functions * | |
43 *****************************************************************************/ | |
44 static GaimBlistNode *gaim_blist_get_last_sibling(GaimBlistNode *node) | |
45 { | |
46 GaimBlistNode *n = node; | |
47 if (!n) | |
48 return NULL; | |
49 while (n->next) | |
50 n = n->next; | |
51 return n; | |
52 } | |
6695 | 53 |
5228 | 54 static GaimBlistNode *gaim_blist_get_last_child(GaimBlistNode *node) |
55 { | |
56 if (!node) | |
57 return NULL; | |
58 return gaim_blist_get_last_sibling(node->child); | |
59 } | |
60 | |
5247 | 61 struct _gaim_hbuddy { |
62 char *name; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
63 GaimAccount *account; |
5758 | 64 GaimBlistNode *group; |
5247 | 65 }; |
66 | |
67 static guint _gaim_blist_hbuddy_hash (struct _gaim_hbuddy *hb) | |
68 { | |
69 return g_str_hash(hb->name); | |
70 } | |
71 | |
72 static guint _gaim_blist_hbuddy_equal (struct _gaim_hbuddy *hb1, struct _gaim_hbuddy *hb2) | |
73 { | |
5758 | 74 return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group); |
5247 | 75 } |
76 | |
6742 | 77 static void _gaim_blist_hbuddy_free_key(struct _gaim_hbuddy *hb) |
78 { | |
79 g_free(hb->name); | |
80 g_free(hb); | |
81 } | |
82 | |
6006 | 83 static void blist_pref_cb(const char *name, GaimPrefType typ, gpointer value, gpointer data) |
84 { | |
6012 | 85 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
6695 | 86 GaimBlistNode *gnode, *cnode, *bnode; |
6012 | 87 |
88 if (!ops) | |
89 return; | |
90 | |
6695 | 91 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { |
92 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6012 | 93 continue; |
6695 | 94 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
95 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
96 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
97 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
98 continue; | |
99 ops->update(gaimbuddylist, bnode); | |
100 } | |
101 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
102 ops->update(gaimbuddylist, cnode); | |
103 } | |
6012 | 104 } |
105 } | |
6006 | 106 } |
107 | |
6843 | 108 static GaimContact *gaim_buddy_get_contact(GaimBuddy *buddy) |
109 { | |
110 return (GaimContact*)((GaimBlistNode*)buddy)->parent; | |
111 } | |
112 | |
113 static void gaim_contact_compute_priority_buddy(GaimContact *contact) { | |
114 GaimBlistNode *bnode; | |
6870 | 115 contact->priority = NULL; |
6843 | 116 |
117 for(bnode = ((GaimBlistNode*)contact)->child; bnode; bnode = bnode->next) { | |
118 GaimBuddy *buddy; | |
119 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
120 continue; | |
121 buddy = (GaimBuddy*)bnode; | |
122 if(!gaim_account_is_connected(buddy->account)) | |
123 continue; | |
124 | |
125 if(!contact->priority) { | |
126 contact->priority = buddy; | |
127 } else if(GAIM_BUDDY_IS_ONLINE(buddy)) { | |
128 if(!GAIM_BUDDY_IS_ONLINE(contact->priority)) { | |
129 contact->priority = buddy; | |
130 } else if(!(buddy->uc & UC_UNAVAILABLE) && !buddy->idle && | |
131 (contact->priority->uc & UC_UNAVAILABLE || | |
132 contact->priority->idle)) { | |
133 contact->priority = buddy; | |
134 } else if(!buddy->idle && contact->priority->idle) { | |
135 contact->priority = buddy; | |
136 } else if(contact->priority->uc & UC_UNAVAILABLE && | |
137 contact->priority->idle && (!(buddy->uc & UC_UNAVAILABLE) || | |
138 !buddy->idle)) { | |
139 contact->priority = buddy; | |
140 } | |
141 } | |
142 } | |
143 } | |
144 | |
145 | |
5228 | 146 /***************************************************************************** |
147 * Public API functions * | |
148 *****************************************************************************/ | |
149 | |
150 struct gaim_buddy_list *gaim_blist_new() | |
151 { | |
152 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1); | |
153 | |
154 gbl->ui_ops = gaim_get_blist_ui_ops(); | |
155 | |
6742 | 156 gbl->buddies = g_hash_table_new_full((GHashFunc)_gaim_blist_hbuddy_hash, |
157 (GEqualFunc)_gaim_blist_hbuddy_equal, | |
158 (GDestroyNotify)_gaim_blist_hbuddy_free_key, NULL); | |
5247 | 159 |
5228 | 160 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL) |
161 gbl->ui_ops->new_list(gbl); | |
162 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
163 gaim_prefs_connect_callback("/core/buddies/use_server_alias", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
164 blist_pref_cb, NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
165 |
6006 | 166 |
5228 | 167 return gbl; |
168 } | |
169 | |
170 void | |
171 gaim_set_blist(struct gaim_buddy_list *list) | |
172 { | |
173 gaimbuddylist = list; | |
174 } | |
175 | |
176 struct gaim_buddy_list * | |
177 gaim_get_blist(void) | |
178 { | |
179 return gaimbuddylist; | |
180 } | |
181 | |
6695 | 182 void gaim_blist_show () |
5228 | 183 { |
184 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
185 if (ops) | |
186 ops->show(gaimbuddylist); | |
187 } | |
188 | |
189 void gaim_blist_destroy() | |
190 { | |
191 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
192 if (ops) | |
193 ops->destroy(gaimbuddylist); | |
194 } | |
195 | |
196 void gaim_blist_set_visible (gboolean show) | |
197 { | |
198 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
199 if (ops) | |
200 ops->set_visible(gaimbuddylist, show); | |
201 } | |
202 | |
6695 | 203 void gaim_blist_update_buddy_status (GaimBuddy *buddy, int status) |
5228 | 204 { |
5266
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
205 struct gaim_blist_ui_ops *ops; |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
206 |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
207 if (buddy->uc == status) |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
208 return; |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
209 |
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
210 ops = gaimbuddylist->ui_ops; |
5228 | 211 |
5305 | 212 if((status & UC_UNAVAILABLE) != (buddy->uc & UC_UNAVAILABLE)) { |
213 if(status & UC_UNAVAILABLE) | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
214 gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); |
5305 | 215 else |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
216 gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); |
5305 | 217 } |
5228 | 218 |
5305 | 219 buddy->uc = status; |
6843 | 220 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
5228 | 221 if (ops) |
222 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
223 } | |
224 | |
6695 | 225 static gboolean presence_update_timeout_cb(GaimBuddy *buddy) { |
5228 | 226 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
227 GaimConversation *conv; |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
228 |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
229 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
5228 | 230 |
231 if(buddy->present == GAIM_BUDDY_SIGNING_ON) { | |
232 buddy->present = GAIM_BUDDY_ONLINE; | |
233 } else if(buddy->present == GAIM_BUDDY_SIGNING_OFF) { | |
234 buddy->present = GAIM_BUDDY_OFFLINE; | |
6860 | 235 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online--; |
236 if(((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 0) | |
237 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online--; | |
5228 | 238 } |
239 | |
240 buddy->timer = 0; | |
6843 | 241 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
5228 | 242 |
243 if (ops) | |
244 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
245 | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
246 if (conv) { |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
247 if (buddy->present == GAIM_BUDDY_ONLINE) |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
248 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
249 else if (buddy->present == GAIM_BUDDY_OFFLINE) |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
250 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_OFFLINE); |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
251 } |
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
252 |
5228 | 253 return FALSE; |
254 } | |
255 | |
6695 | 256 void gaim_blist_update_buddy_presence(GaimBuddy *buddy, int presence) { |
5228 | 257 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
258 gboolean do_timer = FALSE; | |
259 | |
260 if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) { | |
6901 | 261 int old_present = buddy->present; |
5228 | 262 buddy->present = GAIM_BUDDY_SIGNING_ON; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
263 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy); |
5228 | 264 do_timer = TRUE; |
6901 | 265 |
266 if(old_present != GAIM_BUDDY_SIGNING_OFF) { | |
267 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online++; | |
268 if(((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 1) | |
269 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online++; | |
270 } | |
5228 | 271 } else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) { |
272 buddy->present = GAIM_BUDDY_SIGNING_OFF; | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
273 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy); |
5228 | 274 do_timer = TRUE; |
275 } | |
276 | |
277 if(do_timer) { | |
278 if(buddy->timer > 0) | |
279 g_source_remove(buddy->timer); | |
280 buddy->timer = g_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); | |
281 } | |
282 | |
6843 | 283 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
5228 | 284 if (ops) |
285 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
286 } | |
287 | |
288 | |
6695 | 289 void gaim_blist_update_buddy_idle (GaimBuddy *buddy, int idle) |
5228 | 290 { |
291 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
292 buddy->idle = idle; | |
6843 | 293 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
5228 | 294 if (ops) |
295 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
296 } | |
6695 | 297 |
298 void gaim_blist_update_buddy_evil (GaimBuddy *buddy, int warning) | |
5228 | 299 { |
300 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
301 buddy->evil = warning; | |
302 if (ops) | |
303 ops->update(gaimbuddylist,(GaimBlistNode*)buddy); | |
304 } | |
6695 | 305 |
306 void gaim_blist_update_buddy_icon(GaimBuddy *buddy) { | |
5228 | 307 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
308 if(ops) | |
309 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
310 } | |
6695 | 311 |
312 void gaim_blist_rename_buddy (GaimBuddy *buddy, const char *name) | |
5228 | 313 { |
314 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
5634 | 315 g_free(buddy->name); |
5228 | 316 buddy->name = g_strdup(name); |
317 if (ops) | |
318 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
319 } | |
5234 | 320 |
6695 | 321 void gaim_blist_alias_chat(GaimBlistChat *chat, const char *alias) |
5234 | 322 { |
323 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
324 | |
5237 | 325 g_free(chat->alias); |
5234 | 326 |
5237 | 327 if(alias && strlen(alias)) |
328 chat->alias = g_strdup(alias); | |
329 else | |
330 chat->alias = NULL; | |
331 | |
5234 | 332 if(ops) |
333 ops->update(gaimbuddylist, (GaimBlistNode*)chat); | |
334 } | |
335 | |
6695 | 336 void gaim_blist_alias_buddy (GaimBuddy *buddy, const char *alias) |
5228 | 337 { |
338 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5634
diff
changeset
|
339 GaimConversation *conv; |
5228 | 340 |
341 g_free(buddy->alias); | |
342 | |
343 if(alias && strlen(alias)) | |
344 buddy->alias = g_strdup(alias); | |
345 else | |
346 buddy->alias = NULL; | |
347 | |
348 if (ops) | |
349 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
350 | |
351 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); | |
352 | |
353 if (conv) | |
354 gaim_conversation_autoset_title(conv); | |
355 } | |
356 | |
6695 | 357 void gaim_blist_server_alias_buddy (GaimBuddy *buddy, const char *alias) |
6058 | 358 { |
359 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
360 GaimConversation *conv; | |
361 | |
362 g_free(buddy->server_alias); | |
363 | |
364 if(alias && strlen(alias) && g_utf8_validate(alias, -1, NULL)) | |
365 buddy->server_alias = g_strdup(alias); | |
366 else | |
367 buddy->server_alias = NULL; | |
368 | |
369 if (ops) | |
370 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
371 | |
372 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); | |
373 | |
374 if (conv) | |
375 gaim_conversation_autoset_title(conv); | |
376 } | |
377 | |
6695 | 378 void gaim_blist_rename_group(GaimGroup *group, const char *name) |
5228 | 379 { |
380 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
6695 | 381 GaimGroup *dest_group; |
5346 | 382 GaimBlistNode *prev, *child, *next; |
383 GSList *accts; | |
384 | |
385 if(!name || !strlen(name) || !strcmp(name, group->name)) { | |
386 /* nothing to do here */ | |
387 return; | |
388 } else if((dest_group = gaim_find_group(name))) { | |
389 /* here we're merging two groups */ | |
390 prev = gaim_blist_get_last_child((GaimBlistNode*)dest_group); | |
391 child = ((GaimBlistNode*)group)->child; | |
392 | |
393 while(child) | |
394 { | |
395 next = child->next; | |
6695 | 396 if(GAIM_BLIST_NODE_IS_CONTACT(child)) { |
397 GaimBlistNode *bnode; | |
398 gaim_blist_add_contact((GaimContact *)child, dest_group, prev); | |
399 for(bnode = child->child; bnode; bnode = bnode->next) | |
400 gaim_blist_add_buddy((GaimBuddy*)bnode, (GaimContact*)child, | |
401 NULL, bnode->prev); | |
5346 | 402 prev = child; |
403 } else if(GAIM_BLIST_NODE_IS_CHAT(child)) { | |
6695 | 404 gaim_blist_add_chat((GaimBlistChat *)child, dest_group, prev); |
5346 | 405 prev = child; |
406 } else { | |
407 gaim_debug(GAIM_DEBUG_ERROR, "blist", | |
408 "Unknown child type in group %s\n", group->name); | |
409 } | |
410 child = next; | |
411 } | |
412 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
|
413 GaimAccount *account = accts->data; |
5346 | 414 serv_rename_group(account->gc, group, name); |
415 } | |
416 gaim_blist_remove_group(group); | |
417 } else { | |
418 /* a simple rename */ | |
419 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
|
420 GaimAccount *account = accts->data; |
5346 | 421 serv_rename_group(account->gc, group, name); |
422 } | |
423 g_free(group->name); | |
424 group->name = g_strdup(name); | |
425 if (ops) | |
426 ops->update(gaimbuddylist, (GaimBlistNode*)group); | |
427 } | |
5228 | 428 } |
5234 | 429 |
6695 | 430 GaimBlistChat *gaim_blist_chat_new(GaimAccount *account, const char *alias, GHashTable *components) |
5234 | 431 { |
6695 | 432 GaimBlistChat *chat; |
5234 | 433 struct gaim_blist_ui_ops *ops; |
434 | |
5237 | 435 if(!components) |
5234 | 436 return NULL; |
437 | |
6695 | 438 chat = g_new0(GaimBlistChat, 1); |
5234 | 439 chat->account = account; |
5237 | 440 if(alias && strlen(alias)) |
441 chat->alias = g_strdup(alias); | |
5234 | 442 chat->components = components; |
5906 | 443 chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
444 g_free, g_free); | |
5234 | 445 |
446 ((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE; | |
447 | |
448 ops = gaim_get_blist_ui_ops(); | |
449 | |
450 if (ops != NULL && ops->new_node != NULL) | |
451 ops->new_node((GaimBlistNode *)chat); | |
452 | |
453 return chat; | |
454 } | |
455 | |
6695 | 456 char *gaim_blist_chat_get_display_name(GaimBlistChat *chat) |
6034 | 457 { |
458 char *name; | |
459 | |
460 if(chat->alias){ | |
461 name = g_strdup(chat->alias); | |
462 } | |
463 else{ | |
464 GList *parts; | |
465 GaimPlugin *prpl; | |
466 GaimPluginProtocolInfo *prpl_info; | |
467 struct proto_chat_entry *pce; | |
468 | |
469 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); | |
470 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
471 | |
472 parts = prpl_info->chat_info(chat->account->gc); | |
473 | |
474 pce = parts->data; | |
475 name = g_markup_escape_text(g_hash_table_lookup(chat->components, | |
476 pce->identifier), -1); | |
477 g_list_free(parts); | |
478 } | |
479 | |
480 return name; | |
481 } | |
482 | |
6695 | 483 GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias) |
5228 | 484 { |
6695 | 485 GaimBuddy *b; |
5228 | 486 struct gaim_blist_ui_ops *ops; |
487 | |
6695 | 488 b = g_new0(GaimBuddy, 1); |
5228 | 489 b->account = account; |
490 b->name = g_strdup(screenname); | |
491 b->alias = g_strdup(alias); | |
492 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
493 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE; | |
494 | |
495 ops = gaim_get_blist_ui_ops(); | |
496 | |
497 if (ops != NULL && ops->new_node != NULL) | |
498 ops->new_node((GaimBlistNode *)b); | |
499 | |
500 return b; | |
501 } | |
5634 | 502 |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
503 void |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
504 gaim_buddy_set_icon(GaimBuddy *buddy, GaimBuddyIcon *icon) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
505 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
506 g_return_if_fail(buddy != NULL); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
507 |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
508 if (buddy->icon == icon) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
509 return; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
510 |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
511 if (buddy->icon != NULL) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
512 gaim_buddy_icon_unref(buddy->icon); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
513 |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
514 buddy->icon = (icon == NULL ? NULL : gaim_buddy_icon_ref(icon)); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
515 |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6885
diff
changeset
|
516 gaim_buddy_icon_cache(icon, buddy); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
517 |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
518 gaim_blist_update_buddy_icon(buddy); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
519 } |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
520 |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
521 GaimBuddyIcon * |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
522 gaim_buddy_get_icon(const GaimBuddy *buddy) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
523 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
524 g_return_val_if_fail(buddy != NULL, NULL); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
525 |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
526 return buddy->icon; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
527 } |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
528 |
6695 | 529 void gaim_blist_add_chat(GaimBlistChat *chat, GaimGroup *group, GaimBlistNode *node) |
5234 | 530 { |
531 GaimBlistNode *n = node, *cnode = (GaimBlistNode*)chat; | |
6695 | 532 GaimGroup *g = group; |
5234 | 533 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
534 gboolean save = FALSE; | |
535 | |
6774 | 536 |
537 g_return_if_fail(chat != NULL); | |
538 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT((GaimBlistNode*)chat)); | |
539 | |
5234 | 540 if (!n) { |
541 if (!g) { | |
542 g = gaim_group_new(_("Chats")); | |
5634 | 543 gaim_blist_add_group(g, |
544 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5234 | 545 } |
546 } else { | |
6695 | 547 g = (GaimGroup*)n->parent; |
5234 | 548 } |
549 | |
550 /* if we're moving to overtop of ourselves, do nothing */ | |
551 if(cnode == n) | |
552 return; | |
553 | |
554 if (cnode->parent) { | |
555 /* This chat was already in the list and is | |
556 * being moved. | |
557 */ | |
6695 | 558 ((GaimGroup *)cnode->parent)->totalsize--; |
5855 | 559 if (gaim_account_is_connected(chat->account)) { |
6695 | 560 ((GaimGroup *)cnode->parent)->online--; |
561 ((GaimGroup *)cnode->parent)->currentsize--; | |
5287 | 562 } |
5234 | 563 if(cnode->next) |
564 cnode->next->prev = cnode->prev; | |
565 if(cnode->prev) | |
566 cnode->prev->next = cnode->next; | |
567 if(cnode->parent->child == cnode) | |
568 cnode->parent->child = cnode->next; | |
569 | |
570 ops->remove(gaimbuddylist, cnode); | |
571 | |
572 save = TRUE; | |
573 } | |
574 | |
575 if (n) { | |
576 if(n->next) | |
577 n->next->prev = cnode; | |
578 cnode->next = n->next; | |
579 cnode->prev = n; | |
580 cnode->parent = n->parent; | |
581 n->next = cnode; | |
6695 | 582 ((GaimGroup *)n->parent)->totalsize++; |
5855 | 583 if (gaim_account_is_connected(chat->account)) { |
6695 | 584 ((GaimGroup *)n->parent)->online++; |
585 ((GaimGroup *)n->parent)->currentsize++; | |
5287 | 586 } |
5234 | 587 } else { |
5634 | 588 if(((GaimBlistNode*)g)->child) |
589 ((GaimBlistNode*)g)->child->prev = cnode; | |
590 cnode->next = ((GaimBlistNode*)g)->child; | |
591 cnode->prev = NULL; | |
5234 | 592 ((GaimBlistNode*)g)->child = cnode; |
593 cnode->parent = (GaimBlistNode*)g; | |
5277 | 594 g->totalsize++; |
5855 | 595 if (gaim_account_is_connected(chat->account)) { |
5287 | 596 g->online++; |
5277 | 597 g->currentsize++; |
5287 | 598 } |
5234 | 599 } |
600 | |
601 if (ops) | |
602 ops->update(gaimbuddylist, (GaimBlistNode*)cnode); | |
603 if (save) | |
604 gaim_blist_save(); | |
605 } | |
606 | |
6695 | 607 void gaim_blist_add_buddy (GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
5228 | 608 { |
6695 | 609 GaimBlistNode *cnode, *bnode; |
610 GaimGroup *g; | |
611 GaimContact *c; | |
5228 | 612 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; |
6695 | 613 gboolean save = FALSE; |
5247 | 614 struct _gaim_hbuddy *hb; |
6695 | 615 |
616 g_return_if_fail(buddy != NULL); | |
6774 | 617 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY((GaimBlistNode*)buddy)); |
6695 | 618 |
619 bnode = (GaimBlistNode *)buddy; | |
5228 | 620 |
6695 | 621 /* if we're moving to overtop of ourselves, do nothing */ |
622 if(bnode == node || (!node && bnode->parent && | |
623 contact && bnode->parent == (GaimBlistNode*)contact | |
624 && bnode == bnode->parent->child)) | |
625 return; | |
626 | |
627 if(node && GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
628 c = (GaimContact*)node->parent; | |
629 g = (GaimGroup*)node->parent->parent; | |
630 } else if(contact) { | |
631 c = contact; | |
632 g = (GaimGroup*)((GaimBlistNode*)c)->parent; | |
633 } else { | |
634 if(group) { | |
635 g = group; | |
636 } else { | |
5228 | 637 g = gaim_group_new(_("Buddies")); |
5634 | 638 gaim_blist_add_group(g, |
639 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5228 | 640 } |
6695 | 641 c = gaim_contact_new(); |
642 gaim_blist_add_contact(c, g, | |
643 gaim_blist_get_last_child((GaimBlistNode*)g)); | |
5228 | 644 } |
645 | |
6695 | 646 cnode = (GaimBlistNode *)c; |
5228 | 647 |
6695 | 648 if(bnode->parent) { |
649 if(GAIM_BUDDY_IS_ONLINE(buddy)) { | |
650 ((GaimContact*)bnode->parent)->online--; | |
651 if(((GaimContact*)bnode->parent)->online == 0) | |
652 ((GaimGroup*)bnode->parent->parent)->online--; | |
653 } | |
654 if(gaim_account_is_connected(buddy->account)) { | |
655 ((GaimContact*)bnode->parent)->currentsize--; | |
656 if(((GaimContact*)bnode->parent)->currentsize == 0) | |
657 ((GaimGroup*)bnode->parent->parent)->currentsize--; | |
658 } | |
659 ((GaimContact*)bnode->parent)->totalsize--; | |
660 /* the group totalsize will be taken care of by remove_contact below */ | |
661 | |
662 if(bnode->parent->parent != (GaimBlistNode*)g) | |
663 serv_move_buddy(buddy, (GaimGroup *)bnode->parent->parent, g); | |
5277 | 664 |
5228 | 665 if(bnode->next) |
666 bnode->next->prev = bnode->prev; | |
667 if(bnode->prev) | |
668 bnode->prev->next = bnode->next; | |
6794 | 669 if(bnode->parent->child == bnode) |
5228 | 670 bnode->parent->child = bnode->next; |
671 | |
672 ops->remove(gaimbuddylist, bnode); | |
673 | |
674 save = TRUE; | |
6742 | 675 |
676 if(bnode->parent->parent != (GaimBlistNode*)g) { | |
677 hb = g_new(struct _gaim_hbuddy, 1); | |
678 hb->name = normalize(buddy->name); | |
679 hb->account = buddy->account; | |
680 hb->group = bnode->parent->parent; | |
6775 | 681 g_hash_table_remove(gaimbuddylist->buddies, hb); |
6742 | 682 g_free(hb); |
683 } | |
6794 | 684 |
685 if(!bnode->parent->child) | |
686 gaim_blist_remove_contact((GaimContact*)bnode->parent); | |
687 | |
5228 | 688 } |
689 | |
6695 | 690 if(node && GAIM_BLIST_NODE_IS_BUDDY(node)) { |
691 if(node->next) | |
692 node->next->prev = bnode; | |
693 bnode->next = node->next; | |
694 bnode->prev = node; | |
695 bnode->parent = node->parent; | |
696 node->next = bnode; | |
5228 | 697 } else { |
6695 | 698 if(cnode->child) |
699 cnode->child->prev = bnode; | |
700 bnode->prev = NULL; | |
701 bnode->next = cnode->child; | |
702 cnode->child = bnode; | |
703 bnode->parent = cnode; | |
5228 | 704 } |
705 | |
6695 | 706 if(GAIM_BUDDY_IS_ONLINE(buddy)) { |
707 ((GaimContact*)bnode->parent)->online++; | |
708 if(((GaimContact*)bnode->parent)->online == 1) | |
709 ((GaimGroup*)bnode->parent->parent)->online++; | |
710 } | |
711 if(gaim_account_is_connected(buddy->account)) { | |
712 ((GaimContact*)bnode->parent)->currentsize++; | |
713 if(((GaimContact*)bnode->parent)->currentsize == 1) | |
714 ((GaimGroup*)bnode->parent->parent)->currentsize++; | |
715 } | |
716 ((GaimContact*)bnode->parent)->totalsize++; | |
717 | |
718 | |
6742 | 719 hb = g_new(struct _gaim_hbuddy, 1); |
5247 | 720 hb->name = g_strdup(normalize(buddy->name)); |
721 hb->account = buddy->account; | |
6695 | 722 hb->group = ((GaimBlistNode*)buddy)->parent->parent; |
5247 | 723 |
6742 | 724 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy); |
5247 | 725 |
6843 | 726 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
5228 | 727 if (ops) |
728 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
729 if (save) | |
730 gaim_blist_save(); | |
731 } | |
732 | |
6695 | 733 GaimContact *gaim_contact_new() |
5228 | 734 { |
6695 | 735 struct gaim_blist_ui_ops *ops; |
736 GaimContact *c = g_new0(GaimContact, 1); | |
737 ((GaimBlistNode*)c)->type = GAIM_BLIST_CONTACT_NODE; | |
738 | |
739 c->totalsize = c->currentsize = c->online = 0; | |
740 | |
741 ops = gaim_get_blist_ui_ops(); | |
742 if (ops != NULL && ops->new_node != NULL) | |
743 ops->new_node((GaimBlistNode *)c); | |
744 | |
745 return c; | |
746 } | |
747 | |
6755 | 748 void gaim_contact_set_alias(GaimContact* contact, const char *alias) |
749 { | |
750 g_return_if_fail(contact != NULL); | |
751 | |
752 if(contact->alias) | |
753 g_free(contact->alias); | |
754 | |
755 contact->alias = g_strdup(alias); | |
756 } | |
757 | |
758 const char *gaim_contact_get_alias(GaimContact* contact) | |
759 { | |
760 return contact ? contact->alias : NULL; | |
761 } | |
762 | |
6695 | 763 GaimGroup *gaim_group_new(const char *name) |
764 { | |
765 GaimGroup *g = gaim_find_group(name); | |
5228 | 766 |
767 if (!g) { | |
768 struct gaim_blist_ui_ops *ops; | |
6695 | 769 g= g_new0(GaimGroup, 1); |
5228 | 770 g->name = g_strdup(name); |
5277 | 771 g->totalsize = 0; |
772 g->currentsize = 0; | |
773 g->online = 0; | |
5228 | 774 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
775 g_free, g_free); | |
776 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE; | |
777 | |
778 ops = gaim_get_blist_ui_ops(); | |
779 | |
780 if (ops != NULL && ops->new_node != NULL) | |
781 ops->new_node((GaimBlistNode *)g); | |
782 | |
783 } | |
784 return g; | |
785 } | |
786 | |
6695 | 787 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
788 { | |
789 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
790 GaimGroup *g; | |
6742 | 791 GaimBlistNode *gnode, *cnode, *bnode; |
6695 | 792 gboolean save = FALSE; |
793 | |
6774 | 794 g_return_if_fail(contact != NULL); |
795 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); | |
6695 | 796 |
797 if(node && (GAIM_BLIST_NODE_IS_CONTACT(node) || | |
798 GAIM_BLIST_NODE_IS_CHAT(node))) | |
799 g = (GaimGroup*)node->parent; | |
800 else if(group) | |
801 g = group; | |
802 else { | |
803 g = gaim_group_new(_("Buddies")); | |
804 gaim_blist_add_group(g, | |
805 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
806 } | |
807 | |
808 gnode = (GaimBlistNode*)g; | |
809 cnode = (GaimBlistNode*)contact; | |
810 | |
811 if(cnode->parent) { | |
6731 | 812 if(cnode->parent->child == cnode) |
813 cnode->parent->child = cnode->next; | |
6695 | 814 if(cnode->prev) |
815 cnode->prev->next = cnode->next; | |
816 if(cnode->next) | |
817 cnode->next->prev = cnode->prev; | |
818 | |
819 | |
820 if(contact->online > 0) | |
821 ((GaimGroup*)cnode->parent)->online--; | |
822 if(contact->currentsize > 0) | |
823 ((GaimGroup*)cnode->parent)->currentsize--; | |
824 ((GaimGroup*)cnode->parent)->totalsize--; | |
825 | |
6731 | 826 ops->remove(gaimbuddylist, cnode); |
827 | |
6695 | 828 save = TRUE; |
6742 | 829 |
830 if(cnode->parent != gnode) { | |
831 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
832 GaimBuddy *b = (GaimBuddy*)bnode; | |
833 | |
834 struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); | |
835 hb->name = g_strdup(normalize(b->name)); | |
836 hb->account = b->account; | |
837 hb->group = cnode->parent; | |
838 | |
6776 | 839 g_hash_table_remove(gaimbuddylist->buddies, hb); |
6742 | 840 |
841 hb->group = gnode; | |
842 g_hash_table_replace(gaimbuddylist->buddies, hb, b); | |
843 | |
844 if(b->account->gc) | |
845 serv_move_buddy(b, (GaimGroup*)cnode->parent, g); | |
846 } | |
847 } | |
6695 | 848 } |
849 | |
6775 | 850 |
6695 | 851 if(node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
852 GAIM_BLIST_NODE_IS_CHAT(node))) { | |
853 if(node->next) | |
854 node->next->prev = cnode; | |
855 cnode->next = node->next; | |
856 cnode->prev = node; | |
857 cnode->parent = node->parent; | |
858 node->next = cnode; | |
859 } else { | |
860 if(gnode->child) | |
861 gnode->child->prev = cnode; | |
862 cnode->prev = NULL; | |
863 cnode->next = gnode->child; | |
864 gnode->child = cnode; | |
865 cnode->parent = gnode; | |
866 } | |
867 | |
868 if(contact->online > 0) | |
869 g->online++; | |
870 if(contact->currentsize > 0) | |
871 g->currentsize++; | |
872 g->totalsize++; | |
873 | |
874 if(ops && cnode->child) | |
875 ops->update(gaimbuddylist, cnode); | |
6775 | 876 |
877 for(bnode = cnode->child; bnode; bnode = bnode->next) | |
878 ops->update(gaimbuddylist, bnode); | |
879 | |
6695 | 880 if (save) |
881 gaim_blist_save(); | |
882 } | |
883 | |
884 void gaim_blist_add_group (GaimGroup *group, GaimBlistNode *node) | |
5228 | 885 { |
886 struct gaim_blist_ui_ops *ops; | |
887 GaimBlistNode *gnode = (GaimBlistNode*)group; | |
888 gboolean save = FALSE; | |
889 | |
6774 | 890 g_return_if_fail(group != NULL); |
891 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP((GaimBlistNode*)group)); | |
892 | |
5228 | 893 if (!gaimbuddylist) |
894 gaimbuddylist = gaim_blist_new(); | |
895 ops = gaimbuddylist->ui_ops; | |
896 | |
897 if (!gaimbuddylist->root) { | |
898 gaimbuddylist->root = gnode; | |
899 return; | |
900 } | |
901 | |
902 /* if we're moving to overtop of ourselves, do nothing */ | |
903 if(gnode == node) | |
904 return; | |
905 | |
906 if (gaim_find_group(group->name)) { | |
907 /* This is just being moved */ | |
908 | |
909 ops->remove(gaimbuddylist, (GaimBlistNode*)group); | |
910 | |
911 if(gnode == gaimbuddylist->root) | |
912 gaimbuddylist->root = gnode->next; | |
913 if(gnode->prev) | |
914 gnode->prev->next = gnode->next; | |
915 if(gnode->next) | |
916 gnode->next->prev = gnode->prev; | |
917 | |
918 save = TRUE; | |
919 } | |
920 | |
6695 | 921 if (node && GAIM_BLIST_NODE_IS_GROUP(node)) { |
5634 | 922 gnode->next = node->next; |
923 gnode->prev = node; | |
924 if(node->next) | |
925 node->next->prev = gnode; | |
926 node->next = gnode; | |
927 } else { | |
6807 | 928 if(gaimbuddylist->root) |
929 gaimbuddylist->root->prev = gnode; | |
5634 | 930 gnode->next = gaimbuddylist->root; |
931 gnode->prev = NULL; | |
932 gaimbuddylist->root = gnode; | |
933 } | |
934 | |
5228 | 935 |
936 if (ops) { | |
937 ops->update(gaimbuddylist, gnode); | |
938 for(node = gnode->child; node; node = node->next) | |
939 ops->update(gaimbuddylist, node); | |
940 } | |
941 if (save) | |
942 gaim_blist_save(); | |
943 } | |
944 | |
6695 | 945 void gaim_blist_remove_contact(GaimContact* contact) |
5228 | 946 { |
947 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
948 | |
6695 | 949 GaimBlistNode *gnode, *cnode = (GaimBlistNode*)contact; |
950 | |
951 gnode = cnode->parent; | |
952 | |
953 if(cnode->child) { | |
954 while(cnode->child) { | |
955 gaim_blist_remove_buddy((GaimBuddy*)cnode->child); | |
956 } | |
957 } else { | |
958 if(ops) | |
959 ops->remove(gaimbuddylist, cnode); | |
960 | |
961 if(gnode->child == cnode) | |
962 gnode->child = cnode->next; | |
963 if(cnode->prev) | |
964 cnode->prev->next = cnode->next; | |
965 if(cnode->next) | |
966 cnode->next->prev = cnode->prev; | |
967 | |
968 g_free(contact); | |
969 } | |
970 } | |
971 | |
6742 | 972 void gaim_blist_remove_buddy (GaimBuddy *buddy) |
6695 | 973 { |
974 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
975 | |
976 GaimBlistNode *cnode, *node = (GaimBlistNode*)buddy; | |
977 GaimGroup *group; | |
6742 | 978 struct _gaim_hbuddy hb; |
5228 | 979 |
6695 | 980 cnode = node->parent; |
981 group = (GaimGroup *)cnode->parent; | |
5228 | 982 |
6695 | 983 if(GAIM_BUDDY_IS_ONLINE(buddy)) { |
984 ((GaimContact*)cnode)->online--; | |
985 if(((GaimContact*)cnode)->online == 0) | |
986 group->online--; | |
987 } | |
988 if(gaim_account_is_connected(buddy->account)) { | |
989 ((GaimContact*)cnode)->currentsize--; | |
990 if(((GaimContact*)cnode)->currentsize == 0) | |
991 group->currentsize--; | |
992 } | |
993 ((GaimContact*)cnode)->totalsize--; | |
994 | |
5228 | 995 if (node->prev) |
996 node->prev->next = node->next; | |
997 if (node->next) | |
998 node->next->prev = node->prev; | |
6695 | 999 if(cnode->child == node) { |
1000 cnode->child = node->next; | |
1001 } | |
5228 | 1002 |
6755 | 1003 |
5247 | 1004 hb.name = normalize(buddy->name); |
1005 hb.account = buddy->account; | |
6695 | 1006 hb.group = ((GaimBlistNode*)buddy)->parent->parent; |
6742 | 1007 g_hash_table_remove(gaimbuddylist->buddies, &hb); |
5247 | 1008 |
5292 | 1009 if(buddy->timer > 0) |
1010 g_source_remove(buddy->timer); | |
1011 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1012 if (buddy->icon != NULL) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1013 gaim_buddy_icon_unref(buddy->icon); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1014 |
5228 | 1015 ops->remove(gaimbuddylist, node); |
1016 g_hash_table_destroy(buddy->settings); | |
1017 g_free(buddy->name); | |
1018 g_free(buddy->alias); | |
1019 g_free(buddy); | |
6755 | 1020 |
1021 if(!cnode->child) | |
1022 gaim_blist_remove_contact((GaimContact*)cnode); | |
5228 | 1023 } |
1024 | |
6695 | 1025 void gaim_blist_remove_chat (GaimBlistChat *chat) |
5234 | 1026 { |
1027 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
1028 | |
1029 GaimBlistNode *gnode, *node = (GaimBlistNode*)chat; | |
6695 | 1030 GaimGroup *group; |
5234 | 1031 |
1032 gnode = node->parent; | |
6695 | 1033 group = (GaimGroup *)gnode; |
5234 | 1034 |
1035 if(gnode->child == node) | |
1036 gnode->child = node->next; | |
1037 if (node->prev) | |
1038 node->prev->next = node->next; | |
1039 if (node->next) | |
1040 node->next->prev = node->prev; | |
5277 | 1041 group->totalsize--; |
5855 | 1042 if (gaim_account_is_connected(chat->account)) { |
5277 | 1043 group->currentsize--; |
5394 | 1044 group->online--; |
1045 } | |
5234 | 1046 |
1047 ops->remove(gaimbuddylist, node); | |
1048 g_hash_table_destroy(chat->components); | |
1049 g_free(chat->alias); | |
1050 g_free(chat); | |
1051 } | |
1052 | |
6695 | 1053 void gaim_blist_remove_group (GaimGroup *group) |
5228 | 1054 { |
1055 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
1056 GaimBlistNode *node = (GaimBlistNode*)group; | |
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1057 GList *l; |
5228 | 1058 |
1059 if(node->child) { | |
1060 char *buf; | |
1061 int count = 0; | |
1062 GaimBlistNode *child = node->child; | |
1063 | |
1064 while(child) { | |
1065 count++; | |
1066 child = child->next; | |
1067 } | |
1068 | |
6308 | 1069 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed " |
1070 "because its account was not logged in." | |
1071 " This buddy and the group were not " | |
1072 "removed.\n", | |
1073 "%d buddies from group %s were not " | |
1074 "removed because their accounts were " | |
6336 | 1075 "not logged in. These buddies and " |
1076 "the group were not removed.\n", count), | |
6308 | 1077 count, group->name); |
5541
aee0ee458974
[gaim-migrate @ 5941]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1078 gaim_notify_error(NULL, NULL, _("Group not removed"), buf); |
5228 | 1079 g_free(buf); |
1080 return; | |
1081 } | |
1082 | |
1083 if(gaimbuddylist->root == node) | |
1084 gaimbuddylist->root = node->next; | |
1085 if (node->prev) | |
1086 node->prev->next = node->next; | |
1087 if (node->next) | |
1088 node->next->prev = node->prev; | |
1089 | |
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1090 for (l = gaim_connections_get_all(); l != NULL; l = l->next) |
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1091 { |
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1092 GaimConnection *gc = (GaimConnection *)l->data; |
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1093 |
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1094 if (gaim_connection_get_state(gc) == GAIM_CONNECTED) |
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1095 serv_remove_group(gc, group->name); |
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1096 } |
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1097 |
5228 | 1098 ops->remove(gaimbuddylist, node); |
1099 g_free(group->name); | |
1100 g_free(group); | |
1101 } | |
1102 | |
6695 | 1103 GaimBuddy *gaim_contact_get_priority_buddy(GaimContact *contact) { |
6843 | 1104 return contact->priority; |
6695 | 1105 } |
1106 | |
1107 const char *gaim_get_buddy_alias_only(GaimBuddy *b) { | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1108 if(!b) |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1109 return NULL; |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1110 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1111 if(b->alias && b->alias[0]) { |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1112 return b->alias; |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1113 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1114 else if (b->server_alias != NULL && |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1115 gaim_prefs_get_bool("/core/buddies/use_server_alias")) { |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1116 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1117 return b->server_alias; |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1118 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1119 |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1120 return NULL; |
5228 | 1121 } |
1122 | |
6695 | 1123 const char * gaim_get_buddy_alias (GaimBuddy *buddy) |
5228 | 1124 { |
6755 | 1125 GaimContact *contact; |
1126 const char *ret; | |
1127 | |
1128 if(!buddy) | |
1129 return _("Unknown"); | |
5228 | 1130 |
6755 | 1131 contact = (GaimContact*)((GaimBlistNode*)buddy)->parent; |
6036 | 1132 |
6755 | 1133 if(contact && contact->alias) |
1134 return contact->alias; | |
1135 | |
1136 ret= gaim_get_buddy_alias_only(buddy); | |
1137 | |
1138 return ret ? ret : buddy->name; | |
5228 | 1139 } |
1140 | |
6744 | 1141 const char *gaim_blist_chat_get_name(GaimBlistChat *chat) |
1142 { | |
1143 if(chat->alias && *chat->alias) { | |
1144 return chat->alias; | |
1145 } else { | |
1146 struct proto_chat_entry *pce; | |
1147 GList *parts, *tmp; | |
1148 char *ret; | |
1149 | |
1150 parts = GAIM_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc); | |
1151 pce = parts->data; | |
1152 ret = g_hash_table_lookup(chat->components, pce->identifier); | |
1153 for(tmp = parts; tmp; tmp = tmp->next) | |
1154 g_free(tmp->data); | |
1155 g_list_free(parts); | |
1156 | |
1157 return ret; | |
1158 } | |
1159 } | |
1160 | |
6695 | 1161 GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name) |
5228 | 1162 { |
6695 | 1163 GaimBuddy *buddy; |
5247 | 1164 struct _gaim_hbuddy hb; |
5758 | 1165 GaimBlistNode *group; |
5228 | 1166 |
1167 if (!gaimbuddylist) | |
1168 return NULL; | |
6245 | 1169 |
1170 if (!name) | |
5985
60d9cbfb6bf8
[gaim-migrate @ 6433]
Christian Hammond <chipx86@chipx86.com>
parents:
5947
diff
changeset
|
1171 return NULL; |
5228 | 1172 |
6245 | 1173 hb.name = normalize(name); |
1174 hb.account = account; | |
5247 | 1175 |
6245 | 1176 for(group = gaimbuddylist->root; group; group = group->next) { |
5758 | 1177 hb.group = group; |
5776 | 1178 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) |
5758 | 1179 return buddy; |
1180 } | |
6245 | 1181 |
5758 | 1182 return NULL; |
5228 | 1183 } |
1184 | |
6872 | 1185 GaimBuddy *gaim_find_buddy_in_group(GaimAccount *account, const char *name, |
1186 GaimGroup *group) | |
1187 { | |
1188 struct _gaim_hbuddy hb; | |
1189 | |
1190 if (!gaimbuddylist) | |
1191 return NULL; | |
1192 | |
1193 if (!name) | |
1194 return NULL; | |
1195 | |
1196 hb.name = normalize(name); | |
1197 hb.account = account; | |
1198 hb.group = (GaimBlistNode*)group; | |
1199 | |
1200 return g_hash_table_lookup(gaimbuddylist->buddies, &hb); | |
1201 } | |
1202 | |
6245 | 1203 GSList *gaim_find_buddies(GaimAccount *account, const char *name) |
1204 { | |
1205 struct buddy *buddy; | |
1206 struct _gaim_hbuddy hb; | |
1207 GaimBlistNode *group; | |
1208 GSList *ret = NULL; | |
1209 | |
1210 if (!gaimbuddylist) | |
1211 return NULL; | |
1212 | |
1213 if (!name) | |
1214 return NULL; | |
1215 | |
1216 hb.name = normalize(name); | |
1217 hb.account = account; | |
1218 | |
1219 for(group = gaimbuddylist->root; group; group = group->next) { | |
1220 hb.group = group; | |
1221 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) | |
1222 ret = g_slist_append(ret, buddy); | |
1223 } | |
1224 | |
1225 return ret; | |
1226 } | |
1227 | |
6695 | 1228 GaimGroup *gaim_find_group(const char *name) |
5228 | 1229 { |
1230 GaimBlistNode *node; | |
1231 if (!gaimbuddylist) | |
1232 return NULL; | |
1233 node = gaimbuddylist->root; | |
1234 while(node) { | |
6695 | 1235 if (!strcmp(((GaimGroup *)node)->name, name)) |
1236 return (GaimGroup *)node; | |
5228 | 1237 node = node->next; |
1238 } | |
1239 return NULL; | |
1240 } | |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1241 |
6695 | 1242 GaimBlistChat * |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1243 gaim_blist_find_chat(GaimAccount *account, const char *name) |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1244 { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1245 char *chat_name; |
6695 | 1246 GaimBlistChat *chat; |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1247 GaimPlugin *prpl; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1248 GaimPluginProtocolInfo *prpl_info = NULL; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1249 struct proto_chat_entry *pce; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1250 GaimBlistNode *node, *group; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1251 GList *parts; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1252 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1253 g_return_val_if_fail(gaim_get_blist() != NULL, NULL); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1254 g_return_val_if_fail(name != NULL, NULL); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1255 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1256 for (group = gaimbuddylist->root; group != NULL; group = group->next) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1257 for (node = group->child; node != NULL; node = node->next) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1258 if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1259 |
6695 | 1260 chat = (GaimBlistChat*)node; |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1261 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1262 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1263 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1264 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1265 parts = prpl_info->chat_info( |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1266 gaim_account_get_connection(chat->account)); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1267 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1268 pce = parts->data; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1269 chat_name = g_hash_table_lookup(chat->components, |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1270 pce->identifier); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1271 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1272 if (chat->account == account && |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1273 name != NULL && !strcmp(chat_name, name)) { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1274 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1275 return chat; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1276 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1277 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1278 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1279 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1280 |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1281 return NULL; |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1282 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1283 |
6695 | 1284 GaimGroup * |
1285 gaim_blist_chat_get_group(GaimBlistChat *chat) | |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1286 { |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1287 g_return_val_if_fail(chat != NULL, NULL); |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1288 |
6695 | 1289 return (GaimGroup *)(((GaimBlistNode *)chat)->parent); |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1290 } |
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1291 |
6695 | 1292 GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy) |
5228 | 1293 { |
1294 if (!buddy) | |
1295 return NULL; | |
6706
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1296 |
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1297 if (((GaimBlistNode *)buddy)->parent == NULL) |
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1298 return NULL; |
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1299 |
6695 | 1300 return (GaimGroup *)(((GaimBlistNode*)buddy)->parent->parent); |
5228 | 1301 } |
1302 | |
6695 | 1303 GSList *gaim_group_get_accounts(GaimGroup *g) |
5228 | 1304 { |
1305 GSList *l = NULL; | |
6695 | 1306 GaimBlistNode *gnode, *cnode, *bnode; |
1307 | |
1308 gnode = (GaimBlistNode *)g; | |
5228 | 1309 |
6695 | 1310 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
1311 if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
1312 if(!g_slist_find(l, ((GaimBlistChat *)cnode)->account)) | |
1313 l = g_slist_append(l, ((GaimBlistChat *)cnode)->account); | |
1314 } else if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
1315 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
1316 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
1317 if(!g_slist_find(l, ((GaimBuddy *)bnode)->account)) | |
1318 l = g_slist_append(l, ((GaimBuddy *)bnode)->account); | |
1319 } | |
1320 } | |
1321 } | |
5228 | 1322 } |
6695 | 1323 |
5228 | 1324 return l; |
1325 } | |
1326 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1327 void gaim_blist_add_account(GaimAccount *account) |
5234 | 1328 { |
1329 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
6695 | 1330 GaimBlistNode *gnode, *cnode, *bnode; |
5234 | 1331 |
1332 if(!gaimbuddylist) | |
1333 return; | |
1334 | |
6695 | 1335 if(!ops) |
1336 return; | |
1337 | |
1338 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
1339 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5234 | 1340 continue; |
6695 | 1341 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
1342 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
6956 | 1343 gboolean recompute = FALSE; |
6695 | 1344 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
1345 if(GAIM_BLIST_NODE_IS_BUDDY(bnode) && | |
1346 ((GaimBuddy*)bnode)->account == account) { | |
6956 | 1347 recompute = TRUE; |
6695 | 1348 ((GaimContact*)cnode)->currentsize++; |
1349 if(((GaimContact*)cnode)->currentsize == 1) | |
1350 ((GaimGroup*)gnode)->currentsize++; | |
1351 if(GAIM_BUDDY_IS_ONLINE((GaimBuddy*)bnode)) { | |
1352 ((GaimContact*)cnode)->online++; | |
1353 if(((GaimContact*)cnode)->online == 1) | |
1354 ((GaimGroup*)gnode)->online++; | |
1355 } | |
1356 ops->update(gaimbuddylist, bnode); | |
1357 } | |
1358 } | |
6956 | 1359 if(recompute) { |
1360 gaim_contact_compute_priority_buddy((GaimContact*)cnode); | |
1361 ops->update(gaimbuddylist, cnode); | |
1362 } | |
6695 | 1363 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
1364 ((GaimBlistChat*)cnode)->account == account) { | |
6901 | 1365 ((GaimGroup *)gnode)->online++; |
1366 ((GaimGroup *)gnode)->currentsize++; | |
1367 ops->update(gaimbuddylist, cnode); | |
5234 | 1368 } |
1369 } | |
6695 | 1370 ops->update(gaimbuddylist, gnode); |
5234 | 1371 } |
1372 } | |
1373 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1374 void gaim_blist_remove_account(GaimAccount *account) |
5228 | 1375 { |
1376 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
6695 | 1377 GaimBlistNode *gnode, *cnode, *bnode; |
5234 | 1378 |
5228 | 1379 if (!gaimbuddylist) |
1380 return; | |
5234 | 1381 |
6695 | 1382 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { |
1383 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5234 | 1384 continue; |
6695 | 1385 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
1386 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
6957 | 1387 gboolean recompute = FALSE; |
6695 | 1388 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
1389 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
1390 continue; | |
1391 if(account == ((GaimBuddy *)bnode)->account) { | |
6957 | 1392 recompute = TRUE; |
6695 | 1393 if(((GaimBuddy*)bnode)->present == GAIM_BUDDY_ONLINE || |
1394 ((GaimBuddy*)bnode)->present == GAIM_BUDDY_SIGNING_ON) { | |
1395 ((GaimContact*)cnode)->online--; | |
1396 if(((GaimContact*)cnode)->online == 0) | |
1397 ((GaimGroup*)gnode)->online--; | |
1398 } | |
1399 ((GaimContact*)cnode)->currentsize--; | |
1400 if(((GaimContact*)cnode)->currentsize == 0) | |
1401 ((GaimGroup*)gnode)->currentsize--; | |
1402 | |
1403 ((GaimBuddy*)bnode)->present = GAIM_BUDDY_OFFLINE; | |
1404 | |
6803 | 1405 ((GaimBuddy*)bnode)->uc = 0; |
1406 ((GaimBuddy*)bnode)->idle = 0; | |
1407 ((GaimBuddy*)bnode)->evil = 0; | |
1408 | |
6945 | 1409 |
6695 | 1410 if(ops) |
1411 ops->remove(gaimbuddylist, bnode); | |
1412 } | |
5234 | 1413 } |
6959 | 1414 if(recompute) { |
1415 gaim_contact_compute_priority_buddy((GaimContact*)cnode); | |
1416 if(ops) | |
1417 ops->remove(gaimbuddylist, bnode); | |
1418 } | |
6695 | 1419 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
1420 ((GaimBlistChat*)cnode)->account == account) { | |
1421 ((GaimGroup*)gnode)->currentsize--; | |
1422 ((GaimGroup*)gnode)->online--; | |
1423 if(ops) | |
1424 ops->remove(gaimbuddylist, cnode); | |
5228 | 1425 } |
1426 } | |
1427 } | |
1428 } | |
1429 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1430 void parse_toc_buddy_list(GaimAccount *account, char *config) |
5228 | 1431 { |
1432 char *c; | |
1433 char current[256]; | |
1434 GList *bud = NULL; | |
1435 | |
1436 | |
1437 if (config != NULL) { | |
1438 | |
1439 /* skip "CONFIG:" (if it exists) */ | |
1440 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ? | |
1441 strtok(config, "\n") : | |
1442 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n"); | |
1443 do { | |
1444 if (c == NULL) | |
1445 break; | |
1446 if (*c == 'g') { | |
1447 char *utf8 = NULL; | |
1448 utf8 = gaim_try_conv_to_utf8(c + 2); | |
1449 if (utf8 == NULL) { | |
1450 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); | |
1451 } else { | |
1452 g_strlcpy(current, utf8, sizeof(current)); | |
1453 g_free(utf8); | |
1454 } | |
1455 if (!gaim_find_group(current)) { | |
6695 | 1456 GaimGroup *g = gaim_group_new(current); |
5634 | 1457 gaim_blist_add_group(g, |
1458 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5228 | 1459 } |
1460 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ | |
1461 char nm[80], sw[388], *a, *utf8 = NULL; | |
1462 | |
1463 if ((a = strchr(c + 2, ':')) != NULL) { | |
1464 *a++ = '\0'; /* nul the : */ | |
1465 } | |
1466 | |
1467 g_strlcpy(nm, c + 2, sizeof(nm)); | |
1468 if (a) { | |
1469 utf8 = gaim_try_conv_to_utf8(a); | |
1470 if (utf8 == NULL) { | |
1471 gaim_debug(GAIM_DEBUG_ERROR, "toc blist", | |
1472 "Failed to convert alias for " | |
1473 "'%s' to UTF-8\n", nm); | |
1474 } | |
1475 } | |
1476 if (utf8 == NULL) { | |
1477 sw[0] = '\0'; | |
1478 } else { | |
1479 /* This can leave a partial sequence at the end, | |
1480 * but who cares? */ | |
1481 g_strlcpy(sw, utf8, sizeof(sw)); | |
1482 g_free(utf8); | |
1483 } | |
1484 | |
1485 if (!gaim_find_buddy(account, nm)) { | |
6695 | 1486 GaimBuddy *b = gaim_buddy_new(account, nm, sw); |
1487 GaimGroup *g = gaim_find_group(current); | |
1488 gaim_blist_add_buddy(b, NULL, g, | |
5634 | 1489 gaim_blist_get_last_child((GaimBlistNode*)g)); |
5228 | 1490 bud = g_list_append(bud, g_strdup(nm)); |
1491 } | |
1492 } else if (*c == 'p') { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1493 gaim_privacy_permit_add(account, c + 2, TRUE); |
5228 | 1494 } else if (*c == 'd') { |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1495 gaim_privacy_deny_add(account, c + 2, TRUE); |
5228 | 1496 } else if (!strncmp("toc", c, 3)) { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1497 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); |
5228 | 1498 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1499 "permdeny: %d\n", account->perm_deny); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1500 if (account->perm_deny == 0) |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1501 account->perm_deny = 1; |
5228 | 1502 } else if (*c == 'm') { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1503 sscanf(c + 2, "%d", &account->perm_deny); |
5228 | 1504 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1505 "permdeny: %d\n", account->perm_deny); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1506 if (account->perm_deny == 0) |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1507 account->perm_deny = 1; |
5228 | 1508 } |
1509 } while ((c = strtok(NULL, "\n"))); | |
1510 | |
1511 if(account->gc) { | |
1512 if(bud) { | |
1513 GList *node = bud; | |
1514 serv_add_buddies(account->gc, bud); | |
1515 while(node) { | |
1516 g_free(node->data); | |
1517 node = node->next; | |
1518 } | |
1519 } | |
1520 serv_set_permit_deny(account->gc); | |
1521 } | |
1522 g_list_free(bud); | |
1523 } | |
1524 } | |
1525 | |
1526 #if 0 | |
1527 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */ | |
1528 static GString *translate_lst(FILE *src_fp) | |
1529 { | |
1530 char line[BUF_LEN], *line2; | |
1531 char *name; | |
1532 int i; | |
1533 | |
1534 GString *dest = g_string_new("m 1\n"); | |
1535 | |
1536 while (fgets(line, BUF_LEN, src_fp)) { | |
1537 line2 = g_strchug(line); | |
1538 if (strstr(line2, "group") == line2) { | |
1539 name = strpbrk(line2, " \t\n\r\f") + 1; | |
1540 dest = g_string_append(dest, "g "); | |
1541 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
1542 if (name[i] != '\"') | |
1543 dest = g_string_append_c(dest, name[i]); | |
1544 dest = g_string_append_c(dest, '\n'); | |
1545 } | |
1546 if (strstr(line2, "buddy") == line2) { | |
1547 name = strpbrk(line2, " \t\n\r\f") + 1; | |
1548 dest = g_string_append(dest, "b "); | |
1549 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
1550 if (name[i] != '\"') | |
1551 dest = g_string_append_c(dest, name[i]); | |
1552 dest = g_string_append_c(dest, '\n'); | |
1553 } | |
1554 } | |
1555 | |
1556 return dest; | |
1557 } | |
1558 | |
1559 | |
1560 /* translate an AIM 4 buddylist (*.blt) to Gaim format */ | |
1561 static GString *translate_blt(FILE *src_fp) | |
1562 { | |
1563 int i; | |
1564 char line[BUF_LEN]; | |
1565 char *buddy; | |
1566 | |
1567 GString *dest = g_string_new("m 1\n"); | |
1568 | |
1569 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL); | |
1570 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL); | |
1571 | |
1572 while (1) { | |
1573 fgets(line, BUF_LEN, src_fp); g_strchomp(line); | |
1574 if (strchr(line, '}') != NULL) | |
1575 break; | |
1576 | |
1577 if (strchr(line, '{') != NULL) { | |
1578 /* Syntax starting with "<group> {" */ | |
1579 | |
1580 dest = g_string_append(dest, "g "); | |
1581 buddy = g_strchug(strtok(line, "{")); | |
1582 for (i = 0; i < strlen(buddy); i++) | |
1583 if (buddy[i] != '\"') | |
1584 dest = g_string_append_c(dest, buddy[i]); | |
1585 dest = g_string_append_c(dest, '\n'); | |
1586 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) { | |
1587 gboolean pounce = FALSE; | |
1588 char *e; | |
1589 g_strchomp(line); | |
1590 buddy = g_strchug(line); | |
1591 gaim_debug(GAIM_DEBUG_MISC, "AIM 4 blt import", | |
1592 "buddy: \"%s\"\n", buddy); | |
1593 dest = g_string_append(dest, "b "); | |
1594 if (strchr(buddy, '{') != NULL) { | |
1595 /* buddy pounce, etc */ | |
1596 char *pos = strchr(buddy, '{') - 1; | |
1597 *pos = 0; | |
1598 pounce = TRUE; | |
1599 } | |
1600 if ((e = strchr(buddy, '\"')) != NULL) { | |
1601 *e = '\0'; | |
1602 buddy++; | |
1603 } | |
1604 dest = g_string_append(dest, buddy); | |
1605 dest = g_string_append_c(dest, '\n'); | |
1606 if (pounce) | |
1607 do | |
1608 fgets(line, BUF_LEN, src_fp); | |
1609 while (!strchr(line, '}')); | |
1610 } | |
1611 } else { | |
1612 | |
1613 /* Syntax "group buddy buddy ..." */ | |
1614 buddy = g_strchug(strtok(line, " \n")); | |
1615 dest = g_string_append(dest, "g "); | |
1616 if (strchr(buddy, '\"') != NULL) { | |
1617 dest = g_string_append(dest, &buddy[1]); | |
1618 dest = g_string_append_c(dest, ' '); | |
1619 buddy = g_strchug(strtok(NULL, " \n")); | |
1620 while (strchr(buddy, '\"') == NULL) { | |
1621 dest = g_string_append(dest, buddy); | |
1622 dest = g_string_append_c(dest, ' '); | |
1623 buddy = g_strchug(strtok(NULL, " \n")); | |
1624 } | |
1625 buddy[strlen(buddy) - 1] = '\0'; | |
1626 dest = g_string_append(dest, buddy); | |
1627 } else { | |
1628 dest = g_string_append(dest, buddy); | |
1629 } | |
1630 dest = g_string_append_c(dest, '\n'); | |
1631 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) { | |
1632 dest = g_string_append(dest, "b "); | |
1633 if (strchr(buddy, '\"') != NULL) { | |
1634 dest = g_string_append(dest, &buddy[1]); | |
1635 dest = g_string_append_c(dest, ' '); | |
1636 buddy = g_strchug(strtok(NULL, " \n")); | |
1637 while (strchr(buddy, '\"') == NULL) { | |
1638 dest = g_string_append(dest, buddy); | |
1639 dest = g_string_append_c(dest, ' '); | |
1640 buddy = g_strchug(strtok(NULL, " \n")); | |
1641 } | |
1642 buddy[strlen(buddy) - 1] = '\0'; | |
1643 dest = g_string_append(dest, buddy); | |
1644 } else { | |
1645 dest = g_string_append(dest, buddy); | |
1646 } | |
1647 dest = g_string_append_c(dest, '\n'); | |
1648 } | |
1649 } | |
1650 } | |
1651 | |
1652 return dest; | |
1653 } | |
1654 | |
1655 static GString *translate_gnomeicu(FILE *src_fp) | |
1656 { | |
1657 char line[BUF_LEN]; | |
1658 GString *dest = g_string_new("m 1\ng Buddies\n"); | |
1659 | |
1660 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL); | |
1661 | |
1662 while (fgets(line, BUF_LEN, src_fp)) { | |
1663 char *eq; | |
1664 g_strchomp(line); | |
1665 if (line[0] == '\n' || line[0] == '[') | |
1666 break; | |
1667 eq = strchr(line, '='); | |
1668 if (!eq) | |
1669 break; | |
1670 *eq = ':'; | |
1671 eq = strchr(eq, ','); | |
1672 if (eq) | |
1673 *eq = '\0'; | |
1674 dest = g_string_append(dest, "b "); | |
1675 dest = g_string_append(dest, line); | |
1676 dest = g_string_append_c(dest, '\n'); | |
1677 } | |
1678 | |
1679 return dest; | |
1680 } | |
1681 #endif | |
1682 | |
1683 static gchar *get_screenname_filename(const char *name) | |
1684 { | |
1685 gchar **split; | |
1686 gchar *good; | |
1687 gchar *ret; | |
1688 | |
1689 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1); | |
1690 good = g_strjoinv(NULL, split); | |
1691 g_strfreev(split); | |
1692 | |
1693 ret = g_utf8_strup(good, -1); | |
1694 | |
1695 g_free(good); | |
1696 | |
1697 return ret; | |
1698 } | |
1699 | |
1700 static gboolean gaim_blist_read(const char *filename); | |
1701 | |
1702 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1703 static void do_import(GaimAccount *account, const char *filename) |
5228 | 1704 { |
1705 GString *buf = NULL; | |
1706 char first[64]; | |
1707 char path[PATHSIZE]; | |
1708 int len; | |
1709 FILE *f; | |
1710 struct stat st; | |
1711 | |
1712 if (filename) { | |
1713 g_snprintf(path, sizeof(path), "%s", filename); | |
1714 } else { | |
1715 char *g_screenname = get_screenname_filename(account->username); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1716 const char *username; |
5228 | 1717 char *file = gaim_user_dir(); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1718 GaimProtocol prpl_num; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1719 int protocol; |
6695 | 1720 |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1721 prpl_num = gaim_account_get_protocol(account); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1722 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1723 protocol = prpl_num; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1724 |
6450
e7b87c8e8c0a
[gaim-migrate @ 6959]
Christian Hammond <chipx86@chipx86.com>
parents:
6392
diff
changeset
|
1725 /* TODO Somehow move this checking into prpls */ |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1726 if (prpl_num == GAIM_PROTO_OSCAR) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1727 if ((username = gaim_account_get_username(account)) != NULL) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1728 protocol = (isalpha(*username) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1729 ? GAIM_PROTO_TOC : GAIM_PROTO_ICQ); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1730 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1731 } |
5228 | 1732 |
1733 if (file != (char *)NULL) { | |
5435 | 1734 snprintf(path, PATHSIZE, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol); |
5228 | 1735 g_free(g_screenname); |
1736 } else { | |
1737 g_free(g_screenname); | |
1738 return; | |
1739 } | |
1740 } | |
1741 | |
1742 if (stat(path, &st)) { | |
1743 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to stat %s.\n", | |
1744 path); | |
1745 return; | |
1746 } | |
1747 | |
1748 if (!(f = fopen(path, "r"))) { | |
1749 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to open %s.\n", | |
1750 path); | |
1751 return; | |
1752 } | |
1753 | |
1754 fgets(first, 64, f); | |
1755 | |
1756 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n')) | |
1757 fgets(first, 64, f); | |
1758 | |
1759 #if 0 | |
1760 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) { | |
1761 /* new gaim XML buddy list */ | |
1762 gaim_blist_read(path); | |
1763 | |
1764 /* We really don't need to bother doing stuf like translating AIM 3 buddy lists anymore */ | |
1765 | |
1766 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) { | |
1767 /* AIM 4 buddy list */ | |
1768 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 4\n"); | |
1769 rewind(f); | |
1770 buf = translate_blt(f); | |
1771 } else if (strstr(first, "group") != NULL) { | |
1772 /* AIM 3 buddy list */ | |
1773 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 3\n"); | |
1774 rewind(f); | |
1775 buf = translate_lst(f); | |
1776 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) { | |
1777 /* GnomeICU (hopefully) */ | |
1778 gaim_debug(GAIM_DEBUG_MISC, "blist import", "gnomeicu\n"); | |
1779 rewind(f); | |
1780 buf = translate_gnomeicu(f); | |
1781 | |
1782 } else | |
1783 #endif | |
1784 if (first[0] == 'm') { | |
1785 /* Gaim buddy list - no translation */ | |
1786 char buf2[BUF_LONG * 2]; | |
1787 buf = g_string_new(""); | |
1788 rewind(f); | |
1789 while (1) { | |
1790 len = fread(buf2, 1, BUF_LONG * 2 - 1, f); | |
1791 if (len <= 0) | |
1792 break; | |
1793 buf2[len] = '\0'; | |
1794 buf = g_string_append(buf, buf2); | |
1795 if (len != BUF_LONG * 2 - 1) | |
1796 break; | |
1797 } | |
1798 } | |
1799 | |
1800 fclose(f); | |
1801 | |
1802 if (buf) { | |
1803 buf = g_string_prepend(buf, "toc_set_config {"); | |
1804 buf = g_string_append(buf, "}\n"); | |
1805 parse_toc_buddy_list(account, buf->str); | |
1806 g_string_free(buf, TRUE); | |
1807 } | |
1808 } | |
1809 | |
6695 | 1810 gboolean gaim_group_on_account(GaimGroup *g, GaimAccount *account) { |
1811 GaimBlistNode *cnode, *bnode; | |
1812 for(cnode = ((GaimBlistNode *)g)->child; cnode; cnode = cnode->next) { | |
1813 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
1814 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
1815 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
1816 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
1817 if((!account && gaim_account_is_connected(buddy->account)) | |
1818 || buddy->account == account) | |
1819 return TRUE; | |
1820 } | |
1821 } | |
1822 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
1823 GaimBlistChat *chat = (GaimBlistChat *)cnode; | |
1824 if((!account && gaim_account_is_connected(chat->account)) | |
1825 || chat->account == account) | |
1826 return TRUE; | |
1827 } | |
5228 | 1828 } |
1829 return FALSE; | |
1830 } | |
1831 | |
1832 static gboolean blist_safe_to_write = FALSE; | |
1833 | |
6695 | 1834 GaimGroup *blist_parser_group = NULL; |
1835 GaimContact *blist_parser_contact = NULL; | |
5228 | 1836 static char *blist_parser_account_name = NULL; |
1837 static int blist_parser_account_protocol = 0; | |
5234 | 1838 static char *blist_parser_chat_alias = NULL; |
1839 static char *blist_parser_component_name = NULL; | |
1840 static char *blist_parser_component_value = NULL; | |
5228 | 1841 static char *blist_parser_buddy_name = NULL; |
1842 static char *blist_parser_buddy_alias = NULL; | |
1843 static char *blist_parser_setting_name = NULL; | |
1844 static char *blist_parser_setting_value = NULL; | |
1845 static GHashTable *blist_parser_buddy_settings = NULL; | |
5906 | 1846 static GHashTable *blist_parser_chat_settings = NULL; |
5228 | 1847 static GHashTable *blist_parser_group_settings = NULL; |
5234 | 1848 static GHashTable *blist_parser_chat_components = NULL; |
5228 | 1849 static int blist_parser_privacy_mode = 0; |
1850 static GList *tag_stack = NULL; | |
1851 enum { | |
1852 BLIST_TAG_GAIM, | |
1853 BLIST_TAG_BLIST, | |
1854 BLIST_TAG_GROUP, | |
5234 | 1855 BLIST_TAG_CHAT, |
1856 BLIST_TAG_COMPONENT, | |
6695 | 1857 BLIST_TAG_CONTACT, |
5228 | 1858 BLIST_TAG_BUDDY, |
1859 BLIST_TAG_NAME, | |
1860 BLIST_TAG_ALIAS, | |
1861 BLIST_TAG_SETTING, | |
1862 BLIST_TAG_PRIVACY, | |
1863 BLIST_TAG_ACCOUNT, | |
1864 BLIST_TAG_PERMIT, | |
1865 BLIST_TAG_BLOCK, | |
1866 BLIST_TAG_IGNORE | |
1867 }; | |
1868 static gboolean blist_parser_error_occurred = FALSE; | |
1869 | |
1870 static void blist_start_element_handler (GMarkupParseContext *context, | |
1871 const gchar *element_name, | |
1872 const gchar **attribute_names, | |
1873 const gchar **attribute_values, | |
1874 gpointer user_data, | |
1875 GError **error) { | |
1876 int i; | |
1877 | |
1878 if(!strcmp(element_name, "gaim")) { | |
1879 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GAIM)); | |
1880 } else if(!strcmp(element_name, "blist")) { | |
1881 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLIST)); | |
1882 } else if(!strcmp(element_name, "group")) { | |
6803 | 1883 const char *name = NULL; |
5228 | 1884 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GROUP)); |
1885 for(i=0; attribute_names[i]; i++) { | |
1886 if(!strcmp(attribute_names[i], "name")) { | |
6778 | 1887 name = attribute_values[i]; |
5228 | 1888 } |
1889 } | |
6778 | 1890 if(name) { |
1891 blist_parser_group = gaim_group_new(name); | |
6695 | 1892 gaim_blist_add_group(blist_parser_group, |
5634 | 1893 gaim_blist_get_last_sibling(gaimbuddylist->root)); |
5228 | 1894 } |
6695 | 1895 } else if(!strcmp(element_name, "contact")) { |
6755 | 1896 char *alias = NULL; |
6695 | 1897 tag_stack = g_list_prepend(tag_stack, |
1898 GINT_TO_POINTER(BLIST_TAG_CONTACT)); | |
1899 | |
6755 | 1900 for(i=0; attribute_names[i]; i++) { |
1901 if(!strcmp(attribute_names[i], "alias")) { | |
1902 g_free(alias); | |
1903 alias = g_strdup(attribute_values[i]); | |
1904 } | |
1905 } | |
1906 | |
6695 | 1907 blist_parser_contact = gaim_contact_new(); |
1908 gaim_blist_add_contact(blist_parser_contact, blist_parser_group, | |
1909 gaim_blist_get_last_sibling(((GaimBlistNode*)blist_parser_group)->child)); | |
6755 | 1910 |
1911 if(alias) { | |
1912 gaim_contact_set_alias(blist_parser_contact, alias); | |
1913 g_free(alias); | |
1914 } | |
5234 | 1915 } else if(!strcmp(element_name, "chat")) { |
1916 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_CHAT)); | |
1917 for(i=0; attribute_names[i]; i++) { | |
1918 if(!strcmp(attribute_names[i], "account")) { | |
1919 g_free(blist_parser_account_name); | |
1920 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1921 } else if(!strcmp(attribute_names[i], "protocol")) { | |
1922 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1923 } | |
1924 } | |
5228 | 1925 } else if(!strcmp(element_name, "buddy")) { |
1926 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BUDDY)); | |
1927 for(i=0; attribute_names[i]; i++) { | |
1928 if(!strcmp(attribute_names[i], "account")) { | |
1929 g_free(blist_parser_account_name); | |
1930 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1931 } else if(!strcmp(attribute_names[i], "protocol")) { | |
1932 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1933 } | |
1934 } | |
1935 } else if(!strcmp(element_name, "name")) { | |
1936 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_NAME)); | |
1937 } else if(!strcmp(element_name, "alias")) { | |
1938 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ALIAS)); | |
1939 } else if(!strcmp(element_name, "setting")) { | |
1940 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_SETTING)); | |
1941 for(i=0; attribute_names[i]; i++) { | |
1942 if(!strcmp(attribute_names[i], "name")) { | |
1943 g_free(blist_parser_setting_name); | |
1944 blist_parser_setting_name = g_strdup(attribute_values[i]); | |
1945 } | |
1946 } | |
5234 | 1947 } else if(!strcmp(element_name, "component")) { |
1948 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_COMPONENT)); | |
1949 for(i=0; attribute_names[i]; i++) { | |
1950 if(!strcmp(attribute_names[i], "name")) { | |
1951 g_free(blist_parser_component_name); | |
1952 blist_parser_component_name = g_strdup(attribute_values[i]); | |
1953 } | |
1954 } | |
1955 | |
5228 | 1956 } else if(!strcmp(element_name, "privacy")) { |
1957 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PRIVACY)); | |
1958 } else if(!strcmp(element_name, "account")) { | |
1959 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ACCOUNT)); | |
1960 for(i=0; attribute_names[i]; i++) { | |
1961 if(!strcmp(attribute_names[i], "protocol")) | |
1962 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1963 else if(!strcmp(attribute_names[i], "mode")) | |
1964 blist_parser_privacy_mode = atoi(attribute_values[i]); | |
1965 else if(!strcmp(attribute_names[i], "name")) { | |
1966 g_free(blist_parser_account_name); | |
1967 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1968 } | |
1969 } | |
1970 } else if(!strcmp(element_name, "permit")) { | |
1971 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERMIT)); | |
1972 } else if(!strcmp(element_name, "block")) { | |
1973 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLOCK)); | |
1974 } else if(!strcmp(element_name, "ignore")) { | |
1975 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_IGNORE)); | |
1976 } | |
1977 } | |
1978 | |
1979 static void blist_end_element_handler(GMarkupParseContext *context, | |
1980 const gchar *element_name, gpointer user_data, GError **error) { | |
1981 if(!strcmp(element_name, "gaim")) { | |
1982 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1983 } else if(!strcmp(element_name, "blist")) { | |
1984 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1985 } else if(!strcmp(element_name, "group")) { | |
1986 if(blist_parser_group_settings) { | |
6778 | 1987 g_hash_table_destroy(blist_parser_group->settings); |
1988 blist_parser_group->settings = blist_parser_group_settings; | |
5228 | 1989 } |
1990 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1991 blist_parser_group_settings = NULL; | |
6695 | 1992 blist_parser_group = NULL; |
5234 | 1993 } else if(!strcmp(element_name, "chat")) { |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1994 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5234 | 1995 blist_parser_account_protocol); |
5237 | 1996 if(account) { |
6695 | 1997 GaimBlistChat *chat = gaim_blist_chat_new(account, |
1998 blist_parser_chat_alias, blist_parser_chat_components); | |
6778 | 1999 gaim_blist_add_chat(chat,blist_parser_group, |
2000 gaim_blist_get_last_child((GaimBlistNode*)blist_parser_group)); | |
5906 | 2001 if(blist_parser_chat_settings) { |
2002 g_hash_table_destroy(chat->settings); | |
2003 chat->settings = blist_parser_chat_settings; | |
2004 } | |
5234 | 2005 } |
2006 g_free(blist_parser_chat_alias); | |
2007 blist_parser_chat_alias = NULL; | |
2008 g_free(blist_parser_account_name); | |
2009 blist_parser_account_name = NULL; | |
2010 blist_parser_chat_components = NULL; | |
5906 | 2011 blist_parser_chat_settings = NULL; |
5234 | 2012 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
6695 | 2013 } else if(!strcmp(element_name, "contact")) { |
2014 if(blist_parser_contact && !blist_parser_contact->node.child) | |
2015 gaim_blist_remove_contact(blist_parser_contact); | |
2016 blist_parser_contact = NULL; | |
5228 | 2017 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
2018 } else if(!strcmp(element_name, "buddy")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2019 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2020 blist_parser_account_protocol); |
6872 | 2021 if(account && !gaim_find_buddy_in_group(account, |
2022 blist_parser_buddy_name, blist_parser_group)) { | |
2023 GaimBuddy *b = gaim_buddy_new(account, blist_parser_buddy_name, | |
2024 blist_parser_buddy_alias); | |
6695 | 2025 gaim_blist_add_buddy(b,blist_parser_contact, blist_parser_group, |
2026 gaim_blist_get_last_child((GaimBlistNode*)blist_parser_contact)); | |
5228 | 2027 if(blist_parser_buddy_settings) { |
2028 g_hash_table_destroy(b->settings); | |
2029 b->settings = blist_parser_buddy_settings; | |
2030 } | |
2031 } | |
2032 g_free(blist_parser_buddy_name); | |
2033 blist_parser_buddy_name = NULL; | |
2034 g_free(blist_parser_buddy_alias); | |
2035 blist_parser_buddy_alias = NULL; | |
2036 g_free(blist_parser_account_name); | |
2037 blist_parser_account_name = NULL; | |
2038 blist_parser_buddy_settings = NULL; | |
2039 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2040 } else if(!strcmp(element_name, "name")) { | |
2041 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2042 } else if(!strcmp(element_name, "alias")) { | |
2043 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
5234 | 2044 } else if(!strcmp(element_name, "component")) { |
2045 if(!blist_parser_chat_components) | |
2046 blist_parser_chat_components = g_hash_table_new_full(g_str_hash, | |
2047 g_str_equal, g_free, g_free); | |
2048 if(blist_parser_component_name && blist_parser_component_value) { | |
2049 g_hash_table_replace(blist_parser_chat_components, | |
2050 g_strdup(blist_parser_component_name), | |
2051 g_strdup(blist_parser_component_value)); | |
2052 } | |
2053 g_free(blist_parser_component_name); | |
2054 g_free(blist_parser_component_value); | |
2055 blist_parser_component_name = NULL; | |
2056 blist_parser_component_value = NULL; | |
2057 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
5228 | 2058 } else if(!strcmp(element_name, "setting")) { |
2059 if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) { | |
2060 if(!blist_parser_buddy_settings) | |
2061 blist_parser_buddy_settings = g_hash_table_new_full(g_str_hash, | |
2062 g_str_equal, g_free, g_free); | |
2063 if(blist_parser_setting_name && blist_parser_setting_value) { | |
2064 g_hash_table_replace(blist_parser_buddy_settings, | |
2065 g_strdup(blist_parser_setting_name), | |
2066 g_strdup(blist_parser_setting_value)); | |
2067 } | |
5906 | 2068 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) { |
2069 if(!blist_parser_chat_settings) | |
2070 blist_parser_chat_settings = g_hash_table_new_full(g_str_hash, | |
2071 g_str_equal, g_free, g_free); | |
2072 if(blist_parser_setting_name && blist_parser_setting_value) { | |
6307 | 2073 g_hash_table_replace(blist_parser_chat_settings, |
5906 | 2074 g_strdup(blist_parser_setting_name), |
2075 g_strdup(blist_parser_setting_value)); | |
2076 } | |
5228 | 2077 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_GROUP) { |
2078 if(!blist_parser_group_settings) | |
2079 blist_parser_group_settings = g_hash_table_new_full(g_str_hash, | |
2080 g_str_equal, g_free, g_free); | |
2081 if(blist_parser_setting_name && blist_parser_setting_value) { | |
2082 g_hash_table_replace(blist_parser_group_settings, | |
2083 g_strdup(blist_parser_setting_name), | |
2084 g_strdup(blist_parser_setting_value)); | |
2085 } | |
2086 } | |
2087 g_free(blist_parser_setting_name); | |
2088 g_free(blist_parser_setting_value); | |
2089 blist_parser_setting_name = NULL; | |
2090 blist_parser_setting_value = NULL; | |
2091 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2092 } else if(!strcmp(element_name, "privacy")) { | |
2093 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2094 } else if(!strcmp(element_name, "account")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2095 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2096 blist_parser_account_protocol); |
2097 if(account) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2098 account->perm_deny = blist_parser_privacy_mode; |
5228 | 2099 } |
2100 g_free(blist_parser_account_name); | |
2101 blist_parser_account_name = NULL; | |
2102 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2103 } else if(!strcmp(element_name, "permit")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2104 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2105 blist_parser_account_protocol); |
2106 if(account) { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
2107 gaim_privacy_permit_add(account, blist_parser_buddy_name, TRUE); |
5228 | 2108 } |
2109 g_free(blist_parser_buddy_name); | |
2110 blist_parser_buddy_name = NULL; | |
2111 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2112 } else if(!strcmp(element_name, "block")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2113 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2114 blist_parser_account_protocol); |
2115 if(account) { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
2116 gaim_privacy_deny_add(account, blist_parser_buddy_name, TRUE); |
5228 | 2117 } |
2118 g_free(blist_parser_buddy_name); | |
2119 blist_parser_buddy_name = NULL; | |
2120 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2121 } else if(!strcmp(element_name, "ignore")) { | |
2122 /* we'll apparently do something with this later */ | |
2123 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2124 } | |
2125 } | |
2126 | |
2127 static void blist_text_handler(GMarkupParseContext *context, const gchar *text, | |
2128 gsize text_len, gpointer user_data, GError **error) { | |
2129 switch(GPOINTER_TO_INT(tag_stack->data)) { | |
2130 case BLIST_TAG_NAME: | |
2131 blist_parser_buddy_name = g_strndup(text, text_len); | |
2132 break; | |
2133 case BLIST_TAG_ALIAS: | |
5234 | 2134 if(tag_stack->next && |
2135 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) | |
2136 blist_parser_buddy_alias = g_strndup(text, text_len); | |
2137 else if(tag_stack->next && | |
2138 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) | |
2139 blist_parser_chat_alias = g_strndup(text, text_len); | |
5228 | 2140 break; |
2141 case BLIST_TAG_PERMIT: | |
2142 case BLIST_TAG_BLOCK: | |
2143 case BLIST_TAG_IGNORE: | |
2144 blist_parser_buddy_name = g_strndup(text, text_len); | |
2145 break; | |
5234 | 2146 case BLIST_TAG_COMPONENT: |
2147 blist_parser_component_value = g_strndup(text, text_len); | |
2148 break; | |
5228 | 2149 case BLIST_TAG_SETTING: |
2150 blist_parser_setting_value = g_strndup(text, text_len); | |
2151 break; | |
2152 default: | |
2153 break; | |
2154 } | |
2155 } | |
2156 | |
2157 static void blist_error_handler(GMarkupParseContext *context, GError *error, | |
2158 gpointer user_data) { | |
2159 blist_parser_error_occurred = TRUE; | |
2160 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
2161 "Error parsing blist.xml: %s\n", error->message); | |
2162 } | |
2163 | |
2164 static GMarkupParser blist_parser = { | |
2165 blist_start_element_handler, | |
2166 blist_end_element_handler, | |
2167 blist_text_handler, | |
2168 NULL, | |
2169 blist_error_handler | |
2170 }; | |
2171 | |
2172 static gboolean gaim_blist_read(const char *filename) { | |
2173 gchar *contents = NULL; | |
2174 gsize length; | |
2175 GMarkupParseContext *context; | |
2176 GError *error = NULL; | |
2177 | |
2178 gaim_debug(GAIM_DEBUG_INFO, "blist import", | |
2179 "Reading %s\n", filename); | |
2180 if(!g_file_get_contents(filename, &contents, &length, &error)) { | |
2181 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
2182 "Error reading blist: %s\n", error->message); | |
2183 g_error_free(error); | |
2184 return FALSE; | |
2185 } | |
2186 | |
2187 context = g_markup_parse_context_new(&blist_parser, 0, NULL, NULL); | |
2188 | |
2189 if(!g_markup_parse_context_parse(context, contents, length, NULL)) { | |
2190 g_markup_parse_context_free(context); | |
2191 g_free(contents); | |
2192 return FALSE; | |
2193 } | |
2194 | |
2195 if(!g_markup_parse_context_end_parse(context, NULL)) { | |
2196 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
2197 "Error parsing %s\n", filename); | |
2198 g_markup_parse_context_free(context); | |
2199 g_free(contents); | |
2200 return FALSE; | |
2201 } | |
2202 | |
2203 g_markup_parse_context_free(context); | |
2204 g_free(contents); | |
2205 | |
2206 if(blist_parser_error_occurred) | |
2207 return FALSE; | |
2208 | |
2209 gaim_debug(GAIM_DEBUG_INFO, "blist import", "Finished reading %s\n", | |
2210 filename); | |
2211 | |
2212 return TRUE; | |
2213 } | |
2214 | |
2215 void gaim_blist_load() { | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2216 GList *accts; |
5228 | 2217 char *user_dir = gaim_user_dir(); |
2218 char *filename; | |
2219 char *msg; | |
2220 | |
2221 blist_safe_to_write = TRUE; | |
2222 | |
2223 if(!user_dir) | |
2224 return; | |
2225 | |
2226 filename = g_build_filename(user_dir, "blist.xml", NULL); | |
2227 | |
2228 if(g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
2229 if(!gaim_blist_read(filename)) { | |
2230 msg = g_strdup_printf(_("An error was encountered parsing your " | |
2231 "buddy list. It has not been loaded.")); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2232 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg); |
5228 | 2233 g_free(msg); |
2234 } | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2235 } else if(g_list_length(gaim_accounts_get_all())) { |
5228 | 2236 /* 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
|
2237 for(accts = gaim_accounts_get_all(); accts; accts = accts->next) { |
5228 | 2238 do_import(accts->data, NULL); |
2239 } | |
2240 gaim_blist_save(); | |
2241 } | |
2242 | |
2243 g_free(filename); | |
2244 } | |
2245 | |
2246 static void blist_print_group_settings(gpointer key, gpointer data, | |
2247 gpointer user_data) { | |
2248 char *key_val; | |
2249 char *data_val; | |
2250 FILE *file = user_data; | |
2251 | |
2252 if(!key || !data) | |
2253 return; | |
2254 | |
2255 key_val = g_markup_escape_text(key, -1); | |
2256 data_val = g_markup_escape_text(data, -1); | |
2257 | |
2258 fprintf(file, "\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
2259 data_val); | |
2260 g_free(key_val); | |
2261 g_free(data_val); | |
2262 } | |
2263 | |
2264 static void blist_print_buddy_settings(gpointer key, gpointer data, | |
2265 gpointer user_data) { | |
2266 char *key_val; | |
2267 char *data_val; | |
2268 FILE *file = user_data; | |
2269 | |
2270 if(!key || !data) | |
2271 return; | |
2272 | |
2273 key_val = g_markup_escape_text(key, -1); | |
2274 data_val = g_markup_escape_text(data, -1); | |
2275 | |
2276 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
2277 data_val); | |
2278 g_free(key_val); | |
2279 g_free(data_val); | |
2280 } | |
2281 | |
6695 | 2282 static void blist_print_cnode_settings(gpointer key, gpointer data, |
2283 gpointer user_data) { | |
2284 char *key_val; | |
2285 char *data_val; | |
2286 FILE *file = user_data; | |
2287 | |
2288 if(!key || !data) | |
2289 return; | |
2290 | |
2291 key_val = g_markup_escape_text(key, -1); | |
2292 data_val = g_markup_escape_text(data, -1); | |
2293 | |
2294 fprintf(file, "\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
2295 data_val); | |
2296 g_free(key_val); | |
2297 g_free(data_val); | |
2298 } | |
2299 | |
5234 | 2300 static void blist_print_chat_components(gpointer key, gpointer data, |
2301 gpointer user_data) { | |
2302 char *key_val; | |
2303 char *data_val; | |
2304 FILE *file = user_data; | |
2305 | |
2306 if(!key || !data) | |
2307 return; | |
2308 | |
2309 key_val = g_markup_escape_text(key, -1); | |
2310 data_val = g_markup_escape_text(data, -1); | |
2311 | |
2312 fprintf(file, "\t\t\t\t<component name=\"%s\">%s</component>\n", key_val, | |
2313 data_val); | |
2314 g_free(key_val); | |
2315 g_free(data_val); | |
2316 } | |
2317 | |
6695 | 2318 static void print_buddy(FILE *file, GaimBuddy *buddy) { |
2319 char *bud_name = g_markup_escape_text(buddy->name, -1); | |
2320 char *bud_alias = NULL; | |
2321 char *acct_name = g_markup_escape_text(buddy->account->username, -1); | |
2322 if(buddy->alias) | |
2323 bud_alias= g_markup_escape_text(buddy->alias, -1); | |
2324 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" " | |
2325 "account=\"%s\">\n", | |
2326 gaim_account_get_protocol(buddy->account), | |
2327 acct_name); | |
2328 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name); | |
2329 if(bud_alias) { | |
2330 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n", bud_alias); | |
2331 } | |
2332 g_hash_table_foreach(buddy->settings, blist_print_buddy_settings, file); | |
2333 fprintf(file, "\t\t\t\t</buddy>\n"); | |
2334 g_free(bud_name); | |
2335 g_free(bud_alias); | |
2336 g_free(acct_name); | |
2337 } | |
2338 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2339 static void gaim_blist_write(FILE *file, GaimAccount *exp_acct) { |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2340 GList *accounts; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2341 GSList *buds; |
6695 | 2342 GaimBlistNode *gnode, *cnode, *bnode; |
5228 | 2343 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); |
2344 fprintf(file, "<gaim version=\"1\">\n"); | |
2345 fprintf(file, "\t<blist>\n"); | |
2346 | |
2347 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
6695 | 2348 GaimGroup *group; |
2349 | |
5228 | 2350 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
2351 continue; | |
6695 | 2352 |
2353 group = (GaimGroup *)gnode; | |
5228 | 2354 if(!exp_acct || gaim_group_on_account(group, exp_acct)) { |
2355 char *group_name = g_markup_escape_text(group->name, -1); | |
2356 fprintf(file, "\t\t<group name=\"%s\">\n", group_name); | |
2357 g_hash_table_foreach(group->settings, blist_print_group_settings, file); | |
6695 | 2358 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2359 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
6755 | 2360 GaimContact *contact = (GaimContact*)cnode; |
2361 fprintf(file, "\t\t\t<contact"); | |
2362 if(contact->alias) { | |
2363 char *alias = g_markup_escape_text(contact->alias, -1); | |
2364 fprintf(file, " alias=\"%s\"", alias); | |
2365 g_free(alias); | |
2366 } | |
2367 fprintf(file, ">\n"); | |
6695 | 2368 |
2369 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
2370 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
2371 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
2372 if(!exp_acct || buddy->account == exp_acct) { | |
2373 print_buddy(file, buddy); | |
2374 } | |
5234 | 2375 } |
5228 | 2376 } |
6695 | 2377 |
2378 fprintf(file, "\t\t\t</contact>\n"); | |
2379 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
2380 GaimBlistChat *chat = (GaimBlistChat *)cnode; | |
5234 | 2381 if(!exp_acct || chat->account == exp_acct) { |
2382 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
|
2383 fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2384 gaim_account_get_protocol(chat->account), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2385 acct_name); |
5237 | 2386 if(chat->alias) { |
2387 char *chat_alias = g_markup_escape_text(chat->alias, -1); | |
2388 fprintf(file, "\t\t\t\t<alias>%s</alias>\n", chat_alias); | |
2389 g_free(chat_alias); | |
2390 } | |
5234 | 2391 g_hash_table_foreach(chat->components, |
2392 blist_print_chat_components, file); | |
5906 | 2393 g_hash_table_foreach(chat->settings, |
6695 | 2394 blist_print_cnode_settings, file); |
5234 | 2395 fprintf(file, "\t\t\t</chat>\n"); |
5237 | 2396 g_free(acct_name); |
5234 | 2397 } |
5228 | 2398 } |
2399 } | |
2400 fprintf(file, "\t\t</group>\n"); | |
2401 g_free(group_name); | |
2402 } | |
2403 } | |
2404 | |
2405 fprintf(file, "\t</blist>\n"); | |
2406 fprintf(file, "\t<privacy>\n"); | |
2407 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2408 for(accounts = gaim_accounts_get_all(); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2409 accounts != NULL; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2410 accounts = accounts->next) { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2411 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2412 GaimAccount *account = accounts->data; |
5228 | 2413 char *acct_name = g_markup_escape_text(account->username, -1); |
2414 if(!exp_acct || account == exp_acct) { | |
2415 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" " | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2416 "mode=\"%d\">\n", gaim_account_get_protocol(account), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2417 acct_name, account->perm_deny); |
5228 | 2418 for(buds = account->permit; buds; buds = buds->next) { |
2419 char *bud_name = g_markup_escape_text(buds->data, -1); | |
2420 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); | |
2421 g_free(bud_name); | |
2422 } | |
2423 for(buds = account->deny; buds; buds = buds->next) { | |
2424 char *bud_name = g_markup_escape_text(buds->data, -1); | |
2425 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name); | |
2426 g_free(bud_name); | |
2427 } | |
2428 fprintf(file, "\t\t</account>\n"); | |
2429 } | |
2430 g_free(acct_name); | |
2431 } | |
2432 | |
2433 fprintf(file, "\t</privacy>\n"); | |
2434 fprintf(file, "</gaim>\n"); | |
2435 } | |
2436 | |
2437 void gaim_blist_save() { | |
2438 FILE *file; | |
2439 char *user_dir = gaim_user_dir(); | |
2440 char *filename; | |
2441 char *filename_real; | |
2442 | |
2443 if(!user_dir) | |
2444 return; | |
2445 if(!blist_safe_to_write) { | |
2446 gaim_debug(GAIM_DEBUG_WARNING, "blist save", | |
2447 "AHH!! Tried to write the blist before we read it!\n"); | |
2448 return; | |
2449 } | |
2450 | |
2451 file = fopen(user_dir, "r"); | |
2452 if(!file) | |
2453 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR); | |
2454 else | |
2455 fclose(file); | |
2456 | |
2457 filename = g_build_filename(user_dir, "blist.xml.save", NULL); | |
2458 | |
2459 if((file = fopen(filename, "w"))) { | |
2460 gaim_blist_write(file, NULL); | |
2461 fclose(file); | |
2462 chmod(filename, S_IRUSR | S_IWUSR); | |
2463 } else { | |
2464 gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n", | |
2465 filename); | |
2466 } | |
2467 | |
2468 filename_real = g_build_filename(user_dir, "blist.xml", NULL); | |
2469 | |
2470 if(rename(filename, filename_real) < 0) | |
2471 gaim_debug(GAIM_DEBUG_ERROR, "blist save", | |
2472 "Error renaming %s to %s\n", filename, filename_real); | |
2473 | |
2474 | |
2475 g_free(filename); | |
2476 g_free(filename_real); | |
2477 } | |
2478 | |
6695 | 2479 void gaim_group_set_setting(GaimGroup *g, const char *key, |
5228 | 2480 const char *value) { |
2481 if(!g) | |
2482 return; | |
2483 g_hash_table_replace(g->settings, g_strdup(key), g_strdup(value)); | |
2484 } | |
2485 | |
6695 | 2486 char *gaim_group_get_setting(GaimGroup *g, const char *key) { |
5228 | 2487 if(!g) |
2488 return NULL; | |
2489 return g_strdup(g_hash_table_lookup(g->settings, key)); | |
2490 } | |
2491 | |
6695 | 2492 void gaim_blist_chat_set_setting(GaimBlistChat *c, const char *key, |
5906 | 2493 const char *value) |
2494 { | |
2495 if(!c) | |
2496 return; | |
2497 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); | |
2498 } | |
2499 | |
6695 | 2500 char *gaim_blist_chat_get_setting(GaimBlistChat *c, const char *key) |
5906 | 2501 { |
2502 if(!c) | |
2503 return NULL; | |
2504 return g_strdup(g_hash_table_lookup(c->settings, key)); | |
2505 } | |
2506 | |
6695 | 2507 void gaim_buddy_set_setting(GaimBuddy *b, const char *key, |
5228 | 2508 const char *value) { |
2509 if(!b) | |
2510 return; | |
2511 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value)); | |
2512 } | |
2513 | |
6695 | 2514 char *gaim_buddy_get_setting(GaimBuddy *b, const char *key) { |
5228 | 2515 if(!b) |
2516 return NULL; | |
2517 return g_strdup(g_hash_table_lookup(b->settings, key)); | |
2518 } | |
2519 | |
2520 void gaim_set_blist_ui_ops(struct gaim_blist_ui_ops *ops) | |
2521 { | |
2522 blist_ui_ops = ops; | |
2523 } | |
2524 | |
2525 struct gaim_blist_ui_ops * | |
2526 gaim_get_blist_ui_ops(void) | |
2527 { | |
2528 return blist_ui_ops; | |
2529 } | |
2530 | |
6695 | 2531 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) { |
5228 | 2532 if(!group) |
2533 return 0; | |
2534 | |
5277 | 2535 return offline ? group->totalsize : group->currentsize; |
5228 | 2536 } |
2537 | |
6695 | 2538 int gaim_blist_get_group_online_count(GaimGroup *group) { |
5228 | 2539 if(!group) |
2540 return 0; | |
2541 | |
5277 | 2542 return group->online; |
5228 | 2543 } |
2544 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2545 void * |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2546 gaim_blist_get_handle(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2547 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2548 static int handle; |
5228 | 2549 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2550 return &handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2551 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2552 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2553 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2554 gaim_blist_init(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2555 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2556 void *handle = gaim_blist_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2557 |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2558 gaim_signal_register(handle, "buddy-away", |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2559 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2560 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2561 GAIM_SUBTYPE_BLIST_BUDDY)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2562 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2563 gaim_signal_register(handle, "buddy-back", |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2564 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2565 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2566 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2567 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2568 gaim_signal_register(handle, "buddy-idle", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2569 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2570 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2571 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2572 gaim_signal_register(handle, "buddy-unidle", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2573 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2574 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2575 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2576 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2577 gaim_signal_register(handle, "buddy-signed-on", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2578 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2579 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2580 GAIM_SUBTYPE_BLIST_BUDDY)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2581 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2582 gaim_signal_register(handle, "buddy-signed-off", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2583 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2584 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2585 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2586 |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2587 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
|
2588 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2589 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2590 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2591 gaim_blist_uninit(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2592 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2593 gaim_signals_unregister_by_instance(gaim_blist_get_handle()); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2594 } |