# HG changeset patch # User Mikael Berthe # Date 1269191554 -3600 # Node ID eef8c9fff72783b13ab940598706cba328c03f1e # Parent 7a1c405492914518460bf118c8453e2cb0b48d81 Hopefully fix issue with hook-unread-list-change diff -r 7a1c40549291 -r eef8c9fff727 mcabber/mcabber/roster.c --- a/mcabber/mcabber/roster.c Sun Mar 21 15:46:50 2010 +0100 +++ b/mcabber/mcabber/roster.c Sun Mar 21 18:12:34 2010 +0100 @@ -590,6 +590,55 @@ roster_usr->flags &= ~flags; } +// roster_unread_count() +guint roster_unread_count(void) +{ + guint unread_count = 0; +#ifdef MODULES_ENABLE + gpointer unread_ptr, first_unread; + guint muc_unread = 0, muc_attention = 0; + guint attention_count = 0; + + unread_ptr = first_unread = unread_msg(NULL); + if (first_unread) { + do { + guint type = buddy_gettype(unread_ptr); + unread_count++; + + if (type & ROSTER_TYPE_ROOM) { + muc_unread++; + if (buddy_getuiprio(unread_ptr) >= ROSTER_UI_PRIO_MUC_HL_MESSAGE) + muc_attention++; + } else { + if (buddy_getuiprio(unread_ptr) >= ROSTER_UI_PRIO_ATTENTION_MESSAGE) + attention_count++; + } + unread_ptr = unread_msg(unread_ptr); + } while (unread_ptr && unread_ptr != first_unread); + } + + { + gchar *str_unread = g_strdup_printf("%u", unread_count); + gchar *str_attention = g_strdup_printf("%u", attention_count); + gchar *str_muc_unread = g_strdup_printf("%u", muc_unread); + gchar *str_muc_attention = g_strdup_printf("%u", muc_attention); + hk_arg_t args[] = { + { "unread", str_unread }, // All unread + { "attention", str_attention }, // Attention (private) + { "muc_unread", str_muc_unread }, // MUC unread + { "muc_attention", str_muc_attention }, // MUC attention (highlight) + { NULL, NULL }, + }; + hk_run_handlers(HOOK_UNREAD_LIST_CHANGE, args); + g_free(str_unread); + g_free(str_attention); + g_free(str_muc_unread); + g_free(str_muc_attention); + } +#endif + return unread_count; +} + // roster_msg_setflag() // Set the ROSTER_FLAG_MSG to the given value for the given jid. // It will update the buddy's group message flag. @@ -691,49 +740,7 @@ hlog_save_state(); #ifdef MODULES_ENABLE - { - gpointer unread_ptr, first_unread; - guint muc_unread = 0, muc_attention = 0; - guint attention_count = 0; - unread_count = 0; - - unread_ptr = first_unread = unread_msg(NULL); - if (first_unread) { - do { - guint type = buddy_gettype(unread_ptr); - unread_count++; - - if (type & ROSTER_TYPE_ROOM) { - muc_unread++; - if (buddy_getuiprio(unread_ptr) >= ROSTER_UI_PRIO_MUC_HL_MESSAGE) - muc_attention++; - } else { - if (buddy_getuiprio(unread_ptr) >= ROSTER_UI_PRIO_ATTENTION_MESSAGE) - attention_count++; - } - unread_ptr = unread_msg(unread_ptr); - } while (unread_ptr && unread_ptr != first_unread); - } - - { - gchar *str_unread = g_strdup_printf("%u", unread_count); - gchar *str_attention = g_strdup_printf("%u", attention_count); - gchar *str_muc_unread = g_strdup_printf("%u", muc_unread); - gchar *str_muc_attention = g_strdup_printf("%u", muc_attention); - hk_arg_t args[] = { - { "unread", str_unread }, // All unread - { "attention", str_attention }, // Attention (private) - { "muc_unread", str_muc_unread }, // MUC unread - { "muc_attention", str_muc_attention }, // MUC attention (highlight) - { NULL, NULL }, - }; - hk_run_handlers(HOOK_UNREAD_LIST_CHANGE, args); - g_free(str_unread); - g_free(str_attention); - g_free(str_muc_unread); - g_free(str_muc_attention); - } - } + unread_count = roster_unread_count(); #else unread_count = g_slist_length(unread_list); #endif @@ -774,6 +781,7 @@ roster_usr->ui_prio = newval; unread_list = g_slist_sort(unread_list, (GCompareFunc)&_roster_compare_uiprio); + roster_unread_count(); } guint roster_getuiprio(const char *jid, guint special)