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