diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-12-28 07:37:11 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-28 07:37:11 -0800 |
commit | 0be0cdb046018a5ec633bfc6f0aacba20d5c35e2 (patch) | |
tree | 628557756a616ad1cfc3a8ac286a7fbb9353cf23 | |
parent | 542ff7fc367560b33c8d617c9534f934cab0a546 (diff) | |
download | subsurface-0be0cdb046018a5ec633bfc6f0aacba20d5c35e2.tar.gz |
OSTC firmware update prompt: use the stable changelog files
Heinrichs Weikamp is giving us stable URLs from which we can get the
latest stable version. The parsing is a bit simplistic, but it seems to
work.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/configuredivecomputerdialog.cpp | 20 | ||||
-rw-r--r-- | qt-ui/configuredivecomputerdialog.h | 2 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 5 |
3 files changed, 18 insertions, 9 deletions
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 29275c6a7..46ac62386 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -190,18 +190,26 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : settings.endGroup(); } -OstcFirmwareCheck::OstcFirmwareCheck() +OstcFirmwareCheck::OstcFirmwareCheck(QString product) { - hwVersionPage.mainFrame()->load(QUrl("http://www.heinrichsweikamp.com/?id=162")); + QUrl url; + if (product == "OSTC 3") + url = QUrl("http://www.heinrichsweikamp.net/autofirmware/ostc3_changelog.txt"); + else if (product == "OSTC Sport") + url = QUrl("http://www.heinrichsweikamp.net/autofirmware/ostc_sport_changelog.txt"); + else // not one of the known dive computers + return; + hwVersionPage.mainFrame()->load(url); connect(&hwVersionPage, SIGNAL(loadFinished(bool)), this, SLOT(parseOstcFwVersion())); } void OstcFirmwareCheck::parseOstcFwVersion() { - QWebElement parse = hwVersionPage.mainFrame()->documentElement(); - QWebElement result = parse.findFirst("div[id=content_firmware_headline_typ0]"); - latestFirmwareAvailable = result.toPlainText().trimmed().replace("stable", ""); - qDebug() << "Latest OSTC 3 Version" << latestFirmwareAvailable; + QString parse = hwVersionPage.mainFrame()->toPlainText(); + int firstOpenBracket = parse.indexOf('['); + int firstCloseBracket = parse.indexOf(']'); + latestFirmwareAvailable = parse.mid(firstOpenBracket + 1, firstCloseBracket - firstOpenBracket -1); + qDebug() << "latest firmware available" << latestFirmwareAvailable; } void OstcFirmwareCheck::checkLatest(QWidget *parent, uint32_t firmwareOnDevice) diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index abc7d0be6..3e3262df4 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -106,7 +106,7 @@ class OstcFirmwareCheck : QObject { Q_OBJECT public: - explicit OstcFirmwareCheck(); + explicit OstcFirmwareCheck(QString product); void checkLatest(QWidget *parent, uint32_t firmwareOnDevice); public slots: diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index bc3fc12e8..59a8139d6 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -304,8 +304,9 @@ void DownloadFromDCWidget::on_ok_clicked() thread->start(); - if (ui.product->currentText() == "OSTC 3" || ui.product->currentText() == "OSTC sport") - ostcFirmwareCheck = new OstcFirmwareCheck(); + QString product(ui.product->currentText()); + if (product == "OSTC 3" || product == "OSTC Sport") + ostcFirmwareCheck = new OstcFirmwareCheck(product); } bool DownloadFromDCWidget::preferDownloaded() |