src/blist.c

changeset 7035
76bca80cd91d
parent 7003
f386c83fdf52
child 7060
717cbeb22b6d
equal deleted inserted replaced
7034:b1d44fe5f072 7035:76bca80cd91d
149 149
150 struct gaim_buddy_list *gaim_blist_new() 150 struct gaim_buddy_list *gaim_blist_new()
151 { 151 {
152 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1); 152 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1);
153 153
154 gbl->ui_ops = gaim_get_blist_ui_ops(); 154 gbl->ui_ops = gaim_blist_get_ui_ops();
155 155
156 gbl->buddies = g_hash_table_new_full((GHashFunc)_gaim_blist_hbuddy_hash, 156 gbl->buddies = g_hash_table_new_full((GHashFunc)_gaim_blist_hbuddy_hash,
157 (GEqualFunc)_gaim_blist_hbuddy_equal, 157 (GEqualFunc)_gaim_blist_hbuddy_equal,
158 (GDestroyNotify)_gaim_blist_hbuddy_free_key, NULL); 158 (GDestroyNotify)_gaim_blist_hbuddy_free_key, NULL);
159 159
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,
449 g_free, g_free); 449 g_free, g_free);
450 450
451 ((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE; 451 ((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE;
452 452
453 ops = gaim_get_blist_ui_ops(); 453 ops = gaim_blist_get_ui_ops();
454 454
455 if (ops != NULL && ops->new_node != NULL) 455 if (ops != NULL && ops->new_node != NULL)
456 ops->new_node((GaimBlistNode *)chat); 456 ops->new_node((GaimBlistNode *)chat);
457 457
458 return chat; 458 return chat;
495 b->name = g_strdup(screenname); 495 b->name = g_strdup(screenname);
496 b->alias = g_strdup(alias); 496 b->alias = g_strdup(alias);
497 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 497 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
498 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE; 498 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE;
499 499
500 ops = gaim_get_blist_ui_ops(); 500 ops = gaim_blist_get_ui_ops();
501 501
502 if (ops != NULL && ops->new_node != NULL) 502 if (ops != NULL && ops->new_node != NULL)
503 ops->new_node((GaimBlistNode *)b); 503 ops->new_node((GaimBlistNode *)b);
504 504
505 return b; 505 return b;
744 GaimContact *c = g_new0(GaimContact, 1); 744 GaimContact *c = g_new0(GaimContact, 1);
745 ((GaimBlistNode*)c)->type = GAIM_BLIST_CONTACT_NODE; 745 ((GaimBlistNode*)c)->type = GAIM_BLIST_CONTACT_NODE;
746 746
747 c->totalsize = c->currentsize = c->online = 0; 747 c->totalsize = c->currentsize = c->online = 0;
748 748
749 ops = gaim_get_blist_ui_ops(); 749 ops = gaim_blist_get_ui_ops();
750 if (ops != NULL && ops->new_node != NULL) 750 if (ops != NULL && ops->new_node != NULL)
751 ops->new_node((GaimBlistNode *)c); 751 ops->new_node((GaimBlistNode *)c);
752 752
753 return c; 753 return c;
754 } 754 }
781 g->online = 0; 781 g->online = 0;
782 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal, 782 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
783 g_free, g_free); 783 g_free, g_free);
784 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE; 784 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE;
785 785
786 ops = gaim_get_blist_ui_ops(); 786 ops = gaim_blist_get_ui_ops();
787 787
788 if (ops != NULL && ops->new_node != NULL) 788 if (ops != NULL && ops->new_node != NULL)
789 ops->new_node((GaimBlistNode *)g); 789 ops->new_node((GaimBlistNode *)g);
790 790
791 } 791 }
2546 if(!b) 2546 if(!b)
2547 return NULL; 2547 return NULL;
2548 return g_strdup(g_hash_table_lookup(b->settings, key)); 2548 return g_strdup(g_hash_table_lookup(b->settings, key));
2549 } 2549 }
2550 2550
2551 void gaim_set_blist_ui_ops(struct gaim_blist_ui_ops *ops)
2552 {
2553 blist_ui_ops = ops;
2554 }
2555
2556 struct gaim_blist_ui_ops *
2557 gaim_get_blist_ui_ops(void)
2558 {
2559 return blist_ui_ops;
2560 }
2561
2562 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) { 2551 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) {
2563 if(!group) 2552 if(!group)
2564 return 0; 2553 return 0;
2565 2554
2566 return offline ? group->totalsize : group->currentsize; 2555 return offline ? group->totalsize : group->currentsize;
2570 if(!group) 2559 if(!group)
2571 return 0; 2560 return 0;
2572 2561
2573 return group->online; 2562 return group->online;
2574 } 2563 }
2564
2565 void
2566 gaim_blist_set_ui_ops(struct gaim_blist_ui_ops *ops)
2567 {
2568 blist_ui_ops = ops;
2569 }
2570
2571 struct gaim_blist_ui_ops *
2572 gaim_blist_get_ui_ops(void)
2573 {
2574 return blist_ui_ops;
2575 }
2576
2575 2577
2576 void * 2578 void *
2577 gaim_blist_get_handle(void) 2579 gaim_blist_get_handle(void)
2578 { 2580 {
2579 static int handle; 2581 static int handle;

mercurial