diff options
author | James Booth <boothj5@gmail.com> | 2013-08-14 22:27:44 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-08-14 22:27:44 +0100 |
commit | bc82a7d0f804a5ad42ac41be6c41eddc3cf65582 (patch) | |
tree | eb479cca40131ce69361526bb2bc769e4f031980 /src/otr.c | |
parent | 10f556f4127c248d0a25a97d03a0731c554cfa1a (diff) | |
download | profani-tty-bc82a7d0f804a5ad42ac41be6c41eddc3cf65582.tar.gz |
Load keys and fingerprints for account on connect
Diffstat (limited to 'src/otr.c')
-rw-r--r-- | src/otr.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/otr.c b/src/otr.c index 7dd6aafd..6b10e3be 100644 --- a/src/otr.c +++ b/src/otr.c @@ -21,15 +21,52 @@ */ #include <libotr/proto.h> -#include <libotr/userstate.h> -#include <libotr/message.h> #include <libotr/privkey.h> +#include <glib.h> +#include "otr.h" #include "ui/ui.h" +static OtrlUserState user_state; + void otr_init(void) { cons_debug("otr_init()"); OTRL_INIT; } + +void +otr_account_load(ProfAccount *account) +{ + gcry_error_t err = 0; + cons_debug("otr_account_load()"); + GString *keys_filename = g_string_new("./"); + g_string_append(keys_filename, account->jid); + g_string_append(keys_filename, "_keys.txt"); + + GString *fp_filename = g_string_new("./"); + g_string_append(fp_filename, account->jid); + g_string_append(fp_filename, "_fingerprints.txt"); + + user_state = otrl_userstate_create(); + + err = otrl_privkey_read(user_state, keys_filename->str); + if (err != 0) { + cons_debug("Failed to load private keys"); + g_string_free(keys_filename, TRUE); + g_string_free(fp_filename, TRUE); + return; + } + + err = otrl_privkey_read_fingerprints(user_state, fp_filename->str, NULL, NULL); + if (err != 0) { + cons_debug("Failed to load fingerprints"); + g_string_free(keys_filename, TRUE); + g_string_free(fp_filename, TRUE); + return; + } + + g_string_free(keys_filename, TRUE); + g_string_free(fp_filename, TRUE); +} |