about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-09-21 22:33:43 +0100
committerJames Booth <boothj5@gmail.com>2013-09-21 22:33:43 +0100
commit1d32413b99d2c42865b5bbd5fff63306e02c712e (patch)
treef2dc5238b47e9a5e02f2aac025734c4b04772bf3 /src
parent4aa05f65beb5b5a9657390b24c78971704e7ddbe (diff)
downloadprofani-tty-1d32413b99d2c42865b5bbd5fff63306e02c712e.tar.gz
Added /otr command
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c32
-rw-r--r--src/profanity.c3
2 files changed, 32 insertions, 3 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 6e79dc48..18d104bf 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -126,6 +126,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);
@@ -638,6 +639,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.",
@@ -3182,6 +3191,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];
diff --git a/src/profanity.c b/src/profanity.c
index 3aa75538..0dd9808a 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -253,9 +253,6 @@ void
 prof_handle_login_account_success(char *account_name)
 {
     ProfAccount *account = accounts_get_account(account_name);
-#ifdef HAVE_LIBOTR
-    otr_account_load(account);
-#endif
     resource_presence_t resource_presence = accounts_get_login_presence(account->name);
     contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
     cons_show_login_success(account);