From 46e7f0d69db376cf45b354fef69ecba1e4636805 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sat, 12 Jun 2021 19:57:20 +0200 Subject: Emit needsSave when required --- lib/connection.cpp | 3 +-- lib/crypto/qolmaccount.cpp | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/connection.cpp b/lib/connection.cpp index ab5e030b..aaa17cdd 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -460,13 +460,12 @@ void Connection::Private::completeSetup(const QString& mxId) connect(olmAccount.get(), &QOlmAccount::needsSave, q, [=](){ auto pickle = olmAccount->pickle(Unencrypted{}); AccountSettings(data->userId()).setEncryptionAccountPickle(std::get(pickle)); + //TODO handle errors }); if (accountSettings.encryptionAccountPickle().isEmpty()) { // create new account and save unpickle data olmAccount->createNewAccount(); - accountSettings.setEncryptionAccountPickle(std::get(olmAccount->pickle(Unencrypted{}))); - // TODO handle pickle errors auto job = q->callApi(olmAccount->deviceKeys()); connect(job, &BaseJob::failure, q, [=]{ qCWarning(E2EE) << "Failed to upload device keys:" << job->errorString(); diff --git a/lib/crypto/qolmaccount.cpp b/lib/crypto/qolmaccount.cpp index 44959ac2..3c1f4bd3 100644 --- a/lib/crypto/qolmaccount.cpp +++ b/lib/crypto/qolmaccount.cpp @@ -68,6 +68,7 @@ void QOlmAccount::createNewAccount() if (error == olm_error()) { throw lastError(m_account); } + Q_EMIT needsSave(); } void QOlmAccount::unpickle(QByteArray &pickled, const PicklingMode &mode) @@ -218,6 +219,7 @@ std::optional QOlmAccount::removeOneTimeKeys(const std::unique_ptr, QOlmError> QOlmAccount::createOutboun void QOlmAccount::markKeysAsPublished() { olm_account_mark_keys_as_published(m_account); + Q_EMIT needsSave(); } bool Quotient::verifyIdentitySignature(const DeviceKeys &deviceKeys, -- cgit v1.2.3