[Horus] Horus downloads now enabled

This commit is contained in:
Bertrand Songis
2016-01-27 22:29:03 +01:00
parent 4c8789106d
commit 087e606021
4 changed files with 142 additions and 158 deletions
+2 -1
View File
@@ -46,7 +46,8 @@ QString getBoardName(BoardEnum board);
#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E) #define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E)
#define IS_TARANIS_PLUS(board) (board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E) #define IS_TARANIS_PLUS(board) (board==BOARD_TARANIS_PLUS || board==BOARD_TARANIS_X9E)
#define IS_TARANIS_X9E(board) (board==BOARD_TARANIS_X9E) #define IS_TARANIS_X9E(board) (board==BOARD_TARANIS_X9E)
#define IS_ARM(board) (IS_TARANIS(board) || IS_SKY9X(board)) #define IS_HORUS(board) (board==BOARD_HORUS)
#define IS_ARM(board) (IS_TARANIS(board) || IS_SKY9X(board) || IS_HORUS(board))
const uint8_t modn12x3[4][4]= { const uint8_t modn12x3[4][4]= {
{1, 2, 3, 4}, {1, 2, 3, 4},
@@ -1097,25 +1097,10 @@ QString OpenTxFirmware::getFirmwareBaseUrl()
QString OpenTxFirmware::getFirmwareUrl() QString OpenTxFirmware::getFirmwareUrl()
{ {
QString url = getFirmwareBaseUrl(); QString url = getFirmwareBaseUrl();
switch (board) { if (IS_ARM(board))
case BOARD_STOCK:
case BOARD_M128:
case BOARD_GRUVIN9X:
case BOARD_MEGA2560:
url.append(QString("/getfw.php?fw=%1.hex").arg(id));
break;
case BOARD_SKY9X:
case BOARD_AR9X:
case BOARD_9XRPRO:
case BOARD_TARANIS:
case BOARD_TARANIS_PLUS:
case BOARD_TARANIS_X9E:
url.append(QString("/getfw.php?fw=%1.bin").arg(id)); url.append(QString("/getfw.php?fw=%1.bin").arg(id));
break; else
default: url.append(QString("/getfw.php?fw=%1.hex").arg(id));
url.clear();
break;
}
return url; return url;
} }
+29 -32
View File
@@ -275,16 +275,26 @@ void MainWindow::closeUpdatesWaitDialog()
} }
} }
QString MainWindow::seekCodeString(const QByteArray & qba, const QString & label)
{
int posLabel = qba.indexOf(label);
if (posLabel < 0)
return QString::null;
int start = qba.indexOf("\"", posLabel + label.length());
if (start < 0)
return QString::null;
int end = qba.indexOf("\"", start + 1);
if (end < 0)
return QString::null;
return qba.mid(start + 1, end - start - 1);
}
void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply) void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
{ {
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
int i = qba.indexOf("VERSION"); QString version = seekCodeString(qba, "VERSION");
if (i>0) { if (version.isNull())
QString version = qba.mid(i+14, qba.indexOf("\"", i+14)-i-14);
if (version.isNull()) {
return onUpdatesError(); return onUpdatesError();
}
int vnum = version2index(version); int vnum = version2index(version);
@@ -317,10 +327,6 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
QMessageBox::information(this, "Companion", tr("No updates available at this time.")); QMessageBox::information(this, "Companion", tr("No updates available at this time."));
} }
} }
}
else {
return onUpdatesError();
}
checkForUpdates(); checkForUpdates();
} }
@@ -388,21 +394,17 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
bool ignore = false; bool ignore = false;
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
QString versionString = seekCodeString(qba, "VERSION");
QString dateString = seekCodeString(qba, "DATE");
if (versionString.isNull() || dateString.isNull())
return onUpdatesError();
long version = 0; long version = version2index(versionString);
if (version <= 0)
return onUpdatesError();
int versionIndex = qba.indexOf("VERS_STR"); QString fullVersionString = QString("%1 (%2)").arg(versionString).arg(dateString);
int dateIndex = qba.indexOf("DATE_STR");
QString versionString;
if (versionIndex > 0 && dateIndex > 0) {
firmwareVersionString = qba.mid(versionIndex+10, qba.indexOf("\"", versionIndex+10)-versionIndex-10);
QString dateString = qba.mid(dateIndex+10, 10);
version = version2index(firmwareVersionString);
versionString = QString("%1 (%2)").arg(firmwareVersionString).arg(dateString);
}
if (version > 0) {
if (checkForUpdatesState & AUTOMATIC_DOWNLOAD) { if (checkForUpdatesState & AUTOMATIC_DOWNLOAD) {
checkForUpdatesState -= AUTOMATIC_DOWNLOAD; checkForUpdatesState -= AUTOMATIC_DOWNLOAD;
download = true; download = true;
@@ -420,7 +422,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
if (currentVersion == 0) { if (currentVersion == 0) {
QString rn = GetCurrentFirmware()->getReleaseNotesUrl(); QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
QAbstractButton *rnButton = NULL; QAbstractButton *rnButton = NULL;
msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nRelease %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(versionString)); msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nRelease %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(fullVersionString));
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole); msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
if (!rn.isEmpty()) { if (!rn.isEmpty()) {
@@ -432,7 +434,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
if (msgBox.clickedButton() == rnButton) { if (msgBox.clickedButton() == rnButton) {
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn); ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
dialog->exec(); dialog->exec();
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString), QMessageBox::Yes | QMessageBox::No); int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No);
if (ret2 == QMessageBox::Yes) if (ret2 == QMessageBox::Yes)
download = true; download = true;
else else
@@ -448,7 +450,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
else if (version > currentVersion) { else if (version > currentVersion) {
QString rn = GetCurrentFirmware()->getReleaseNotesUrl(); QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
QAbstractButton *rnButton = NULL; QAbstractButton *rnButton = NULL;
msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(currentVersionString).arg(versionString)); msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.").arg(current_firmware_variant->getId()).arg(currentVersionString).arg(fullVersionString));
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole); msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
if (!rn.isEmpty()) { if (!rn.isEmpty()) {
@@ -460,7 +462,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
if( msgBox.clickedButton() == rnButton ) { if( msgBox.clickedButton() == rnButton ) {
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn); ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
dialog->exec(); dialog->exec();
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString), int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(fullVersionString),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (ret2 == QMessageBox::Yes) { if (ret2 == QMessageBox::Yes) {
download = true; download = true;
@@ -484,7 +486,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
} }
if (ignore) { if (ignore) {
int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(versionString), QMessageBox::Yes | QMessageBox::No); int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No);
if (res==QMessageBox::Yes) { if (res==QMessageBox::Yes) {
g.fwRev.set(current_firmware_variant->getId(), version); g.fwRev.set(current_firmware_variant->getId(), version);
} }
@@ -492,11 +494,6 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
else if (download == true) { else if (download == true) {
startFirmwareDownload(); startFirmwareDownload();
} }
}
else {
// TODO remove serverFails config?
return onUpdatesError();
}
checkForUpdates(); checkForUpdates();
} }
+1
View File
@@ -83,6 +83,7 @@ class MainWindow : public QMainWindow
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event);
void setLanguage(const QString & langString); void setLanguage(const QString & langString);
QString seekCodeString(const QByteArray & qba, const QString & label);
private slots: private slots:
void openDocURL(); void openDocURL();