mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
fix: various fixes (#2662)
* fix: fixed dns processing * fix: fixed proceesed index/id selection * refactor: stop using the server index as state * fix: fixed autostart and start minimized * fix: fixed typo * fix: add socks5 extractConfigFromContainer * fix: remove unused currentContainerUpdated * fix: fixed clear cached profile order
This commit is contained in:
@@ -65,6 +65,7 @@ SubscriptionUiController::SubscriptionUiController(ServersController* serversCon
|
||||
ApiCountryModel* apiCountryModel,
|
||||
ApiDevicesModel* apiDevicesModel,
|
||||
SettingsController* settingsController,
|
||||
ConnectionController* connectionController,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
m_serversController(serversController),
|
||||
@@ -76,13 +77,29 @@ SubscriptionUiController::SubscriptionUiController(ServersController* serversCon
|
||||
m_apiAccountInfoModel(apiAccountInfoModel),
|
||||
m_apiCountryModel(apiCountryModel),
|
||||
m_apiDevicesModel(apiDevicesModel),
|
||||
m_settingsController(settingsController)
|
||||
m_settingsController(settingsController),
|
||||
m_connectionController(connectionController)
|
||||
{
|
||||
connect(m_apiServicesModel, &ApiServicesModel::serviceSelectionChanged, this, [this]() {
|
||||
ApiServicesModel::ApiServicesData selectedServiceData = m_apiServicesModel->selectedServiceData();
|
||||
m_apiSubscriptionPlansModel->updateModel(selectedServiceData.subscriptionPlansJson);
|
||||
m_apiBenefitsModel->updateModel(selectedServiceData.benefits);
|
||||
});
|
||||
|
||||
connect(this, &SubscriptionUiController::installServerFromApiFinished, this,
|
||||
[this](const QString &, int preferredDefaultServerIndex) {
|
||||
if (m_connectionController->isConnected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int selectedServerIndex = preferredDefaultServerIndex >= 0
|
||||
? preferredDefaultServerIndex
|
||||
: (m_serversController->getServersCount() - 1);
|
||||
const QString serverId = m_serversController->getServerId(selectedServerIndex);
|
||||
if (!serverId.isEmpty()) {
|
||||
m_serversController->setDefaultServer(serverId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool SubscriptionUiController::exportVpnKey(const QString &serverId, const QString &fileName)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "core/controllers/serversController.h"
|
||||
#include "core/controllers/settingsController.h"
|
||||
#include "core/controllers/connectionController.h"
|
||||
#include "core/controllers/api/servicesCatalogController.h"
|
||||
#include "core/controllers/api/subscriptionController.h"
|
||||
#include "ui/models/api/apiSubscriptionPlansModel.h"
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
ApiCountryModel* apiCountryModel,
|
||||
ApiDevicesModel* apiDevicesModel,
|
||||
SettingsController* settingsController,
|
||||
ConnectionController* connectionController,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
Q_PROPERTY(QList<QString> qrCodes READ getQrCodes NOTIFY vpnKeyExportReady)
|
||||
@@ -104,6 +106,7 @@ private:
|
||||
ApiCountryModel* m_apiCountryModel;
|
||||
ApiDevicesModel* m_apiDevicesModel;
|
||||
SettingsController* m_settingsController;
|
||||
ConnectionController* m_connectionController;
|
||||
};
|
||||
|
||||
#endif // SUBSCRIPTIONUICONTROLLER_H
|
||||
|
||||
@@ -44,7 +44,6 @@ signals:
|
||||
void connectionStateChanged();
|
||||
|
||||
void connectionErrorOccurred(ErrorCode errorCode);
|
||||
void reconnectWithUpdatedContainer(const QString &message);
|
||||
|
||||
void connectButtonClicked();
|
||||
void preparingConfig();
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "core/utils/api/apiUtils.h"
|
||||
#include "core/controllers/selfhosted/installController.h"
|
||||
#include "core/controllers/connectionController.h"
|
||||
#include "core/utils/networkUtilities.h"
|
||||
#include "core/utils/protocolEnum.h"
|
||||
#include "core/protocols/protocolUtils.h"
|
||||
@@ -51,6 +52,7 @@ InstallUiController::InstallUiController(InstallController *installController,
|
||||
Socks5ProxyConfigModel *socks5ConfigModel,
|
||||
MtProxyConfigModel* mtConfigModel,
|
||||
TelemtConfigModel *telemtConfigModel,
|
||||
ConnectionController *connectionController,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
m_installController(installController),
|
||||
@@ -69,7 +71,8 @@ InstallUiController::InstallUiController(InstallController *installController,
|
||||
m_sftpConfigModel(sftpConfigModel),
|
||||
m_socks5ConfigModel(socks5ConfigModel),
|
||||
m_mtProxyConfigModel(mtConfigModel),
|
||||
m_telemtConfigModel(telemtConfigModel)
|
||||
m_telemtConfigModel(telemtConfigModel),
|
||||
m_connectionController(connectionController)
|
||||
{
|
||||
connect(m_installController, &InstallController::configValidated, this, &InstallUiController::configValidated);
|
||||
connect(m_installController, &InstallController::validationErrorOccurred, this, [this](ErrorCode errorCode) {
|
||||
@@ -133,6 +136,10 @@ void InstallUiController::install(DockerContainer container, int port, Transport
|
||||
finishMessage += tr("\nAdded containers that were already installed on the server");
|
||||
}
|
||||
|
||||
if (!m_connectionController->isConnected()) {
|
||||
m_serversController->setDefaultServer(newServerId);
|
||||
}
|
||||
|
||||
emit installServerFinished(finishMessage);
|
||||
} else {
|
||||
const auto adminBefore = m_serversController->selfHostedAdminConfig(serverId);
|
||||
@@ -172,7 +179,12 @@ void InstallUiController::install(DockerContainer container, int port, Transport
|
||||
"All installed containers have been added to the application");
|
||||
}
|
||||
|
||||
emit installContainerFinished(finishMessage, ContainerUtils::containerService(container) == ServiceType::Other);
|
||||
const bool isServiceInstall = ContainerUtils::containerService(container) == ServiceType::Other;
|
||||
if (!m_connectionController->isConnected() && !isServiceInstall) {
|
||||
m_serversController->setDefaultContainer(serverId, container);
|
||||
}
|
||||
|
||||
emit installContainerFinished(finishMessage, isServiceInstall);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,15 +288,7 @@ void InstallUiController::updateContainer(const QString &serverId, int container
|
||||
const ContainerConfig updatedConfig =
|
||||
m_serversController->getContainerConfig(serverId, container);
|
||||
m_protocolModel->updateModel(updatedConfig);
|
||||
|
||||
const auto defaultContainer =
|
||||
m_serversController->getDefaultContainer(serverId);
|
||||
if ((serverId == m_serversController->getDefaultServerId())
|
||||
&& (container == defaultContainer)) {
|
||||
emit currentContainerUpdated();
|
||||
} else {
|
||||
emit updateContainerFinished(tr("Settings updated successfully"), closePage);
|
||||
}
|
||||
emit updateContainerFinished(tr("Settings updated successfully"), closePage);
|
||||
} else {
|
||||
emit installationErrorOccurred(errorCode);
|
||||
}
|
||||
@@ -307,13 +311,7 @@ void InstallUiController::updateContainer(const QString &serverId, int container
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
ContainerConfig updatedConfig = m_serversController->getContainerConfig(serverId, container);
|
||||
m_protocolModel->updateModel(updatedConfig);
|
||||
|
||||
const auto defaultContainer = m_serversController->getDefaultContainer(serverId);
|
||||
if ((serverId == m_serversController->getDefaultServerId()) && (container == defaultContainer)) {
|
||||
emit currentContainerUpdated();
|
||||
} else {
|
||||
emit updateContainerFinished(tr("Settings updated successfully"), closePage);
|
||||
}
|
||||
emit updateContainerFinished(tr("Settings updated successfully"), closePage);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -517,6 +515,12 @@ void InstallUiController::setEncryptedPassphrase(QString passphrase)
|
||||
void InstallUiController::addEmptyServer()
|
||||
{
|
||||
m_installController->addEmptyServer(m_processedServerCredentials);
|
||||
if (!m_connectionController->isConnected()) {
|
||||
const QString newServerId = m_serversController->getServerId(m_serversController->getServersCount() - 1);
|
||||
if (!newServerId.isEmpty()) {
|
||||
m_serversController->setDefaultServer(newServerId);
|
||||
}
|
||||
}
|
||||
emit installServerFinished(tr("Server added successfully"));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "core/utils/protocolEnum.h"
|
||||
#include "core/controllers/serversController.h"
|
||||
#include "core/controllers/settingsController.h"
|
||||
#include "core/controllers/connectionController.h"
|
||||
#include "core/controllers/selfhosted/usersController.h"
|
||||
#include "core/controllers/selfhosted/installController.h"
|
||||
#include "core/utils/errorCodes.h"
|
||||
@@ -52,6 +53,7 @@ public:
|
||||
Socks5ProxyConfigModel* socks5ConfigModel,
|
||||
MtProxyConfigModel* mtConfigModel,
|
||||
TelemtConfigModel* telemtConfigModel,
|
||||
ConnectionController* connectionController,
|
||||
QObject *parent = nullptr);
|
||||
~InstallUiController();
|
||||
|
||||
@@ -127,8 +129,6 @@ signals:
|
||||
void serverIsBusy(const bool isBusy);
|
||||
void cancelInstallation();
|
||||
|
||||
void currentContainerUpdated();
|
||||
|
||||
void cachedProfileCleared(const QString &message);
|
||||
void apiConfigRemoved(const QString &message);
|
||||
|
||||
@@ -155,6 +155,7 @@ private:
|
||||
Socks5ProxyConfigModel* m_socks5ConfigModel;
|
||||
MtProxyConfigModel* m_mtProxyConfigModel;
|
||||
TelemtConfigModel* m_telemtConfigModel;
|
||||
ConnectionController* m_connectionController;
|
||||
|
||||
ServerCredentials m_processedServerCredentials;
|
||||
|
||||
|
||||
@@ -31,6 +31,12 @@ bool descriptionsHaveGatewayServers(const QVector<ServerDescription> &list)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const ServerDescription &emptyServerDescription()
|
||||
{
|
||||
static const ServerDescription s_emptyDescription;
|
||||
return s_emptyDescription;
|
||||
}
|
||||
} // namespace
|
||||
ServersUiController::ServersUiController(ServersController* serversController,
|
||||
SettingsController* settingsController,
|
||||
@@ -100,8 +106,6 @@ void ServersUiController::setDefaultServer(const QString &serverId)
|
||||
return;
|
||||
}
|
||||
m_serversController->setDefaultServer(serverId);
|
||||
updateModel();
|
||||
emit defaultServerIdChanged(serverId);
|
||||
}
|
||||
|
||||
void ServersUiController::setDefaultContainer(const QString &serverId, int containerIndex)
|
||||
@@ -120,12 +124,12 @@ void ServersUiController::toggleAmneziaDns(bool enabled)
|
||||
updateModel();
|
||||
}
|
||||
|
||||
void ServersUiController::onDefaultServerChanged(const QString &/*defaultServerId*/)
|
||||
void ServersUiController::onDefaultServerChanged(const QString &defaultServerId)
|
||||
{
|
||||
updateModel();
|
||||
setProcessedServerId(m_serversController->getDefaultServerId());
|
||||
m_serversModel->setDefaultServerId(defaultServerId);
|
||||
updateDefaultServerContainersModel();
|
||||
emit defaultServerIdChanged(m_serversController->getDefaultServerId());
|
||||
|
||||
emit defaultServerIdChanged(defaultServerId);
|
||||
}
|
||||
|
||||
void ServersUiController::updateModel()
|
||||
@@ -136,27 +140,21 @@ void ServersUiController::updateModel()
|
||||
const QString defaultServerId = m_serversController->getDefaultServerId();
|
||||
const bool hadServersFromGatewayBefore = descriptionsHaveGatewayServers(m_orderedServerDescriptions);
|
||||
const bool hasServersFromGatewayNow = descriptionsHaveGatewayServers(descriptions);
|
||||
const int listCount = descriptions.size();
|
||||
const int defaultRowInDescriptions = rowForServerId(descriptions, defaultServerId);
|
||||
|
||||
m_orderedServerDescriptions = descriptions;
|
||||
|
||||
if (listCount == 0) {
|
||||
setProcessedServerId(QString());
|
||||
} else if (m_processedServerIndex >= listCount) {
|
||||
setProcessedServerId(defaultServerId);
|
||||
if (m_orderedServerDescriptions.isEmpty()) {
|
||||
if (!m_processedServerId.isEmpty()) {
|
||||
setProcessedServerId(QString());
|
||||
}
|
||||
} else if (!m_processedServerId.isEmpty()) {
|
||||
const int row = rowForServerId(m_orderedServerDescriptions, m_processedServerId);
|
||||
if (row < 0) {
|
||||
setProcessedServerId(defaultServerId);
|
||||
} else {
|
||||
setProcessedServerId(m_processedServerId);
|
||||
setProcessedServerId(QString());
|
||||
}
|
||||
} else if (defaultRowInDescriptions >= 0) {
|
||||
setProcessedServerId(defaultServerId);
|
||||
}
|
||||
|
||||
m_serversModel->updateModel(m_orderedServerDescriptions, defaultRowInDescriptions);
|
||||
m_serversModel->updateModel(m_orderedServerDescriptions, defaultServerId);
|
||||
|
||||
updateContainersModel();
|
||||
updateDefaultServerContainersModel();
|
||||
@@ -166,7 +164,6 @@ void ServersUiController::updateModel()
|
||||
}
|
||||
|
||||
emit defaultServerIdChanged(defaultServerId);
|
||||
emit defaultServerIndexChanged(defaultServerIndex());
|
||||
}
|
||||
|
||||
QString ServersUiController::getDefaultServerId() const
|
||||
@@ -176,60 +173,35 @@ QString ServersUiController::getDefaultServerId() const
|
||||
|
||||
QString ServersUiController::getDefaultServerName() const
|
||||
{
|
||||
const QString defaultServerId = m_serversController->getDefaultServerId();
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == defaultServerId) {
|
||||
return description.serverName;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
return serverName(getDefaultServerId());
|
||||
}
|
||||
|
||||
QString ServersUiController::getDefaultServerDefaultContainerName() const
|
||||
{
|
||||
const QString defaultServerId = m_serversController->getDefaultServerId();
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == defaultServerId) {
|
||||
return ContainerUtils::containerHumanNames().value(description.defaultContainer);
|
||||
}
|
||||
const auto &description = serverDescriptionById(getDefaultServerId());
|
||||
if (description.serverId.isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
return QString();
|
||||
return ContainerUtils::containerHumanNames().value(description.defaultContainer);
|
||||
}
|
||||
|
||||
QString ServersUiController::getDefaultServerDescriptionCollapsed() const
|
||||
{
|
||||
const QString defaultServerId = m_serversController->getDefaultServerId();
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == defaultServerId) {
|
||||
return description.collapsedServerDescription;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
return serverDescriptionById(getDefaultServerId()).collapsedServerDescription;
|
||||
}
|
||||
|
||||
QString ServersUiController::getDefaultServerImagePathCollapsed() const
|
||||
{
|
||||
const QString defaultServerId = m_serversController->getDefaultServerId();
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == defaultServerId) {
|
||||
if (!description.isApiV2 || description.apiServerCountryCode.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return QString("qrc:/countriesFlags/images/flagKit/%1.svg").arg(description.apiServerCountryCode.toUpper());
|
||||
}
|
||||
const auto &description = serverDescriptionById(getDefaultServerId());
|
||||
if (!description.isApiV2 || description.apiServerCountryCode.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
return QString("qrc:/countriesFlags/images/flagKit/%1.svg").arg(description.apiServerCountryCode.toUpper());
|
||||
}
|
||||
|
||||
QString ServersUiController::getDefaultServerDescriptionExpanded() const
|
||||
{
|
||||
const QString defaultServerId = m_serversController->getDefaultServerId();
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == defaultServerId) {
|
||||
return description.expandedServerDescription;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
return serverDescriptionById(getDefaultServerId()).expandedServerDescription;
|
||||
}
|
||||
|
||||
bool ServersUiController::isDefaultServerDefaultContainerHasSplitTunneling() const
|
||||
@@ -281,15 +253,75 @@ bool ServersUiController::isDefaultServerDefaultContainerHasSplitTunneling() con
|
||||
|
||||
bool ServersUiController::isDefaultServerFromApi() const
|
||||
{
|
||||
const QString defaultServerId = m_serversController->getDefaultServerId();
|
||||
return isServerFromApi(getDefaultServerId());
|
||||
}
|
||||
|
||||
bool ServersUiController::hasServerWithWriteAccess() const
|
||||
{
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == defaultServerId) {
|
||||
return description.isApiV2;
|
||||
if (description.hasWriteAccess) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ServersUiController::serverName(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).serverName;
|
||||
}
|
||||
|
||||
QString ServersUiController::serverHostName(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).hostName;
|
||||
}
|
||||
|
||||
int ServersUiController::serverDefaultContainer(const QString &serverId) const
|
||||
{
|
||||
const auto &description = serverDescriptionById(serverId);
|
||||
return description.serverId.isEmpty() ? -1 : static_cast<int>(description.defaultContainer);
|
||||
}
|
||||
|
||||
bool ServersUiController::isServerFromApi(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).isServerFromGatewayApi;
|
||||
}
|
||||
|
||||
bool ServersUiController::isServerCountrySelectionAvailable(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).isCountrySelectionAvailable;
|
||||
}
|
||||
|
||||
bool ServersUiController::isServerHasWriteAccess(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).hasWriteAccess;
|
||||
}
|
||||
|
||||
bool ServersUiController::serverHasInstalledContainers(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).hasInstalledVpnContainers;
|
||||
}
|
||||
|
||||
QString ServersUiController::serverAdEndpoint(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).adEndpoint;
|
||||
}
|
||||
|
||||
bool ServersUiController::isServerRenewalAvailable(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).isRenewalAvailable;
|
||||
}
|
||||
|
||||
bool ServersUiController::isServerSubscriptionExpired(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).isSubscriptionExpired;
|
||||
}
|
||||
|
||||
bool ServersUiController::isServerSubscriptionExpiringSoon(const QString &serverId) const
|
||||
{
|
||||
return serverDescriptionById(serverId).isSubscriptionExpiringSoon;
|
||||
}
|
||||
|
||||
int ServersUiController::getProcessedContainerIndex() const
|
||||
{
|
||||
return m_processedContainerIndex;
|
||||
@@ -311,27 +343,17 @@ QString ServersUiController::getProcessedServerId() const
|
||||
|
||||
void ServersUiController::setProcessedServerId(const QString &serverId)
|
||||
{
|
||||
const int index = serverId.isEmpty() ? -1 : serverIndexForId(serverId);
|
||||
if (!serverId.isEmpty() && index < 0) {
|
||||
return;
|
||||
}
|
||||
const int newIndex = serverId.isEmpty() ? -1 : serverIndexForId(serverId);
|
||||
const QString normalizedServerId = newIndex >= 0 ? serverId : QString();
|
||||
|
||||
if (m_processedServerIndex != index || m_processedServerId != serverId) {
|
||||
m_processedServerIndex = index;
|
||||
m_processedServerId = serverId;
|
||||
m_serversModel->setProcessedServerIndex(index);
|
||||
if (m_processedServerId != normalizedServerId) {
|
||||
m_processedServerId = normalizedServerId;
|
||||
|
||||
if (index >= 0) {
|
||||
if (newIndex >= 0) {
|
||||
updateContainersModel();
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == serverId) {
|
||||
setProcessedContainerIndex(static_cast<int>(description.defaultContainer));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId != serverId) {
|
||||
if (description.serverId != normalizedServerId) {
|
||||
continue;
|
||||
}
|
||||
if (description.isApiV2) {
|
||||
@@ -345,45 +367,12 @@ void ServersUiController::setProcessedServerId(const QString &serverId)
|
||||
}
|
||||
|
||||
emit processedServerIdChanged(m_processedServerId);
|
||||
emit processedServerIndexChanged(m_processedServerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
int ServersUiController::getProcessedServerIndex() const
|
||||
{
|
||||
return m_processedServerIndex;
|
||||
}
|
||||
|
||||
void ServersUiController::setProcessedServerIndex(int index)
|
||||
{
|
||||
if (index < 0) {
|
||||
setProcessedServerId(QString());
|
||||
return;
|
||||
}
|
||||
const QString id = getServerId(index);
|
||||
if (!id.isEmpty()) {
|
||||
setProcessedServerId(id);
|
||||
}
|
||||
}
|
||||
|
||||
int ServersUiController::defaultServerIndex() const
|
||||
{
|
||||
return rowForServerId(m_orderedServerDescriptions, getDefaultServerId());
|
||||
}
|
||||
|
||||
bool ServersUiController::processedServerIsPremium() const
|
||||
{
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == m_processedServerId) {
|
||||
return description.isPremium;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const ServerCredentials ServersUiController::getProcessedServerCredentials() const
|
||||
{
|
||||
return m_serversController->getServerCredentials(m_processedServerId);
|
||||
return processedServerDescription().isPremium;
|
||||
}
|
||||
|
||||
bool ServersUiController::isDefaultServerCurrentlyProcessed() const
|
||||
@@ -393,18 +382,22 @@ bool ServersUiController::isDefaultServerCurrentlyProcessed() const
|
||||
|
||||
bool ServersUiController::isProcessedServerHasWriteAccess() const
|
||||
{
|
||||
ServerCredentials credentials = m_serversController->getServerCredentials(m_processedServerId);
|
||||
return (!credentials.userName.isEmpty() && !credentials.secretData.isEmpty());
|
||||
return isServerHasWriteAccess(m_processedServerId);
|
||||
}
|
||||
|
||||
QString ServersUiController::getDefaultServerDescription(const QString &serverId) const
|
||||
const ServerDescription &ServersUiController::processedServerDescription() const
|
||||
{
|
||||
return serverDescriptionById(m_processedServerId);
|
||||
}
|
||||
|
||||
const ServerDescription &ServersUiController::serverDescriptionById(const QString &serverId) const
|
||||
{
|
||||
for (const auto &description : m_orderedServerDescriptions) {
|
||||
if (description.serverId == serverId) {
|
||||
return description.baseDescription;
|
||||
return description;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
return emptyServerDescription();
|
||||
}
|
||||
|
||||
bool ServersUiController::hasServersFromGatewayApi() const
|
||||
@@ -467,6 +460,11 @@ int ServersUiController::getServerIndexById(const QString &serverId) const
|
||||
return rowForServerId(m_orderedServerDescriptions, serverId);
|
||||
}
|
||||
|
||||
int ServersUiController::getServersCount() const
|
||||
{
|
||||
return m_orderedServerDescriptions.size();
|
||||
}
|
||||
|
||||
void ServersUiController::updateContainersModel()
|
||||
{
|
||||
if (m_processedServerId.isEmpty()) {
|
||||
|
||||
@@ -19,7 +19,6 @@ class ServersUiController : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString defaultServerId READ getDefaultServerId NOTIFY defaultServerIdChanged)
|
||||
Q_PROPERTY(int defaultServerIndex READ defaultServerIndex NOTIFY defaultServerIndexChanged)
|
||||
|
||||
Q_PROPERTY(QString defaultServerName READ getDefaultServerName NOTIFY defaultServerIdChanged)
|
||||
Q_PROPERTY(QString defaultServerDefaultContainerName READ getDefaultServerDefaultContainerName NOTIFY defaultServerIdChanged)
|
||||
@@ -30,9 +29,8 @@ class ServersUiController : public QObject
|
||||
Q_PROPERTY(bool isDefaultServerFromApi READ isDefaultServerFromApi NOTIFY defaultServerIdChanged)
|
||||
|
||||
Q_PROPERTY(QString processedServerId READ getProcessedServerId WRITE setProcessedServerId NOTIFY processedServerIdChanged)
|
||||
Q_PROPERTY(int processedServerIndex READ getProcessedServerIndex WRITE setProcessedServerIndex NOTIFY processedServerIndexChanged)
|
||||
Q_PROPERTY(int processedContainerIndex READ getProcessedContainerIndex WRITE setProcessedContainerIndex NOTIFY processedContainerIndexChanged)
|
||||
Q_PROPERTY(bool processedServerIsPremium READ processedServerIsPremium NOTIFY processedServerIndexChanged)
|
||||
Q_PROPERTY(bool processedServerIsPremium READ processedServerIsPremium NOTIFY processedServerIdChanged)
|
||||
|
||||
Q_PROPERTY(bool hasServersFromGatewayApi READ hasServersFromGatewayApi NOTIFY hasServersFromGatewayApiChanged)
|
||||
|
||||
@@ -72,20 +70,27 @@ public slots:
|
||||
QString getDefaultServerDescriptionExpanded() const;
|
||||
bool isDefaultServerDefaultContainerHasSplitTunneling() const;
|
||||
bool isDefaultServerFromApi() const;
|
||||
bool hasServerWithWriteAccess() const;
|
||||
|
||||
QString serverName(const QString &serverId) const;
|
||||
QString serverHostName(const QString &serverId) const;
|
||||
int serverDefaultContainer(const QString &serverId) const;
|
||||
bool isServerFromApi(const QString &serverId) const;
|
||||
bool isServerCountrySelectionAvailable(const QString &serverId) const;
|
||||
bool isServerHasWriteAccess(const QString &serverId) const;
|
||||
bool serverHasInstalledContainers(const QString &serverId) const;
|
||||
QString serverAdEndpoint(const QString &serverId) const;
|
||||
bool isServerRenewalAvailable(const QString &serverId) const;
|
||||
bool isServerSubscriptionExpired(const QString &serverId) const;
|
||||
bool isServerSubscriptionExpiringSoon(const QString &serverId) const;
|
||||
|
||||
QString getProcessedServerId() const;
|
||||
void setProcessedServerId(const QString &serverId);
|
||||
|
||||
int getProcessedServerIndex() const;
|
||||
void setProcessedServerIndex(int index);
|
||||
|
||||
int defaultServerIndex() const;
|
||||
|
||||
int getProcessedContainerIndex() const;
|
||||
void setProcessedContainerIndex(int index);
|
||||
bool processedServerIsPremium() const;
|
||||
|
||||
const ServerCredentials getProcessedServerCredentials() const;
|
||||
bool isDefaultServerCurrentlyProcessed() const;
|
||||
bool isProcessedServerHasWriteAccess() const;
|
||||
|
||||
@@ -97,15 +102,14 @@ public slots:
|
||||
|
||||
QString getServerId(int index) const;
|
||||
int getServerIndexById(const QString &serverId) const;
|
||||
int getServersCount() const;
|
||||
QStringList getAllInstalledServicesName(int serverIndex) const;
|
||||
|
||||
signals:
|
||||
void errorOccurred(const QString &errorMessage);
|
||||
void finished(const QString &message);
|
||||
void defaultServerIdChanged(const QString &serverId);
|
||||
void defaultServerIndexChanged(int index);
|
||||
void processedServerIdChanged(const QString &serverId);
|
||||
void processedServerIndexChanged(int index);
|
||||
void processedContainerIndexChanged(int index);
|
||||
void hasServersFromGatewayApiChanged();
|
||||
void updateApiCountryModel();
|
||||
@@ -115,7 +119,8 @@ public:
|
||||
void updateModel();
|
||||
|
||||
private:
|
||||
QString getDefaultServerDescription(const QString &serverId) const;
|
||||
const ServerDescription &serverDescriptionById(const QString &serverId) const;
|
||||
const ServerDescription &processedServerDescription() const;
|
||||
int serverIndexForId(const QString &serverId) const;
|
||||
bool listHasServersFromGatewayApi() const;
|
||||
|
||||
@@ -130,7 +135,6 @@ private:
|
||||
|
||||
QVector<amnezia::ServerDescription> m_orderedServerDescriptions;
|
||||
|
||||
int m_processedServerIndex = -1;
|
||||
QString m_processedServerId;
|
||||
int m_processedContainerIndex = -1;
|
||||
};
|
||||
|
||||
@@ -164,6 +164,7 @@ void SettingsUiController::restoreAppConfigFromData(const QByteArray &data)
|
||||
emit amneziaDnsToggled(amneziaDnsEnabled);
|
||||
|
||||
emit restoreBackupFinished();
|
||||
emit startMinimizedChanged();
|
||||
} else {
|
||||
emit errorOccurred(errorCode);
|
||||
}
|
||||
@@ -177,6 +178,7 @@ QString SettingsUiController::getAppVersion()
|
||||
void SettingsUiController::clearSettings()
|
||||
{
|
||||
m_settingsController->clearSettings();
|
||||
emit startMinimizedChanged();
|
||||
emit resetLanguageToSystem();
|
||||
|
||||
emit changeSettingsFinished(tr("All settings have been reset to default values"));
|
||||
@@ -204,6 +206,9 @@ bool SettingsUiController::isAutoStartEnabled()
|
||||
void SettingsUiController::toggleAutoStart(bool enable)
|
||||
{
|
||||
m_settingsController->toggleAutoStart(enable);
|
||||
if (!enable) {
|
||||
emit startMinimizedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingsUiController::isStartMinimizedEnabled()
|
||||
|
||||
Reference in New Issue
Block a user