# HG changeset patch # User Mikael Berthe # Date 1269290842 -3600 # Node ID 5dbb3ebbc46638b3d2c1c91f498433aed1dbe3b0 # Parent e6d355e50d7a35c11bf13570f53edaaad2d13a5d Add hk_unread_list_change() (Suggested by isbear) diff -r e6d355e50d7a -r 5dbb3ebbc466 mcabber/mcabber/hooks.c --- a/mcabber/mcabber/hooks.c Mon Mar 22 21:32:11 2010 +0100 +++ b/mcabber/mcabber/hooks.c Mon Mar 22 21:47:22 2010 +0100 @@ -649,6 +649,30 @@ g_free(cmdline); } +void hk_unread_list_change(guint unread_count, guint attention_count, + guint muc_unread, guint muc_attention) +{ +#ifdef MODULES_ENABLE + 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 +} + + /* External commands */ // hk_ext_cmd_init() diff -r e6d355e50d7a -r 5dbb3ebbc466 mcabber/mcabber/hooks.h --- a/mcabber/mcabber/hooks.h Mon Mar 22 21:32:11 2010 +0100 +++ b/mcabber/mcabber/hooks.h Mon Mar 22 21:47:22 2010 +0100 @@ -59,6 +59,9 @@ void hk_postconnect(void); void hk_predisconnect(void); +void hk_unread_list_change(guint unread_count, guint attention_count, + guint muc_unread, guint muc_attention); + void hk_ext_cmd_init(const char *command); void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data); diff -r e6d355e50d7a -r 5dbb3ebbc466 mcabber/mcabber/roster.c --- a/mcabber/mcabber/roster.c Mon Mar 22 21:32:11 2010 +0100 +++ b/mcabber/mcabber/roster.c Mon Mar 22 21:47:22 2010 +0100 @@ -617,24 +617,8 @@ } 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); - } + hk_unread_list_change(unread_count, attention_count, + muc_unread, muc_attention); #endif return unread_count; }