From 2461a731fc4c485c3d54f4cd5def37aaaf6cb829 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 27 Dec 2014 09:16:39 -0800 Subject: 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 --- qt-ui/configuredivecomputerdialog.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 546032e63..8ebfa317b 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -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"; + } } } -- cgit v1.2.3-70-g09d2