1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Add OMEMO end command

This commit is contained in:
Paul Fariello 2019-03-19 17:10:20 +01:00
parent 9a66e74986
commit bc541cb8ac
4 changed files with 46 additions and 0 deletions

View File

@ -579,6 +579,7 @@ cmd_ac_init(void)
omemo_ac = autocomplete_new(); omemo_ac = autocomplete_new();
autocomplete_add(omemo_ac, "gen"); autocomplete_add(omemo_ac, "gen");
autocomplete_add(omemo_ac, "start"); autocomplete_add(omemo_ac, "start");
autocomplete_add(omemo_ac, "end");
autocomplete_add(omemo_ac, "trust"); autocomplete_add(omemo_ac, "trust");
autocomplete_add(omemo_ac, "untrust"); autocomplete_add(omemo_ac, "untrust");
autocomplete_add(omemo_ac, "fingerprint"); autocomplete_add(omemo_ac, "fingerprint");

View File

@ -2335,6 +2335,7 @@ static struct cmd_t command_defs[] =
CMD_SUBFUNCS( CMD_SUBFUNCS(
{ "gen", cmd_omemo_gen }, { "gen", cmd_omemo_gen },
{ "start", cmd_omemo_start }, { "start", cmd_omemo_start },
{ "end", cmd_omemo_end },
{ "trust", cmd_omemo_trust }, { "trust", cmd_omemo_trust },
{ "untrust", cmd_omemo_untrust }, { "untrust", cmd_omemo_untrust },
{ "fingerprint", cmd_omemo_fingerprint }) { "fingerprint", cmd_omemo_fingerprint })
@ -2346,12 +2347,14 @@ static struct cmd_t command_defs[] =
"/omemo gen", "/omemo gen",
"/omemo start [<contact>]", "/omemo start [<contact>]",
"/omemo trust [<contact>] <fingerprint>", "/omemo trust [<contact>] <fingerprint>",
"/omemo end",
"/omemo fingerprint") "/omemo fingerprint")
CMD_DESC( CMD_DESC(
"Omemo commands to manage keys, and perform encryption during chat sessions.") "Omemo commands to manage keys, and perform encryption during chat sessions.")
CMD_ARGS( CMD_ARGS(
{ "gen", "Generate OMEMO crytographic materials for current account." }, { "gen", "Generate OMEMO crytographic materials for current account." },
{ "start [<contact>]", "Start an OMEMO session with contact, or current recipient if omitted." }, { "start [<contact>]", "Start an OMEMO session with contact, or current recipient if omitted." },
{ "end", "End the current OMEMO session," },
{ "fingerprint", "Show current device fingerprint." }) { "fingerprint", "Show current device fingerprint." })
CMD_EXAMPLES( CMD_EXAMPLES(
"/omemo gen", "/omemo gen",

View File

@ -7995,6 +7995,47 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args)
#endif #endif
} }
gboolean
cmd_omemo_end(ProfWin *window, const char *const command, gchar **args)
{
#ifdef HAVE_OMEMO
if (connection_get_status() != JABBER_CONNECTED) {
cons_show("You must be connected with an account to load OMEMO information.");
return TRUE;
}
if (window->type == WIN_CHAT) {
ProfChatWin *chatwin = (ProfChatWin*)window;
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
if (!chatwin->is_omemo) {
win_println(window, THEME_DEFAULT, '!', "You are not currently in an OMEMO session.");
return TRUE;
}
chatwin->is_omemo = FALSE;
} else if (window->type == WIN_MUC) {
ProfMucWin *mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
if (!mucwin->is_omemo) {
win_println(window, THEME_DEFAULT, '!', "You are not currently in an OMEMO session.");
return TRUE;
}
mucwin->is_omemo = FALSE;
} else {
win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session.");
return TRUE;
}
return TRUE;
#else
cons_show("This version of Profanity has not been built with OMEMO support enabled");
return TRUE;
#endif
}
gboolean gboolean
cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args)
{ {

View File

@ -216,6 +216,7 @@ gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);
gboolean cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_start(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_start(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_end(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args);