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 parse = hwVersionPage.mainFrame()->documentElement(); | ||||||
| 	QWebElement result = parse.findFirst("div[id=content_firmware_headline_typ0]"); | 	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; | 	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 now libdivecomputer gives us the firmware on device undecoded as integer
 | ||||||
| 	// for the OSTC that means highbyte.lowbyte is the version number
 | 	// for the OSTC that means highbyte.lowbyte is the version number
 | ||||||
| 	QString firmware; | 	QString firmware; | ||||||
| 	firmware = QString("%1.%2").arg(firmwareOnDevice / 256). arg(firmwareOnDevice % 256); | 	firmware = QString("%1.%2").arg(firmwareOnDevice / 256). arg(firmwareOnDevice % 256); | ||||||
| 	if (!latestFirmwareAvailable.isEmpty() && latestFirmwareAvailable != firmware) { | 	if (!latestFirmwareAvailable.isEmpty() && latestFirmwareAvailable != firmware) { | ||||||
| 		qDebug() << "you should update your firmware: you have" << firmware << | 		QMessageBox response(parent); | ||||||
| 			    "but the latest stable version is" << latestFirmwareAvailable; | 		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 | 	Q_OBJECT | ||||||
| public: | public: | ||||||
| 	explicit OstcFirmwareCheck(); | 	explicit OstcFirmwareCheck(); | ||||||
| 	void checkLatest(uint32_t firmwareOnDevice); | 	void checkLatest(QWidget *parent, uint32_t firmwareOnDevice); | ||||||
| public | public | ||||||
| slots: | slots: | ||||||
| 	void parseOstcFwVersion(); | 	void parseOstcFwVersion(); | ||||||
|  |  | ||||||
|  | @ -403,7 +403,7 @@ void DownloadFromDCWidget::onDownloadThreadFinished() | ||||||
| 			MainWindow::instance()->dive_list()->selectDive(idx, true); | 			MainWindow::instance()->dive_list()->selectDive(idx, true); | ||||||
| 			QString dcName = data.devname; | 			QString dcName = data.devname; | ||||||
| 			if (ostcFirmwareCheck) | 			if (ostcFirmwareCheck) | ||||||
| 				ostcFirmwareCheck->checkLatest(data.libdc_firmware); | 				ostcFirmwareCheck->checkLatest(this, data.libdc_firmware); | ||||||
| 		} | 		} | ||||||
| 	} else if (currentState == CANCELLING || currentState == CANCELLED) { | 	} else if (currentState == CANCELLING || currentState == CANCELLED) { | ||||||
| 		if (import_thread_cancelled) { | 		if (import_thread_cancelled) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue