about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-10-26 23:10:30 +0000
committerJames Booth <boothj5@gmail.com>2015-10-26 23:10:30 +0000
commit9d3bcf5f90af09eb073b1caf64ccfadaad599e4b (patch)
treec8e59b4d7e46f139aa90cb3d45e9b5d72a25a729
parent4fb0b4b0da41525a8c9d70937fcc538aae2877cb (diff)
downloadprofani-tty-9d3bcf5f90af09eb073b1caf64ccfadaad599e4b.tar.gz
ui_gone_insecure takes ProfChatWin
-rw-r--r--src/command/commands.c2
-rw-r--r--src/otr/otr.c5
-rw-r--r--src/ui/chatwin.c17
-rw-r--r--src/ui/ui.h2
-rw-r--r--tests/unittests/ui/stub_ui.c2
5 files changed, 14 insertions, 14 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index bab32c33..e3dc5613 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4939,7 +4939,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args)
             return TRUE;
         }
 
-        ui_gone_insecure(chatwin->barejid);
+        ui_gone_insecure(chatwin);
         otr_end_session(chatwin->barejid);
         return TRUE;
 
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 6b9dd34d..8d1ee545 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -739,7 +739,10 @@ otr_decrypt_message(const char *const from, const char *const message, gboolean
         if (tlv) {
             if (context) {
                 otrl_context_force_plaintext(context);
-                ui_gone_insecure(from);
+                ProfChatWin *chatwin = wins_get_chat(from);
+                if (chatwin) {
+                    ui_gone_insecure(chatwin);
+                }
             }
         }
 
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 07159760..9af332a3 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -82,18 +82,15 @@ ui_gone_secure(ProfChatWin *chatwin, gboolean trusted)
 }
 
 void
-ui_gone_insecure(const char *const barejid)
+ui_gone_insecure(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        chatwin->is_otr = FALSE;
-        chatwin->otr_is_trusted = FALSE;
+    chatwin->is_otr = FALSE;
+    chatwin->otr_is_trusted = FALSE;
 
-        ProfWin *window = (ProfWin*)chatwin;
-        win_print(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended.");
-        if (wins_is_current(window)) {
-            title_bar_switch();
-        }
+    ProfWin *window = (ProfWin*)chatwin;
+    win_print(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended.");
+    if (wins_is_current(window)) {
+        title_bar_switch();
     }
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 693cda39..9df8d9d3 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -63,7 +63,7 @@ void ui_switch_win(ProfWin *window);
 void ui_sigwinch_handler(int sig);
 
 void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted);
-void ui_gone_insecure(const char *const barejid);
+void ui_gone_insecure(ProfChatWin *chatwin);
 void ui_trust(const char *const barejid);
 void ui_untrust(const char *const barejid);
 void ui_smp_recipient_initiated(const char *const barejid);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index 3b196f46..11f648a5 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -67,7 +67,7 @@ GSList* ui_get_chat_recipients(void)
 void ui_switch_win(ProfWin *win) {}
 
 void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted) {}
-void ui_gone_insecure(const char * const barejid) {}
+void ui_gone_insecure(ProfChatWin *chatwin) {}
 void ui_trust(const char * const barejid) {}
 void ui_untrust(const char * const barejid) {}
 void ui_smp_recipient_initiated(const char * const barejid) {}