1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 09:45:21 +03:00

OpenTX 2.0 downloads from Companion should be working now

This commit is contained in:
bsongis 2014-05-20 14:53:59 +02:00
parent a178d6b326
commit 73faca60d7
11 changed files with 118 additions and 138 deletions

View file

@ -199,16 +199,35 @@ void CompStoreObj::getset( int &number, const QString tag, const int def, const
} }
// ** FwRevision class******************** // ** FwRevision class********************
int FwRevision::get( const QString fwType ) long FwRevision::get( const QString fwType )
{ {
QString result; QString result;
retrieve( result, fwType, "", "FwRevisions" ); retrieve( result, fwType, "", "FwRevisions" );
return result.toInt(); return result.toLong();
} }
void FwRevision::set( const QString fwType, const int fwRevision ) QString FwRevision::getString( const QString fwType )
{ {
QString tempString= QString("%1").arg(fwRevision); long revision = get(fwType);
if (revision > 19920140101) {
int day = revision % 100;
revision /= 100;
int month = revision % 100;
revision /= 100;
int year = revision % 10000;
revision /= 10000;
int minor = revision % 100;
revision /= 100;
return QString("%1.%2 (%3-%4-%5)").arg(revision).arg(minor, 2, 10, (const QChar)'0').arg(year, 4, 10, (const QChar)'0').arg(month, 2, 10, (const QChar)'0').arg(day, 2, 10, (const QChar)'0');
}
else {
return QString();
}
}
void FwRevision::set( const QString fwType, const long fwRevision )
{
QString tempString = QString("%1").arg(fwRevision);
store( tempString, tempString, fwType, "FwRevisions" ); store( tempString, tempString, fwType, "FwRevisions" );
} }
@ -480,7 +499,6 @@ QString AppData::armMcu() { return _armMcu; }
QString AppData::avrArguments() { return _avrArguments; } QString AppData::avrArguments() { return _avrArguments; }
QString AppData::avrPort() { return _avrPort; } QString AppData::avrPort() { return _avrPort; }
QString AppData::avrdudeLocation() { return _avrdudeLocation; } QString AppData::avrdudeLocation() { return _avrdudeLocation; }
QString AppData::compileServer() { return _compileServer; }
QString AppData::cpuId() { return _cpuId; } QString AppData::cpuId() { return _cpuId; }
QString AppData::dfuArguments() { return _dfuArguments; } QString AppData::dfuArguments() { return _dfuArguments; }
QString AppData::dfuLocation() { return _dfuLocation; } QString AppData::dfuLocation() { return _dfuLocation; }
@ -532,7 +550,6 @@ void AppData::armMcu (const QString x) { store(x, _armMcu,
void AppData::avrArguments (const QString x) { store(x, _avrArguments, "avr_arguments" );} void AppData::avrArguments (const QString x) { store(x, _avrArguments, "avr_arguments" );}
void AppData::avrPort (const QString x) { store(x, _avrPort, "avr_port" );} void AppData::avrPort (const QString x) { store(x, _avrPort, "avr_port" );}
void AppData::avrdudeLocation (const QString x) { store(x, _avrdudeLocation, "avrdudeLocation" );} void AppData::avrdudeLocation (const QString x) { store(x, _avrdudeLocation, "avrdudeLocation" );}
void AppData::compileServer (const QString x) { store(x, _compileServer, "compilation-server" );}
void AppData::cpuId (const QString x) { store(x, _cpuId, "cpu_id" );} void AppData::cpuId (const QString x) { store(x, _cpuId, "cpu_id" );}
void AppData::dfuArguments (const QString x) { store(x, _dfuArguments, "dfu_arguments" );} void AppData::dfuArguments (const QString x) { store(x, _dfuArguments, "dfu_arguments" );}
void AppData::dfuLocation (const QString x) { store(x, _dfuLocation, "dfu_location" );} void AppData::dfuLocation (const QString x) { store(x, _dfuLocation, "dfu_location" );}
@ -651,7 +668,6 @@ AppData::AppData()
getset( _avrArguments, "avr_arguments" ,"" ); getset( _avrArguments, "avr_arguments" ,"" );
getset( _avrPort, "avr_port" ,"" ); getset( _avrPort, "avr_port" ,"" );
getset( _avrdudeLocation, "avrdudeLocation" ,"" ); getset( _avrdudeLocation, "avrdudeLocation" ,"" );
getset( _compileServer, "compilation-server" ,"" );
getset( _cpuId, "cpu_id" ,"" ); getset( _cpuId, "cpu_id" ,"" );
getset( _dfuArguments, "dfu_arguments" ,"-a 0" ); getset( _dfuArguments, "dfu_arguments" ,"-a 0" );
getset( _dfuLocation, "dfu_location" ,"" ); getset( _dfuLocation, "dfu_location" ,"" );

View file

@ -58,8 +58,9 @@ class CompStoreObj
class FwRevision: protected CompStoreObj class FwRevision: protected CompStoreObj
{ {
public: public:
int get( const QString); long get( const QString);
void set( const QString, const int ); QString getString( const QString);
void set( const QString, const long );
void remove( const QString ); void remove( const QString );
}; };
@ -206,7 +207,6 @@ class AppData: protected CompStoreObj
QString _avrArguments; QString _avrArguments;
QString _avrPort; QString _avrPort;
QString _avrdudeLocation; QString _avrdudeLocation;
QString _compileServer;
QString _cpuId; QString _cpuId;
QString _dfuArguments; QString _dfuArguments;
QString _dfuLocation; QString _dfuLocation;
@ -259,7 +259,6 @@ class AppData: protected CompStoreObj
QString avrArguments(); QString avrArguments();
QString avrPort(); QString avrPort();
QString avrdudeLocation(); QString avrdudeLocation();
QString compileServer();
QString cpuId(); QString cpuId();
QString dfuArguments(); QString dfuArguments();
QString dfuLocation(); QString dfuLocation();
@ -312,7 +311,6 @@ class AppData: protected CompStoreObj
void avrArguments (const QString); void avrArguments (const QString);
void avrPort (const QString); void avrPort (const QString);
void avrdudeLocation (const QString); void avrdudeLocation (const QString);
void compileServer (const QString);
void cpuId (const QString); void cpuId (const QString);
void dfuArguments (const QString); void dfuArguments (const QString);
void dfuLocation (const QString); void dfuLocation (const QString);

View file

@ -192,7 +192,7 @@ void burnDialog::checkFw(QString fileName)
if (flash.isValid()) { if (flash.isValid()) {
ui->FramFWInfo->show(); ui->FramFWInfo->show();
ui->DateField->setText(flash.getDate() + " " + flash.getTime()); ui->DateField->setText(flash.getDate() + " " + flash.getTime());
ui->versionField->setText(flash.getVersion().isEmpty() ? flash.getSvn() : flash.getVersion()); ui->versionField->setText(flash.getVersion());
ui->ModField->setText(flash.getEEprom()); ui->ModField->setText(flash.getEEprom());
ui->SplashFrame->hide(); ui->SplashFrame->hide();

View file

@ -5,43 +5,41 @@
#include <QTime> #include <QTime>
#include "helpers.h" #include "helpers.h"
downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt) : downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt):
QDialog(parent), QDialog(parent),
ui(new Ui::downloadDialog) ui(new Ui::downloadDialog),
file(NULL)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(CompanionIcon("fwpreferences.png")); setWindowIcon(CompanionIcon("fwpreferences.png"));
ui->progressBar->setValue(1); ui->progressBar->setValue(1);
ui->progressBar->setMinimum(0); ui->progressBar->setMinimum(0);
ui->progressBar->setMaximum(0); ui->progressBar->setMaximum(0);
if(tgt.isEmpty()) if (tgt.isEmpty()) {
{ setWindowTitle(src);
setWindowTitle(src); return; // just show wait dialog.
return; // just show wait dialog.
} }
file = new QFile(tgt); file = new QFile(tgt);
if (!file->open(QIODevice::WriteOnly)) { if (!file->open(QIODevice::WriteOnly)) {
QMessageBox::critical(this, "Companion", QMessageBox::critical(this, "Companion",
tr("Unable to save the file %1: %2.") tr("Unable to save the file %1: %2.")
.arg(tgt).arg(file->errorString())); .arg(tgt).arg(file->errorString()));
QTimer::singleShot(0, this, SLOT(fileError())); QTimer::singleShot(0, this, SLOT(fileError()));
} else { }
else {
reply = qnam.get(QNetworkRequest(QUrl(src))); reply = qnam.get(QNetworkRequest(QUrl(src)));
connect(reply, SIGNAL(finished()), connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));
this, SLOT(httpFinished())); connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
connect(reply, SIGNAL(readyRead()), connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDataReadProgress(qint64,qint64)));
this, SLOT(httpReadyRead()));
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(updateDataReadProgress(qint64,qint64)));
} }
} }
downloadDialog::~downloadDialog() downloadDialog::~downloadDialog()
{ {
delete ui; delete ui;
delete file;
} }
void downloadDialog::httpFinished() void downloadDialog::httpFinished()
@ -50,8 +48,7 @@ void downloadDialog::httpFinished()
file->close(); file->close();
bool ok = true; bool ok = true;
if (reply->error()) if (reply->error()) {
{
file->remove(); file->remove();
QMessageBox::information(this, tr("Companion"), QMessageBox::information(this, tr("Companion"),
tr("Download failed: %1.") tr("Download failed: %1.")
@ -62,31 +59,32 @@ void downloadDialog::httpFinished()
reply->deleteLater(); reply->deleteLater();
reply = 0; reply = 0;
delete file; delete file;
file = 0; file = NULL;
if(ok) if (ok)
accept(); accept();
else else
reject(); reject();
} }
void downloadDialog::httpReadyRead() void downloadDialog::httpReadyRead()
{ {
if (file) if (file) {
file->write(reply->readAll()); file->write(reply->readAll());
}
} }
void downloadDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes) void downloadDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
{ {
ui->progressBar->setMaximum(totalBytes); ui->progressBar->setMaximum(totalBytes);
ui->progressBar->setValue(bytesRead); ui->progressBar->setValue(bytesRead);
} }
void downloadDialog::fileError() void downloadDialog::fileError()
{ {
delete file; delete file;
file = 0; file = NULL;
reject(); reject();
} }
void downloadDialog::closeEvent( QCloseEvent * event) void downloadDialog::closeEvent( QCloseEvent * event)

View file

@ -911,12 +911,8 @@ bool OpenTxEepromInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, in
QString OpenTxFirmware::getFirmwareUrl(QString & id) QString OpenTxFirmware::getFirmwareUrl(QString & id)
{ {
QString url = g.compileServer(); QString url = OPENTX_FIRMWARE_DOWNLOADS;
if (url.isEmpty()){ switch (board) {
url = OPENTX_FIRMWARE_DOWNLOADS;
g.compileServer(url);
}
switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
case BOARD_M128: case BOARD_M128:
case BOARD_GRUVIN9X: case BOARD_GRUVIN9X:
@ -936,22 +932,14 @@ QString OpenTxFirmware::getFirmwareUrl(QString & id)
QString OpenTxFirmware::getReleaseNotesUrl() QString OpenTxFirmware::getReleaseNotesUrl()
{ {
QString url = g.compileServer(); QString url = OPENTX_FIRMWARE_DOWNLOADS;
if (url.isEmpty()){
url = OPENTX_FIRMWARE_DOWNLOADS;
g.compileServer(url);
}
url.append("/releasenotes.txt"); url.append("/releasenotes.txt");
return url; return url;
} }
QString OpenTxFirmware::getStampUrl() QString OpenTxFirmware::getStampUrl()
{ {
QString url = g.compileServer(); QString url = OPENTX_FIRMWARE_DOWNLOADS;
if (url.isEmpty()){
url= OPENTX_FIRMWARE_DOWNLOADS;
g.compileServer(url);
}
url.append("/stamp-opentx.txt"); url.append("/stamp-opentx.txt");
return url; return url;
} }

View file

@ -18,8 +18,8 @@
#include "eeprominterface.h" #include "eeprominterface.h"
#define OPENTX_COMPANION_DOWNLOADS "http://downloads.open-tx.org/companion" #define OPENTX_COMPANION_DOWNLOADS "http://downloads-20.open-tx.org/companion"
#define OPENTX_FIRMWARE_DOWNLOADS "http://next.open-tx.org/firmware" #define OPENTX_FIRMWARE_DOWNLOADS "http://downloads-20.open-tx.org/firmware"
class EFile; class EFile;

View file

@ -20,7 +20,6 @@
#include "flashinterface.h" #include "flashinterface.h"
#define VERS_MARK "VERS" #define VERS_MARK "VERS"
#define SVN_MARK "SVN"
#define DATE_MARK "DATE" #define DATE_MARK "DATE"
#define TIME_MARK "TIME" #define TIME_MARK "TIME"
#define BLD_MARK "BLD" #define BLD_MARK "BLD"
@ -66,7 +65,6 @@ FlashInterface::FlashInterface(QString fileName):
} }
if (flash_size > 0) { if (flash_size > 0) {
svn = seekLabel(SVN_MARK);
version = seekLabel(VERS_MARK); version = seekLabel(VERS_MARK);
date = seekLabel(DATE_MARK); date = seekLabel(DATE_MARK);
time = seekLabel(TIME_MARK); time = seekLabel(TIME_MARK);
@ -123,7 +121,6 @@ bool FlashInterface::SeekSplash(QByteArray splash)
bool FlashInterface::SeekSplash(QByteArray sps, QByteArray spe, int size) bool FlashInterface::SeekSplash(QByteArray sps, QByteArray spe, int size)
{ {
qDebug() << "Seek";
int start = 0; int start = 0;
while (start>=0) { while (start>=0) {
start = flash.indexOf(sps, start+1); start = flash.indexOf(sps, start+1);

View file

@ -46,7 +46,7 @@ class FlashInterface
FlashInterface(QString filename); FlashInterface(QString filename);
inline QString getDate() { return date; } inline QString getDate() { return date; }
inline QString getTime() { return time; } inline QString getTime() { return time; }
inline QString getSvn() { return svn; } inline QString getStamp() { return QString("%1%2").arg(version.replace(".", "")).arg(date.replace("-", "")); }
int getSize() { return flash_size; } int getSize() { return flash_size; }
inline QString getVersion() { return version; } inline QString getVersion() { return version; }
inline QString getEEprom() { return eeprom; } inline QString getEEprom() { return eeprom; }
@ -70,7 +70,6 @@ class FlashInterface
QString filename; QString filename;
QString date; QString date;
QString time; QString time;
QString svn;
QString version; QString version;
QString eeprom; QString eeprom;
QByteArray splash; QByteArray splash;

View file

@ -24,9 +24,10 @@ FirmwarePreferencesDialog::~FirmwarePreferencesDialog()
void FirmwarePreferencesDialog::initSettings() void FirmwarePreferencesDialog::initSettings()
{ {
ui->fwTypeLbl->setText(g.profile[g.id()].fwType()); ui->fwTypeLbl->setText(g.profile[g.id()].fwType());
int revision = g.fwRev.get(g.profile[g.id()].fwType()); QString revision = g.fwRev.getString(g.profile[g.id()].fwType());
if (revision > 0) if (!revision.isEmpty()) {
ui->lastRevisionLbl->setText(QString("%1").arg(revision)); ui->lastRevisionLbl->setText(revision);
}
} }
void FirmwarePreferencesDialog::on_checkFWUpdates_clicked() void FirmwarePreferencesDialog::on_checkFWUpdates_clicked()
@ -46,7 +47,7 @@ void FirmwarePreferencesDialog::on_fw_dnld_clicked()
void FirmwarePreferencesDialog::on_voice_dnld_clicked() void FirmwarePreferencesDialog::on_voice_dnld_clicked()
{ {
QString url="http://voice.open-tx.org/"; QString url = "http://voices-20.open-tx.org/";
QString fwType = g.profile[g.id()].fwType(); QString fwType = g.profile[g.id()].fwType();
QStringList list = fwType.split("-"); QStringList list = fwType.split("-");
QString firmware = QString("%1-%2").arg(list[0]).arg(list[1]); QString firmware = QString("%1-%2").arg(list[0]).arg(list[1]);

View file

@ -165,20 +165,19 @@ MainWindow::MainWindow():
void MainWindow::displayWarnings() void MainWindow::displayWarnings()
{ {
int warnId=g.warningId(); int warnId = g.warningId();
if (warnId<WARNING_ID && warnId!=0) { if (warnId<WARNING_ID && warnId!=0) {
int res=0; int res=0;
if (WARNING_LEVEL>0) { if (WARNING_LEVEL>0)
QMessageBox::warning(this, "Companion", WARNING); QMessageBox::warning(this, "Companion", WARNING);
res = QMessageBox::question(this, "Companion",tr("Display previous warning again at startup ?"),QMessageBox::Yes | QMessageBox::No); else
} else {
QMessageBox::about(this, "Companion", WARNING); QMessageBox::about(this, "Companion", WARNING);
res = QMessageBox::question(this, "Companion",tr("Display previous message again at startup ?"),QMessageBox::Yes | QMessageBox::No); res = QMessageBox::question(this, "Companion", tr("Display previous warning again at startup ?"), QMessageBox::Yes | QMessageBox::No);
}
if (res == QMessageBox::No) { if (res == QMessageBox::No) {
g.warningId(WARNING_ID); g.warningId(WARNING_ID);
} }
} else if (warnId==0) { }
else if (warnId==0) {
g.warningId(WARNING_ID); g.warningId(WARNING_ID);
} }
} }
@ -304,13 +303,13 @@ void MainWindow::downloadLatestFW(FirmwareVariant & firmware)
{ {
QString url, ext, cpuid; QString url, ext, cpuid;
url = firmware.getFirmwareUrl(); url = firmware.getFirmwareUrl();
cpuid=g.cpuId(); cpuid = g.cpuId();
ext = url.mid(url.lastIndexOf(".")); ext = url.mid(url.lastIndexOf("."));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + firmware.id + ext); QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + firmware.id + ext);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
downloadedFW = firmware.id; downloadedFW = firmware.id;
needRename=true; needRename = true;
g.profile[g.id()].fwName( fileName ); g.profile[g.id()].fwName(fileName);
if (!cpuid.isEmpty()) { if (!cpuid.isEmpty()) {
url.append("&cpuid="); url.append("&cpuid=");
url.append(cpuid); url.append(cpuid);
@ -329,10 +328,10 @@ void MainWindow::reply1Accepted()
if (!(downloadedFW.isEmpty())) { if (!(downloadedFW.isEmpty())) {
QFile file(downloadedFW); QFile file(downloadedFW);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
QMessageBox::critical(this, tr("Error"), QMessageBox::critical(this, tr("Error"),
tr("Error opening file %1:\n%2.") tr("Error opening file %1:\n%2.")
.arg(downloadedFW) .arg(downloadedFW)
.arg(file.errorString())); .arg(file.errorString()));
return; return;
} }
file.reset(); file.reset();
@ -363,15 +362,17 @@ void MainWindow::reply1Accepted()
} }
file.close(); file.close();
currentFWrev = currentFWrev_temp; currentFWrev = currentFWrev_temp;
qDebug() << currentFWrev;
g.fwRev.set(downloadedFW, currentFWrev); g.fwRev.set(downloadedFW, currentFWrev);
} }
} else { }
else {
QFile file(g.profile[g.id()].fwName()); QFile file(g.profile[g.id()].fwName());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
QMessageBox::critical(this, tr("Error"), QMessageBox::critical(this, tr("Error"),
tr("Error opening file %1:\n%2.") tr("Error opening file %1:\n%2.")
.arg(g.profile[g.id()].fwName()) .arg(g.profile[g.id()].fwName())
.arg(file.errorString())); .arg(file.errorString()));
return; return;
} }
file.reset(); file.reset();
@ -381,19 +382,19 @@ void MainWindow::reply1Accepted()
int errnum=hline.mid(6).toInt(); int errnum=hline.mid(6).toInt();
switch(errnum) { switch(errnum) {
case 1: case 1:
errormsg=tr("Not enough memory for all the selected firmware options"); errormsg = tr("Not enough memory for all the selected firmware options");
break; break;
case 2: case 2:
errormsg=tr("Compilation server termporary failure, try later"); errormsg = tr("Compilation server termporary failure, try later");
break; break;
case 3: case 3:
errormsg=tr("Compilation server too busy, try later"); errormsg = tr("Compilation server too busy, try later");
break; break;
case 4: case 4:
errormsg=tr("Compilation server requires registration, please check OpenTX web site"); errormsg = tr("Compilation server requires registration, please check OpenTX web site");
break; break;
default: default:
errormsg=tr("Unknown server failure, try later"); errormsg = tr("Unknown server failure, try later");
break; break;
} }
file.close(); file.close();
@ -402,10 +403,11 @@ void MainWindow::reply1Accepted()
} }
file.close(); file.close();
FlashInterface flash(g.profile[g.id()].fwName()); FlashInterface flash(g.profile[g.id()].fwName());
QString rev=flash.getSvn(); long stamp = flash.getStamp().toLong();
int pos=rev.lastIndexOf("-r"); if (stamp > 0) {
if (pos>0) { currentFWrev = stamp;
currentFWrev=rev.mid(pos+2).toInt(); #if 0
// TODO what's that?
if (g.profile[g.id()].renameFwFiles() && needRename) { if (g.profile[g.id()].renameFwFiles() && needRename) {
QFileInfo fi(g.profile[g.id()].fwName()); QFileInfo fi(g.profile[g.id()].fwName());
QString path=fi.path()+QDir::separator (); QString path=fi.path()+QDir::separator ();
@ -418,6 +420,7 @@ void MainWindow::reply1Accepted()
qd.rename(g.profile[g.id()].fwName(),path); qd.rename(g.profile[g.id()].fwName(),path);
g.profile[g.id()].fwName(path); g.profile[g.id()].fwName(path);
} }
#endif
g.fwRev.set(downloadedFW, currentFWrev); g.fwRev.set(downloadedFW, currentFWrev);
if (g.profile[g.id()].burnFirmware()) { if (g.profile[g.id()].burnFirmware()) {
int ret = QMessageBox::question(this, "Companion", tr("Do you want to write the firmware to the radio now ?"), QMessageBox::Yes | QMessageBox::No); int ret = QMessageBox::question(this, "Companion", tr("Do you want to write the firmware to the radio now ?"), QMessageBox::Yes | QMessageBox::No);
@ -442,15 +445,17 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
// TODO delete downloadDialog_forWait? // TODO delete downloadDialog_forWait?
} }
cpuid=g.cpuId(); cpuid = g.cpuId();
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
int i = qba.indexOf("SVN_VERS"); int i = qba.indexOf("SVN_VERS");
int warning = qba.indexOf("WARNING"); int warning = qba.indexOf("WARNING");
if(i>0) {
if (i>0) {
bool cres; bool cres;
int k = qba.indexOf("-r", i); int k = qba.indexOf("-r", i);
int l = qba.indexOf('"', k); int l = qba.indexOf('"', k);
qDebug() << qba;
int rev = QString::fromAscii(qba.mid(k+2, l-k-2)).toInt(&cres); int rev = QString::fromAscii(qba.mid(k+2, l-k-2)).toInt(&cres);
QString newrev=qba.mid(k).replace('"', "").trimmed(); QString newrev=qba.mid(k).replace('"', "").trimmed();
@ -461,7 +466,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
} }
if(rev>0) { if(rev>0) {
NewFwRev=rev; NewFwRev = rev;
OldFwRev = g.fwRev.get(fwToUpdate); OldFwRev = g.fwRev.get(fwToUpdate);
QMessageBox msgBox; QMessageBox msgBox;
QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
@ -536,7 +541,8 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
if (res==QMessageBox::Yes) { if (res==QMessageBox::Yes) {
g.fwRev.set(fwToUpdate, NewFwRev); g.fwRev.set(fwToUpdate, NewFwRev);
} }
} else if (download == true) { }
else if (download == true) {
if (warning>0) { if (warning>0) {
QString rn = GetFirmware(fwToUpdate)->getReleaseNotesUrl(); QString rn = GetFirmware(fwToUpdate)->getReleaseNotesUrl();
if (!rn.isEmpty()) { if (!rn.isEmpty()) {
@ -555,7 +561,8 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
QString fileName; QString fileName;
if (addversion) { if (addversion) {
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + fwToUpdate + newrev + ext); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + fwToUpdate + newrev + ext);
} else { }
else {
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + fwToUpdate + ext); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + fwToUpdate + ext);
} }
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
@ -1269,35 +1276,11 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
if (!flash.isValid()) if (!flash.isValid())
return false; return false;
QString fwSvn = flash.getSvn();
if (fwSvn.isEmpty() || !fwSvn.contains("-r"))
return false;
QStringList svnTags = fwSvn.split("-r", QString::SkipEmptyParts);
fwSvn = svnTags.back();
if (fwSvn.endsWith('M'))
fwSvn = fwSvn.mid(0, fwSvn.size()-1);
int revision = fwSvn.toInt();
if (!revision)
return false;
unsigned int version = 0; unsigned int version = 0;
unsigned int variant = 0; unsigned int variant = 0;
if ((svnTags.at(0) == "open9x")||(svnTags.at(0) == "opentx")) { QString fwEEprom = flash.getEEprom();
if (revision > 1464) { version = fwEEprom.toInt();
QString fwEEprom = flash.getEEprom();
if (fwEEprom.contains("-")) {
QStringList buildTags = fwEEprom.split("-", QString::SkipEmptyParts);
if (buildTags.size() >= 1)
version = buildTags.at(0).toInt();
if (buildTags.size() >= 2)
variant = buildTags.at(1).toInt();
}
else {
version = fwEEprom.toInt();
}
}
}
QFile file(backupFile); QFile file(backupFile);
int eeprom_size = file.size(); int eeprom_size = file.size();

View file

@ -203,9 +203,9 @@ class MainWindow : public QMainWindow
bool needRename; bool needRename;
bool showcheckForUpdatesResult; bool showcheckForUpdatesResult;
int currentFWrev; long currentFWrev;
int currentFWrev_temp; long currentFWrev_temp;
int NewFwRev; long NewFwRev;
bool check1done; bool check1done;
bool check2done; bool check2done;