diff options
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 15 | ||||
-rw-r--r-- | src/command/commands.c | 24 | ||||
-rw-r--r-- | src/command/commands.h | 1 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c index a13687a3..45381b99 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -41,6 +41,7 @@ #include "jid.h" #include "log.h" #include "muc.h" +#include "otr.h" #include "profanity.h" #include "tools/autocomplete.h" #include "tools/parser.h" @@ -567,6 +568,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.", @@ -1129,7 +1138,13 @@ cmd_execute_default(const char * const inp) if (status != JABBER_CONNECTED) { ui_current_print_line("You are not currently connected."); } else { +#ifdef HAVE_LIBOTR + char *encrypted = otr_encrypt_message(recipient, inp); + message_send(encrypted, recipient); + otr_free_message(encrypted); +#else message_send(inp, recipient); +#endif if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); diff --git a/src/command/commands.c b/src/command/commands.c index 67458c79..d962ce6d 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -36,6 +36,7 @@ #include "jid.h" #include "log.h" #include "muc.h" +#include "otr.h" #include "profanity.h" #include "tools/autocomplete.h" #include "tools/parser.h" @@ -2242,6 +2243,29 @@ cmd_xa(gchar **args, struct cmd_help_t help) return TRUE; } +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 +} + // helper function for status change commands static void _update_presence(const resource_presence_t resource_presence, diff --git a/src/command/commands.h b/src/command/commands.h index aee74849..3caa3085 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -86,6 +86,7 @@ gboolean cmd_msg(gchar **args, struct cmd_help_t help); gboolean cmd_nick(gchar **args, struct cmd_help_t help); gboolean cmd_notify(gchar **args, struct cmd_help_t help); gboolean cmd_online(gchar **args, struct cmd_help_t help); +gboolean cmd_otr(gchar **args, struct cmd_help_t help); gboolean cmd_outtype(gchar **args, struct cmd_help_t help); gboolean cmd_prefs(gchar **args, struct cmd_help_t help); gboolean cmd_priority(gchar **args, struct cmd_help_t help); |