Store connection configuration as key value pairs

Add migration for the sqlite database.
Because the Qt SQL library is a bit hard to work with use sqlite through custom wrapper.
This commit is contained in:
eelke 2025-02-22 19:59:24 +01:00
parent 4caccf1000
commit aac55b0ed1
17 changed files with 276439 additions and 384 deletions

View file

@ -2,11 +2,10 @@
#include "MasterController.h"
#include "ConnectionManagerWindow.h"
#include "ConnectionListModel.h"
#include "PasswordManager.h"
#include "utils/PasswordManager.h"
#include "DatabaseWindow.h"
#include "BackupDialog.h"
#include "PasswordPromptDialog.h"
#include "ScopeGuard.h"
#include "ConnectionConfigurationWidget.h"
#include <QSqlQuery>
#include <QInputDialog>
@ -133,11 +132,14 @@ void ConnectionController::addGroup()
auto result = QInputDialog::getText(nullptr, tr("Add new connection group"),
tr("Group name"));
if (!result.isEmpty()) {
auto res = m_connectionTreeModel->addGroup(result);
if (std::holds_alternative<QSqlError>(res)) {
try
{
m_connectionTreeModel->addGroup(result);
}
catch (const SQLiteException &ex) {
QMessageBox::critical(nullptr, tr("Add group failed"),
tr("Failed to add group.\n") +
std::get<QSqlError>(res).text());
QString(ex.what()));
}
}
}
@ -236,19 +238,11 @@ bool ConnectionController::decodeConnectionPassword(QUuid id, QByteArray encoded
void ConnectionController::resetPasswordManager()
{
auto&& user_cfg_db = m_masterController->userConfigDatabase();
user_cfg_db.transaction();
try
{
m_passwordManager->resetMasterPassword(user_cfg_db);
m_connectionTreeModel->clearAllPasswords();
user_cfg_db.commit();
}
catch (...)
{
user_cfg_db.rollback();
throw;
}
SQLiteConnection& user_cfg_db = m_masterController->userConfigDatabase();
SQLiteTransaction tx(user_cfg_db);
m_passwordManager->resetMasterPassword(user_cfg_db);
m_connectionTreeModel->clearAllPasswords();
tx.Commit();
}
bool ConnectionController::UnlockPasswordManagerIfNeeded()