about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c32
-rw-r--r--src/common.c6
-rw-r--r--src/event/client_events.c34
-rw-r--r--src/event/server_events.c36
-rw-r--r--src/otr/otr.c4
-rw-r--r--src/ui/core.c18
-rw-r--r--src/ui/titlebar.c103
-rw-r--r--src/ui/ui.h6
-rw-r--r--src/ui/win_types.h10
-rw-r--r--src/ui/window.c8
10 files changed, 132 insertions, 125 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 7d829e2f..06c6d9b8 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4355,12 +4355,12 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
             assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
         }
 
-        if (chatwin->enc_mode == PROF_ENC_OTR) {
+        if (chatwin->is_otr) {
             ui_current_print_formatted_line('!', 0, "You must end the OTR session to start PGP encryption.");
             return TRUE;
         }
 
-        if (chatwin->enc_mode == PROF_ENC_PGP) {
+        if (chatwin->pgp_send) {
             ui_current_print_formatted_line('!', 0, "You have already started PGP encryption.");
             return TRUE;
         }
@@ -4378,7 +4378,7 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
             return TRUE;
         }
 
-        chatwin->enc_mode = PROF_ENC_PGP;
+        chatwin->pgp_send = TRUE;
         ui_current_print_formatted_line('!', 0, "PGP encyption enabled.");
         return TRUE;
     }
@@ -4396,12 +4396,12 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
         }
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
-        if (chatwin->enc_mode != PROF_ENC_PGP) {
+        if (chatwin->pgp_send == FALSE) {
             ui_current_print_formatted_line('!', 0, "PGP encryption is not currently enabled.");
             return TRUE;
         }
 
-        chatwin->enc_mode = PROF_ENC_NONE;
+        chatwin->pgp_send = FALSE;
         ui_current_print_formatted_line('!', 0, "PGP encyption disabled.");
         return TRUE;
     }
@@ -4527,7 +4527,7 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        if (chatwin->enc_mode != PROF_ENC_OTR) {
+        if (chatwin->is_otr == FALSE) {
             ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
             return TRUE;
         }
@@ -4552,12 +4552,12 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
             }
             ui_ev_focus_win((ProfWin*)chatwin);
 
