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

Added "/otr fp" to show users fingerprint

This commit is contained in:
James Booth 2014-01-10 20:20:38 +00:00
parent 1b5254010e
commit e294a6db92
4 changed files with 27 additions and 11 deletions

View File

@ -570,10 +570,11 @@ static struct cmd_t command_defs[] =
{ "/otr", { "/otr",
cmd_otr, parse_args, 1, 2, NULL, cmd_otr, parse_args, 1, 2, NULL,
{ "/otr gen|start|end|trust|untrust [contact]", "Off The Record encryption commands.", { "/otr gen|fp", "Off The Record encryption commands.",
{ "/otr gen|start|end|trust|untrust [contact]", { "/otr gen|fp",
"-----------------------------------------", "-----------",
"gen - Load or create private key and fingerprints.", "gen - Load or create private key and fingerprints.",
"fp - Show your fingerprint.",
NULL } } }, NULL } } },
{ "/outtype", { "/outtype",

View File

@ -2287,15 +2287,19 @@ gboolean
cmd_otr(gchar **args, struct cmd_help_t help) cmd_otr(gchar **args, struct cmd_help_t help)
{ {
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
if (jabber_get_connection_status() != JABBER_CONNECTED) {
cons_show("You must be connected with an account to load OTR information.");
return TRUE;
}
if (strcmp(args[0], "gen") == 0) { if (strcmp(args[0], "gen") == 0) {
if (jabber_get_connection_status() != JABBER_CONNECTED) { ProfAccount *account = accounts_get_account(jabber_get_account_name());
cons_show("You must be connected with an account to load OTR information."); otr_account_load(account);
return TRUE; return TRUE;
} else { } else if (strcmp(args[0], "fp") == 0) {
ProfAccount *account = accounts_get_account(jabber_get_account_name()); char *fingerprint = otr_get_fingerprint();
otr_account_load(account); cons_show("Your fingerprint: %s", fingerprint);
return TRUE; return TRUE;
}
} else { } else {
cons_show("Usage: %s", help.usage); cons_show("Usage: %s", help.usage);
return TRUE; return TRUE;

View File

@ -259,6 +259,16 @@ otr_account_load(ProfAccount *account)
return; return;
} }
char *
otr_get_fingerprint(void)
{
char fingerprint[45];
otrl_privkey_fingerprint(user_state, fingerprint, jid, "xmpp");
char *result = strdup(fingerprint);
return result;
}
char * char *
otr_encrypt_message(const char * const to, const char * const message) otr_encrypt_message(const char * const to, const char * const message)
{ {

View File

@ -27,6 +27,7 @@
void otr_init(void); void otr_init(void);
void otr_account_load(ProfAccount *account); void otr_account_load(ProfAccount *account);
char * otr_get_fingerprint(void);
char * otr_encrypt_message(const char * const to, const char * const message); char * otr_encrypt_message(const char * const to, const char * const message);
char * otr_decrypt_message(const char * const from, const char * const message); char * otr_decrypt_message(const char * const from, const char * const message);
void otr_free_message(char *message); void otr_free_message(char *message);