Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into HEAD

This commit is contained in:
vladimir.kuznetsov 2023-12-13 14:21:51 +07:00
commit a91ab0e910
12 changed files with 41 additions and 12 deletions

View file

@ -634,9 +634,9 @@ QString ServerController::checkSshConnection(const ServerCredentials &credential
return stdOut; return stdOut;
} }
void ServerController::setCancelInstallation(const bool cancel) void ServerController::cancelInstallation()
{ {
m_cancelInstallation = cancel; m_cancelInstallation = true;
} }
ErrorCode ServerController::setupServerFirewall(const ServerCredentials &credentials) ErrorCode ServerController::setupServerFirewall(const ServerCredentials &credentials)
@ -737,6 +737,7 @@ ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, D
ErrorCode ServerController::isServerDpkgBusy(const ServerCredentials &credentials, DockerContainer container) ErrorCode ServerController::isServerDpkgBusy(const ServerCredentials &credentials, DockerContainer container)
{ {
m_cancelInstallation = false;
QString stdOut; QString stdOut;
auto cbReadStdOut = [&](const QString &data, libssh::Client &) { auto cbReadStdOut = [&](const QString &data, libssh::Client &) {
stdOut += data + "\n"; stdOut += data + "\n";
@ -784,7 +785,6 @@ ErrorCode ServerController::isServerDpkgBusy(const ServerCredentials &credential
watcher.setFuture(future); watcher.setFuture(future);
wait.exec(); wait.exec();
m_cancelInstallation = false;
emit serverIsBusy(false); emit serverIsBusy(false);
return future.result(); return future.result();

View file

@ -56,7 +56,7 @@ public:
QString checkSshConnection(const ServerCredentials &credentials, ErrorCode *errorCode = nullptr); QString checkSshConnection(const ServerCredentials &credentials, ErrorCode *errorCode = nullptr);
void setCancelInstallation(const bool cancel); void cancelInstallation();
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey, ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey,
const std::function<QString()> &callback); const std::function<QString()> &callback);

View file

@ -108,6 +108,8 @@ void ConnectionController::onCurrentContainerUpdated()
if (m_isConnected || m_isConnectionInProgress) { if (m_isConnected || m_isConnectionInProgress) {
emit reconnectWithUpdatedContainer(tr("Settings updated successfully, Reconnnection...")); emit reconnectWithUpdatedContainer(tr("Settings updated successfully, Reconnnection..."));
openConnection(); openConnection();
} else {
emit reconnectWithUpdatedContainer(tr("Settings updated successfully"));
} }
} }

View file

@ -130,6 +130,7 @@ void InstallController::installServer(DockerContainer container, QJsonObject &co
{ {
ServerController serverController(m_settings); ServerController serverController(m_settings);
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy); connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
QMap<DockerContainer, QJsonObject> installedContainers; QMap<DockerContainer, QJsonObject> installedContainers;
ErrorCode errorCode = ErrorCode errorCode =
@ -181,6 +182,7 @@ void InstallController::installContainer(DockerContainer container, QJsonObject
ServerController serverController(m_settings); ServerController serverController(m_settings);
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy); connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
QMap<DockerContainer, QJsonObject> installedContainers; QMap<DockerContainer, QJsonObject> installedContainers;
ErrorCode errorCode = serverController.getAlreadyInstalledContainers(serverCredentials, installedContainers); ErrorCode errorCode = serverController.getAlreadyInstalledContainers(serverCredentials, installedContainers);
@ -274,6 +276,7 @@ void InstallController::updateContainer(QJsonObject config)
ServerController serverController(m_settings); ServerController serverController(m_settings);
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy); connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
auto errorCode = serverController.updateContainer(serverCredentials, container, oldContainerConfig, config); auto errorCode = serverController.updateContainer(serverCredentials, container, oldContainerConfig, config);
if (errorCode == ErrorCode::NoError) { if (errorCode == ErrorCode::NoError) {

View file

@ -65,6 +65,7 @@ signals:
void passphraseRequestFinished(); void passphraseRequestFinished();
void serverIsBusy(const bool isBusy); void serverIsBusy(const bool isBusy);
void cancelInstallation();
void currentContainerUpdated(); void currentContainerUpdated();

View file

@ -312,9 +312,8 @@ PageType {
onClicked: { onClicked: {
forceActiveFocus() forceActiveFocus()
PageController.showBusyIndicator(true) PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.updateContainer(AwgConfigModel.getConfig()) InstallController.updateContainer(AwgConfigModel.getConfig())
PageController.showBusyIndicator(false)
} }
} }
} }

View file

@ -4,6 +4,8 @@ import QtQuick.Layouts
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
import PageEnum 1.0
import "./" import "./"
import "../Controls2" import "../Controls2"
import "../Controls2/TextTypes" import "../Controls2/TextTypes"
@ -160,9 +162,8 @@ PageType {
onClicked: { onClicked: {
forceActiveFocus() forceActiveFocus()
PageController.showBusyIndicator(true) PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.updateContainer(CloakConfigModel.getConfig()) InstallController.updateContainer(CloakConfigModel.getConfig())
PageController.showBusyIndicator(false)
} }
} }
} }

