C++ (Qt)void QSpeedTest::_checkForProgramUpdates(){ QNetworkAccessManager manager; QNetworkReply *download; QEventLoop loop; int remoteVersion; _w.slotLog(trUtf8("Checking online for an updated version of %1").arg(PROGRAMNAME)); QTimer::singleShot(UPDATECHECKTIMEOUTSECS * 1000, &loop, SLOT(quit())); download = manager.get(QNetworkRequest(QUrl(PROJECTVERSIONURL))); // From here on, download pointer does not require manual deletion! connect(download, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); if(download->isRunning() || download->error()) { download->abort(); _w.slotLog(trUtf8("Update site unreachable")); return; } if((remoteVersion = download->readLine().mid(1).toInt()) > PROJECTVERSION.mid(1).toInt()) { _w.slotLog(trUtf8("%1 update available, remote version: r%2").arg(PROGRAMNAME).arg(remoteVersion)); int reply = QMessageBox::question(&_w, trUtf8("Update available"), trUtf8("An updated version of %1 (r%2) is available online.").arg(PROGRAMNAME).arg(remoteVersion) + "\n\n" + trUtf8("Would you like to open the download page in your browser?"), QMessageBox::Yes, QMessageBox::No); if(reply == QMessageBox::Yes) { _w.slotLog(trUtf8("Opening download page %1").arg(PROJECTDOWNLOADURL)); QDesktopServices::openUrl(QUrl(PROJECTDOWNLOADURL)); } } else { _w.slotLog(trUtf8("You are using the latest version of %1").arg(PROGRAMNAME)); }}