mirror of
https://github.com/outbackdingo/amnezia-client.git
synced 2026-01-27 02:18:09 +00:00
fixed error handling for config import
This commit is contained in:
@@ -79,7 +79,7 @@ bool ImportController::extractConfigFromFile(const QString &fileName)
|
||||
return extractConfigFromData(data);
|
||||
}
|
||||
|
||||
emit importErrorOccurred(tr("Unable to open file"));
|
||||
emit importErrorOccurred(tr("Unable to open file"), false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ bool ImportController::extractConfigFromData(QString data)
|
||||
if (!m_serversModel->getServersCount()) {
|
||||
emit restoreAppConfig(config.toUtf8());
|
||||
} else {
|
||||
emit importErrorOccurred(tr("Invalid configuration file"));
|
||||
emit importErrorOccurred(tr("Invalid configuration file"), false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ConfigTypes::Invalid: {
|
||||
emit importErrorOccurred(tr("Invalid configuration file"));
|
||||
emit importErrorOccurred(tr("Invalid configuration file"), false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -257,6 +257,7 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
||||
} else {
|
||||
qDebug() << "Key parameter 'Endpoint' is missing";
|
||||
emit importErrorOccurred(errorString(ErrorCode::ImportInvalidConfigError), false);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
if (hostNameAndPortMatch.hasCaptured(2)) {
|
||||
@@ -282,7 +283,7 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
||||
lastConfig[config_key::server_pub_key] = configMap.value("PublicKey");
|
||||
} else {
|
||||
qDebug() << "One of the key parameters is missing (PrivateKey, Address, PublicKey)";
|
||||
emit importErrorOccurred(errorString(ErrorCode::ImportInvalidConfigError));
|
||||
emit importErrorOccurred(errorString(ErrorCode::ImportInvalidConfigError), false);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ public slots:
|
||||
signals:
|
||||
void importFinished();
|
||||
void importErrorOccurred(const QString &errorMessage, bool goToPageHome);
|
||||
void importErrorOccurred(const QString &errorMessage);
|
||||
|
||||
void qrDecodingFinished();
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ PageType {
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
|
||||
function onImportErrorOccurred(errorMessage) {
|
||||
function onImportErrorOccurred(errorMessage, goToPageHome) {
|
||||
PageController.showErrorMessage(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ PageType {
|
||||
} else {
|
||||
PageController.closePage()
|
||||
}
|
||||
PageController.showErrorMessage(errorMessage)
|
||||
}
|
||||
|
||||
function onImportFinished() {
|
||||
|
||||
@@ -124,7 +124,7 @@ PageType {
|
||||
Connections {
|
||||
target: ImportController
|
||||
|
||||
function onImportErrorOccurred(errorMessage) {
|
||||
function onImportErrorOccurred(errorMessage, goToPageHome) {
|
||||
PageController.showErrorMessage(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user