View file

@ -390,9 +390,8 @@ PageType {
onClicked: { onClicked: {
forceActiveFocus() forceActiveFocus()
PageController.showBusyIndicator(true) PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.updateContainer(OpenVpnConfigModel.getConfig()) InstallController.updateContainer(OpenVpnConfigModel.getConfig())
PageController.showBusyIndicator(false)
} }
} }
} }

View file

@ -4,6 +4,8 @@ import QtQuick.Layouts
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
import PageEnum 1.0
import "./" import "./"
import "../Controls2" import "../Controls2"
import "../Controls2/TextTypes" import "../Controls2/TextTypes"
@ -138,9 +140,8 @@ PageType {
onClicked: { onClicked: {
forceActiveFocus() forceActiveFocus()
PageController.showBusyIndicator(true) PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.updateContainer(ShadowSocksConfigModel.getConfig()) InstallController.updateContainer(ShadowSocksConfigModel.getConfig())
PageController.showBusyIndicator(false)
} }
} }
} }

View file

@ -19,6 +19,7 @@ PageType {
property bool isTimerRunning: true property bool isTimerRunning: true
property string progressBarText: qsTr("Usually it takes no more than 5 minutes") property string progressBarText: qsTr("Usually it takes no more than 5 minutes")
property bool isCancelButtonVisible: false
Connections { Connections {
target: InstallController target: InstallController
@ -61,11 +62,13 @@ PageType {
function onServerIsBusy(isBusy) { function onServerIsBusy(isBusy) {
if (isBusy) { if (isBusy) {
root.isCancelButtonVisible = true
root.progressBarText = qsTr("Amnezia has detected that your server is currently ") + root.progressBarText = qsTr("Amnezia has detected that your server is currently ") +
qsTr("busy installing other software. Amnezia installation ") + qsTr("busy installing other software. Amnezia installation ") +
qsTr("will pause until the server finishes installing other software") qsTr("will pause until the server finishes installing other software")
root.isTimerRunning = false root.isTimerRunning = false
} else { } else {
root.isCancelButtonVisible = false
root.progressBarText = qsTr("Usually it takes no more than 5 minutes") root.progressBarText = qsTr("Usually it takes no more than 5 minutes")
root.isTimerRunning = true root.isTimerRunning = true
} }
@ -150,6 +153,22 @@ PageType {
text: root.progressBarText text: root.progressBarText
} }
BasicButtonType {
id: cancelIntallationButton
Layout.fillWidth: true
Layout.topMargin: 24
visible: root.isCancelButtonVisible
text: qsTr("Cancel installation")
onClicked: {
InstallController.cancelInstallation()
PageController.showBusyIndicator(true)
}
}
} }
} }
} }

View file

@ -60,6 +60,7 @@ PageType {
target: InstallController target: InstallController
function onInstallationErrorOccurred(errorMessage) { function onInstallationErrorOccurred(errorMessage) {
PageController.showBusyIndicator(false)
PageController.showErrorMessage(errorMessage) PageController.showErrorMessage(errorMessage)
var currentPageName = stackView.currentItem.objectName var currentPageName = stackView.currentItem.objectName

View file

@ -82,6 +82,7 @@ PageType {
target: InstallController target: InstallController
function onInstallationErrorOccurred(errorMessage) { function onInstallationErrorOccurred(errorMessage) {
PageController.showBusyIndicator(false)
PageController.showErrorMessage(errorMessage) PageController.showErrorMessage(errorMessage)
var needCloseCurrentPage = false var needCloseCurrentPage = false
@ -99,6 +100,7 @@ PageType {
function onUpdateContainerFinished(message) { function onUpdateContainerFinished(message) {
PageController.showNotificationMessage(message) PageController.showNotificationMessage(message)
PageController.closePage()
} }
} }
@ -107,6 +109,7 @@ PageType {
function onReconnectWithUpdatedContainer(message) { function onReconnectWithUpdatedContainer(message) {
PageController.showNotificationMessage(message) PageController.showNotificationMessage(message)
PageController.closePage()
} }
} }