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