comparison 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
comparison
equal deleted inserted replaced
13866:cf6f32628f8f 13867:a092ea4edd4e
653 * Public API functions * 653 * Public API functions *
654 *****************************************************************************/ 654 *****************************************************************************/
655 655
656 GaimBuddyList *gaim_blist_new() 656 GaimBuddyList *gaim_blist_new()
657 { 657 {
658 GaimBlistUiOps *ui_ops;
658 GaimBuddyList *gbl = g_new0(GaimBuddyList, 1); 659 GaimBuddyList *gbl = g_new0(GaimBuddyList, 1);
659 GAIM_DBUS_REGISTER_POINTER(gbl, GaimBuddyList); 660 GAIM_DBUS_REGISTER_POINTER(gbl, GaimBuddyList);
660 661
661 gbl->ui_ops = gaim_blist_get_ui_ops(); 662 ui_ops = gaim_blist_get_ui_ops();
662 663
663 gbl->buddies = g_hash_table_new_full((GHashFunc)_gaim_blist_hbuddy_hash, 664 gbl->buddies = g_hash_table_new_full((GHashFunc)_gaim_blist_hbuddy_hash,
664 (GEqualFunc)_gaim_blist_hbuddy_equal, 665 (GEqualFunc)_gaim_blist_hbuddy_equal,
665 (GDestroyNotify)_gaim_blist_hbuddy_free_key, NULL); 666 (GDestroyNotify)_gaim_blist_hbuddy_free_key, NULL);
666 667
667 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL) 668 if (ui_ops != NULL && ui_ops->new_list != NULL)
668 gbl->ui_ops->new_list(gbl); 669 ui_ops->new_list(gbl);
669 670
670 return gbl; 671 return gbl;
671 } 672 }
672 673
673 void 674 void
688 return gaimbuddylist ? gaimbuddylist->root : NULL; 689 return gaimbuddylist ? gaimbuddylist->root : NULL;
689 } 690 }
690 691
691 void gaim_blist_show() 692 void gaim_blist_show()
692 { 693 {
693 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 694 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
694 695
695 if (ops && ops->show) 696 if (ops && ops->show)
696 ops->show(gaimbuddylist); 697 ops->show(gaimbuddylist);
697 } 698 }
698 699
699 void gaim_blist_destroy() 700 void gaim_blist_destroy()
700 { 701 {
701 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 702 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
702 703
703 gaim_debug(GAIM_DEBUG_INFO, "blist", "Destroying\n"); 704 gaim_debug(GAIM_DEBUG_INFO, "blist", "Destroying\n");
704 705
705 if (ops && ops->destroy) 706 if (ops && ops->destroy)
706 ops->destroy(gaimbuddylist); 707 ops->destroy(gaimbuddylist);
707 } 708 }
708 709
709 void gaim_blist_set_visible(gboolean show) 710 void gaim_blist_set_visible(gboolean show)
710 { 711 {
711 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 712 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
712 713
713 if (ops && ops->set_visible) 714 if (ops && ops->set_visible)
714 ops->set_visible(gaimbuddylist, show); 715 ops->set_visible(gaimbuddylist, show);
715 } 716 }
716 717
742 } 743 }
743 744
744 void 745 void
745 gaim_blist_update_buddy_status(GaimBuddy *buddy, GaimStatus *old_status) 746 gaim_blist_update_buddy_status(GaimBuddy *buddy, GaimStatus *old_status)
746 { 747 {
747 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 748 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
748 GaimPresence *presence; 749 GaimPresence *presence;
749 GaimStatus *status; 750 GaimStatus *status;
750 751
751 g_return_if_fail(buddy != NULL); 752 g_return_if_fail(buddy != NULL);
752 753
792 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); 793 ops->update(gaimbuddylist, (GaimBlistNode *)buddy);
793 } 794 }
794 795
795 void gaim_blist_update_buddy_icon(GaimBuddy *buddy) 796 void gaim_blist_update_buddy_icon(GaimBuddy *buddy)
796 { 797 {
797 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 798 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
798 799
799 g_return_if_fail(buddy != NULL); 800 g_return_if_fail(buddy != NULL);
800 801
801 if (ops && ops->update) 802 if (ops && ops->update)
802 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); 803 ops->update(gaimbuddylist, (GaimBlistNode *)buddy);
806 * TODO: Maybe remove the call to this from server.c and call it 807 * TODO: Maybe remove the call to this from server.c and call it
807 * from oscar.c and toc.c instead? 808 * from oscar.c and toc.c instead?
808 */ 809 */
809 void gaim_blist_rename_buddy(GaimBuddy *buddy, const char *name) 810 void gaim_blist_rename_buddy(GaimBuddy *buddy, const char *name)
810 { 811 {
811 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 812 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
812 struct _gaim_hbuddy *hb; 813 struct _gaim_hbuddy *hb;
813 814
814 g_return_if_fail(buddy != NULL); 815 g_return_if_fail(buddy != NULL);
815 816
816 hb = g_new(struct _gaim_hbuddy, 1); 817 hb = g_new(struct _gaim_hbuddy, 1);
832 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); 833 ops->update(gaimbuddylist, (GaimBlistNode *)buddy);
833 } 834 }
834 835
835 void gaim_blist_alias_contact(GaimContact *contact, const char *alias) 836 void gaim_blist_alias_contact(GaimContact *contact, const char *alias)
836 { 837 {
837 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 838 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
838 GaimConversation *conv; 839 GaimConversation *conv;
839 char *old_alias = contact->alias; 840 char *old_alias = contact->alias;
840 GaimBlistNode *bnode; 841 GaimBlistNode *bnode;
841 842
842 g_return_if_fail(contact != NULL); 843 g_return_if_fail(contact != NULL);
866 g_free(old_alias); 867 g_free(old_alias);
867 } 868 }
868 869
869 void gaim_blist_alias_chat(GaimChat *chat, const char *alias) 870 void gaim_blist_alias_chat(GaimChat *chat, const char *alias)
870 { 871 {
871 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 872 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
872 char *old_alias = chat->alias; 873 char *old_alias = chat->alias;
873 874
874 g_return_if_fail(chat != NULL); 875 g_return_if_fail(chat != NULL);
875 876
876 if ((alias != NULL) && (*alias != '\0')) 877 if ((alias != NULL) && (*alias != '\0'))
888 g_free(old_alias); 889 g_free(old_alias);
889 } 890 }
890 891
891 void gaim_blist_alias_buddy(GaimBuddy *buddy, const char *alias) 892 void gaim_blist_alias_buddy(GaimBuddy *buddy, const char *alias)
892 { 893 {
893 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 894 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
894 GaimConversation *conv; 895 GaimConversation *conv;
895 char *old_alias = buddy->alias; 896 char *old_alias = buddy->alias;
896 897
897 g_return_if_fail(buddy != NULL); 898 g_return_if_fail(buddy != NULL);
898 899
916 g_free(old_alias); 917 g_free(old_alias);
917 } 918 }
918 919
919 void gaim_blist_server_alias_buddy(GaimBuddy *buddy, const char *alias) 920 void gaim_blist_server_alias_buddy(GaimBuddy *buddy, const char *alias)
920 { 921 {
921 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 922 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
922 GaimConversation *conv; 923 GaimConversation *conv;
923 char *old_alias = buddy->server_alias; 924 char *old_alias = buddy->server_alias;
924 925
925 g_return_if_fail(buddy != NULL); 926 g_return_if_fail(buddy != NULL);
926 927
947 /* 948 /*
948 * TODO: If merging, prompt the user if they want to merge. 949 * TODO: If merging, prompt the user if they want to merge.
949 */ 950 */
950 void gaim_blist_rename_group(GaimGroup *source, const char *new_name) 951 void gaim_blist_rename_group(GaimGroup *source, const char *new_name)
951 { 952 {
952 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 953 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
953 GaimGroup *dest; 954 GaimGroup *dest;
954 gchar *old_name; 955 gchar *old_name;
955 GList *moved_buddies = NULL; 956 GList *moved_buddies = NULL;
956 GSList *accts; 957 GSList *accts;
957 958
1069 1070
1070 static void gaim_blist_node_initialize_settings(GaimBlistNode *node); 1071 static void gaim_blist_node_initialize_settings(GaimBlistNode *node);
1071 1072
1072 GaimChat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components) 1073 GaimChat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components)
1073 { 1074 {
1074 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1075 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1075 GaimChat *chat; 1076 GaimChat *chat;
1076 1077
1077 g_return_val_if_fail(account != NULL, FALSE); 1078 g_return_val_if_fail(account != NULL, FALSE);
1078 g_return_val_if_fail(components != NULL, FALSE); 1079 g_return_val_if_fail(components != NULL, FALSE);
1079 1080
1092 return chat; 1093 return chat;
1093 } 1094 }
1094 1095
1095 GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias) 1096 GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias)
1096 { 1097 {
1097 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1098 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1098 GaimBuddy *buddy; 1099 GaimBuddy *buddy;
1099 1100
1100 g_return_val_if_fail(account != NULL, FALSE); 1101 g_return_val_if_fail(account != NULL, FALSE);
1101 g_return_val_if_fail(screenname != NULL, FALSE); 1102 g_return_val_if_fail(screenname != NULL, FALSE);
1102 1103
1167 } 1168 }
1168 1169
1169 void gaim_blist_add_chat(GaimChat *chat, GaimGroup *group, GaimBlistNode *node) 1170 void gaim_blist_add_chat(GaimChat *chat, GaimGroup *group, GaimBlistNode *node)
1170 { 1171 {
1171 GaimBlistNode *cnode = (GaimBlistNode*)chat; 1172 GaimBlistNode *cnode = (GaimBlistNode*)chat;
1172 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1173 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1173 1174
1174 g_return_if_fail(chat != NULL); 1175 g_return_if_fail(chat != NULL);
1175 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT((GaimBlistNode *)chat)); 1176 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT((GaimBlistNode *)chat));
1176 1177
1177 if (node == NULL) { 1178 if (node == NULL) {
1249 void gaim_blist_add_buddy(GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node) 1250 void gaim_blist_add_buddy(GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node)
1250 { 1251 {
1251 GaimBlistNode *cnode, *bnode; 1252 GaimBlistNode *cnode, *bnode;
1252 GaimGroup *g; 1253 GaimGroup *g;
1253 GaimContact *c; 1254 GaimContact *c;
1254 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1255 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1255 struct _gaim_hbuddy *hb; 1256 struct _gaim_hbuddy *hb;
1256 1257
1257 g_return_if_fail(buddy != NULL); 1258 g_return_if_fail(buddy != NULL);
1258 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY((GaimBlistNode*)buddy)); 1259 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY((GaimBlistNode*)buddy));
1259 1260
1398 return contact; 1399 return contact;
1399 } 1400 }
1400 1401
1401 void gaim_contact_set_alias(GaimContact *contact, const char *alias) 1402 void gaim_contact_set_alias(GaimContact *contact, const char *alias)
1402 { 1403 {
1403 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1404 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1404 char *old_alias = contact->alias; 1405 char *old_alias = contact->alias;
1405 1406
1406 g_return_if_fail(contact != NULL); 1407 g_return_if_fail(contact != NULL);
1407 1408
1408 if ((alias != NULL) && (*alias != '\0')) 1409 if ((alias != NULL) && (*alias != '\0'))
1484 return group; 1485 return group;
1485 } 1486 }
1486 1487
1487 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node) 1488 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node)
1488 { 1489 {
1489 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1490 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1490 GaimGroup *g; 1491 GaimGroup *g;
1491 GaimBlistNode *gnode, *cnode, *bnode; 1492 GaimBlistNode *gnode, *cnode, *bnode;
1492 1493
1493 g_return_if_fail(contact != NULL); 1494 g_return_if_fail(contact != NULL);
1494 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); 1495 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact));
1650 GaimBlistNode *gnode = (GaimBlistNode*)group; 1651 GaimBlistNode *gnode = (GaimBlistNode*)group;
1651 1652
1652 g_return_if_fail(group != NULL); 1653 g_return_if_fail(group != NULL);
1653 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP((GaimBlistNode *)group)); 1654 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP((GaimBlistNode *)group));
1654 1655
1655 ops = gaimbuddylist->ui_ops; 1656 ops = gaim_blist_get_ui_ops();
1656 1657
1657 if (!gaimbuddylist->root) { 1658 if (!gaimbuddylist->root) {
1658 gaimbuddylist->root = gnode; 1659 gaimbuddylist->root = gnode;
1659 return; 1660 return;
1660 } 1661 }
1700 } 1701 }
1701 } 1702 }
1702 1703
1703 void gaim_blist_remove_contact(GaimContact *contact) 1704 void gaim_blist_remove_contact(GaimContact *contact)
1704 { 1705 {
1705 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1706 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1706 GaimBlistNode *node, *gnode; 1707 GaimBlistNode *node, *gnode;
1707 1708
1708 g_return_if_fail(contact != NULL); 1709 g_return_if_fail(contact != NULL);
1709 1710
1710 node = (GaimBlistNode *)contact; 1711 node = (GaimBlistNode *)contact;
1747 } 1748 }
1748 } 1749 }
1749 1750
1750 void gaim_blist_remove_buddy(GaimBuddy *buddy) 1751 void gaim_blist_remove_buddy(GaimBuddy *buddy)
1751 { 1752 {
1752 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1753 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1753 GaimBlistNode *node, *cnode, *gnode; 1754 GaimBlistNode *node, *cnode, *gnode;
1754 GaimContact *contact; 1755 GaimContact *contact;
1755 GaimGroup *group; 1756 GaimGroup *group;
1756 struct _gaim_hbuddy hb; 1757 struct _gaim_hbuddy hb;
1757 1758
1835 gaim_blist_remove_contact(contact); 1836 gaim_blist_remove_contact(contact);
1836 } 1837 }
1837 1838
1838 void gaim_blist_remove_chat(GaimChat *chat) 1839 void gaim_blist_remove_chat(GaimChat *chat)
1839 { 1840 {
1840 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1841 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1841 GaimBlistNode *node, *gnode; 1842 GaimBlistNode *node, *gnode;
1842 GaimGroup *group; 1843 GaimGroup *group;
1843 1844
1844 g_return_if_fail(chat != NULL); 1845 g_return_if_fail(chat != NULL);
1845 1846
1879 g_free(chat); 1880 g_free(chat);
1880 } 1881 }
1881 1882
1882 void gaim_blist_remove_group(GaimGroup *group) 1883 void gaim_blist_remove_group(GaimGroup *group)
1883 { 1884 {
1884 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 1885 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
1885 GaimBlistNode *node; 1886 GaimBlistNode *node;
1886 GList *l; 1887 GList *l;
1887 1888
1888 g_return_if_fail(group != NULL); 1889 g_return_if_fail(group != NULL);
1889 1890
2242 return l; 2243 return l;
2243 } 2244 }
2244 2245
2245 void gaim_blist_add_account(GaimAccount *account) 2246 void gaim_blist_add_account(GaimAccount *account)
2246 { 2247 {
2247 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 2248 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
2248 GaimBlistNode *gnode, *cnode, *bnode; 2249 GaimBlistNode *gnode, *cnode, *bnode;
2249 2250
2250 g_return_if_fail(gaimbuddylist != NULL); 2251 g_return_if_fail(gaimbuddylist != NULL);
2251 2252
2252 if (!ops || !ops->update) 2253 if (!ops || !ops->update)
2284 } 2285 }
2285 } 2286 }
2286 2287
2287 void gaim_blist_remove_account(GaimAccount *account) 2288 void gaim_blist_remove_account(GaimAccount *account)
2288 { 2289 {
2289 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 2290 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
2290 GaimBlistNode *gnode, *cnode, *bnode; 2291 GaimBlistNode *gnode, *cnode, *bnode;
2291 GaimBuddy *buddy; 2292 GaimBuddy *buddy;
2292 GaimChat *chat; 2293 GaimChat *chat;
2293 GaimContact *contact; 2294 GaimContact *contact;
2294 GaimGroup *group; 2295 GaimGroup *group;