-            if (chatwin->enc_mode == PROF_ENC_PGP) {
+            if (chatwin->pgp_send) {
                 ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session.");
                 return TRUE;
             }
 
-            if (chatwin->enc_mode == PROF_ENC_OTR) {
+            if (chatwin->is_otr) {
                 ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
                 return TRUE;
             }
@@ -4586,12 +4586,12 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
             ProfChatWin *chatwin = (ProfChatWin*)window;
             assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-            if (chatwin->enc_mode == PROF_ENC_PGP) {
+            if (chatwin->pgp_send) {
                 ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session.");
                 return TRUE;
             }
 
-            if (chatwin->enc_mode == PROF_ENC_OTR) {
+            if (chatwin->is_otr) {
                 ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
                 return TRUE;
             }
@@ -4615,7 +4615,7 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        if (chatwin->enc_mode != PROF_ENC_OTR) {
+        if (chatwin->is_otr == FALSE) {
             ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
             return TRUE;
         }
@@ -4632,7 +4632,7 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        if (chatwin->enc_mode != PROF_ENC_OTR) {
+        if (chatwin->is_otr == FALSE) {
             ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
             return TRUE;
         }
@@ -4649,7 +4649,7 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        if (chatwin->enc_mode != PROF_ENC_OTR) {
+        if (chatwin->is_otr == FALSE) {
             ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
             return TRUE;
         }
@@ -4666,7 +4666,7 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        if (chatwin->enc_mode != PROF_ENC_OTR) {
+        if (chatwin->is_otr == FALSE) {
             ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
             return TRUE;
         }
@@ -4695,7 +4695,7 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        if (chatwin->enc_mode != PROF_ENC_OTR) {
+        if (chatwin->is_otr == FALSE) {
             ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
             return TRUE;
         }
@@ -4711,7 +4711,7 @@ cmd_otr(ProfWin *window, const char * const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        if (chatwin->enc_mode != PROF_ENC_OTR) {
+        if (chatwin->is_otr == FALSE) {
             ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
             return TRUE;
         }
diff --git a/src/common.c b/src/common.c
index fc701b8b..0a314c91 100644
--- a/src/common.c
+++ b/src/common.c
@@ -195,6 +195,12 @@ str_replace(const char *string, const char *substr,
 gboolean
 str_contains_str(const char *  const searchstr, const char * const substr)
 {
+    if (!searchstr) {
+        return FALSE;
+    }
+    if (!substr) {
+        return FALSE;
+    }
     return g_strrstr(searchstr, substr) != NULL;
 }
 
diff --git a/src/event/client_events.c b/src/event/client_events.c
index 56723f40..761452df 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -91,20 +91,19 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
 // OTR suported, PGP supported
 #ifdef HAVE_LIBOTR
 #ifdef HAVE_LIBGPGME
-    prof_enc_t enc_mode = chatwin->enc_mode;
-    if (enc_mode == PROF_ENC_NONE || enc_mode == PROF_ENC_OTR) {
+    if (chatwin->pgp_send) {
+        char *id = message_send_chat_pgp(chatwin->barejid, msg);
+        chat_log_pgp_msg_out(chatwin->barejid, msg);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PGP);
+        free(id);
+    } else {
         gboolean handled = otr_on_message_send(chatwin, msg);
         if (!handled) {
             char *id = message_send_chat(chatwin->barejid, msg);
             chat_log_msg_out(chatwin->barejid, msg);
-            ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
+            ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
             free(id);
         }
-    } else { // enc_mode = PROF_ENC_PGP
-        char *id = message_send_chat_pgp(chatwin->barejid, msg);
-        chat_log_pgp_msg_out(chatwin->barejid, msg);
-        ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP);
-        free(id);
     }
     return;
 #endif
@@ -117,7 +116,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
     if (!handled) {
         char *id = message_send_chat(chatwin->barejid, msg);
         chat_log_msg_out(chatwin->barejid, msg);
-        ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
         free(id);
     }
     return;
@@ -127,16 +126,15 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
 // OTR unsupported, PGP supported
 #ifndef HAVE_LIBOTR
 #ifdef HAVE_LIBGPGME
-    prof_enc_t enc_mode = chatwin->enc_mode;
-    if (enc_mode == PROF_ENC_NONE) {
-        char *id = message_send_chat(chatwin->barejid, msg);
-        chat_log_msg_out(chatwin->barejid, msg);
-        ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
-        free(id);
-    } else if (enc_mode == PROF_ENC_PGP) {
+    if (chatwin->pgp_send) {
         char *id = message_send_chat_pgp(chatwin->barejid, msg);
         chat_log_pgp_msg_out(chatwin->barejid, msg);
-        ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PGP);
+        free(id);
+    } else {
+        char *id = message_send_chat(chatwin->barejid, msg);
+        chat_log_msg_out(chatwin->barejid, msg);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
         free(id);
     }
     return;
@@ -148,7 +146,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
 #ifndef HAVE_LIBGPGME
     char *id = message_send_chat(chatwin->barejid, msg);
     chat_log_msg_out(chatwin->barejid, msg);
-    ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
+    ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
     free(id);
     return;
 #endif
diff --git a/src/event/server_events.c b/src/event/server_events.c
index ae85d32a..74aa4d74 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -187,7 +187,7 @@ sv_ev_incoming_carbon(char *barejid, char *resource, char *message)
         new_win = TRUE;
     }
 
-    ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
+    ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN);
     chat_log_msg_in(barejid, message);
 }
 
@@ -197,17 +197,14 @@ _sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, char *barejid, char
 {
     char *decrypted = p_gpg_decrypt(pgp_message);
     if (decrypted) {
-        if (chatwin->enc_mode == PROF_ENC_NONE) {
-            win_println((ProfWin*)chatwin, 0, "PGP encryption enabled.");
-        }
-        ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win, PROF_ENC_PGP);
+        ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win, PROF_MSG_PGP);
         chat_log_pgp_msg_in(barejid, decrypted);
-        chatwin->enc_mode = PROF_ENC_PGP;
+        chatwin->pgp_recv = TRUE;
         p_gpg_free_decrypted(decrypted);
     } else {
-        ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
+        ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN);
         chat_log_msg_in(barejid, message);
-        chatwin->enc_mode = PROF_ENC_NONE;
+        chatwin->pgp_recv = FALSE;
     }
 }
 #endif
@@ -220,23 +217,27 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char
     char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted);
     if (otr_res) {
         if (decrypted) {
-            ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_OTR);
+            ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_MSG_OTR);
+            chatwin->pgp_send = FALSE;
         } else {
-            ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_NONE);
+            ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_MSG_PLAIN);
         }
         chat_log_otr_msg_in(barejid, otr_res, decrypted);
         otr_free_message(otr_res);
+        chatwin->pgp_recv = FALSE;
     }
 }
 #endif
 
