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:
parent
9a66e74986
commit
bc541cb8ac
@ -579,6 +579,7 @@ cmd_ac_init(void)
|
||||
omemo_ac = autocomplete_new();
|
||||
autocomplete_add(omemo_ac, "gen");
|
||||
autocomplete_add(omemo_ac, "start");
|
||||
autocomplete_add(omemo_ac, "end");
|
||||
autocomplete_add(omemo_ac, "trust");
|
||||
autocomplete_add(omemo_ac, "untrust");
|
||||
autocomplete_add(omemo_ac, "fingerprint");
|
||||
|
@ -2335,6 +2335,7 @@ static struct cmd_t command_defs[] =
|
||||
CMD_SUBFUNCS(
|
||||
{ "gen", cmd_omemo_gen },
|
||||
{ "start", cmd_omemo_start },
|
||||
{ "end", cmd_omemo_end },
|
||||
{ "trust", cmd_omemo_trust },
|
||||
{ "untrust", cmd_omemo_untrust },
|
||||
{ "fingerprint", cmd_omemo_fingerprint })
|
||||
@ -2346,12 +2347,14 @@ static struct cmd_t command_defs[] =
|
||||
"/omemo gen",
|
||||
"/omemo start [<contact>]",
|
||||
"/omemo trust [<contact>] <fingerprint>",
|
||||
"/omemo end",
|
||||
"/omemo fingerprint")
|
||||
CMD_DESC(
|
||||
"Omemo commands to manage keys, and perform encryption during chat sessions.")
|
||||
CMD_ARGS(
|
||||
{ "gen", "Generate OMEMO crytographic materials for current account." },
|
||||
{ "start [<contact>]", "Start an OMEMO session with contact, or current recipient if omitted." },
|
||||
{ "end", "End the current OMEMO session," },
|
||||
{ "fingerprint", "Show current device fingerprint." })
|
||||
CMD_EXAMPLES(
|
||||
"/omemo gen",
|
||||
|
@ -7995,6 +7995,47 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args)
|
||||
#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
|
||||
cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
|
@ -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_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_trust(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args);
|
||||
|
Loading…
Reference in New Issue
Block a user