[Companion] Centralize download URLs; URLs now based on build major.minor version macros; Remove AVR fw download URL; Make some QStrings cheaper.
This commit is contained in:
@@ -23,19 +23,13 @@
|
|||||||
#include "rlefile.h"
|
#include "rlefile.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <companion/src/storage/storage.h>
|
|
||||||
|
|
||||||
using namespace Board;
|
#include "storage.h" // does this need to be last include?
|
||||||
|
|
||||||
const char * const OPENTX_FIRMWARE_DOWNLOAD_URL[] = {
|
|
||||||
"https://downloads.open-tx.org/2.2/release/firmware",
|
|
||||||
"https://downloads.open-tx.org/2.2/rc/firmware",
|
|
||||||
"https://downloads.open-tx.org/2.2/nightlies/firmware"
|
|
||||||
};
|
|
||||||
|
|
||||||
#define FILE_TYP_GENERAL 1
|
#define FILE_TYP_GENERAL 1
|
||||||
#define FILE_TYP_MODEL 2
|
#define FILE_TYP_MODEL 2
|
||||||
@@ -45,6 +39,8 @@ const char * const OPENTX_FIRMWARE_DOWNLOAD_URL[] = {
|
|||||||
/// convert model number 0..MAX_MODELS-1 int fileId
|
/// convert model number 0..MAX_MODELS-1 int fileId
|
||||||
#define FILE_MODEL(n) (1+n)
|
#define FILE_MODEL(n) (1+n)
|
||||||
|
|
||||||
|
using namespace Board;
|
||||||
|
|
||||||
template<typename T, size_t N>
|
template<typename T, size_t N>
|
||||||
inline
|
inline
|
||||||
size_t SizeOfArray(T(&)[N])
|
size_t SizeOfArray(T(&)[N])
|
||||||
@@ -1045,33 +1041,22 @@ unsigned long OpenTxEepromInterface::loadBackup(RadioData &radioData, const uint
|
|||||||
|
|
||||||
QString OpenTxFirmware::getFirmwareBaseUrl()
|
QString OpenTxFirmware::getFirmwareBaseUrl()
|
||||||
{
|
{
|
||||||
return OPENTX_FIRMWARE_DOWNLOAD_URL[g.boundedOpenTxBranch()];
|
return g.openTxCurrentDownloadBranchUrl() % QStringLiteral("firmware/");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OpenTxFirmware::getFirmwareUrl()
|
QString OpenTxFirmware::getFirmwareUrl()
|
||||||
{
|
{
|
||||||
QString url = getFirmwareBaseUrl();
|
return getFirmwareBaseUrl() % QString("getfw.php?fw=%1.bin").arg(QString(QUrl::toPercentEncoding(id)));
|
||||||
QByteArray data = QUrl::toPercentEncoding(id);
|
|
||||||
|
|
||||||
if (IS_ARM(board))
|
|
||||||
url.append(QString("/getfw.php?fw=%1.bin").arg((QString) data));
|
|
||||||
else
|
|
||||||
url.append(QString("/getfw.php?fw=%1.hex").arg((QString) data));
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OpenTxFirmware::getReleaseNotesUrl()
|
QString OpenTxFirmware::getReleaseNotesUrl()
|
||||||
{
|
{
|
||||||
QString url = getFirmwareBaseUrl();
|
return getFirmwareBaseUrl() % QStringLiteral("releasenotes.txt");
|
||||||
url.append("/releasenotes.txt");
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OpenTxFirmware::getStampUrl()
|
QString OpenTxFirmware::getStampUrl()
|
||||||
{
|
{
|
||||||
QString url = getFirmwareBaseUrl();
|
return getFirmwareBaseUrl() % QStringLiteral("stamp-opentx.txt");
|
||||||
url.append("/stamp-opentx.txt");
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addOpenTxCommonOptions(OpenTxFirmware * firmware)
|
void addOpenTxCommonOptions(OpenTxFirmware * firmware)
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
|
|
||||||
const char * const OPENTX_SDCARD_DOWNLOAD_URL[] = {
|
|
||||||
"https://downloads.open-tx.org/2.2/release/sdcard/",
|
|
||||||
"https://downloads.open-tx.org/2.2/rc/sdcard/",
|
|
||||||
"https://downloads.open-tx.org/2.2/nightlies/sdcard/"
|
|
||||||
};
|
|
||||||
|
|
||||||
FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget * parent) :
|
FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget * parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::FirmwarePreferencesDialog)
|
ui(new Ui::FirmwarePreferencesDialog)
|
||||||
@@ -69,7 +63,7 @@ void FirmwarePreferencesDialog::on_fw_dnld_clicked()
|
|||||||
|
|
||||||
void FirmwarePreferencesDialog::on_sd_dnld_clicked()
|
void FirmwarePreferencesDialog::on_sd_dnld_clicked()
|
||||||
{
|
{
|
||||||
QString url = OPENTX_SDCARD_DOWNLOAD_URL[g.boundedOpenTxBranch()];
|
QString url = g.openTxCurrentDownloadBranchUrl() % QStringLiteral("sdcard/");
|
||||||
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]);
|
||||||
|
|||||||
@@ -61,32 +61,26 @@
|
|||||||
#define INTERACTIVE_DOWNLOAD 4
|
#define INTERACTIVE_DOWNLOAD 4
|
||||||
#define AUTOMATIC_DOWNLOAD 8
|
#define AUTOMATIC_DOWNLOAD 8
|
||||||
|
|
||||||
#define OPENTX_DOWNLOADS_PAGE_URL "http://www.open-tx.org/downloads"
|
#define OPENTX_DOWNLOADS_PAGE_URL QStringLiteral("http://www.open-tx.org/downloads")
|
||||||
#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2"
|
#define DONATE_STR QStringLiteral("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2")
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
#define COMPANION_STAMP "companion-macosx.stamp"
|
#define COMPANION_STAMP QStringLiteral("companion-macosx.stamp")
|
||||||
#define COMPANION_INSTALLER "macosx/opentx-companion-%1.dmg"
|
#define COMPANION_INSTALLER QStringLiteral("macosx/opentx-companion-%1.dmg")
|
||||||
#define COMPANION_FILEMASK QT_TRANSLATE_NOOP("MainWindow", "Diskimage (*.dmg)")
|
#define COMPANION_FILEMASK QT_TRANSLATE_NOOP("MainWindow", "Diskimage (*.dmg)")
|
||||||
#define COMPANION_INSTALL_QUESTION QT_TRANSLATE_NOOP("MainWindow", "Would you like to open the disk image to install the new version?")
|
#define COMPANION_INSTALL_QUESTION QT_TRANSLATE_NOOP("MainWindow", "Would you like to open the disk image to install the new version?")
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
#define COMPANION_STAMP "companion-windows.stamp"
|
#define COMPANION_STAMP QStringLiteral("companion-windows.stamp")
|
||||||
#define COMPANION_INSTALLER "windows/companion-windows-%1.exe"
|
#define COMPANION_INSTALLER QStringLiteral("windows/companion-windows-%1.exe")
|
||||||
#define COMPANION_FILEMASK QT_TRANSLATE_NOOP("MainWindow", "Executable (*.exe)")
|
#define COMPANION_FILEMASK QT_TRANSLATE_NOOP("MainWindow", "Executable (*.exe)")
|
||||||
#define COMPANION_INSTALL_QUESTION QT_TRANSLATE_NOOP("MainWindow", "Would you like to launch the installer?")
|
#define COMPANION_INSTALL_QUESTION QT_TRANSLATE_NOOP("MainWindow", "Would you like to launch the installer?")
|
||||||
#else
|
#else
|
||||||
#define COMPANION_STAMP "companion-linux.stamp"
|
#define COMPANION_STAMP QStringLiteral("companion-linux.stamp")
|
||||||
#define COMPANION_INSTALLER "" // no automated updates for linux
|
#define COMPANION_INSTALLER "" // no automated updates for linux
|
||||||
#define COMPANION_FILEMASK "*.*"
|
#define COMPANION_FILEMASK QStringLiteral("*.*")
|
||||||
#define COMPANION_INSTALL_QUESTION QT_TRANSLATE_NOOP("MainWindow", "Would you like to launch the installer?")
|
#define COMPANION_INSTALL_QUESTION QT_TRANSLATE_NOOP("MainWindow", "Would you like to launch the installer?")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char * const OPENTX_COMPANION_DOWNLOAD_URL[] = {
|
|
||||||
"https://downloads.open-tx.org/2.2/release/companion",
|
|
||||||
"https://downloads.open-tx.org/2.2/rc/companion",
|
|
||||||
"https://downloads.open-tx.org/2.2/nightlies/companion"
|
|
||||||
};
|
|
||||||
|
|
||||||
MainWindow::MainWindow():
|
MainWindow::MainWindow():
|
||||||
downloadDialog_forWait(nullptr),
|
downloadDialog_forWait(nullptr),
|
||||||
checkForUpdatesState(0),
|
checkForUpdatesState(0),
|
||||||
@@ -260,9 +254,9 @@ void MainWindow::dowloadLastFirmwareUpdate()
|
|||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MainWindow::getCompanionUpdateBaseUrl()
|
QString MainWindow::getCompanionUpdateBaseUrl() const
|
||||||
{
|
{
|
||||||
return OPENTX_COMPANION_DOWNLOAD_URL[g.boundedOpenTxBranch()];
|
return g.openTxCurrentDownloadBranchUrl() % QStringLiteral("companion/");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::checkForUpdates()
|
void MainWindow::checkForUpdates()
|
||||||
@@ -286,7 +280,7 @@ void MainWindow::checkForUpdates()
|
|||||||
checkForUpdatesState -= CHECK_COMPANION;
|
checkForUpdatesState -= CHECK_COMPANION;
|
||||||
if (checkForUpdatesState & INTERACTIVE_DOWNLOAD)
|
if (checkForUpdatesState & INTERACTIVE_DOWNLOAD)
|
||||||
openUpdatesWaitDialog();
|
openUpdatesWaitDialog();
|
||||||
url.setUrl(QString("%1/%2").arg(getCompanionUpdateBaseUrl()).arg(COMPANION_STAMP));
|
url.setUrl(getCompanionUpdateBaseUrl() % COMPANION_STAMP);
|
||||||
connect(networkManager, &QNetworkAccessManager::finished, this, &MainWindow::checkForCompanionUpdateFinished);
|
connect(networkManager, &QNetworkAccessManager::finished, this, &MainWindow::checkForCompanionUpdateFinished);
|
||||||
qDebug() << "Checking for Companion update " << url.url();
|
qDebug() << "Checking for Companion update " << url.url();
|
||||||
}
|
}
|
||||||
@@ -334,7 +328,7 @@ void MainWindow::closeUpdatesWaitDialog()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MainWindow::seekCodeString(const QByteArray & qba, const QString & label)
|
QString MainWindow::seekCodeString(const QByteArray & qba, const QString & label) const
|
||||||
{
|
{
|
||||||
int posLabel = qba.indexOf(label);
|
int posLabel = qba.indexOf(label);
|
||||||
if (posLabel < 0)
|
if (posLabel < 0)
|
||||||
@@ -374,7 +368,7 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
|
|||||||
|
|
||||||
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, getCompanionUpdateBaseUrl() % 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();
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ class MainWindow : public QMainWindow
|
|||||||
void startSync();
|
void startSync();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getCompanionUpdateBaseUrl();
|
QString getCompanionUpdateBaseUrl() const;
|
||||||
QString seekCodeString(const QByteArray & qba, const QString & label);
|
QString seekCodeString(const QByteArray & qba, const QString & label) const;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void dowloadLastFirmwareUpdate();
|
void dowloadLastFirmwareUpdate();
|
||||||
|
|||||||
@@ -58,6 +58,12 @@
|
|||||||
#define CPN_SETTINGS_INI_FILE QString(PRODUCT % " " % QCoreApplication::translate("Companion", "settings") % " %1.ini")
|
#define CPN_SETTINGS_INI_FILE QString(PRODUCT % " " % QCoreApplication::translate("Companion", "settings") % " %1.ini")
|
||||||
#define CPN_SETTINGS_INI_PATH QString(CPN_SETTINGS_BACKUP_DIR % "/" % CPN_SETTINGS_INI_FILE)
|
#define CPN_SETTINGS_INI_PATH QString(CPN_SETTINGS_BACKUP_DIR % "/" % CPN_SETTINGS_INI_FILE)
|
||||||
|
|
||||||
|
#define CPN_URL_DOWNLOAD "https://downloads.open-tx.org/"
|
||||||
|
#define CPN_URL_DOWNLOAD_CUR_VERS CPN_URL_DOWNLOAD QT_STRINGIFY(VERSION_MAJOR) "." QT_STRINGIFY(VERSION_MINOR) "/"
|
||||||
|
#define CPN_URL_DOWNLOAD_CUR_REL CPN_URL_DOWNLOAD_CUR_VERS "release/"
|
||||||
|
#define CPN_URL_DOWNLOAD_CUR_RC CPN_URL_DOWNLOAD_CUR_VERS "rc/"
|
||||||
|
#define CPN_URL_DOWNLOAD_CUR_UNST CPN_URL_DOWNLOAD_CUR_VERS "nightlies/"
|
||||||
|
|
||||||
#define MAX_PROFILES 15
|
#define MAX_PROFILES 15
|
||||||
#define MAX_JOYSTICKS 8
|
#define MAX_JOYSTICKS 8
|
||||||
|
|
||||||
@@ -490,12 +496,20 @@ class AppData: public CompStoreObj
|
|||||||
|
|
||||||
inline DownloadBranchType boundedOpenTxBranch() const {
|
inline DownloadBranchType boundedOpenTxBranch() const {
|
||||||
#if defined(ALLOW_NIGHTLY_BUILDS)
|
#if defined(ALLOW_NIGHTLY_BUILDS)
|
||||||
return qBound(BRANCH_RELEASE_STABLE, DownloadBranchType(OpenTxBranch()), BRANCH_NIGHTLY_UNSTABLE);
|
return qBound(BRANCH_RELEASE_STABLE, OpenTxBranch(), BRANCH_NIGHTLY_UNSTABLE);
|
||||||
#else
|
#else
|
||||||
return qBound(BRANCH_RELEASE_STABLE, DownloadBranchType(OpenTxBranch()), BRANCH_RC_TESTING);
|
return qBound(BRANCH_RELEASE_STABLE, OpenTxBranch(), BRANCH_RC_TESTING);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QString openTxCurrentDownloadBranchUrl() const { return openTxDownloadBranchUrl(boundedOpenTxBranch()); }
|
||||||
|
|
||||||
|
static const QString openTxDownloadBranchUrl(DownloadBranchType type)
|
||||||
|
{
|
||||||
|
static const QStringList urlList({ CPN_URL_DOWNLOAD_CUR_REL, CPN_URL_DOWNLOAD_CUR_RC, CPN_URL_DOWNLOAD_CUR_UNST });
|
||||||
|
return urlList.value(type, CPN_URL_DOWNLOAD_CUR_VERS);
|
||||||
|
}
|
||||||
|
|
||||||
Profile profile[MAX_PROFILES];
|
Profile profile[MAX_PROFILES];
|
||||||
JStickData joystick[MAX_JOYSTICKS];
|
JStickData joystick[MAX_JOYSTICKS];
|
||||||
FwRevision fwRev;
|
FwRevision fwRev;
|
||||||
|
|||||||
Reference in New Issue
Block a user