16
17
* You should have received a copy of the GNU General Public License *
17
18
* along with this program; if not, write to the *
18
19
* Free Software Foundation, Inc., *
19
* 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
20
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
20
21
***************************************************************************/
22
23
#include "autoupdater.h"
23
24
#include "logger.h"
24
25
#include "exceptions.h"
26
#include "containerutils.h"
26
#include "MooseCommon.h"
27
#include "UnicornCommon.h"
29
30
#include <windows.h>
243
QString errorString = header.reasonPhrase();
235
244
// Something went wrong
236
245
LOG(2, "Download of component failed. Error: " <<
237
mTransport->error() << " - " << mTransport->errorString() << "\n");
246
statusCode << " - " << errorString << "\n");
240
249
mTransport->deleteLater();
242
emit updateDownloadDone(true, QString(tr("Download failed (%1)")).
243
arg(mTransport->errorString()));
251
emit updateDownloadDone(true, QString(tr("Download failed ( %1 - %2 )")).
345
354
LOG(3, "Running '" << installerPath << " " << installArgs << "'\n");
348
if ( ( QSysInfo::WindowsVersion & QSysInfo::WV_VISTA ) == 0 )
350
// Use QProcess if not on Vista to not break Win98
351
QProcess proc( this );
352
proc.setWorkingDirectory( QCoreApplication::applicationDirPath() );
353
installerPath += " " + installArgs;
354
proc.start( installerPath );
356
if (!proc.waitForStarted())
358
LOG(1, "Couldn't start " << installerPath <<
359
". Error: " << proc.error() << "\n");
361
QString msg = tr("Failed to install '%1'.").arg( installerPath );
362
emit updateDownloadDone(true, msg);
366
if (!proc.waitForFinished( 10000 ))
368
LOG(1, installerPath << " never finished. " <<
369
". Error: " << proc.error() << "\n");
371
QString msg = tr("Failed to install '") + installerPath + tr("'.");
372
emit updateDownloadDone(true, msg);
378
// On Vista, use ShellExecute because otherwise the elevation dialog
379
// doesn't appear when launching the installer
380
SHELLEXECUTEINFOW sei;
381
memset(&sei, 0, sizeof(sei));
383
sei.cbSize = sizeof(sei);
384
sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
385
sei.hwnd = GetForegroundWindow();
386
sei.lpVerb = L"open";
387
sei.lpFile = reinterpret_cast<LPCWSTR>(installerPath.utf16());
388
sei.lpParameters = reinterpret_cast<LPCWSTR>(installArgs.utf16());
389
sei.nShow = SW_SHOWNORMAL;
391
BOOL bOK = ShellExecuteExW(&sei);
394
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
395
WaitForSingleObject(sei.hProcess, 5000);
396
CloseHandle(sei.hProcess);
397
QApplication::restoreOverrideCursor();
401
LOG(1, "Couldn't ShellExecuteEx " << installerPath << " " <<
402
installArgs << ". GetLastError: " << GetLastError() << "\n");
404
QString msg = tr("Failed to install '") + installerPath + tr("'.");
405
emit updateDownloadDone(true, msg);
357
// Must use ShellExecute because otherwise the elevation dialog
358
// doesn't appear when launching the installer on Vista.
359
SHELLEXECUTEINFOW sei;
360
memset(&sei, 0, sizeof(sei));
362
sei.cbSize = sizeof(sei);
363
sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
364
sei.hwnd = GetForegroundWindow();
365
sei.lpVerb = L"open";
366
sei.lpFile = reinterpret_cast<LPCWSTR>(installerPath.utf16());
367
sei.lpParameters = reinterpret_cast<LPCWSTR>(installArgs.utf16());
368
sei.nShow = SW_SHOWNORMAL;
370
BOOL bOK = ShellExecuteExW(&sei);
373
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
374
WaitForSingleObject(sei.hProcess, 5000);
375
CloseHandle(sei.hProcess);
376
QApplication::restoreOverrideCursor();
380
LOG(1, "Couldn't ShellExecuteEx " << installerPath << " " <<
381
installArgs << ". GetLastError: " << GetLastError() << "\n");
383
QString msg = tr("Failed to install '") + installerPath + tr("'.");
384
emit updateDownloadDone(true, msg);
411
389
if (mnCurrentDownload < (mnDownloadTasks - 1))