Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/roster.c @ 1806:9daf6b3f30d6
Add hook-unread-list-change
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 21 Mar 2010 15:22:48 +0100 |
parents | 7d3060070d10 |
children | eef8c9fff727 |
comparison
equal
deleted
inserted
replaced
1805:48e47198a9db | 1806:9daf6b3f30d6 |
---|---|
685 if (buddylist && (new_roster_item || !g_list_find(buddylist, roster_usr))) | 685 if (buddylist && (new_roster_item || !g_list_find(buddylist, roster_usr))) |
686 buddylist_build(); | 686 buddylist_build(); |
687 | 687 |
688 roster_msg_setflag_return: | 688 roster_msg_setflag_return: |
689 if (unread_list_modified) { | 689 if (unread_list_modified) { |
690 guint unread_count = g_slist_length(unread_list); | 690 guint unread_count; |
691 hlog_save_state(); | 691 hlog_save_state(); |
692 | |
693 #ifdef MODULES_ENABLE | |
694 { | |
695 gpointer unread_ptr, first_unread; | |
696 guint muc_unread = 0, muc_attention = 0; | |
697 guint attention_count = 0; | |
698 unread_count = 0; | |
699 | |
700 unread_ptr = first_unread = unread_msg(NULL); | |
701 if (first_unread) { | |
702 do { | |
703 guint type = buddy_gettype(unread_ptr); | |
704 unread_count++; | |
705 | |
706 if (type & ROSTER_TYPE_ROOM) { | |
707 muc_unread++; | |
708 if (buddy_getuiprio(unread_ptr) >= ROSTER_UI_PRIO_MUC_HL_MESSAGE) | |
709 muc_attention++; | |
710 } else { | |
711 if (buddy_getuiprio(unread_ptr) >= ROSTER_UI_PRIO_ATTENTION_MESSAGE) | |
712 attention_count++; | |
713 } | |
714 unread_ptr = unread_msg(unread_ptr); | |
715 } while (unread_ptr && unread_ptr != first_unread); | |
716 } | |
717 | |
718 { | |
719 gchar *str_unread = g_strdup_printf("%u", unread_count); | |
720 gchar *str_attention = g_strdup_printf("%u", attention_count); | |
721 gchar *str_muc_unread = g_strdup_printf("%u", muc_unread); | |
722 gchar *str_muc_attention = g_strdup_printf("%u", muc_attention); | |
723 hk_arg_t args[] = { | |
724 { "unread", str_unread }, // All unread | |
725 { "attention", str_attention }, // Attention (private) | |
726 { "muc_unread", str_muc_unread }, // MUC unread | |
727 { "muc_attention", str_muc_attention }, // MUC attention (highlight) | |
728 { NULL, NULL }, | |
729 }; | |
730 hk_run_handlers(HOOK_UNREAD_LIST_CHANGE, args); | |
731 g_free(str_unread); | |
732 g_free(str_attention); | |
733 g_free(str_muc_unread); | |
734 g_free(str_muc_attention); | |
735 } | |
736 } | |
737 #else | |
738 unread_count = g_slist_length(unread_list); | |
739 #endif | |
740 | |
692 /* Call external command */ | 741 /* Call external command */ |
693 hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), NULL); | 742 hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), NULL); |
694 } | 743 } |
695 } | 744 } |
696 | 745 |