diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-09-21 21:09:49 +0200 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-09-26 10:46:34 +0200 |
commit | 2ff045d8b381bfbd64100d083f81b61c5fe87b23 (patch) | |
tree | 00f200e7c7547df77fd034a2bad04815c6a04495 /lib/connection.cpp | |
parent | bc1ded73bedf593acda80b00eb7da32f688c4843 (diff) | |
download | libquotient-2ff045d8b381bfbd64100d083f81b61c5fe87b23.tar.gz libquotient-2ff045d8b381bfbd64100d083f81b61c5fe87b23.zip |
Wrap error reporting into facility macros
Facility macros to report Olm errors: QOLM_INTERNAL_ERROR[_X],
QOLM_FAIL_OR_LOG[_X]
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r-- | lib/connection.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index cd8ee727..0afbffbc 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -206,13 +206,9 @@ public: } void saveSession(const QOlmSession& session, const QString& senderKey) const { - if (auto pickleResult = session.pickle(picklingMode)) - q->database()->saveOlmSession(senderKey, session.sessionId(), - *pickleResult, - QDateTime::currentDateTime()); - else - qCWarning(E2EE) << "Failed to pickle olm session. Error" - << pickleResult.error(); + q->database()->saveOlmSession(senderKey, session.sessionId(), + session.pickle(picklingMode), + QDateTime::currentDateTime()); } template <typename FnT> @@ -2219,11 +2215,7 @@ void Connection::saveOlmAccount() { #ifdef Quotient_E2EE_ENABLED qCDebug(E2EE) << "Saving olm account"; - if (const auto expectedPickle = d->olmAccount->pickle(d->picklingMode)) - d->database->setAccountPickle(*expectedPickle); - else - qCWarning(E2EE) << "Couldn't save Olm account pickle:" - << expectedPickle.error(); + d->database->setAccountPickle(d->olmAccount->pickle(d->picklingMode)); #endif } @@ -2300,11 +2292,8 @@ std::pair<QOlmMessage::Type, QByteArray> Connection::Private::olmEncryptMessage( const auto& curveKey = curveKeyForUserDevice(userId, device); const auto& olmSession = olmSessions.at(curveKey).front(); const auto result = olmSession->encrypt(message); - if (const auto pickle = olmSession->pickle(picklingMode)) { - database->updateOlmSession(curveKey, olmSession->sessionId(), *pickle); - } else { - qWarning(E2EE) << "Failed to pickle olm session: " << pickle.error(); - } + database->updateOlmSession(curveKey, olmSession->sessionId(), + olmSession->pickle(picklingMode)); return { result.type(), result.toCiphertext() }; } |