2023-07-01 17:54:53 +01:00
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
|
|
#include "../QSbieAPI/SbieStatus.h"
|
|
|
|
|
|
|
|
|
|
|
|
class CAddon : public QObject
|
|
|
|
{
|
|
|
|
public:
|
2023-07-30 13:28:35 +01:00
|
|
|
CAddon(const QVariantMap& Data) : Data(Data)
|
2023-07-01 17:54:53 +01:00
|
|
|
{
|
|
|
|
Id = Data["id"].toString();
|
|
|
|
}
|
2023-07-30 13:28:35 +01:00
|
|
|
|
2023-07-01 17:54:53 +01:00
|
|
|
QString Id;
|
|
|
|
QVariantMap Data;
|
|
|
|
CSbieProgressPtr pProgress;
|
|
|
|
|
|
|
|
QVariant GetSpecificEntry(const QString& Name, QString* pName = NULL);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QSharedPointer<CAddon> CAddonPtr;
|
|
|
|
|
2023-07-30 13:28:35 +01:00
|
|
|
class CAddonInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CAddonInfo(const QVariantMap& data, bool installed) : Data(data), Installed(installed) {
|
|
|
|
Id = Data["id"].toString();
|
|
|
|
};
|
|
|
|
|
|
|
|
QString Id;
|
|
|
|
QVariantMap Data;
|
|
|
|
bool Installed;
|
|
|
|
QString UpdateVersion;
|
|
|
|
|
|
|
|
QString GetLocalizedEntry(const QString& Name);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QSharedPointer<CAddonInfo> CAddonInfoPtr;
|
|
|
|
|
2023-07-01 17:54:53 +01:00
|
|
|
class CAddonManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
CAddonManager(QObject* parent = NULL);
|
|
|
|
|
|
|
|
bool LoadAddons();
|
|
|
|
|
2023-07-01 20:24:12 +01:00
|
|
|
void UpdateAddonsWhenNotCached();
|
2023-07-01 17:54:53 +01:00
|
|
|
void UpdateAddons();
|
|
|
|
|
2023-07-30 13:28:35 +01:00
|
|
|
QList<CAddonInfoPtr> GetAddons();
|
2023-07-01 17:54:53 +01:00
|
|
|
|
2023-07-30 13:28:35 +01:00
|
|
|
enum EState {
|
|
|
|
eAny = 0,
|
|
|
|
eInstalled,
|
|
|
|
eNotINstalled
|
|
|
|
};
|
|
|
|
|
|
|
|
CAddonPtr GetAddon(const QString& Id, EState State = eAny);
|
2023-07-01 17:54:53 +01:00
|
|
|
|
|
|
|
SB_PROGRESS TryInstallAddon(const QString& Id, QWidget* pParent, const QString& Prompt = QString());
|
|
|
|
SB_PROGRESS InstallAddon(const QString& Id);
|
|
|
|
SB_PROGRESS TryRemoveAddon(const QString& Id, QWidget* pParent);
|
|
|
|
SB_PROGRESS RemoveAddon(const QString& Id);
|
2023-07-30 13:28:35 +01:00
|
|
|
|
|
|
|
static QString GetAppArch();
|
|
|
|
static QString GetSysArch();
|
|
|
|
static QString GetFramework();
|
2023-07-01 17:54:53 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void DataUpdated();
|
|
|
|
void AddonInstalled();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void OnUpdateData(const QVariantMap& Data, const QVariantMap& Params);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2023-07-30 13:28:35 +01:00
|
|
|
static void RunUpdaterAsync(CAddonPtr pAddon, const QStringList& Params);
|
2023-07-01 17:54:53 +01:00
|
|
|
|
2023-07-30 13:28:35 +01:00
|
|
|
QList<CAddonPtr> m_Installed;
|
|
|
|
QList<CAddonPtr> m_KnownAddons;
|
2023-07-01 17:54:53 +01:00
|
|
|
};
|
|
|
|
|