diff options
author | James Booth <boothj5@gmail.com> | 2015-05-10 01:44:34 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-05-10 01:44:34 +0100 |
commit | aeffca496c338e91cacb4af1ebf0d8ca3160bf31 (patch) | |
tree | c21d2c0a2245c85463a54e9f44e4b0d924e89c86 /src | |
parent | aaad3ff90903e05f075076dc87b4ec9e66b4a773 (diff) | |
download | profani-tty-aeffca496c338e91cacb4af1ebf0d8ca3160bf31.tar.gz |
Tidy ui_room_message
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/core.c | 122 |
1 files changed, 62 insertions, 60 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index 36b73f33..2c797271 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1748,77 +1748,79 @@ ui_room_message(const char * const roomjid, const char * const nick, ProfMucWin *mucwin = wins_get_muc(roomjid); if (mucwin == NULL) { log_error("Room message received from %s, but no window open for %s", nick, roomjid); - } else { - ProfWin *window = (ProfWin*) mucwin; - int num = wins_get_num(window); - char *my_nick = muc_nick(roomjid); + return; + } - if (g_strcmp0(nick, my_nick) != 0) { - if (g_strrstr(message, my_nick)) { - win_print(window, '-', NULL, NO_ME, THEME_ROOMMENTION, nick, message); - } else { - win_print(window, '-', NULL, NO_ME, THEME_TEXT_THEM, nick, message); - } + ProfWin *window = (ProfWin*) mucwin; + int num = wins_get_num(window); + char *my_nick = muc_nick(roomjid); + + if (g_strcmp0(nick, my_nick) != 0) { + if (g_strrstr(message, my_nick)) { + win_print(window, '-', NULL, NO_ME, THEME_ROOMMENTION, nick, message); } else { - win_print(window, '-', NULL, 0, THEME_TEXT_ME, nick, message); + win_print(window, '-', NULL, NO_ME, THEME_TEXT_THEM, nick, message); } + } else { + win_print(window, '-', NULL, 0, THEME_TEXT_ME, 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); + // currently in groupchat window + if (wins_is_current(window)) { + status_bar_active(num); - if (strcmp(nick, my_nick) != 0) { - if (prefs_get_boolean(PREF_FLASH)) { - flash(); - } - } + // not currently on groupchat window + } else { + status_bar_new(num); + cons_show_incoming_message(nick, num); - mucwin->unread++; + if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, my_nick) != 0)) { + flash(); } - int ui_index = num; - if (ui_index == 10) { - ui_index = 0; - } + mucwin->unread++; + } - if (strcmp(nick, muc_nick(roomjid)) != 0) { - if (prefs_get_boolean(PREF_BEEP)) { - beep(); - } + int ui_index = num; + if (ui_index == 10) { + ui_index = 0; + } - gboolean notify = FALSE; - char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM); - if (g_strcmp0(room_setting, "on") == 0) { - notify = TRUE; - } - 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); - } - 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(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); - } + // don't notify self messages + if (strcmp(nick, my_nick) == 0) { + return; + } + + if (prefs_get_boolean(PREF_BEEP)) { + beep(); + } + + gboolean notify = FALSE; + char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM); + if (g_strcmp0(room_setting, "on") == 0) { + notify = TRUE; + } + 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); + } + 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(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); } } } |