about summary refs log tree commit diff stats
path: root/src/ui/console.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/console.c')
-rw-r--r--src/ui/console.c55
1 files changed, 48 insertions, 7 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 6fd6fc38..2be41b14 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -301,8 +301,27 @@ cons_show_typing(const char *const barejid)
     cons_alert();
 }
 
+char*
+_room_triggers_to_string(GList *triggers)
+{
+    GString *triggers_str = g_string_new("");
+    GList *curr = triggers;
+    while (curr) {
+        g_string_append_printf(triggers_str, "\"%s\"", (char*)curr->data);
+        curr = g_list_next(curr);
+        if (curr) {
+            g_string_append(triggers_str, ", ");
+        }
+    }
+
+    char *result = triggers_str->str;
+    g_string_free(triggers_str, FALSE);
+    return result;
+}
+
 void
-cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index)
+cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention,
+    GList *triggers, int unread)
 {
     ProfWin *const console = wins_get_console();
 
@@ -311,13 +330,35 @@ cons_show_incoming_room_message(const char *const nick, const char *const room,
         ui_index = 0;
     }
 
-    if (nick) {
-        win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index);
-    } else {
-        win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index);
-    }
+    char *muc_show = prefs_get_string(PREF_CONSOLE_MUC);
 
-    cons_alert();
+    if (g_strcmp0(muc_show, "all") == 0) {
+        if (mention) {
+            win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index);
+        } else if (triggers) {
+            char *triggers_str = _room_triggers_to_string(triggers);
+            win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index);
+            free(triggers_str);
+        } else {
+            win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index);
+        }
+        cons_alert();
+
+    } else if (g_strcmp0(muc_show, "first") == 0) {
+        if (mention) {
+            win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index);
+            cons_alert();
+        } else if (triggers) {
+            char *triggers_str = _room_triggers_to_string(triggers);
+            win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index);
+            free(triggers_str);
+            cons_alert();
+        } else if (unread == 0) {
+            win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index);
+            cons_alert();
+        }
+    }
+    prefs_free_string(muc_show);
 }
 
 void