about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event/server_events.c4
-rw-r--r--src/event/server_events.h2
-rw-r--r--src/ui/console.c5
-rw-r--r--src/ui/core.c8
-rw-r--r--src/ui/titlebar.c80
-rw-r--r--src/ui/titlebar.h4
-rw-r--r--src/ui/ui.h4
-rw-r--r--src/xmpp/connection.c5
8 files changed, 92 insertions, 20 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 83310e7d..697eb6c9 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -57,7 +57,7 @@
 #include "ui/ui.h"
 
 void
-sv_ev_login_account_success(char *account_name)
+sv_ev_login_account_success(char *account_name, int secured)
 {
     ProfAccount *account = accounts_get_account(account_name);
 
@@ -69,7 +69,7 @@ sv_ev_login_account_success(char *account_name)
     p_gpg_on_connect(account->jid);
 #endif
 
-    ui_handle_login_account_success(account);
+    ui_handle_login_account_success(account, secured);
 
     // attempt to rejoin rooms with passwords
     GList *curr = muc_rooms();
diff --git a/src/event/server_events.h b/src/event/server_events.h
index 3770dd94..9ec08e6b 100644
--- a/src/event/server_events.h
+++ b/src/event/server_events.h
@@ -37,7 +37,7 @@
 
 #include "xmpp/xmpp.h"
 
-void sv_ev_login_account_success(char *account_name);
+void sv_ev_login_account_success(char *account_name, int secured);
 void sv_ev_lost_connection(void);
 void sv_ev_failed_login(void);
 void sv_ev_room_invite(jabber_invite_t invite_type,
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);
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 5ad5e108..ba694bfd 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -482,11 +482,12 @@ _connection_handler(xmpp_conn_t * const conn,
     // login success
     if (status == XMPP_CONN_CONNECT) {
         log_debug("Connection handler: XMPP_CONN_CONNECT");
+        int secured = xmpp_conn_is_secured(jabber_conn.conn);
 
         // logged in with account
         if (saved_account.name) {
             log_debug("Connection handler: logged in with account name: %s", saved_account.name);
-            sv_ev_login_account_success(saved_account.name);
+            sv_ev_login_account_success(saved_account.name, secured);
 
         // logged in without account, use details to create new account
         } else {
@@ -494,7 +495,7 @@ _connection_handler(xmpp_conn_t * const conn,
             accounts_add(saved_details.name, saved_details.altdomain, saved_details.port);
             accounts_set_jid(saved_details.name, saved_details.jid);
 
-            sv_ev_login_account_success(saved_details.name);
+            sv_ev_login_account_success(saved_details.name, secured);
             saved_account.name = strdup(saved_details.name);
             saved_account.passwd = strdup(saved_details.passwd);