about summary refs log tree commit diff stats
path: root/src/command/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/command/command.c')
-rw-r--r--src/command/command.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 7a74f394..3828ddcf 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -129,6 +129,7 @@ static gboolean _cmd_nick(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_notify(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_online(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_outtype(gchar **args, struct cmd_help_t help);
+static gboolean _cmd_otr(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_prefs(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_priority(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_quit(gchar **args, struct cmd_help_t help);
@@ -651,6 +652,14 @@ static struct cmd_t command_defs[] =
           "Such as whether you have become inactive, or have closed the chat window.",
           NULL } } },
 
+    { "/otr",
+        _cmd_otr, parse_args, 1, 2, NULL,
+        { "/otr gen|start|end|trust|untrust [contact]", "Off The Record encryption commands.",
+        { "/otr gen|start|end|trust|untrust [contact]",
+          "-----------------------------------------",
+          "gen - Load or create private key and fingerprints.",
+          NULL } } },
+
     { "/outtype",
         _cmd_outtype, parse_args, 1, 1, cons_outtype_setting,
         { "/outtype on|off", "Send typing notification to recipient.",
@@ -3207,6 +3216,29 @@ _cmd_outtype(gchar **args, struct cmd_help_t help)
 }
 
 static gboolean
+_cmd_otr(gchar **args, struct cmd_help_t help)
+{
+#ifdef HAVE_LIBOTR
+    if (strcmp(args[0], "gen") == 0) {
+        if (jabber_get_connection_status() != JABBER_CONNECTED) {
+            cons_show("You must be connected with an account to load OTR information.");
+            return TRUE;
+        } else {
+            ProfAccount *account = accounts_get_account(jabber_get_account_name());
+            otr_account_load(account);
+            return TRUE;
+        }
+    } else {
+        cons_show("Usage: %s", help.usage);
+        return TRUE;
+    }
+#else
+    cons_show("This version of Profanity has not been build with OTR support enabled");
+    return TRUE;
+#endif
+}
+
+static gboolean
 _cmd_gone(gchar **args, struct cmd_help_t help)
 {
     char *value = args[0];