diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/console.c | 5 | ||||
-rw-r--r-- | src/ui/core.c | 8 | ||||
-rw-r--r-- | src/ui/titlebar.c | 80 | ||||
-rw-r--r-- | src/ui/titlebar.h | 4 | ||||
-rw-r--r-- | src/ui/ui.h | 4 |
5 files changed, 86 insertions, 15 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index 5445a503..820684c1 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -290,7 +290,7 @@ cons_check_version(gboolean not_available_msg) } void -cons_show_login_success(ProfAccount *account) +cons_show_login_success(ProfAccount *account, int secured) { ProfWin *console = wins_get_console(); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid); @@ -303,6 +303,9 @@ cons_show_login_success(ProfAccount *account) win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); win_print(console, '-', 0, NULL, NO_DATE, 0, "", "."); + if (!secured) { + cons_show_error("TLS connection not established"); + } cons_alert(); } diff --git a/src/ui/core.c b/src/ui/core.c index ff6d90ce..3fda21e8 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -558,12 +558,14 @@ ui_titlebar_presence(contact_presence_t presence) } void -ui_handle_login_account_success(ProfAccount *account) +ui_handle_login_account_success(ProfAccount *account, int secured) { resource_presence_t resource_presence = accounts_get_login_presence(account->name); contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence); - cons_show_login_success(account); + cons_show_login_success(account, secured); title_bar_set_presence(contact_presence); + title_bar_set_connected(TRUE); + title_bar_set_tls(secured ? TRUE : FALSE); GString *fulljid = g_string_new(account->jid); g_string_append(fulljid, "/"); @@ -661,6 +663,8 @@ void ui_disconnected(void) { wins_lost_connection(); + title_bar_set_connected(FALSE); + title_bar_set_tls(FALSE); title_bar_set_presence(CONTACT_OFFLINE); status_bar_clear_message(); status_bar_update_virtual(); diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 3bf8ab22..32ba13b4 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -51,6 +51,8 @@ static WINDOW *win; static contact_presence_t current_presence; +static gboolean tls_secured; +static gboolean is_connected; static gboolean typing; static GTimer *typing_elapsed; @@ -69,6 +71,8 @@ create_title_bar(void) wbkgd(win, theme_attrs(THEME_TITLE_TEXT)); title_bar_console(); title_bar_set_presence(CONTACT_OFFLINE); + title_bar_set_tls(FALSE); + title_bar_set_connected(FALSE); wnoutrefresh(win); inp_put_back(); } @@ -124,6 +128,20 @@ title_bar_set_presence(contact_presence_t presence) } void +title_bar_set_connected(gboolean connected) +{ + is_connected = connected; + _title_bar_draw(); +} + +void +title_bar_set_tls(gboolean secured) +{ + tls_secured = secured; + _title_bar_draw(); +} + +void title_bar_switch(void) { if (typing_elapsed) { @@ -190,55 +208,99 @@ _show_self_presence(void) { int presence_attrs = 0; int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); + int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED); + int unencrypted_attrs = theme_attrs(THEME_TITLE_UNENCRYPTED); int cols = getmaxx(stdscr); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 14, '['); - wattroff(win, bracket_attrs); + int tls_start = 0; switch (current_presence) { case CONTACT_ONLINE: presence_attrs = theme_attrs(THEME_TITLE_ONLINE); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 9, '['); + wattroff(win, bracket_attrs); wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 13, " ...online "); + mvwprintw(win, 0, cols - 8, "online"); wattroff(win, presence_attrs); + tls_start = 15; break; case CONTACT_AWAY: presence_attrs = theme_attrs(THEME_TITLE_AWAY); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 7, '['); + wattroff(win, bracket_attrs); wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 13, " .....away "); + mvwprintw(win, 0, cols - 6, "away"); wattroff(win, presence_attrs); + tls_start = 13; break; case CONTACT_DND: presence_attrs = theme_attrs(THEME_TITLE_DND); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 6, '['); + wattroff(win, bracket_attrs); wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 13, " ......dnd "); + mvwprintw(win, 0, cols - 5, "dnd"); wattroff(win, presence_attrs); + tls_start = 12; break; case CONTACT_CHAT: presence_attrs = theme_attrs(THEME_TITLE_CHAT); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 7, '['); + wattroff(win, bracket_attrs); wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 13, " .....chat "); + mvwprintw(win, 0, cols - 6, "chat"); wattroff(win, presence_attrs); + tls_start = 13; break; case CONTACT_XA: presence_attrs = theme_attrs(THEME_TITLE_XA); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 5, '['); + wattroff(win, bracket_attrs); wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 13, " .......xa "); + mvwprintw(win, 0, cols - 4, "xa"); wattroff(win, presence_attrs); + tls_start = 11; break; case CONTACT_OFFLINE: presence_attrs = theme_attrs(THEME_TITLE_OFFLINE); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 10, '['); + wattroff(win, bracket_attrs); wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 13, " ..offline "); + mvwprintw(win, 0, cols - 9, "offline"); wattroff(win, presence_attrs); + tls_start = 16; break; } wattron(win, bracket_attrs); mvwaddch(win, 0, cols - 2, ']'); wattroff(win, bracket_attrs); + + if (is_connected) { + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - tls_start, '['); + wattroff(win, bracket_attrs); + + if (tls_secured) { + wattron(win, encrypted_attrs); + mvwprintw(win, 0, cols - (tls_start - 1), "TLS"); + wattroff(win, encrypted_attrs); + } else { + wattron(win, unencrypted_attrs); + mvwprintw(win, 0, cols - (tls_start - 1), "TLS"); + wattroff(win, unencrypted_attrs); + } + + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - (tls_start - 4), ']'); + wattroff(win, bracket_attrs); + } } static void diff --git a/src/ui/titlebar.h b/src/ui/titlebar.h index 66237f86..4e11107e 100644 --- a/src/ui/titlebar.h +++ b/src/ui/titlebar.h @@ -40,7 +40,9 @@ void title_bar_update_virtual(void); void title_bar_resize(void); void title_bar_console(void); void title_bar_set_presence(contact_presence_t presence); +void title_bar_set_connected(gboolean connected); +void title_bar_set_tls(gboolean secured); void title_bar_switch(void); void title_bar_set_typing(gboolean is_typing); -#endif \ No newline at end of file +#endif diff --git a/src/ui/ui.h b/src/ui/ui.h index 3aae7643..93fde07b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -227,7 +227,7 @@ void ui_clear_win(ProfWin *window); void ui_auto_away(char *message, gint time, resource_presence_t res_presence); void ui_titlebar_presence(contact_presence_t presence); -void ui_handle_login_account_success(ProfAccount *account); +void ui_handle_login_account_success(ProfAccount *account, int secured); void ui_update_presence(const resource_presence_t resource_presence, const char * const message, const char * const show); void ui_about(void); @@ -279,7 +279,7 @@ void cons_show_info(PContact pcontact); void cons_show_caps(const char * const fulljid, resource_presence_t presence); void cons_show_themes(GSList *themes); void cons_show_aliases(GList *aliases); -void cons_show_login_success(ProfAccount *account); +void cons_show_login_success(ProfAccount *account, int secured); void cons_show_software_version(const char * const jid, const char * const presence, const char * const name, const char * const version, const char * const os); |