diff options
author | Dr. David Alan Gilbert <dave@treblig.org> | 2017-01-02 16:10:14 +0000 |
---|---|---|
committer | Dr. David Alan Gilbert <dave@treblig.org> | 2018-02-25 02:08:49 +0000 |
commit | 77a487c7eedfef3104835d09044e71939b5dcbfa (patch) | |
tree | 10143721e8eecd29d1d6bcfe041474dc7ec64af6 /matrix-connection.c | |
parent | 08b25e67e6e7189e4ba268ffe9326071adccc5e1 (diff) | |
download | purple-matrix-77a487c7eedfef3104835d09044e71939b5dcbfa.tar.gz |
e2e: Retrieve or create Olm account state, send keys
If we've got a previously stored olm account state then use it,
else create us a new one.
Either way, upload the device keys to the server.
Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Diffstat (limited to 'matrix-connection.c')
-rw-r--r-- | matrix-connection.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/matrix-connection.c b/matrix-connection.c index 91c660a..736782b 100644 --- a/matrix-connection.c +++ b/matrix-connection.c @@ -17,6 +17,7 @@ */ #include "matrix-connection.h" +#include "matrix-e2e.h" #include <string.h> @@ -53,6 +54,7 @@ void matrix_connection_free(PurpleConnection *pc) g_assert(conn != NULL); + matrix_e2e_cleanup_connection(conn); purple_connection_set_protocol_data(pc, NULL); g_free(conn->homeserver); @@ -167,6 +169,7 @@ static void _login_completed(MatrixConnectionData *conn, JsonObject *root_obj; const gchar *access_token; const gchar *next_batch; + const gchar *device_id; gboolean needs_full_state_sync = TRUE; root_obj = matrix_json_node_get_object(json_root); @@ -181,9 +184,12 @@ static void _login_completed(MatrixConnectionData *conn, conn->access_token = g_strdup(access_token); conn->user_id = g_strdup(matrix_json_object_get_string_member(root_obj, "user_id")); - purple_account_set_string(pc->account, "device_id", - matrix_json_object_get_string_member(root_obj, "device_id")); + device_id = matrix_json_object_get_string_member(root_obj, "device_id"); + purple_account_set_string(pc->account, "device_id", device_id); + if (device_id) { + matrix_e2e_get_device_keys(conn, device_id); + } /* start the sync loop */ next_batch = purple_account_get_string(pc->account, PRPL_ACCOUNT_OPT_NEXT_BATCH, NULL); |