--- a/mcabber/mcabber/hooks.c Sat Mar 27 18:09:29 2010 +0100
+++ b/mcabber/mcabber/hooks.c Sat Mar 27 18:42:37 2010 +0100
@@ -652,12 +652,12 @@
void hk_unread_list_change(guint unread_count, guint attention_count,
guint muc_unread, guint muc_attention)
{
-#ifdef MODULES_ENABLE
// Previous static variables are initialized with an unlikely value
static guint prev_unread = 65535;
static guint prev_attention = 65535;
static guint prev_muc_unread = 65535;
static guint prev_muc_attention = 65535;
+ gchar *str_unread;
// Do not call the handlers if the unread values haven't changed
if (unread_count == prev_unread &&
@@ -666,28 +666,37 @@
muc_attention == prev_muc_attention)
return;
- 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);
+#ifdef MODULES_ENABLE
+ {
+ 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
prev_unread = unread_count;
prev_attention = attention_count;
prev_muc_unread = muc_unread;
prev_muc_attention = muc_attention;
-#endif
+
+ /* Call external command */
+ str_unread = g_strdup_printf("%u %u %u %u", unread_count, attention_count,
+ muc_unread, muc_attention);
+ hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), str_unread);
+ g_free(str_unread);
}
@@ -712,12 +721,11 @@
void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data)
{
pid_t pid;
- char *arg_type = NULL;
- char *arg_info = NULL;
- char *arg_data = NULL;
+ const char *arg_type = NULL;
+ const char *arg_info = NULL;
+ const char *arg_data = NULL;
char status_str[2];
char *datafname = NULL;
- char unread_str[16];
if (!extcmd) return;
@@ -744,8 +752,7 @@
break;
case 'U': /* Unread buffer count */
arg_type = "UNREAD";
- g_snprintf(unread_str, sizeof unread_str, "%d", info);
- arg_info = unread_str; /* number of remaining unread bjids */
+ arg_info = data;
break;
default:
return;
--- a/mcabber/mcabber/roster.c Sat Mar 27 18:09:29 2010 +0100
+++ b/mcabber/mcabber/roster.c Sat Mar 27 18:42:37 2010 +0100
@@ -590,11 +590,10 @@
roster_usr->flags &= ~flags;
}
-// roster_unread_count()
-guint roster_unread_count(void)
+// roster_unread_check()
+static void roster_unread_check(void)
{
guint unread_count = 0;
-#ifdef MODULES_ENABLE
gpointer unread_ptr, first_unread;
guint muc_unread = 0, muc_attention = 0;
guint attention_count = 0;
@@ -619,8 +618,6 @@
hk_unread_list_change(unread_count, attention_count,
muc_unread, muc_attention);
-#endif
- return unread_count;
}
// roster_msg_setflag()
@@ -720,17 +717,8 @@
roster_msg_setflag_return:
if (unread_list_modified) {
- guint unread_count;
hlog_save_state();
-
-#ifdef MODULES_ENABLE
- unread_count = roster_unread_count();
-#else
- unread_count = g_slist_length(unread_list);
-#endif
-
- /* Call external command */
- hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), NULL);
+ roster_unread_check();
}
}
@@ -765,7 +753,7 @@
roster_usr->ui_prio = newval;
unread_list = g_slist_sort(unread_list,
(GCompareFunc)&_roster_compare_uiprio);
- roster_unread_count();
+ roster_unread_check();
}
guint roster_getuiprio(const char *jid, guint special)
--- a/mcabber/mcabberrc.example Sat Mar 27 18:09:29 2010 +0100
+++ b/mcabber/mcabberrc.example Sat Mar 27 18:42:37 2010 +0100
@@ -215,7 +215,8 @@
# $events_command MSG OUT jabber@id (when sending a message)
# $events_command MSG MUC room_id [file] (when receiving a MUC message)
# $events_command STATUS X jabber@id (new buddy status is X)
-# $events_command UNREAD N (number of unread buddy buffers)
+# $events_command UNREAD "N x y z" (number of unread buddy buffers)
+# (x=attention y=muc unread buffers z=muc unread buffers with attention sign)
# See sample script in contrib/ directory.
#set events_command = ~/.mcabber/eventcmd
#