From 226df215e7c5afcd22b005d3305f28cc8bacea35 Mon Sep 17 00:00:00 2001 From: Stefan Forstenlechner Date: Mon, 20 Jan 2025 23:11:24 +0100 Subject: [PATCH] Fix open remote database - Display correct error message. Wrong error message was displayed as no early return statement was used. - Use configurable timeout for opening remote database as it is done for syncing --- share/translations/keepassxc_en.ts | 8 +++++ src/gui/remote/RemoteProcess.cpp | 1 - src/gui/wizard/ImportWizardPageReview.cpp | 4 +++ src/gui/wizard/ImportWizardPageReview.h | 1 + src/gui/wizard/ImportWizardPageSelect.cpp | 3 ++ src/gui/wizard/ImportWizardPageSelect.ui | 41 ++++++++++++++++++----- 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index 0cf445a86..29efd5aa7 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -4748,6 +4748,14 @@ The command has to exit. In case of `sftp` as last commend `exit` has to be sent Remote Database (.kdbx) + + Timeout: + + + + seconds + + KMessageWidget diff --git a/src/gui/remote/RemoteProcess.cpp b/src/gui/remote/RemoteProcess.cpp index 6b2f60717..5dd8ede78 100644 --- a/src/gui/remote/RemoteProcess.cpp +++ b/src/gui/remote/RemoteProcess.cpp @@ -17,7 +17,6 @@ #include "RemoteProcess.h" -#include #include RemoteProcess::RemoteProcess(QObject* parent) diff --git a/src/gui/wizard/ImportWizardPageReview.cpp b/src/gui/wizard/ImportWizardPageReview.cpp index c7ed90fe7..4ab1bf903 100644 --- a/src/gui/wizard/ImportWizardPageReview.cpp +++ b/src/gui/wizard/ImportWizardPageReview.cpp @@ -92,6 +92,7 @@ void ImportWizardPageReview::initializePage() case ImportWizard::IMPORT_REMOTE: m_db = importRemote(field("DownloadCommand").toString(), field("DownloadInput").toString(), + field("DownloadTimeoutSec").toInt(), field("ImportPassword").toString(), field("ImportKeyFile").toString()); break; @@ -239,17 +240,20 @@ bool ImportWizardPageReview::isCsvImport() const QSharedPointer ImportWizardPageReview::importRemote(const QString& downloadCommand, const QString& downloadInput, + int downloadTimeoutSec, const QString& password, const QString& keyfile) { auto* params = new RemoteParams(); params->downloadCommand = downloadCommand; params->downloadInput = downloadInput; + params->downloadTimeoutMsec = downloadTimeoutSec * 1000; auto result = m_remoteHandler->download(params); if (!result.success) { m_ui->messageWidget->showMessage(result.errorMessage, KMessageWidget::Error, -1); + return {}; } auto key = QSharedPointer::create(); diff --git a/src/gui/wizard/ImportWizardPageReview.h b/src/gui/wizard/ImportWizardPageReview.h index 17f85a1a5..d1c010fbb 100644 --- a/src/gui/wizard/ImportWizardPageReview.h +++ b/src/gui/wizard/ImportWizardPageReview.h @@ -58,6 +58,7 @@ private: QSharedPointer importProtonPass(const QString& filename); QSharedPointer importRemote(const QString& downloadCommand, const QString& downloadInput, + int downloadTimeSec, const QString& password, const QString& keyfile); diff --git a/src/gui/wizard/ImportWizardPageSelect.cpp b/src/gui/wizard/ImportWizardPageSelect.cpp index ba5f28521..f008c24dd 100644 --- a/src/gui/wizard/ImportWizardPageSelect.cpp +++ b/src/gui/wizard/ImportWizardPageSelect.cpp @@ -76,6 +76,7 @@ ImportWizardPageSelect::ImportWizardPageSelect(QWidget* parent) registerField("ImportKeyFile", m_ui->keyFileEdit); registerField("DownloadCommand", m_ui->downloadCommand); registerField("DownloadInput", m_ui->downloadCommandInput, "plainText", "textChanged"); + registerField("DownloadTimeoutSec", m_ui->downloadTimeoutSec); } ImportWizardPageSelect::~ImportWizardPageSelect() @@ -274,6 +275,8 @@ void ImportWizardPageSelect::setDownloadCommand(bool downloadCommandEnabled) m_ui->downloadCommandInputLabel->setVisible(downloadCommandEnabled); m_ui->downloadCommandInput->setVisible(downloadCommandEnabled); m_ui->downloadCommandHelpButton->setVisible(downloadCommandEnabled); + m_ui->downloadTimeoutLabel->setVisible(downloadCommandEnabled); + m_ui->downloadTimeoutSec->setVisible(downloadCommandEnabled); m_ui->temporaryDatabaseRadio->setVisible(downloadCommandEnabled); diff --git a/src/gui/wizard/ImportWizardPageSelect.ui b/src/gui/wizard/ImportWizardPageSelect.ui index ca37fec71..ce871ef76 100644 --- a/src/gui/wizard/ImportWizardPageSelect.ui +++ b/src/gui/wizard/ImportWizardPageSelect.ui @@ -94,14 +94,14 @@ QLayout::SetMinimumSize - + Import File: - + @@ -115,24 +115,24 @@ - + Password: - + - + Key File: - + @@ -146,7 +146,7 @@ - + Qt::Vertical @@ -162,7 +162,7 @@ - + Import Into: @@ -172,7 +172,7 @@ - + @@ -297,6 +297,29 @@ The command has to exit. In case of `sftp` as last commend `exit` has to be sent + + + + Timeout: + + + + + + + seconds + + + 1 + + + 300 + + + 10 + + +