aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-27 09:16:39 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-28 06:39:30 -0800
commit2461a731fc4c485c3d54f4cd5def37aaaf6cb829 (patch)
tree2e607f2825cb372dc5688b44eac599d8790295c9
parenta0d36e2061d4f831e51bc3a87552d58a80c4cf6c (diff)
downloadsubsurface-2461a731fc4c485c3d54f4cd5def37aaaf6cb829.tar.gz
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>
-rw-r--r--qt-ui/configuredivecomputerdialog.cpp21
-rw-r--r--qt-ui/configuredivecomputerdialog.h2
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp2
3 files changed, 19 insertions, 6 deletions
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";
+ }
}
}
diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h
index fa43592c2..abc7d0be6 100644
--- a/qt-ui/configuredivecomputerdialog.h
+++ b/qt-ui/configuredivecomputerdialog.h
@@ -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();
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index b270def5b..bc3fc12e8 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -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) {