[network/ruqola] src/core/localdatabase: Continue to implement database
Laurent Montel <[email protected]> Wed, 5 Aug 2026 05:29:20 +0000 (UTC)
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 8126ecf39c561eb2fb6aa4136348b7fa8b5606d4 by Laurent Montel.
Committed on 05/08/2026 at 05:27.
Pushed by mlaurent into branch 'master'.
Continue to implement database
M +2 -1 src/core/localdatabase/autotests/e2eroomsdatabasetest.cpp
M +2 -2 src/core/localdatabase/e2edatabase.cpp
M +9 -9 src/core/localdatabase/e2eroomsdatabase.cpp
https://invent.kde.org/network/ruqola/-/commit/8126ecf39c561eb2fb6aa4136348b7fa8b5606d4
diff --git a/src/core/localdatabase/autotests/e2eroomsdatabasetest.cpp b/src/core/localdatabase/autotests/e2eroomsdatabasetest.cpp
index 38cc7794f6..e59b8e4442 100644
--- a/src/core/localdatabase/autotests/e2eroomsdatabasetest.cpp
+++ b/src/core/localdatabase/autotests/e2eroomsdatabasetest.cpp
@@ -27,7 +27,8 @@ void E2ERoomsDataBaseTest::initTestCase()
void E2ERoomsDataBaseTest::shouldDefaultValues()
{
E2ERoomsDataBase E2ERoomsDataBase;
- QCOMPARE(E2ERoomsDataBase.schemaDatabaseStr(), u"CREATE TABLE E2EKEYS (userId TEXT PRIMARY KEY NOT NULL, encryptedPrivateKey BLOB, publicKey BLOB)"_s);
+ QCOMPARE(E2ERoomsDataBase.schemaDatabaseStr(),
+ u"CREATE TABLE E2EROOMSKEYS (roomKeyId TEXT PRIMARY KEY NOT NULL, encryptedPrivateKey BLOB, publicKey BLOB)"_s);
}
void E2ERoomsDataBaseTest::testSaveLoadDelete()
diff --git a/src/core/localdatabase/e2edatabase.cpp b/src/core/localdatabase/e2edatabase.cpp
index 5b4eb832fe..ebbcc5cba5 100644
--- a/src/core/localdatabase/e2edatabase.cpp
+++ b/src/core/localdatabase/e2edatabase.cpp
@@ -14,7 +14,7 @@
#include <QSqlTableModel>
using namespace Qt::Literals::StringLiterals;
static const char s_schemaE2EKeyStore[] = "CREATE TABLE E2EKEYS (userId TEXT PRIMARY KEY NOT NULL, encryptedPrivateKey BLOB, publicKey BLOB)";
-enum class E2EFields {
+enum class E2ERoomsFields {
UserId,
EncryptedPrivateKey,
PublicKey
@@ -118,7 +118,7 @@ std::unique_ptr<QSqlTableModel> E2EDataBase::createE2eModel(const QString &accou
Q_ASSERT(db.isOpen());
auto model = std::make_unique<QSqlTableModel>(nullptr, db);
model->setTable(u"E2EKEYS"_s);
- model->setSort(int(E2EFields::UserId), Qt::AscendingOrder);
+ model->setSort(int(E2ERoomsFields::UserId), Qt::AscendingOrder);
model->select();
return model;
}
diff --git a/src/core/localdatabase/e2eroomsdatabase.cpp b/src/core/localdatabase/e2eroomsdatabase.cpp
index 618f1bd1ae..a1b422fded 100644
--- a/src/core/localdatabase/e2eroomsdatabase.cpp
+++ b/src/core/localdatabase/e2eroomsdatabase.cpp
@@ -13,9 +13,9 @@
#include <QSqlQuery>
#include <QSqlTableModel>
using namespace Qt::Literals::StringLiterals;
-static const char s_schemaE2ERoomsKeysStore[] = "CREATE TABLE E2EROOMSKEYS (userId TEXT PRIMARY KEY NOT NULL, encryptedPrivateKey BLOB, publicKey BLOB)";
-enum class E2EFields {
- UserId,
+static const char s_schemaE2ERoomsKeysStore[] = "CREATE TABLE E2EROOMSKEYS (roomKeyId TEXT PRIMARY KEY NOT NULL, encryptedPrivateKey BLOB, publicKey BLOB)";
+enum class E2ERoomsFields {
+ RoomKeyId,
EncryptedPrivateKey,
PublicKey
}; // in the same order as the table
@@ -39,7 +39,7 @@ bool E2ERoomsDataBase::saveKey(const QString &accountName, const QString &userId
return false;
}
QSqlQuery query(db);
- query.prepare(QStringLiteral("INSERT OR REPLACE INTO E2EROOMSKEYS (userId, encryptedPrivateKey, publicKey) VALUES (?, ?, ?)"));
+ query.prepare(QStringLiteral("INSERT OR REPLACE INTO E2EROOMSKEYS (roomKeyId, encryptedPrivateKey, publicKey) VALUES (?, ?, ?)"));
query.addBindValue(userId);
query.addBindValue(encryptedPrivateKey);
query.addBindValue(publicKey);
@@ -57,7 +57,7 @@ bool E2ERoomsDataBase::loadKey(const QString &accountName, const QString &userId
return false;
}
QSqlQuery query(db);
- query.prepare(QStringLiteral("SELECT encryptedPrivateKey, publicKey FROM E2EROOMSKEYS WHERE userId = ?"));
+ query.prepare(QStringLiteral("SELECT encryptedPrivateKey, publicKey FROM E2EROOMSKEYS WHERE roomKeyId = ?"));
query.addBindValue(userId);
if (query.exec() && query.first()) {
encryptedPrivateKey = query.value(0).toByteArray();
@@ -74,10 +74,10 @@ bool E2ERoomsDataBase::deleteKey(const QString &accountName, const QString &user
return false;
}
QSqlQuery query(db);
- query.prepare(QStringLiteral("DELETE FROM E2EROOMSKEYS WHERE userId = ?"));
+ query.prepare(QStringLiteral("DELETE FROM E2EROOMSKEYS WHERE roomKeyId = ?"));
query.addBindValue(userId);
if (!query.exec()) {
- qCWarning(RUQOLA_DATABASE_LOG) << "Couldn't delete from E2EKEYS table" << db.databaseName() << query.lastError();
+ qCWarning(RUQOLA_DATABASE_LOG) << "Couldn't delete from E2EROOMSKEYS table" << db.databaseName() << query.lastError();
return false;
}
return true;
@@ -90,7 +90,7 @@ bool E2ERoomsDataBase::hasKey(const QString &accountName, const QString &userId)
return false;
}
QSqlQuery query(db);
- query.prepare(QStringLiteral("SELECT 1 FROM E2EROOMSKEYS WHERE userId = ?"));
+ query.prepare(QStringLiteral("SELECT 1 FROM E2EROOMSKEYS WHERE roomKeyId = ?"));
query.addBindValue(userId);
return query.exec() && query.first();
}
@@ -118,7 +118,7 @@ std::unique_ptr<QSqlTableModel> E2ERoomsDataBase::createE2eRoomsModel(const QStr
Q_ASSERT(db.isOpen());
auto model = std::make_unique<QSqlTableModel>(nullptr, db);
model->setTable(u"E2EROOMSKEYS"_s);
- model->setSort(int(E2EFields::UserId), Qt::AscendingOrder);
+ model->setSort(int(E2ERoomsFields::RoomKeyId), Qt::AscendingOrder);
model->select();
return model;
}