diff options
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 5 | ||||
-rw-r--r-- | src/command/commands.c | 50 |
2 files changed, 54 insertions, 1 deletions
diff --git a/src/command/command.c b/src/command/command.c index 95a6158e..d7a60495 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -594,7 +594,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/otr", - cmd_otr, parse_args, 1, 2, NULL, + cmd_otr, parse_args, 1, 3, NULL, { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver|policy", "Off The Record encryption commands.", { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver|policy", "--------------------------------------------------------------------", @@ -1066,10 +1066,13 @@ cmd_init(void) autocomplete_add(otr_ac, "theirfp"); autocomplete_add(otr_ac, "trust"); autocomplete_add(otr_ac, "untrust"); + autocomplete_add(otr_ac, "secret"); autocomplete_add(otr_ac, "log"); autocomplete_add(otr_ac, "warn"); autocomplete_add(otr_ac, "libver"); autocomplete_add(otr_ac, "policy"); + autocomplete_add(otr_ac, "question"); + autocomplete_add(otr_ac, "answer"); otr_log_ac = autocomplete_new(); autocomplete_add(otr_log_ac, "on"); diff --git a/src/command/commands.c b/src/command/commands.c index 940a7f5a..ad508cc7 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2788,7 +2788,57 @@ cmd_otr(gchar **args, struct cmd_help_t help) otr_untrust(recipient); } return TRUE; + } else if (strcmp(args[0], "secret") == 0) { + win_type_t win_type = ui_current_win_type(); + if (win_type != WIN_CHAT) { + ui_current_print_line("You must be in an OTR session to trust a recipient."); + } else if (!ui_current_win_is_otr()) { + ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + } else { + char *secret = args[1]; + if (secret == NULL) { + cons_show("Usage: %s", help.usage); + } else { + char *recipient = ui_current_recipient(); + otr_smp_secret(recipient, secret); + } + } + return TRUE; + } else if (strcmp(args[0], "question") == 0) { + char *question = args[1]; + char *answer = args[2]; + if (question == NULL || answer == NULL) { + cons_show("Usage: %s", help.usage); + return TRUE; + } else { + win_type_t win_type = ui_current_win_type(); + if (win_type != WIN_CHAT) { + ui_current_print_line("You must be in an OTR session to trust a recipient."); + } else if (!ui_current_win_is_otr()) { + ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + } else { + char *recipient = ui_current_recipient(); + otr_smp_question(recipient, question, answer); + } + return TRUE; + } + } else if (strcmp(args[0], "answer") == 0) { + win_type_t win_type = ui_current_win_type(); + if (win_type != WIN_CHAT) { + ui_current_print_line("You must be in an OTR session to trust a recipient."); + } else if (!ui_current_win_is_otr()) { + ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + } else { + char *answer = args[1]; + if (answer == NULL) { + cons_show("Usage: %s", help.usage); + } else { + char *recipient = ui_current_recipient(); + otr_smp_answer(recipient, answer); + } + } + return TRUE; } else { cons_show("Usage: %s", help.usage); return TRUE; |