made error output in the same style
- some code style refactoring
This commit is contained in:
parent
ddc3fe7807
commit
480b2181f0
13 changed files with 92 additions and 135 deletions
|
@ -47,9 +47,9 @@ void AdvancedServerSettingsLogic::onPushButtonClearServer()
|
|||
ErrorCode e = m_serverController->removeAllContainers(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
|
||||
m_serverController->disconnectFromHost(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
|
||||
if (e) {
|
||||
uiLogic()->set_dialogConnectErrorText(tr("Error occurred while configuring server.") + "\n" +
|
||||
errorString(e) + "\n" + tr("See logs for details."));
|
||||
emit uiLogic()->showConnectErrorDialog();
|
||||
emit uiLogic()->showWarningMessage(tr("Error occurred while configuring server.") + "\n" +
|
||||
tr("Error message: ") + errorString(e) + "\n" +
|
||||
tr("See logs for details."));
|
||||
} else {
|
||||
set_labelWaitInfoVisible(true);
|
||||
set_labelWaitInfoText(tr("Amnezia server successfully uninstalled"));
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace amnezia;
|
||||
|
@ -96,10 +95,8 @@ void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
|||
if (ok) {
|
||||
emit uiLogic()->goToPage(Page::Vpn);
|
||||
emit uiLogic()->setStartPage(Page::Vpn);
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(nullptr, APPLICATION_NAME,
|
||||
tr("Can't import config, file is corrupted."));
|
||||
} else {
|
||||
emit uiLogic()->showWarningMessage(tr("Can't import config, file is corrupted."));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "core/errorstrings.h"
|
||||
#include <QTimer>
|
||||
#include <QEventLoop>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "core/servercontroller.h"
|
||||
|
||||
|
@ -142,9 +141,6 @@ ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function<Er
|
|||
if (waitInfo.setVisibleFunc) {
|
||||
waitInfo.setVisibleFunc(false);
|
||||
}
|
||||
QMessageBox::warning(nullptr, APPLICATION_NAME,
|
||||
tr("Error occurred while configuring server.") + "\n" +
|
||||
errorString(e));
|
||||
|
||||
progress.setVisibleFunc(false);
|
||||
return e;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "../uilogic.h"
|
||||
#include "../pages_logic/VpnLogic.h"
|
||||
#include "vpnconnection.h"
|
||||
#include "core/errorstrings.h"
|
||||
|
||||
|
||||
ServerContainersLogic::ServerContainersLogic(UiLogic *logic, QObject *parent):
|
||||
|
@ -87,24 +88,33 @@ void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int p
|
|||
emit uiLogic()->goToPage(Page::ServerConfiguringProgress);
|
||||
qApp->processEvents();
|
||||
|
||||
uiLogic()->getInstalledContainers(false); //todo its work like should be?
|
||||
|
||||
ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex);
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(false, credentials);
|
||||
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
if (!uiLogic()->isContainerAlreadyAddedToGui(c, credentials)) {
|
||||
auto installAction = [this, c, &config]() {
|
||||
return m_serverController->setupContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), c, config);
|
||||
};
|
||||
ErrorCode error = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction);
|
||||
errorCode = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction);
|
||||
|
||||
if (error == ErrorCode::NoError) {
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, c, config);
|
||||
if (ContainerProps::containerService(c) == ServiceType::Vpn) {
|
||||
m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, c);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
emit uiLogic()->showWarningMessage("Attention! The container you are trying to install is already installed on the server. "
|
||||
"All installed containers have been added to the application ");
|
||||
}
|
||||
|
||||
uiLogic()->onUpdateAllPages();
|
||||
}
|
||||
if (errorCode != ErrorCode::NoError) {
|
||||
emit uiLogic()->showWarningMessage(tr("Error occurred while configuring server.") + "\n" +
|
||||
tr("Error message: ") + errorString(errorCode) + "\n" +
|
||||
tr("See logs for details."));
|
||||
}
|
||||
emit uiLogic()->closePage();
|
||||
}
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_labelWaitInfoVisible{true},
|
||||
m_pushButtonClearVisible{true},
|
||||
m_pushButtonClearClientCacheVisible{true},
|
||||
m_pushButtonShareFullVisible{true},
|
||||
m_pushButtonClearText{tr("Clear server from Amnezia software")},
|
||||
m_pushButtonClearClientCacheText{tr("Clear client cached profile")}
|
||||
{ }
|
||||
|
||||
|
@ -27,7 +25,6 @@ void ServerSettingsLogic::onUpdatePage()
|
|||
{
|
||||
set_labelWaitInfoVisible(false);
|
||||
set_labelWaitInfoText("");
|
||||
set_pushButtonClearVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex));
|
||||
set_pushButtonClearClientCacheVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex));
|
||||
set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex));
|
||||
const QJsonObject &server = m_settings->server(uiLogic()->m_selectedServerIndex);
|
||||
|
@ -50,36 +47,6 @@ void ServerSettingsLogic::onUpdatePage()
|
|||
set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName);
|
||||
}
|
||||
|
||||
void ServerSettingsLogic::onPushButtonClearServer()
|
||||
{
|
||||
set_pageEnabled(false);
|
||||
set_pushButtonClearText(tr("Uninstalling Amnezia software..."));
|
||||
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex) {
|
||||
uiLogic()->pageLogic<VpnLogic>()->onDisconnect();
|
||||
}
|
||||
|
||||
ErrorCode e = m_serverController->removeAllContainers(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
|
||||
m_serverController->disconnectFromHost(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
|
||||
if (e) {
|
||||
uiLogic()->set_dialogConnectErrorText(
|
||||
tr("Error occurred while configuring server.") + "\n" +
|
||||
errorString(e) + "\n" +
|
||||
tr("See logs for details."));
|
||||
emit uiLogic()->showConnectErrorDialog();
|
||||
}
|
||||
else {
|
||||
set_labelWaitInfoVisible(true);
|
||||
set_labelWaitInfoText(tr("Amnezia server successfully uninstalled"));
|
||||
}
|
||||
|
||||
m_settings->setContainers(uiLogic()->m_selectedServerIndex, {});
|
||||
m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, DockerContainer::None);
|
||||
|
||||
set_pageEnabled(true);
|
||||
set_pushButtonClearText(tr("Clear server from Amnezia software"));
|
||||
}
|
||||
|
||||
void ServerSettingsLogic::onPushButtonForgetServer()
|
||||
{
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
|
||||
|
|
|
@ -16,9 +16,7 @@ class ServerSettingsLogic : public PageLogicBase
|
|||
|
||||
AUTO_PROPERTY(bool, labelWaitInfoVisible)
|
||||
AUTO_PROPERTY(QString, labelWaitInfoText)
|
||||
AUTO_PROPERTY(QString, pushButtonClearText)
|
||||
AUTO_PROPERTY(QString, pushButtonClearClientCacheText)
|
||||
AUTO_PROPERTY(bool, pushButtonClearVisible)
|
||||
AUTO_PROPERTY(bool, pushButtonClearClientCacheVisible)
|
||||
AUTO_PROPERTY(bool, pushButtonShareFullVisible)
|
||||
AUTO_PROPERTY(QString, labelServerText)
|
||||
|
@ -28,7 +26,6 @@ class ServerSettingsLogic : public PageLogicBase
|
|||
public:
|
||||
Q_INVOKABLE void onUpdatePage() override;
|
||||
|
||||
Q_INVOKABLE void onPushButtonClearServer();
|
||||
Q_INVOKABLE void onPushButtonForgetServer();
|
||||
Q_INVOKABLE void onPushButtonShareFullClicked();
|
||||
Q_INVOKABLE void onPushButtonClearClientCacheClicked();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include <QBuffer>
|
||||
#include <QImage>
|
||||
#include <QDataStream>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qrcodegen.hpp"
|
||||
|
||||
|
@ -218,9 +217,9 @@ void ShareConnectionLogic::onPushButtonShareWireGuardGenerateClicked()
|
|||
ErrorCode e = ErrorCode::NoError;
|
||||
QString cfg = m_configurator->wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, &e);
|
||||
if (e) {
|
||||
QMessageBox::warning(nullptr, APPLICATION_NAME,
|
||||
tr("Error occurred while configuring server.") + "\n" +
|
||||
errorString(e));
|
||||
emit uiLogic()->showWarningMessage(tr("Error occurred while generating the config.") + "\n" +
|
||||
tr("Error message: ") + errorString(e) + "\n" +
|
||||
tr("See logs for details."));
|
||||
return;
|
||||
}
|
||||
cfg = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::WireGuard, cfg);
|
||||
|
|
|
@ -50,6 +50,5 @@ public:
|
|||
QList<QString> genQrCodeImageSeries(const QByteArray &data);
|
||||
|
||||
QString svgToBase64(const QString &image);
|
||||
|
||||
};
|
||||
#endif // SHARE_CONNECTION_LOGIC_H
|
||||
|
|
|
@ -92,7 +92,6 @@ PageBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Logo {
|
||||
id : logo
|
||||
anchors.bottom: parent.bottom
|
||||
|
|
|
@ -128,7 +128,6 @@ PageBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Logo {
|
||||
id : logo
|
||||
anchors.bottom: parent.bottom
|
||||
|
|
|
@ -242,12 +242,6 @@ Window {
|
|||
text: qsTr("It's public key. Private key required")
|
||||
visible: false
|
||||
}
|
||||
MessageDialog {
|
||||
id: connectErrorDialog
|
||||
title: "AmneziaVPN"
|
||||
text: UiLogic.dialogConnectErrorText
|
||||
visible: false
|
||||
}
|
||||
|
||||
Drawer {
|
||||
id: drawer_log
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <QJsonObject>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
#include <QSysInfo>
|
||||
#include <QThread>
|
||||
|
@ -326,11 +325,8 @@ void UiLogic::installServer(QMap<DockerContainer, QJsonObject> &containers)
|
|||
pageLogic<ServerConfiguringProgressLogic>()->set_pushButtonCancelVisible(visible);
|
||||
};
|
||||
|
||||
ErrorCode error = getInstalledContainers(true);
|
||||
if (error != ErrorCode::NoError) {
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorCode errorCode = addAlreadyInstalledContainersGui(true, m_installCredentials);
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
int count = 0;
|
||||
bool isSomethingInstalled = false;
|
||||
for (QMap<DockerContainer, QJsonObject>::iterator i = containers.begin(); i != containers.end(); i++, count++) {
|
||||
|
@ -344,15 +340,16 @@ void UiLogic::installServer(QMap<DockerContainer, QJsonObject> &containers)
|
|||
auto installAction = [&] () {
|
||||
return m_serverController->setupContainer(m_installCredentials, i.key(), i.value());
|
||||
};
|
||||
error = pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction, pageFunc, progressBarFunc,
|
||||
errorCode = pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction, pageFunc, progressBarFunc,
|
||||
noButton, waitInfoFunc,
|
||||
busyInfoFunc, cancelButtonFunc);
|
||||
|
||||
m_serverController->disconnectFromHost(m_installCredentials);
|
||||
}
|
||||
|
||||
if (error == ErrorCode::NoError) {
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
if (!isSomethingInstalled) {
|
||||
onUpdateAllPages();
|
||||
emit showWarningMessage("Attention! The container you are trying to install is already installed on the server. "
|
||||
"All installed containers have been added to the application ");
|
||||
emit setStartPage(Page::Vpn);
|
||||
|
@ -379,10 +376,14 @@ void UiLogic::installServer(QMap<DockerContainer, QJsonObject> &containers)
|
|||
|
||||
emit setStartPage(Page::Vpn);
|
||||
qApp->processEvents();
|
||||
} else {
|
||||
emit closePage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
emit showWarningMessage(tr("Error occurred while configuring server.") + "\n" +
|
||||
tr("Error message: ") + errorString(errorCode) + "\n" +
|
||||
tr("See logs for details."));
|
||||
emit closePage();
|
||||
}
|
||||
|
||||
PageProtocolLogicBase *UiLogic::protocolLogic(Proto p)
|
||||
{
|
||||
|
@ -520,45 +521,45 @@ void UiLogic::registerPagesLogic()
|
|||
registerPageLogic<AdvancedServerSettingsLogic>();
|
||||
}
|
||||
|
||||
ErrorCode UiLogic::getInstalledContainers(bool addNewServerToGui)
|
||||
ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool createNewServer, const ServerCredentials& credentials)
|
||||
{
|
||||
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||
ErrorCode errorCode = m_serverController->getAlreadyInstalledContainers(m_installCredentials, installedContainers);
|
||||
ErrorCode errorCode = m_serverController->getAlreadyInstalledContainers(credentials, installedContainers);
|
||||
m_serverController->disconnectFromHost(credentials);
|
||||
if (errorCode != ErrorCode::NoError) {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
QJsonObject server;
|
||||
QJsonArray containerConfigs;
|
||||
if (addNewServerToGui) {
|
||||
server.insert(config_key::hostName, m_installCredentials.hostName);
|
||||
server.insert(config_key::userName, m_installCredentials.userName);
|
||||
server.insert(config_key::password, m_installCredentials.password);
|
||||
server.insert(config_key::port, m_installCredentials.port);
|
||||
if (createNewServer) {
|
||||
server.insert(config_key::hostName, credentials.hostName);
|
||||
server.insert(config_key::userName, credentials.userName);
|
||||
server.insert(config_key::password, credentials.password);
|
||||
server.insert(config_key::port, credentials.port);
|
||||
server.insert(config_key::description, m_settings->nextAvailableServerName());
|
||||
}
|
||||
|
||||
for (auto container = installedContainers.begin(); container != installedContainers.end(); container++) {
|
||||
if (isContainerAlreadyAddedToGui(container.key(), m_installCredentials)) {
|
||||
if (isContainerAlreadyAddedToGui(container.key(), credentials)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (addNewServerToGui) {
|
||||
if (createNewServer) {
|
||||
containerConfigs.append(container.value());
|
||||
server.insert(config_key::containers, containerConfigs);
|
||||
|
||||
} else {
|
||||
m_settings->setContainerConfig(m_selectedServerIndex, container.key(), container.value());
|
||||
m_settings->setDefaultContainer(m_selectedServerIndex, installedContainers.firstKey());
|
||||
}
|
||||
}
|
||||
|
||||
if (addNewServerToGui) {
|
||||
if (createNewServer) {
|
||||
server.insert(config_key::defaultContainer, ContainerProps::containerToString(installedContainers.firstKey()));
|
||||
m_settings->addServer(server);
|
||||
m_settings->setDefaultServer(m_settings->serversCount() - 1);
|
||||
}
|
||||
|
||||
onUpdateAllPages();
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ class UiLogic : public QObject
|
|||
AUTO_PROPERTY(bool, pageEnabled)
|
||||
AUTO_PROPERTY(int, pagesStackDepth)
|
||||
AUTO_PROPERTY(int, currentPageValue)
|
||||
AUTO_PROPERTY(QString, dialogConnectErrorText)
|
||||
AUTO_PROPERTY(QString, popupWarningText)
|
||||
|
||||
READONLY_PROPERTY(QObject *, containersModel)
|
||||
|
@ -115,7 +114,7 @@ public:
|
|||
Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data);
|
||||
Q_INVOKABLE void copyToClipboard(const QString& text);
|
||||
|
||||
Q_INVOKABLE amnezia::ErrorCode getInstalledContainers(bool addNewServerToGui);
|
||||
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool createNewServer, const ServerCredentials& credentials);
|
||||
|
||||
void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue