about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-06-21 20:20:28 +0100
committerJames Booth <boothj5@gmail.com>2015-06-21 20:20:28 +0100
commit217fcff42080a67bdd5834c590441a05fdb90753 (patch)
tree78c4abefc662bc5cf44fecce9a717b93c5144120 /src/command
parentf81652e84eab97e555143ca436fa6bafd3d4bb80 (diff)
downloadprofani-tty-217fcff42080a67bdd5834c590441a05fdb90753.tar.gz
Added /pgp end command
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c1
-rw-r--r--src/command/commands.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 5e38a7be..af91bf16 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1601,6 +1601,7 @@ cmd_init(void)
     autocomplete_add(pgp_ac, "fps");
     autocomplete_add(pgp_ac, "libver");
     autocomplete_add(pgp_ac, "start");
+    autocomplete_add(pgp_ac, "end");
 }
 
 void
diff --git a/src/command/commands.c b/src/command/commands.c
index 4aa0df5b..2fe4c2f6 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4261,6 +4261,30 @@ cmd_pgp(ProfWin *window, gchar **args, struct cmd_help_t help)
 
         chatwin->enc_mode = PROF_ENC_PGP;
         ui_current_print_formatted_line('!', 0, "PGP encyption enabled.");
+        return TRUE;
+    }
+
+    if (g_strcmp0(args[0], "end") == 0) {
+        jabber_conn_status_t conn_status = jabber_get_connection_status();
+        if (conn_status != JABBER_CONNECTED) {
+            cons_show("You are not currently connected.");
+            return TRUE;
+        }
+
+        if (window->type != WIN_CHAT) {
+            cons_show("You must be in a regular chat window to end PGP encrpytion.");
+            return TRUE;
+        }
+
+        ProfChatWin *chatwin = (ProfChatWin*)window;
+        if (chatwin->enc_mode != PROF_ENC_PGP) {
+            ui_current_print_formatted_line('!', 0, "PGP encryption is not currently enabled.");
+            return TRUE;
+        }
+
+        chatwin->enc_mode = PROF_ENC_NONE;
+        ui_current_print_formatted_line('!', 0, "PGP encyption disabled.");
+        return TRUE;
     }
 
     return TRUE;