chore(cpn): Switch from component names to ids (#2602)
* cpn(fix): Switch from component names to ids * Fix Win compile * Sound packs list entries should not be editable
This commit is contained in:
@@ -346,7 +346,7 @@ bool ComponentData::existsOnDisk()
|
|||||||
void ComponentData::clearRelease()
|
void ComponentData::clearRelease()
|
||||||
{
|
{
|
||||||
releaseReset();
|
releaseReset();
|
||||||
idReset();
|
releaseIdReset();
|
||||||
prereleaseReset();
|
prereleaseReset();
|
||||||
dateReset();
|
dateReset();
|
||||||
versionReset();
|
versionReset();
|
||||||
@@ -516,15 +516,6 @@ QMap<int, QString> AppData::getActiveProfiles() const
|
|||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AppData::getComponentIndex(QString name) const
|
|
||||||
{
|
|
||||||
for (int i=0; i<MAX_COMPONENTS; i++) {
|
|
||||||
if (g.component[i].existsOnDisk() && g.component[i].name() == name)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppData::convertSettings(QSettings & settings)
|
void AppData::convertSettings(QSettings & settings)
|
||||||
{
|
{
|
||||||
quint32 savedVer = settings.value(SETTINGS_VERSION_KEY, 0).toUInt();
|
quint32 savedVer = settings.value(SETTINGS_VERSION_KEY, 0).toUInt();
|
||||||
@@ -567,6 +558,18 @@ void AppData::convertSettings(QSettings & settings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (savedMajMin < 0x209) {
|
||||||
|
// 2.9 component id renamed releaseId - copy value before calling clearUnusedSettings
|
||||||
|
qInfo().noquote() << "Converting components - moving id to releaseId";
|
||||||
|
static const QString path = QStringLiteral("Components/component%1/%2");
|
||||||
|
for (int i = 0; i < MAX_COMPONENTS; i++) {
|
||||||
|
if (settings.contains(path.arg(i).arg("id"))) {
|
||||||
|
const QVariant id = settings.value(path.arg(i).arg("id"));
|
||||||
|
settings.setValue(path.arg(i).arg("releaseId"), id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (removeUnused)
|
if (removeUnused)
|
||||||
clearUnusedSettings(settings);
|
clearUnusedSettings(settings);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
//! CPN_SETTINGS_REVISION is used to track settings changes independently of EdgeTX version. It should be reset to zero whenever settings are migrated to new COMPANY or PRODUCT.
|
//! CPN_SETTINGS_REVISION is used to track settings changes independently of EdgeTX version. It should be reset to zero whenever settings are migrated to new COMPANY or PRODUCT.
|
||||||
//! \note !! Increment this value if properties are removed or refactored. It will trigger a conversion/cleanup of any stored settings. \sa AppData::convertSettings()
|
//! \note !! Increment this value if properties are removed or refactored. It will trigger a conversion/cleanup of any stored settings. \sa AppData::convertSettings()
|
||||||
#define CPN_SETTINGS_REVISION 1 // Note: bumped to ensure 2.7 Nightly version users also get upgraded
|
#define CPN_SETTINGS_REVISION 2 // Note: bumped for fix during 2.8 RCs
|
||||||
|
|
||||||
//! CPN_SETTINGS_VERSION is used for settings data version tracking.
|
//! CPN_SETTINGS_VERSION is used for settings data version tracking.
|
||||||
#define CPN_SETTINGS_VERSION ((VERSION_NUMBER << 8) | CPN_SETTINGS_REVISION)
|
#define CPN_SETTINGS_VERSION ((VERSION_NUMBER << 8) | CPN_SETTINGS_REVISION)
|
||||||
@@ -495,11 +495,10 @@ class ComponentData: public CompStoreObj
|
|||||||
friend class AppData;
|
friend class AppData;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PROPERTYSTR (name)
|
|
||||||
PROPERTY (bool, checkForUpdate, false)
|
PROPERTY (bool, checkForUpdate, false)
|
||||||
PROPERTY (ReleaseChannel, releaseChannel, RELEASE_CHANNEL_STABLE)
|
PROPERTY (ReleaseChannel, releaseChannel, RELEASE_CHANNEL_STABLE)
|
||||||
PROPERTYSTRD( release, "unknown")
|
PROPERTYSTRD( release, "unknown")
|
||||||
PROPERTY (int, id, 0)
|
PROPERTY (int, releaseId, 0)
|
||||||
PROPERTY (bool, prerelease, false)
|
PROPERTY (bool, prerelease, false)
|
||||||
PROPERTYSTRD( version, "0")
|
PROPERTYSTRD( version, "0")
|
||||||
PROPERTYSTRD( date, "")
|
PROPERTYSTRD( date, "")
|
||||||
@@ -574,8 +573,6 @@ class AppData: public CompStoreObj
|
|||||||
//! List of all active profiles mapped by index.
|
//! List of all active profiles mapped by index.
|
||||||
QMap<int, QString> getActiveProfiles() const;
|
QMap<int, QString> getActiveProfiles() const;
|
||||||
|
|
||||||
//! Get a modifiable (non-const) index to ComponentData for \a name. Returns -1 if \a name not found.
|
|
||||||
int getComponentIndex(QString name) const;
|
|
||||||
//! Get a modifiable (non-const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.
|
//! Get a modifiable (non-const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.
|
||||||
ComponentData & getComponent(int index);
|
ComponentData & getComponent(int index);
|
||||||
//! Get a non-modifiable (const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.
|
//! Get a non-modifiable (const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ ChooserDialog::ChooserDialog(QWidget * parent, QString title, QStandardItemModel
|
|||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
|
||||||
ui->listView->setModel(itemModel);
|
ui->listView->setModel(itemModel);
|
||||||
|
ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=]() {
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=]() {
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
|||||||
@@ -433,19 +433,37 @@ bool AssetsFilteredItemModel::setCopyFilter(const int id, const QString filter)
|
|||||||
return setMetaDataValue(id, UpdatesItemModel::IMDR_CopyFilter, QVariant(filter));
|
return setMetaDataValue(id, UpdatesItemModel::IMDR_CopyFilter, QVariant(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
RepoMetaData
|
||||||
|
*/
|
||||||
|
|
||||||
|
RepoMetaData::RepoMetaData(QObject * parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ReleasesMetaData
|
ReleasesMetaData
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ReleasesMetaData::ReleasesMetaData(QObject * parent) :
|
ReleasesMetaData::ReleasesMetaData(QObject * parent) :
|
||||||
QObject(parent),
|
RepoMetaData(parent),
|
||||||
m_repo(""),
|
|
||||||
m_id(0)
|
m_id(0)
|
||||||
{
|
{
|
||||||
itemModel = new ReleasesItemModel();
|
itemModel = new ReleasesItemModel();
|
||||||
filteredItemModel = new ReleasesFilteredItemModel(itemModel);
|
filteredItemModel = new ReleasesFilteredItemModel(itemModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReleasesMetaData::init(const QString repo, const QString nightly, const int settingsIndex, const int resultsPerPage)
|
||||||
|
{
|
||||||
|
m_repo = repo;
|
||||||
|
m_resultsPerPage = resultsPerPage;
|
||||||
|
itemModel->setNightlyName(nightly);
|
||||||
|
itemModel->setSettingsIndex(settingsIndex);
|
||||||
|
}
|
||||||
|
|
||||||
bool ReleasesMetaData::refreshRequired()
|
bool ReleasesMetaData::refreshRequired()
|
||||||
{
|
{
|
||||||
return m_id == 0 ? true : itemModel->refreshRequired();
|
return m_id == 0 ? true : itemModel->refreshRequired();
|
||||||
@@ -490,12 +508,18 @@ QString ReleasesMetaData::version()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
AssetsMetaData::AssetsMetaData(QObject * parent) :
|
AssetsMetaData::AssetsMetaData(QObject * parent) :
|
||||||
QObject(parent)
|
RepoMetaData(parent)
|
||||||
{
|
{
|
||||||
itemModel = new AssetsItemModel();
|
itemModel = new AssetsItemModel();
|
||||||
filteredItemModel = new AssetsFilteredItemModel(itemModel);
|
filteredItemModel = new AssetsFilteredItemModel(itemModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetsMetaData::init(const QString repo, const int resultsPerPage)
|
||||||
|
{
|
||||||
|
m_repo = repo;
|
||||||
|
m_resultsPerPage = resultsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
int AssetsMetaData::getSetId(int row)
|
int AssetsMetaData::getSetId(int row)
|
||||||
{
|
{
|
||||||
m_id = filteredItemModel->id(row);
|
m_id = filteredItemModel->id(row);
|
||||||
|
|||||||
@@ -202,18 +202,32 @@ class AssetsFilteredItemModel : public UpdatesFilteredItemModel
|
|||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReleasesMetaData : public QObject
|
class RepoMetaData : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit RepoMetaData(QObject * parent);
|
||||||
|
virtual ~RepoMetaData() {};
|
||||||
|
|
||||||
|
const QString urlReleases() { return QString("%1/releases").arg(m_repo); }
|
||||||
|
const QString urlReleaseLatest() { return QString("%1/latest").arg(urlReleases()); }
|
||||||
|
const QString urlContent(const QString & path) { return QString("%1/contents/%2").arg(m_repo).arg(path); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_repo;
|
||||||
|
int m_resultsPerPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ReleasesMetaData : public RepoMetaData
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ReleasesMetaData(QObject * parent);
|
explicit ReleasesMetaData(QObject * parent);
|
||||||
virtual ~ReleasesMetaData() {};
|
virtual ~ReleasesMetaData() {};
|
||||||
|
|
||||||
bool refreshRequired();
|
void init(const QString repo, const QString nightly, const int settingsIndex, const int resultsPerPage);
|
||||||
|
|
||||||
void setRepo(QString repo) { m_repo = repo; }
|
bool refreshRequired();
|
||||||
void setNightlyName(QString name) { itemModel->setNightlyName(name); }
|
|
||||||
void setSettingsIndex(const int index) { itemModel->setSettingsIndex(index); }
|
|
||||||
void setReleaseChannel(const int channel) { itemModel->setReleaseChannel(channel); }
|
void setReleaseChannel(const int channel) { itemModel->setReleaseChannel(channel); }
|
||||||
|
|
||||||
void setId(int id) { m_id = id; }
|
void setId(int id) { m_id = id; }
|
||||||
@@ -234,25 +248,22 @@ class ReleasesMetaData : public QObject
|
|||||||
bool prerelease() { return filteredItemModel->prerelease(m_id); }
|
bool prerelease() { return filteredItemModel->prerelease(m_id); }
|
||||||
QString version();
|
QString version();
|
||||||
|
|
||||||
QString urlReleases() { return QString("%1/releases").arg(m_repo); }
|
const QString urlRelease() { return QString("%1/%2").arg(urlReleases()).arg(m_id); }
|
||||||
QString urlReleaseLatest() { return QString("%1/latest").arg(urlReleases()); }
|
|
||||||
QString urlRelease() { return QString("%1/%2").arg(urlReleases()).arg(m_id); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ReleasesItemModel *itemModel;
|
ReleasesItemModel *itemModel;
|
||||||
ReleasesFilteredItemModel *filteredItemModel;
|
ReleasesFilteredItemModel *filteredItemModel;
|
||||||
QString m_repo;
|
|
||||||
int m_id;
|
int m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AssetsMetaData : public QObject
|
class AssetsMetaData : public RepoMetaData
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AssetsMetaData(QObject * parent);
|
explicit AssetsMetaData(QObject * parent);
|
||||||
virtual ~AssetsMetaData() {};
|
virtual ~AssetsMetaData() {};
|
||||||
|
|
||||||
void setRepo(QString repo) { m_repo = repo; }
|
void init(const QString repo, const int resultsPerPage);
|
||||||
|
|
||||||
void setId(int id) { m_id = id; }
|
void setId(int id) { m_id = id; }
|
||||||
int id() { return m_id; }
|
int id() { return m_id; }
|
||||||
@@ -282,17 +293,13 @@ class AssetsMetaData : public QObject
|
|||||||
QString copyFilter() { return filteredItemModel->metaDataValue(m_id, UpdatesItemModel::IMDR_CopyFilter).toString(); }
|
QString copyFilter() { return filteredItemModel->metaDataValue(m_id, UpdatesItemModel::IMDR_CopyFilter).toString(); }
|
||||||
int flags() { return filteredItemModel->metaDataValue(m_id, UpdatesItemModel::IMDR_Flags).toInt(); }
|
int flags() { return filteredItemModel->metaDataValue(m_id, UpdatesItemModel::IMDR_Flags).toInt(); }
|
||||||
|
|
||||||
QString urlReleaseAssets(int releaseId, int max)
|
const QString urlReleaseAssets(int releaseId) {
|
||||||
{ return QString("%1/%2/assets").arg(urlReleases()).arg(releaseId) % (max > -1 ? QString("\?per_page=%1").arg(max) : ""); }
|
return QString("%1/%2/assets").arg(urlReleases()).arg(releaseId) % (m_resultsPerPage > -1 ?
|
||||||
QString urlAsset() { return QString("%1/assets/%2").arg(urlReleases()).arg(m_id); }
|
QString("\?per_page=%1").arg(m_resultsPerPage) : ""); }
|
||||||
|
const QString urlAsset() { return QString("%1/assets/%2").arg(urlReleases()).arg(m_id); }
|
||||||
QString urlContent(QString path) { return QString("%1/contents/%2").arg(m_repo).arg(path); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AssetsItemModel *itemModel;
|
AssetsItemModel *itemModel;
|
||||||
AssetsFilteredItemModel *filteredItemModel;
|
AssetsFilteredItemModel *filteredItemModel;
|
||||||
QString m_repo;
|
|
||||||
int m_id;
|
int m_id;
|
||||||
|
|
||||||
QString urlReleases() { return m_repo % "/releases"; }
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,9 +55,7 @@
|
|||||||
UpdateCompanion::UpdateCompanion(QWidget * parent) :
|
UpdateCompanion::UpdateCompanion(QWidget * parent) :
|
||||||
UpdateInterface(parent)
|
UpdateInterface(parent)
|
||||||
{
|
{
|
||||||
setName(tr("Companion"));
|
init(CID_Companion, tr("Companion"), QString(GH_REPOS_EDGETX).append("/edgetx"), "nightly");
|
||||||
setRepo(QString(GH_REPOS_EDGETX).append("/edgetx"));
|
|
||||||
setReleasesNightlyName("nightly");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateCompanion::initAssetSettings()
|
void UpdateCompanion::initAssetSettings()
|
||||||
@@ -65,9 +63,9 @@ void UpdateCompanion::initAssetSettings()
|
|||||||
if (!isValidSettingsIndex())
|
if (!isValidSettingsIndex())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g.component[settingsIndex()].initAllAssets();
|
g.component[id()].initAllAssets();
|
||||||
|
|
||||||
ComponentAssetData &cad = g.component[settingsIndex()].asset[0];
|
ComponentAssetData &cad = g.component[id()].asset[0];
|
||||||
|
|
||||||
cad.desc("installer");
|
cad.desc("installer");
|
||||||
cad.processes((UPDFLG_Common_Asset | UPDFLG_AsyncInstall) & ~UPDFLG_CopyDest);
|
cad.processes((UPDFLG_Common_Asset | UPDFLG_AsyncInstall) & ~UPDFLG_CopyDest);
|
||||||
|
|||||||
@@ -25,9 +25,7 @@
|
|||||||
UpdateFirmware::UpdateFirmware(QWidget * parent) :
|
UpdateFirmware::UpdateFirmware(QWidget * parent) :
|
||||||
UpdateInterface(parent)
|
UpdateInterface(parent)
|
||||||
{
|
{
|
||||||
setName(tr("Firmware"));
|
init(CID_Firmware, tr("Firmware"), QString(GH_REPOS_EDGETX).append("/edgetx"), "nightly");
|
||||||
setRepo(QString(GH_REPOS_EDGETX).append("/edgetx"));
|
|
||||||
setReleasesNightlyName("nightly");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFirmware::initAssetSettings()
|
void UpdateFirmware::initAssetSettings()
|
||||||
@@ -35,9 +33,9 @@ void UpdateFirmware::initAssetSettings()
|
|||||||
if (!isValidSettingsIndex())
|
if (!isValidSettingsIndex())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g.component[settingsIndex()].initAllAssets();
|
g.component[id()].initAllAssets();
|
||||||
|
|
||||||
ComponentAssetData &cad = g.component[settingsIndex()].asset[0];
|
ComponentAssetData &cad = g.component[id()].asset[0];
|
||||||
|
|
||||||
cad.desc("binary");
|
cad.desc("binary");
|
||||||
cad.processes(UPDFLG_Common_Asset | UPDFLG_AsyncInstall);
|
cad.processes(UPDFLG_Common_Asset | UPDFLG_AsyncInstall);
|
||||||
|
|||||||
@@ -114,19 +114,17 @@ QString UpdateParameters::updateFilterTypeToString(UpdateFilterType uft)
|
|||||||
UpdateInterface::UpdateInterface(QWidget * parent) :
|
UpdateInterface::UpdateInterface(QWidget * parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
progress(nullptr),
|
progress(nullptr),
|
||||||
resultsPerPage(-1),
|
|
||||||
reply(nullptr),
|
reply(nullptr),
|
||||||
buffer(new QByteArray()),
|
buffer(new QByteArray()),
|
||||||
file(nullptr),
|
file(nullptr),
|
||||||
m_settingsIdx(-1)
|
m_id(CID_Unknown),
|
||||||
|
m_name("")
|
||||||
{
|
{
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
|
|
||||||
releases = new ReleasesMetaData(this);
|
releases = new ReleasesMetaData(this);
|
||||||
assets = new AssetsMetaData(this);
|
assets = new AssetsMetaData(this);
|
||||||
params = new UpdateParameters(this);
|
params = new UpdateParameters(this);
|
||||||
|
|
||||||
setReleasesNightlyName("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateInterface::~UpdateInterface()
|
UpdateInterface::~UpdateInterface()
|
||||||
@@ -141,6 +139,76 @@ UpdateInterface::~UpdateInterface()
|
|||||||
delete params;
|
delete params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateInterface::init(ComponentIdentity id, QString name, QString repo, QString nightly, int resultsPerPage)
|
||||||
|
{
|
||||||
|
setId(id);
|
||||||
|
setName(name);
|
||||||
|
|
||||||
|
initAppSettings();
|
||||||
|
|
||||||
|
releases->init(repo, nightly, resultsPerPage, id);
|
||||||
|
assets->init(repo, resultsPerPage);
|
||||||
|
|
||||||
|
currentRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateInterface::initAppSettings()
|
||||||
|
{
|
||||||
|
if (!isValidSettingsIndex()) {
|
||||||
|
reportProgress(tr("Component id: %1 exceeds maximum application settings components: %2!").arg(m_id).arg(MAX_COMPONENTS), QtCriticalMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g.component[m_id].existsOnDisk()) {
|
||||||
|
g.component[m_id].init();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g.component[m_id].asset[0].existsOnDisk())
|
||||||
|
initAssetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateInterface::loadAssetSettings()
|
||||||
|
{
|
||||||
|
if (!isValidSettingsIndex())
|
||||||
|
return;
|
||||||
|
|
||||||
|
params->assets.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_COMPONENT_ASSETS && g.component[m_id].asset[i].existsOnDisk(); i++) {
|
||||||
|
UpdateParameters::AssetParams &ap = params->addAsset();
|
||||||
|
ComponentAssetData &cad = g.component[m_id].asset[i];
|
||||||
|
|
||||||
|
ap.processes = cad.processes();
|
||||||
|
ap.flags = cad.flags();
|
||||||
|
ap.filterType = (UpdateParameters::UpdateFilterType)cad.filterType();
|
||||||
|
ap.filter = cad.filter();
|
||||||
|
ap.maxExpected = cad.maxExpected();
|
||||||
|
ap.destSubDir = cad.destSubDir();
|
||||||
|
ap.copyFilterType = (UpdateParameters::UpdateFilterType)cad.copyFilterType();
|
||||||
|
ap.copyFilter = cad.copyFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateInterface::saveAssetSettings()
|
||||||
|
{
|
||||||
|
if (!isValidSettingsIndex())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_COMPONENT_ASSETS && g.component[m_id].asset[i].existsOnDisk(); i++) {
|
||||||
|
const UpdateParameters::AssetParams &ap = params->assets.at(i);
|
||||||
|
ComponentAssetData &cad = g.component[m_id].asset[i];
|
||||||
|
|
||||||
|
// DO NOT overwrite cad.processes
|
||||||
|
cad.flags(ap.flags);
|
||||||
|
cad.filterType(ap.filterType);
|
||||||
|
cad.filter(ap.filter);
|
||||||
|
cad.maxExpected(ap.maxExpected);
|
||||||
|
cad.destSubDir(ap.destSubDir);
|
||||||
|
cad.copyFilterType(ap.copyFilterType);
|
||||||
|
cad.copyFilter(ap.copyFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool UpdateInterface::update(ProgressWidget * progress)
|
bool UpdateInterface::update(ProgressWidget * progress)
|
||||||
{
|
{
|
||||||
if (!(params->flags & UPDFLG_Update))
|
if (!(params->flags & UPDFLG_Update))
|
||||||
@@ -149,30 +217,30 @@ bool UpdateInterface::update(ProgressWidget * progress)
|
|||||||
this->progress = progress;
|
this->progress = progress;
|
||||||
|
|
||||||
if (progress) {
|
if (progress) {
|
||||||
progress->setInfo(tr("Processing updates for: %1").arg(name));
|
progress->setInfo(tr("Processing updates for: %1").arg(m_name));
|
||||||
progress->setValue(0);
|
progress->setValue(0);
|
||||||
progress->setMaximum(100);
|
progress->setMaximum(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
reportProgress(tr("Processing updates for: %1").arg(name), QtInfoMsg);
|
reportProgress(tr("Processing updates for: %1").arg(m_name), QtInfoMsg);
|
||||||
|
|
||||||
if (!preparation()) {
|
if (!preparation()) {
|
||||||
reportProgress(tr("%1 preparation failed").arg(name), QtCriticalMsg);
|
reportProgress(tr("%1 preparation failed").arg(m_name), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!download()) {
|
if (!download()) {
|
||||||
reportProgress(tr("%1 download failed").arg(name), QtCriticalMsg);
|
reportProgress(tr("%1 download failed").arg(m_name), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!decompress()) {
|
if (!decompress()) {
|
||||||
reportProgress(tr("%1 decompress failed").arg(name), QtCriticalMsg);
|
reportProgress(tr("%1 decompress failed").arg(m_name), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!copyToDestination()) {
|
if (!copyToDestination()) {
|
||||||
reportProgress(tr("%1 copy to destination failed").arg(name), QtCriticalMsg);
|
reportProgress(tr("%1 copy to destination failed").arg(m_name), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,19 +251,19 @@ bool UpdateInterface::update(ProgressWidget * progress)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!asyncInstall()) {
|
if (!asyncInstall()) {
|
||||||
reportProgress(tr("%1 start async failed").arg(name), QtCriticalMsg);
|
reportProgress(tr("%1 start async failed").arg(m_name), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!housekeeping()) {
|
if (!housekeeping()) {
|
||||||
reportProgress(tr("%1 housekeeping failed").arg(name), QtCriticalMsg);
|
reportProgress(tr("%1 housekeeping failed").arg(m_name), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
reportProgress(tr("%1 update successful").arg(name), QtInfoMsg);
|
reportProgress(tr("%1 update successful").arg(m_name), QtInfoMsg);
|
||||||
|
|
||||||
if (!progress)
|
if (!progress)
|
||||||
QMessageBox::information(progress, CPN_STR_APP_NAME, tr("%1 update successful").arg(name));
|
QMessageBox::information(progress, CPN_STR_APP_NAME, tr("%1 update successful").arg(m_name));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -288,87 +356,9 @@ void UpdateInterface::criticalMsg(const QString & msg)
|
|||||||
QMessageBox::critical(progress, tr("Update Interface"), msg);
|
QMessageBox::critical(progress, tr("Update Interface"), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateInterface::setName(QString name)
|
|
||||||
{
|
|
||||||
this->name = name;
|
|
||||||
setSettingsIndex();
|
|
||||||
currentRelease();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateInterface::setRepo(QString repo)
|
|
||||||
{
|
|
||||||
releases->setRepo(repo);
|
|
||||||
assets->setRepo(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateInterface::setSettingsIndex()
|
|
||||||
{
|
|
||||||
int i = g.getComponentIndex(name);
|
|
||||||
|
|
||||||
if (i < 0) {
|
|
||||||
for (i = 0; i < MAX_COMPONENTS && g.component[i].existsOnDisk(); i++)
|
|
||||||
;
|
|
||||||
if (i >= MAX_COMPONENTS) {
|
|
||||||
reportProgress(tr("No free slot to save interface settings!"), QtCriticalMsg);
|
|
||||||
i = -1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g.component[i].init();
|
|
||||||
g.component[i].name(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_settingsIdx = i;
|
|
||||||
releases->setSettingsIndex(m_settingsIdx);
|
|
||||||
if (isValidSettingsIndex() && !g.component[m_settingsIdx].asset[0].existsOnDisk())
|
|
||||||
initAssetSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateInterface::loadAssetSettings()
|
|
||||||
{
|
|
||||||
if (!isValidSettingsIndex())
|
|
||||||
return;
|
|
||||||
|
|
||||||
params->assets.clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COMPONENT_ASSETS && g.component[m_settingsIdx].asset[i].existsOnDisk(); i++) {
|
|
||||||
UpdateParameters::AssetParams &ap = params->addAsset();
|
|
||||||
ComponentAssetData &cad = g.component[m_settingsIdx].asset[i];
|
|
||||||
|
|
||||||
ap.processes = cad.processes();
|
|
||||||
ap.flags = cad.flags();
|
|
||||||
ap.filterType = (UpdateParameters::UpdateFilterType)cad.filterType();
|
|
||||||
ap.filter = cad.filter();
|
|
||||||
ap.maxExpected = cad.maxExpected();
|
|
||||||
ap.destSubDir = cad.destSubDir();
|
|
||||||
ap.copyFilterType = (UpdateParameters::UpdateFilterType)cad.copyFilterType();
|
|
||||||
ap.copyFilter = cad.copyFilter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateInterface::saveAssetSettings()
|
|
||||||
{
|
|
||||||
if (!isValidSettingsIndex())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COMPONENT_ASSETS && g.component[m_settingsIdx].asset[i].existsOnDisk(); i++) {
|
|
||||||
const UpdateParameters::AssetParams &ap = params->assets.at(i);
|
|
||||||
ComponentAssetData &cad = g.component[m_settingsIdx].asset[i];
|
|
||||||
|
|
||||||
// ap.processes do not overwrite as read only
|
|
||||||
cad.flags(ap.flags);
|
|
||||||
cad.filterType(ap.filterType);
|
|
||||||
cad.filter(ap.filter);
|
|
||||||
cad.maxExpected(ap.maxExpected);
|
|
||||||
cad.destSubDir(ap.destSubDir);
|
|
||||||
cad.copyFilterType(ap.copyFilterType);
|
|
||||||
cad.copyFilter(ap.copyFilter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UpdateInterface::isUpdateable()
|
bool UpdateInterface::isUpdateable()
|
||||||
{
|
{
|
||||||
return g.component[m_settingsIdx].checkForUpdate();
|
return g.component[m_id].checkForUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateInterface::resetEnvironment()
|
void UpdateInterface::resetEnvironment()
|
||||||
@@ -378,7 +368,7 @@ void UpdateInterface::resetEnvironment()
|
|||||||
progress = nullptr;
|
progress = nullptr;
|
||||||
|
|
||||||
params->logLevel = g.updLogLevel();
|
params->logLevel = g.updLogLevel();
|
||||||
setReleaseChannel(g.component[m_settingsIdx].releaseChannel());
|
setReleaseChannel(g.component[m_id].releaseChannel());
|
||||||
params->updateRelease = "";
|
params->updateRelease = "";
|
||||||
setFlavourLanguage();
|
setFlavourLanguage();
|
||||||
loadAssetSettings();
|
loadAssetSettings();
|
||||||
@@ -398,9 +388,15 @@ void UpdateInterface::resetEnvironment()
|
|||||||
void UpdateInterface::setReleaseChannel(int channel)
|
void UpdateInterface::setReleaseChannel(int channel)
|
||||||
{
|
{
|
||||||
params->releaseChannel = channel;
|
params->releaseChannel = channel;
|
||||||
|
//repoReleasesMetaData();
|
||||||
releases->setReleaseChannel(channel);
|
releases->setReleaseChannel(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateInterface::setReleaseId(QString val)
|
||||||
|
{
|
||||||
|
releases->getSetId(val);
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateInterface::setFlavourLanguage()
|
void UpdateInterface::setFlavourLanguage()
|
||||||
{
|
{
|
||||||
const Firmware * baseFw = getCurrentFirmware()->getFirmwareBase();
|
const Firmware * baseFw = getCurrentFirmware()->getFirmwareBase();
|
||||||
@@ -460,19 +456,21 @@ void UpdateInterface::setParamFolders()
|
|||||||
|
|
||||||
void UpdateInterface::clearRelease()
|
void UpdateInterface::clearRelease()
|
||||||
{
|
{
|
||||||
g.component[m_settingsIdx].clearRelease();
|
g.component[m_id].clearRelease();
|
||||||
currentRelease();
|
currentRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString UpdateInterface::currentRelease()
|
const QString UpdateInterface::currentRelease()
|
||||||
{
|
{
|
||||||
params->currentRelease = g.component[m_settingsIdx].release();
|
params->currentRelease = g.component[m_id].release();
|
||||||
return params->currentRelease;
|
return params->currentRelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UpdateInterface::latestRelease()
|
QString UpdateInterface::latestRelease()
|
||||||
{
|
{
|
||||||
repoReleasesMetaData();
|
if (!repoReleasesMetaData())
|
||||||
|
return tr("unknown");
|
||||||
|
|
||||||
return releases->name();
|
return releases->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +484,7 @@ const QString UpdateInterface::updateRelease()
|
|||||||
|
|
||||||
const bool UpdateInterface::isUpdateAvailable()
|
const bool UpdateInterface::isUpdateAvailable()
|
||||||
{
|
{
|
||||||
if (g.component[m_settingsIdx].checkForUpdate())
|
if (g.component[m_id].checkForUpdate())
|
||||||
return !isLatestRelease();
|
return !isLatestRelease();
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
@@ -510,11 +508,13 @@ const bool UpdateInterface::isLatestVersion(const QString & installed, const QSt
|
|||||||
|
|
||||||
const bool UpdateInterface::isLatestRelease()
|
const bool UpdateInterface::isLatestRelease()
|
||||||
{
|
{
|
||||||
repoReleasesMetaData();
|
if (!repoReleasesMetaData())
|
||||||
|
return false;
|
||||||
|
|
||||||
QString currentVer = currentVersion();
|
QString currentVer = currentVersion();
|
||||||
QString latestVer = releases->version();
|
QString latestVer = releases->version();
|
||||||
// nightlies often have the same version so also check id
|
// nightlies often have the same version so also check id
|
||||||
if (isLatestVersion(currentVer, latestVer) && g.component[m_settingsIdx].id() == releases->id()) {
|
if (isLatestVersion(currentVer, latestVer) && g.component[m_id].releaseId() == releases->id()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -524,12 +524,14 @@ const bool UpdateInterface::isLatestRelease()
|
|||||||
|
|
||||||
const QString UpdateInterface::currentVersion()
|
const QString UpdateInterface::currentVersion()
|
||||||
{
|
{
|
||||||
return g.component[m_settingsIdx].version();
|
return g.component[m_id].version();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList UpdateInterface::getReleases()
|
const QStringList UpdateInterface::getReleases()
|
||||||
{
|
{
|
||||||
repoReleasesMetaData();
|
if (!repoReleasesMetaData())
|
||||||
|
return QStringList();
|
||||||
|
|
||||||
return releases->list();
|
return releases->list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,17 +543,20 @@ bool UpdateInterface::repoReleasesMetaData()
|
|||||||
releases->setId(0);
|
releases->setId(0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
releases->getSetId();
|
releases->getSetId();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateInterface::repoReleaseAssetsMetaData()
|
bool UpdateInterface::repoReleaseAssetsMetaData()
|
||||||
{
|
{
|
||||||
|
if (!repoReleasesMetaData())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!downloadReleaseAssetsMetaData(releases->id())) {
|
if (!downloadReleaseAssetsMetaData(releases->id())) {
|
||||||
reportProgress(tr("Unable to download release channel assets information"), QtDebugMsg);
|
reportProgress(tr("Unable to download release assets information"), QtDebugMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,14 +589,14 @@ bool UpdateInterface::setRunFolders()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadDir = QString("%1/%2/%3").arg(params->downloadDir).arg(name).arg(fldr);
|
downloadDir = QString("%1/%2/%3").arg(params->downloadDir).arg(m_name).arg(fldr);
|
||||||
|
|
||||||
if (!checkCreateDirectory(downloadDir, UPDFLG_Download))
|
if (!checkCreateDirectory(downloadDir, UPDFLG_Download))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//reportProgress(tr("Download directory: %1").arg(downloadDir), QtDebugMsg);
|
//reportProgress(tr("Download directory: %1").arg(downloadDir), QtDebugMsg);
|
||||||
|
|
||||||
decompressDir = QString("%1/%2/%3").arg(params->decompressDir).arg(name).arg(fldr);
|
decompressDir = QString("%1/%2/%3").arg(params->decompressDir).arg(m_name).arg(fldr);
|
||||||
|
|
||||||
if (!checkCreateDirectory(decompressDir, UPDFLG_Decompress))
|
if (!checkCreateDirectory(decompressDir, UPDFLG_Decompress))
|
||||||
return false;
|
return false;
|
||||||
@@ -624,6 +629,38 @@ bool UpdateInterface::checkCreateDirectory(const QString & dir, const UpdateFlag
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UpdateInterface::getReleaseJsonAsset(const QString assetName, QJsonDocument * json)
|
||||||
|
{
|
||||||
|
if (!repoReleaseAssetsMetaData())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!assets->getSetId(assetName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!downloadAssetToBuffer(assets->id())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!convertDownloadToJson(json)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UpdateInterface::getRepoJsonFile(const QString filename, QJsonDocument * json)
|
||||||
|
{
|
||||||
|
if (!downloadTextFileToBuffer(filename)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!convertDownloadToJson(json)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool UpdateInterface::downloadReleasesMetaData()
|
bool UpdateInterface::downloadReleasesMetaData()
|
||||||
{
|
{
|
||||||
//progressMessage(tr("Download releases metadata"));
|
//progressMessage(tr("Download releases metadata"));
|
||||||
@@ -649,7 +686,7 @@ bool UpdateInterface::downloadReleaseMetaData(const int releaseId)
|
|||||||
bool UpdateInterface::downloadReleaseAssetsMetaData(const int releaseId)
|
bool UpdateInterface::downloadReleaseAssetsMetaData(const int releaseId)
|
||||||
{
|
{
|
||||||
//progressMessage(tr("Download release %1 assets metadata").arg(releaseId));
|
//progressMessage(tr("Download release %1 assets metadata").arg(releaseId));
|
||||||
downloadMetaData(MDT_ReleaseAssets, assets->urlReleaseAssets(releaseId, resultsPerPage));
|
downloadMetaData(MDT_ReleaseAssets, assets->urlReleaseAssets(releaseId));
|
||||||
return downloadSuccess;
|
return downloadSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1380,10 +1417,10 @@ bool UpdateInterface::asyncInstall()
|
|||||||
bool UpdateInterface::saveReleaseSettings()
|
bool UpdateInterface::saveReleaseSettings()
|
||||||
{
|
{
|
||||||
reportProgress(tr("Save release settings"), QtDebugMsg);
|
reportProgress(tr("Save release settings"), QtDebugMsg);
|
||||||
g.component[m_settingsIdx].release(releases->name());
|
g.component[m_id].release(releases->name());
|
||||||
g.component[m_settingsIdx].version(releases->version());
|
g.component[m_id].version(releases->version());
|
||||||
g.component[m_settingsIdx].id(releases->id());
|
g.component[m_id].releaseId(releases->id());
|
||||||
g.component[m_settingsIdx].date(releases->date());
|
g.component[m_id].date(releases->date());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1405,6 +1442,12 @@ UpdateFactories::~UpdateFactories()
|
|||||||
|
|
||||||
void UpdateFactories::registerUpdateFactory(UpdateFactoryInterface * factory)
|
void UpdateFactories::registerUpdateFactory(UpdateFactoryInterface * factory)
|
||||||
{
|
{
|
||||||
|
foreach (UpdateFactoryInterface * registeredFactory, registeredUpdateFactories) {
|
||||||
|
if (registeredFactory->id() == factory->id()) {
|
||||||
|
qDebug() << "Duplicate factory - id:" << factory->id() << "name:" << factory->name();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
registeredUpdateFactories.append(factory);
|
registeredUpdateFactories.append(factory);
|
||||||
qDebug() << "Registered update factory:" << factory->name();
|
qDebug() << "Registered update factory:" << factory->name();
|
||||||
}
|
}
|
||||||
@@ -1429,63 +1472,60 @@ void UpdateFactories::unregisterUpdateFactories()
|
|||||||
delete factory;
|
delete factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFactories::initAssetSettings(const QString & name)
|
UpdateInterface * UpdateFactories::getInstance(const int id)
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
||||||
if (name == factory->name()) {
|
if (id == factory->id())
|
||||||
factory->instance()->initAssetSettings();
|
return factory->instance();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
qDebug() << "Critical error - Interface not found for id:" << id;
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFactories::saveAssetSettings(const QString & name)
|
const QString UpdateFactories::name(const int id)
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
UpdateInterface * iface = getInstance(id);
|
||||||
if (name == factory->name()) {
|
if (iface)
|
||||||
factory->instance()->saveAssetSettings();
|
return iface->name();
|
||||||
break;
|
|
||||||
}
|
return "";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateParameters * const UpdateFactories::getParams(const QString & name)
|
void UpdateFactories::saveAssetSettings(const int id)
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
UpdateInterface * iface = getInstance(id);
|
||||||
if (name == factory->name()) {
|
if (iface)
|
||||||
return factory->instance()->getParams();
|
iface->saveAssetSettings();
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
UpdateParameters * const UpdateFactories::getParams(const int id)
|
||||||
|
{
|
||||||
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->getParams();
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFactories::resetEnvironment(const QString & name)
|
void UpdateFactories::resetEnvironment(const int id)
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
UpdateInterface * iface = getInstance(id);
|
||||||
if (name == factory->name()) {
|
if (iface)
|
||||||
factory->instance()->resetEnvironment();
|
iface->resetEnvironment();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFactories::resetAllEnvironments()
|
void UpdateFactories::resetAllEnvironments()
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
||||||
resetEnvironment(factory->name());
|
resetEnvironment(factory->id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFactories::setRunUpdate(const QString & name)
|
void UpdateFactories::setRunUpdate(const int id)
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
UpdateInterface * iface = getInstance(id);
|
||||||
if (name == factory->name()) {
|
if (iface)
|
||||||
factory->instance()->setRunUpdate();
|
iface->setRunUpdate();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMap<QString, int> UpdateFactories::sortedComponentsList(bool updateableOnly)
|
const QMap<QString, int> UpdateFactories::sortedComponentsList(bool updateableOnly)
|
||||||
@@ -1495,114 +1535,85 @@ const QMap<QString, int> UpdateFactories::sortedComponentsList(bool updateableOn
|
|||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
||||||
if (updateableOnly && !factory->instance()->isUpdateable())
|
if (updateableOnly && !factory->instance()->isUpdateable())
|
||||||
continue;
|
continue;
|
||||||
map.insert(factory->name(), factory->instance()->settingsIndex());
|
map.insert(factory->name(), factory->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFactories::clearRelease(const QString & name)
|
void UpdateFactories::clearRelease(const int id)
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
UpdateInterface * iface = getInstance(id);
|
||||||
if (name == factory->name()) {
|
if (iface)
|
||||||
factory->instance()->clearRelease();
|
iface->clearRelease();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFactories::setReleaseChannel(const QString & name, int channel)
|
void UpdateFactories::setReleaseChannel(const int id, int channel)
|
||||||
{
|
{
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
UpdateInterface * iface = getInstance(id);
|
||||||
if (name == factory->name()) {
|
if (iface)
|
||||||
factory->instance()->setReleaseChannel(channel);
|
iface->setReleaseChannel(channel);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString UpdateFactories::currentRelease(const QString & name)
|
void UpdateFactories::setReleaseId(const int id, QString val)
|
||||||
{
|
{
|
||||||
QString ret;
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
iface->setReleaseId(val);
|
||||||
if (name == factory->name()) {
|
|
||||||
ret = factory->instance()->currentRelease();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString UpdateFactories::updateRelease(const QString & name)
|
const QString UpdateFactories::currentRelease(const int id)
|
||||||
{
|
{
|
||||||
QString ret;
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->currentRelease();
|
||||||
|
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
return "";
|
||||||
if (name == factory->name()) {
|
|
||||||
ret = factory->instance()->updateRelease();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool UpdateFactories::isLatestRelease(const QString & name)
|
const QString UpdateFactories::updateRelease(const int id)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->updateRelease();
|
||||||
|
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
return "";
|
||||||
if (name == factory->name()) {
|
|
||||||
ret = factory->instance()->isLatestRelease();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString UpdateFactories::latestRelease(const QString & name)
|
const bool UpdateFactories::isLatestRelease(const int id)
|
||||||
{
|
{
|
||||||
QString ret;
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->isLatestRelease();
|
||||||
|
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
return true;
|
||||||
if (name == factory->name()) {
|
|
||||||
ret = factory->instance()->latestRelease();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList UpdateFactories::releases(const QString & name)
|
const QString UpdateFactories::latestRelease(const int id)
|
||||||
{
|
{
|
||||||
QStringList ret;
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->latestRelease();
|
||||||
|
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
return "";
|
||||||
if (name == factory->name()) {
|
|
||||||
ret = factory->instance()->getReleases();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateFactories::update(const QString & name, ProgressWidget * progress)
|
const QStringList UpdateFactories::releases(const int id)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->getReleases();
|
||||||
|
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
return QStringList();
|
||||||
if (name == factory->name()) {
|
}
|
||||||
ret = factory->instance()->update(progress);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
bool UpdateFactories::update(const int id, ProgressWidget * progress)
|
||||||
|
{
|
||||||
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->update(progress);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateFactories::updateAll(ProgressWidget * progress)
|
bool UpdateFactories::updateAll(ProgressWidget * progress)
|
||||||
@@ -1610,7 +1621,7 @@ bool UpdateFactories::updateAll(ProgressWidget * progress)
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
||||||
ret = update(factory->name(), progress);
|
ret = factory->instance()->update(progress);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1618,17 +1629,36 @@ bool UpdateFactories::updateAll(ProgressWidget * progress)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool UpdateFactories::isUpdateAvailable(QStringList & names)
|
const bool UpdateFactories::isUpdateAvailable(QMap<QString, int> & list)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
names.clear();
|
|
||||||
|
list.clear();
|
||||||
|
|
||||||
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) {
|
||||||
if (factory->instance()->isUpdateable() && factory->instance()->isUpdateAvailable()) {
|
if (factory->instance()->isUpdateable() && factory->instance()->isUpdateAvailable()) {
|
||||||
names.append(factory->name());
|
list.insert(factory->name(), factory->id());
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UpdateFactories::getReleaseJsonAsset(const int id, const QString assetName, QJsonDocument * json)
|
||||||
|
{
|
||||||
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->getReleaseJsonAsset(assetName, json);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UpdateFactories::getRepoJsonFile(const int id, const QString filename, QJsonDocument * json)
|
||||||
|
{
|
||||||
|
UpdateInterface * iface = getInstance(id);
|
||||||
|
if (iface)
|
||||||
|
return iface->getRepoJsonFile(filename, json);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -114,10 +114,25 @@ class UpdateInterface : public QWidget
|
|||||||
};
|
};
|
||||||
Q_ENUM(UpdateFlags)
|
Q_ENUM(UpdateFlags)
|
||||||
|
|
||||||
|
// The CID is used as a key to the application settings therefore
|
||||||
|
// ids must be explicit so no renumbering if components removed
|
||||||
|
// new components must be added to the end of the enum
|
||||||
|
enum ComponentIdentity {
|
||||||
|
CID_Unknown = -1,
|
||||||
|
CID_SDCard = 0,
|
||||||
|
CID_Firmware = 1,
|
||||||
|
CID_Sounds = 2,
|
||||||
|
CID_Themes = 3,
|
||||||
|
CID_MultiProtocol = 4,
|
||||||
|
CID_Companion = 5,
|
||||||
|
};
|
||||||
|
Q_ENUM(ComponentIdentity)
|
||||||
|
|
||||||
explicit UpdateInterface(QWidget * parent);
|
explicit UpdateInterface(QWidget * parent);
|
||||||
virtual ~UpdateInterface();
|
virtual ~UpdateInterface();
|
||||||
|
|
||||||
const QString getName() const { return name; }
|
const int id() const { return (int)m_id; }
|
||||||
|
const QString name() const { return m_name; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class UpdateFactories;
|
friend class UpdateFactories;
|
||||||
@@ -127,8 +142,6 @@ class UpdateInterface : public QWidget
|
|||||||
UpdateParameters *params;
|
UpdateParameters *params;
|
||||||
ProgressWidget *progress;
|
ProgressWidget *progress;
|
||||||
|
|
||||||
QString name;
|
|
||||||
int resultsPerPage;
|
|
||||||
QString downloadDir;
|
QString downloadDir;
|
||||||
QString decompressDir;
|
QString decompressDir;
|
||||||
QString updateDir;
|
QString updateDir;
|
||||||
@@ -155,14 +168,17 @@ class UpdateInterface : public QWidget
|
|||||||
virtual const bool isLatestRelease();
|
virtual const bool isLatestRelease();
|
||||||
virtual const bool isLatestVersion(const QString & current, const QString & latest);
|
virtual const bool isLatestVersion(const QString & current, const QString & latest);
|
||||||
virtual QString latestRelease();
|
virtual QString latestRelease();
|
||||||
|
|
||||||
void clearRelease();
|
void clearRelease();
|
||||||
const QStringList getReleases();
|
const QStringList getReleases();
|
||||||
|
|
||||||
void setName(QString name);
|
void init(ComponentIdentity id, QString name, QString repo, QString nightly = "", int resultsPerPage = -1);
|
||||||
void setRepo(QString repo);
|
|
||||||
void setResultsPerPage(int cnt) { resultsPerPage = cnt; }
|
void setId(ComponentIdentity id) { m_id = id; }
|
||||||
void setReleasesNightlyName(QString name) { releases->setNightlyName(name); }
|
void setName(QString name) { m_name = name; }
|
||||||
|
|
||||||
void setReleaseChannel(int channel);
|
void setReleaseChannel(int channel);
|
||||||
|
void setReleaseId(QString val);
|
||||||
|
|
||||||
void setParamFolders();
|
void setParamFolders();
|
||||||
UpdateParameters * getParams() { return params; }
|
UpdateParameters * getParams() { return params; }
|
||||||
@@ -177,6 +193,7 @@ class UpdateInterface : public QWidget
|
|||||||
bool downloadReleaseLatestMetaData();
|
bool downloadReleaseLatestMetaData();
|
||||||
bool downloadReleaseMetaData(const int releaseId);
|
bool downloadReleaseMetaData(const int releaseId);
|
||||||
|
|
||||||
|
bool getReleaseJsonAsset(const QString assetName, QJsonDocument * json);
|
||||||
bool downloadReleaseAssetsMetaData(const int releaseId);
|
bool downloadReleaseAssetsMetaData(const int releaseId);
|
||||||
bool downloadAssetMetaData(const int assetId);
|
bool downloadAssetMetaData(const int assetId);
|
||||||
bool getSetAssets(const UpdateParameters::AssetParams & ap);
|
bool getSetAssets(const UpdateParameters::AssetParams & ap);
|
||||||
@@ -187,6 +204,7 @@ class UpdateInterface : public QWidget
|
|||||||
bool copyFlaggedAssets();
|
bool copyFlaggedAssets();
|
||||||
bool copyStructure();
|
bool copyStructure();
|
||||||
bool copyFiles();
|
bool copyFiles();
|
||||||
|
|
||||||
bool saveReleaseSettings();
|
bool saveReleaseSettings();
|
||||||
|
|
||||||
bool downloadAssetToBuffer(const int assetId);
|
bool downloadAssetToBuffer(const int assetId);
|
||||||
@@ -196,14 +214,15 @@ class UpdateInterface : public QWidget
|
|||||||
bool decompressArchive(const QString & archivePath, const QString & destPath);
|
bool decompressArchive(const QString & archivePath, const QString & destPath);
|
||||||
QByteArray * getDownloadBuffer() { return buffer; }
|
QByteArray * getDownloadBuffer() { return buffer; }
|
||||||
|
|
||||||
|
bool getRepoJsonFile(const QString filename, QJsonDocument * json);
|
||||||
|
|
||||||
void reportProgress(const QString & text, const int type = QtInfoMsg);
|
void reportProgress(const QString & text, const int type = QtInfoMsg);
|
||||||
void progressMessage(const QString & text);
|
void progressMessage(const QString & text);
|
||||||
void criticalMsg(const QString & msg);
|
void criticalMsg(const QString & msg);
|
||||||
static QString downloadDataTypeToString(DownloadDataType val);
|
static QString downloadDataTypeToString(DownloadDataType val);
|
||||||
static QString updateFlagsToString(UpdateFlags val);
|
static QString updateFlagsToString(UpdateFlags val);
|
||||||
void setFlavourLanguage();
|
void setFlavourLanguage();
|
||||||
int settingsIndex() { return m_settingsIdx; }
|
bool isValidSettingsIndex() { return m_id > -1 && m_id < MAX_COMPONENTS; }
|
||||||
bool isValidSettingsIndex() { return m_settingsIdx > -1 && m_settingsIdx < MAX_COMPONENTS; }
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDownloadFinished(QNetworkReply * reply, DownloadDataType ddt, int subtype);
|
void onDownloadFinished(QNetworkReply * reply, DownloadDataType ddt, int subtype);
|
||||||
@@ -215,13 +234,14 @@ class UpdateInterface : public QWidget
|
|||||||
QByteArray *buffer;
|
QByteArray *buffer;
|
||||||
QFile *file;
|
QFile *file;
|
||||||
QUrl url;
|
QUrl url;
|
||||||
|
int m_id;
|
||||||
|
QString m_name;
|
||||||
|
|
||||||
bool downloadSuccess;
|
bool downloadSuccess;
|
||||||
int m_settingsIdx;
|
|
||||||
|
|
||||||
static QString semanticVersion(QString version);
|
static QString semanticVersion(QString version);
|
||||||
|
|
||||||
void setSettingsIndex();
|
void initAppSettings();
|
||||||
bool setRunFolders();
|
bool setRunFolders();
|
||||||
bool checkCreateDirectory(const QString & dirSetting, const UpdateFlags flag);
|
bool checkCreateDirectory(const QString & dirSetting, const UpdateFlags flag);
|
||||||
|
|
||||||
@@ -238,7 +258,8 @@ class UpdateFactoryInterface
|
|||||||
explicit UpdateFactoryInterface() {}
|
explicit UpdateFactoryInterface() {}
|
||||||
virtual ~UpdateFactoryInterface() {}
|
virtual ~UpdateFactoryInterface() {}
|
||||||
virtual UpdateInterface * instance() = 0;
|
virtual UpdateInterface * instance() = 0;
|
||||||
virtual QString name() = 0;
|
virtual const QString name() = 0;
|
||||||
|
virtual const int id() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -252,7 +273,8 @@ class UpdateFactory : public UpdateFactoryInterface
|
|||||||
virtual ~UpdateFactory() {}
|
virtual ~UpdateFactory() {}
|
||||||
|
|
||||||
virtual UpdateInterface * instance() { return m_instance; }
|
virtual UpdateInterface * instance() { return m_instance; }
|
||||||
virtual QString name() { return m_instance->getName(); }
|
virtual const QString name() { return m_instance->name(); }
|
||||||
|
virtual const int id() { return m_instance->id(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UpdateInterface *m_instance;
|
UpdateInterface *m_instance;
|
||||||
@@ -266,31 +288,38 @@ class UpdateFactories : public QWidget
|
|||||||
explicit UpdateFactories(QWidget * parent = nullptr);
|
explicit UpdateFactories(QWidget * parent = nullptr);
|
||||||
virtual ~UpdateFactories();
|
virtual ~UpdateFactories();
|
||||||
|
|
||||||
|
const QString name(const int id);
|
||||||
|
|
||||||
void registerUpdateFactory(UpdateFactoryInterface * factory);
|
void registerUpdateFactory(UpdateFactoryInterface * factory);
|
||||||
void registerUpdateFactories();
|
void registerUpdateFactories();
|
||||||
void unregisterUpdateFactories();
|
void unregisterUpdateFactories();
|
||||||
|
|
||||||
void initAssetSettings(const QString & name);
|
void saveAssetSettings(const int id);
|
||||||
void saveAssetSettings(const QString & name);
|
|
||||||
|
|
||||||
UpdateParameters * const getParams(const QString & name);
|
UpdateParameters * const getParams(const int id);
|
||||||
void resetEnvironment(const QString & name);
|
void resetEnvironment(const int id);
|
||||||
void resetAllEnvironments();
|
void resetAllEnvironments();
|
||||||
void setRunUpdate(const QString & name);
|
void setRunUpdate(const int id);
|
||||||
const QMap<QString, int> sortedComponentsList(bool updateableOnly = false);
|
const QMap<QString, int> sortedComponentsList(bool updateableOnly = false);
|
||||||
|
|
||||||
void clearRelease(const QString & name);
|
void clearRelease(const int id);
|
||||||
void setReleaseChannel(const QString & name, int channel);
|
void setReleaseChannel(const int id, int channel);
|
||||||
const QString currentRelease(const QString & name);
|
void setReleaseId(const int id, QString val);
|
||||||
const QString updateRelease(const QString & name);
|
const QString currentRelease(const int id);
|
||||||
const bool isLatestRelease(const QString & name);
|
const QString updateRelease(const int id);
|
||||||
const QString latestRelease(const QString & name);
|
const bool isLatestRelease(const int id);
|
||||||
const QStringList releases(const QString & name);
|
const QString latestRelease(const int id);
|
||||||
|
const QStringList releases(const int id);
|
||||||
|
bool getReleaseJsonAsset(const int id, const QString assetName, QJsonDocument * json);
|
||||||
|
|
||||||
bool update(const QString & name, ProgressWidget * progress = nullptr);
|
bool getRepoJsonFile(const int id, const QString filename, QJsonDocument * json);
|
||||||
|
|
||||||
|
bool update(const int id, ProgressWidget * progress = nullptr);
|
||||||
bool updateAll(ProgressWidget * progress = nullptr);
|
bool updateAll(ProgressWidget * progress = nullptr);
|
||||||
const bool isUpdateAvailable(QStringList & names);
|
const bool isUpdateAvailable(QMap<QString, int> & names);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<UpdateFactoryInterface *> registeredUpdateFactories;
|
QVector<UpdateFactoryInterface *> registeredUpdateFactories;
|
||||||
|
|
||||||
|
UpdateInterface * getInstance(const int id);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,9 +24,8 @@
|
|||||||
UpdateMultiProtocol::UpdateMultiProtocol(QWidget * parent) :
|
UpdateMultiProtocol::UpdateMultiProtocol(QWidget * parent) :
|
||||||
UpdateInterface(parent)
|
UpdateInterface(parent)
|
||||||
{
|
{
|
||||||
setName(tr("Multiprotocol"));
|
// GitHub REST API default ResultsPerPage = 30
|
||||||
setRepo(QString(GITHUB_API_REPOS).append("/pascallanger/DIY-Multiprotocol-TX-Module"));
|
init(CID_MultiProtocol, tr("Multiprotocol"), QString(GITHUB_API_REPOS).append("/pascallanger/DIY-Multiprotocol-TX-Module"), "", 50);
|
||||||
setResultsPerPage(50); // GitHub REST API default 30
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateMultiProtocol::initAssetSettings()
|
void UpdateMultiProtocol::initAssetSettings()
|
||||||
@@ -34,10 +33,10 @@ void UpdateMultiProtocol::initAssetSettings()
|
|||||||
if (!isValidSettingsIndex())
|
if (!isValidSettingsIndex())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g.component[settingsIndex()].initAllAssets();
|
g.component[id()].initAllAssets();
|
||||||
|
|
||||||
{
|
{
|
||||||
ComponentAssetData &cad = g.component[settingsIndex()].asset[0];
|
ComponentAssetData &cad = g.component[id()].asset[0];
|
||||||
cad.desc("scripts");
|
cad.desc("scripts");
|
||||||
cad.processes(UPDFLG_Common_Asset);
|
cad.processes(UPDFLG_Common_Asset);
|
||||||
cad.flags(cad.processes() | UPDFLG_CopyStructure);
|
cad.flags(cad.processes() | UPDFLG_CopyStructure);
|
||||||
@@ -46,7 +45,7 @@ void UpdateMultiProtocol::initAssetSettings()
|
|||||||
cad.maxExpected(1);
|
cad.maxExpected(1);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ComponentAssetData &cad = g.component[settingsIndex()].asset[1];
|
ComponentAssetData &cad = g.component[id()].asset[1];
|
||||||
cad.desc("binaries");
|
cad.desc("binaries");
|
||||||
cad.processes(UPDFLG_Common_Asset &~ UPDFLG_Decompress);
|
cad.processes(UPDFLG_Common_Asset &~ UPDFLG_Decompress);
|
||||||
cad.flags(cad.processes() | UPDFLG_CopyFiles);
|
cad.flags(cad.processes() | UPDFLG_CopyFiles);
|
||||||
|
|||||||
@@ -35,24 +35,24 @@ UpdateOptionsDialog::UpdateOptionsDialog(QWidget * parent, UpdateFactories * fac
|
|||||||
ui(new Ui::UpdateOptionsDialog),
|
ui(new Ui::UpdateOptionsDialog),
|
||||||
factories(factories),
|
factories(factories),
|
||||||
idx(idx),
|
idx(idx),
|
||||||
name(g.component[idx].name()),
|
|
||||||
isRun(isRun)
|
isRun(isRun)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
if (!isRun) factories->resetEnvironment(name);
|
if (!isRun)
|
||||||
|
factories->resetEnvironment(idx);
|
||||||
|
|
||||||
params = factories->getParams(name);
|
params = factories->getParams(idx);
|
||||||
|
|
||||||
setWindowTitle(tr("%1 %2").arg(name).arg(tr("Options")));
|
setWindowTitle(tr("%1 %2").arg(factories->name(idx)).arg(tr("Options")));
|
||||||
|
|
||||||
ui->txtCurrentRelease->setText(factories->currentRelease(name));
|
ui->txtCurrentRelease->setText(factories->currentRelease(idx));
|
||||||
|
|
||||||
connect(ui->btnClearRelease, &QPushButton::clicked, [=]() {
|
connect(ui->btnClearRelease, &QPushButton::clicked, [=]() {
|
||||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear current release information. Are you sure?"),
|
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear current release information. Are you sure?"),
|
||||||
QMessageBox::Yes |QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
|
QMessageBox::Yes |QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
|
||||||
factories->clearRelease(name);
|
factories->clearRelease(idx);
|
||||||
ui->txtCurrentRelease->setText(factories->currentRelease(name));
|
ui->txtCurrentRelease->setText(factories->currentRelease(idx));
|
||||||
emit changed(idx);
|
emit changed(idx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ class UpdateOptionsDialog : public QDialog
|
|||||||
Ui::UpdateOptionsDialog *ui;
|
Ui::UpdateOptionsDialog *ui;
|
||||||
UpdateFactories *factories;
|
UpdateFactories *factories;
|
||||||
const int idx;
|
const int idx;
|
||||||
const QString name;
|
|
||||||
const bool isRun;
|
const bool isRun;
|
||||||
UpdateParameters *params;
|
UpdateParameters *params;
|
||||||
|
|
||||||
|
|||||||
@@ -67,23 +67,35 @@ void Updates::autoUpdates(bool interactive)
|
|||||||
|
|
||||||
factories->resetAllEnvironments();
|
factories->resetAllEnvironments();
|
||||||
|
|
||||||
QStringList list;
|
QMap<QString, int> components;
|
||||||
|
|
||||||
if (!factories->isUpdateAvailable(list)) {
|
if (!factories->isUpdateAvailable(components)) {
|
||||||
if (interactive)
|
if (interactive)
|
||||||
QMessageBox::information(parentWidget(), CPN_STR_APP_NAME, tr("No updates available at this time"));
|
QMessageBox::information(parentWidget(), CPN_STR_APP_NAME, tr("No updates available at this time"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMapIterator<QString, int> it(components);
|
||||||
|
|
||||||
|
QStringList list;
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
list << it.key();
|
||||||
|
}
|
||||||
|
|
||||||
if (QMessageBox::question(parentWidget(), CPN_STR_APP_NAME % ": " % tr("Checking for Updates"),
|
if (QMessageBox::question(parentWidget(), CPN_STR_APP_NAME % ": " % tr("Checking for Updates"),
|
||||||
tr("Updates available for:\n - %1\n\nProcess now?").arg(list.join("\n - ")),
|
tr("Updates available for:\n - %1\n\nProcess now?").arg(list.join("\n - ")),
|
||||||
(QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::No) {
|
(QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::No) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < list.count(); i++) {
|
it.toFront();
|
||||||
factories->setRunUpdate(list.at(i));
|
|
||||||
factories->updateRelease(list.at(i));
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
factories->setRunUpdate(it.value());
|
||||||
|
factories->updateRelease(it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
runUpdate();
|
runUpdate();
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
UpdateSDCard::UpdateSDCard(QWidget * parent) :
|
UpdateSDCard::UpdateSDCard(QWidget * parent) :
|
||||||
UpdateInterface(parent)
|
UpdateInterface(parent)
|
||||||
{
|
{
|
||||||
setName(tr("SD Card"));
|
init(CID_SDCard, tr("SD Card"), QString(GH_REPOS_EDGETX).append("/edgetx-sdcard"));
|
||||||
setRepo(QString(GH_REPOS_EDGETX).append("/edgetx-sdcard"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateSDCard::initAssetSettings()
|
void UpdateSDCard::initAssetSettings()
|
||||||
@@ -35,9 +34,9 @@ void UpdateSDCard::initAssetSettings()
|
|||||||
if (!isValidSettingsIndex())
|
if (!isValidSettingsIndex())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g.component[settingsIndex()].initAllAssets();
|
g.component[id()].initAllAssets();
|
||||||
|
|
||||||
ComponentAssetData &cad = g.component[settingsIndex()].asset[0];
|
ComponentAssetData &cad = g.component[id()].asset[0];
|
||||||
cad.desc("files");
|
cad.desc("files");
|
||||||
cad.processes(UPDFLG_Common_Asset);
|
cad.processes(UPDFLG_Common_Asset);
|
||||||
cad.flags(cad.processes() | UPDFLG_Locked | UPDFLG_CopyStructure);
|
cad.flags(cad.processes() | UPDFLG_Locked | UPDFLG_CopyStructure);
|
||||||
@@ -54,8 +53,8 @@ bool UpdateSDCard::flagAssets()
|
|||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"targets": [
|
"targets": [
|
||||||
["Flysky NV14", "nv14-", "nv14"],
|
["Flysky NV14", "nv14-", "c320x480"],
|
||||||
["FrSky Horus X10", "x10-", "horus"],
|
["FrSky Horus X10", "x10-", "c480x272"],
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const QString mappingfile = "sdcard.json";
|
const QString mappingfile = "sdcard.json";
|
||||||
|
|||||||
@@ -163,8 +163,7 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
|
|||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
int i = it.value();
|
const int i = it.value();
|
||||||
|
|
||||||
const QString name = it.key();
|
const QString name = it.key();
|
||||||
|
|
||||||
row++;
|
row++;
|
||||||
@@ -173,7 +172,7 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
|
|||||||
msg->setText(tr("Retrieving latest release information for %1").arg(name));
|
msg->setText(tr("Retrieving latest release information for %1").arg(name));
|
||||||
chkUpdate[i] = new QCheckBox();
|
chkUpdate[i] = new QCheckBox();
|
||||||
chkUpdate[i]->setProperty("index", i);
|
chkUpdate[i]->setProperty("index", i);
|
||||||
chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
|
chkUpdate[i]->setChecked(!factories->isLatestRelease(i));
|
||||||
grid->addWidget(chkUpdate[i], row, col++);
|
grid->addWidget(chkUpdate[i], row, col++);
|
||||||
grid->setAlignment(chkUpdate[i], Qt::AlignHCenter);
|
grid->setAlignment(chkUpdate[i], Qt::AlignHCenter);
|
||||||
|
|
||||||
@@ -185,27 +184,26 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
|
|||||||
cboRelChannel[i]->setCurrentIndex(g.component[i].releaseChannel());
|
cboRelChannel[i]->setCurrentIndex(g.component[i].releaseChannel());
|
||||||
grid->addWidget(cboRelChannel[i], row, col++);
|
grid->addWidget(cboRelChannel[i], row, col++);
|
||||||
|
|
||||||
lblCurrentRel[i] = new QLabel(factories->currentRelease(name));
|
lblCurrentRel[i] = new QLabel(factories->currentRelease(i));
|
||||||
grid->addWidget(lblCurrentRel[i], row, col++);
|
grid->addWidget(lblCurrentRel[i], row, col++);
|
||||||
|
|
||||||
cboUpdateRel[i] = new QComboBox();
|
cboUpdateRel[i] = new QComboBox();
|
||||||
cboUpdateRel[i]->addItems(factories->releases(name));
|
cboUpdateRel[i]->addItems(factories->releases(i));
|
||||||
grid->addWidget(cboUpdateRel[i], row, col++);
|
grid->addWidget(cboUpdateRel[i], row, col++);
|
||||||
|
|
||||||
connect(cboRelChannel[i], QOverload<int>::of(&QComboBox::currentIndexChanged), [=] (const int index) {
|
connect(cboRelChannel[i], QOverload<int>::of(&QComboBox::currentIndexChanged), [=] (const int index) {
|
||||||
factories->setReleaseChannel(name, index);
|
factories->setReleaseChannel(i, index);
|
||||||
cboUpdateRel[i]->clear();
|
cboUpdateRel[i]->clear();
|
||||||
cboUpdateRel[i]->addItems(factories->releases(name));
|
cboUpdateRel[i]->addItems(factories->releases(i));
|
||||||
});
|
});
|
||||||
|
|
||||||
btnOptions[i] = new QPushButton(tr("Options"));
|
btnOptions[i] = new QPushButton(tr("Options"));
|
||||||
connect(btnOptions[i], &QPushButton::clicked, [=]() {
|
connect(btnOptions[i], &QPushButton::clicked, [=]() {
|
||||||
UpdateOptionsDialog *dlg = new UpdateOptionsDialog(this, factories, i, true);
|
UpdateOptionsDialog *dlg = new UpdateOptionsDialog(this, factories, i, true);
|
||||||
connect(dlg, &UpdateOptionsDialog::changed, [=](const int i) {
|
connect(dlg, &UpdateOptionsDialog::changed, [=](const int i) {
|
||||||
QString name = g.component[i].name();
|
chkUpdate[i]->setChecked(!factories->isLatestRelease(i));
|
||||||
chkUpdate[i]->setChecked(!factories->isLatestRelease(name));
|
lblCurrentRel[i]->setText(factories->currentRelease(i));
|
||||||
lblCurrentRel[i]->setText(factories->currentRelease(name));
|
cboUpdateRel[i]->setCurrentText(factories->updateRelease(i));
|
||||||
cboUpdateRel[i]->setCurrentText(factories->updateRelease(name));
|
|
||||||
});
|
});
|
||||||
dlg->exec();
|
dlg->exec();
|
||||||
dlg->deleteLater();
|
dlg->deleteLater();
|
||||||
@@ -270,12 +268,11 @@ void UpdatesDialog::accept()
|
|||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
int i = it.value();
|
const int i = it.value();
|
||||||
|
|
||||||
if (chkUpdate[i]->isChecked()) {
|
if (chkUpdate[i]->isChecked()) {
|
||||||
cnt++;
|
cnt++;
|
||||||
const QString name = it.key();
|
UpdateParameters *params = factories->getParams(i);
|
||||||
UpdateParameters *params = factories->getParams(name);
|
|
||||||
params->updateRelease = cboUpdateRel[i]->currentText();
|
params->updateRelease = cboUpdateRel[i]->currentText();
|
||||||
params->flags |= UpdateInterface::UPDFLG_Update;
|
params->flags |= UpdateInterface::UPDFLG_Update;
|
||||||
params->downloadDir = ui->leDownloadDir->text();
|
params->downloadDir = ui->leDownloadDir->text();
|
||||||
@@ -316,8 +313,8 @@ void UpdatesDialog::saveAsDefaults()
|
|||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
int i = it.value();
|
const int i = it.value();
|
||||||
g.component[i].releaseChannel((ComponentData::ReleaseChannel)cboRelChannel[i]->currentIndex());
|
g.component[i].releaseChannel((ComponentData::ReleaseChannel)cboRelChannel[i]->currentIndex());
|
||||||
factories->saveAssetSettings(it.key());
|
factories->saveAssetSettings(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,10 @@
|
|||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
|
|
||||||
UpdateSounds::UpdateSounds(QWidget * parent) :
|
UpdateSounds::UpdateSounds(QWidget * parent) :
|
||||||
UpdateInterface(parent),
|
UpdateInterface(parent)
|
||||||
langPacks(new QStandardItemModel())
|
|
||||||
{
|
{
|
||||||
setName(tr("Sounds"));
|
init(CID_Sounds, tr("Sounds"), QString(GH_REPOS_EDGETX).append("/edgetx-sdcard-sounds"));
|
||||||
setRepo(QString(GH_REPOS_EDGETX).append("/edgetx-sdcard-sounds"));
|
langPacks = new QStandardItemModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSounds::~UpdateSounds()
|
UpdateSounds::~UpdateSounds()
|
||||||
@@ -44,9 +43,9 @@ void UpdateSounds::initAssetSettings()
|
|||||||
if (!isValidSettingsIndex())
|
if (!isValidSettingsIndex())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g.component[settingsIndex()].initAllAssets();
|
g.component[id()].initAllAssets();
|
||||||
|
|
||||||
ComponentAssetData &cad = g.component[settingsIndex()].asset[0];
|
ComponentAssetData &cad = g.component[id()].asset[0];
|
||||||
cad.desc("sounds");
|
cad.desc("sounds");
|
||||||
cad.processes(UPDFLG_Common_Asset);
|
cad.processes(UPDFLG_Common_Asset);
|
||||||
cad.flags(cad.processes() | UPDFLG_CopyStructure);
|
cad.flags(cad.processes() | UPDFLG_CopyStructure);
|
||||||
|
|||||||
@@ -24,8 +24,7 @@
|
|||||||
UpdateThemes::UpdateThemes(QWidget * parent) :
|
UpdateThemes::UpdateThemes(QWidget * parent) :
|
||||||
UpdateInterface(parent)
|
UpdateInterface(parent)
|
||||||
{
|
{
|
||||||
setName(tr("Themes"));
|
init(CID_Themes, tr("Themes"), QString(GH_REPOS_EDGETX).append("/themes"));
|
||||||
setRepo(QString(GH_REPOS_EDGETX).append("/themes"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateThemes::initAssetSettings()
|
void UpdateThemes::initAssetSettings()
|
||||||
@@ -33,9 +32,9 @@ void UpdateThemes::initAssetSettings()
|
|||||||
if (!isValidSettingsIndex())
|
if (!isValidSettingsIndex())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g.component[settingsIndex()].initAllAssets();
|
g.component[id()].initAllAssets();
|
||||||
|
|
||||||
ComponentAssetData &cad = g.component[settingsIndex()].asset[0];
|
ComponentAssetData &cad = g.component[id()].asset[0];
|
||||||
cad.desc("files");
|
cad.desc("files");
|
||||||
cad.processes(UPDFLG_Common_Asset);
|
cad.processes(UPDFLG_Common_Asset);
|
||||||
cad.flags(cad.processes() | UPDFLG_CopyStructure);
|
cad.flags(cad.processes() | UPDFLG_CopyStructure);
|
||||||
|
|||||||
Reference in New Issue
Block a user