+#ifndef HAVE_LIBOTR
 static void
 _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message)
 {
-    ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE);
+    ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN);
     chat_log_msg_in(barejid, message);
-    chatwin->enc_mode = PROF_ENC_NONE;
+    chatwin->pgp_recv = FALSE;
 }
+#endif
 
 void
 sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message)
@@ -253,18 +254,13 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
 #ifdef HAVE_LIBOTR
 #ifdef HAVE_LIBGPGME
     if (pgp_message) {
-        if (chatwin->enc_mode == PROF_ENC_OTR) {
+        if (chatwin->is_otr) {
             win_println((ProfWin*)chatwin, 0, "PGP encrypted message received whilst in OTR session.");
         } else { // PROF_ENC_NONE, PROF_ENC_PGP
             _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message);
         }
     } else {
-        if (chatwin->enc_mode == PROF_ENC_PGP) {
-            win_println((ProfWin*)chatwin, 0, "PGP encryption disabled.");
-            _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message);
-        } else {
-            _sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message);
-        }
+        _sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message);
     }
     return;
 #endif
@@ -316,7 +312,7 @@ sv_ev_delayed_message(char *barejid, char *message, GDateTime *timestamp)
         new_win = TRUE;
     }
 
-    ui_incoming_msg(chatwin, NULL, message, timestamp, new_win, PROF_ENC_NONE);
+    ui_incoming_msg(chatwin, NULL, message, timestamp, new_win, PROF_MSG_PLAIN);
     chat_log_msg_in_delayed(barejid, message, timestamp);
 }
 
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 7e68ecb3..511d6843 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -325,7 +325,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char * const message)
         if (encrypted) {
             id = message_send_chat_otr(chatwin->barejid, encrypted);
             chat_log_otr_msg_out(chatwin->barejid, message);
-            ui_outgoing_chat_msg(chatwin, message, id, PROF_ENC_OTR);
+            ui_outgoing_chat_msg(chatwin, message, id, PROF_MSG_OTR);
             otr_free_message(encrypted);
             free(id);
             return TRUE;
@@ -345,7 +345,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char * const message)
     if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
         char *otr_tagged_msg = otr_tag_message(message);
         id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg);
-        ui_outgoing_chat_msg(chatwin, message, id, PROF_ENC_NONE);
+        ui_outgoing_chat_msg(chatwin, message, id, PROF_MSG_PLAIN);
         chat_log_msg_out(chatwin->barejid, message);
         free(otr_tagged_msg);
         free(id);
