mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
refactor: remove serverConfig struct (#2595)
* refactor: remove serverConfig struct * refactor: add warnings for api v1 configs * refactor: moved the server type definition to a separate namespace * refactor: simplified gateway stacks * fix: fixed server description * fix: fixed postAsync reply usage * fix: fixed validateConfig call * fix: fixed server name in notifications * fix: fixed initPrepareConfigHandler for lagacy configs
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/utils/api/apiUtils.h"
|
||||
#include "core/utils/serverConfigUtils.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace
|
||||
@@ -28,7 +29,7 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
switch (role) {
|
||||
case SubscriptionStatusRole: {
|
||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||
if (m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaFreeV3) {
|
||||
return tr("Active");
|
||||
}
|
||||
|
||||
@@ -37,14 +38,14 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
: QStringLiteral("<p><a style=\"color: #28c840;\">%1</a>").arg(tr("Active"));
|
||||
}
|
||||
case EndDateRole: {
|
||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||
if (m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaFreeV3) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return QDateTime::fromString(m_accountInfoData.subscriptionEndDate, Qt::ISODate).toLocalTime().toString("d MMM yyyy");
|
||||
}
|
||||
case ConnectedDevicesRole: {
|
||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||
if (m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaFreeV3) {
|
||||
return "";
|
||||
}
|
||||
return tr("%1 out of %2").arg(m_accountInfoData.activeDeviceCount).arg(m_accountInfoData.maxDeviceCount);
|
||||
@@ -53,9 +54,8 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
return m_accountInfoData.subscriptionDescription;
|
||||
}
|
||||
case IsComponentVisibleRole: {
|
||||
return m_accountInfoData.configType == apiDefs::ConfigType::AmneziaPremiumV2
|
||||
|| m_accountInfoData.configType == apiDefs::ConfigType::ExternalPremium
|
||||
|| m_accountInfoData.configType == apiDefs::ConfigType::ExternalTrial;
|
||||
return m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaPremiumV2
|
||||
|| m_accountInfoData.configType == serverConfigUtils::ConfigType::ExternalPremium;
|
||||
}
|
||||
case IsSubscriptionRenewalAvailableRole: {
|
||||
return m_accountInfoData.isRenewalAvailable;
|
||||
@@ -80,7 +80,7 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
return false;
|
||||
}
|
||||
case IsSubscriptionExpiredRole: {
|
||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||
if (m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaFreeV3) {
|
||||
return false;
|
||||
}
|
||||
if (m_accountInfoData.isInAppPurchase) {
|
||||
@@ -92,7 +92,7 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||
return apiUtils::isSubscriptionExpired(m_accountInfoData.subscriptionEndDate);
|
||||
}
|
||||
case IsSubscriptionExpiringSoonRole: {
|
||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||
if (m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaFreeV3) {
|
||||
return false;
|
||||
}
|
||||
if (m_accountInfoData.isInAppPurchase) {
|
||||
@@ -124,7 +124,7 @@ void ApiAccountInfoModel::updateModel(const QJsonObject &accountInfoObject, cons
|
||||
accountInfoData.maxDeviceCount = accountInfoObject.value(apiDefs::key::maxDeviceCount).toInt();
|
||||
accountInfoData.subscriptionEndDate = accountInfoObject.value(apiDefs::key::subscriptionEndDate).toString();
|
||||
|
||||
accountInfoData.configType = apiUtils::getConfigType(serverConfig);
|
||||
accountInfoData.configType = serverConfigUtils::configTypeFromJson(serverConfig);
|
||||
|
||||
const QJsonObject apiConfig = serverConfig.value(apiDefs::key::apiConfig).toObject();
|
||||
accountInfoData.isInAppPurchase = apiConfig.value(apiDefs::key::isInAppPurchase).toBool(false);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/utils/api/apiEnums.h"
|
||||
#include "core/utils/serverConfigUtils.h"
|
||||
#include "core/utils/constants/apiKeys.h"
|
||||
#include "core/utils/constants/apiConstants.h"
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
int activeDeviceCount;
|
||||
int maxDeviceCount;
|
||||
|
||||
apiDefs::ConfigType configType;
|
||||
serverConfigUtils::ConfigType configType;
|
||||
|
||||
QStringList supportedProtocols;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/utils/api/apiEnums.h"
|
||||
#include "core/utils/serverConfigUtils.h"
|
||||
#include "core/utils/constants/apiKeys.h"
|
||||
#include "core/utils/constants/apiConstants.h"
|
||||
#include "logger.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/utils/api/apiEnums.h"
|
||||
#include "core/utils/serverConfigUtils.h"
|
||||
#include "core/utils/constants/apiKeys.h"
|
||||
#include "core/utils/constants/apiConstants.h"
|
||||
#include "logger.h"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include "serversModel.h"
|
||||
|
||||
#include "core/models/serverDescription.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "core/models/serverConfig.h"
|
||||
#include "core/utils/api/apiEnums.h"
|
||||
#include "core/utils/serverConfigUtils.h"
|
||||
#include "core/utils/constants/apiKeys.h"
|
||||
#include "core/utils/constants/apiConstants.h"
|
||||
#include "core/utils/selfhosted/sshSession.h"
|
||||
@@ -19,42 +20,15 @@
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace configKey
|
||||
{
|
||||
constexpr char apiConfig[] = "api_config";
|
||||
constexpr char serviceInfo[] = "service_info";
|
||||
constexpr char availableCountries[] = "available_countries";
|
||||
constexpr char serverCountryCode[] = "server_country_code";
|
||||
constexpr char serverCountryName[] = "server_country_name";
|
||||
constexpr char userCountryCode[] = "user_country_code";
|
||||
constexpr char serviceType[] = "service_type";
|
||||
constexpr char serviceProtocol[] = "service_protocol";
|
||||
|
||||
constexpr char publicKeyInfo[] = "public_key";
|
||||
constexpr char expiresAt[] = "expires_at";
|
||||
}
|
||||
|
||||
QString normalizeVpnKey(const QString &vpnKey)
|
||||
{
|
||||
QString normalized = vpnKey.trimmed();
|
||||
if (normalized.startsWith(QStringLiteral("vpn://"), Qt::CaseInsensitive)) {
|
||||
normalized = normalized.mid(QStringLiteral("vpn://").size());
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
|
||||
ServersModel::ServersModel(QObject *parent) : QAbstractListModel(parent)
|
||||
{
|
||||
connect(this, &ServersModel::defaultServerIndexChanged, this, &ServersModel::defaultServerNameChanged);
|
||||
|
||||
connect(this, &ServersModel::defaultServerIndexChanged, this, [this](const int serverIndex) {
|
||||
if (serverIndex < 0 || serverIndex >= m_servers.size()) {
|
||||
if (serverIndex < 0 || serverIndex >= m_descriptions.size()) {
|
||||
return;
|
||||
}
|
||||
auto defaultContainer = m_servers.at(serverIndex).defaultContainer();
|
||||
auto defaultContainer = m_descriptions.at(serverIndex).defaultContainer;
|
||||
emit ServersModel::defaultServerDefaultContainerChanged(defaultContainer);
|
||||
emit ServersModel::defaultServerNameChanged();
|
||||
});
|
||||
@@ -65,148 +39,73 @@ ServersModel::ServersModel(QObject *parent) : QAbstractListModel(parent)
|
||||
int ServersModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return static_cast<int>(m_servers.size());
|
||||
return static_cast<int>(m_descriptions.size());
|
||||
}
|
||||
|
||||
QVariant ServersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0 || index.row() >= static_cast<int>(m_servers.size())) {
|
||||
if (!index.isValid() || index.row() < 0 || index.row() >= static_cast<int>(m_descriptions.size())) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
const ServerConfig &server = m_servers.at(index.row());
|
||||
const int configVersion = server.configVersion();
|
||||
|
||||
const ServerDescription &row = m_descriptions.at(index.row());
|
||||
const int configVersion = row.configVersion;
|
||||
|
||||
switch (role) {
|
||||
case NameRole: {
|
||||
if (configVersion) {
|
||||
if (server.isApiV1()) {
|
||||
return server.as<ApiV1ServerConfig>()->name;
|
||||
} else if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->name;
|
||||
}
|
||||
}
|
||||
QString name = server.description();
|
||||
if (name.isEmpty()) {
|
||||
return server.hostName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
case ServerDescriptionRole: {
|
||||
auto description = getServerDescription(server, index.row());
|
||||
return configVersion ? description : description + server.hostName();
|
||||
}
|
||||
case HostNameRole: return server.hostName();
|
||||
case CredentialsRole: return QVariant::fromValue(serverCredentials(index.row()));
|
||||
case CredentialsLoginRole: return serverCredentials(index.row()).userName;
|
||||
case IsDefaultRole: return index.row() == m_defaultServerIndex;
|
||||
case IsCurrentlyProcessedRole: return index.row() == m_processedServerIndex;
|
||||
case HasWriteAccessRole: {
|
||||
auto credentials = serverCredentials(index.row());
|
||||
return (!credentials.userName.isEmpty() && !credentials.secretData.isEmpty());
|
||||
}
|
||||
case ContainsAmneziaDnsRole: {
|
||||
QString primaryDns = server.dns1();
|
||||
return primaryDns == protocols::dns::amneziaDnsIp;
|
||||
}
|
||||
case DefaultContainerRole: {
|
||||
return server.defaultContainer();
|
||||
}
|
||||
case HasInstalledContainers: {
|
||||
return serverHasInstalledContainers(index.row());
|
||||
}
|
||||
case IsServerFromTelegramApiRole: {
|
||||
return configVersion == apiDefs::ConfigSource::Telegram;
|
||||
}
|
||||
case IsServerFromGatewayApiRole: {
|
||||
return configVersion == apiDefs::ConfigSource::AmneziaGateway;
|
||||
}
|
||||
case ApiConfigRole: {
|
||||
case NameRole:
|
||||
return row.serverName;
|
||||
case ServerDescriptionRole:
|
||||
return configVersion ? row.baseDescription : (row.baseDescription + row.hostName);
|
||||
case CollapsedServerDescriptionRole:
|
||||
return row.collapsedServerDescription;
|
||||
case ExpandedServerDescriptionRole:
|
||||
return row.expandedServerDescription;
|
||||
case HostNameRole:
|
||||
return row.hostName;
|
||||
case CredentialsRole:
|
||||
return QVariant::fromValue(serverCredentials(index.row()));
|
||||
case CredentialsLoginRole:
|
||||
return serverCredentials(index.row()).userName;
|
||||
case IsDefaultRole:
|
||||
return index.row() == m_defaultServerIndex;
|
||||
case IsCurrentlyProcessedRole:
|
||||
return index.row() == m_processedServerIndex;
|
||||
case HasWriteAccessRole:
|
||||
return row.hasWriteAccess;
|
||||
case ContainsAmneziaDnsRole:
|
||||
return row.primaryDnsIsAmnezia;
|
||||
case DefaultContainerRole:
|
||||
return QVariant::fromValue(row.defaultContainer);
|
||||
case HasInstalledContainers:
|
||||
return row.hasInstalledVpnContainers;
|
||||
case IsServerFromTelegramApiRole:
|
||||
return false;
|
||||
case IsServerFromGatewayApiRole:
|
||||
return row.isServerFromGatewayApi;
|
||||
case ApiConfigRole:
|
||||
return QVariant();
|
||||
}
|
||||
case IsCountrySelectionAvailableRole: {
|
||||
if (server.isApiV2()) {
|
||||
return !server.as<ApiV2ServerConfig>()->apiConfig.availableCountries.isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case ApiAvailableCountriesRole: {
|
||||
if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->apiConfig.availableCountries;
|
||||
}
|
||||
return QJsonArray();
|
||||
}
|
||||
case ApiServerCountryCodeRole: {
|
||||
if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->apiConfig.serverCountryCode;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
case HasAmneziaDns: {
|
||||
QString primaryDns = server.dns1();
|
||||
return primaryDns == protocols::dns::amneziaDnsIp;
|
||||
}
|
||||
case IsAdVisibleRole: {
|
||||
if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->apiConfig.serviceInfo.isAdVisible;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case AdHeaderRole: {
|
||||
if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->apiConfig.serviceInfo.adHeader;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
case AdDescriptionRole: {
|
||||
if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->apiConfig.serviceInfo.adDescription;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
case AdEndpointRole: {
|
||||
if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->apiConfig.serviceInfo.adEndpoint;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
case IsRenewalAvailableRole: {
|
||||
if (server.isApiV2()) {
|
||||
return server.as<ApiV2ServerConfig>()->apiConfig.serviceInfo.isRenewalAvailable;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case IsSubscriptionExpiredRole: {
|
||||
if (!server.isApiV2()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ApiConfig &apiConfig = server.as<ApiV2ServerConfig>()->apiConfig;
|
||||
if (apiConfig.isInAppPurchase) {
|
||||
return false;
|
||||
}
|
||||
if (apiConfig.subscriptionExpiredByServer) {
|
||||
return true;
|
||||
}
|
||||
if (apiConfig.subscription.endDate.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return apiUtils::isSubscriptionExpired(apiConfig.subscription.endDate);
|
||||
}
|
||||
case IsSubscriptionExpiringSoonRole: {
|
||||
if (!server.isApiV2()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ApiConfig &apiConfig = server.as<ApiV2ServerConfig>()->apiConfig;
|
||||
if (apiConfig.isInAppPurchase) {
|
||||
return false;
|
||||
}
|
||||
if (apiConfig.subscription.endDate.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return apiUtils::isSubscriptionExpiringSoon(apiConfig.subscription.endDate);
|
||||
}
|
||||
case IsCountrySelectionAvailableRole:
|
||||
return row.isCountrySelectionAvailable;
|
||||
case ApiAvailableCountriesRole:
|
||||
return row.apiAvailableCountries;
|
||||
case ApiServerCountryCodeRole:
|
||||
return row.apiServerCountryCode;
|
||||
case HasAmneziaDns:
|
||||
return row.primaryDnsIsAmnezia;
|
||||
case IsAdVisibleRole:
|
||||
return row.isAdVisible;
|
||||
case AdHeaderRole:
|
||||
return row.adHeader;
|
||||
case AdDescriptionRole:
|
||||
return row.adDescription;
|
||||
case AdEndpointRole:
|
||||
return row.adEndpoint;
|
||||
case IsRenewalAvailableRole:
|
||||
return row.isRenewalAvailable;
|
||||
case IsSubscriptionExpiredRole:
|
||||
return row.isSubscriptionExpired;
|
||||
case IsSubscriptionExpiringSoonRole:
|
||||
return row.isSubscriptionExpiringSoon;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
@@ -218,12 +117,11 @@ QVariant ServersModel::data(const int index, int role) const
|
||||
return data(modelIndex, role);
|
||||
}
|
||||
|
||||
void ServersModel::updateModel(const QVector<ServerConfig> &servers, int defaultServerIndex, bool isAmneziaDnsEnabled)
|
||||
void ServersModel::updateModel(const QVector<ServerDescription> &descriptions, int defaultServerIndex)
|
||||
{
|
||||
beginResetModel();
|
||||
m_servers = servers;
|
||||
m_descriptions = descriptions;
|
||||
m_defaultServerIndex = defaultServerIndex;
|
||||
m_isAmneziaDnsEnabled = isAmneziaDnsEnabled;
|
||||
endResetModel();
|
||||
emit defaultServerIndexChanged(m_defaultServerIndex);
|
||||
emit processedServerChanged();
|
||||
@@ -234,43 +132,15 @@ const int ServersModel::getDefaultServerIndex()
|
||||
return m_defaultServerIndex;
|
||||
}
|
||||
|
||||
QString ServersModel::getServerDescription(const ServerConfig &server, const int index) const
|
||||
{
|
||||
const int configVersion = server.configVersion();
|
||||
QString description;
|
||||
|
||||
if (server.isApiV2()) {
|
||||
const ApiV2ServerConfig *apiV2 = server.as<ApiV2ServerConfig>();
|
||||
if (apiV2 && !apiV2->apiConfig.serverCountryCode.isEmpty()) {
|
||||
return apiV2->apiConfig.serverCountryName;
|
||||
}
|
||||
return apiV2 ? apiV2->description : server.description();
|
||||
} else if (server.isApiV1()) {
|
||||
const ApiV1ServerConfig *apiV1 = server.as<ApiV1ServerConfig>();
|
||||
return apiV1 ? apiV1->description : server.description();
|
||||
} else if (data(index, HasWriteAccessRole).toBool()) {
|
||||
QMap<DockerContainer, ContainerConfig> containers = server.containers();
|
||||
bool isDnsInstalled = containers.contains(DockerContainer::Dns);
|
||||
if (m_isAmneziaDnsEnabled && isDnsInstalled) {
|
||||
description += "Amnezia DNS | ";
|
||||
}
|
||||
} else {
|
||||
if (data(index, HasAmneziaDns).toBool()) {
|
||||
description += "Amnezia DNS | ";
|
||||
}
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
const int ServersModel::getServersCount()
|
||||
{
|
||||
return m_servers.size();
|
||||
return m_descriptions.size();
|
||||
}
|
||||
|
||||
bool ServersModel::hasServerWithWriteAccess()
|
||||
{
|
||||
for (size_t i = 0; i < getServersCount(); i++) {
|
||||
if (qvariant_cast<bool>(data(i, HasWriteAccessRole))) {
|
||||
if (qvariant_cast<bool>(data(static_cast<int>(i), HasWriteAccessRole))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -350,29 +220,17 @@ QHash<int, QByteArray> ServersModel::roleNames() const
|
||||
roles[IsSubscriptionExpiredRole] = "isSubscriptionExpired";
|
||||
roles[IsSubscriptionExpiringSoonRole] = "isSubscriptionExpiringSoon";
|
||||
|
||||
roles[HasAmneziaDns] = "hasAmneziaDns";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
ServerCredentials ServersModel::serverCredentials(int index) const
|
||||
{
|
||||
if (index < 0 || index >= m_servers.size()) {
|
||||
if (index < 0 || index >= m_descriptions.size()) {
|
||||
return ServerCredentials();
|
||||
}
|
||||
const ServerConfig &server = m_servers.at(index);
|
||||
|
||||
if (server.isSelfHosted()) {
|
||||
const SelfHostedServerConfig *selfHosted = server.as<SelfHostedServerConfig>();
|
||||
if (selfHosted) {
|
||||
ServerCredentials credentials;
|
||||
credentials.hostName = selfHosted->hostName;
|
||||
credentials.userName = selfHosted->userName.value_or("");
|
||||
credentials.secretData = selfHosted->password.value_or("");
|
||||
credentials.port = selfHosted->port.value_or(22);
|
||||
return credentials;
|
||||
}
|
||||
}
|
||||
|
||||
return ServerCredentials();
|
||||
return m_descriptions.at(index).selfHostedSshCredentials;
|
||||
}
|
||||
|
||||
bool ServersModel::isServerFromApi(const int serverIndex)
|
||||
@@ -405,21 +263,10 @@ QVariant ServersModel::getProcessedServerData(const QString &roleString)
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
bool ServersModel::serverHasInstalledContainers(const int serverIndex) const
|
||||
{
|
||||
const ServerConfig &server = m_servers.at(serverIndex);
|
||||
QMap<DockerContainer, ContainerConfig> containers = server.containers();
|
||||
|
||||
for (auto it = containers.begin(); it != containers.end(); ++it) {
|
||||
DockerContainer container = it.key();
|
||||
if (ContainerUtils::containerService(container) == ServiceType::Vpn) {
|
||||
return true;
|
||||
}
|
||||
if (container == DockerContainer::SSXray) {
|
||||
return true;
|
||||
}
|
||||
if (serverIndex < 0 || serverIndex >= m_descriptions.size()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return m_descriptions.at(serverIndex).hasInstalledVpnContainers;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QVector>
|
||||
|
||||
#include "core/utils/selfhosted/sshSession.h"
|
||||
#include "core/models/serverConfig.h"
|
||||
#include "core/models/serverDescription.h"
|
||||
|
||||
class ServersModel : public QAbstractListModel
|
||||
{
|
||||
@@ -75,14 +75,13 @@ public slots:
|
||||
|
||||
bool isServerFromApi(const int serverIndex);
|
||||
|
||||
void updateModel(const QVector<ServerConfig> &servers, int defaultServerIndex, bool isAmneziaDnsEnabled = false);
|
||||
|
||||
void updateModel(const QVector<amnezia::ServerDescription> &descriptions, int defaultServerIndex);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
signals:
|
||||
void processedServerIndexChanged(const int index);
|
||||
// emitted when the processed server index or processed server data is changed
|
||||
void processedServerChanged();
|
||||
|
||||
void defaultServerIndexChanged(const int index);
|
||||
@@ -97,16 +96,12 @@ signals:
|
||||
private:
|
||||
ServerCredentials serverCredentials(int index) const;
|
||||
|
||||
QString getServerDescription(const ServerConfig &server, const int index) const;
|
||||
|
||||
bool serverHasInstalledContainers(const int serverIndex) const;
|
||||
|
||||
QVector<ServerConfig> m_servers;
|
||||
QVector<amnezia::ServerDescription> m_descriptions;
|
||||
|
||||
int m_defaultServerIndex;
|
||||
int m_processedServerIndex;
|
||||
|
||||
bool m_isAmneziaDnsEnabled = false;
|
||||
int m_defaultServerIndex = -1;
|
||||
int m_processedServerIndex = -1;
|
||||
};
|
||||
|
||||
#endif // SERVERSMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user