Move OMEMO initialization to profanity intialization

Also store identity keys into account
This commit is contained in:
Paul Fariello
2019-02-19 20:03:50 +01:40
parent 519cf295f3
commit 2602cbf785
9 changed files with 47 additions and 19 deletions

View File

@@ -2333,19 +2333,22 @@ static struct cmd_t command_defs[] =
{ "/omemo",
parse_args, 1, 3, NULL,
CMD_SUBFUNCS(
{ "init", cmd_omemo_init })
{ "gen", cmd_omemo_gen })
CMD_NOMAINFUNC
CMD_TAGS(
CMD_TAG_CHAT,
CMD_TAG_UI)
CMD_SYN(
"/omemo init")
"/omemo gen",
"/omemo start [<contact>]")
CMD_DESC(
"Omemo commands to manage keys, and perform encryption during chat sessions.")
CMD_ARGS(
{ "init", "Initialize omemo" })
{ "gen", "Generate OMEMO crytographic materials for current account." },
{ "start [<contact>]", "Start an OMEMO session with contact, or current recipient if omitted." })
CMD_EXAMPLES(
"/omemo init")
"/omemo gen",
"/omemo start buddy@buddychat.org")
},
};

View File

@@ -85,7 +85,7 @@
#include "pgp/gpg.h"
#endif
#ifdef HAVE_LIBSIGNAL_PROTOCOL
#ifdef HAVE_OMEMO
#include "omemo/omemo.h"
#endif
@@ -7878,20 +7878,19 @@ _cmd_set_boolean_preference(gchar *arg, const char *const command,
}
gboolean
cmd_omemo_init(ProfWin *window, const char *const command, gchar **args)
cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args)
{
#ifdef HAVE_LIBSIGNAL_PROTOCOL
#ifdef HAVE_OMEMO
if (connection_get_status() != JABBER_CONNECTED) {
cons_show("You must be connected with an account to initialize omemo");
cons_show("You must be connected with an account to initialize OMEMO");
return TRUE;
}
ProfAccount *account = accounts_get_account(session_get_account_name());
omemo_init(account);
cons_show("Initialized omemo");
omemo_generate_crypto_materials(account);
return TRUE;
#else
cons_show("This version of Profanity has not been built with Omemo support enabled");
cons_show("This version of Profanity has not been built with OMEMO support enabled");
return TRUE;
#endif
}

View File

@@ -214,6 +214,6 @@ gboolean cmd_wins_swap(ProfWin *window, const char *const command, gchar **args)
gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);
gboolean cmd_omemo_init(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_gen(ProfWin *window, const char *const command, gchar **args);
#endif