diff --git a/src/ui/core.c b/src/ui/core.c
index d66806d4..9ee8b9a5 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -478,7 +478,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message,
 
     // currently viewing chat window with sender
     if (wins_is_current(window)) {
-        win_print_incoming_message(window, timestamp, display_from, message, PROF_ENC_NONE);
+        win_print_incoming_message(window, timestamp, display_from, message, PROF_MSG_PLAIN);
         title_bar_set_typing(FALSE);
         status_bar_active(num);
 
@@ -487,7 +487,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message,
         privatewin->unread++;
         status_bar_new(num);
         cons_show_incoming_message(display_from, num);
-        win_print_incoming_message(window, timestamp, display_from, message, PROF_ENC_NONE);
+        win_print_incoming_message(window, timestamp, display_from, message, PROF_MSG_PLAIN);
 
         if (prefs_get_boolean(PREF_FLASH)) {
             flash();
@@ -713,7 +713,7 @@ ui_close_connected_win(int index)
             ProfChatWin *chatwin = (ProfChatWin*) window;
             assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
 #ifdef HAVE_LIBOTR
-            if (chatwin->enc_mode == PROF_ENC_OTR) {
+            if (chatwin->is_otr) {
                 otr_end_session(chatwin->barejid);
             }
 #endif
@@ -895,7 +895,7 @@ ui_gone_secure(const char * const barejid, gboolean trusted)
         chatwin = (ProfChatWin*)window;
     }
 
-    chatwin->enc_mode = PROF_ENC_OTR;
+    chatwin->is_otr = TRUE;
     chatwin->otr_is_trusted = trusted;
     if (trusted) {
         win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted).");
@@ -923,7 +923,7 @@ ui_gone_insecure(const char * const barejid)
 {
     ProfChatWin *chatwin = wins_get_chat(barejid);
     if (chatwin) {
-        chatwin->enc_mode = PROF_ENC_NONE;
+        chatwin->is_otr = FALSE;
         chatwin->otr_is_trusted = FALSE;
 
         ProfWin *window = (ProfWin*)chatwin;
@@ -1042,7 +1042,7 @@ ui_trust(const char * const barejid)
 {
     ProfChatWin *chatwin = wins_get_chat(barejid);
     if (chatwin) {
-        chatwin->enc_mode = PROF_ENC_OTR;
+        chatwin->is_otr = TRUE;
         chatwin->otr_is_trusted = TRUE;
 
         ProfWin *window = (ProfWin*)chatwin;
@@ -1058,7 +1058,7 @@ ui_untrust(const char * const barejid)
 {
     ProfChatWin *chatwin = wins_get_chat(barejid);
     if (chatwin) {
-        chatwin->enc_mode = PROF_ENC_OTR;
+        chatwin->is_otr = TRUE;
         chatwin->otr_is_trusted = FALSE;
 
         ProfWin *window = (ProfWin*)chatwin;
@@ -1290,9 +1290,9 @@ void
 ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode)
 {
     char enc_char = '-';
-    if (enc_mode == PROF_ENC_OTR) {
+    if (enc_mode == PROF_MSG_OTR) {
         enc_char = prefs_get_otr_char();
-    } else if (enc_mode == PROF_ENC_PGP) {
+    } else if (enc_mode == PROF_MSG_PGP) {
         enc_char = prefs_get_pgp_char();
     }
 
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index 16a9eaff..3bf8ab22 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -250,70 +250,73 @@ _show_privacy(ProfChatWin *chatwin)
     int trusted_attrs = theme_attrs(THEME_TITLE_TRUSTED);
     int untrusted_attrs = theme_attrs(THEME_TITLE_UNTRUSTED);
 
-    switch (chatwin->enc_mode) {
-        case PROF_ENC_NONE:
-            if (prefs_get_boolean(PREF_ENC_WARN)) {
-                wprintw(win, " ");
-                wattron(win, bracket_attrs);
-                wprintw(win, "[");
-                wattroff(win, bracket_attrs);
-                wattron(win, unencrypted_attrs);
-                wprintw(win, "unencrypted");
-                wattroff(win, unencrypted_attrs);
-                wattron(win, bracket_attrs);
-                wprintw(win, "]");
-                wattroff(win, bracket_attrs);
-            }
-            break;
-
-        case PROF_ENC_OTR:
+    if (chatwin->is_otr) {
+        wprintw(win, " ");
+        wattron(win, bracket_attrs);
+        wprintw(win, "[");
+        wattroff(win, bracket_attrs);
+        wattron(win, encrypted_attrs);
+        wprintw(win, "OTR");
+        wattroff(win, encrypted_attrs);
+        wattron(win, bracket_attrs);
+        wprintw(win, "]");
+        wattroff(win, bracket_attrs);
+        if (chatwin->otr_is_trusted) {
             wprintw(win, " ");
             wattron(win, bracket_attrs);
             wprintw(win, "[");
             wattroff(win, bracket_attrs);
-            wattron(win, encrypted_attrs);
-            wprintw(win, "OTR");
-            wattroff(win, encrypted_attrs);
+            wattron(win, trusted_attrs);
+            wprintw(win, "trusted");
+            wattroff(win, trusted_attrs);
             wattron(win, bracket_attrs);
             wprintw(win, "]");
             wattroff(win, bracket_attrs);
-            if (chatwin->otr_is_trusted) {
-                wprintw(win, " ");
-                wattron(win, bracket_attrs);
-                wprintw(win, "[");
-                wattroff(win, bracket_attrs);
-                wattron(win, trusted_attrs);
-                wprintw(win, "trusted");
-                wattroff(win, trusted_attrs);
-                wattron(win, bracket_attrs);
-                wprintw(win, "]");
-                wattroff(win, bracket_attrs);
-            } else {
-                wprintw(win, " ");
-                wattron(win, bracket_attrs);
-                wprintw(win, "[");
-                wattroff(win, bracket_attrs);
-                wattron(win, untrusted_attrs);
-                wprintw(win, "untrusted");
-                wattroff(win, untrusted_attrs);
-                wattron(win, bracket_attrs);
-                wprintw(win, "]");
-                wattroff(win, bracket_attrs);
-            }
-            break;
-
-        case PROF_ENC_PGP:
+        } else {
             wprintw(win, " ");
             wattron(win, bracket_attrs);
             wprintw(win, "[");
             wattroff(win, bracket_attrs);
-            wattron(win, encrypted_attrs);
-            wprintw(win, "PGP");
-            wattroff(win, encrypted_attrs);
+            wattron(win, untrusted_attrs);
+            wprintw(win, "untrusted");
+            wattroff(win, untrusted_attrs);
             wattron(win, bracket_attrs);
             wprintw(win, "]");
             wattroff(win, bracket_attrs);
-            break;
+        }
+    } else if (chatwin->pgp_send || chatwin->pgp_recv) {
+        GString *pgpmsg = g_string_new("PGP ");
+        if (chatwin->pgp_send && !chatwin->pgp_recv) {
+            g_string_append(pgpmsg, "send");
+        } else if (!chatwin->pgp_send && chatwin->pgp_recv) {
+            g_string_append(pgpmsg, "recv");
+        } else {
+            g_string_append(pgpmsg, "send/recv");
+        }
+        wprintw(win, " ");
+        wattron(win, bracket_attrs);
+        wprintw(win, "[");
+        wattroff(win, bracket_attrs);
+        wattron(win, encrypted_attrs);
+        wprintw(win, pgpmsg->str);
+        wattroff(win, encrypted_attrs);
+        wattron(win, bracket_attrs);
+        wprintw(win, "]");
+        wattroff(win, bracket_attrs);
+        g_string_free(pgpmsg, TRUE);
+    } else {
+        if (prefs_get_boolean(PREF_ENC_WARN)) {
+            wprintw(win, " ");
+            wattron(win, bracket_attrs);
+            wprintw(win, "[");
+            wattroff(win, bracket_attrs);
+            wattron(win, unencrypted_attrs);
+            wprintw(win, "unencrypted");
+            wattroff(win, unencrypted_attrs);
+            wattron(win, bracket_attrs);
+            wprintw(win, "]");
+            wattroff(win, bracket_attrs);
+        }
     }
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index bd38cbe8..e47cbddd 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -45,6 +45,12 @@
 #define NO_COLOUR_FROM  8
 #define NO_COLOUR_DATE  16
 
+typedef enum {
+    PROF_MSG_PLAIN,
+    PROF_MSG_OTR,
+    PROF_MSG_PGP
+} prof_enc_t;
+
 // ui startup and control
 void ui_init(void);
 void ui_load_colours(void);
diff --git a/src/ui/win_types.h b/src/ui/win_types.h
index 3214fa94..bace4537 100644
--- a/src/ui/win_types.h
+++ b/src/ui/win_types.h
@@ -89,12 +89,6 @@ typedef enum {
     WIN_XML
 } win_type_t;
 
-typedef enum {
-    PROF_ENC_NONE,
-    PROF_ENC_OTR,
-    PROF_ENC_PGP
-} prof_enc_t;
-
 typedef struct prof_win_t {
     win_type_t type;
     ProfLayout *layout;
@@ -109,8 +103,10 @@ typedef struct prof_chat_win_t {
     char *barejid;
     int unread;
     ChatState *state;
-    prof_enc_t enc_mode;
+    gboolean is_otr;
     gboolean otr_is_trusted;
+    gboolean pgp_send;
+    gboolean pgp_recv;
     char *resource_override;
     gboolean history_shown;
     unsigned long memcheck;
diff --git a/src/ui/window.c b/src/ui/window.c
index f6ad7cee..a78b0e15 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -135,8 +135,10 @@ win_create_chat(const char * const barejid)
 
     new_win->barejid = strdup(barejid);
     new_win->resource_override = NULL;
-    new_win->enc_mode = PROF_ENC_NONE;
+    new_win->is_otr = FALSE;
     new_win->otr_is_trusted = FALSE;
+    new_win->pgp_recv = FALSE;
+    new_win->pgp_send = FALSE;
     new_win->history_shown = FALSE;
     new_win->unread = 0;
     new_win->state = chat_state_new();
@@ -884,9 +886,9 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
     switch (window->type)
     {
         case WIN_CHAT:
-            if (enc_mode == PROF_ENC_OTR) {
+            if (enc_mode == PROF_MSG_OTR) {
                 enc_char = prefs_get_otr_char();
-            } else if (enc_mode == PROF_ENC_PGP) {
+            } else if (enc_mode == PROF_MSG_PGP) {
                 enc_char = prefs_get_pgp_char();
             }
             win_print(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message);