[Horus] Horus downloads now enabled
This commit is contained in:
@@ -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:
|
url.append(QString("/getfw.php?fw=%1.bin").arg(id));
|
||||||
case BOARD_M128:
|
else
|
||||||
case BOARD_GRUVIN9X:
|
url.append(QString("/getfw.php?fw=%1.hex").arg(id));
|
||||||
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));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
url.clear();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+133
-136
@@ -275,51 +275,57 @@ 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);
|
return onUpdatesError();
|
||||||
|
|
||||||
if (version.isNull()) {
|
int vnum = version2index(version);
|
||||||
return onUpdatesError();
|
|
||||||
}
|
|
||||||
|
|
||||||
int vnum = version2index(version);
|
QString c9xversion = QString(VERSION);
|
||||||
|
int c9xver = version2index(c9xversion);
|
||||||
|
|
||||||
QString c9xversion = QString(VERSION);
|
if (c9xver < vnum) {
|
||||||
int c9xver = version2index(c9xversion);
|
|
||||||
|
|
||||||
if (c9xver < vnum) {
|
|
||||||
#if defined WIN32 || !defined __GNUC__ // || defined __APPLE__ // OSX should only notify of updates since no update packages are available.
|
#if defined WIN32 || !defined __GNUC__ // || defined __APPLE__ // OSX should only notify of updates since no update packages are available.
|
||||||
int ret = QMessageBox::question(this, "Companion", tr("A new version of Companion is available (version %1)<br>"
|
int ret = QMessageBox::question(this, "Companion", tr("A new version of Companion is available (version %1)<br>"
|
||||||
"Would you like to download it?").arg(version) ,
|
"Would you like to download it?").arg(version) ,
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
if (ret == QMessageBox::Yes) {
|
if (ret == QMessageBox::Yes) {
|
||||||
QDir dir(g.updatesDir());
|
QDir dir(g.updatesDir());
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), dir.absoluteFilePath(QString(COMPANION_INSTALLER).arg(version)), tr("Executable (*.exe)"));
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), dir.absoluteFilePath(QString(COMPANION_INSTALLER).arg(version)), tr("Executable (*.exe)"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
g.updatesDir(QFileInfo(fileName).dir().absolutePath());
|
g.updatesDir(QFileInfo(fileName).dir().absolutePath());
|
||||||
downloadDialog * dd = new downloadDialog(this, QString("%1/%2").arg(getCompanionUpdateBaseUrl()).arg(QString(COMPANION_INSTALLER).arg(version)), fileName);
|
downloadDialog * dd = new downloadDialog(this, QString("%1/%2").arg(getCompanionUpdateBaseUrl()).arg(QString(COMPANION_INSTALLER).arg(version)), fileName);
|
||||||
installer_fileName = fileName;
|
installer_fileName = fileName;
|
||||||
connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded()));
|
connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded()));
|
||||||
dd->exec();
|
dd->exec();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available, please check the OpenTX website!"));
|
QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available, please check the OpenTX website!"));
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (downloadDialog_forWait && checkForUpdatesState==0) {
|
|
||||||
QMessageBox::information(this, "Companion", tr("No updates available at this time."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return onUpdatesError();
|
if (downloadDialog_forWait && checkForUpdatesState==0) {
|
||||||
|
QMessageBox::information(this, "Companion", tr("No updates available at this time."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
@@ -350,7 +356,7 @@ void MainWindow::firmwareDownloadAccepted()
|
|||||||
QTextStream inputStream(&file);
|
QTextStream inputStream(&file);
|
||||||
QString hline = inputStream.readLine();
|
QString hline = inputStream.readLine();
|
||||||
if (hline.startsWith("ERROR:")) {
|
if (hline.startsWith("ERROR:")) {
|
||||||
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");
|
||||||
@@ -388,114 +394,105 @@ 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 (checkForUpdatesState & AUTOMATIC_DOWNLOAD) {
|
||||||
if (versionIndex > 0 && dateIndex > 0) {
|
checkForUpdatesState -= AUTOMATIC_DOWNLOAD;
|
||||||
firmwareVersionString = qba.mid(versionIndex+10, qba.indexOf("\"", versionIndex+10)-versionIndex-10);
|
download = true;
|
||||||
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) {
|
|
||||||
checkForUpdatesState -= AUTOMATIC_DOWNLOAD;
|
|
||||||
download = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int currentVersion = g.fwRev.get(current_firmware_variant->getId());
|
|
||||||
QString currentVersionString = index2version(currentVersion);
|
|
||||||
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setWindowTitle("Companion");
|
|
||||||
QSpacerItem * horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
|
||||||
QGridLayout * layout = (QGridLayout*)msgBox.layout();
|
|
||||||
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
|
|
||||||
|
|
||||||
if (currentVersion == 0) {
|
|
||||||
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
|
||||||
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));
|
|
||||||
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
|
||||||
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
|
||||||
if (!rn.isEmpty()) {
|
|
||||||
rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole);
|
|
||||||
}
|
|
||||||
msgBox.setIcon(QMessageBox::Question);
|
|
||||||
msgBox.resize(0, 0);
|
|
||||||
msgBox.exec();
|
|
||||||
if (msgBox.clickedButton() == rnButton) {
|
|
||||||
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
|
||||||
dialog->exec();
|
|
||||||
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString), QMessageBox::Yes | QMessageBox::No);
|
|
||||||
if (ret2 == QMessageBox::Yes)
|
|
||||||
download = true;
|
|
||||||
else
|
|
||||||
ignore = true;
|
|
||||||
}
|
|
||||||
else if (msgBox.clickedButton() == YesButton ) {
|
|
||||||
download = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ignore = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (version > currentVersion) {
|
|
||||||
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
|
||||||
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));
|
|
||||||
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
|
||||||
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
|
||||||
if (!rn.isEmpty()) {
|
|
||||||
rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole);
|
|
||||||
}
|
|
||||||
msgBox.setIcon(QMessageBox::Question);
|
|
||||||
msgBox.resize(0,0);
|
|
||||||
msgBox.exec();
|
|
||||||
if( msgBox.clickedButton() == rnButton ) {
|
|
||||||
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
|
||||||
dialog->exec();
|
|
||||||
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString),
|
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
|
||||||
if (ret2 == QMessageBox::Yes) {
|
|
||||||
download = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ignore = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (msgBox.clickedButton() == YesButton ) {
|
|
||||||
download = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ignore = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (downloadDialog_forWait && checkForUpdatesState==0) {
|
|
||||||
QMessageBox::information(this, "Companion", tr("No updates available at this time."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ignore) {
|
|
||||||
int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(versionString), QMessageBox::Yes | QMessageBox::No);
|
|
||||||
if (res==QMessageBox::Yes) {
|
|
||||||
g.fwRev.set(current_firmware_variant->getId(), version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (download == true) {
|
|
||||||
startFirmwareDownload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO remove serverFails config?
|
int currentVersion = g.fwRev.get(current_firmware_variant->getId());
|
||||||
return onUpdatesError();
|
QString currentVersionString = index2version(currentVersion);
|
||||||
|
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle("Companion");
|
||||||
|
QSpacerItem * horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
QGridLayout * layout = (QGridLayout*)msgBox.layout();
|
||||||
|
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
|
||||||
|
|
||||||
|
if (currentVersion == 0) {
|
||||||
|
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
||||||
|
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(fullVersionString));
|
||||||
|
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
||||||
|
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
||||||
|
if (!rn.isEmpty()) {
|
||||||
|
rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole);
|
||||||
|
}
|
||||||
|
msgBox.setIcon(QMessageBox::Question);
|
||||||
|
msgBox.resize(0, 0);
|
||||||
|
msgBox.exec();
|
||||||
|
if (msgBox.clickedButton() == rnButton) {
|
||||||
|
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
||||||
|
dialog->exec();
|
||||||
|
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)
|
||||||
|
download = true;
|
||||||
|
else
|
||||||
|
ignore = true;
|
||||||
|
}
|
||||||
|
else if (msgBox.clickedButton() == YesButton ) {
|
||||||
|
download = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ignore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (version > currentVersion) {
|
||||||
|
QString rn = GetCurrentFirmware()->getReleaseNotesUrl();
|
||||||
|
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(fullVersionString));
|
||||||
|
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
|
||||||
|
msgBox.addButton(trUtf8("No"), QMessageBox::NoRole);
|
||||||
|
if (!rn.isEmpty()) {
|
||||||
|
rnButton = msgBox.addButton(trUtf8("Release Notes"), QMessageBox::ActionRole);
|
||||||
|
}
|
||||||
|
msgBox.setIcon(QMessageBox::Question);
|
||||||
|
msgBox.resize(0,0);
|
||||||
|
msgBox.exec();
|
||||||
|
if( msgBox.clickedButton() == rnButton ) {
|
||||||
|
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
|
||||||
|
dialog->exec();
|
||||||
|
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) {
|
||||||
|
download = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ignore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msgBox.clickedButton() == YesButton ) {
|
||||||
|
download = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ignore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (downloadDialog_forWait && checkForUpdatesState==0) {
|
||||||
|
QMessageBox::information(this, "Companion", tr("No updates available at this time."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ignore) {
|
||||||
|
int res = QMessageBox::question(this, "Companion", tr("Ignore this release %1?").arg(fullVersionString), QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (res==QMessageBox::Yes) {
|
||||||
|
g.fwRev.set(current_firmware_variant->getId(), version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (download == true) {
|
||||||
|
startFirmwareDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user