about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-11 23:59:20 +0000
committerJames Booth <boothj5@gmail.com>2014-01-11 23:59:20 +0000
commit494aaadba42ebd95566d2b5128b7925c8aa4cde9 (patch)
tree670f6faad3699098a6bfe052dbe61f57d11c786c
parenta3217bcf8c2a8fe64447a0ec02c0d9d9b39e6686 (diff)
downloadprofani-tty-494aaadba42ebd95566d2b5128b7925c8aa4cde9.tar.gz
Added /otr end command
-rw-r--r--src/command/commands.c14
-rw-r--r--src/ui/core.c3
2 files changed, 16 insertions, 1 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index bb18ff2f..660ec572 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2346,6 +2346,20 @@ cmd_otr(gchar **args, struct cmd_help_t help)
             }
         }
         return TRUE;
+    } else if (strcmp(args[0], "end") == 0) {
+        win_type_t win_type = ui_current_win_type();
+
+        if (win_type != WIN_CHAT) {
+            ui_current_print_line("You must be in a regular chat window to use OTR.");
+        } else if (!ui_current_win_is_otr()) {
+            ui_current_print_line("You are not currently in an OTR session.");
+        } else {
+            char *recipient = ui_current_recipient();
+            ui_gone_insecure(recipient);
+            otr_end_session(recipient);
+        }
+        return TRUE;
+
     } else {
         cons_show("Usage: %s", help.usage);
         return TRUE;
diff --git a/src/ui/core.c b/src/ui/core.c
index 7acab4c2..fc6ca40e 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -442,7 +442,6 @@ _ui_close_connected_win(int index)
 #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
@@ -599,6 +598,7 @@ _ui_gone_secure(const char * const recipient)
     ProfWin *window = wins_get_by_recipient(recipient);
     if (window != NULL) {
         window->is_otr = TRUE;
+        win_vprint_line(window, '!', 0, "OTR session started.");
 
         if (wins_is_current(window)) {
             GString *recipient_str = _get_recipient_string(window);
@@ -616,6 +616,7 @@ _ui_gone_insecure(const char * const recipient)
     ProfWin *window = wins_get_by_recipient(recipient);
     if (window != NULL) {
         window->is_otr = FALSE;
+        win_vprint_line(window, '!', 0, "OTR session ended.");
 
         if (wins_is_current(window)) {
             GString *recipient_str = _get_recipient_string(window);