mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Progress towards automatic OSTC firmware updates
Better parsing of the website data, a simpe dialog that informs the user that they should upgrade their firmware. Still doen't call the right code path to DO the upgrade. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a0d36e2061
commit
2461a731fc
3 changed files with 19 additions and 6 deletions
|
@ -199,19 +199,32 @@ void OstcFirmwareCheck::parseOstcFwVersion()
|
|||
{
|
||||
QWebElement parse = hwVersionPage.mainFrame()->documentElement();
|
||||
QWebElement result = parse.findFirst("div[id=content_firmware_headline_typ0]");
|
||||
latestFirmwareAvailable = result.toPlainText().trimmed();
|
||||
latestFirmwareAvailable = result.toPlainText().trimmed().replace("stable", "");
|
||||
qDebug() << "Latest OSTC 3 Version" << latestFirmwareAvailable;
|
||||
}
|
||||
|
||||
void OstcFirmwareCheck::checkLatest(uint32_t firmwareOnDevice)
|
||||
void OstcFirmwareCheck::checkLatest(QWidget *parent, uint32_t firmwareOnDevice)
|
||||
{
|
||||
// for now libdivecomputer gives us the firmware on device undecoded as integer
|
||||
// for the OSTC that means highbyte.lowbyte is the version number
|
||||
QString firmware;
|
||||
firmware = QString("%1.%2").arg(firmwareOnDevice / 256). arg(firmwareOnDevice % 256);
|
||||
if (!latestFirmwareAvailable.isEmpty() && latestFirmwareAvailable != firmware) {
|
||||
qDebug() << "you should update your firmware: you have" << firmware <<
|
||||
"but the latest stable version is" << latestFirmwareAvailable;
|
||||
QMessageBox response(parent);
|
||||
QString message = tr("You should update the firmware on your dive computer: you have version %1 but the latest stable version is %2")
|
||||
.arg(firmware).arg(latestFirmwareAvailable);
|
||||
response.addButton(tr("Not now"), QMessageBox::RejectRole);
|
||||
response.addButton(tr("Update firmware"), QMessageBox::AcceptRole);
|
||||
response.setText(message);
|
||||
response.setWindowTitle(tr("Firmware upgrade notice"));
|
||||
response.setIcon(QMessageBox::Question);
|
||||
response.setWindowModality(Qt::WindowModal);
|
||||
int ret = response.exec();
|
||||
if (ret == QMessageBox::Accepted) {
|
||||
qDebug() << "go to firmware upgrade";
|
||||
} else {
|
||||
qDebug() << "no upgrade";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class OstcFirmwareCheck : QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit OstcFirmwareCheck();
|
||||
void checkLatest(uint32_t firmwareOnDevice);
|
||||
void checkLatest(QWidget *parent, uint32_t firmwareOnDevice);
|
||||
public
|
||||
slots:
|
||||
void parseOstcFwVersion();
|
||||
|
|
|
@ -403,7 +403,7 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
|
|||
MainWindow::instance()->dive_list()->selectDive(idx, true);
|
||||
QString dcName = data.devname;
|
||||
if (ostcFirmwareCheck)
|
||||
ostcFirmwareCheck->checkLatest(data.libdc_firmware);
|
||||
ostcFirmwareCheck->checkLatest(this, data.libdc_firmware);
|
||||
}
|
||||
} else if (currentState == CANCELLING || currentState == CANCELLED) {
|
||||
if (import_thread_cancelled) {
|
||||
|
|
Loading…
Add table
Reference in a new issue