/***************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the release tools of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** $QT_END_LICENSE$ ** *****************************************************************************/ function Component() { installer.currentPageChanged.connect(this, Component.prototype.reactOnPageChange); } vboxManagePath = function() { var result; if (installer.value("os") === "win") { var installPath = installer.execute("REG", ["QUERY", "HKLM\\SOFTWARE\\Oracle\\VirtualBox", "/v", "InstallDir"]); if (installPath.length === 2 && installPath[1] !== 0) installPath = installer.execute("REG", ["QUERY", "HKLM\\SOFTWARE\\Oracle\\VirtualBox", "/reg:64", "/v", "InstallDir"]); if (installPath.length === 2 && installPath[1] === 0) { // Output of "REG QUERY HKLM\SOFTWARE\Oracle\VirtualBox /v InstallDir": // ! REG.EXE VERSION 3.0 // HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\VirtualBox\ // InstallDir REG_SZ C:\Program Files\Oracle\VirtualBox\ installPath = installPath[0].match(/REG_SZ\s+(.+)/)[1]; } else installPath = installer.environmentVariable("VBOX_INSTALL_PATH"); if (installPath === "") installPath = installer.environmentVariable("VBOX_MSI_INSTALL_PATH"); if (installPath !== "") result = installPath + "\\" + "VBoxManage.exe"; } else { result = installer.execute("/usr/bin/which", ["VBoxManage"])[0]; result = result.replace(/\n/gi, ""); } return result; } vboxDeletePreviousVm = function(vboxVmName) { var vboxmanage = vboxManagePath(); var registeredVMs = installer.execute(vboxmanage, ["list", "vms"])[0]; if (registeredVMs.indexOf("\"" + vboxVmName + "\"") !== -1) { var runningVMs = installer.execute(vboxmanage, ["list", "runningvms"])[0]; if (runningVMs.indexOf("\"" + vboxVmName + "\"") !== -1) { installer.execute(vboxmanage, ["controlvm", vboxVmName, "poweroff"]); installer.execute("/bin/sleep", ["2"]); } var ret = installer.execute(vboxmanage, ["unregistervm", vboxVmName, "--delete"])[1]; if ( ret != "0" ) { QMessageBox.critical("Virtual Machine already exists", "Virtual Machine already exists", "VirtualBox has existing Virtual Machine '" + vboxVmName + "' and installer was unable to remove it. " + "You have to manually remove the existing Virtual Machine from VirtualBox before continuing."); } } } Component.prototype.reactOnPageChange = function(value) { if (QInstaller.ReadyForInstallation == value) { if (component.installationRequested() && !vboxManagePath()) { QMessageBox.warning("VirtualBox not installed", "VirtualBox not installed", "VirtualBox was not found on your computer. It is needed to install the Emulator of this SDK. Install VirtualBox first or deselect all Emulator components."); } } }