about summary refs log tree commit diff stats
path: root/src/ui/mucwin.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-24 23:03:52 +0000
committerJames Booth <boothj5@gmail.com>2015-11-24 23:03:52 +0000
commit9c8b137a515e90f55606177c75847493fa02f556 (patch)
tree2bd84de203d85679dc908d57c2dfd758e19b174d /src/ui/mucwin.c
parent00a735ece58421a6d4d3f7a161684b033aea828a (diff)
downloadprofani-tty-9c8b137a515e90f55606177c75847493fa02f556.tar.gz
Tidy regular chat and room notifications
Diffstat (limited to 'src/ui/mucwin.c')
-rw-r--r--src/ui/mucwin.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 58fef4d1..aa825d16 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -390,11 +390,6 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
         mucwin->unread++;
     }
 
-    int ui_index = num;
-    if (ui_index == 10) {
-        ui_index = 0;
-    }
-
     // don't notify self messages
     if (strcmp(nick, my_nick) == 0) {
         return;
@@ -404,34 +399,24 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
         beep();
     }
 
-    gboolean notify = FALSE;
-    char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
-    if (g_strcmp0(room_setting, "on") == 0) {
-        notify = TRUE;
+    gboolean is_current = wins_is_current(window);
+    gboolean notify = prefs_get_notify_room(is_current, my_nick, message);
+    if (!notify) {
+        return;
     }
-    if (g_strcmp0(room_setting, "mention") == 0) {
-        char *message_lower = g_utf8_strdown(message, -1);
-        char *nick_lower = g_utf8_strdown(nick, -1);
-        if (g_strrstr(message_lower, nick_lower)) {
-            notify = TRUE;
-        }
-        g_free(message_lower);
-        g_free(nick_lower);
+
+    Jid *jidp = jid_create(mucwin->roomjid);
+    int ui_index = num;
+    if (ui_index == 10) {
+        ui_index = 0;
     }
-    prefs_free_string(room_setting);
 
-    if (notify) {
-        gboolean is_current = wins_is_current(window);
-        if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT)) ) {
-            Jid *jidp = jid_create(mucwin->roomjid);
-            if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
-                notify_room_message(nick, jidp->localpart, ui_index, message);
-            } else {
-                notify_room_message(nick, jidp->localpart, ui_index, NULL);
-            }
-            jid_destroy(jidp);
-        }
+    if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
+        notify_room_message(nick, jidp->localpart, ui_index, message);
+    } else {
+        notify_room_message(nick, jidp->localpart, ui_index, NULL);
     }
+    jid_destroy(jidp);
 }
 
 void