about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c28
-rw-r--r--src/ui/ui.h3
2 files changed, 28 insertions, 3 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 397c6a0e..7acab4c2 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -439,7 +439,13 @@ _ui_close_connected_win(int index)
         char *room_jid = ui_recipient(index);
         presence_leave_chat_room(room_jid);
     } else if ((win_type == WIN_CHAT) || (win_type == WIN_PRIVATE)) {
-
+#ifdef HAVE_LIBOTR
+        ProfWin *window = wins_get_by_num(index);
+        if (window->is_otr) {
+            cons_debug("Ending OTR session");
+            otr_end_session(window->from);
+        }
+#endif
         if (prefs_get_boolean(PREF_STATES)) {
             char *recipient = ui_recipient(index);
 
@@ -588,7 +594,7 @@ _ui_next_win(void)
 }
 
 static void
-_ui_gone_secure(char *recipient)
+_ui_gone_secure(const char * const recipient)
 {
     ProfWin *window = wins_get_by_recipient(recipient);
     if (window != NULL) {
@@ -605,6 +611,23 @@ _ui_gone_secure(char *recipient)
 }
 
 static void
+_ui_gone_insecure(const char * const recipient)
+{
+    ProfWin *window = wins_get_by_recipient(recipient);
+    if (window != NULL) {
+        window->is_otr = FALSE;
+
+        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();
@@ -1663,4 +1686,5 @@ ui_init_module(void)
     ui_current_win_is_otr = _ui_current_win_is_otr;
     ui_current_set_otr = _ui_current_set_otr;
     ui_gone_secure = _ui_gone_secure;
+    ui_gone_insecure = _ui_gone_insecure;
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 6f2e6c4f..88be3fbb 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -61,7 +61,8 @@ 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);
+void (*ui_gone_secure)(const char * const recipient);
+void (*ui_gone_insecure)(const char * const recipient);
 unsigned long (*ui_get_idle_time)(void);
 void (*ui_reset_idle_time)(void);
 void (*ui_new_chat_win)(const char * const to);