diff options
Diffstat (limited to 'src/ui/console.c')
-rw-r--r-- | src/ui/console.c | 137 |
1 files changed, 88 insertions, 49 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index 4f7e222d..2f81af04 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -63,6 +63,7 @@ static void _cons_splash_logo(void); static void _show_roster_contacts(GSList* list, gboolean show_groups); +static GList* alert_list; void cons_debug(const char* const msg, ...) @@ -172,7 +173,7 @@ cons_show_error(const char* const msg, ...) g_string_free(fmt_msg, TRUE); va_end(arg); - cons_alert(); + cons_alert(NULL); } void @@ -284,7 +285,7 @@ cons_show_typing(const char* const barejid) } win_println(console, THEME_TYPING, "-", "!! %s is typing a message...", display_usr); - cons_alert(); + cons_alert(NULL); } char* @@ -307,7 +308,7 @@ _room_triggers_to_string(GList* triggers) void cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, gboolean mention, - GList* triggers, int unread) + GList* triggers, int unread, ProfWin* const window) { ProfWin* const console = wins_get_console(); @@ -328,27 +329,27 @@ cons_show_incoming_room_message(const char* const nick, const char* const room, } else { win_println(console, THEME_INCOMING, "-", "<< room message: %s in %s (win %d)", nick, room, ui_index); } - cons_alert(); + cons_alert(window); } else if (g_strcmp0(muc_show, "first") == 0) { if (mention) { win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); - cons_alert(); + cons_alert(window); } else if (triggers) { char* triggers_str = _room_triggers_to_string(triggers); win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); - cons_alert(); + cons_alert(window); } else if (unread == 0) { win_println(console, THEME_INCOMING, "-", "<< room message: %s (win %d)", room, ui_index); - cons_alert(); + cons_alert(window); } } g_free(muc_show); } void -cons_show_incoming_message(const char* const short_from, const int win_index, int unread) +cons_show_incoming_message(const char* const short_from, const int win_index, int unread, ProfWin* const window) { ProfWin* console = wins_get_console(); @@ -360,17 +361,17 @@ cons_show_incoming_message(const char* const short_from, const int win_index, in char* chat_show = prefs_get_string(PREF_CONSOLE_CHAT); if (g_strcmp0(chat_show, "all") == 0) { win_println(console, THEME_INCOMING, "-", "<< chat message: %s (win %d)", short_from, ui_index); - cons_alert(); + cons_alert(window); } else if ((g_strcmp0(chat_show, "first") == 0) && unread == 0) { win_println(console, THEME_INCOMING, "-", "<< chat message: %s (win %d)", short_from, ui_index); - cons_alert(); + cons_alert(window); } g_free(chat_show); } void -cons_show_incoming_private_message(const char* const nick, const char* const room, const int win_index, int unread) +cons_show_incoming_private_message(const char* const nick, const char* const room, const int win_index, int unread, ProfWin* const window) { ProfWin* console = wins_get_console(); @@ -382,10 +383,10 @@ cons_show_incoming_private_message(const char* const nick, const char* const roo char* priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); if (g_strcmp0(priv_show, "all") == 0) { win_println(console, THEME_INCOMING, "-", "<< private message: %s in %s (win %d)", nick, room, ui_index); - cons_alert(); + cons_alert(window); } else if ((g_strcmp0(priv_show, "first") == 0) && unread == 0) { win_println(console, THEME_INCOMING, "-", "<< private message: %s in %s (win %d)", nick, room, ui_index); - cons_alert(); + cons_alert(window); } g_free(priv_show); @@ -429,7 +430,7 @@ cons_about(void) pnoutrefresh(console->layout->win, 0, 0, 1, 0, rows - 3, cols - 1); - cons_alert(); + cons_alert(NULL); } void @@ -453,7 +454,7 @@ cons_check_version(gboolean not_available_msg) } } - cons_alert(); + cons_alert(NULL); } free(latest_release); } @@ -477,7 +478,7 @@ cons_show_login_success(ProfAccount* account, gboolean secured) if (!secured) { cons_show_error("TLS connection not established"); } - cons_alert(); + cons_alert(NULL); } void @@ -507,7 +508,7 @@ cons_show_wins(gboolean unread) } g_slist_free_full(window_strings, free); - cons_alert(); + cons_alert(NULL); } void @@ -524,7 +525,7 @@ cons_show_room_invites(GList* invites) } } - cons_alert(); + cons_alert(NULL); } void @@ -533,7 +534,7 @@ cons_show_info(PContact pcontact) ProfWin* console = wins_get_console(); win_show_info(console, pcontact); - cons_alert(); + cons_alert(NULL); } void @@ -608,7 +609,7 @@ cons_show_caps(const char* const fulljid, resource_presence_t presence) cons_show("No capabilities found for %s", fulljid); } - cons_alert(); + cons_alert(NULL); } void @@ -627,7 +628,7 @@ cons_show_received_subs(void) g_list_free_full(received, g_free); } - cons_alert(); + cons_alert(NULL); } void @@ -649,7 +650,7 @@ cons_show_sent_subs(void) } else { cons_show("No pending requests sent."); } - cons_alert(); + cons_alert(NULL); } void @@ -671,7 +672,7 @@ cons_show_room_list(GSList* rooms, const char* const conference_node) cons_show("No chat rooms at %s", conference_node); } - cons_alert(); + cons_alert(NULL); } void @@ -725,7 +726,7 @@ cons_show_bookmarks(const GList* list) cons_show("Automatic invite bookmarking (/bookmark invites): OFF"); } - cons_alert(); + cons_alert(NULL); } void @@ -765,7 +766,7 @@ cons_show_disco_info(const char* jid, GSList* identities, GSList* features) features = g_slist_next(features); } - cons_alert(); + cons_alert(NULL); } } @@ -790,7 +791,7 @@ cons_show_disco_items(GSList* items, const char* const jid) cons_show("No service discovery items for %s", jid); } - cons_alert(); + cons_alert(NULL); } void @@ -805,7 +806,7 @@ cons_show_status(const char* const barejid) cons_show("No such contact \"%s\" in roster.", barejid); } - cons_alert(); + cons_alert(NULL); } void @@ -841,7 +842,7 @@ cons_show_room_invite(const char* const invitor, const char* const room, const c free(display_from); - cons_alert(); + cons_alert(NULL); } void @@ -867,7 +868,7 @@ cons_show_account_list(gchar** accounts) cons_show(""); } - cons_alert(); + cons_alert(NULL); } void @@ -1058,7 +1059,7 @@ cons_show_account(ProfAccount* account) g_list_free(ordered_resources); } - cons_alert(); + cons_alert(NULL); } void @@ -1592,7 +1593,7 @@ cons_show_ui_prefs(void) cons_titlebar_setting(); cons_statusbar_setting(); - cons_alert(); + cons_alert(NULL); } void @@ -1691,7 +1692,7 @@ cons_show_desktop_prefs(void) cons_notify_setting(); cons_tray_setting(); - cons_alert(); + cons_alert(NULL); } void @@ -1779,7 +1780,7 @@ cons_show_chat_prefs(void) cons_carbons_setting(); cons_receipts_setting(); - cons_alert(); + cons_alert(NULL); } void @@ -1889,7 +1890,7 @@ cons_show_log_prefs(void) cons_log_setting(); cons_logging_setting(); - cons_alert(); + cons_alert(NULL); } void @@ -1955,7 +1956,7 @@ cons_show_presence_prefs(void) cons_show("Send last activity (/lastactivity) : OFF"); } - cons_alert(); + cons_alert(NULL); } void @@ -2096,7 +2097,7 @@ cons_show_connection_prefs(void) cons_autoconnect_setting(); cons_rooms_cache_setting(); - cons_alert(); + cons_alert(NULL); } void @@ -2129,7 +2130,7 @@ cons_show_otr_prefs(void) cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): OFF"); } - cons_alert(); + cons_alert(NULL); } void @@ -2158,7 +2159,7 @@ cons_show_pgp_prefs(void) cons_show("Allow sending unencrypted files via /sendfile while otherwise using PGP (/pgp sendfile): OFF"); } - cons_alert(); + cons_alert(NULL); } void @@ -2191,7 +2192,7 @@ cons_show_omemo_prefs(void) cons_show("Allow sending unencrypted files in an OMEMO session via /sendfile (/omemo sendfile): OFF"); } - cons_alert(); + cons_alert(NULL); } void @@ -2209,7 +2210,7 @@ cons_show_themes(GSList* themes) } } - cons_alert(); + cons_alert(NULL); } void @@ -2227,7 +2228,7 @@ cons_show_scripts(GSList* scripts) } } - cons_alert(); + cons_alert(NULL); } void @@ -2245,7 +2246,7 @@ cons_show_script(const char* const script, GSList* commands) } } - cons_alert(); + cons_alert(NULL); } void @@ -2271,7 +2272,7 @@ cons_prefs(void) cons_show_omemo_prefs(); cons_show(""); - cons_alert(); + cons_alert(NULL); } void @@ -2295,7 +2296,7 @@ cons_help(void) cons_show_padded(pad, "/help navigation : How to navigate around Profanity."); cons_show(""); - cons_alert(); + cons_alert(NULL); } void @@ -2314,7 +2315,7 @@ cons_navigation_help(void) cons_show(""); cons_show("See '/help win' for more information."); - cons_alert(); + cons_alert(NULL); } void @@ -2330,7 +2331,7 @@ cons_show_roster_group(const char* const group, GSList* list) _show_roster_contacts(list, FALSE); - cons_alert(); + cons_alert(NULL); } void @@ -2341,7 +2342,7 @@ cons_show_roster(GSList* list) _show_roster_contacts(list, TRUE); - cons_alert(); + cons_alert(NULL); } void @@ -2381,15 +2382,27 @@ cons_show_contacts(GSList* list) } curr = g_slist_next(curr); } - cons_alert(); + cons_alert(NULL); } void -cons_alert(void) +cons_alert(ProfWin* alert_origin_window) { ProfWin* current = wins_get_current(); if (current->type != WIN_CONSOLE) { status_bar_new(1, WIN_CONSOLE, "console"); + + char* win_name; + if (alert_origin_window) { + win_name = win_to_string(alert_origin_window); + } else { + win_name = strdup("console"); + } + + GList* item = g_list_find_custom(alert_list, win_name, (GCompareFunc)g_strcmp0); + if (!item) { + alert_list = g_list_append(alert_list, win_name); + } } } @@ -2707,3 +2720,29 @@ cons_show_bookmarks_ignore(gchar** list, gsize len) win_newline(console); } } + +gboolean +cons_has_alerts(void) +{ + if (g_list_length(alert_list) > 0) { + return TRUE; + } + return FALSE; +} + +void +cons_clear_alerts(void) +{ + g_list_free_full(alert_list, g_free); + alert_list = NULL; +} + +void +cons_remove_alert(ProfWin* window) +{ + char* win_name = win_to_string(window); + GList* item = g_list_find_custom(alert_list, win_name, (GCompareFunc)g_strcmp0); + alert_list = g_list_remove_link(alert_list, item); + g_list_free_full(item, g_free); + free(win_name); +} |