about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-12-20 00:54:17 +0000
committerJames Booth <boothj5@gmail.com>2015-12-20 00:54:17 +0000
commit1f56c12377f15ac4892f7f72eb31be6bf084061e (patch)
tree477bf8dae58e1560f447a25895b4ce4d94ec5988 /src
parent8f6b37f650aaf9c2f59cae401ee3ce9a063072cd (diff)
downloadprofani-tty-1f56c12377f15ac4892f7f72eb31be6bf084061e.tar.gz
Added cons_show_incoming_room_message()
Diffstat (limited to 'src')
-rw-r--r--src/event/server_events.c63
-rw-r--r--src/ui/console.c15
-rw-r--r--src/ui/mucwin.c49
-rw-r--r--src/ui/ui.h1
4 files changed, 74 insertions, 54 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index a519a28b..12c34d76 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -212,16 +212,69 @@ void
 sv_ev_room_message(const char *const room_jid, const char *const nick,
     const char *const message)
 {
-    ProfMucWin *mucwin = wins_get_muc(room_jid);
-    if (mucwin) {
-        mucwin_message(mucwin, nick, message);
-    }
-
     if (prefs_get_boolean(PREF_GRLOG)) {
         Jid *jid = jid_create(jabber_get_fulljid());
         groupchat_log_chat(jid->barejid, room_jid, nick, message);
         jid_destroy(jid);
     }
+
+    ProfMucWin *mucwin = wins_get_muc(room_jid);
+    if (!mucwin) {
+        return;
+    }
+
+    mucwin_message(mucwin, nick, message);
+
+    ProfWin *window = (ProfWin*)mucwin;
+    gboolean is_current = wins_is_current(window);
+    int num = wins_get_num(window);
+    char *my_nick = muc_nick(mucwin->roomjid);
+    gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, my_nick, message);
+
+    // currently in groupchat window
+    if (wins_is_current(window)) {
+        status_bar_active(num);
+
+    // not currently on groupchat window
+    } else {
+        status_bar_new(num);
+        cons_show_incoming_room_message(nick, mucwin->roomjid, num);
+
+        if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, my_nick) != 0)) {
+            flash();
+        }
+
+        mucwin->unread++;
+        if (notify) {
+            mucwin->notify = TRUE;
+        }
+    }
+
+    // don't notify self messages
+    if (strcmp(nick, my_nick) == 0) {
+        return;
+    }
+
+    if (prefs_get_boolean(PREF_BEEP)) {
+        beep();
+    }
+
+    if (!notify) {
+        return;
+    }
+
+    Jid *jidp = jid_create(mucwin->roomjid);
+    int ui_index = num;
+    if (ui_index == 10) {
+        ui_index = 0;
+    }
+
+    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
diff --git a/src/ui/console.c b/src/ui/console.c
index b4083ea3..4e7077c4 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -302,6 +302,21 @@ cons_show_typing(const char *const barejid)
 }
 
 void
+cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index)
+{
+    ProfWin *const console = wins_get_console();
+
+    int ui_index = win_index;
+    if (ui_index == 10) {
+        ui_index = 0;
+    }
+
+    win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< incoming from %s in %s (win %d)", nick, room, ui_index);
+
+    cons_alert();
+}
+
+void
 cons_show_incoming_message(const char *const short_from, const int win_index)
 {
     ProfWin *console = wins_get_console();
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 432256de..4674b198 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -361,7 +361,6 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
     assert(mucwin != NULL);
 
     ProfWin *window = (ProfWin*)mucwin;
-    int num = wins_get_num(window);
     char *my_nick = muc_nick(mucwin->roomjid);
 
     if (g_strcmp0(nick, my_nick) != 0) {
@@ -373,54 +372,6 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
     } else {
         win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message);
     }
-
-    gboolean is_current = wins_is_current(window);
-    gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, my_nick, message);
-
-    // currently in groupchat window
-    if (wins_is_current(window)) {
-        status_bar_active(num);
-
-    // not currently on groupchat window
-    } else {
-        status_bar_new(num);
-        cons_show_incoming_message(nick, num);
-
-        if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, my_nick) != 0)) {
-            flash();
-        }
-
-        mucwin->unread++;
-        if (notify) {
-            mucwin->notify = TRUE;
-        }
-    }
-
-    // don't notify self messages
-    if (strcmp(nick, my_nick) == 0) {
-        return;
-    }
-
-    if (prefs_get_boolean(PREF_BEEP)) {
-        beep();
-    }
-
-    if (!notify) {
-        return;
-    }
-
-    Jid *jidp = jid_create(mucwin->roomjid);
-    int ui_index = num;
-    if (ui_index == 10) {
-        ui_index = 0;
-    }
-
-    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
diff --git a/src/ui/ui.h b/src/ui/ui.h
index e21f2ea8..7bb15545 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -257,6 +257,7 @@ void cons_show_disco_info(const char *from, GSList *identities, GSList *features
 void cons_show_room_invite(const char *const invitor, const char *const room, const char *const reason);
 void cons_check_version(gboolean not_available_msg);
 void cons_show_typing(const char *const barejid);
+void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index);
 void cons_show_incoming_message(const char *const short_from, const int win_index);
 void cons_show_room_invites(GSList *invites);
 void cons_show_received_subs(void);