Mercurial > pidgin.yaz
annotate src/blist.c @ 13867:a092ea4edd4e
[gaim-migrate @ 16333]
Patch #1511180: Buddy list ui_ops fix
I had a hard time figuring out why things were not
working even after I set the blist-uiops using
gaim_blist_set_ui_ops. This patch is a fix for it.
committer: Tailor Script <tailor@pidgin.im>
| author | Sadrul Habib Chowdhury <imadil@gmail.com> |
|---|---|
| date | Sat, 24 Jun 2006 22:25:22 +0000 |
| parents | 8f299b9cd184 |
| children | 085b15c33ca4 |
| rev | line source |
|---|---|
| 5228 | 1 /* |
| 2 * gaim | |
| 3 * | |
| 8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
| 5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 * source distribution. | |
| 5228 | 7 * |
| 8 * This program is free software; you can redistribute it and/or modify | |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 * | |
| 22 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
23 #include "internal.h" |
| 5228 | 24 #include "blist.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
25 #include "conversation.h" |
| 11067 | 26 #include "dbus-maybe.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
27 #include "debug.h" |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
28 #include "notify.h" |
|
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
29 #include "prefs.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
30 #include "privacy.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
31 #include "prpl.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
32 #include "server.h" |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
33 #include "signals.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5855
diff
changeset
|
34 #include "util.h" |
| 10431 | 35 #include "value.h" |
| 7132 | 36 #include "xmlnode.h" |
| 5228 | 37 |
| 38 #define PATHSIZE 1024 | |
| 39 | |
| 10426 | 40 static GaimBlistUiOps *blist_ui_ops = NULL; |
| 41 | |
| 42 static GaimBuddyList *gaimbuddylist = NULL; | |
| 10428 | 43 static guint save_timer = 0; |
| 10426 | 44 static gboolean blist_loaded = FALSE; |
| 7693 | 45 |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
46 |
| 10428 | 47 /********************************************************************* |
| 48 * Private utility functions * | |
| 49 *********************************************************************/ | |
| 50 | |
| 5228 | 51 static GaimBlistNode *gaim_blist_get_last_sibling(GaimBlistNode *node) |
| 52 { | |
| 53 GaimBlistNode *n = node; | |
| 54 if (!n) | |
| 55 return NULL; | |
| 56 while (n->next) | |
| 57 n = n->next; | |
| 58 return n; | |
| 59 } | |
| 6695 | 60 |
| 5228 | 61 static GaimBlistNode *gaim_blist_get_last_child(GaimBlistNode *node) |
| 62 { | |
| 63 if (!node) | |
| 64 return NULL; | |
| 65 return gaim_blist_get_last_sibling(node->child); | |
| 66 } | |
| 67 | |
| 5247 | 68 struct _gaim_hbuddy { |
| 69 char *name; | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
70 GaimAccount *account; |
| 5758 | 71 GaimBlistNode *group; |
| 5247 | 72 }; |
| 73 | |
| 9285 | 74 static guint _gaim_blist_hbuddy_hash(struct _gaim_hbuddy *hb) |
| 5247 | 75 { |
| 76 return g_str_hash(hb->name); | |
| 77 } | |
| 78 | |
| 9285 | 79 static guint _gaim_blist_hbuddy_equal(struct _gaim_hbuddy *hb1, struct _gaim_hbuddy *hb2) |
| 5247 | 80 { |
| 5758 | 81 return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group); |
| 5247 | 82 } |
| 83 | |
| 6742 | 84 static void _gaim_blist_hbuddy_free_key(struct _gaim_hbuddy *hb) |
| 85 { | |
| 86 g_free(hb->name); | |
| 87 g_free(hb); | |
| 88 } | |
| 89 | |
| 10428 | 90 |
| 91 /********************************************************************* | |
| 10429 | 92 * Writing to disk * |
| 10428 | 93 *********************************************************************/ |
| 94 | |
| 95 static void | |
| 10430 | 96 value_to_xmlnode(gpointer key, gpointer hvalue, gpointer user_data) |
| 10428 | 97 { |
| 10429 | 98 const char *name; |
| 10430 | 99 GaimValue *value; |
| 10429 | 100 xmlnode *node, *child; |
| 101 char buf[20]; | |
| 102 | |
| 103 name = (const char *)key; | |
| 10430 | 104 value = (GaimValue *)hvalue; |
| 10429 | 105 node = (xmlnode *)user_data; |
| 106 | |
| 10475 | 107 g_return_if_fail(value != NULL); |
| 108 | |
| 10429 | 109 child = xmlnode_new_child(node, "setting"); |
| 110 xmlnode_set_attrib(child, "name", name); | |
| 111 | |
| 10430 | 112 if (gaim_value_get_type(value) == GAIM_TYPE_INT) { |
| 10429 | 113 xmlnode_set_attrib(child, "type", "int"); |
| 10430 | 114 snprintf(buf, sizeof(buf), "%d", gaim_value_get_int(value)); |
| 10429 | 115 xmlnode_insert_data(child, buf, -1); |
| 10428 | 116 } |
| 10430 | 117 else if (gaim_value_get_type(value) == GAIM_TYPE_STRING) { |
| 10429 | 118 xmlnode_set_attrib(child, "type", "string"); |
| 10430 | 119 xmlnode_insert_data(child, gaim_value_get_string(value), -1); |
| 10429 | 120 } |
| 10430 | 121 else if (gaim_value_get_type(value) == GAIM_TYPE_BOOLEAN) { |
| 10429 | 122 xmlnode_set_attrib(child, "type", "bool"); |
| 10430 | 123 snprintf(buf, sizeof(buf), "%d", gaim_value_get_boolean(value)); |
| 10429 | 124 xmlnode_insert_data(child, buf, -1); |
| 125 } | |
| 10428 | 126 } |
| 127 | |
| 128 static void | |
| 10429 | 129 chat_component_to_xmlnode(gpointer key, gpointer value, gpointer user_data) |
| 10428 | 130 { |
| 10429 | 131 const char *name; |
| 132 const char *data; | |
| 133 xmlnode *node, *child; | |
| 134 | |
| 135 name = (const char *)key; | |
| 136 data = (const char *)value; | |
| 137 node = (xmlnode *)user_data; | |
| 138 | |
| 10431 | 139 g_return_if_fail(data != NULL); |
| 140 | |
| 10429 | 141 child = xmlnode_new_child(node, "component"); |
| 142 xmlnode_set_attrib(child, "name", name); | |
| 143 xmlnode_insert_data(child, data, -1); | |
| 144 } | |
| 145 | |
| 10850 | 146 static xmlnode * |
| 10429 | 147 buddy_to_xmlnode(GaimBlistNode *bnode) |
| 148 { | |
| 149 xmlnode *node, *child; | |
| 150 GaimBuddy *buddy; | |
| 151 | |
| 152 buddy = (GaimBuddy *)bnode; | |
| 153 | |
| 154 node = xmlnode_new("buddy"); | |
| 155 xmlnode_set_attrib(node, "account", gaim_account_get_username(buddy->account)); | |
| 156 xmlnode_set_attrib(node, "proto", gaim_account_get_protocol_id(buddy->account)); | |
| 157 | |
| 158 child = xmlnode_new_child(node, "name"); | |
| 159 xmlnode_insert_data(child, buddy->name, -1); | |
| 160 | |
| 161 if (buddy->alias != NULL) | |
| 162 { | |
| 163 child = xmlnode_new_child(node, "alias"); | |
| 164 xmlnode_insert_data(child, buddy->alias, -1); | |
| 10428 | 165 } |
| 166 | |
| 10429 | 167 /* Write buddy settings */ |
| 10430 | 168 g_hash_table_foreach(buddy->node.settings, value_to_xmlnode, node); |
| 10429 | 169 |
| 170 return node; | |
| 10428 | 171 } |
| 172 | |
| 10850 | 173 static xmlnode * |
| 10429 | 174 contact_to_xmlnode(GaimBlistNode *cnode) |
| 10428 | 175 { |
| 10429 | 176 xmlnode *node, *child; |
| 177 GaimContact *contact; | |
| 178 GaimBlistNode *bnode; | |
| 179 | |
| 180 contact = (GaimContact *)cnode; | |
| 181 | |
| 182 node = xmlnode_new("contact"); | |
| 183 | |
| 184 if (contact->alias != NULL) | |
| 185 { | |
| 186 xmlnode_set_attrib(node, "alias", contact->alias); | |
| 10428 | 187 } |
| 10429 | 188 |
| 189 /* Write buddies */ | |
| 190 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) | |
| 191 { | |
| 192 if (!GAIM_BLIST_NODE_SHOULD_SAVE(bnode)) | |
| 193 continue; | |
| 194 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 195 { | |
| 196 child = buddy_to_xmlnode(bnode); | |
| 197 xmlnode_insert_child(node, child); | |
| 10428 | 198 } |
| 199 } | |
| 200 | |
| 10429 | 201 /* Write contact settings */ |
| 10430 | 202 g_hash_table_foreach(cnode->settings, value_to_xmlnode, node); |
| 10429 | 203 |
| 204 return node; | |
| 10428 | 205 } |
| 206 | |
| 10850 | 207 static xmlnode * |
| 10429 | 208 chat_to_xmlnode(GaimBlistNode *cnode) |
| 10428 | 209 { |
| 10429 | 210 xmlnode *node, *child; |
| 211 GaimChat *chat; | |
| 212 | |
| 213 chat = (GaimChat *)cnode; | |
| 214 | |
| 215 node = xmlnode_new("chat"); | |
| 216 xmlnode_set_attrib(node, "proto", gaim_account_get_protocol_id(chat->account)); | |
| 217 xmlnode_set_attrib(node, "account", gaim_account_get_username(chat->account)); | |
| 218 | |
| 219 if (chat->alias != NULL) | |
| 220 { | |
| 221 child = xmlnode_new_child(node, "alias"); | |
| 222 xmlnode_insert_data(child, chat->alias, -1); | |
| 10428 | 223 } |
| 224 | |
| 10429 | 225 /* Write chat components */ |
| 226 g_hash_table_foreach(chat->components, chat_component_to_xmlnode, node); | |
| 227 | |
| 228 /* Write chat settings */ | |
| 10430 | 229 g_hash_table_foreach(chat->node.settings, value_to_xmlnode, node); |
| 10429 | 230 |
| 231 return node; | |
| 10428 | 232 } |
| 233 | |
| 10850 | 234 static xmlnode * |
| 10429 | 235 group_to_xmlnode(GaimBlistNode *gnode) |
| 10428 | 236 { |
| 10429 | 237 xmlnode *node, *child; |
| 238 GaimGroup *group; | |
| 239 GaimBlistNode *cnode; | |
| 240 | |
| 241 group = (GaimGroup *)gnode; | |
| 242 | |
| 243 node = xmlnode_new("group"); | |
| 244 xmlnode_set_attrib(node, "name", group->name); | |
| 245 | |
| 246 /* Write settings */ | |
| 10430 | 247 g_hash_table_foreach(group->node.settings, value_to_xmlnode, node); |
| 10429 | 248 |
| 249 /* Write contacts and chats */ | |
| 250 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) | |
| 251 { | |
| 252 if (!GAIM_BLIST_NODE_SHOULD_SAVE(cnode)) | |
| 253 continue; | |
| 254 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 255 { | |
| 256 child = contact_to_xmlnode(cnode); | |
| 257 xmlnode_insert_child(node, child); | |
| 258 } | |
| 259 else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
| 260 { | |
| 261 child = chat_to_xmlnode(cnode); | |
| 262 xmlnode_insert_child(node, child); | |
| 10428 | 263 } |
| 264 } | |
| 265 | |
| 10429 | 266 return node; |
| 10428 | 267 } |
| 268 | |
| 10850 | 269 static xmlnode * |
| 10429 | 270 accountprivacy_to_xmlnode(GaimAccount *account) |
| 10428 | 271 { |
| 10429 | 272 xmlnode *node, *child; |
| 273 GSList *cur; | |
| 274 char buf[10]; | |
| 275 | |
| 276 node = xmlnode_new("account"); | |
| 277 xmlnode_set_attrib(node, "proto", gaim_account_get_protocol_id(account)); | |
| 278 xmlnode_set_attrib(node, "name", gaim_account_get_username(account)); | |
| 279 snprintf(buf, sizeof(buf), "%d", account->perm_deny); | |
| 280 xmlnode_set_attrib(node, "mode", buf); | |
| 281 | |
| 282 for (cur = account->permit; cur; cur = cur->next) | |
| 283 { | |
| 284 child = xmlnode_new_child(node, "permit"); | |
| 285 xmlnode_insert_data(child, cur->data, -1); | |
| 10428 | 286 } |
| 287 | |
| 10429 | 288 for (cur = account->deny; cur; cur = cur->next) |
| 289 { | |
| 290 child = xmlnode_new_child(node, "block"); | |
| 291 xmlnode_insert_data(child, cur->data, -1); | |
| 10428 | 292 } |
| 293 | |
| 10429 | 294 return node; |
| 10428 | 295 } |
| 296 | |
| 10850 | 297 static xmlnode * |
| 10429 | 298 blist_to_xmlnode() |
| 10428 | 299 { |
| 10429 | 300 xmlnode *node, *child, *grandchild; |
| 10428 | 301 GaimBlistNode *gnode; |
| 10429 | 302 GList *cur; |
| 303 | |
| 304 node = xmlnode_new("gaim"); | |
| 305 xmlnode_set_attrib(node, "version", "1.0"); | |
| 306 | |
| 307 /* Write groups */ | |
| 308 child = xmlnode_new_child(node, "blist"); | |
| 309 for (gnode = gaimbuddylist->root; gnode != NULL; gnode = gnode->next) | |
| 310 { | |
| 311 if (!GAIM_BLIST_NODE_SHOULD_SAVE(gnode)) | |
| 312 continue; | |
| 10428 | 313 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 10429 | 314 { |
| 315 grandchild = group_to_xmlnode(gnode); | |
| 316 xmlnode_insert_child(child, grandchild); | |
| 317 } | |
| 10428 | 318 } |
| 319 | |
| 10429 | 320 /* Write privacy settings */ |
| 321 child = xmlnode_new_child(node, "privacy"); | |
| 322 for (cur = gaim_accounts_get_all(); cur != NULL; cur = cur->next) | |
| 323 { | |
| 324 grandchild = accountprivacy_to_xmlnode(cur->data); | |
| 325 xmlnode_insert_child(child, grandchild); | |
| 10428 | 326 } |
| 327 | |
| 10429 | 328 return node; |
| 10428 | 329 } |
| 330 | |
|
12398
bd42f4d5854c
[gaim-migrate @ 14705]
Richard Laager <rlaager@wiktel.com>
parents:
12319
diff
changeset
|
331 static void |
| 10428 | 332 gaim_blist_sync() |
| 10378 | 333 { |
| 10429 | 334 xmlnode *node; |
| 335 char *data; | |
| 336 | |
| 337 if (!blist_loaded) | |
| 338 { | |
| 339 gaim_debug_error("blist", "Attempted to save buddy list before it " | |
| 340 "was read!\n"); | |
| 10428 | 341 return; |
| 342 } | |
| 343 | |
| 10429 | 344 node = blist_to_xmlnode(); |
| 345 data = xmlnode_to_formatted_str(node, NULL); | |
| 346 gaim_util_write_data_to_file("blist.xml", data, -1); | |
| 347 g_free(data); | |
| 348 xmlnode_free(node); | |
| 10428 | 349 } |
| 350 | |
| 351 static gboolean | |
| 352 save_cb(gpointer data) | |
| 353 { | |
| 354 gaim_blist_sync(); | |
| 355 save_timer = 0; | |
| 356 return FALSE; | |
| 357 } | |
| 358 | |
| 10704 | 359 void |
| 360 gaim_blist_schedule_save() | |
| 10428 | 361 { |
| 362 if (save_timer == 0) | |
| 363 save_timer = gaim_timeout_add(5000, save_cb, NULL); | |
| 364 } | |
| 365 | |
| 366 | |
| 367 /********************************************************************* | |
| 368 * Reading from disk * | |
| 369 *********************************************************************/ | |
| 370 | |
| 371 static void | |
| 372 parse_setting(GaimBlistNode *node, xmlnode *setting) | |
| 373 { | |
| 374 const char *name = xmlnode_get_attrib(setting, "name"); | |
| 375 const char *type = xmlnode_get_attrib(setting, "type"); | |
| 376 char *value = xmlnode_get_data(setting); | |
| 377 | |
| 378 if (!value) | |
| 379 return; | |
| 380 | |
| 381 if (!type || !strcmp(type, "string")) | |
| 382 gaim_blist_node_set_string(node, name, value); | |
| 383 else if (!strcmp(type, "bool")) | |
| 384 gaim_blist_node_set_bool(node, name, atoi(value)); | |
| 385 else if (!strcmp(type, "int")) | |
| 386 gaim_blist_node_set_int(node, name, atoi(value)); | |
| 387 | |
| 388 g_free(value); | |
| 389 } | |
| 390 | |
| 391 static void | |
| 392 parse_buddy(GaimGroup *group, GaimContact *contact, xmlnode *bnode) | |
| 393 { | |
| 394 GaimAccount *account; | |
| 395 GaimBuddy *buddy; | |
| 396 char *name = NULL, *alias = NULL; | |
| 397 const char *acct_name, *proto, *protocol; | |
| 398 xmlnode *x; | |
| 399 | |
| 400 acct_name = xmlnode_get_attrib(bnode, "account"); | |
| 401 protocol = xmlnode_get_attrib(bnode, "protocol"); | |
| 402 proto = xmlnode_get_attrib(bnode, "proto"); | |
| 403 | |
| 404 if (!acct_name || (!proto && !protocol)) | |
| 405 return; | |
| 406 | |
| 407 account = gaim_accounts_find(acct_name, proto ? proto : protocol); | |
| 408 | |
| 409 if (!account) | |
| 410 return; | |
| 411 | |
| 412 if ((x = xmlnode_get_child(bnode, "name"))) | |
| 413 name = xmlnode_get_data(x); | |
| 414 | |
| 415 if (!name) | |
| 416 return; | |
| 417 | |
| 418 if ((x = xmlnode_get_child(bnode, "alias"))) | |
| 419 alias = xmlnode_get_data(x); | |
| 420 | |
| 421 buddy = gaim_buddy_new(account, name, alias); | |
| 422 gaim_blist_add_buddy(buddy, contact, group, | |
| 423 gaim_blist_get_last_child((GaimBlistNode*)contact)); | |
| 424 | |
| 425 for (x = xmlnode_get_child(bnode, "setting"); x; x = xmlnode_get_next_twin(x)) { | |
| 426 parse_setting((GaimBlistNode*)buddy, x); | |
| 427 } | |
| 428 | |
| 429 g_free(name); | |
| 12687 | 430 g_free(alias); |
| 10378 | 431 } |
| 432 | |
| 10428 | 433 static void |
| 434 parse_contact(GaimGroup *group, xmlnode *cnode) | |
| 435 { | |
| 436 GaimContact *contact = gaim_contact_new(); | |
| 437 xmlnode *x; | |
| 438 const char *alias; | |
| 439 | |
| 440 gaim_blist_add_contact(contact, group, | |
| 441 gaim_blist_get_last_child((GaimBlistNode*)group)); | |
| 442 | |
| 443 if ((alias = xmlnode_get_attrib(cnode, "alias"))) { | |
| 444 gaim_contact_set_alias(contact, alias); | |
| 445 } | |
| 446 | |
| 447 for (x = cnode->child; x; x = x->next) { | |
| 448 if (x->type != XMLNODE_TYPE_TAG) | |
| 449 continue; | |
| 450 if (!strcmp(x->name, "buddy")) | |
| 451 parse_buddy(group, contact, x); | |
| 452 else if (!strcmp(x->name, "setting")) | |
| 453 parse_setting((GaimBlistNode*)contact, x); | |
| 454 } | |
| 455 | |
| 456 /* if the contact is empty, don't keep it around. it causes problems */ | |
| 457 if (!((GaimBlistNode*)contact)->child) | |
| 458 gaim_blist_remove_contact(contact); | |
| 459 } | |
| 460 | |
| 461 static void | |
| 462 parse_chat(GaimGroup *group, xmlnode *cnode) | |
| 463 { | |
| 464 GaimChat *chat; | |
| 465 GaimAccount *account; | |
| 466 const char *acct_name, *proto, *protocol; | |
| 467 xmlnode *x; | |
| 468 char *alias = NULL; | |
| 469 GHashTable *components; | |
| 470 | |
| 471 acct_name = xmlnode_get_attrib(cnode, "account"); | |
| 472 protocol = xmlnode_get_attrib(cnode, "protocol"); | |
| 473 proto = xmlnode_get_attrib(cnode, "proto"); | |
| 474 | |
| 475 if (!acct_name || (!proto && !protocol)) | |
| 476 return; | |
| 477 | |
| 478 account = gaim_accounts_find(acct_name, proto ? proto : protocol); | |
| 479 | |
| 480 if (!account) | |
| 481 return; | |
| 482 | |
| 483 if ((x = xmlnode_get_child(cnode, "alias"))) | |
| 484 alias = xmlnode_get_data(x); | |
| 485 | |
| 486 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 487 | |
| 488 for (x = xmlnode_get_child(cnode, "component"); x; x = xmlnode_get_next_twin(x)) { | |
| 489 const char *name; | |
| 490 char *value; | |
| 491 | |
| 492 name = xmlnode_get_attrib(x, "name"); | |
| 493 value = xmlnode_get_data(x); | |
| 494 g_hash_table_replace(components, g_strdup(name), value); | |
| 495 } | |
| 496 | |
| 497 chat = gaim_chat_new(account, alias, components); | |
| 498 gaim_blist_add_chat(chat, group, | |
| 499 gaim_blist_get_last_child((GaimBlistNode*)group)); | |
| 500 | |
| 501 for (x = xmlnode_get_child(cnode, "setting"); x; x = xmlnode_get_next_twin(x)) { | |
| 502 parse_setting((GaimBlistNode*)chat, x); | |
| 503 } | |
| 504 | |
| 12687 | 505 g_free(alias); |
| 10428 | 506 } |
| 507 | |
| 508 static void | |
| 509 parse_group(xmlnode *groupnode) | |
| 510 { | |
| 511 const char *name = xmlnode_get_attrib(groupnode, "name"); | |
| 512 GaimGroup *group; | |
| 513 xmlnode *cnode; | |
| 514 | |
| 515 if (!name) | |
| 516 name = _("Buddies"); | |
| 517 | |
| 518 group = gaim_group_new(name); | |
| 519 gaim_blist_add_group(group, | |
| 520 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 521 | |
| 522 for (cnode = groupnode->child; cnode; cnode = cnode->next) { | |
| 523 if (cnode->type != XMLNODE_TYPE_TAG) | |
| 524 continue; | |
| 525 if (!strcmp(cnode->name, "setting")) | |
| 526 parse_setting((GaimBlistNode*)group, cnode); | |
| 527 else if (!strcmp(cnode->name, "contact") || | |
| 528 !strcmp(cnode->name, "person")) | |
| 529 parse_contact(group, cnode); | |
| 530 else if (!strcmp(cnode->name, "chat")) | |
| 531 parse_chat(group, cnode); | |
| 532 } | |
| 533 } | |
| 534 | |
| 535 /* TODO: Make static and rename to load_blist */ | |
| 536 void | |
| 537 gaim_blist_load() | |
| 538 { | |
| 539 xmlnode *gaim, *blist, *privacy; | |
| 540 | |
| 541 blist_loaded = TRUE; | |
| 542 | |
| 543 gaim = gaim_util_read_xml_from_file("blist.xml", _("buddy list")); | |
| 544 | |
| 545 if (gaim == NULL) | |
| 546 return; | |
| 547 | |
| 548 blist = xmlnode_get_child(gaim, "blist"); | |
| 549 if (blist) { | |
| 550 xmlnode *groupnode; | |
| 551 for (groupnode = xmlnode_get_child(blist, "group"); groupnode != NULL; | |
| 552 groupnode = xmlnode_get_next_twin(groupnode)) { | |
| 553 parse_group(groupnode); | |
| 554 } | |
| 555 } | |
| 556 | |
| 557 privacy = xmlnode_get_child(gaim, "privacy"); | |
| 558 if (privacy) { | |
| 559 xmlnode *anode; | |
| 560 for (anode = privacy->child; anode; anode = anode->next) { | |
| 561 xmlnode *x; | |
| 562 GaimAccount *account; | |
| 10944 | 563 int imode; |
| 10428 | 564 const char *acct_name, *proto, *mode, *protocol; |
| 565 | |
| 566 acct_name = xmlnode_get_attrib(anode, "name"); | |
| 567 protocol = xmlnode_get_attrib(anode, "protocol"); | |
| 568 proto = xmlnode_get_attrib(anode, "proto"); | |
| 569 mode = xmlnode_get_attrib(anode, "mode"); | |
| 570 | |
| 571 if (!acct_name || (!proto && !protocol) || !mode) | |
| 572 continue; | |
| 573 | |
| 574 account = gaim_accounts_find(acct_name, proto ? proto : protocol); | |
| 575 | |
| 576 if (!account) | |
| 577 continue; | |
| 578 | |
| 10944 | 579 imode = atoi(mode); |
| 10945 | 580 account->perm_deny = (imode != 0 ? imode : GAIM_PRIVACY_ALLOW_ALL); |
| 10428 | 581 |
| 582 for (x = anode->child; x; x = x->next) { | |
| 583 char *name; | |
| 584 if (x->type != XMLNODE_TYPE_TAG) | |
| 585 continue; | |
| 586 | |
| 587 if (!strcmp(x->name, "permit")) { | |
| 588 name = xmlnode_get_data(x); | |
| 589 gaim_privacy_permit_add(account, name, TRUE); | |
| 590 g_free(name); | |
| 591 } else if (!strcmp(x->name, "block")) { | |
| 592 name = xmlnode_get_data(x); | |
| 593 gaim_privacy_deny_add(account, name, TRUE); | |
| 594 g_free(name); | |
| 595 } | |
| 596 } | |
| 597 } | |
| 598 } | |
| 599 | |
| 600 xmlnode_free(gaim); | |
| 601 } | |
| 602 | |
| 603 | |
| 604 /********************************************************************* | |
| 605 * Stuff * | |
| 606 *********************************************************************/ | |
| 607 | |
| 608 static void | |
| 609 gaim_contact_compute_priority_buddy(GaimContact *contact) | |
| 6843 | 610 { |
| 611 GaimBlistNode *bnode; | |
| 9949 | 612 GaimBuddy *new_priority = NULL; |
| 9285 | 613 |
| 614 g_return_if_fail(contact != NULL); | |
| 615 | |
| 6870 | 616 contact->priority = NULL; |
| 9949 | 617 for (bnode = ((GaimBlistNode*)contact)->child; |
| 618 bnode != NULL; | |
| 619 bnode = bnode->next) | |
| 620 { | |
| 6843 | 621 GaimBuddy *buddy; |
| 7420 | 622 |
| 9285 | 623 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
| 6843 | 624 continue; |
| 9949 | 625 |
| 6843 | 626 buddy = (GaimBuddy*)bnode; |
| 9949 | 627 |
| 9285 | 628 if (!gaim_account_is_connected(buddy->account)) |
| 6843 | 629 continue; |
| 9949 | 630 if (new_priority == NULL) |
| 631 new_priority = buddy; | |
| 632 else | |
| 633 { | |
| 634 int cmp; | |
| 10427 | 635 |
| 10368 | 636 cmp = gaim_presence_compare(gaim_buddy_get_presence(new_priority), |
| 637 gaim_buddy_get_presence(buddy)); | |
| 9949 | 638 |
| 639 if (cmp > 0 || (cmp == 0 && | |
| 10368 | 640 gaim_prefs_get_bool("/core/contact/last_match"))) |
| 9949 | 641 { |
| 642 new_priority = buddy; | |
| 643 } | |
| 644 } | |
| 6843 | 645 } |
| 9949 | 646 |
| 647 contact->priority = new_priority; | |
| 10378 | 648 contact->priority_valid = TRUE; |
| 6843 | 649 } |
| 650 | |
| 651 | |
| 5228 | 652 /***************************************************************************** |
| 653 * Public API functions * | |
| 654 *****************************************************************************/ | |
| 655 | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
656 GaimBuddyList *gaim_blist_new() |
| 5228 | 657 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
658 GaimBlistUiOps *ui_ops; |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
659 GaimBuddyList *gbl = g_new0(GaimBuddyList, 1); |
| 11146 | 660 GAIM_DBUS_REGISTER_POINTER(gbl, GaimBuddyList); |
| 5228 | 661 |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
662 ui_ops = gaim_blist_get_ui_ops(); |
| 5228 | 663 |
| 6742 | 664 gbl->buddies = g_hash_table_new_full((GHashFunc)_gaim_blist_hbuddy_hash, |
| 665 (GEqualFunc)_gaim_blist_hbuddy_equal, | |
| 666 (GDestroyNotify)_gaim_blist_hbuddy_free_key, NULL); | |
| 5247 | 667 |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
668 if (ui_ops != NULL && ui_ops->new_list != NULL) |
|
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
669 ui_ops->new_list(gbl); |
| 5228 | 670 |
| 671 return gbl; | |
| 672 } | |
| 673 | |
| 674 void | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
675 gaim_set_blist(GaimBuddyList *list) |
| 5228 | 676 { |
| 677 gaimbuddylist = list; | |
| 678 } | |
| 679 | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
680 GaimBuddyList * |
| 9285 | 681 gaim_get_blist() |
| 5228 | 682 { |
| 683 return gaimbuddylist; | |
| 684 } | |
| 685 | |
| 13484 | 686 GaimBlistNode * |
| 687 gaim_blist_get_root() | |
| 688 { | |
| 689 return gaimbuddylist ? gaimbuddylist->root : NULL; | |
| 690 } | |
| 691 | |
| 9285 | 692 void gaim_blist_show() |
| 5228 | 693 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
694 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 695 |
| 696 if (ops && ops->show) | |
| 5228 | 697 ops->show(gaimbuddylist); |
| 698 } | |
| 699 | |
| 700 void gaim_blist_destroy() | |
| 701 { | |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
702 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 703 |
|
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8200
diff
changeset
|
704 gaim_debug(GAIM_DEBUG_INFO, "blist", "Destroying\n"); |
| 9285 | 705 |
| 706 if (ops && ops->destroy) | |
| 5228 | 707 ops->destroy(gaimbuddylist); |
| 708 } | |
| 709 | |
| 9285 | 710 void gaim_blist_set_visible(gboolean show) |
| 5228 | 711 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
712 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 713 |
| 714 if (ops && ops->set_visible) | |
| 5228 | 715 ops->set_visible(gaimbuddylist, show); |
| 716 } | |
| 717 | |
| 12112 | 718 static GaimBlistNode *get_next_node(GaimBlistNode *node, gboolean godeep) |
| 719 { | |
| 720 if (node == NULL) | |
| 721 return NULL; | |
| 722 | |
| 723 if (godeep && node->child) | |
| 724 return node->child; | |
| 725 | |
| 726 if (node->next) | |
| 727 return node->next; | |
| 728 | |
| 729 return get_next_node(node->parent, FALSE); | |
| 730 } | |
| 731 | |
| 732 GaimBlistNode *gaim_blist_node_next(GaimBlistNode *node, gboolean offline) | |
| 733 { | |
| 734 GaimBlistNode *ret = node; | |
| 735 | |
| 736 do | |
| 737 { | |
| 738 ret = get_next_node(ret, TRUE); | |
| 739 } while (ret && !offline && GAIM_BLIST_NODE_IS_BUDDY(ret) && | |
| 740 !gaim_account_is_connected(gaim_buddy_get_account((GaimBuddy *)ret))); | |
| 741 | |
| 742 return ret; | |
| 743 } | |
| 744 | |
| 10052 | 745 void |
| 746 gaim_blist_update_buddy_status(GaimBuddy *buddy, GaimStatus *old_status) | |
| 9285 | 747 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
748 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 10052 | 749 GaimPresence *presence; |
| 750 GaimStatus *status; | |
| 9285 | 751 |
| 752 g_return_if_fail(buddy != NULL); | |
| 5228 | 753 |
| 10052 | 754 presence = gaim_buddy_get_presence(buddy); |
| 755 status = gaim_presence_get_active_status(presence); | |
| 756 | |
| 10847 | 757 gaim_debug_info("blist", "Updating buddy status for %s (%s)\n", |
| 758 buddy->name, gaim_account_get_protocol_name(buddy->account)); | |
| 10052 | 759 |
| 760 if (gaim_status_is_online(status) && | |
| 761 !gaim_status_is_online(old_status)) { | |
| 11910 | 762 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
763 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy); |
| 11910 | 764 |
| 765 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online++; | |
| 766 if (((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 1) | |
| 767 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online++; | |
| 10052 | 768 } else if (!gaim_status_is_online(status) && |
| 769 gaim_status_is_online(old_status)) { | |
| 10475 | 770 gaim_blist_node_set_int(&buddy->node, "last_seen", time(NULL)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
771 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy); |
| 11910 | 772 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online--; |
| 773 if (((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 0) | |
| 774 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online--; | |
|
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
775 } else { |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
776 gaim_signal_emit(gaim_blist_get_handle(), |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
777 "buddy-status-changed", buddy, old_status, |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
778 status); |
| 5228 | 779 } |
| 780 | |
| 10205 | 781 /* |
| 782 * This function used to only call the following two functions if one of | |
| 783 * the above signals had been triggered, but that's not good, because | |
| 784 * if someone's away message changes and they don't go from away to back | |
| 785 * to away then no signal is triggered. | |
| 786 * | |
| 787 * It's a safe assumption that SOMETHING called this function. PROBABLY | |
| 788 * because something, somewhere changed. Calling the stuff below | |
| 789 * certainly won't hurt anything. Unless you're on a K6-2 300. | |
| 790 */ | |
| 10378 | 791 gaim_contact_invalidate_priority_buddy(gaim_buddy_get_contact(buddy)); |
| 10205 | 792 if (ops && ops->update) |
| 793 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | |
| 5228 | 794 } |
| 795 | |
| 9285 | 796 void gaim_blist_update_buddy_icon(GaimBuddy *buddy) |
| 5228 | 797 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
798 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 799 |
| 800 g_return_if_fail(buddy != NULL); | |
| 801 | |
| 802 if (ops && ops->update) | |
| 803 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | |
| 804 } | |
| 805 | |
| 806 /* | |
| 10428 | 807 * TODO: Maybe remove the call to this from server.c and call it |
| 9285 | 808 * from oscar.c and toc.c instead? |
| 809 */ | |
| 810 void gaim_blist_rename_buddy(GaimBuddy *buddy, const char *name) | |
| 811 { | |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
812 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 813 struct _gaim_hbuddy *hb; |
| 814 | |
| 815 g_return_if_fail(buddy != NULL); | |
| 816 | |
| 817 hb = g_new(struct _gaim_hbuddy, 1); | |
| 8675 | 818 hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); |
| 819 hb->account = buddy->account; | |
| 820 hb->group = ((GaimBlistNode *)buddy)->parent->parent; | |
| 821 g_hash_table_remove(gaimbuddylist->buddies, hb); | |
| 822 | |
| 823 g_free(hb->name); | |
| 824 hb->name = g_strdup(gaim_normalize(buddy->account, name)); | |
| 825 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy); | |
| 826 | |
| 5634 | 827 g_free(buddy->name); |
| 5228 | 828 buddy->name = g_strdup(name); |
| 9285 | 829 |
| 10704 | 830 gaim_blist_schedule_save(); |
| 9285 | 831 |
| 832 if (ops && ops->update) | |
| 833 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | |
| 5228 | 834 } |
| 5234 | 835 |
|
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
836 void gaim_blist_alias_contact(GaimContact *contact, const char *alias) |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
837 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
838 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
|
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
839 GaimConversation *conv; |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
840 char *old_alias = contact->alias; |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
841 GaimBlistNode *bnode; |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
842 |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
843 g_return_if_fail(contact != NULL); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
844 |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
845 if ((alias != NULL) && (*alias != '\0')) |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
846 contact->alias = g_strdup(alias); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
847 else |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
848 contact->alias = NULL; |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
849 |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
850 gaim_blist_schedule_save(); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
851 |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
852 if (ops && ops->update) |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
853 ops->update(gaimbuddylist, (GaimBlistNode *)contact); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
854 |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
855 for(bnode = ((GaimBlistNode *)contact)->child; bnode != NULL; bnode = bnode->next) |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
856 { |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
857 GaimBuddy *buddy = (GaimBuddy *)bnode; |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
858 |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
859 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
860 buddy->account); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
861 if (conv) |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
862 gaim_conversation_autoset_title(conv); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
863 } |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
864 |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
865 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
866 contact, old_alias); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
867 g_free(old_alias); |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
868 } |
|
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12305
diff
changeset
|
869 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
870 void gaim_blist_alias_chat(GaimChat *chat, const char *alias) |
| 5234 | 871 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
872 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
873 char *old_alias = chat->alias; |
| 5234 | 874 |
| 9285 | 875 g_return_if_fail(chat != NULL); |
| 876 | |
| 877 if ((alias != NULL) && (*alias != '\0')) | |
| 5237 | 878 chat->alias = g_strdup(alias); |
| 879 else | |
| 880 chat->alias = NULL; | |
| 881 | |
| 10704 | 882 gaim_blist_schedule_save(); |
| 9285 | 883 |
| 884 if (ops && ops->update) | |
| 885 ops->update(gaimbuddylist, (GaimBlistNode *)chat); | |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
886 |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
887 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
888 chat, old_alias); |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
889 g_free(old_alias); |
| 5234 | 890 } |
| 891 | |
| 9285 | 892 void gaim_blist_alias_buddy(GaimBuddy *buddy, const char *alias) |
| 5228 | 893 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
894 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
|
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5634
diff
changeset
|
895 GaimConversation *conv; |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
896 char *old_alias = buddy->alias; |
| 5228 | 897 |
| 9285 | 898 g_return_if_fail(buddy != NULL); |
| 899 | |
| 900 if ((alias != NULL) && (*alias != '\0')) | |
| 5228 | 901 buddy->alias = g_strdup(alias); |
| 902 else | |
| 903 buddy->alias = NULL; | |
| 904 | |
| 10704 | 905 gaim_blist_schedule_save(); |
| 9285 | 906 |
| 907 if (ops && ops->update) | |
| 908 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | |
| 5228 | 909 |
| 11338 | 910 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, |
| 10246 | 911 buddy->account); |
| 5228 | 912 if (conv) |
| 913 gaim_conversation_autoset_title(conv); | |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
914 |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
915 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
916 buddy, old_alias); |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
917 g_free(old_alias); |
| 5228 | 918 } |
| 919 | |
| 9285 | 920 void gaim_blist_server_alias_buddy(GaimBuddy *buddy, const char *alias) |
| 6058 | 921 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
922 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 6058 | 923 GaimConversation *conv; |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
924 char *old_alias = buddy->server_alias; |
| 6058 | 925 |
| 9285 | 926 g_return_if_fail(buddy != NULL); |
| 927 | |
| 928 if ((alias != NULL) && (*alias != '\0') && g_utf8_validate(alias, -1, NULL)) | |
| 6058 | 929 buddy->server_alias = g_strdup(alias); |
| 930 else | |
| 931 buddy->server_alias = NULL; | |
| 932 | |
| 10704 | 933 gaim_blist_schedule_save(); |
| 9285 | 934 |
| 935 if (ops && ops->update) | |
| 936 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | |
| 6058 | 937 |
| 11338 | 938 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, |
| 10246 | 939 buddy->account); |
| 6058 | 940 if (conv) |
| 941 gaim_conversation_autoset_title(conv); | |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
942 |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
943 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
944 buddy, old_alias); |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
945 g_free(old_alias); |
| 6058 | 946 } |
| 947 | |
| 9285 | 948 /* |
| 10428 | 949 * TODO: If merging, prompt the user if they want to merge. |
| 9285 | 950 */ |
| 951 void gaim_blist_rename_group(GaimGroup *source, const char *new_name) | |
| 5228 | 952 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
953 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 954 GaimGroup *dest; |
| 955 gchar *old_name; | |
| 956 GList *moved_buddies = NULL; | |
| 5346 | 957 GSList *accts; |
| 958 | |
| 9285 | 959 g_return_if_fail(source != NULL); |
| 960 g_return_if_fail(new_name != NULL); | |
| 961 | |
| 962 if (*new_name == '\0' || !strcmp(new_name, source->name)) | |
| 5346 | 963 return; |
| 9285 | 964 |
| 965 dest = gaim_find_group(new_name); | |
| 966 if (dest != NULL) { | |
| 967 /* We're merging two groups */ | |
| 968 GaimBlistNode *prev, *child, *next; | |
| 969 | |
| 970 prev = gaim_blist_get_last_child((GaimBlistNode*)dest); | |
| 971 child = ((GaimBlistNode*)source)->child; | |
| 972 | |
| 973 /* | |
| 10428 | 974 * TODO: This seems like a dumb way to do this... why not just |
| 9285 | 975 * append all children from the old group to the end of the new |
| 976 * one? PRPLs might be expecting to receive an add_buddy() for | |
| 977 * each moved buddy... | |
| 978 */ | |
| 979 while (child) | |
| 5346 | 980 { |
| 981 next = child->next; | |
| 9285 | 982 if (GAIM_BLIST_NODE_IS_CONTACT(child)) { |
| 6695 | 983 GaimBlistNode *bnode; |
| 9285 | 984 gaim_blist_add_contact((GaimContact *)child, dest, prev); |
| 985 for (bnode = child->child; bnode != NULL; bnode = bnode->next) { | |
| 986 gaim_blist_add_buddy((GaimBuddy *)bnode, (GaimContact *)child, | |
| 6695 | 987 NULL, bnode->prev); |
| 9285 | 988 moved_buddies = g_list_append(moved_buddies, bnode); |
| 989 } | |
| 5346 | 990 prev = child; |
| 9285 | 991 } else if (GAIM_BLIST_NODE_IS_CHAT(child)) { |
| 992 gaim_blist_add_chat((GaimChat *)child, dest, prev); | |
| 5346 | 993 prev = child; |
| 994 } else { | |
| 995 gaim_debug(GAIM_DEBUG_ERROR, "blist", | |
| 9285 | 996 "Unknown child type in group %s\n", source->name); |
| 5346 | 997 } |
| 998 child = next; | |
| 999 } | |
| 9285 | 1000 |
| 1001 /* Make a copy of the old group name and then delete the old group */ | |
| 1002 old_name = g_strdup(source->name); | |
| 1003 gaim_blist_remove_group(source); | |
| 13195 | 1004 source = dest; |
| 5346 | 1005 } else { |
| 9285 | 1006 /* A simple rename */ |
| 1007 GaimBlistNode *cnode, *bnode; | |
| 1008 | |
| 1009 /* Build a GList of all buddies in this group */ | |
| 1010 for (cnode = ((GaimBlistNode *)source)->child; cnode != NULL; cnode = cnode->next) { | |
| 1011 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 1012 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) | |
| 1013 moved_buddies = g_list_append(moved_buddies, bnode); | |
| 5346 | 1014 } |
| 9285 | 1015 |
| 1016 old_name = source->name; | |
| 1017 source->name = g_strdup(new_name); | |
| 5346 | 1018 } |
| 9285 | 1019 |
| 1020 /* Save our changes */ | |
| 10704 | 1021 gaim_blist_schedule_save(); |
| 9285 | 1022 |
| 1023 /* Update the UI */ | |
| 1024 if (ops && ops->update) | |
| 1025 ops->update(gaimbuddylist, (GaimBlistNode*)source); | |
| 1026 | |
| 1027 /* Notify all PRPLs */ | |
| 13195 | 1028 /* TODO: Is this condition needed? Seems like it would always be TRUE */ |
|
10853
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1029 if(old_name && source && strcmp(source->name, old_name)) { |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1030 for (accts = gaim_group_get_accounts(source); accts; accts = g_slist_remove(accts, accts->data)) { |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1031 GaimAccount *account = accts->data; |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1032 GaimPluginProtocolInfo *prpl_info = NULL; |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1033 GList *l = NULL, *buddies = NULL; |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1034 |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1035 if(account->gc && account->gc->prpl) |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1036 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1037 |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1038 if(!prpl_info) |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1039 continue; |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1040 |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1041 for(l = moved_buddies; l; l = l->next) { |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1042 GaimBuddy *buddy = (GaimBuddy *)l->data; |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1043 |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1044 if(buddy && buddy->account == account) |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1045 buddies = g_list_append(buddies, (GaimBlistNode *)buddy); |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1046 } |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1047 |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1048 if(prpl_info->rename_group) { |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1049 prpl_info->rename_group(account->gc, old_name, source, buddies); |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1050 } else { |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1051 GList *cur, *groups = NULL; |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1052 |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1053 /* Make a list of what the groups each buddy is in */ |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1054 for(cur = buddies; cur; cur = cur->next) { |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1055 GaimBlistNode *node = (GaimBlistNode *)cur->data; |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1056 groups = g_list_append(groups, node->parent->parent); |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1057 } |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1058 |
| 11643 | 1059 gaim_account_remove_buddies(account, buddies, groups); |
|
10853
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1060 g_list_free(groups); |
| 11643 | 1061 gaim_account_add_buddies(account, buddies); |
|
10853
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1062 } |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1063 |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1064 g_list_free(buddies); |
|
2409700be3dc
[gaim-migrate @ 12527]
Luke Schierer <lschiere@pidgin.im>
parents:
10850
diff
changeset
|
1065 } |
| 9285 | 1066 } |
| 1067 g_list_free(moved_buddies); | |
| 1068 g_free(old_name); | |
| 5228 | 1069 } |
| 5234 | 1070 |
| 9285 | 1071 static void gaim_blist_node_initialize_settings(GaimBlistNode *node); |
| 7693 | 1072 |
| 7125 | 1073 GaimChat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components) |
| 5234 | 1074 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1075 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1076 GaimChat *chat; |
| 9285 | 1077 |
| 1078 g_return_val_if_fail(account != NULL, FALSE); | |
| 1079 g_return_val_if_fail(components != NULL, FALSE); | |
| 5234 | 1080 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1081 chat = g_new0(GaimChat, 1); |
| 5234 | 1082 chat->account = account; |
| 9285 | 1083 if ((alias != NULL) && (*alias != '\0')) |
| 5237 | 1084 chat->alias = g_strdup(alias); |
| 5234 | 1085 chat->components = components; |
| 9285 | 1086 gaim_blist_node_initialize_settings((GaimBlistNode *)chat); |
| 1087 ((GaimBlistNode *)chat)->type = GAIM_BLIST_CHAT_NODE; | |
| 5234 | 1088 |
| 1089 if (ops != NULL && ops->new_node != NULL) | |
| 1090 ops->new_node((GaimBlistNode *)chat); | |
| 1091 | |
| 11146 | 1092 GAIM_DBUS_REGISTER_POINTER(chat, GaimChat); |
| 5234 | 1093 return chat; |
| 1094 } | |
| 1095 | |
| 6695 | 1096 GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias) |
| 5228 | 1097 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1098 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 1099 GaimBuddy *buddy; |
| 1100 | |
| 1101 g_return_val_if_fail(account != NULL, FALSE); | |
| 1102 g_return_val_if_fail(screenname != NULL, FALSE); | |
| 1103 | |
| 1104 buddy = g_new0(GaimBuddy, 1); | |
| 9949 | 1105 buddy->account = account; |
| 1106 buddy->name = g_strdup(screenname); | |
| 1107 buddy->alias = g_strdup(alias); | |
| 1108 buddy->presence = gaim_presence_new_for_buddy(buddy); | |
| 11624 | 1109 ((GaimBlistNode *)buddy)->type = GAIM_BLIST_BUDDY_NODE; |
| 9949 | 1110 |
| 10052 | 1111 gaim_presence_set_status_active(buddy->presence, "offline", TRUE); |
| 1112 | |
| 9285 | 1113 gaim_blist_node_initialize_settings((GaimBlistNode *)buddy); |
| 1114 | |
| 1115 if (ops && ops->new_node) | |
| 1116 ops->new_node((GaimBlistNode *)buddy); | |
| 1117 | |
| 11146 | 1118 GAIM_DBUS_REGISTER_POINTER(buddy, GaimBuddy); |
| 9285 | 1119 return buddy; |
| 5228 | 1120 } |
| 5634 | 1121 |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1122 void |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1123 gaim_buddy_set_icon(GaimBuddy *buddy, GaimBuddyIcon *icon) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1124 { |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1125 g_return_if_fail(buddy != NULL); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1126 |
|
12476
18b16e801e6f
[gaim-migrate @ 14787]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
1127 if (buddy->icon != icon) { |
|
18b16e801e6f
[gaim-migrate @ 14787]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
1128 if (buddy->icon != NULL) |
|
18b16e801e6f
[gaim-migrate @ 14787]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
1129 gaim_buddy_icon_unref(buddy->icon); |
|
18b16e801e6f
[gaim-migrate @ 14787]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
1130 |
|
18b16e801e6f
[gaim-migrate @ 14787]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
1131 buddy->icon = (icon != NULL ? gaim_buddy_icon_ref(icon) : NULL); |
|
18b16e801e6f
[gaim-migrate @ 14787]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
1132 } |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1133 |
| 9324 | 1134 if (buddy->icon) |
| 1135 gaim_buddy_icon_cache(icon, buddy); | |
| 1136 else | |
|
11040
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
1137 gaim_buddy_icon_uncache(buddy); |
| 9299 | 1138 |
| 10704 | 1139 gaim_blist_schedule_save(); |
| 9926 | 1140 |
| 12097 | 1141 gaim_signal_emit(gaim_blist_get_handle(), "buddy-icon-changed", buddy); |
| 1142 | |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1143 gaim_blist_update_buddy_icon(buddy); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1144 } |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1145 |
|
10037
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1146 GaimAccount * |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1147 gaim_buddy_get_account(const GaimBuddy *buddy) |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1148 { |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1149 g_return_val_if_fail(buddy != NULL, NULL); |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1150 |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1151 return buddy->account; |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1152 } |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1153 |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1154 const char * |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1155 gaim_buddy_get_name(const GaimBuddy *buddy) |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1156 { |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1157 g_return_val_if_fail(buddy != NULL, NULL); |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1158 |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1159 return buddy->name; |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1160 } |
|
e6e68b9db19b
[gaim-migrate @ 10996]
Luke Schierer <lschiere@pidgin.im>
parents:
10001
diff
changeset
|
1161 |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1162 GaimBuddyIcon * |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1163 gaim_buddy_get_icon(const GaimBuddy *buddy) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1164 { |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1165 g_return_val_if_fail(buddy != NULL, NULL); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1166 |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1167 return buddy->icon; |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1168 } |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1169 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1170 void gaim_blist_add_chat(GaimChat *chat, GaimGroup *group, GaimBlistNode *node) |
| 5234 | 1171 { |
| 9285 | 1172 GaimBlistNode *cnode = (GaimBlistNode*)chat; |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1173 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 6774 | 1174 |
| 1175 g_return_if_fail(chat != NULL); | |
| 9285 | 1176 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT((GaimBlistNode *)chat)); |
| 1177 | |
| 1178 if (node == NULL) { | |
| 1179 if (group == NULL) { | |
| 1180 group = gaim_group_new(_("Chats")); | |
| 1181 gaim_blist_add_group(group, | |
| 5634 | 1182 gaim_blist_get_last_sibling(gaimbuddylist->root)); |
| 5234 | 1183 } |
| 1184 } else { | |
| 9285 | 1185 group = (GaimGroup*)node->parent; |
| 5234 | 1186 } |
| 1187 | |
| 1188 /* if we're moving to overtop of ourselves, do nothing */ | |
| 9285 | 1189 if (cnode == node) |
| 5234 | 1190 return; |
| 1191 | |
| 1192 if (cnode->parent) { | |
| 1193 /* This chat was already in the list and is | |
| 1194 * being moved. | |
| 1195 */ | |
| 6695 | 1196 ((GaimGroup *)cnode->parent)->totalsize--; |
| 5855 | 1197 if (gaim_account_is_connected(chat->account)) { |
| 6695 | 1198 ((GaimGroup *)cnode->parent)->online--; |
| 1199 ((GaimGroup *)cnode->parent)->currentsize--; | |
| 5287 | 1200 } |
| 9285 | 1201 if (cnode->next) |
| 5234 | 1202 cnode->next->prev = cnode->prev; |
| 9285 | 1203 if (cnode->prev) |
| 5234 | 1204 cnode->prev->next = cnode->next; |
| 9285 | 1205 if (cnode->parent->child == cnode) |
| 5234 | 1206 cnode->parent->child = cnode->next; |
| 1207 | |
|
13422
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1208 if (ops && ops->remove) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1209 ops->remove(gaimbuddylist, cnode); |
|
11101
8b346ce5cdb8
[gaim-migrate @ 13140]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11067
diff
changeset
|
1210 /* ops->remove() cleaned up the cnode's ui_data, so we need to |
|
8b346ce5cdb8
[gaim-migrate @ 13140]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11067
diff
changeset
|
1211 * reinitialize it */ |
|
13495
8f299b9cd184
[gaim-migrate @ 15871]
Richard Laager <rlaager@wiktel.com>
parents:
13484
diff
changeset
|
1212 if (ops && ops->new_node) |
|
8f299b9cd184
[gaim-migrate @ 15871]
Richard Laager <rlaager@wiktel.com>
parents:
13484
diff
changeset
|
1213 ops->new_node(cnode); |
| 5234 | 1214 |
| 10704 | 1215 gaim_blist_schedule_save(); |
| 5234 | 1216 } |
| 1217 | |
| 9285 | 1218 if (node != NULL) { |
| 1219 if (node->next) | |
| 1220 node->next->prev = cnode; | |
| 1221 cnode->next = node->next; | |
| 1222 cnode->prev = node; | |
| 1223 cnode->parent = node->parent; | |
| 1224 node->next = cnode; | |
| 1225 ((GaimGroup *)node->parent)->totalsize++; | |
| 5855 | 1226 if (gaim_account_is_connected(chat->account)) { |
| 9285 | 1227 ((GaimGroup *)node->parent)->online++; |
| 1228 ((GaimGroup *)node->parent)->currentsize++; | |
| 5287 | 1229 } |
| 5234 | 1230 } else { |
| 9285 | 1231 if (((GaimBlistNode *)group)->child) |
| 1232 ((GaimBlistNode *)group)->child->prev = cnode; | |
| 1233 cnode->next = ((GaimBlistNode *)group)->child; | |
| 5634 | 1234 cnode->prev = NULL; |
| 9285 | 1235 ((GaimBlistNode *)group)->child = cnode; |
| 1236 cnode->parent = (GaimBlistNode *)group; | |
| 1237 group->totalsize++; | |
| 5855 | 1238 if (gaim_account_is_connected(chat->account)) { |
| 9285 | 1239 group->online++; |
| 1240 group->currentsize++; | |
| 5287 | 1241 } |
| 5234 | 1242 } |
| 1243 | |
| 10704 | 1244 gaim_blist_schedule_save(); |
| 9285 | 1245 |
| 1246 if (ops && ops->update) | |
| 1247 ops->update(gaimbuddylist, (GaimBlistNode *)cnode); | |
| 5234 | 1248 } |
| 1249 | |
| 7879 | 1250 void gaim_blist_add_buddy(GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
| 5228 | 1251 { |
| 6695 | 1252 GaimBlistNode *cnode, *bnode; |
| 1253 GaimGroup *g; | |
| 1254 GaimContact *c; | |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1255 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 5247 | 1256 struct _gaim_hbuddy *hb; |
| 6695 | 1257 |
| 1258 g_return_if_fail(buddy != NULL); | |
| 6774 | 1259 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY((GaimBlistNode*)buddy)); |
| 6695 | 1260 |
| 1261 bnode = (GaimBlistNode *)buddy; | |
| 5228 | 1262 |
| 6695 | 1263 /* if we're moving to overtop of ourselves, do nothing */ |
| 9285 | 1264 if (bnode == node || (!node && bnode->parent && |
| 6695 | 1265 contact && bnode->parent == (GaimBlistNode*)contact |
| 1266 && bnode == bnode->parent->child)) | |
| 1267 return; | |
| 1268 | |
| 9285 | 1269 if (node && GAIM_BLIST_NODE_IS_BUDDY(node)) { |
| 6695 | 1270 c = (GaimContact*)node->parent; |
| 1271 g = (GaimGroup*)node->parent->parent; | |
| 9285 | 1272 } else if (contact) { |
| 6695 | 1273 c = contact; |
| 9285 | 1274 g = (GaimGroup *)((GaimBlistNode *)c)->parent; |
| 1275 } else { | |
| 1276 if (group) { | |
| 6695 | 1277 g = group; |
| 1278 } else { | |
| 5228 | 1279 g = gaim_group_new(_("Buddies")); |
| 5634 | 1280 gaim_blist_add_group(g, |
| 1281 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 5228 | 1282 } |
| 6695 | 1283 c = gaim_contact_new(); |
| 1284 gaim_blist_add_contact(c, g, | |
| 1285 gaim_blist_get_last_child((GaimBlistNode*)g)); | |
| 5228 | 1286 } |
| 1287 | |
| 6695 | 1288 cnode = (GaimBlistNode *)c; |
| 5228 | 1289 |
| 9285 | 1290 if (bnode->parent) { |
| 1291 if (GAIM_BUDDY_IS_ONLINE(buddy)) { | |
| 6695 | 1292 ((GaimContact*)bnode->parent)->online--; |
| 9285 | 1293 if (((GaimContact*)bnode->parent)->online == 0) |
| 6695 | 1294 ((GaimGroup*)bnode->parent->parent)->online--; |
| 1295 } | |
| 9285 | 1296 if (gaim_account_is_connected(buddy->account)) { |
| 6695 | 1297 ((GaimContact*)bnode->parent)->currentsize--; |
| 9285 | 1298 if (((GaimContact*)bnode->parent)->currentsize == 0) |
| 6695 | 1299 ((GaimGroup*)bnode->parent->parent)->currentsize--; |
| 1300 } | |
| 1301 ((GaimContact*)bnode->parent)->totalsize--; | |
| 1302 /* the group totalsize will be taken care of by remove_contact below */ | |
| 1303 | |
| 9285 | 1304 if (bnode->parent->parent != (GaimBlistNode*)g) |
| 6695 | 1305 serv_move_buddy(buddy, (GaimGroup *)bnode->parent->parent, g); |
| 5277 | 1306 |
| 9285 | 1307 if (bnode->next) |
| 5228 | 1308 bnode->next->prev = bnode->prev; |
| 9285 | 1309 if (bnode->prev) |
| 5228 | 1310 bnode->prev->next = bnode->next; |
| 9285 | 1311 if (bnode->parent->child == bnode) |
| 5228 | 1312 bnode->parent->child = bnode->next; |
| 1313 | |
|
13422
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1314 if (ops && ops->remove) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1315 ops->remove(gaimbuddylist, bnode); |
| 5228 | 1316 |
| 10704 | 1317 gaim_blist_schedule_save(); |
| 9285 | 1318 |
| 1319 if (bnode->parent->parent != (GaimBlistNode*)g) { | |
| 6742 | 1320 hb = g_new(struct _gaim_hbuddy, 1); |
| 7261 | 1321 hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); |
| 6742 | 1322 hb->account = buddy->account; |
| 1323 hb->group = bnode->parent->parent; | |
| 6775 | 1324 g_hash_table_remove(gaimbuddylist->buddies, hb); |
| 7162 | 1325 g_free(hb->name); |
| 6742 | 1326 g_free(hb); |
| 1327 } | |
| 6794 | 1328 |
| 9285 | 1329 if (!bnode->parent->child) { |
| 6794 | 1330 gaim_blist_remove_contact((GaimContact*)bnode->parent); |
| 7003 | 1331 } else { |
| 10378 | 1332 gaim_contact_invalidate_priority_buddy((GaimContact*)bnode->parent); |
|
13422
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1333 if (ops && ops->update) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1334 ops->update(gaimbuddylist, bnode->parent); |
| 7003 | 1335 } |
| 5228 | 1336 } |
| 1337 | |
| 9285 | 1338 if (node && GAIM_BLIST_NODE_IS_BUDDY(node)) { |
| 1339 if (node->next) | |
| 6695 | 1340 node->next->prev = bnode; |
| 1341 bnode->next = node->next; | |
| 1342 bnode->prev = node; | |
| 1343 bnode->parent = node->parent; | |
| 1344 node->next = bnode; | |
| 5228 | 1345 } else { |
| 9285 | 1346 if (cnode->child) |
| 6695 | 1347 cnode->child->prev = bnode; |
| 1348 bnode->prev = NULL; | |
| 1349 bnode->next = cnode->child; | |
| 1350 cnode->child = bnode; | |
| 1351 bnode->parent = cnode; | |
| 5228 | 1352 } |
| 1353 | |
| 9285 | 1354 if (GAIM_BUDDY_IS_ONLINE(buddy)) { |
| 6695 | 1355 ((GaimContact*)bnode->parent)->online++; |
| 9285 | 1356 if (((GaimContact*)bnode->parent)->online == 1) |
| 6695 | 1357 ((GaimGroup*)bnode->parent->parent)->online++; |
| 1358 } | |
| 9285 | 1359 if (gaim_account_is_connected(buddy->account)) { |
| 6695 | 1360 ((GaimContact*)bnode->parent)->currentsize++; |
| 9285 | 1361 if (((GaimContact*)bnode->parent)->currentsize == 1) |
| 6695 | 1362 ((GaimGroup*)bnode->parent->parent)->currentsize++; |
| 1363 } | |
| 1364 ((GaimContact*)bnode->parent)->totalsize++; | |
| 1365 | |
| 6742 | 1366 hb = g_new(struct _gaim_hbuddy, 1); |
| 7261 | 1367 hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); |
| 5247 | 1368 hb->account = buddy->account; |
| 6695 | 1369 hb->group = ((GaimBlistNode*)buddy)->parent->parent; |
| 5247 | 1370 |
| 6742 | 1371 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy); |
| 5247 | 1372 |
| 10378 | 1373 gaim_contact_invalidate_priority_buddy(gaim_buddy_get_contact(buddy)); |
| 9285 | 1374 |
| 10704 | 1375 gaim_blist_schedule_save(); |
| 9285 | 1376 |
| 1377 if (ops && ops->update) | |
| 5228 | 1378 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1379 |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1380 /* Signal that the buddy has been added */ |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1381 gaim_signal_emit(gaim_blist_get_handle(), "buddy-added", buddy); |
| 5228 | 1382 } |
| 1383 | |
| 6695 | 1384 GaimContact *gaim_contact_new() |
| 5228 | 1385 { |
| 9285 | 1386 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 1387 | |
| 1388 GaimContact *contact = g_new0(GaimContact, 1); | |
| 1389 contact->totalsize = 0; | |
| 1390 contact->currentsize = 0; | |
| 1391 contact->online = 0; | |
| 1392 gaim_blist_node_initialize_settings((GaimBlistNode *)contact); | |
| 1393 ((GaimBlistNode *)contact)->type = GAIM_BLIST_CONTACT_NODE; | |
| 1394 | |
| 1395 if (ops && ops->new_node) | |
| 1396 ops->new_node((GaimBlistNode *)contact); | |
| 1397 | |
| 11146 | 1398 GAIM_DBUS_REGISTER_POINTER(contact, GaimContact); |
| 9285 | 1399 return contact; |
| 6695 | 1400 } |
| 1401 | |
| 9285 | 1402 void gaim_contact_set_alias(GaimContact *contact, const char *alias) |
| 6755 | 1403 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1404 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1405 char *old_alias = contact->alias; |
| 7245 | 1406 |
| 6755 | 1407 g_return_if_fail(contact != NULL); |
| 1408 | |
| 9285 | 1409 if ((alias != NULL) && (*alias != '\0')) |
| 7245 | 1410 contact->alias = g_strdup(alias); |
| 1411 else | |
| 1412 contact->alias = NULL; | |
| 1413 | |
| 10704 | 1414 gaim_blist_schedule_save(); |
| 9285 | 1415 |
| 1416 if (ops && ops->update) | |
| 7245 | 1417 ops->update(gaimbuddylist, (GaimBlistNode*)contact); |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1418 |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1419 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1420 contact, old_alias); |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1421 g_free(old_alias); |
| 6755 | 1422 } |
| 1423 | |
| 1424 const char *gaim_contact_get_alias(GaimContact* contact) | |
| 1425 { | |
| 9285 | 1426 g_return_val_if_fail(contact != NULL, NULL); |
| 1427 | |
| 1428 if (contact->alias) | |
| 7312 | 1429 return contact->alias; |
| 1430 | |
| 10378 | 1431 return gaim_buddy_get_alias(gaim_contact_get_priority_buddy(contact)); |
| 6755 | 1432 } |
| 1433 | |
| 9787 | 1434 gboolean gaim_contact_on_account(GaimContact *c, GaimAccount *account) |
| 1435 { | |
| 1436 GaimBlistNode *bnode, *cnode = (GaimBlistNode *) c; | |
| 1437 | |
| 1438 g_return_val_if_fail(c != NULL, FALSE); | |
| 1439 g_return_val_if_fail(account != NULL, FALSE); | |
| 1440 | |
| 1441 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 1442 GaimBuddy *buddy; | |
| 1443 | |
| 1444 if (! GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 1445 continue; | |
| 1446 | |
| 1447 buddy = (GaimBuddy *)bnode; | |
| 1448 if (buddy->account == account) | |
| 1449 return TRUE; | |
| 1450 } | |
| 1451 return FALSE; | |
| 1452 } | |
| 1453 | |
| 10428 | 1454 void gaim_contact_invalidate_priority_buddy(GaimContact *contact) |
| 1455 { | |
| 1456 g_return_if_fail(contact != NULL); | |
| 1457 | |
| 1458 contact->priority_valid = FALSE; | |
| 1459 } | |
| 1460 | |
| 6695 | 1461 GaimGroup *gaim_group_new(const char *name) |
| 1462 { | |
| 9285 | 1463 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 12458 | 1464 GaimGroup *group; |
| 1465 | |
| 1466 g_return_val_if_fail(name != NULL, NULL); | |
| 1467 g_return_val_if_fail(*name != '\0', NULL); | |
| 1468 | |
| 1469 group = gaim_find_group(name); | |
| 9285 | 1470 if (group != NULL) |
| 1471 return group; | |
| 1472 | |
| 1473 group = g_new0(GaimGroup, 1); | |
| 1474 group->name = g_strdup(name); | |
| 1475 group->totalsize = 0; | |
| 1476 group->currentsize = 0; | |
| 1477 group->online = 0; | |
| 1478 gaim_blist_node_initialize_settings((GaimBlistNode *)group); | |
| 1479 ((GaimBlistNode *)group)->type = GAIM_BLIST_GROUP_NODE; | |
| 1480 | |
| 1481 if (ops && ops->new_node) | |
| 1482 ops->new_node((GaimBlistNode *)group); | |
| 1483 | |
| 11146 | 1484 GAIM_DBUS_REGISTER_POINTER(group, GaimGroup); |
| 9285 | 1485 return group; |
| 5228 | 1486 } |
| 1487 | |
| 6695 | 1488 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
| 1489 { | |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1490 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 6695 | 1491 GaimGroup *g; |
| 6742 | 1492 GaimBlistNode *gnode, *cnode, *bnode; |
| 6695 | 1493 |
| 6774 | 1494 g_return_if_fail(contact != NULL); |
| 1495 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); | |
| 6695 | 1496 |
| 9285 | 1497 if ((GaimBlistNode*)contact == node) |
| 6975 | 1498 return; |
| 1499 | |
| 9285 | 1500 if (node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
| 6695 | 1501 GAIM_BLIST_NODE_IS_CHAT(node))) |
| 1502 g = (GaimGroup*)node->parent; | |
| 9285 | 1503 else if (group) |
| 6695 | 1504 g = group; |
| 1505 else { | |
| 1506 g = gaim_group_new(_("Buddies")); | |
| 1507 gaim_blist_add_group(g, | |
| 1508 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 1509 } | |
| 1510 | |
| 1511 gnode = (GaimBlistNode*)g; | |
| 1512 cnode = (GaimBlistNode*)contact; | |
| 1513 | |
| 9285 | 1514 if (cnode->parent) { |
| 1515 if (cnode->parent->child == cnode) | |
| 6731 | 1516 cnode->parent->child = cnode->next; |
| 9285 | 1517 if (cnode->prev) |
| 6695 | 1518 cnode->prev->next = cnode->next; |
| 9285 | 1519 if (cnode->next) |
| 6695 | 1520 cnode->next->prev = cnode->prev; |
| 1521 | |
| 9285 | 1522 if (cnode->parent != gnode) { |
| 9928 | 1523 bnode = cnode->child; |
| 1524 while (bnode) { | |
| 1525 GaimBlistNode *next_bnode = bnode->next; | |
| 6742 | 1526 GaimBuddy *b = (GaimBuddy*)bnode; |
| 1527 | |
| 1528 struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); | |
| 7261 | 1529 hb->name = g_strdup(gaim_normalize(b->account, b->name)); |
| 6742 | 1530 hb->account = b->account; |
| 1531 hb->group = cnode->parent; | |
| 1532 | |
| 6776 | 1533 g_hash_table_remove(gaimbuddylist->buddies, hb); |
| 6742 | 1534 |
| 9285 | 1535 if (!gaim_find_buddy_in_group(b->account, b->name, g)) { |
| 8328 | 1536 hb->group = gnode; |
| 1537 g_hash_table_replace(gaimbuddylist->buddies, hb, b); | |
| 1538 | |
| 9285 | 1539 if (b->account->gc) |
| 1540 serv_move_buddy(b, (GaimGroup *)cnode->parent, g); | |
| 8328 | 1541 } else { |
| 9928 | 1542 gboolean empty_contact = FALSE; |
| 1543 | |
| 8328 | 1544 /* this buddy already exists in the group, so we're |
| 1545 * gonna delete it instead */ | |
| 1546 g_free(hb->name); | |
| 1547 g_free(hb); | |
| 9285 | 1548 if (b->account->gc) |
| 11643 | 1549 gaim_account_remove_buddy(b->account, b, (GaimGroup *)cnode->parent); |
| 9285 | 1550 |
| 1551 if (!cnode->child->next) | |
| 8328 | 1552 empty_contact = TRUE; |
| 1553 gaim_blist_remove_buddy(b); | |
| 9928 | 1554 |
| 1555 /** in gaim_blist_remove_buddy(), if the last buddy in a | |
| 1556 * contact is removed, the contact is cleaned up and | |
| 1557 * g_free'd, so we mustn't try to reference bnode->next */ | |
| 1558 if (empty_contact) | |
| 1559 return; | |
| 8328 | 1560 } |
| 9928 | 1561 bnode = next_bnode; |
| 6742 | 1562 } |
| 1563 } | |
| 9928 | 1564 |
| 1565 if (contact->online > 0) | |
| 1566 ((GaimGroup*)cnode->parent)->online--; | |
| 1567 if (contact->currentsize > 0) | |
| 1568 ((GaimGroup*)cnode->parent)->currentsize--; | |
| 1569 ((GaimGroup*)cnode->parent)->totalsize--; | |
| 1570 | |
|
13422
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1571 if (ops && ops->remove) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1572 ops->remove(gaimbuddylist, cnode); |
| 9928 | 1573 |
| 10704 | 1574 gaim_blist_schedule_save(); |
| 6695 | 1575 } |
| 1576 | |
| 9285 | 1577 if (node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
| 6695 | 1578 GAIM_BLIST_NODE_IS_CHAT(node))) { |
| 9285 | 1579 if (node->next) |
| 6695 | 1580 node->next->prev = cnode; |
| 1581 cnode->next = node->next; | |
| 1582 cnode->prev = node; | |
| 1583 cnode->parent = node->parent; | |
| 1584 node->next = cnode; | |
| 1585 } else { | |
| 9285 | 1586 if (gnode->child) |
| 6695 | 1587 gnode->child->prev = cnode; |
| 1588 cnode->prev = NULL; | |
| 1589 cnode->next = gnode->child; | |
| 1590 gnode->child = cnode; | |
| 1591 cnode->parent = gnode; | |
| 1592 } | |
| 1593 | |
| 9285 | 1594 if (contact->online > 0) |
| 6695 | 1595 g->online++; |
| 9285 | 1596 if (contact->currentsize > 0) |
| 6695 | 1597 g->currentsize++; |
| 1598 g->totalsize++; | |
| 1599 | |
| 10704 | 1600 gaim_blist_schedule_save(); |
| 9285 | 1601 |
|
13422
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1602 if (ops && ops->update) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1603 { |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1604 if (cnode->child) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1605 ops->update(gaimbuddylist, cnode); |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1606 |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1607 for (bnode = cnode->child; bnode; bnode = bnode->next) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1608 ops->update(gaimbuddylist, bnode); |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1609 } |
| 6695 | 1610 } |
| 1611 | |
| 7246 | 1612 void gaim_blist_merge_contact(GaimContact *source, GaimBlistNode *node) |
| 6965 | 1613 { |
| 1614 GaimBlistNode *sourcenode = (GaimBlistNode*)source; | |
| 7246 | 1615 GaimBlistNode *targetnode; |
| 1616 GaimBlistNode *prev, *cur, *next; | |
| 1617 GaimContact *target; | |
| 1618 | |
| 9285 | 1619 g_return_if_fail(source != NULL); |
| 1620 g_return_if_fail(node != NULL); | |
| 1621 | |
| 1622 if (GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
| 1623 target = (GaimContact *)node; | |
| 7246 | 1624 prev = gaim_blist_get_last_child(node); |
| 9285 | 1625 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
| 1626 target = (GaimContact *)node->parent; | |
| 7246 | 1627 prev = node; |
| 1628 } else { | |
| 6965 | 1629 return; |
| 7246 | 1630 } |
| 1631 | |
| 9285 | 1632 if (source == target || !target) |
| 7246 | 1633 return; |
| 1634 | |
| 9285 | 1635 targetnode = (GaimBlistNode *)target; |
| 7246 | 1636 next = sourcenode->child; |
| 1637 | |
| 9285 | 1638 while (next) { |
| 7246 | 1639 cur = next; |
| 1640 next = cur->next; | |
| 9285 | 1641 if (GAIM_BLIST_NODE_IS_BUDDY(cur)) { |
| 1642 gaim_blist_add_buddy((GaimBuddy *)cur, target, NULL, prev); | |
| 7246 | 1643 prev = cur; |
| 1644 } | |
| 6965 | 1645 } |
| 1646 } | |
| 1647 | |
| 9285 | 1648 void gaim_blist_add_group(GaimGroup *group, GaimBlistNode *node) |
| 5228 | 1649 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1650 GaimBlistUiOps *ops; |
| 5228 | 1651 GaimBlistNode *gnode = (GaimBlistNode*)group; |
| 1652 | |
| 6774 | 1653 g_return_if_fail(group != NULL); |
| 9285 | 1654 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP((GaimBlistNode *)group)); |
| 1655 | |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1656 ops = gaim_blist_get_ui_ops(); |
| 5228 | 1657 |
| 1658 if (!gaimbuddylist->root) { | |
| 1659 gaimbuddylist->root = gnode; | |
| 1660 return; | |
| 1661 } | |
| 1662 | |
| 1663 /* if we're moving to overtop of ourselves, do nothing */ | |
| 9285 | 1664 if (gnode == node) |
| 5228 | 1665 return; |
| 1666 | |
| 1667 if (gaim_find_group(group->name)) { | |
| 1668 /* This is just being moved */ | |
| 1669 | |
|
13422
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1670 if (ops && ops->remove) |
|
b53fe4fa46b6
[gaim-migrate @ 15797]
Richard Laager <rlaager@wiktel.com>
parents:
13195
diff
changeset
|
1671 ops->remove(gaimbuddylist, (GaimBlistNode *)group); |
| 9285 | 1672 |
| 1673 if (gnode == gaimbuddylist->root) | |
| 5228 | 1674 gaimbuddylist->root = gnode->next; |
| 9285 | 1675 if (gnode->prev) |
| 5228 | 1676 gnode->prev->next = gnode->next; |
| 9285 | 1677 if (gnode->next) |
| 5228 | 1678 gnode->next->prev = gnode->prev; |
| 1679 } | |
| 1680 | |
| 6695 | 1681 if (node && GAIM_BLIST_NODE_IS_GROUP(node)) { |
| 5634 | 1682 gnode->next = node->next; |
| 1683 gnode->prev = node; | |
| 9285 | 1684 if (node->next) |
| 5634 | 1685 node->next->prev = gnode; |
| 1686 node->next = gnode; | |
| 1687 } else { | |
| 9285 | 1688 if (gaimbuddylist->root) |
| 6807 | 1689 gaimbuddylist->root->prev = gnode; |
| 5634 | 1690 gnode->next = gaimbuddylist->root; |
| 1691 gnode->prev = NULL; | |
| 1692 gaimbuddylist->root = gnode; | |
| 1693 } | |
| 1694 | |
| 10704 | 1695 gaim_blist_schedule_save(); |
| 9285 | 1696 |
| 1697 if (ops && ops->update) { | |
| 5228 | 1698 ops->update(gaimbuddylist, gnode); |
| 9285 | 1699 for (node = gnode->child; node; node = node->next) |
| 5228 | 1700 ops->update(gaimbuddylist, node); |
| 1701 } | |
| 1702 } | |
| 1703 | |
| 9285 | 1704 void gaim_blist_remove_contact(GaimContact *contact) |
| 5228 | 1705 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1706 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 1707 GaimBlistNode *node, *gnode; |
| 1708 | |
| 1709 g_return_if_fail(contact != NULL); | |
| 1710 | |
| 1711 node = (GaimBlistNode *)contact; | |
| 1712 gnode = node->parent; | |
| 1713 | |
| 1714 if (node->child) { | |
| 1715 /* | |
| 1716 * If this contact has children then remove them. When the last | |
| 10166 | 1717 * buddy is removed from the contact, the contact is automatically |
| 1718 * deleted. | |
| 9285 | 1719 */ |
| 10166 | 1720 while (node->child->next) { |
| 9285 | 1721 gaim_blist_remove_buddy((GaimBuddy*)node->child); |
| 6695 | 1722 } |
| 10166 | 1723 /* |
| 1724 * Remove the last buddy and trigger the deletion of the contact. | |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1725 * It would probably be cleaner if contact-deletion was done after |
| 10166 | 1726 * a timeout? Or if it had to be done manually, like below? |
| 1727 */ | |
| 1728 gaim_blist_remove_buddy((GaimBuddy*)node->child); | |
| 6695 | 1729 } else { |
| 9285 | 1730 /* Remove the node from its parent */ |
| 1731 if (gnode->child == node) | |
| 1732 gnode->child = node->next; | |
| 1733 if (node->prev) | |
| 1734 node->prev->next = node->next; | |
| 1735 if (node->next) | |
| 1736 node->next->prev = node->prev; | |
| 1737 | |
| 10704 | 1738 gaim_blist_schedule_save(); |
| 9285 | 1739 |
| 1740 /* Update the UI */ | |
| 1741 if (ops && ops->remove) | |
| 1742 ops->remove(gaimbuddylist, node); | |
| 1743 | |
| 1744 /* Delete the node */ | |
| 10504 | 1745 g_hash_table_destroy(contact->node.settings); |
| 11067 | 1746 GAIM_DBUS_UNREGISTER_POINTER(contact); |
| 6695 | 1747 g_free(contact); |
| 1748 } | |
| 1749 } | |
| 1750 | |
| 9285 | 1751 void gaim_blist_remove_buddy(GaimBuddy *buddy) |
| 6695 | 1752 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1753 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 1754 GaimBlistNode *node, *cnode, *gnode; |
| 1755 GaimContact *contact; | |
| 6695 | 1756 GaimGroup *group; |
| 6742 | 1757 struct _gaim_hbuddy hb; |
| 5228 | 1758 |
| 9285 | 1759 g_return_if_fail(buddy != NULL); |
| 1760 | |
| 1761 node = (GaimBlistNode *)buddy; | |
| 6695 | 1762 cnode = node->parent; |
| 9285 | 1763 gnode = cnode->parent; |
| 1764 contact = (GaimContact *)cnode; | |
| 1765 group = (GaimGroup *)gnode; | |
| 1766 | |
|
11302
fc17554c32c5
[gaim-migrate @ 13502]
Richard Laager <rlaager@wiktel.com>
parents:
11268
diff
changeset
|
1767 /* Delete any buddy icon. */ |
| 11860 | 1768 gaim_buddy_icon_uncache(buddy); |
|
11302
fc17554c32c5
[gaim-migrate @ 13502]
Richard Laager <rlaager@wiktel.com>
parents:
11268
diff
changeset
|
1769 |
| 9285 | 1770 /* Remove the node from its parent */ |
| 5228 | 1771 if (node->prev) |
| 1772 node->prev->next = node->next; | |
| 1773 if (node->next) | |
| 1774 node->next->prev = node->prev; | |
| 9285 | 1775 if (cnode->child == node) |
| 6695 | 1776 cnode->child = node->next; |
| 9285 | 1777 |
| 1778 /* Adjust size counts */ | |
| 1779 if (GAIM_BUDDY_IS_ONLINE(buddy)) { | |
| 1780 contact->online--; | |
| 1781 if (contact->online == 0) | |
| 1782 group->online--; | |
| 6695 | 1783 } |
| 9285 | 1784 if (gaim_account_is_connected(buddy->account)) { |
| 1785 contact->currentsize--; | |
| 1786 if (contact->currentsize == 0) | |
| 1787 group->currentsize--; | |
| 8194 | 1788 } |
| 9285 | 1789 contact->totalsize--; |
| 1790 | |
| 10704 | 1791 gaim_blist_schedule_save(); |
| 9285 | 1792 |
| 1793 /* Re-sort the contact */ | |
| 1794 if (contact->priority == buddy) { | |
| 10378 | 1795 gaim_contact_invalidate_priority_buddy(contact); |
| 9285 | 1796 if (ops && ops->update) |
| 1797 ops->update(gaimbuddylist, cnode); | |
| 1798 } | |
| 1799 | |
| 1800 /* Remove this buddy from the buddies hash table */ | |
| 7261 | 1801 hb.name = g_strdup(gaim_normalize(buddy->account, buddy->name)); |
| 5247 | 1802 hb.account = buddy->account; |
| 6695 | 1803 hb.group = ((GaimBlistNode*)buddy)->parent->parent; |
| 6742 | 1804 g_hash_table_remove(gaimbuddylist->buddies, &hb); |
| 7162 | 1805 g_free(hb.name); |
| 5247 | 1806 |
| 9285 | 1807 /* Update the UI */ |
| 1808 if (ops && ops->remove) | |
| 1809 ops->remove(gaimbuddylist, node); | |
| 1810 | |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1811 /* Signal that the buddy has been removed before freeing the memory for it */ |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1812 gaim_signal_emit(gaim_blist_get_handle(), "buddy-removed", buddy); |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
1813 |
| 9285 | 1814 /* Delete the node */ |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1815 if (buddy->icon != NULL) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1816 gaim_buddy_icon_unref(buddy->icon); |
| 7693 | 1817 g_hash_table_destroy(buddy->node.settings); |
| 9944 | 1818 gaim_presence_remove_buddy(buddy->presence, buddy); |
| 1819 gaim_presence_destroy(buddy->presence); | |
| 5228 | 1820 g_free(buddy->name); |
| 1821 g_free(buddy->alias); | |
| 10504 | 1822 g_free(buddy->server_alias); |
| 11067 | 1823 |
| 1824 GAIM_DBUS_UNREGISTER_POINTER(buddy); | |
| 5228 | 1825 g_free(buddy); |
| 6755 | 1826 |
|
12862
b503265495f7
[gaim-migrate @ 15213]
Richard Laager <rlaager@wiktel.com>
parents:
12860
diff
changeset
|
1827 /* FIXME: Once GaimBuddy is a GObject, timeout callbacks can |
|
b503265495f7
[gaim-migrate @ 15213]
Richard Laager <rlaager@wiktel.com>
parents:
12860
diff
changeset
|
1828 * g_object_ref() it when connecting the callback and |
|
b503265495f7
[gaim-migrate @ 15213]
Richard Laager <rlaager@wiktel.com>
parents:
12860
diff
changeset
|
1829 * g_object_unref() it in the handler. That way, it won't |
|
b503265495f7
[gaim-migrate @ 15213]
Richard Laager <rlaager@wiktel.com>
parents:
12860
diff
changeset
|
1830 * get freed while the timeout is pending and this line can |
|
b503265495f7
[gaim-migrate @ 15213]
Richard Laager <rlaager@wiktel.com>
parents:
12860
diff
changeset
|
1831 * be removed. */ |
|
12860
a35edda11737
[gaim-migrate @ 15211]
Richard Laager <rlaager@wiktel.com>
parents:
12797
diff
changeset
|
1832 while (g_source_remove_by_user_data((gpointer *)buddy)); |
|
a35edda11737
[gaim-migrate @ 15211]
Richard Laager <rlaager@wiktel.com>
parents:
12797
diff
changeset
|
1833 |
| 9285 | 1834 /* If the contact is empty then remove it */ |
| 1835 if (!cnode->child) | |
| 1836 gaim_blist_remove_contact(contact); | |
| 5228 | 1837 } |
| 1838 | |
| 9285 | 1839 void gaim_blist_remove_chat(GaimChat *chat) |
| 5234 | 1840 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1841 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 1842 GaimBlistNode *node, *gnode; |
| 6695 | 1843 GaimGroup *group; |
| 5234 | 1844 |
| 9285 | 1845 g_return_if_fail(chat != NULL); |
| 1846 | |
| 1847 node = (GaimBlistNode *)chat; | |
| 5234 | 1848 gnode = node->parent; |
| 6695 | 1849 group = (GaimGroup *)gnode; |
| 5234 | 1850 |
|
12577
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1851 if (gnode != NULL) |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1852 { |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1853 /* Remove the node from its parent */ |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1854 if (gnode->child == node) |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1855 gnode->child = node->next; |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1856 if (node->prev) |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1857 node->prev->next = node->next; |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1858 if (node->next) |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1859 node->next->prev = node->prev; |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1860 |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1861 /* Adjust size counts */ |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1862 if (gaim_account_is_connected(chat->account)) { |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1863 group->online--; |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1864 group->currentsize--; |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1865 } |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1866 group->totalsize--; |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1867 |
|
f1ee8a29bd69
[gaim-migrate @ 14899]
Richard Laager <rlaager@wiktel.com>
parents:
12476
diff
changeset
|
1868 gaim_blist_schedule_save(); |
| 5394 | 1869 } |
| 9285 | 1870 |
| 1871 /* Update the UI */ | |
| 1872 if (ops && ops->remove) | |
| 1873 ops->remove(gaimbuddylist, node); | |
| 1874 | |
| 1875 /* Delete the node */ | |
| 5234 | 1876 g_hash_table_destroy(chat->components); |
| 10504 | 1877 g_hash_table_destroy(chat->node.settings); |
| 5234 | 1878 g_free(chat->alias); |
| 11067 | 1879 GAIM_DBUS_UNREGISTER_POINTER(chat); |
| 5234 | 1880 g_free(chat); |
| 1881 } | |
| 1882 | |
| 9285 | 1883 void gaim_blist_remove_group(GaimGroup *group) |
| 5228 | 1884 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
1885 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 9285 | 1886 GaimBlistNode *node; |
|
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1887 GList *l; |
| 5228 | 1888 |
| 9285 | 1889 g_return_if_fail(group != NULL); |
| 1890 | |
| 1891 node = (GaimBlistNode *)group; | |
| 1892 | |
| 1893 /* Make sure the group is empty */ | |
| 1894 if (node->child) { | |
| 5228 | 1895 char *buf; |
| 1896 int count = 0; | |
| 9285 | 1897 GaimBlistNode *child; |
| 1898 | |
| 1899 for (child = node->child; child != NULL; child = child->next) | |
| 5228 | 1900 count++; |
| 1901 | |
| 6308 | 1902 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed " |
|
13043
fa99be331f2f
[gaim-migrate @ 15402]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
1903 "because it belongs to an account which is " |
|
fa99be331f2f
[gaim-migrate @ 15402]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
1904 "disabled or offline. This buddy and the " |
|
fa99be331f2f
[gaim-migrate @ 15402]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
1905 "group were not removed.\n", |
| 6308 | 1906 "%d buddies from group %s were not " |
|
13043
fa99be331f2f
[gaim-migrate @ 15402]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
1907 "removed because they belong to accounts " |
|
fa99be331f2f
[gaim-migrate @ 15402]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
1908 "which are currently disabled or offline. " |
|
fa99be331f2f
[gaim-migrate @ 15402]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
1909 "These buddies and the group were not " |
|
fa99be331f2f
[gaim-migrate @ 15402]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
1910 "removed.\n", count), |
| 6308 | 1911 count, group->name); |
|
5541
aee0ee458974
[gaim-migrate @ 5941]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1912 gaim_notify_error(NULL, NULL, _("Group not removed"), buf); |
| 5228 | 1913 g_free(buf); |
| 1914 return; | |
| 1915 } | |
| 1916 | |
| 9285 | 1917 /* Remove the node from its parent */ |
| 1918 if (gaimbuddylist->root == node) | |
| 5228 | 1919 gaimbuddylist->root = node->next; |
| 1920 if (node->prev) | |
| 1921 node->prev->next = node->next; | |
| 1922 if (node->next) | |
| 1923 node->next->prev = node->prev; | |
| 1924 | |
| 10704 | 1925 gaim_blist_schedule_save(); |
| 9285 | 1926 |
| 1927 /* Update the UI */ | |
| 1928 if (ops && ops->remove) | |
| 1929 ops->remove(gaimbuddylist, node); | |
| 1930 | |
| 1931 /* Remove the group from all accounts that are online */ | |
|
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1932 for (l = gaim_connections_get_all(); l != NULL; l = l->next) |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1933 { |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1934 GaimConnection *gc = (GaimConnection *)l->data; |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1935 |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1936 if (gaim_connection_get_state(gc) == GAIM_CONNECTED) |
| 11643 | 1937 gaim_account_remove_group(gaim_connection_get_account(gc), group); |
|
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1938 } |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1939 |
| 9285 | 1940 /* Delete the node */ |
| 10504 | 1941 g_hash_table_destroy(group->node.settings); |
| 5228 | 1942 g_free(group->name); |
| 11067 | 1943 GAIM_DBUS_UNREGISTER_POINTER(group); |
| 5228 | 1944 g_free(group); |
| 1945 } | |
| 1946 | |
| 9285 | 1947 GaimBuddy *gaim_contact_get_priority_buddy(GaimContact *contact) |
| 1948 { | |
| 1949 g_return_val_if_fail(contact != NULL, NULL); | |
| 1950 | |
| 10378 | 1951 if (!contact->priority_valid) |
| 1952 gaim_contact_compute_priority_buddy(contact); | |
| 1953 | |
| 6843 | 1954 return contact->priority; |
| 6695 | 1955 } |
| 1956 | |
| 9620 | 1957 const char *gaim_buddy_get_alias_only(GaimBuddy *buddy) |
| 9285 | 1958 { |
| 1959 g_return_val_if_fail(buddy != NULL, NULL); | |
| 1960 | |
| 1961 if ((buddy->alias != NULL) && (*buddy->alias != '\0')) { | |
| 1962 return buddy->alias; | |
| 1963 } else if ((buddy->server_alias != NULL) && | |
| 10389 | 1964 (*buddy->server_alias != '\0')) { |
| 9285 | 1965 |
| 1966 return buddy->server_alias; | |
|
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1967 } |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1968 |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1969 return NULL; |
| 5228 | 1970 } |
| 1971 | |
| 9620 | 1972 |
| 1973 const char *gaim_buddy_get_contact_alias(GaimBuddy *buddy) | |
| 5228 | 1974 { |
| 9620 | 1975 GaimContact *c; |
| 1976 | |
| 1977 g_return_val_if_fail(buddy != NULL, NULL); | |
| 1978 | |
| 1979 /* Search for an alias for the buddy. In order of precedence: */ | |
| 1980 /* The buddy alias */ | |
| 1981 if (buddy->alias != NULL) | |
| 1982 return buddy->alias; | |
| 1983 | |
| 1984 /* The contact alias */ | |
| 1985 c = gaim_buddy_get_contact(buddy); | |
| 1986 if ((c != NULL) && (c->alias != NULL)) | |
| 1987 return c->alias; | |
| 1988 | |
| 10349 | 1989 /* The server alias */ |
| 1990 if ((buddy->server_alias) && (*buddy->server_alias)) | |
| 9620 | 1991 return buddy->server_alias; |
| 1992 | |
| 1993 /* The buddy's user name (i.e. no alias) */ | |
| 1994 return buddy->name; | |
| 5228 | 1995 } |
| 1996 | |
| 9620 | 1997 |
| 1998 const char *gaim_buddy_get_alias(GaimBuddy *buddy) | |
| 1999 { | |
| 2000 g_return_val_if_fail(buddy != NULL, NULL); | |
| 2001 | |
| 2002 /* Search for an alias for the buddy. In order of precedence: */ | |
| 2003 /* The buddy alias */ | |
| 2004 if (buddy->alias != NULL) | |
| 2005 return buddy->alias; | |
| 2006 | |
| 11266 | 2007 /* The server alias */ |
| 10389 | 2008 if ((buddy->server_alias) && (*buddy->server_alias)) |
| 9620 | 2009 return buddy->server_alias; |
| 2010 | |
| 2011 /* The buddy's user name (i.e. no alias) */ | |
| 2012 return buddy->name; | |
| 2013 } | |
| 2014 | |
| 10349 | 2015 const char *gaim_buddy_get_local_alias(GaimBuddy *buddy) |
| 2016 { | |
| 2017 GaimContact *c; | |
| 2018 | |
| 2019 g_return_val_if_fail(buddy != NULL, NULL); | |
| 2020 | |
| 2021 /* Search for an alias for the buddy. In order of precedence: */ | |
| 2022 /* The buddy alias */ | |
| 2023 if (buddy->alias != NULL) | |
| 2024 return buddy->alias; | |
| 2025 | |
| 2026 /* The contact alias */ | |
| 2027 c = gaim_buddy_get_contact(buddy); | |
| 2028 if ((c != NULL) && (c->alias != NULL)) | |
| 2029 return c->alias; | |
| 2030 | |
| 2031 /* The buddy's user name (i.e. no alias) */ | |
| 2032 return buddy->name; | |
| 2033 } | |
| 9620 | 2034 |
| 7125 | 2035 const char *gaim_chat_get_name(GaimChat *chat) |
| 6744 | 2036 { |
| 9285 | 2037 struct proto_chat_entry *pce; |
| 2038 GList *parts, *tmp; | |
| 2039 char *ret; | |
| 2040 | |
| 2041 g_return_val_if_fail(chat != NULL, NULL); | |
| 2042 | |
| 2043 if ((chat->alias != NULL) && (*chat->alias != '\0')) | |
| 6744 | 2044 return chat->alias; |
| 9285 | 2045 |
| 2046 parts = GAIM_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc); | |
| 2047 pce = parts->data; | |
| 2048 ret = g_hash_table_lookup(chat->components, pce->identifier); | |
| 2049 for (tmp = parts; tmp; tmp = tmp->next) | |
| 2050 g_free(tmp->data); | |
| 2051 g_list_free(parts); | |
| 2052 | |
| 2053 return ret; | |
| 6744 | 2054 } |
| 2055 | |
| 6695 | 2056 GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name) |
| 5228 | 2057 { |
| 6695 | 2058 GaimBuddy *buddy; |
| 5247 | 2059 struct _gaim_hbuddy hb; |
| 5758 | 2060 GaimBlistNode *group; |
| 5228 | 2061 |
| 9285 | 2062 g_return_val_if_fail(gaimbuddylist != NULL, NULL); |
| 2063 g_return_val_if_fail(account != NULL, NULL); | |
| 2064 g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL); | |
| 5228 | 2065 |
| 7429 | 2066 hb.account = account; |
| 7261 | 2067 hb.name = g_strdup(gaim_normalize(account, name)); |
| 7429 | 2068 |
| 9285 | 2069 for (group = gaimbuddylist->root; group; group = group->next) { |
| 5758 | 2070 hb.group = group; |
| 7162 | 2071 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb))) { |
| 2072 g_free(hb.name); | |
| 5758 | 2073 return buddy; |
| 7162 | 2074 } |
| 5758 | 2075 } |
| 7162 | 2076 g_free(hb.name); |
| 9285 | 2077 |
| 5758 | 2078 return NULL; |
| 5228 | 2079 } |
| 2080 | |
| 6872 | 2081 GaimBuddy *gaim_find_buddy_in_group(GaimAccount *account, const char *name, |
| 2082 GaimGroup *group) | |
| 2083 { | |
| 2084 struct _gaim_hbuddy hb; | |
| 7162 | 2085 GaimBuddy *ret; |
| 6872 | 2086 |
| 9285 | 2087 g_return_val_if_fail(gaimbuddylist != NULL, NULL); |
| 2088 g_return_val_if_fail(account != NULL, NULL); | |
| 2089 g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL); | |
| 6872 | 2090 |
| 7261 | 2091 hb.name = g_strdup(gaim_normalize(account, name)); |
| 6872 | 2092 hb.account = account; |
| 2093 hb.group = (GaimBlistNode*)group; | |
| 2094 | |
| 7162 | 2095 ret = g_hash_table_lookup(gaimbuddylist->buddies, &hb); |
| 2096 g_free(hb.name); | |
| 9285 | 2097 |
| 7162 | 2098 return ret; |
| 6872 | 2099 } |
| 2100 | |
| 6245 | 2101 GSList *gaim_find_buddies(GaimAccount *account, const char *name) |
| 2102 { | |
| 2103 struct buddy *buddy; | |
| 2104 struct _gaim_hbuddy hb; | |
| 9285 | 2105 GaimBlistNode *node; |
| 6245 | 2106 GSList *ret = NULL; |
| 2107 | |
| 9285 | 2108 g_return_val_if_fail(gaimbuddylist != NULL, NULL); |
| 2109 g_return_val_if_fail(account != NULL, NULL); | |
| 2110 g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL); | |
| 6245 | 2111 |
| 7261 | 2112 hb.name = g_strdup(gaim_normalize(account, name)); |
| 6245 | 2113 hb.account = account; |
| 2114 | |
| 9285 | 2115 for (node = gaimbuddylist->root; node != NULL; node = node->next) { |
| 2116 hb.group = node; | |
| 6245 | 2117 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) |
| 2118 ret = g_slist_append(ret, buddy); | |
| 2119 } | |
| 7162 | 2120 g_free(hb.name); |
| 9285 | 2121 |
| 6245 | 2122 return ret; |
| 2123 } | |
| 2124 | |
| 6695 | 2125 GaimGroup *gaim_find_group(const char *name) |
| 5228 | 2126 { |
| 2127 GaimBlistNode *node; | |
| 9285 | 2128 |
| 2129 g_return_val_if_fail(gaimbuddylist != NULL, NULL); | |
| 2130 g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL); | |
| 2131 | |
| 2132 for (node = gaimbuddylist->root; node != NULL; node = node->next) { | |
| 6695 | 2133 if (!strcmp(((GaimGroup *)node)->name, name)) |
| 2134 return (GaimGroup *)node; | |
| 5228 | 2135 } |
| 9285 | 2136 |
| 5228 | 2137 return NULL; |
| 2138 } | |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2139 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2140 GaimChat * |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2141 gaim_blist_find_chat(GaimAccount *account, const char *name) |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2142 { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2143 char *chat_name; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2144 GaimChat *chat; |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2145 GaimPlugin *prpl; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2146 GaimPluginProtocolInfo *prpl_info = NULL; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2147 struct proto_chat_entry *pce; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2148 GaimBlistNode *node, *group; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2149 GList *parts; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2150 |
| 9285 | 2151 g_return_val_if_fail(gaimbuddylist != NULL, NULL); |
| 2152 g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL); | |
| 2153 | |
| 2154 if (!gaim_account_is_connected(account)) | |
| 7970 | 2155 return NULL; |
| 2156 | |
| 7999 | 2157 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
| 2158 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
| 2159 | |
| 9285 | 2160 if (prpl_info->find_blist_chat != NULL) |
| 7999 | 2161 return prpl_info->find_blist_chat(account, name); |
| 2162 | |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2163 for (group = gaimbuddylist->root; group != NULL; group = group->next) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2164 for (node = group->child; node != NULL; node = node->next) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2165 if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2166 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2167 chat = (GaimChat*)node; |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2168 |
| 9285 | 2169 if (account != chat->account) |
| 7970 | 2170 continue; |
| 2171 | |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2172 parts = prpl_info->chat_info( |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2173 gaim_account_get_connection(chat->account)); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2174 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2175 pce = parts->data; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2176 chat_name = g_hash_table_lookup(chat->components, |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2177 pce->identifier); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2178 |
| 9153 | 2179 if (chat->account == account && chat_name != NULL && |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2180 name != NULL && !strcmp(chat_name, name)) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2181 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2182 return chat; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2183 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2184 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2185 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2186 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2187 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2188 return NULL; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2189 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2190 |
| 6695 | 2191 GaimGroup * |
| 7125 | 2192 gaim_chat_get_group(GaimChat *chat) |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2193 { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2194 g_return_val_if_fail(chat != NULL, NULL); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2195 |
| 6695 | 2196 return (GaimGroup *)(((GaimBlistNode *)chat)->parent); |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2197 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
2198 |
| 9285 | 2199 GaimContact *gaim_buddy_get_contact(GaimBuddy *buddy) |
| 2200 { | |
| 2201 g_return_val_if_fail(buddy != NULL, NULL); | |
| 2202 | |
| 2203 return (GaimContact*)((GaimBlistNode*)buddy)->parent; | |
| 2204 } | |
| 2205 | |
| 9949 | 2206 GaimPresence *gaim_buddy_get_presence(const GaimBuddy *buddy) |
| 2207 { | |
| 2208 g_return_val_if_fail(buddy != NULL, NULL); | |
|
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2209 return buddy->presence; |
| 9949 | 2210 } |
| 2211 | |
| 12088 | 2212 GaimGroup *gaim_buddy_get_group(GaimBuddy *buddy) |
| 5228 | 2213 { |
| 9285 | 2214 g_return_val_if_fail(buddy != NULL, NULL); |
|
6706
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2215 |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2216 if (((GaimBlistNode *)buddy)->parent == NULL) |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2217 return NULL; |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2218 |
| 6695 | 2219 return (GaimGroup *)(((GaimBlistNode*)buddy)->parent->parent); |
| 5228 | 2220 } |
| 2221 | |
| 9285 | 2222 GSList *gaim_group_get_accounts(GaimGroup *group) |
| 5228 | 2223 { |
| 2224 GSList *l = NULL; | |
| 6695 | 2225 GaimBlistNode *gnode, *cnode, *bnode; |
| 2226 | |
| 9285 | 2227 gnode = (GaimBlistNode *)group; |
| 2228 | |
| 2229 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 6695 | 2230 if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
| 9285 | 2231 if (!g_slist_find(l, ((GaimChat *)cnode)->account)) |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2232 l = g_slist_append(l, ((GaimChat *)cnode)->account); |
| 9285 | 2233 } else if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
| 2234 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 2235 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
| 2236 if (!g_slist_find(l, ((GaimBuddy *)bnode)->account)) | |
| 6695 | 2237 l = g_slist_append(l, ((GaimBuddy *)bnode)->account); |
| 2238 } | |
| 2239 } | |
| 2240 } | |
| 5228 | 2241 } |
| 6695 | 2242 |
| 5228 | 2243 return l; |
| 2244 } | |
| 2245 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2246 void gaim_blist_add_account(GaimAccount *account) |
| 5234 | 2247 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
2248 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 6695 | 2249 GaimBlistNode *gnode, *cnode, *bnode; |
| 5234 | 2250 |
| 9285 | 2251 g_return_if_fail(gaimbuddylist != NULL); |
| 2252 | |
| 2253 if (!ops || !ops->update) | |
| 6695 | 2254 return; |
| 2255 | |
| 9285 | 2256 for (gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { |
| 2257 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 5234 | 2258 continue; |
| 9285 | 2259 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
| 2260 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 6956 | 2261 gboolean recompute = FALSE; |
| 9285 | 2262 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
| 2263 if (GAIM_BLIST_NODE_IS_BUDDY(bnode) && | |
| 6695 | 2264 ((GaimBuddy*)bnode)->account == account) { |
| 6956 | 2265 recompute = TRUE; |
| 6695 | 2266 ((GaimContact*)cnode)->currentsize++; |
| 9285 | 2267 if (((GaimContact*)cnode)->currentsize == 1) |
| 6695 | 2268 ((GaimGroup*)gnode)->currentsize++; |
| 2269 ops->update(gaimbuddylist, bnode); | |
| 2270 } | |
| 2271 } | |
| 9285 | 2272 if (recompute || |
| 8960 | 2273 gaim_blist_node_get_bool(cnode, "show_offline")) { |
| 10378 | 2274 gaim_contact_invalidate_priority_buddy((GaimContact*)cnode); |
| 6956 | 2275 ops->update(gaimbuddylist, cnode); |
| 2276 } | |
| 9285 | 2277 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode) && |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2278 ((GaimChat*)cnode)->account == account) { |
| 6901 | 2279 ((GaimGroup *)gnode)->online++; |
| 2280 ((GaimGroup *)gnode)->currentsize++; | |
| 2281 ops->update(gaimbuddylist, cnode); | |
| 5234 | 2282 } |
| 2283 } | |
| 6695 | 2284 ops->update(gaimbuddylist, gnode); |
| 5234 | 2285 } |
| 2286 } | |
| 2287 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2288 void gaim_blist_remove_account(GaimAccount *account) |
| 5228 | 2289 { |
|
13867
a092ea4edd4e
[gaim-migrate @ 16333]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13495
diff
changeset
|
2290 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
| 6695 | 2291 GaimBlistNode *gnode, *cnode, *bnode; |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2292 GaimBuddy *buddy; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2293 GaimChat *chat; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2294 GaimContact *contact; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2295 GaimGroup *group; |
| 12305 | 2296 GList *list = NULL, *iter = NULL; |
| 5234 | 2297 |
| 9285 | 2298 g_return_if_fail(gaimbuddylist != NULL); |
| 2299 | |
| 2300 for (gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
| 2301 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 5234 | 2302 continue; |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2303 |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2304 group = (GaimGroup *)gnode; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2305 |
| 9285 | 2306 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
| 2307 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 10727 | 2308 gboolean recompute = FALSE; |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2309 contact = (GaimContact *)cnode; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2310 |
| 9285 | 2311 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
| 2312 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 6695 | 2313 continue; |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2314 |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2315 buddy = (GaimBuddy *)bnode; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2316 if (account == buddy->account) { |
| 10557 | 2317 GaimPresence *presence; |
| 6957 | 2318 recompute = TRUE; |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2319 |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2320 presence = gaim_buddy_get_presence(buddy); |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2321 |
| 10728 | 2322 if(gaim_presence_is_online(presence)) { |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2323 contact->online--; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2324 if (contact->online == 0) |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2325 group->online--; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2326 |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2327 gaim_blist_node_set_int(&buddy->node, |
| 10475 | 2328 "last_seen", time(NULL)); |
| 6695 | 2329 } |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2330 |
| 10728 | 2331 contact->currentsize--; |
| 2332 if (contact->currentsize == 0) | |
| 2333 group->currentsize--; | |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2334 |
| 12305 | 2335 if (!g_list_find(list, presence)) |
| 2336 list = g_list_prepend(list, presence); | |
| 10557 | 2337 |
| 9285 | 2338 if (ops && ops->remove) |
| 6695 | 2339 ops->remove(gaimbuddylist, bnode); |
| 2340 } | |
| 5234 | 2341 } |
| 9285 | 2342 if (recompute) { |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2343 gaim_contact_invalidate_priority_buddy(contact); |
| 9285 | 2344 if (ops && ops->update) |
| 6983 | 2345 ops->update(gaimbuddylist, cnode); |
| 2346 } | |
|
10726
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2347 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2348 chat = (GaimChat *)cnode; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2349 |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2350 if(chat->account == account) { |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2351 group->currentsize--; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2352 group->online--; |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2353 |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2354 if (ops && ops->remove) |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2355 ops->remove(gaimbuddylist, cnode); |
|
00e3dc1a0206
[gaim-migrate @ 12326]
Luke Schierer <lschiere@pidgin.im>
parents:
10704
diff
changeset
|
2356 } |
| 5228 | 2357 } |
| 2358 } | |
| 2359 } | |
| 12305 | 2360 |
| 2361 for (iter = list; iter; iter = iter->next) | |
| 2362 { | |
| 2363 gaim_presence_set_status_active(iter->data, "offline", TRUE); | |
| 2364 } | |
| 2365 g_list_free(list); | |
| 5228 | 2366 } |
| 2367 | |
| 9285 | 2368 gboolean gaim_group_on_account(GaimGroup *g, GaimAccount *account) |
| 2369 { | |
| 9787 | 2370 GaimBlistNode *cnode; |
| 9285 | 2371 for (cnode = ((GaimBlistNode *)g)->child; cnode; cnode = cnode->next) { |
| 2372 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 9787 | 2373 if(gaim_contact_on_account((GaimContact *) cnode, account)) |
| 2374 return TRUE; | |
| 9285 | 2375 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2376 GaimChat *chat = (GaimChat *)cnode; |
| 9285 | 2377 if ((!account && gaim_account_is_connected(chat->account)) |
| 6695 | 2378 || chat->account == account) |
| 2379 return TRUE; | |
| 2380 } | |
| 5228 | 2381 } |
| 2382 return FALSE; | |
| 2383 } | |
| 2384 | |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2385 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2386 gaim_blist_request_add_buddy(GaimAccount *account, const char *username, |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2387 const char *group, const char *alias) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2388 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2389 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2390 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2391 ui_ops = gaim_blist_get_ui_ops(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2392 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2393 if (ui_ops != NULL && ui_ops->request_add_buddy != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2394 ui_ops->request_add_buddy(account, username, group, alias); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2395 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2396 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2397 void |
| 9754 | 2398 gaim_blist_request_add_chat(GaimAccount *account, GaimGroup *group, |
| 2399 const char *alias, const char *name) | |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2400 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2401 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2402 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2403 ui_ops = gaim_blist_get_ui_ops(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2404 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2405 if (ui_ops != NULL && ui_ops->request_add_chat != NULL) |
| 9754 | 2406 ui_ops->request_add_chat(account, group, alias, name); |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2407 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2408 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2409 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2410 gaim_blist_request_add_group(void) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2411 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2412 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2413 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2414 ui_ops = gaim_blist_get_ui_ops(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2415 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2416 if (ui_ops != NULL && ui_ops->request_add_group != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2417 ui_ops->request_add_group(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2418 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2419 |
| 10430 | 2420 static void |
| 2421 gaim_blist_node_setting_free(gpointer data) | |
| 7693 | 2422 { |
| 10430 | 2423 GaimValue *value; |
| 2424 | |
| 2425 value = (GaimValue *)data; | |
| 2426 | |
| 2427 gaim_value_destroy(value); | |
| 7693 | 2428 } |
| 2429 | |
| 9285 | 2430 static void gaim_blist_node_initialize_settings(GaimBlistNode *node) |
| 7693 | 2431 { |
| 9285 | 2432 if (node->settings) |
| 5228 | 2433 return; |
| 7693 | 2434 |
| 2435 node->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, | |
| 2436 (GDestroyNotify)gaim_blist_node_setting_free); | |
| 2437 } | |
| 2438 | |
| 2439 void gaim_blist_node_remove_setting(GaimBlistNode *node, const char *key) | |
| 2440 { | |
| 2441 g_return_if_fail(node != NULL); | |
| 2442 g_return_if_fail(node->settings != NULL); | |
| 2443 g_return_if_fail(key != NULL); | |
| 2444 | |
| 2445 g_hash_table_remove(node->settings, key); | |
| 9285 | 2446 |
| 10704 | 2447 gaim_blist_schedule_save(); |
| 5228 | 2448 } |
| 2449 | |
| 10430 | 2450 void |
| 10548 | 2451 gaim_blist_node_set_flags(GaimBlistNode *node, GaimBlistNodeFlags flags) |
| 2452 { | |
| 2453 g_return_if_fail(node != NULL); | |
| 2454 | |
| 2455 node->flags = flags; | |
| 2456 } | |
| 2457 | |
| 2458 GaimBlistNodeFlags | |
| 2459 gaim_blist_node_get_flags(GaimBlistNode *node) | |
| 2460 { | |
| 2461 g_return_val_if_fail(node != NULL, 0); | |
| 2462 | |
| 2463 return node->flags; | |
| 2464 } | |
| 2465 | |
| 2466 void | |
| 10430 | 2467 gaim_blist_node_set_bool(GaimBlistNode* node, const char *key, gboolean data) |
| 7693 | 2468 { |
| 10430 | 2469 GaimValue *value; |
| 7693 | 2470 |
| 2471 g_return_if_fail(node != NULL); | |
| 2472 g_return_if_fail(node->settings != NULL); | |
| 2473 g_return_if_fail(key != NULL); | |
| 2474 | |
| 10430 | 2475 value = gaim_value_new(GAIM_TYPE_BOOLEAN); |
| 2476 gaim_value_set_boolean(value, data); | |
| 2477 | |
| 2478 g_hash_table_replace(node->settings, g_strdup(key), value); | |
| 9285 | 2479 |
| 10704 | 2480 gaim_blist_schedule_save(); |
| 7693 | 2481 } |
| 2482 | |
| 10430 | 2483 gboolean |
| 2484 gaim_blist_node_get_bool(GaimBlistNode* node, const char *key) | |
| 7693 | 2485 { |
| 10430 | 2486 GaimValue *value; |
| 7693 | 2487 |
| 2488 g_return_val_if_fail(node != NULL, FALSE); | |
| 2489 g_return_val_if_fail(node->settings != NULL, FALSE); | |
| 2490 g_return_val_if_fail(key != NULL, FALSE); | |
| 2491 | |
| 10430 | 2492 value = g_hash_table_lookup(node->settings, key); |
| 2493 | |
| 2494 if (value == NULL) | |
| 7849 | 2495 return FALSE; |
| 2496 | |
| 10430 | 2497 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_BOOLEAN, FALSE); |
| 2498 | |
| 2499 return gaim_value_get_boolean(value); | |
| 5228 | 2500 } |
| 2501 | |
| 10430 | 2502 void |
| 2503 gaim_blist_node_set_int(GaimBlistNode* node, const char *key, int data) | |
| 7693 | 2504 { |
| 10430 | 2505 GaimValue *value; |
| 7693 | 2506 |
| 2507 g_return_if_fail(node != NULL); | |
| 2508 g_return_if_fail(node->settings != NULL); | |
| 2509 g_return_if_fail(key != NULL); | |
| 2510 | |
| 10430 | 2511 value = gaim_value_new(GAIM_TYPE_INT); |
| 2512 gaim_value_set_int(value, data); | |
| 2513 | |
| 2514 g_hash_table_replace(node->settings, g_strdup(key), value); | |
| 9285 | 2515 |
| 10704 | 2516 gaim_blist_schedule_save(); |
| 7693 | 2517 } |
| 2518 | |
| 10430 | 2519 int |
| 2520 gaim_blist_node_get_int(GaimBlistNode* node, const char *key) | |
| 7693 | 2521 { |
| 10430 | 2522 GaimValue *value; |
| 7693 | 2523 |
| 2524 g_return_val_if_fail(node != NULL, 0); | |
| 2525 g_return_val_if_fail(node->settings != NULL, 0); | |
| 2526 g_return_val_if_fail(key != NULL, 0); | |
| 2527 | |
| 10430 | 2528 value = g_hash_table_lookup(node->settings, key); |
| 2529 | |
| 2530 if (value == NULL) | |
| 7849 | 2531 return 0; |
| 2532 | |
| 10430 | 2533 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_INT, 0); |
| 2534 | |
| 2535 return gaim_value_get_int(value); | |
| 7693 | 2536 } |
| 2537 | |
| 10430 | 2538 void |
| 2539 gaim_blist_node_set_string(GaimBlistNode* node, const char *key, const char *data) | |
| 5906 | 2540 { |
| 10430 | 2541 GaimValue *value; |
| 7693 | 2542 |
| 2543 g_return_if_fail(node != NULL); | |
| 2544 g_return_if_fail(node->settings != NULL); | |
| 2545 g_return_if_fail(key != NULL); | |
| 2546 | |
| 10430 | 2547 value = gaim_value_new(GAIM_TYPE_STRING); |
| 2548 gaim_value_set_string(value, data); | |
| 2549 | |
| 2550 g_hash_table_replace(node->settings, g_strdup(key), value); | |
| 9285 | 2551 |
| 10704 | 2552 gaim_blist_schedule_save(); |
| 7693 | 2553 } |
| 2554 | |
| 10430 | 2555 const char * |
| 2556 gaim_blist_node_get_string(GaimBlistNode* node, const char *key) | |
| 7693 | 2557 { |
| 10430 | 2558 GaimValue *value; |
| 7693 | 2559 |
| 2560 g_return_val_if_fail(node != NULL, NULL); | |
| 2561 g_return_val_if_fail(node->settings != NULL, NULL); | |
| 2562 g_return_val_if_fail(key != NULL, NULL); | |
| 2563 | |
| 10430 | 2564 value = g_hash_table_lookup(node->settings, key); |
| 2565 | |
| 2566 if (value == NULL) | |
| 7849 | 2567 return NULL; |
| 2568 | |
| 10430 | 2569 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_STRING, NULL); |
| 2570 | |
| 2571 return gaim_value_get_string(value); | |
| 7693 | 2572 } |
| 2573 | |
|
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10567
diff
changeset
|
2574 GList * |
|
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10567
diff
changeset
|
2575 gaim_blist_node_get_extended_menu(GaimBlistNode *n) |
| 7693 | 2576 { |
|
8710
36b043fe2740
[gaim-migrate @ 9464]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
2577 GList *menu = NULL; |
| 9030 | 2578 |
|
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10567
diff
changeset
|
2579 g_return_val_if_fail(n != NULL, NULL); |
| 9030 | 2580 |
| 2581 gaim_signal_emit(gaim_blist_get_handle(), | |
| 2582 "blist-node-extended-menu", | |
| 2583 n, &menu); | |
|
8710
36b043fe2740
[gaim-migrate @ 9464]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
2584 return menu; |
|
36b043fe2740
[gaim-migrate @ 9464]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
2585 } |
|
36b043fe2740
[gaim-migrate @ 9464]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
2586 |
| 9285 | 2587 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) |
| 2588 { | |
| 2589 if (!group) | |
| 5228 | 2590 return 0; |
| 2591 | |
| 5277 | 2592 return offline ? group->totalsize : group->currentsize; |
| 5228 | 2593 } |
| 2594 | |
| 9285 | 2595 int gaim_blist_get_group_online_count(GaimGroup *group) |
| 2596 { | |
| 2597 if (!group) | |
| 5228 | 2598 return 0; |
| 2599 | |
| 5277 | 2600 return group->online; |
| 5228 | 2601 } |
| 2602 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2603 void |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2604 gaim_blist_set_ui_ops(GaimBlistUiOps *ops) |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2605 { |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2606 blist_ui_ops = ops; |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2607 } |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2608 |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2609 GaimBlistUiOps * |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2610 gaim_blist_get_ui_ops(void) |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2611 { |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2612 return blist_ui_ops; |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2613 } |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2614 |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2615 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2616 void * |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2617 gaim_blist_get_handle(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2618 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2619 static int handle; |
| 5228 | 2620 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2621 return &handle; |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2622 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2623 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2624 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2625 gaim_blist_init(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2626 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2627 void *handle = gaim_blist_get_handle(); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2628 |
|
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2629 gaim_signal_register(handle, "buddy-status-changed", |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2630 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2631 3, |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2632 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2633 GAIM_SUBTYPE_BLIST_BUDDY), |
|
11979
717cbb3115bc
[gaim-migrate @ 14272]
Gary Kramlich <grim@reaperworld.com>
parents:
11935
diff
changeset
|
2634 gaim_value_new(GAIM_TYPE_SUBTYPE, |
| 12097 | 2635 GAIM_SUBTYPE_STATUS), |
|
11979
717cbb3115bc
[gaim-migrate @ 14272]
Gary Kramlich <grim@reaperworld.com>
parents:
11935
diff
changeset
|
2636 gaim_value_new(GAIM_TYPE_SUBTYPE, |
| 12097 | 2637 GAIM_SUBTYPE_STATUS)); |
|
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2638 |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2639 gaim_signal_register(handle, "buddy-idle-changed", |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2640 gaim_marshal_VOID__POINTER_INT_INT, NULL, |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2641 3, |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2642 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2643 GAIM_SUBTYPE_BLIST_BUDDY), |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2644 gaim_value_new(GAIM_TYPE_INT), |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2645 gaim_value_new(GAIM_TYPE_INT)); |
|
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11910
diff
changeset
|
2646 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2647 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2648 gaim_signal_register(handle, "buddy-signed-on", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2649 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2650 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2651 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2652 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2653 gaim_signal_register(handle, "buddy-signed-off", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2654 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2655 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2656 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2657 |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2658 gaim_signal_register(handle, "buddy-added", |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2659 gaim_marshal_VOID__POINTER, NULL, 1, |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2660 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2661 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2662 |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2663 gaim_signal_register(handle, "buddy-removed", |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2664 gaim_marshal_VOID__POINTER, NULL, 1, |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2665 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2666 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2667 |
| 12097 | 2668 gaim_signal_register(handle, "buddy-icon-changed", |
| 2669 gaim_marshal_VOID__POINTER, NULL, 1, | |
| 2670 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
| 2671 GAIM_SUBTYPE_BLIST_BUDDY)); | |
| 2672 | |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2673 gaim_signal_register(handle, "update-idle", gaim_marshal_VOID, NULL, 0); |
| 9030 | 2674 |
| 2675 gaim_signal_register(handle, "blist-node-extended-menu", | |
|
8710
36b043fe2740
[gaim-migrate @ 9464]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
2676 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
|
36b043fe2740
[gaim-migrate @ 9464]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
2677 gaim_value_new(GAIM_TYPE_SUBTYPE, |
| 9030 | 2678 GAIM_SUBTYPE_BLIST_NODE), |
| 8952 | 2679 gaim_value_new(GAIM_TYPE_BOXED, "GList **")); |
|
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2680 |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2681 gaim_signal_register(handle, "blist-node-aliased", |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2682 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2683 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2684 GAIM_SUBTYPE_BLIST_NODE), |
|
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11434
diff
changeset
|
2685 gaim_value_new(GAIM_TYPE_STRING)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2686 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2687 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2688 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2689 gaim_blist_uninit(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2690 { |
| 10428 | 2691 if (save_timer != 0) |
| 2692 { | |
| 2693 gaim_timeout_remove(save_timer); | |
| 2694 save_timer = 0; | |
| 9285 | 2695 gaim_blist_sync(); |
| 2696 } | |
| 2697 | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2698 gaim_signals_unregister_by_instance(gaim_blist_get_handle()); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2699 } |
