diff options
author | Tobias Fella <fella@posteo.de> | 2021-11-15 21:35:11 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2021-12-01 21:56:59 +0100 |
commit | cab1c772abaf380f30a504231fc06b070feb09ec (patch) | |
tree | 2bc64ed821d986513c66cada1c420dea3b61e72e /lib/connection.cpp | |
parent | 34db4fd1294e41765a5db58ee1a0c59712af62c6 (diff) | |
download | libquotient-cab1c772abaf380f30a504231fc06b070feb09ec.tar.gz libquotient-cab1c772abaf380f30a504231fc06b070feb09ec.zip |
Save olm account on shutdown
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r-- | lib/connection.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index f36166ff..20b4a113 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -270,6 +270,9 @@ Connection::Connection(const QUrl& server, QObject* parent) { #ifdef Quotient_E2EE_ENABLED d->encryptionManager = new EncryptionManager(this); + connect(qApp, &QCoreApplication::aboutToQuit, this, [this](){ + saveOlmAccount(); + }); #endif d->q = this; // All d initialization should occur before this line } @@ -498,11 +501,8 @@ void Connection::Private::completeSetup(const QString& mxId) // init olmAccount olmAccount = std::make_unique<QOlmAccount>(data->userId(), data->deviceId(), q); - connect(olmAccount.get(), &QOlmAccount::needsSave, q, [=](){ - auto pickle = olmAccount->pickle(picklingMode); - AccountSettings(data->userId()).setEncryptionAccountPickle(std::get<QByteArray>(pickle)); - //TODO handle errors - }); + connect(olmAccount.get(), &QOlmAccount::needsSave, q, &Connection::saveOlmAccount); + encryptionManager = new EncryptionManager(q); if (accountSettings.encryptionAccountPickle().isEmpty()) { @@ -2042,3 +2042,11 @@ PicklingMode Connection::picklingMode() const return d->picklingMode; } #endif + +void Connection::saveOlmAccount() +{ + qCDebug(E2EE) << "Saving olm account"; + auto pickle = d->olmAccount->pickle(d->picklingMode); + AccountSettings(d->data->userId()).setEncryptionAccountPickle(std::get<QByteArray>(pickle)); + //TODO handle errors +} |