about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-11 21:44:24 +0000
committerJames Booth <boothj5@gmail.com>2014-01-11 21:44:24 +0000
commitf35e485bd4d5b6bfa7997b48f5b1f9c13576e26b (patch)
treea0d62dc5fa9ef9991e1619e29d4306feb4d25f46 /src/ui
parent5a7eba518d4193696051601e77d75dc3d9051567 (diff)
downloadprofani-tty-f35e485bd4d5b6bfa7997b48f5b1f9c13576e26b.tar.gz
Handle window creation for incoming and outgoing OTR sessions
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c29
-rw-r--r--src/ui/ui.h1
2 files changed, 30 insertions, 0 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 74a4d66e..397c6a0e 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -48,6 +48,7 @@
 #include "jid.h"
 #include "log.h"
 #include "muc.h"
+#include "otr.h"
 #include "ui/ui.h"
 #include "ui/window.h"
 #include "ui/windows.h"
@@ -245,6 +246,11 @@ _ui_incoming_msg(const char * const from, const char * const message,
     ProfWin *window = wins_get_by_recipient(from);
     if (window == NULL) {
         window = wins_new(from, win_type);
+#ifdef HAVE_LIBOTR
+        if (otr_is_secure(from)) {
+            window->is_otr = TRUE;
+        }
+#endif
         win_created = TRUE;
     }
 
@@ -582,6 +588,23 @@ _ui_next_win(void)
 }
 
 static void
+_ui_gone_secure(char *recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window != NULL) {
+        window->is_otr = TRUE;
+
+        if (wins_is_current(window)) {
+            GString *recipient_str = _get_recipient_string(window);
+            title_bar_set_recipient(recipient_str->str);
+            g_string_free(recipient_str, TRUE);
+            title_bar_draw();
+            wins_refresh_current();
+        }
+    }
+}
+
+static void
 _ui_previous_win(void)
 {
     ui_current_page_off();
@@ -966,6 +989,11 @@ _ui_outgoing_msg(const char * const from, const char * const to,
             window = wins_new(to, WIN_PRIVATE);
         } else {
             window = wins_new(to, WIN_CHAT);
+#ifdef HAVE_LIBOTR
+            if (otr_is_secure(to)) {
+                window->is_otr = TRUE;
+            }
+#endif
         }
 
         jid_destroy(jid);
@@ -1634,4 +1662,5 @@ ui_init_module(void)
     ui_ask_password = _ui_ask_password;
     ui_current_win_is_otr = _ui_current_win_is_otr;
     ui_current_set_otr = _ui_current_set_otr;
+    ui_gone_secure = _ui_gone_secure;
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 546f606a..6f2e6c4f 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -61,6 +61,7 @@ void (*ui_handle_special_keys)(const wint_t * const ch, const char * const inp,
 void (*ui_switch_win)(const int i);
 void (*ui_next_win)(void);
 void (*ui_previous_win)(void);
+void (*ui_gone_secure)(char *recipient);
 unsigned long (*ui_get_idle_time)(void);
 void (*ui_reset_idle_time)(void);
 void (*ui_new_chat_win)(const char * const to);