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