Mercurial > trustbridge
diff ui/mainwindow.cpp @ 1081:edbf5e5e88f4
(issue118) Extend verify_binary to carry an open file
* binverify.c: Change result to a structure containing an open fptr
Use in Memory data for windows verification.
* mainwindow.cpp, selftest.c: Handle the returend structure
* binverifytest.cpp: Test for the exclusive read and update signature.
* listutil.c: Add optional fptr parameter to read_file
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 11 Sep 2014 12:05:24 +0200 |
parents | 51b97ebc5b06 |
children | a12e6172d82c |
line wrap: on
line diff
--- a/ui/mainwindow.cpp Thu Sep 11 12:00:10 2014 +0200 +++ b/ui/mainwindow.cpp Thu Sep 11 12:05:24 2014 +0200 @@ -234,14 +234,15 @@ } bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(), swFileName.toUtf8().size()); - qDebug() << "Binary verify result: " << verifyResult; - if (verifyResult != VerifyValid) { + qDebug() << "Binary verify result: " << verifyResult.result; + if (verifyResult.result != VerifyValid) { qDebug() << "Failed to verify downloaded data."; QFile::remove(swFileName); mSettings.remove("Software/available"); mSettings.remove("Software/availableDate"); return; } + fclose(verifyResult.fptr); } void MainWindow::handleNewList(const QString& fileName, const QDateTime& modDate) { @@ -289,9 +290,10 @@ void MainWindow::installNewSW(const QString& fileName, const QDateTime& modDate) { QFileInfo instProcInfo = QFileInfo(fileName); QString filePath = QDir::toNativeSeparators(instProcInfo.absoluteFilePath()); + bin_verify_result vres = verify_binary(filePath.toUtf8().constData(), + filePath.toUtf8().size()); - if (verify_binary(filePath.toUtf8().constData(), - filePath.toUtf8().size()) != VerifyValid) { + if (vres.result != VerifyValid) { qDebug() << "Invalid software. Not installing"; return; } @@ -328,6 +330,7 @@ free(errmsg); qDebug() << "Failed to start process: " << qerrmsg; setState(NewSoftwareAvailable); + fclose(vres.fptr); return; } #else /* WIN32 */ @@ -360,12 +363,15 @@ qDebug() << "Starting process " << filePath <<" params: " << parameters; if (!sudo_started && !QProcess::startDetached(filePath, parameters)) { qDebug() << "Failed to start process."; + fclose(vres.fptr); return; } #endif + + syslog_info_printf ("Installing update: %s\n", fileName.toUtf8().constData()); /* Installer process should now be running. We exit */ - + fclose(vres.fptr); closeApp(); }