mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-05 10:02:04 +03:00
* 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
76 lines
1.9 KiB
C++
76 lines
1.9 KiB
C++
#ifndef APIACCOUNTINFOMODEL_H
|
|
#define APIACCOUNTINFOMODEL_H
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QJsonArray>
|
|
#include <QJsonObject>
|
|
|
|
#include "core/utils/serverConfigUtils.h"
|
|
#include "core/utils/constants/apiKeys.h"
|
|
#include "core/utils/constants/apiConstants.h"
|
|
|
|
class ApiAccountInfoModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum Roles {
|
|
SubscriptionStatusRole = Qt::UserRole + 1,
|
|
ConnectedDevicesRole,
|
|
ServiceDescriptionRole,
|
|
EndDateRole,
|
|
IsComponentVisibleRole,
|
|
IsSubscriptionRenewalAvailableRole,
|
|
HasExpiredWorkerRole,
|
|
IsProtocolSelectionSupportedRole,
|
|
IsSubscriptionExpiredRole,
|
|
IsSubscriptionExpiringSoonRole,
|
|
IsInAppPurchaseRole
|
|
};
|
|
|
|
explicit ApiAccountInfoModel(QObject *parent = nullptr);
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
public slots:
|
|
void updateModel(const QJsonObject &accountInfoObject, const QJsonObject &serverConfig);
|
|
QVariant data(const QString &roleString);
|
|
QJsonArray getAvailableCountries();
|
|
QJsonArray getIssuedConfigsInfo();
|
|
|
|
QString getTelegramBotLink();
|
|
QString getEmailLink();
|
|
QString getBillingEmailLink();
|
|
QString getSiteLink();
|
|
QString getFullSiteLink();
|
|
|
|
protected:
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
private:
|
|
struct AccountInfoData
|
|
{
|
|
QString subscriptionEndDate;
|
|
int activeDeviceCount;
|
|
int maxDeviceCount;
|
|
|
|
serverConfigUtils::ConfigType configType;
|
|
|
|
QStringList supportedProtocols;
|
|
|
|
QString subscriptionDescription;
|
|
|
|
bool isInAppPurchase = false;
|
|
bool isRenewalAvailable = false;
|
|
};
|
|
|
|
AccountInfoData m_accountInfoData;
|
|
QJsonArray m_availableCountries;
|
|
QJsonArray m_issuedConfigsInfo;
|
|
QJsonObject m_supportInfo;
|
|
};
|
|
|
|
#endif // APIACCOUNTINFOMODEL_H
|