Mercurial > pidgin.yaz
comparison src/blist.c @ 7118:bf630f7dfdcd
[gaim-migrate @ 7685]
Here's a commit that I think will make faceprint happy. GaimWindow ->
GaimConvWindow, GaimIm -> GaimConvIm, GaimChat -> GaimConvChat,
GaimBlistChat -> GaimChat, and updated the API functions as well. Plugin
authors are going to hunt me down and murder me. I can feel it..
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 02 Oct 2003 02:54:07 +0000 |
parents | 943085b0ff8b |
children | 208cb260d7a7 |
comparison
equal
deleted
inserted
replaced
7117:943085b0ff8b | 7118:bf630f7dfdcd |
---|---|
321 buddy->name = g_strdup(name); | 321 buddy->name = g_strdup(name); |
322 if (ops) | 322 if (ops) |
323 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | 323 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); |
324 } | 324 } |
325 | 325 |
326 void gaim_blist_alias_chat(GaimBlistChat *chat, const char *alias) | 326 void gaim_blist_alias_chat(GaimChat *chat, const char *alias) |
327 { | 327 { |
328 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 328 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
329 | 329 |
330 g_free(chat->alias); | 330 g_free(chat->alias); |
331 | 331 |
404 for(bnode = child->child; bnode; bnode = bnode->next) | 404 for(bnode = child->child; bnode; bnode = bnode->next) |
405 gaim_blist_add_buddy((GaimBuddy*)bnode, (GaimContact*)child, | 405 gaim_blist_add_buddy((GaimBuddy*)bnode, (GaimContact*)child, |
406 NULL, bnode->prev); | 406 NULL, bnode->prev); |
407 prev = child; | 407 prev = child; |
408 } else if(GAIM_BLIST_NODE_IS_CHAT(child)) { | 408 } else if(GAIM_BLIST_NODE_IS_CHAT(child)) { |
409 gaim_blist_add_chat((GaimBlistChat *)child, dest_group, prev); | 409 gaim_blist_add_chat((GaimChat *)child, dest_group, prev); |
410 prev = child; | 410 prev = child; |
411 } else { | 411 } else { |
412 gaim_debug(GAIM_DEBUG_ERROR, "blist", | 412 gaim_debug(GAIM_DEBUG_ERROR, "blist", |
413 "Unknown child type in group %s\n", group->name); | 413 "Unknown child type in group %s\n", group->name); |
414 } | 414 } |
430 if (ops) | 430 if (ops) |
431 ops->update(gaimbuddylist, (GaimBlistNode*)group); | 431 ops->update(gaimbuddylist, (GaimBlistNode*)group); |
432 } | 432 } |
433 } | 433 } |
434 | 434 |
435 GaimBlistChat *gaim_blist_chat_new(GaimAccount *account, const char *alias, GHashTable *components) | 435 GaimChat *gaim_blist_chat_new(GaimAccount *account, const char *alias, GHashTable *components) |
436 { | 436 { |
437 GaimBlistChat *chat; | 437 GaimChat *chat; |
438 GaimBlistUiOps *ops; | 438 GaimBlistUiOps *ops; |
439 | 439 |
440 if(!components) | 440 if(!components) |
441 return NULL; | 441 return NULL; |
442 | 442 |
443 chat = g_new0(GaimBlistChat, 1); | 443 chat = g_new0(GaimChat, 1); |
444 chat->account = account; | 444 chat->account = account; |
445 if(alias && strlen(alias)) | 445 if(alias && strlen(alias)) |
446 chat->alias = g_strdup(alias); | 446 chat->alias = g_strdup(alias); |
447 chat->components = components; | 447 chat->components = components; |
448 chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal, | 448 chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
456 ops->new_node((GaimBlistNode *)chat); | 456 ops->new_node((GaimBlistNode *)chat); |
457 | 457 |
458 return chat; | 458 return chat; |
459 } | 459 } |
460 | 460 |
461 char *gaim_blist_chat_get_display_name(GaimBlistChat *chat) | 461 char *gaim_blist_chat_get_display_name(GaimChat *chat) |
462 { | 462 { |
463 char *name; | 463 char *name; |
464 | 464 |
465 if(chat->alias){ | 465 if(chat->alias){ |
466 name = g_strdup(chat->alias); | 466 name = g_strdup(chat->alias); |
529 g_return_val_if_fail(buddy != NULL, NULL); | 529 g_return_val_if_fail(buddy != NULL, NULL); |
530 | 530 |
531 return buddy->icon; | 531 return buddy->icon; |
532 } | 532 } |
533 | 533 |
534 void gaim_blist_add_chat(GaimBlistChat *chat, GaimGroup *group, GaimBlistNode *node) | 534 void gaim_blist_add_chat(GaimChat *chat, GaimGroup *group, GaimBlistNode *node) |
535 { | 535 { |
536 GaimBlistNode *n = node, *cnode = (GaimBlistNode*)chat; | 536 GaimBlistNode *n = node, *cnode = (GaimBlistNode*)chat; |
537 GaimGroup *g = group; | 537 GaimGroup *g = group; |
538 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 538 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
539 gboolean save = FALSE; | 539 gboolean save = FALSE; |
1051 | 1051 |
1052 if(!cnode->child) | 1052 if(!cnode->child) |
1053 gaim_blist_remove_contact((GaimContact*)cnode); | 1053 gaim_blist_remove_contact((GaimContact*)cnode); |
1054 } | 1054 } |
1055 | 1055 |
1056 void gaim_blist_remove_chat (GaimBlistChat *chat) | 1056 void gaim_blist_remove_chat (GaimChat *chat) |
1057 { | 1057 { |
1058 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 1058 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
1059 | 1059 |
1060 GaimBlistNode *gnode, *node = (GaimBlistNode*)chat; | 1060 GaimBlistNode *gnode, *node = (GaimBlistNode*)chat; |
1061 GaimGroup *group; | 1061 GaimGroup *group; |
1167 ret= gaim_get_buddy_alias_only(buddy); | 1167 ret= gaim_get_buddy_alias_only(buddy); |
1168 | 1168 |
1169 return ret ? ret : buddy->name; | 1169 return ret ? ret : buddy->name; |
1170 } | 1170 } |
1171 | 1171 |
1172 const char *gaim_blist_chat_get_name(GaimBlistChat *chat) | 1172 const char *gaim_blist_chat_get_name(GaimChat *chat) |
1173 { | 1173 { |
1174 if(chat->alias && *chat->alias) { | 1174 if(chat->alias && *chat->alias) { |
1175 return chat->alias; | 1175 return chat->alias; |
1176 } else { | 1176 } else { |
1177 struct proto_chat_entry *pce; | 1177 struct proto_chat_entry *pce; |
1268 node = node->next; | 1268 node = node->next; |
1269 } | 1269 } |
1270 return NULL; | 1270 return NULL; |
1271 } | 1271 } |
1272 | 1272 |
1273 GaimBlistChat * | 1273 GaimChat * |
1274 gaim_blist_find_chat(GaimAccount *account, const char *name) | 1274 gaim_blist_find_chat(GaimAccount *account, const char *name) |
1275 { | 1275 { |
1276 char *chat_name; | 1276 char *chat_name; |
1277 GaimBlistChat *chat; | 1277 GaimChat *chat; |
1278 GaimPlugin *prpl; | 1278 GaimPlugin *prpl; |
1279 GaimPluginProtocolInfo *prpl_info = NULL; | 1279 GaimPluginProtocolInfo *prpl_info = NULL; |
1280 struct proto_chat_entry *pce; | 1280 struct proto_chat_entry *pce; |
1281 GaimBlistNode *node, *group; | 1281 GaimBlistNode *node, *group; |
1282 GList *parts; | 1282 GList *parts; |
1286 | 1286 |
1287 for (group = gaimbuddylist->root; group != NULL; group = group->next) { | 1287 for (group = gaimbuddylist->root; group != NULL; group = group->next) { |
1288 for (node = group->child; node != NULL; node = node->next) { | 1288 for (node = group->child; node != NULL; node = node->next) { |
1289 if (GAIM_BLIST_NODE_IS_CHAT(node)) { | 1289 if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
1290 | 1290 |
1291 chat = (GaimBlistChat*)node; | 1291 chat = (GaimChat*)node; |
1292 | 1292 |
1293 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); | 1293 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); |
1294 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | 1294 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
1295 | 1295 |
1296 parts = prpl_info->chat_info( | 1296 parts = prpl_info->chat_info( |
1311 | 1311 |
1312 return NULL; | 1312 return NULL; |
1313 } | 1313 } |
1314 | 1314 |
1315 GaimGroup * | 1315 GaimGroup * |
1316 gaim_blist_chat_get_group(GaimBlistChat *chat) | 1316 gaim_blist_chat_get_group(GaimChat *chat) |
1317 { | 1317 { |
1318 g_return_val_if_fail(chat != NULL, NULL); | 1318 g_return_val_if_fail(chat != NULL, NULL); |
1319 | 1319 |
1320 return (GaimGroup *)(((GaimBlistNode *)chat)->parent); | 1320 return (GaimGroup *)(((GaimBlistNode *)chat)->parent); |
1321 } | 1321 } |
1338 | 1338 |
1339 gnode = (GaimBlistNode *)g; | 1339 gnode = (GaimBlistNode *)g; |
1340 | 1340 |
1341 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 1341 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
1342 if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | 1342 if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
1343 if(!g_slist_find(l, ((GaimBlistChat *)cnode)->account)) | 1343 if(!g_slist_find(l, ((GaimChat *)cnode)->account)) |
1344 l = g_slist_append(l, ((GaimBlistChat *)cnode)->account); | 1344 l = g_slist_append(l, ((GaimChat *)cnode)->account); |
1345 } else if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | 1345 } else if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
1346 for(bnode = cnode->child; bnode; bnode = bnode->next) { | 1346 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
1347 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | 1347 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
1348 if(!g_slist_find(l, ((GaimBuddy *)bnode)->account)) | 1348 if(!g_slist_find(l, ((GaimBuddy *)bnode)->account)) |
1349 l = g_slist_append(l, ((GaimBuddy *)bnode)->account); | 1349 l = g_slist_append(l, ((GaimBuddy *)bnode)->account); |
1390 if(recompute) { | 1390 if(recompute) { |
1391 gaim_contact_compute_priority_buddy((GaimContact*)cnode); | 1391 gaim_contact_compute_priority_buddy((GaimContact*)cnode); |
1392 ops->update(gaimbuddylist, cnode); | 1392 ops->update(gaimbuddylist, cnode); |
1393 } | 1393 } |
1394 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && | 1394 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
1395 ((GaimBlistChat*)cnode)->account == account) { | 1395 ((GaimChat*)cnode)->account == account) { |
1396 ((GaimGroup *)gnode)->online++; | 1396 ((GaimGroup *)gnode)->online++; |
1397 ((GaimGroup *)gnode)->currentsize++; | 1397 ((GaimGroup *)gnode)->currentsize++; |
1398 ops->update(gaimbuddylist, cnode); | 1398 ops->update(gaimbuddylist, cnode); |
1399 } | 1399 } |
1400 } | 1400 } |
1446 gaim_contact_compute_priority_buddy((GaimContact*)cnode); | 1446 gaim_contact_compute_priority_buddy((GaimContact*)cnode); |
1447 if(ops) | 1447 if(ops) |
1448 ops->update(gaimbuddylist, cnode); | 1448 ops->update(gaimbuddylist, cnode); |
1449 } | 1449 } |
1450 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && | 1450 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
1451 ((GaimBlistChat*)cnode)->account == account) { | 1451 ((GaimChat*)cnode)->account == account) { |
1452 ((GaimGroup*)gnode)->currentsize--; | 1452 ((GaimGroup*)gnode)->currentsize--; |
1453 ((GaimGroup*)gnode)->online--; | 1453 ((GaimGroup*)gnode)->online--; |
1454 if(ops) | 1454 if(ops) |
1455 ops->remove(gaimbuddylist, cnode); | 1455 ops->remove(gaimbuddylist, cnode); |
1456 } | 1456 } |
1849 || buddy->account == account) | 1849 || buddy->account == account) |
1850 return TRUE; | 1850 return TRUE; |
1851 } | 1851 } |
1852 } | 1852 } |
1853 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | 1853 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
1854 GaimBlistChat *chat = (GaimBlistChat *)cnode; | 1854 GaimChat *chat = (GaimChat *)cnode; |
1855 if((!account && gaim_account_is_connected(chat->account)) | 1855 if((!account && gaim_account_is_connected(chat->account)) |
1856 || chat->account == account) | 1856 || chat->account == account) |
1857 return TRUE; | 1857 return TRUE; |
1858 } | 1858 } |
1859 } | 1859 } |
2023 blist_parser_group = NULL; | 2023 blist_parser_group = NULL; |
2024 } else if(!strcmp(element_name, "chat")) { | 2024 } else if(!strcmp(element_name, "chat")) { |
2025 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, | 2025 GaimAccount *account = gaim_accounts_find(blist_parser_account_name, |
2026 blist_parser_account_protocol); | 2026 blist_parser_account_protocol); |
2027 if(account) { | 2027 if(account) { |
2028 GaimBlistChat *chat = gaim_blist_chat_new(account, | 2028 GaimChat *chat = gaim_blist_chat_new(account, |
2029 blist_parser_chat_alias, blist_parser_chat_components); | 2029 blist_parser_chat_alias, blist_parser_chat_components); |
2030 gaim_blist_add_chat(chat,blist_parser_group, | 2030 gaim_blist_add_chat(chat,blist_parser_group, |
2031 gaim_blist_get_last_child((GaimBlistNode*)blist_parser_group)); | 2031 gaim_blist_get_last_child((GaimBlistNode*)blist_parser_group)); |
2032 if(blist_parser_chat_settings) { | 2032 if(blist_parser_chat_settings) { |
2033 g_hash_table_destroy(chat->settings); | 2033 g_hash_table_destroy(chat->settings); |
2440 } | 2440 } |
2441 } | 2441 } |
2442 | 2442 |
2443 fprintf(file, "\t\t\t</contact>\n"); | 2443 fprintf(file, "\t\t\t</contact>\n"); |
2444 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | 2444 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
2445 GaimBlistChat *chat = (GaimBlistChat *)cnode; | 2445 GaimChat *chat = (GaimChat *)cnode; |
2446 if(!exp_acct || chat->account == exp_acct) { | 2446 if(!exp_acct || chat->account == exp_acct) { |
2447 char *acct_name = g_markup_escape_text(chat->account->username, -1); | 2447 char *acct_name = g_markup_escape_text(chat->account->username, -1); |
2448 fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n", | 2448 fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n", |
2449 gaim_account_get_protocol(chat->account), | 2449 gaim_account_get_protocol(chat->account), |
2450 acct_name); | 2450 acct_name); |
2552 if(!g) | 2552 if(!g) |
2553 return NULL; | 2553 return NULL; |
2554 return g_strdup(g_hash_table_lookup(g->settings, key)); | 2554 return g_strdup(g_hash_table_lookup(g->settings, key)); |
2555 } | 2555 } |
2556 | 2556 |
2557 void gaim_blist_chat_set_setting(GaimBlistChat *c, const char *key, | 2557 void gaim_blist_chat_set_setting(GaimChat *c, const char *key, |
2558 const char *value) | 2558 const char *value) |
2559 { | 2559 { |
2560 if(!c) | 2560 if(!c) |
2561 return; | 2561 return; |
2562 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); | 2562 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); |
2563 } | 2563 } |
2564 | 2564 |
2565 char *gaim_blist_chat_get_setting(GaimBlistChat *c, const char *key) | 2565 char *gaim_blist_chat_get_setting(GaimChat *c, const char *key) |
2566 { | 2566 { |
2567 if(!c) | 2567 if(!c) |
2568 return NULL; | 2568 return NULL; |
2569 return g_strdup(g_hash_table_lookup(c->settings, key)); | 2569 return g_strdup(g_hash_table_lookup(c->settings, key)); |
2570 } | 2570 } |