Mercurial > pidgin
annotate src/blist.c @ 6914:efb54eb0158f
[gaim-migrate @ 7461]
Code page from utf-8 to win code page
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Tue, 23 Sep 2003 16:36:26 +0000 |
parents | 5ace3b44cf61 |
children | ed14dda65d8e |
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)) { | |
1343 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
1344 if(GAIM_BLIST_NODE_IS_BUDDY(bnode) && | |
1345 ((GaimBuddy*)bnode)->account == account) { | |
1346 ((GaimContact*)cnode)->currentsize++; | |
1347 if(((GaimContact*)cnode)->currentsize == 1) | |
1348 ((GaimGroup*)gnode)->currentsize++; | |
1349 if(GAIM_BUDDY_IS_ONLINE((GaimBuddy*)bnode)) { | |
1350 ((GaimContact*)cnode)->online++; | |
1351 if(((GaimContact*)cnode)->online == 1) | |
1352 ((GaimGroup*)gnode)->online++; | |
1353 } | |
1354 ops->update(gaimbuddylist, bnode); | |
1355 } | |
1356 } | |
6843 | 1357 gaim_contact_compute_priority_buddy((GaimContact*)cnode); |
6695 | 1358 ops->update(gaimbuddylist, cnode); |
1359 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && | |
1360 ((GaimBlistChat*)cnode)->account == account) { | |
6901 | 1361 ((GaimGroup *)gnode)->online++; |
1362 ((GaimGroup *)gnode)->currentsize++; | |
1363 ops->update(gaimbuddylist, cnode); | |
5234 | 1364 } |
1365 } | |
6695 | 1366 ops->update(gaimbuddylist, gnode); |
5234 | 1367 } |
1368 } | |
1369 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1370 void gaim_blist_remove_account(GaimAccount *account) |
5228 | 1371 { |
1372 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; | |
6695 | 1373 GaimBlistNode *gnode, *cnode, *bnode; |
5234 | 1374 |
5228 | 1375 if (!gaimbuddylist) |
1376 return; | |
5234 | 1377 |
6695 | 1378 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { |
1379 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5234 | 1380 continue; |
6695 | 1381 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
1382 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
1383 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
1384 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
1385 continue; | |
1386 if(account == ((GaimBuddy *)bnode)->account) { | |
1387 if(((GaimBuddy*)bnode)->present == GAIM_BUDDY_ONLINE || | |
1388 ((GaimBuddy*)bnode)->present == GAIM_BUDDY_SIGNING_ON) { | |
1389 ((GaimContact*)cnode)->online--; | |
1390 if(((GaimContact*)cnode)->online == 0) | |
1391 ((GaimGroup*)gnode)->online--; | |
1392 } | |
1393 ((GaimContact*)cnode)->currentsize--; | |
1394 if(((GaimContact*)cnode)->currentsize == 0) | |
1395 ((GaimGroup*)gnode)->currentsize--; | |
1396 | |
1397 ((GaimBuddy*)bnode)->present = GAIM_BUDDY_OFFLINE; | |
1398 | |
6803 | 1399 ((GaimBuddy*)bnode)->uc = 0; |
1400 ((GaimBuddy*)bnode)->idle = 0; | |
1401 ((GaimBuddy*)bnode)->evil = 0; | |
1402 | |
6695 | 1403 if(ops) |
1404 ops->remove(gaimbuddylist, bnode); | |
1405 } | |
5234 | 1406 } |
6843 | 1407 gaim_contact_compute_priority_buddy((GaimContact*)cnode); |
6695 | 1408 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
1409 ((GaimBlistChat*)cnode)->account == account) { | |
1410 ((GaimGroup*)gnode)->currentsize--; | |
1411 ((GaimGroup*)gnode)->online--; | |
1412 if(ops) | |
1413 ops->remove(gaimbuddylist, cnode); | |
5228 | 1414 } |
1415 } | |
1416 } | |
1417 } | |
1418 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1419 void parse_toc_buddy_list(GaimAccount *account, char *config) |
5228 | 1420 { |
1421 char *c; | |
1422 char current[256]; | |
1423 GList *bud = NULL; | |
1424 | |
1425 | |
1426 if (config != NULL) { | |
1427 | |
1428 /* skip "CONFIG:" (if it exists) */ | |
1429 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ? | |
1430 strtok(config, "\n") : | |
1431 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n"); | |
1432 do { | |
1433 if (c == NULL) | |
1434 break; | |
1435 if (*c == 'g') { | |
1436 char *utf8 = NULL; | |
1437 utf8 = gaim_try_conv_to_utf8(c + 2); | |
1438 if (utf8 == NULL) { | |
1439 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); | |
1440 } else { | |
1441 g_strlcpy(current, utf8, sizeof(current)); | |
1442 g_free(utf8); | |
1443 } | |
1444 if (!gaim_find_group(current)) { | |
6695 | 1445 GaimGroup *g = gaim_group_new(current); |
5634 | 1446 gaim_blist_add_group(g, |
1447 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
5228 | 1448 } |
1449 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ | |
1450 char nm[80], sw[388], *a, *utf8 = NULL; | |
1451 | |
1452 if ((a = strchr(c + 2, ':')) != NULL) { | |
1453 *a++ = '\0'; /* nul the : */ | |
1454 } | |
1455 | |
1456 g_strlcpy(nm, c + 2, sizeof(nm)); | |
1457 if (a) { | |
1458 utf8 = gaim_try_conv_to_utf8(a); | |
1459 if (utf8 == NULL) { | |
1460 gaim_debug(GAIM_DEBUG_ERROR, "toc blist", | |
1461 "Failed to convert alias for " | |
1462 "'%s' to UTF-8\n", nm); | |
1463 } | |
1464 } | |
1465 if (utf8 == NULL) { | |
1466 sw[0] = '\0'; | |
1467 } else { | |
1468 /* This can leave a partial sequence at the end, | |
1469 * but who cares? */ | |
1470 g_strlcpy(sw, utf8, sizeof(sw)); | |
1471 g_free(utf8); | |
1472 } | |
1473 | |
1474 if (!gaim_find_buddy(account, nm)) { | |
6695 | 1475 GaimBuddy *b = gaim_buddy_new(account, nm, sw); |
1476 GaimGroup *g = gaim_find_group(current); | |
1477 gaim_blist_add_buddy(b, NULL, g, | |
5634 | 1478 gaim_blist_get_last_child((GaimBlistNode*)g)); |
5228 | 1479 bud = g_list_append(bud, g_strdup(nm)); |
1480 } | |
1481 } else if (*c == 'p') { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1482 gaim_privacy_permit_add(account, c + 2, TRUE); |
5228 | 1483 } else if (*c == 'd') { |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1484 gaim_privacy_deny_add(account, c + 2, TRUE); |
5228 | 1485 } else if (!strncmp("toc", c, 3)) { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1486 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); |
5228 | 1487 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1488 "permdeny: %d\n", account->perm_deny); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1489 if (account->perm_deny == 0) |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1490 account->perm_deny = 1; |
5228 | 1491 } else if (*c == 'm') { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1492 sscanf(c + 2, "%d", &account->perm_deny); |
5228 | 1493 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1494 "permdeny: %d\n", account->perm_deny); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1495 if (account->perm_deny == 0) |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1496 account->perm_deny = 1; |
5228 | 1497 } |
1498 } while ((c = strtok(NULL, "\n"))); | |
1499 | |
1500 if(account->gc) { | |
1501 if(bud) { | |
1502 GList *node = bud; | |
1503 serv_add_buddies(account->gc, bud); | |
1504 while(node) { | |
1505 g_free(node->data); | |
1506 node = node->next; | |
1507 } | |
1508 } | |
1509 serv_set_permit_deny(account->gc); | |
1510 } | |
1511 g_list_free(bud); | |
1512 } | |
1513 } | |
1514 | |
1515 #if 0 | |
1516 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */ | |
1517 static GString *translate_lst(FILE *src_fp) | |
1518 { | |
1519 char line[BUF_LEN], *line2; | |
1520 char *name; | |
1521 int i; | |
1522 | |
1523 GString *dest = g_string_new("m 1\n"); | |
1524 | |
1525 while (fgets(line, BUF_LEN, src_fp)) { | |
1526 line2 = g_strchug(line); | |
1527 if (strstr(line2, "group") == line2) { | |
1528 name = strpbrk(line2, " \t\n\r\f") + 1; | |
1529 dest = g_string_append(dest, "g "); | |
1530 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
1531 if (name[i] != '\"') | |
1532 dest = g_string_append_c(dest, name[i]); | |
1533 dest = g_string_append_c(dest, '\n'); | |
1534 } | |
1535 if (strstr(line2, "buddy") == line2) { | |
1536 name = strpbrk(line2, " \t\n\r\f") + 1; | |
1537 dest = g_string_append(dest, "b "); | |
1538 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
1539 if (name[i] != '\"') | |
1540 dest = g_string_append_c(dest, name[i]); | |
1541 dest = g_string_append_c(dest, '\n'); | |
1542 } | |
1543 } | |
1544 | |
1545 return dest; | |
1546 } | |
1547 | |
1548 | |
1549 /* translate an AIM 4 buddylist (*.blt) to Gaim format */ | |
1550 static GString *translate_blt(FILE *src_fp) | |
1551 { | |
1552 int i; | |
1553 char line[BUF_LEN]; | |
1554 char *buddy; | |
1555 | |
1556 GString *dest = g_string_new("m 1\n"); | |
1557 | |
1558 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL); | |
1559 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL); | |
1560 | |
1561 while (1) { | |
1562 fgets(line, BUF_LEN, src_fp); g_strchomp(line); | |
1563 if (strchr(line, '}') != NULL) | |
1564 break; | |
1565 | |
1566 if (strchr(line, '{') != NULL) { | |
1567 /* Syntax starting with "<group> {" */ | |
1568 | |
1569 dest = g_string_append(dest, "g "); | |
1570 buddy = g_strchug(strtok(line, "{")); | |
1571 for (i = 0; i < strlen(buddy); i++) | |
1572 if (buddy[i] != '\"') | |
1573 dest = g_string_append_c(dest, buddy[i]); | |
1574 dest = g_string_append_c(dest, '\n'); | |
1575 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) { | |
1576 gboolean pounce = FALSE; | |
1577 char *e; | |
1578 g_strchomp(line); | |
1579 buddy = g_strchug(line); | |
1580 gaim_debug(GAIM_DEBUG_MISC, "AIM 4 blt import", | |
1581 "buddy: \"%s\"\n", buddy); | |
1582 dest = g_string_append(dest, "b "); | |
1583 if (strchr(buddy, '{') != NULL) { | |
1584 /* buddy pounce, etc */ | |
1585 char *pos = strchr(buddy, '{') - 1; | |
1586 *pos = 0; | |
1587 pounce = TRUE; | |
1588 } | |
1589 if ((e = strchr(buddy, '\"')) != NULL) { | |
1590 *e = '\0'; | |
1591 buddy++; | |
1592 } | |
1593 dest = g_string_append(dest, buddy); | |
1594 dest = g_string_append_c(dest, '\n'); | |
1595 if (pounce) | |
1596 do | |
1597 fgets(line, BUF_LEN, src_fp); | |
1598 while (!strchr(line, '}')); | |
1599 } | |
1600 } else { | |
1601 | |
1602 /* Syntax "group buddy buddy ..." */ | |
1603 buddy = g_strchug(strtok(line, " \n")); | |
1604 dest = g_string_append(dest, "g "); | |
1605 if (strchr(buddy, '\"') != NULL) { | |
1606 dest = g_string_append(dest, &buddy[1]); | |
1607 dest = g_string_append_c(dest, ' '); | |
1608 buddy = g_strchug(strtok(NULL, " \n")); | |
1609 while (strchr(buddy, '\"') == NULL) { | |
1610 dest = g_string_append(dest, buddy); | |
1611 dest = g_string_append_c(dest, ' '); | |
1612 buddy = g_strchug(strtok(NULL, " \n")); | |
1613 } | |
1614 buddy[strlen(buddy) - 1] = '\0'; | |
1615 dest = g_string_append(dest, buddy); | |
1616 } else { | |
1617 dest = g_string_append(dest, buddy); | |
1618 } | |
1619 dest = g_string_append_c(dest, '\n'); | |
1620 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) { | |
1621 dest = g_string_append(dest, "b "); | |
1622 if (strchr(buddy, '\"') != NULL) { | |
1623 dest = g_string_append(dest, &buddy[1]); | |
1624 dest = g_string_append_c(dest, ' '); | |
1625 buddy = g_strchug(strtok(NULL, " \n")); | |
1626 while (strchr(buddy, '\"') == NULL) { | |
1627 dest = g_string_append(dest, buddy); | |
1628 dest = g_string_append_c(dest, ' '); | |
1629 buddy = g_strchug(strtok(NULL, " \n")); | |
1630 } | |
1631 buddy[strlen(buddy) - 1] = '\0'; | |
1632 dest = g_string_append(dest, buddy); | |
1633 } else { | |
1634 dest = g_string_append(dest, buddy); | |
1635 } | |
1636 dest = g_string_append_c(dest, '\n'); | |
1637 } | |
1638 } | |
1639 } | |
1640 | |
1641 return dest; | |
1642 } | |
1643 | |
1644 static GString *translate_gnomeicu(FILE *src_fp) | |
1645 { | |
1646 char line[BUF_LEN]; | |
1647 GString *dest = g_string_new("m 1\ng Buddies\n"); | |
1648 | |
1649 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL); | |
1650 | |
1651 while (fgets(line, BUF_LEN, src_fp)) { | |
1652 char *eq; | |
1653 g_strchomp(line); | |
1654 if (line[0] == '\n' || line[0] == '[') | |
1655 break; | |
1656 eq = strchr(line, '='); | |
1657 if (!eq) | |
1658 break; | |
1659 *eq = ':'; | |
1660 eq = strchr(eq, ','); | |
1661 if (eq) | |
1662 *eq = '\0'; | |
1663 dest = g_string_append(dest, "b "); | |
1664 dest = g_string_append(dest, line); | |
1665 dest = g_string_append_c(dest, '\n'); | |
1666 } | |
1667 | |
1668 return dest; | |
1669 } | |
1670 #endif | |
1671 | |
1672 static gchar *get_screenname_filename(const char *name) | |
1673 { | |
1674 gchar **split; | |
1675 gchar *good; | |
1676 gchar *ret; | |
1677 | |
1678 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1); | |
1679 good = g_strjoinv(NULL, split); | |
1680 g_strfreev(split); | |
1681 | |
1682 ret = g_utf8_strup(good, -1); | |
1683 | |
1684 g_free(good); | |
1685 | |
1686 return ret; | |
1687 } | |
1688 | |
1689 static gboolean gaim_blist_read(const char *filename); | |
1690 | |
1691 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1692 static void do_import(GaimAccount *account, const char *filename) |
5228 | 1693 { |
1694 GString *buf = NULL; | |
1695 char first[64]; | |
1696 char path[PATHSIZE]; | |
1697 int len; | |
1698 FILE *f; | |
1699 struct stat st; | |
1700 | |
1701 if (filename) { | |
1702 g_snprintf(path, sizeof(path), "%s", filename); | |
1703 } else { | |
1704 char *g_screenname = get_screenname_filename(account->username); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1705 const char *username; |
5228 | 1706 char *file = gaim_user_dir(); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1707 GaimProtocol prpl_num; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1708 int protocol; |
6695 | 1709 |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1710 prpl_num = gaim_account_get_protocol(account); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1711 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1712 protocol = prpl_num; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1713 |
6450
e7b87c8e8c0a
[gaim-migrate @ 6959]
Christian Hammond <chipx86@chipx86.com>
parents:
6392
diff
changeset
|
1714 /* TODO Somehow move this checking into prpls */ |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1715 if (prpl_num == GAIM_PROTO_OSCAR) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1716 if ((username = gaim_account_get_username(account)) != NULL) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1717 protocol = (isalpha(*username) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1718 ? GAIM_PROTO_TOC : GAIM_PROTO_ICQ); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1719 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1720 } |
5228 | 1721 |
1722 if (file != (char *)NULL) { | |
5435 | 1723 snprintf(path, PATHSIZE, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol); |
5228 | 1724 g_free(g_screenname); |
1725 } else { | |
1726 g_free(g_screenname); | |
1727 return; | |
1728 } | |
1729 } | |
1730 | |
1731 if (stat(path, &st)) { | |
1732 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to stat %s.\n", | |
1733 path); | |
1734 return; | |
1735 } | |
1736 | |
1737 if (!(f = fopen(path, "r"))) { | |
1738 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to open %s.\n", | |
1739 path); | |
1740 return; | |
1741 } | |
1742 | |
1743 fgets(first, 64, f); | |
1744 | |
1745 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n')) | |
1746 fgets(first, 64, f); | |
1747 | |
1748 #if 0 | |
1749 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) { | |
1750 /* new gaim XML buddy list */ | |
1751 gaim_blist_read(path); | |
1752 | |
1753 /* We really don't need to bother doing stuf like translating AIM 3 buddy lists anymore */ | |
1754 | |
1755 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) { | |
1756 /* AIM 4 buddy list */ | |
1757 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 4\n"); | |
1758 rewind(f); | |
1759 buf = translate_blt(f); | |
1760 } else if (strstr(first, "group") != NULL) { | |
1761 /* AIM 3 buddy list */ | |
1762 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 3\n"); | |
1763 rewind(f); | |
1764 buf = translate_lst(f); | |
1765 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) { | |
1766 /* GnomeICU (hopefully) */ | |
1767 gaim_debug(GAIM_DEBUG_MISC, "blist import", "gnomeicu\n"); | |
1768 rewind(f); | |
1769 buf = translate_gnomeicu(f); | |
1770 | |
1771 } else | |
1772 #endif | |
1773 if (first[0] == 'm') { | |
1774 /* Gaim buddy list - no translation */ | |
1775 char buf2[BUF_LONG * 2]; | |
1776 buf = g_string_new(""); | |
1777 rewind(f); | |
1778 while (1) { | |
1779 len = fread(buf2, 1, BUF_LONG * 2 - 1, f); | |
1780 if (len <= 0) | |
1781 break; | |
1782 buf2[len] = '\0'; | |
1783 buf = g_string_append(buf, buf2); | |
1784 if (len != BUF_LONG * 2 - 1) | |
1785 break; | |
1786 } | |
1787 } | |
1788 | |
1789 fclose(f); | |
1790 | |
1791 if (buf) { | |
1792 buf = g_string_prepend(buf, "toc_set_config {"); | |
1793 buf = g_string_append(buf, "}\n"); | |
1794 parse_toc_buddy_list(account, buf->str); | |
1795 g_string_free(buf, TRUE); | |
1796 } | |
1797 } | |
1798 | |
6695 | 1799 gboolean gaim_group_on_account(GaimGroup *g, GaimAccount *account) { |
1800 GaimBlistNode *cnode, *bnode; | |
1801 for(cnode = ((GaimBlistNode *)g)->child; cnode; cnode = cnode->next) { | |
1802 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
1803 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
1804 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
1805 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
1806 if((!account && gaim_account_is_connected(buddy->account)) | |
1807 || buddy->account == account) | |
1808 return TRUE; | |
1809 } | |
1810 } | |
1811 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
1812 GaimBlistChat *chat = (GaimBlistChat *)cnode; | |
1813 if((!account && gaim_account_is_connected(chat->account)) | |
1814 || chat->account == account) | |
1815 return TRUE; | |
1816 } | |
5228 | 1817 } |
1818 return FALSE; | |
1819 } | |
1820 | |
1821 static gboolean blist_safe_to_write = FALSE; | |
1822 | |
6695 | 1823 GaimGroup *blist_parser_group = NULL; |
1824 GaimContact *blist_parser_contact = NULL; | |
5228 | 1825 static char *blist_parser_account_name = NULL; |
1826 static int blist_parser_account_protocol = 0; | |
5234 | 1827 static char *blist_parser_chat_alias = NULL; |
1828 static char *blist_parser_component_name = NULL; | |
1829 static char *blist_parser_component_value = NULL; | |
5228 | 1830 static char *blist_parser_buddy_name = NULL; |
1831 static char *blist_parser_buddy_alias = NULL; | |
1832 static char *blist_parser_setting_name = NULL; | |
1833 static char *blist_parser_setting_value = NULL; | |
1834 static GHashTable *blist_parser_buddy_settings = NULL; | |
5906 | 1835 static GHashTable *blist_parser_chat_settings = NULL; |
5228 | 1836 static GHashTable *blist_parser_group_settings = NULL; |
5234 | 1837 static GHashTable *blist_parser_chat_components = NULL; |
5228 | 1838 static int blist_parser_privacy_mode = 0; |
1839 static GList *tag_stack = NULL; | |
1840 enum { | |
1841 BLIST_TAG_GAIM, | |
1842 BLIST_TAG_BLIST, | |
1843 BLIST_TAG_GROUP, | |
5234 | 1844 BLIST_TAG_CHAT, |
1845 BLIST_TAG_COMPONENT, | |
6695 | 1846 BLIST_TAG_CONTACT, |
5228 | 1847 BLIST_TAG_BUDDY, |
1848 BLIST_TAG_NAME, | |
1849 BLIST_TAG_ALIAS, | |
1850 BLIST_TAG_SETTING, | |
1851 BLIST_TAG_PRIVACY, | |
1852 BLIST_TAG_ACCOUNT, | |
1853 BLIST_TAG_PERMIT, | |
1854 BLIST_TAG_BLOCK, | |
1855 BLIST_TAG_IGNORE | |
1856 }; | |
1857 static gboolean blist_parser_error_occurred = FALSE; | |
1858 | |
1859 static void blist_start_element_handler (GMarkupParseContext *context, | |
1860 const gchar *element_name, | |
1861 const gchar **attribute_names, | |
1862 const gchar **attribute_values, | |
1863 gpointer user_data, | |
1864 GError **error) { | |
1865 int i; | |
1866 | |
1867 if(!strcmp(element_name, "gaim")) { | |
1868 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GAIM)); | |
1869 } else if(!strcmp(element_name, "blist")) { | |
1870 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLIST)); | |
1871 } else if(!strcmp(element_name, "group")) { | |
6803 | 1872 const char *name = NULL; |
5228 | 1873 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GROUP)); |
1874 for(i=0; attribute_names[i]; i++) { | |
1875 if(!strcmp(attribute_names[i], "name")) { | |
6778 | 1876 name = attribute_values[i]; |
5228 | 1877 } |
1878 } | |
6778 | 1879 if(name) { |
1880 blist_parser_group = gaim_group_new(name); | |
6695 | 1881 gaim_blist_add_group(blist_parser_group, |
5634 | 1882 gaim_blist_get_last_sibling(gaimbuddylist->root)); |
5228 | 1883 } |
6695 | 1884 } else if(!strcmp(element_name, "contact")) { |
6755 | 1885 char *alias = NULL; |
6695 | 1886 tag_stack = g_list_prepend(tag_stack, |
1887 GINT_TO_POINTER(BLIST_TAG_CONTACT)); | |
1888 | |
6755 | 1889 for(i=0; attribute_names[i]; i++) { |
1890 if(!strcmp(attribute_names[i], "alias")) { | |
1891 g_free(alias); | |
1892 alias = g_strdup(attribute_values[i]); | |
1893 } | |
1894 } | |
1895 | |
6695 | 1896 blist_parser_contact = gaim_contact_new(); |
1897 gaim_blist_add_contact(blist_parser_contact, blist_parser_group, | |
1898 gaim_blist_get_last_sibling(((GaimBlistNode*)blist_parser_group)->child)); | |
6755 | 1899 |
1900 if(alias) { | |
1901 gaim_contact_set_alias(blist_parser_contact, alias); | |
1902 g_free(alias); | |
1903 } | |
5234 | 1904 } else if(!strcmp(element_name, "chat")) { |
1905 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_CHAT)); | |
1906 for(i=0; attribute_names[i]; i++) { | |
1907 if(!strcmp(attribute_names[i], "account")) { | |
1908 g_free(blist_parser_account_name); | |
1909 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1910 } else if(!strcmp(attribute_names[i], "protocol")) { | |
1911 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1912 } | |
1913 } | |
5228 | 1914 } else if(!strcmp(element_name, "buddy")) { |
1915 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BUDDY)); | |
1916 for(i=0; attribute_names[i]; i++) { | |
1917 if(!strcmp(attribute_names[i], "account")) { | |
1918 g_free(blist_parser_account_name); | |
1919 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1920 } else if(!strcmp(attribute_names[i], "protocol")) { | |
1921 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1922 } | |
1923 } | |
1924 } else if(!strcmp(element_name, "name")) { | |
1925 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_NAME)); | |
1926 } else if(!strcmp(element_name, "alias")) { | |
1927 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ALIAS)); | |
1928 } else if(!strcmp(element_name, "setting")) { | |
1929 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_SETTING)); | |
1930 for(i=0; attribute_names[i]; i++) { | |
1931 if(!strcmp(attribute_names[i], "name")) { | |
1932 g_free(blist_parser_setting_name); | |
1933 blist_parser_setting_name = g_strdup(attribute_values[i]); | |
1934 } | |
1935 } | |
5234 | 1936 } else if(!strcmp(element_name, "component")) { |
1937 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_COMPONENT)); | |
1938 for(i=0; attribute_names[i]; i++) { | |
1939 if(!strcmp(attribute_names[i], "name")) { | |
1940 g_free(blist_parser_component_name); | |
1941 blist_parser_component_name = g_strdup(attribute_values[i]); | |
1942 } | |
1943 } | |
1944 | |
5228 | 1945 } else if(!strcmp(element_name, "privacy")) { |
1946 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PRIVACY)); | |
1947 } else if(!strcmp(element_name, "account")) { | |
1948 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ACCOUNT)); | |
1949 for(i=0; attribute_names[i]; i++) { | |
1950 if(!strcmp(attribute_names[i], "protocol")) | |
1951 blist_parser_account_protocol = atoi(attribute_values[i]); | |
1952 else if(!strcmp(attribute_names[i], "mode")) | |
1953 blist_parser_privacy_mode = atoi(attribute_values[i]); | |
1954 else if(!strcmp(attribute_names[i], "name")) { | |
1955 g_free(blist_parser_account_name); | |
1956 blist_parser_account_name = g_strdup(attribute_values[i]); | |
1957 } | |
1958 } | |
1959 } else if(!strcmp(element_name, "permit")) { | |
1960 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERMIT)); | |
1961 } else if(!strcmp(element_name, "block")) { | |
1962 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLOCK)); | |
1963 } else if(!strcmp(element_name, "ignore")) { | |
1964 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_IGNORE)); | |
1965 } | |
1966 } | |
1967 | |
1968 static void blist_end_element_handler(GMarkupParseContext *context, | |
1969 const gchar *element_name, gpointer user_data, GError **error) { | |
1970 if(!strcmp(element_name, "gaim")) { | |
1971 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1972 } else if(!strcmp(element_name, "blist")) { | |
1973 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1974 } else if(!strcmp(element_name, "group")) { | |
1975 if(blist_parser_group_settings) { | |
6778 | 1976 g_hash_table_destroy(blist_parser_group->settings); |
1977 blist_parser_group->settings = blist_parser_group_settings; | |
5228 | 1978 } |
1979 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
1980 blist_parser_group_settings = NULL; | |
6695 | 1981 blist_parser_group = NULL; |
5234 | 1982 } else if(!strcmp(element_name, "chat")) { |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1983 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5234 | 1984 blist_parser_account_protocol); |
5237 | 1985 if(account) { |
6695 | 1986 GaimBlistChat *chat = gaim_blist_chat_new(account, |
1987 blist_parser_chat_alias, blist_parser_chat_components); | |
6778 | 1988 gaim_blist_add_chat(chat,blist_parser_group, |
1989 gaim_blist_get_last_child((GaimBlistNode*)blist_parser_group)); | |
5906 | 1990 if(blist_parser_chat_settings) { |
1991 g_hash_table_destroy(chat->settings); | |
1992 chat->settings = blist_parser_chat_settings; | |
1993 } | |
5234 | 1994 } |
1995 g_free(blist_parser_chat_alias); | |
1996 blist_parser_chat_alias = NULL; | |
1997 g_free(blist_parser_account_name); | |
1998 blist_parser_account_name = NULL; | |
1999 blist_parser_chat_components = NULL; | |
5906 | 2000 blist_parser_chat_settings = NULL; |
5234 | 2001 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
6695 | 2002 } else if(!strcmp(element_name, "contact")) { |
2003 if(blist_parser_contact && !blist_parser_contact->node.child) | |
2004 gaim_blist_remove_contact(blist_parser_contact); | |
2005 blist_parser_contact = NULL; | |
5228 | 2006 tag_stack = g_list_delete_link(tag_stack, tag_stack); |
2007 } else if(!strcmp(element_name, "buddy")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2008 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2009 blist_parser_account_protocol); |
6872 | 2010 if(account && !gaim_find_buddy_in_group(account, |
2011 blist_parser_buddy_name, blist_parser_group)) { | |
2012 GaimBuddy *b = gaim_buddy_new(account, blist_parser_buddy_name, | |
2013 blist_parser_buddy_alias); | |
6695 | 2014 gaim_blist_add_buddy(b,blist_parser_contact, blist_parser_group, |
2015 gaim_blist_get_last_child((GaimBlistNode*)blist_parser_contact)); | |
5228 | 2016 if(blist_parser_buddy_settings) { |
2017 g_hash_table_destroy(b->settings); | |
2018 b->settings = blist_parser_buddy_settings; | |
2019 } | |
2020 } | |
2021 g_free(blist_parser_buddy_name); | |
2022 blist_parser_buddy_name = NULL; | |
2023 g_free(blist_parser_buddy_alias); | |
2024 blist_parser_buddy_alias = NULL; | |
2025 g_free(blist_parser_account_name); | |
2026 blist_parser_account_name = NULL; | |
2027 blist_parser_buddy_settings = NULL; | |
2028 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2029 } else if(!strcmp(element_name, "name")) { | |
2030 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2031 } else if(!strcmp(element_name, "alias")) { | |
2032 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
5234 | 2033 } else if(!strcmp(element_name, "component")) { |
2034 if(!blist_parser_chat_components) | |
2035 blist_parser_chat_components = g_hash_table_new_full(g_str_hash, | |
2036 g_str_equal, g_free, g_free); | |
2037 if(blist_parser_component_name && blist_parser_component_value) { | |
2038 g_hash_table_replace(blist_parser_chat_components, | |
2039 g_strdup(blist_parser_component_name), | |
2040 g_strdup(blist_parser_component_value)); | |
2041 } | |
2042 g_free(blist_parser_component_name); | |
2043 g_free(blist_parser_component_value); | |
2044 blist_parser_component_name = NULL; | |
2045 blist_parser_component_value = NULL; | |
2046 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
5228 | 2047 } else if(!strcmp(element_name, "setting")) { |
2048 if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) { | |
2049 if(!blist_parser_buddy_settings) | |
2050 blist_parser_buddy_settings = g_hash_table_new_full(g_str_hash, | |
2051 g_str_equal, g_free, g_free); | |
2052 if(blist_parser_setting_name && blist_parser_setting_value) { | |
2053 g_hash_table_replace(blist_parser_buddy_settings, | |
2054 g_strdup(blist_parser_setting_name), | |
2055 g_strdup(blist_parser_setting_value)); | |
2056 } | |
5906 | 2057 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) { |
2058 if(!blist_parser_chat_settings) | |
2059 blist_parser_chat_settings = g_hash_table_new_full(g_str_hash, | |
2060 g_str_equal, g_free, g_free); | |
2061 if(blist_parser_setting_name && blist_parser_setting_value) { | |
6307 | 2062 g_hash_table_replace(blist_parser_chat_settings, |
5906 | 2063 g_strdup(blist_parser_setting_name), |
2064 g_strdup(blist_parser_setting_value)); | |
2065 } | |
5228 | 2066 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_GROUP) { |
2067 if(!blist_parser_group_settings) | |
2068 blist_parser_group_settings = g_hash_table_new_full(g_str_hash, | |
2069 g_str_equal, g_free, g_free); | |
2070 if(blist_parser_setting_name && blist_parser_setting_value) { | |
2071 g_hash_table_replace(blist_parser_group_settings, | |
2072 g_strdup(blist_parser_setting_name), | |
2073 g_strdup(blist_parser_setting_value)); | |
2074 } | |
2075 } | |
2076 g_free(blist_parser_setting_name); | |
2077 g_free(blist_parser_setting_value); | |
2078 blist_parser_setting_name = NULL; | |
2079 blist_parser_setting_value = NULL; | |
2080 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2081 } else if(!strcmp(element_name, "privacy")) { | |
2082 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2083 } else if(!strcmp(element_name, "account")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2084 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2085 blist_parser_account_protocol); |
2086 if(account) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2087 account->perm_deny = blist_parser_privacy_mode; |
5228 | 2088 } |
2089 g_free(blist_parser_account_name); | |
2090 blist_parser_account_name = NULL; | |
2091 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2092 } else if(!strcmp(element_name, "permit")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2093 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2094 blist_parser_account_protocol); |
2095 if(account) { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
2096 gaim_privacy_permit_add(account, blist_parser_buddy_name, TRUE); |
5228 | 2097 } |
2098 g_free(blist_parser_buddy_name); | |
2099 blist_parser_buddy_name = NULL; | |
2100 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2101 } else if(!strcmp(element_name, "block")) { | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2102 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
5228 | 2103 blist_parser_account_protocol); |
2104 if(account) { | |
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
2105 gaim_privacy_deny_add(account, blist_parser_buddy_name, TRUE); |
5228 | 2106 } |
2107 g_free(blist_parser_buddy_name); | |
2108 blist_parser_buddy_name = NULL; | |
2109 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2110 } else if(!strcmp(element_name, "ignore")) { | |
2111 /* we'll apparently do something with this later */ | |
2112 tag_stack = g_list_delete_link(tag_stack, tag_stack); | |
2113 } | |
2114 } | |
2115 | |
2116 static void blist_text_handler(GMarkupParseContext *context, const gchar *text, | |
2117 gsize text_len, gpointer user_data, GError **error) { | |
2118 switch(GPOINTER_TO_INT(tag_stack->data)) { | |
2119 case BLIST_TAG_NAME: | |
2120 blist_parser_buddy_name = g_strndup(text, text_len); | |
2121 break; | |
2122 case BLIST_TAG_ALIAS: | |
5234 | 2123 if(tag_stack->next && |
2124 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) | |
2125 blist_parser_buddy_alias = g_strndup(text, text_len); | |
2126 else if(tag_stack->next && | |
2127 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) | |
2128 blist_parser_chat_alias = g_strndup(text, text_len); | |
5228 | 2129 break; |
2130 case BLIST_TAG_PERMIT: | |
2131 case BLIST_TAG_BLOCK: | |
2132 case BLIST_TAG_IGNORE: | |
2133 blist_parser_buddy_name = g_strndup(text, text_len); | |
2134 break; | |
5234 | 2135 case BLIST_TAG_COMPONENT: |
2136 blist_parser_component_value = g_strndup(text, text_len); | |
2137 break; | |
5228 | 2138 case BLIST_TAG_SETTING: |
2139 blist_parser_setting_value = g_strndup(text, text_len); | |
2140 break; | |
2141 default: | |
2142 break; | |
2143 } | |
2144 } | |
2145 | |
2146 static void blist_error_handler(GMarkupParseContext *context, GError *error, | |
2147 gpointer user_data) { | |
2148 blist_parser_error_occurred = TRUE; | |
2149 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
2150 "Error parsing blist.xml: %s\n", error->message); | |
2151 } | |
2152 | |
2153 static GMarkupParser blist_parser = { | |
2154 blist_start_element_handler, | |
2155 blist_end_element_handler, | |
2156 blist_text_handler, | |
2157 NULL, | |
2158 blist_error_handler | |
2159 }; | |
2160 | |
2161 static gboolean gaim_blist_read(const char *filename) { | |
2162 gchar *contents = NULL; | |
2163 gsize length; | |
2164 GMarkupParseContext *context; | |
2165 GError *error = NULL; | |
2166 | |
2167 gaim_debug(GAIM_DEBUG_INFO, "blist import", | |
2168 "Reading %s\n", filename); | |
2169 if(!g_file_get_contents(filename, &contents, &length, &error)) { | |
2170 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
2171 "Error reading blist: %s\n", error->message); | |
2172 g_error_free(error); | |
2173 return FALSE; | |
2174 } | |
2175 | |
2176 context = g_markup_parse_context_new(&blist_parser, 0, NULL, NULL); | |
2177 | |
2178 if(!g_markup_parse_context_parse(context, contents, length, NULL)) { | |
2179 g_markup_parse_context_free(context); | |
2180 g_free(contents); | |
2181 return FALSE; | |
2182 } | |
2183 | |
2184 if(!g_markup_parse_context_end_parse(context, NULL)) { | |
2185 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
2186 "Error parsing %s\n", filename); | |
2187 g_markup_parse_context_free(context); | |
2188 g_free(contents); | |
2189 return FALSE; | |
2190 } | |
2191 | |
2192 g_markup_parse_context_free(context); | |
2193 g_free(contents); | |
2194 | |
2195 if(blist_parser_error_occurred) | |
2196 return FALSE; | |
2197 | |
2198 gaim_debug(GAIM_DEBUG_INFO, "blist import", "Finished reading %s\n", | |
2199 filename); | |
2200 | |
2201 return TRUE; | |
2202 } | |
2203 | |
2204 void gaim_blist_load() { | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2205 GList *accts; |
5228 | 2206 char *user_dir = gaim_user_dir(); |
2207 char *filename; | |
2208 char *msg; | |
2209 | |
2210 blist_safe_to_write = TRUE; | |
2211 | |
2212 if(!user_dir) | |
2213 return; | |
2214 | |
2215 filename = g_build_filename(user_dir, "blist.xml", NULL); | |
2216 | |
2217 if(g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
2218 if(!gaim_blist_read(filename)) { | |
2219 msg = g_strdup_printf(_("An error was encountered parsing your " | |
2220 "buddy list. It has not been loaded.")); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2221 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg); |
5228 | 2222 g_free(msg); |
2223 } | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2224 } else if(g_list_length(gaim_accounts_get_all())) { |
5228 | 2225 /* 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
|
2226 for(accts = gaim_accounts_get_all(); accts; accts = accts->next) { |
5228 | 2227 do_import(accts->data, NULL); |
2228 } | |
2229 gaim_blist_save(); | |
2230 } | |
2231 | |
2232 g_free(filename); | |
2233 } | |
2234 | |
2235 static void blist_print_group_settings(gpointer key, gpointer data, | |
2236 gpointer user_data) { | |
2237 char *key_val; | |
2238 char *data_val; | |
2239 FILE *file = user_data; | |
2240 | |
2241 if(!key || !data) | |
2242 return; | |
2243 | |
2244 key_val = g_markup_escape_text(key, -1); | |
2245 data_val = g_markup_escape_text(data, -1); | |
2246 | |
2247 fprintf(file, "\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
2248 data_val); | |
2249 g_free(key_val); | |
2250 g_free(data_val); | |
2251 } | |
2252 | |
2253 static void blist_print_buddy_settings(gpointer key, gpointer data, | |
2254 gpointer user_data) { | |
2255 char *key_val; | |
2256 char *data_val; | |
2257 FILE *file = user_data; | |
2258 | |
2259 if(!key || !data) | |
2260 return; | |
2261 | |
2262 key_val = g_markup_escape_text(key, -1); | |
2263 data_val = g_markup_escape_text(data, -1); | |
2264 | |
2265 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
2266 data_val); | |
2267 g_free(key_val); | |
2268 g_free(data_val); | |
2269 } | |
2270 | |
6695 | 2271 static void blist_print_cnode_settings(gpointer key, gpointer data, |
2272 gpointer user_data) { | |
2273 char *key_val; | |
2274 char *data_val; | |
2275 FILE *file = user_data; | |
2276 | |
2277 if(!key || !data) | |
2278 return; | |
2279 | |
2280 key_val = g_markup_escape_text(key, -1); | |
2281 data_val = g_markup_escape_text(data, -1); | |
2282 | |
2283 fprintf(file, "\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
2284 data_val); | |
2285 g_free(key_val); | |
2286 g_free(data_val); | |
2287 } | |
2288 | |
5234 | 2289 static void blist_print_chat_components(gpointer key, gpointer data, |
2290 gpointer user_data) { | |
2291 char *key_val; | |
2292 char *data_val; | |
2293 FILE *file = user_data; | |
2294 | |
2295 if(!key || !data) | |
2296 return; | |
2297 | |
2298 key_val = g_markup_escape_text(key, -1); | |
2299 data_val = g_markup_escape_text(data, -1); | |
2300 | |
2301 fprintf(file, "\t\t\t\t<component name=\"%s\">%s</component>\n", key_val, | |
2302 data_val); | |
2303 g_free(key_val); | |
2304 g_free(data_val); | |
2305 } | |
2306 | |
6695 | 2307 static void print_buddy(FILE *file, GaimBuddy *buddy) { |
2308 char *bud_name = g_markup_escape_text(buddy->name, -1); | |
2309 char *bud_alias = NULL; | |
2310 char *acct_name = g_markup_escape_text(buddy->account->username, -1); | |
2311 if(buddy->alias) | |
2312 bud_alias= g_markup_escape_text(buddy->alias, -1); | |
2313 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" " | |
2314 "account=\"%s\">\n", | |
2315 gaim_account_get_protocol(buddy->account), | |
2316 acct_name); | |
2317 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name); | |
2318 if(bud_alias) { | |
2319 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n", bud_alias); | |
2320 } | |
2321 g_hash_table_foreach(buddy->settings, blist_print_buddy_settings, file); | |
2322 fprintf(file, "\t\t\t\t</buddy>\n"); | |
2323 g_free(bud_name); | |
2324 g_free(bud_alias); | |
2325 g_free(acct_name); | |
2326 } | |
2327 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2328 static void gaim_blist_write(FILE *file, GaimAccount *exp_acct) { |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2329 GList *accounts; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2330 GSList *buds; |
6695 | 2331 GaimBlistNode *gnode, *cnode, *bnode; |
5228 | 2332 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); |
2333 fprintf(file, "<gaim version=\"1\">\n"); | |
2334 fprintf(file, "\t<blist>\n"); | |
2335 | |
2336 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
6695 | 2337 GaimGroup *group; |
2338 | |
5228 | 2339 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
2340 continue; | |
6695 | 2341 |
2342 group = (GaimGroup *)gnode; | |
5228 | 2343 if(!exp_acct || gaim_group_on_account(group, exp_acct)) { |
2344 char *group_name = g_markup_escape_text(group->name, -1); | |
2345 fprintf(file, "\t\t<group name=\"%s\">\n", group_name); | |
2346 g_hash_table_foreach(group->settings, blist_print_group_settings, file); | |
6695 | 2347 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2348 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
6755 | 2349 GaimContact *contact = (GaimContact*)cnode; |
2350 fprintf(file, "\t\t\t<contact"); | |
2351 if(contact->alias) { | |
2352 char *alias = g_markup_escape_text(contact->alias, -1); | |
2353 fprintf(file, " alias=\"%s\"", alias); | |
2354 g_free(alias); | |
2355 } | |
2356 fprintf(file, ">\n"); | |
6695 | 2357 |
2358 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
2359 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
2360 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
2361 if(!exp_acct || buddy->account == exp_acct) { | |
2362 print_buddy(file, buddy); | |
2363 } | |
5234 | 2364 } |
5228 | 2365 } |
6695 | 2366 |
2367 fprintf(file, "\t\t\t</contact>\n"); | |
2368 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
2369 GaimBlistChat *chat = (GaimBlistChat *)cnode; | |
5234 | 2370 if(!exp_acct || chat->account == exp_acct) { |
2371 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
|
2372 fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2373 gaim_account_get_protocol(chat->account), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2374 acct_name); |
5237 | 2375 if(chat->alias) { |
2376 char *chat_alias = g_markup_escape_text(chat->alias, -1); | |
2377 fprintf(file, "\t\t\t\t<alias>%s</alias>\n", chat_alias); | |
2378 g_free(chat_alias); | |
2379 } | |
5234 | 2380 g_hash_table_foreach(chat->components, |
2381 blist_print_chat_components, file); | |
5906 | 2382 g_hash_table_foreach(chat->settings, |
6695 | 2383 blist_print_cnode_settings, file); |
5234 | 2384 fprintf(file, "\t\t\t</chat>\n"); |
5237 | 2385 g_free(acct_name); |
5234 | 2386 } |
5228 | 2387 } |
2388 } | |
2389 fprintf(file, "\t\t</group>\n"); | |
2390 g_free(group_name); | |
2391 } | |
2392 } | |
2393 | |
2394 fprintf(file, "\t</blist>\n"); | |
2395 fprintf(file, "\t<privacy>\n"); | |
2396 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2397 for(accounts = gaim_accounts_get_all(); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2398 accounts != NULL; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2399 accounts = accounts->next) { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2400 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2401 GaimAccount *account = accounts->data; |
5228 | 2402 char *acct_name = g_markup_escape_text(account->username, -1); |
2403 if(!exp_acct || account == exp_acct) { | |
2404 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" " | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2405 "mode=\"%d\">\n", gaim_account_get_protocol(account), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2406 acct_name, account->perm_deny); |
5228 | 2407 for(buds = account->permit; buds; buds = buds->next) { |
2408 char *bud_name = g_markup_escape_text(buds->data, -1); | |
2409 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); | |
2410 g_free(bud_name); | |
2411 } | |
2412 for(buds = account->deny; buds; buds = buds->next) { | |
2413 char *bud_name = g_markup_escape_text(buds->data, -1); | |
2414 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name); | |
2415 g_free(bud_name); | |
2416 } | |
2417 fprintf(file, "\t\t</account>\n"); | |
2418 } | |
2419 g_free(acct_name); | |
2420 } | |
2421 | |
2422 fprintf(file, "\t</privacy>\n"); | |
2423 fprintf(file, "</gaim>\n"); | |
2424 } | |
2425 | |
2426 void gaim_blist_save() { | |
2427 FILE *file; | |
2428 char *user_dir = gaim_user_dir(); | |
2429 char *filename; | |
2430 char *filename_real; | |
2431 | |
2432 if(!user_dir) | |
2433 return; | |
2434 if(!blist_safe_to_write) { | |
2435 gaim_debug(GAIM_DEBUG_WARNING, "blist save", | |
2436 "AHH!! Tried to write the blist before we read it!\n"); | |
2437 return; | |
2438 } | |
2439 | |
2440 file = fopen(user_dir, "r"); | |
2441 if(!file) | |
2442 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR); | |
2443 else | |
2444 fclose(file); | |
2445 | |
2446 filename = g_build_filename(user_dir, "blist.xml.save", NULL); | |
2447 | |
2448 if((file = fopen(filename, "w"))) { | |
2449 gaim_blist_write(file, NULL); | |
2450 fclose(file); | |
2451 chmod(filename, S_IRUSR | S_IWUSR); | |
2452 } else { | |
2453 gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n", | |
2454 filename); | |
2455 } | |
2456 | |
2457 filename_real = g_build_filename(user_dir, "blist.xml", NULL); | |
2458 | |
2459 if(rename(filename, filename_real) < 0) | |
2460 gaim_debug(GAIM_DEBUG_ERROR, "blist save", | |
2461 "Error renaming %s to %s\n", filename, filename_real); | |
2462 | |
2463 | |
2464 g_free(filename); | |
2465 g_free(filename_real); | |
2466 } | |
2467 | |
6695 | 2468 void gaim_group_set_setting(GaimGroup *g, const char *key, |
5228 | 2469 const char *value) { |
2470 if(!g) | |
2471 return; | |
2472 g_hash_table_replace(g->settings, g_strdup(key), g_strdup(value)); | |
2473 } | |
2474 | |
6695 | 2475 char *gaim_group_get_setting(GaimGroup *g, const char *key) { |
5228 | 2476 if(!g) |
2477 return NULL; | |
2478 return g_strdup(g_hash_table_lookup(g->settings, key)); | |
2479 } | |
2480 | |
6695 | 2481 void gaim_blist_chat_set_setting(GaimBlistChat *c, const char *key, |
5906 | 2482 const char *value) |
2483 { | |
2484 if(!c) | |
2485 return; | |
2486 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); | |
2487 } | |
2488 | |
6695 | 2489 char *gaim_blist_chat_get_setting(GaimBlistChat *c, const char *key) |
5906 | 2490 { |
2491 if(!c) | |
2492 return NULL; | |
2493 return g_strdup(g_hash_table_lookup(c->settings, key)); | |
2494 } | |
2495 | |
6695 | 2496 void gaim_buddy_set_setting(GaimBuddy *b, const char *key, |
5228 | 2497 const char *value) { |
2498 if(!b) | |
2499 return; | |
2500 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value)); | |
2501 } | |
2502 | |
6695 | 2503 char *gaim_buddy_get_setting(GaimBuddy *b, const char *key) { |
5228 | 2504 if(!b) |
2505 return NULL; | |
2506 return g_strdup(g_hash_table_lookup(b->settings, key)); | |
2507 } | |
2508 | |
2509 void gaim_set_blist_ui_ops(struct gaim_blist_ui_ops *ops) | |
2510 { | |
2511 blist_ui_ops = ops; | |
2512 } | |
2513 | |
2514 struct gaim_blist_ui_ops * | |
2515 gaim_get_blist_ui_ops(void) | |
2516 { | |
2517 return blist_ui_ops; | |
2518 } | |
2519 | |
6695 | 2520 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) { |
5228 | 2521 if(!group) |
2522 return 0; | |
2523 | |
5277 | 2524 return offline ? group->totalsize : group->currentsize; |
5228 | 2525 } |
2526 | |
6695 | 2527 int gaim_blist_get_group_online_count(GaimGroup *group) { |
5228 | 2528 if(!group) |
2529 return 0; | |
2530 | |
5277 | 2531 return group->online; |
5228 | 2532 } |
2533 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2534 void * |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2535 gaim_blist_get_handle(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2536 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2537 static int handle; |
5228 | 2538 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2539 return &handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2540 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2541 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2542 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2543 gaim_blist_init(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2544 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2545 void *handle = gaim_blist_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2546 |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2547 gaim_signal_register(handle, "buddy-away", |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2548 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2549 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2550 GAIM_SUBTYPE_BLIST_BUDDY)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2551 |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2552 gaim_signal_register(handle, "buddy-back", |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2553 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2554 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2555 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2556 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2557 gaim_signal_register(handle, "buddy-idle", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2558 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2559 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2560 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2561 gaim_signal_register(handle, "buddy-unidle", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2562 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2563 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2564 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2565 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2566 gaim_signal_register(handle, "buddy-signed-on", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2567 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2568 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2569 GAIM_SUBTYPE_BLIST_BUDDY)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2570 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2571 gaim_signal_register(handle, "buddy-signed-off", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2572 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2573 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2574 GAIM_SUBTYPE_BLIST_BUDDY)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2575 |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2576 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
|
2577 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2578 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2579 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2580 gaim_blist_uninit(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2581 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2582 gaim_signals_unregister_by_instance(gaim_blist_get_handle()); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2583 } |