Delay initialisation of fw flavour and language until update process runs
This commit is contained in:
@@ -39,7 +39,7 @@ UpdateFirmware::UpdateFirmware(QWidget * parent) :
|
|||||||
ap.flags = dfltParams->data.flags | UPDFLG_CopyFiles;
|
ap.flags = dfltParams->data.flags | UPDFLG_CopyFiles;
|
||||||
ap.destSubDir = "FIRMWARE";
|
ap.destSubDir = "FIRMWARE";
|
||||||
ap.copyFilterType = UpdateParameters::UFT_Expression;
|
ap.copyFilterType = UpdateParameters::UFT_Expression;
|
||||||
ap.copyFilter = QString("^%1-.*\\.bin$").arg(fwFlavour);
|
ap.copyFilter = QString("^%FWFLAVOUR%-.*\\.bin$");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateFirmware::asyncInstall()
|
bool UpdateFirmware::asyncInstall()
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ UpdateParameters& UpdateParameters::operator=(const UpdateParameters& source)
|
|||||||
|
|
||||||
if (this != &source) {
|
if (this != &source) {
|
||||||
data.flags = source.data.flags;
|
data.flags = source.data.flags;
|
||||||
|
data.fwFlavour = source.data.fwFlavour;
|
||||||
|
data.language = source.data.language;
|
||||||
data.currentRelease = source.data.currentRelease;
|
data.currentRelease = source.data.currentRelease;
|
||||||
data.updateRelease = source.data.updateRelease;
|
data.updateRelease = source.data.updateRelease;
|
||||||
data.downloadDir = source.data.downloadDir;
|
data.downloadDir = source.data.downloadDir;
|
||||||
@@ -94,10 +96,12 @@ UpdateParameters::AssetParams & UpdateParameters::addAsset()
|
|||||||
return data.assets[data.assets.size() - 1];
|
return data.assets[data.assets.size() - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
QString UpdateParameters::buildFilterPattern(const UpdateParameters::UpdateFilterType filterType, const QString & filter)
|
QString UpdateParameters::buildFilterPattern(const UpdateParameters::UpdateFilterType filterType, const QString & filter)
|
||||||
{
|
{
|
||||||
QString pattern = filter;
|
QString pattern(filter);
|
||||||
|
|
||||||
|
pattern.replace("%FWFLAVOUR%", data.fwFlavour);
|
||||||
|
pattern.replace("%LANGUAGE%", data.language);
|
||||||
|
|
||||||
switch ((int)filterType) {
|
switch ((int)filterType) {
|
||||||
case UpdateParameters::UFT_Exact:
|
case UpdateParameters::UFT_Exact:
|
||||||
@@ -154,13 +158,9 @@ UpdateInterface::UpdateInterface(QWidget * parent) :
|
|||||||
dfltParams = new UpdateParameters(this);
|
dfltParams = new UpdateParameters(this);
|
||||||
runParams = new UpdateParameters(this);
|
runParams = new UpdateParameters(this);
|
||||||
|
|
||||||
getRadioProfileSettings();
|
|
||||||
|
|
||||||
setReleasesNightlyName("");
|
setReleasesNightlyName("");
|
||||||
dfltParams->data.flags = UPDFLG_Common;
|
dfltParams->data.flags = UPDFLG_Common;
|
||||||
resultsPerPage = -1;
|
resultsPerPage = -1;
|
||||||
|
|
||||||
initParamFolders(dfltParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateInterface::~UpdateInterface()
|
UpdateInterface::~UpdateInterface()
|
||||||
@@ -381,6 +381,9 @@ void UpdateInterface::resetRunEnvironment()
|
|||||||
progress = nullptr;
|
progress = nullptr;
|
||||||
logLevel = g.updLogLevel();
|
logLevel = g.updLogLevel();
|
||||||
|
|
||||||
|
initFlavourLanguage(dfltParams);
|
||||||
|
initParamFolders(dfltParams);
|
||||||
|
|
||||||
*runParams = *dfltParams;
|
*runParams = *dfltParams;
|
||||||
runParams->data.flags &= ~UPDFLG_Update;
|
runParams->data.flags &= ~UPDFLG_Update;
|
||||||
|
|
||||||
@@ -417,23 +420,26 @@ void UpdateInterface::setSettingsIdx()
|
|||||||
releases->setSettingsIndex(idx);
|
releases->setSettingsIndex(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateInterface::getRadioProfileSettings()
|
void UpdateInterface::initFlavourLanguage(UpdateParameters * params)
|
||||||
{
|
{
|
||||||
// eg edgetx-ts16s-en
|
const Firmware * baseFw = getCurrentFirmware()->getFirmwareBase();
|
||||||
QStringList strl = QStringList(g.currentProfile().fwType().split('-'));
|
const QStringList currVariant = getCurrentFirmware()->getId().split('-');
|
||||||
|
|
||||||
if (strl.size() < 1) {
|
params->data.fwFlavour = "";
|
||||||
//reportProgress(tr("Settings radio profile firmware type unexpected format"), QtWarningMsg);
|
|
||||||
return;
|
if (currVariant.size() > 1) {
|
||||||
|
params->data.fwFlavour = currVariant.at(1);
|
||||||
|
params->data.fwFlavour = params->data.fwFlavour.replace('+', 'p');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strl.size() > 1) {
|
params->data.language = "";
|
||||||
fwFlavour = strl.at(1);
|
|
||||||
fwFlavour = fwFlavour.replace('+', 'p');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strl.size() > 2)
|
for (const char *lang : baseFw->languageList()) {
|
||||||
language = strl.at(2);
|
if (currVariant.last() == lang) {
|
||||||
|
params->data.language = currVariant.last();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateInterface::clearRelease()
|
void UpdateInterface::clearRelease()
|
||||||
@@ -818,20 +824,19 @@ bool UpdateInterface::convertDownloadToJson(QJsonDocument * json)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateInterface::getSetAssets(const int flags, const UpdateParameters::UpdateFilterType assetsFilterType, const QString & assetsFilter, const int maxAssetsExpected,
|
bool UpdateInterface::getSetAssets(const UpdateParameters::AssetParams & ap)
|
||||||
const QString & subDirectory, const UpdateParameters::UpdateFilterType copyFilterType, const QString & copyFilter)
|
|
||||||
{
|
{
|
||||||
QString pattern(UpdateParameters::buildFilterPattern(assetsFilterType, assetsFilter));
|
QString pattern(runParams->buildFilterPattern(ap.filterType, ap.filter));
|
||||||
assets->setFilterPattern(pattern);
|
assets->setFilterPattern(pattern);
|
||||||
//reportProgress(tr("Asset filter applied: %1").arg(pattern), QtDebugMsg);
|
//reportProgress(tr("Asset filter applied: %1").arg(pattern), QtDebugMsg);
|
||||||
|
|
||||||
if (assets->count() < 0) {
|
if (assets->count() < 0) {
|
||||||
reportProgress(tr("No assets not found in release '%1' using filter pattern '%2'").arg(releases->name().arg(assetsFilter)), QtCriticalMsg);
|
reportProgress(tr("No assets not found in release '%1' using filter pattern '%2'").arg(releases->name().arg(pattern)), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (maxAssetsExpected > -1 && assets->count() > maxAssetsExpected) {
|
else if (ap.maxExpected > -1 && assets->count() > ap.maxExpected) {
|
||||||
reportProgress(tr("%1 assets found when %2 expected in release '%3' using filter pattern '%4'")
|
reportProgress(tr("%1 assets found when %2 expected in release '%3' using filter pattern '%4'")
|
||||||
.arg(assets->count()).arg(maxAssetsExpected).arg(releases->name().arg(assetsFilter)), QtCriticalMsg);
|
.arg(assets->count()).arg(ap.maxExpected).arg(releases->name().arg(pattern)), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,17 +844,17 @@ bool UpdateInterface::getSetAssets(const int flags, const UpdateParameters::Upda
|
|||||||
|
|
||||||
for (int i = 0; i < assets->count(); i++) {
|
for (int i = 0; i < assets->count(); i++) {
|
||||||
assets->getSetId(i);
|
assets->getSetId(i);
|
||||||
if (!assets->setFlags(flags)) {
|
if (!assets->setFlags(ap.flags)) {
|
||||||
reportProgress(tr("Unable to set processing flags for asset %1").arg(assets->filename()), QtCriticalMsg);
|
reportProgress(tr("Unable to set processing flags for asset %1").arg(assets->filename()), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!assets->setSubDirectory(subDirectory)) {
|
if (!assets->setSubDirectory(ap.destSubDir)) {
|
||||||
reportProgress(tr("Unable to set sub directory for asset %1").arg(assets->filename()), QtCriticalMsg);
|
reportProgress(tr("Unable to set sub directory for asset %1").arg(assets->filename()), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!assets->setCopyFilter(UpdateParameters::buildFilterPattern(copyFilterType, copyFilter))) {
|
if (!assets->setCopyFilter(runParams->buildFilterPattern(ap.copyFilterType, ap.copyFilter))) {
|
||||||
reportProgress(tr("Unable to set copy filter for asset %1").arg(assets->filename()), QtCriticalMsg);
|
reportProgress(tr("Unable to set copy filter for asset %1").arg(assets->filename()), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -914,8 +919,6 @@ void UpdateInterface::downloadBinaryToFile(const QString & url, const QString &
|
|||||||
download(DDT_SaveToFile, 0, url, GH_ACCEPT_HEADER_BINARY, f.absoluteFilePath());
|
download(DDT_SaveToFile, 0, url, GH_ACCEPT_HEADER_BINARY, f.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool UpdateInterface::decompressFlaggedAssets()
|
bool UpdateInterface::decompressFlaggedAssets()
|
||||||
{
|
{
|
||||||
assets->setFilterFlags(UPDFLG_Decompress);
|
assets->setFilterFlags(UPDFLG_Decompress);
|
||||||
@@ -1263,8 +1266,8 @@ bool UpdateInterface::flagAssets()
|
|||||||
progressMessage(tr("Flagging assets"));
|
progressMessage(tr("Flagging assets"));
|
||||||
|
|
||||||
for (int i = 0; i < runParams->data.assets.size(); i++) {
|
for (int i = 0; i < runParams->data.assets.size(); i++) {
|
||||||
const UpdateParameters::AssetParams &ap = runParams->data.assets.at(i);
|
const UpdateParameters::AssetParams & ap = runParams->data.assets.at(i);
|
||||||
if (!getSetAssets(ap.flags, ap.filterType, ap.filter, ap.maxExpected, ap.destSubDir, ap.copyFilterType, ap.copyFilter))
|
if (!getSetAssets(ap))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ class UpdateParameters : public QWidget
|
|||||||
|
|
||||||
struct GeneralParams{
|
struct GeneralParams{
|
||||||
int flags;
|
int flags;
|
||||||
|
QString fwFlavour;
|
||||||
|
QString language;
|
||||||
QString currentRelease;
|
QString currentRelease;
|
||||||
QString updateRelease;
|
QString updateRelease;
|
||||||
QString downloadDir;
|
QString downloadDir;
|
||||||
@@ -76,7 +78,7 @@ class UpdateParameters : public QWidget
|
|||||||
virtual ~UpdateParameters() {}
|
virtual ~UpdateParameters() {}
|
||||||
|
|
||||||
AssetParams & addAsset();
|
AssetParams & addAsset();
|
||||||
static QString buildFilterPattern(const UpdateFilterType filterType, const QString & filter);
|
QString buildFilterPattern(const UpdateFilterType filterType, const QString & filter);
|
||||||
|
|
||||||
UpdateParameters& operator=(const UpdateParameters& source);
|
UpdateParameters& operator=(const UpdateParameters& source);
|
||||||
};
|
};
|
||||||
@@ -132,8 +134,6 @@ class UpdateInterface : public QWidget
|
|||||||
QString downloadDir;
|
QString downloadDir;
|
||||||
QString decompressDir;
|
QString decompressDir;
|
||||||
QString updateDir;
|
QString updateDir;
|
||||||
QString fwFlavour;
|
|
||||||
QString language;
|
|
||||||
int logLevel;
|
int logLevel;
|
||||||
|
|
||||||
virtual bool autoUpdate(ProgressWidget * progress = nullptr);
|
virtual bool autoUpdate(ProgressWidget * progress = nullptr);
|
||||||
@@ -179,9 +179,7 @@ class UpdateInterface : public QWidget
|
|||||||
|
|
||||||
bool downloadReleaseAssetsMetaData(const int releaseId);
|
bool downloadReleaseAssetsMetaData(const int releaseId);
|
||||||
bool downloadAssetMetaData(const int assetId);
|
bool downloadAssetMetaData(const int assetId);
|
||||||
bool getSetAssets(const int flags, const UpdateParameters::UpdateFilterType assetFilterType, const QString & assetsFilter,
|
bool getSetAssets(const UpdateParameters::AssetParams & ap);
|
||||||
const int maxAssetsExpected, const QString & subDirectory,
|
|
||||||
const UpdateParameters::UpdateFilterType copyFilterType, const QString & copyFilter);
|
|
||||||
bool downloadAsset(int row);
|
bool downloadAsset(int row);
|
||||||
bool downloadFlaggedAssets();
|
bool downloadFlaggedAssets();
|
||||||
bool decompressAsset(int row);
|
bool decompressAsset(int row);
|
||||||
@@ -202,7 +200,7 @@ class UpdateInterface : public QWidget
|
|||||||
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 getRadioProfileSettings();
|
void initFlavourLanguage(UpdateParameters * params);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDownloadFinished(QNetworkReply * reply, DownloadDataType ddt, int subtype);
|
void onDownloadFinished(QNetworkReply * reply, DownloadDataType ddt, int subtype);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ UpdateSDCard::UpdateSDCard(QWidget * parent) :
|
|||||||
|
|
||||||
UpdateParameters::AssetParams &ap = dfltParams->addAsset();
|
UpdateParameters::AssetParams &ap = dfltParams->addAsset();
|
||||||
ap.filterType = UpdateParameters::UFT_Startswith;
|
ap.filterType = UpdateParameters::UFT_Startswith;
|
||||||
ap.filter = QString("%1-").arg(fwFlavour);
|
ap.filter = QString("%FWFLAVOUR%-");
|
||||||
ap.maxExpected = 1;
|
ap.maxExpected = 1;
|
||||||
ap.flags = dfltParams->data.flags | UPDFLG_CopyStructure;
|
ap.flags = dfltParams->data.flags | UPDFLG_CopyStructure;
|
||||||
}
|
}
|
||||||
@@ -60,9 +60,9 @@ bool UpdateSDCard::flagAssets()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateParameters::AssetParams ap = runParams->data.assets.at(0);
|
const UpdateParameters::AssetParams & ap = runParams->data.assets.at(0);
|
||||||
|
|
||||||
QRegularExpression filter(UpdateParameters::buildFilterPattern(ap.filterType, ap.filter), QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression filter(runParams->buildFilterPattern(ap.filterType, ap.filter), QRegularExpression::CaseInsensitiveOption);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
QString sdimage;
|
QString sdimage;
|
||||||
|
|
||||||
@@ -89,13 +89,17 @@ bool UpdateSDCard::flagAssets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
reportProgress(tr("Radio flavour %1 not listed in %2").arg(fwFlavour).arg(mappingfile), QtCriticalMsg);
|
reportProgress(tr("Radio flavour %1 not listed in %2").arg(runParams->data.fwFlavour).arg(mappingfile), QtCriticalMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete json;
|
delete json;
|
||||||
|
|
||||||
if (!getSetAssets(ap.flags, UpdateParameters::UFT_Startswith, sdimage, ap.maxExpected, ap.destSubDir, ap.copyFilterType, ap.copyFilter))
|
UpdateParameters::AssetParams sd = ap;
|
||||||
|
sd.filterType = UpdateParameters::UFT_Startswith;
|
||||||
|
sd.filter = sdimage;
|
||||||
|
|
||||||
|
if (!getSetAssets(sd))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ UpdateSounds::UpdateSounds(QWidget * parent) :
|
|||||||
// only supports default for each language
|
// only supports default for each language
|
||||||
// eg edgetx-sdcard-sounds-en-2.7.0.zip
|
// eg edgetx-sdcard-sounds-en-2.7.0.zip
|
||||||
ap.filterType = UpdateParameters::UFT_Startswith;
|
ap.filterType = UpdateParameters::UFT_Startswith;
|
||||||
ap.filter = QString("edgetx-sdcard-sounds-%1-").arg(language);
|
ap.filter = QString("edgetx-sdcard-sounds-%LANGUAGE%-");
|
||||||
// if user changes filter then more than one could be returned
|
// if user changes filter then more than one could be returned
|
||||||
//ap.maxExpected = 1;
|
//ap.maxExpected = 1;
|
||||||
ap.flags = dfltParams->data.flags | UPDFLG_CopyStructure;
|
ap.flags = dfltParams->data.flags | UPDFLG_CopyStructure;
|
||||||
|
|||||||
Reference in New Issue
Block a user