aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTobias Fella <9750016+TobiasFella@users.noreply.github.com>2022-05-18 22:02:50 +0200
committerGitHub <noreply@github.com>2022-05-18 22:02:50 +0200
commitc671867a0a3e2a6ad0e7ae6e93fa09467c06188f (patch)
tree6c8605a54480ec85b385e25f263d775d0dbfaead /lib
parent89d8f6c44f86a27df28b1d89a80564fb0d4d89fc (diff)
downloadlibquotient-c671867a0a3e2a6ad0e7ae6e93fa09467c06188f.tar.gz
libquotient-c671867a0a3e2a6ad0e7ae6e93fa09467c06188f.zip
Apply suggestions from code review
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp7
-rw-r--r--lib/connection.h2
-rw-r--r--lib/database.cpp3
-rw-r--r--lib/events/encryptedfile.cpp2
-rw-r--r--lib/room.h2
5 files changed, 7 insertions, 9 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index a5615f64..66e21a2a 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -33,7 +33,6 @@
#include "jobs/downloadfilejob.h"
#include "jobs/mediathumbnailjob.h"
#include "jobs/syncjob.h"
-#include <variant>
#ifdef Quotient_E2EE_ENABLED
# include "database.h"
@@ -2242,7 +2241,7 @@ bool Connection::isKnownCurveKey(const QString& user, const QString& curveKey)
bool Connection::hasOlmSession(User* user, const QString& deviceId) const
{
const auto& curveKey = curveKeyForUserDevice(user->id(), deviceId);
- return d->olmSessions.contains(curveKey) && d->olmSessions[curveKey].size() > 0;
+ return d->olmSessions.contains(curveKey) && !d->olmSessions[curveKey].empty();
}
QPair<QOlmMessage::Type, QByteArray> Connection::olmEncryptMessage(User* user, const QString& device, const QByteArray& message)
@@ -2254,9 +2253,9 @@ QPair<QOlmMessage::Type, QByteArray> Connection::olmEncryptMessage(User* user, c
if (pickle) {
database()->updateOlmSession(curveKey, d->olmSessions[curveKey][0]->sessionId(), *pickle);
} else {
- qCWarning(E2EE) << "Failed to pickle olm session.";
+ qCWarning(E2EE) << "Failed to pickle olm session: " << pickle.error();
}
- return qMakePair(type, result.toCiphertext());
+ return { type, result.toCiphertext() };
}
void Connection::createOlmSession(const QString& theirIdentityKey, const QString& theirOneTimeKey)
diff --git a/lib/connection.h b/lib/connection.h
index 5a1f1e5c..5b266aad 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -134,7 +134,7 @@ class QUOTIENT_API Connection : public QObject {
public:
using UsersToDevicesToEvents =
- UnorderedMap<QString, UnorderedMap<QString, std::unique_ptr<Event>>>;
+ UnorderedMap<QString, UnorderedMap<QString, EventPtr>>;
enum RoomVisibility {
PublishRoom,
diff --git a/lib/database.cpp b/lib/database.cpp
index 87275e1f..99c6f358 100644
--- a/lib/database.cpp
+++ b/lib/database.cpp
@@ -9,7 +9,6 @@
#include <QtCore/QStandardPaths>
#include <QtCore/QDebug>
#include <QtCore/QDir>
-#include <ctime>
#include "e2ee/e2ee.h"
#include "e2ee/qolmsession.h"
@@ -140,7 +139,7 @@ void Database::migrateTo4()
execute(QStringLiteral("CREATE TABLE sent_megolm_sessions (roomId TEXT, userId TEXT, deviceId TEXT, identityKey TEXT, sessionId TEXT, i INTEGER);"));
execute(QStringLiteral("ALTER TABLE outbound_megolm_sessions ADD creationTime TEXT;"));
execute(QStringLiteral("ALTER TABLE outbound_megolm_sessions ADD messageCount INTEGER;"));
- execute(QStringLiteral("PRAGMA user_version = 3;"));
+ execute(QStringLiteral("PRAGMA user_version = 4;"));
commit();
}
diff --git a/lib/events/encryptedfile.cpp b/lib/events/encryptedfile.cpp
index bb4e26c7..d35ee28f 100644
--- a/lib/events/encryptedfile.cpp
+++ b/lib/events/encryptedfile.cpp
@@ -75,7 +75,7 @@ std::pair<EncryptedFile, QByteArray> EncryptedFile::encryptFile(const QByteArray
EncryptedFile file = {{}, key, ivBase64.left(ivBase64.indexOf('=')), {{QStringLiteral("sha256"), hash.left(hash.indexOf('='))}}, "v2"_ls};
return {file, cipherText};
#else
- return {{}, {}};
+ return {};
#endif
}
diff --git a/lib/room.h b/lib/room.h
index d5a8366a..b1201a6c 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -999,7 +999,7 @@ Q_SIGNALS:
void newFileTransfer(QString id, QUrl localFile);
void fileTransferProgress(QString id, qint64 progress, qint64 total);
- void fileTransferCompleted(QString id, QUrl localFile, QUrl mxcUrl, Omittable<EncryptedFile> encryptedFile = std::nullopt);
+ void fileTransferCompleted(QString id, QUrl localFile, QUrl mxcUrl, Omittable<EncryptedFile> encryptedFile = none);
void fileTransferFailed(QString id, QString errorMessage = {});
// fileTransferCancelled() is no more here; use fileTransferFailed() and
// check the transfer status instead