VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

Last change on this file was 106061, checked in by vboxsync, 3 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 104.1 KB
Line 
1/* $Id: UISession.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISession class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QApplication>
30#include <QRegularExpression>
31#include <QWidget>
32
33/* GUI includes: */
34#include "UIActionPoolRuntime.h"
35#include "UICommon.h"
36#include "UIConsoleEventHandler.h"
37#include "UIConverter.h"
38#include "UIDetailsGenerator.h"
39#include "UIExtraDataManager.h"
40#include "UIFrameBuffer.h"
41#include "UIGlobalSession.h"
42#include "UIIconPool.h"
43#include "UIGuestOSType.h"
44#include "UILocalMachineStuff.h"
45#include "UILoggingDefs.h"
46#include "UIMachine.h"
47#include "UIMachineLogic.h"
48#include "UIMachineView.h"
49#include "UIMachineWindow.h"
50#include "UIMedium.h"
51#include "UIMediumEnumerator.h"
52#include "UIMessageCenter.h"
53#include "UIMediumTools.h"
54#include "UIModalWindowManager.h"
55#include "UIMousePointerShapeData.h"
56#include "UINotificationCenter.h"
57#include "UISession.h"
58#include "UITextTable.h"
59#include "UIUSBTools.h"
60#include "UIVersion.h"
61#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
62# include "UIKeyboardHandler.h"
63# include <signal.h>
64#endif
65
66/* COM includes: */
67#include "CAudioAdapter.h"
68#include "CAudioSettings.h"
69#include "CEmulatedUSB.h"
70#include "CGraphicsAdapter.h"
71#include "CHostNetworkInterface.h"
72#include "CHostUSBDevice.h"
73#include "CHostVideoInputDevice.h"
74#include "CMedium.h"
75#include "CMediumAttachment.h"
76#include "CPlatform.h"
77#include "CPlatformProperties.h"
78#include "CRecordingSettings.h"
79#include "CSnapshot.h"
80#include "CStorageController.h"
81#include "CSystemProperties.h"
82#include "CUSBController.h"
83#include "CUSBDevice.h"
84#include "CUSBDeviceFilter.h"
85#include "CUSBDeviceFilters.h"
86#include "CVRDEServer.h"
87#include "CVRDEServerInfo.h"
88#ifdef VBOX_WITH_NETFLT
89# include "CNetworkAdapter.h"
90#endif
91
92/* Other VBox includes: */
93#ifdef VBOX_WITH_DEBUGGER_GUI
94# include <VBox/dbggui.h>
95# include <iprt/ldr.h>
96#endif
97
98#include <VBox/GuestHost/clipboard-helper.h>
99
100/* VirtualBox interface declarations: */
101#include <VBox/com/VirtualBox.h>
102
103/* External includes: */
104#ifdef VBOX_WS_NIX
105# include <X11/Xlib.h>
106# include <X11/Xutil.h>
107#endif
108
109
110#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
111static void signalHandlerSIGUSR1(int sig, siginfo_t *, void *);
112#endif
113
114UISession::UISession(UIMachine *pMachine)
115 : QObject(pMachine)
116 /* Base variables: */
117 , m_pMachine(pMachine)
118 , m_fValid(false)
119 , m_pConsoleEventhandler(0)
120 /* Common variables: */
121 , m_enmMachineStatePrevious(KMachineState_Null)
122 , m_enmMachineState(KMachineState_Null)
123 /* Guest additions flags: */
124 , m_ulGuestAdditionsRunLevel(0)
125 , m_fIsGuestSupportsGraphics(false)
126 , m_fIsGuestSupportsSeamless(false)
127#ifdef VBOX_WITH_DEBUGGER_GUI
128 /* Debug UI stuff: */
129 , m_pDbgGui(0)
130 , m_pDbgGuiVT(0)
131#endif /* VBOX_WITH_DEBUGGER_GUI */
132{
133}
134
135bool UISession::prepare()
136{
137 /* Prepare COM stuff: */
138 if (!prepareCOMStuff())
139 return false;
140
141 /* Cache media early if requested: */
142 if (uiCommon().agressiveCaching())
143 recacheMachineMedia();
144
145 /* Prepare GUI stuff: */
146 prepareConsoleEventHandlers();
147 prepareFramebuffers();
148 prepareConnections();
149 prepareSignalHandling();
150
151 /* True by default: */
152 return true;
153}
154
155bool UISession::initialize()
156{
157 /* Preprocess initialization: */
158 if (!preprocessInitialization())
159 return false;
160
161 /* Notify user about mouse&keyboard auto-capturing: */
162 if (gEDataManager->autoCaptureEnabled())
163 UINotificationMessage::remindAboutAutoCapture();
164
165 m_enmMachineState = machine().GetState();
166
167 /* Apply debug settings from the command line. */
168 if (!debugger().isNull() && debugger().isOk())
169 {
170 if (uiCommon().areWeToExecuteAllInIem())
171 debugger().SetExecuteAllInIEM(true);
172 if (!uiCommon().isDefaultWarpPct())
173 debugger().SetVirtualTimeRate(uiCommon().getWarpPct());
174 }
175
176 /* Apply ad-hoc reconfigurations from the command line: */
177 if (uiCommon().hasFloppyImageToMount())
178 mountAdHocImage(KDeviceType_Floppy, UIMediumDeviceType_Floppy, uiCommon().getFloppyImage());
179 if (uiCommon().hasDvdImageToMount())
180 mountAdHocImage(KDeviceType_DVD, UIMediumDeviceType_DVD, uiCommon().getDvdImage());
181
182 /* Power UP if this is NOT separate process: */
183 if (!uiCommon().isSeparateProcess())
184 if (!powerUp())
185 return false;
186
187 /* Make sure all the pending Console events converted to signals
188 * during the powerUp() progress above reached their destinations.
189 * That is necessary to make sure all the pending machine state change events processed.
190 * We can't just use the machine state directly acquired from IMachine because there
191 * will be few places which are using stale machine state, not just this one. */
192 QApplication::sendPostedEvents(0, QEvent::MetaCall);
193
194 /* Check if we missed a really quick termination after successful startup: */
195 if (isTurnedOff())
196 {
197 LogRel(("GUI: Aborting startup due to invalid machine state detected: %d\n", machineState()));
198 return false;
199 }
200
201 /* Fetch corresponding states: */
202 if (uiCommon().isSeparateProcess())
203 sltAdditionsChange();
204
205#ifdef VBOX_GUI_WITH_PIDFILE
206 uiCommon().createPidfile();
207#endif /* VBOX_GUI_WITH_PIDFILE */
208
209 /* Mark as valid finally: */
210 m_fValid = true;
211
212 /* True by default: */
213 return true;
214}
215
216bool UISession::powerUp()
217{
218 /* Power UP machine: */
219 CProgress comProgress = uiCommon().shouldStartPaused() ? console().PowerUpPaused() : console().PowerUp();
220
221 /* Check for immediate failure: */
222 if (!console().isOk() || comProgress.isNull())
223 {
224 if (uiCommon().showStartVMErrors())
225 msgCenter().cannotStartMachine(console(), machineName());
226 LogRel(("GUI: Aborting startup due to power up issue detected...\n"));
227 return false;
228 }
229
230 /* Some logging right after we powered up: */
231 LogRel(("GUI: Qt version: %s\n", UIVersionInfo::qtRTVersionString().toUtf8().constData()));
232#ifdef VBOX_WS_NIX
233 LogRel(("GUI: X11 Window Manager code: %d\n", (int)uiCommon().typeOfWindowManager()));
234#endif
235#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
236 LogRel(("GUI: HID LEDs sync is %s\n", uimachine()->isHidLedsSyncEnabled() ? "enabled" : "disabled"));
237#else
238 LogRel(("GUI: HID LEDs sync is not supported on this platform\n"));
239#endif
240
241 /* Enable 'manual-override',
242 * preventing automatic Runtime UI closing
243 * and visual representation mode changes: */
244 uimachine()->setManualOverrideMode(true);
245
246 /* Show "Starting/Restoring" progress dialog: */
247 if (isSaved())
248 {
249 msgCenter().showModalProgressDialog(comProgress, machineName(), ":/progress_state_restore_90px.png", 0, 0);
250 /* After restoring from 'saved' state, machine-window(s) geometry should be adjusted: */
251 machineLogic()->adjustMachineWindowsGeometry();
252 }
253 else
254 {
255#ifdef VBOX_IS_QT6_OR_LATER /** @todo why is this any problem on qt6? */
256 msgCenter().showModalProgressDialog(comProgress, machineName(), ":/progress_start_90px.png", 0, 0);
257#else
258 msgCenter().showModalProgressDialog(comProgress, machineName(), ":/progress_start_90px.png");
259#endif
260 /* After VM start, machine-window(s) size-hint(s) should be sent: */
261 machineLogic()->sendMachineWindowsSizeHints();
262 }
263
264 /* Check for progress failure: */
265 if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
266 {
267 if (uiCommon().showStartVMErrors())
268 msgCenter().cannotStartMachine(comProgress, machineName());
269 LogRel(("GUI: Aborting startup due to power up progress issue detected...\n"));
270 return false;
271 }
272
273 /* Disable 'manual-override' finally: */
274 uimachine()->setManualOverrideMode(false);
275
276 /* True by default: */
277 return true;
278}
279
280WId UISession::mainMachineWindowId() const
281{
282 return mainMachineWindow() ? mainMachineWindow()->winId() : 0;
283}
284
285void UISession::acquireMachinePixmap(const QSize &size, QPixmap &pixmap)
286{
287 QPixmap machinePixmap;
288 if (machine().isNotNull())
289 machinePixmap = generalIconPool().userMachinePixmap(machine(), size);
290 if (machinePixmap.isNull())
291 machinePixmap = generalIconPool().guestOSTypePixmap(osTypeId(), size);
292 if (!machinePixmap.isNull())
293 pixmap = machinePixmap;
294}
295
296void UISession::acquireUserMachineIcon(QIcon &icon)
297{
298 QIcon machineIcon;
299 if (machine().isNotNull())
300 machineIcon = generalIconPool().userMachineIcon(machine());
301 if (machineIcon.isNull())
302 machineIcon = generalIconPool().guestOSTypeIcon(osTypeId());
303 if (machineIcon.isNull())
304 machineIcon = QIcon(":/VirtualBox_48px.png");
305 if (!machineIcon.isNull())
306 icon = machineIcon;
307}
308
309bool UISession::acquireArchitectureType(KPlatformArchitecture &enmType)
310{
311 CMachine comMachine = machine();
312 if (comMachine.isNull())
313 return false;
314 CPlatform comPlatform = comMachine.GetPlatform();
315 bool fSuccess = comMachine.isOk();
316 if (!fSuccess)
317 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
318 else
319 {
320 const KPlatformArchitecture enmArchType = comPlatform.GetArchitecture();
321 fSuccess = comPlatform.isOk();
322 if (!fSuccess)
323 UINotificationMessage::cannotAcquirePlatformParameter(comPlatform);
324 else
325 enmType = enmArchType;
326 }
327 return fSuccess;
328}
329
330bool UISession::acquireChipsetType(KChipsetType &enmType)
331{
332 CMachine comMachine = machine();
333 if (comMachine.isNull())
334 return false;
335 CPlatform comPlatform = comMachine.GetPlatform();
336 bool fSuccess = comMachine.isOk();
337 if (!fSuccess)
338 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
339 else
340 {
341 const KChipsetType enmChipsetType = comPlatform.GetChipsetType();
342 fSuccess = comPlatform.isOk();
343 if (!fSuccess)
344 UINotificationMessage::cannotAcquirePlatformParameter(comPlatform);
345 else
346 enmType = enmChipsetType;
347 }
348 return fSuccess;
349}
350
351bool UISession::acquireLiveMachineState(KMachineState &enmState)
352{
353 CMachine comMachine = machine();
354 if (comMachine.isNull())
355 return false;
356 const KMachineState enmMachineState = comMachine.GetState();
357 const bool fSuccess = comMachine.isOk();
358 if (!fSuccess)
359 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
360 else
361 enmState = enmMachineState;
362 return fSuccess;
363}
364
365bool UISession::reset()
366{
367 CConsole comConsole = console();
368 comConsole.Reset();
369 const bool fSuccess = comConsole.isOk();
370 if (!fSuccess)
371 UINotificationMessage::cannotResetMachine(comConsole);
372 return fSuccess;
373}
374
375bool UISession::setPause(bool fPause)
376{
377 CConsole comConsole = console();
378 if (fPause)
379 comConsole.Pause();
380 else
381 comConsole.Resume();
382 const bool fSuccess = comConsole.isOk();
383 if (!fSuccess)
384 {
385 if (fPause)
386 UINotificationMessage::cannotPauseMachine(comConsole);
387 else
388 UINotificationMessage::cannotResumeMachine(comConsole);
389 }
390 return fSuccess;
391}
392
393bool UISession::acquireSettingsFilePath(QString &strPath)
394{
395 CMachine comMachine = machine();
396 const QString strSettingsFilePath = comMachine.GetSettingsFilePath();
397 const bool fSuccess = comMachine.isOk();
398 if (!fSuccess)
399 UINotificationMessage::cannotSaveMachineSettings(comMachine);
400 else
401 strPath = strSettingsFilePath;
402 return fSuccess;
403}
404
405bool UISession::saveSettings()
406{
407 CMachine comMachine = machine();
408 comMachine.SaveSettings();
409 const bool fSuccess = comMachine.isOk();
410 if (!fSuccess)
411 UINotificationMessage::cannotSaveMachineSettings(comMachine);
412 return fSuccess;
413}
414
415bool UISession::acquireSnapshotCount(ulong &uCount)
416{
417 CMachine comMachine = machine();
418 const ULONG uSnapshotCount = comMachine.GetSnapshotCount();
419 const bool fSuccess = comMachine.isOk();
420 if (!fSuccess)
421 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
422 else
423 uCount = uSnapshotCount;
424 return fSuccess;
425}
426
427bool UISession::acquireCurrentSnapshotName(QString &strName)
428{
429 CMachine comMachine = machine();
430 CSnapshot comSnapshot = comMachine.GetCurrentSnapshot();
431 bool fSuccess = comMachine.isOk();
432 if (!fSuccess)
433 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
434 {
435 const QString strSnapshotName = comSnapshot.GetName();
436 fSuccess = comSnapshot.isOk();
437 if (!fSuccess)
438 UINotificationMessage::cannotAcquireSnapshotParameter(comSnapshot);
439 else
440 strName = strSnapshotName;
441 }
442 return fSuccess;
443}
444
445bool UISession::acquireMaxSnapshotIndex(const QString &strNameTemplate, ulong &uIndex)
446{
447 CMachine comMachine = machine();
448 CSnapshot comSnapshot = comMachine.FindSnapshot(QString());
449 return searchMaxSnapshotIndex(comMachine, comSnapshot, strNameTemplate, uIndex);
450}
451
452void UISession::takeSnapshot(const QString &strName, const QString &strDescription)
453{
454 CMachine comMachine = machine();
455 UINotificationProgressSnapshotTake *pNotification = new UINotificationProgressSnapshotTake(comMachine,
456 strName,
457 strDescription);
458 gpNotificationCenter->append(pNotification);
459}
460
461bool UISession::putScancode(LONG iCode)
462{
463 CKeyboard comKeyboard = keyboard();
464 comKeyboard.PutScancode(iCode);
465 const bool fSuccess = comKeyboard.isOk();
466 if (!fSuccess)
467 UINotificationMessage::cannotChangeKeyboardParameter(comKeyboard);
468 return fSuccess;
469}
470
471bool UISession::putScancodes(const QVector<LONG> &codes)
472{
473 CKeyboard comKeyboard = keyboard();
474 if (comKeyboard.isNull())
475 return false;
476 comKeyboard.PutScancodes(codes);
477 const bool fSuccess = comKeyboard.isOk();
478 if (!fSuccess)
479 UINotificationMessage::cannotChangeKeyboardParameter(comKeyboard);
480 return fSuccess;
481}
482
483bool UISession::putCAD()
484{
485 CKeyboard comKeyboard = keyboard();
486 comKeyboard.PutCAD();
487 const bool fSuccess = comKeyboard.isOk();
488 if (!fSuccess)
489 UINotificationMessage::cannotChangeKeyboardParameter(comKeyboard);
490 return fSuccess;
491}
492
493bool UISession::releaseKeys()
494{
495 CKeyboard comKeyboard = keyboard();
496 comKeyboard.ReleaseKeys();
497 const bool fSuccess = comKeyboard.isOk();
498 if (!fSuccess)
499 UINotificationMessage::cannotChangeKeyboardParameter(comKeyboard);
500 return fSuccess;
501}
502
503bool UISession::putUsageCode(LONG iUsageCode, LONG iUsagePage, bool fKeyRelease)
504{
505 CKeyboard comKeyboard = keyboard();
506 comKeyboard.PutUsageCode(iUsageCode, iUsagePage, fKeyRelease);
507 const bool fSuccess = comKeyboard.isOk();
508 if (!fSuccess)
509 UINotificationMessage::cannotChangeKeyboardParameter(comKeyboard);
510 return fSuccess;
511}
512
513bool UISession::acquireWhetherAbsoluteSupported(bool &fSupported)
514{
515 CMouse comMouse = mouse();
516 if (comMouse.isNull())
517 return false;
518 const BOOL fAbsoluteSupported = comMouse.GetAbsoluteSupported();
519 const bool fSuccess = comMouse.isOk();
520 if (!fSuccess)
521 UINotificationMessage::cannotAcquireMouseParameter(comMouse);
522 else
523 fSupported = fAbsoluteSupported == TRUE;
524 return fSuccess;
525}
526
527bool UISession::acquireWhetherRelativeSupported(bool &fSupported)
528{
529 CMouse comMouse = mouse();
530 if (comMouse.isNull())
531 return false;
532 const BOOL fRelativeSupported = comMouse.GetRelativeSupported();
533 const bool fSuccess = comMouse.isOk();
534 if (!fSuccess)
535 UINotificationMessage::cannotAcquireMouseParameter(comMouse);
536 else
537 fSupported = fRelativeSupported == TRUE;
538 return fSuccess;
539}
540
541bool UISession::acquireWhetherTouchScreenSupported(bool &fSupported)
542{
543 CMouse comMouse = mouse();
544 if (comMouse.isNull())
545 return false;
546 const BOOL fTouchScreenSupported = comMouse.GetTouchScreenSupported();
547 const bool fSuccess = comMouse.isOk();
548 if (!fSuccess)
549 UINotificationMessage::cannotAcquireMouseParameter(comMouse);
550 else
551 fSupported = fTouchScreenSupported == TRUE;
552 return fSuccess;
553}
554
555bool UISession::acquireWhetherTouchPadSupported(bool &fSupported)
556{
557 CMouse comMouse = mouse();
558 if (comMouse.isNull())
559 return false;
560 const BOOL fTouchPadSupported = comMouse.GetTouchPadSupported();
561 const bool fSuccess = comMouse.isOk();
562 if (!fSuccess)
563 UINotificationMessage::cannotAcquireMouseParameter(comMouse);
564 else
565 fSupported = fTouchPadSupported == TRUE;
566 return fSuccess;
567}
568
569bool UISession::acquireWhetherNeedsHostCursor(bool &fNeeds)
570{
571 CMouse comMouse = mouse();
572 if (comMouse.isNull())
573 return false;
574 const BOOL fNeedsHostCursor = comMouse.GetNeedsHostCursor();
575 const bool fSuccess = comMouse.isOk();
576 if (!fSuccess)
577 UINotificationMessage::cannotAcquireMouseParameter(comMouse);
578 else
579 fNeeds = fNeedsHostCursor == TRUE;
580 return fSuccess;
581}
582
583bool UISession::putMouseEvent(long iDx, long iDy, long iDz, long iDw, long iButtonState)
584{
585 CMouse comMouse = mouse();
586 if (comMouse.isNull())
587 return false;
588 comMouse.PutMouseEvent(iDx, iDy, iDz, iDw, iButtonState);
589 const bool fSuccess = comMouse.isOk();
590 if (!fSuccess)
591 UINotificationMessage::cannotChangeMouseParameter(comMouse);
592 return fSuccess;
593}
594
595bool UISession::putMouseEventAbsolute(long iX, long iY, long iDz, long iDw, long iButtonState)
596{
597 CMouse comMouse = mouse();
598 if (comMouse.isNull())
599 return false;
600 comMouse.PutMouseEventAbsolute(iX, iY, iDz, iDw, iButtonState);
601 const bool fSuccess = comMouse.isOk();
602 if (!fSuccess)
603 UINotificationMessage::cannotChangeMouseParameter(comMouse);
604 return fSuccess;
605}
606
607bool UISession::putEventMultiTouch(long iCount, const QVector<LONG64> &contacts, bool fIsTouchScreen, ulong uScanTime)
608{
609 CMouse comMouse = mouse();
610 if (comMouse.isNull())
611 return false;
612 comMouse.PutEventMultiTouch(iCount, contacts, fIsTouchScreen, uScanTime);
613 const bool fSuccess = comMouse.isOk();
614 if (!fSuccess)
615 UINotificationMessage::cannotChangeMouseParameter(comMouse);
616 return fSuccess;
617}
618
619bool UISession::acquireClipboardMode(KClipboardMode &enmMode)
620{
621 CMachine comMachine = machine();
622 if (comMachine.isNull())
623 return false;
624 const KClipboardMode enmClipboardMode = comMachine.GetClipboardMode();
625 const bool fSuccess = comMachine.isOk();
626 if (!fSuccess)
627 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
628 else
629 enmMode = enmClipboardMode;
630 return fSuccess;
631}
632
633bool UISession::setClipboardMode(KClipboardMode enmMode)
634{
635 CMachine comMachine = machine();
636 comMachine.SetClipboardMode(enmMode);
637 const bool fSuccess = comMachine.isOk();
638 if (!fSuccess)
639 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
640 return fSuccess;
641}
642
643bool UISession::toggleClipboardFileTransfer(bool fEnabled)
644{
645 CMachine comMachine = machine();
646 comMachine.SetClipboardFileTransfersEnabled(fEnabled);
647 const bool fSuccess = comMachine.isOk();
648 if (!fSuccess)
649 UINotificationMessage::cannotChangeMachineParameter(comMachine);
650 return fSuccess;
651}
652
653bool UISession::isClipboardFileTransferEnabled()
654{
655 CMachine comMachine = machine();
656 bool fEnabled = comMachine.GetClipboardFileTransfersEnabled();
657 const bool fSuccess = comMachine.isOk();
658 if (!fSuccess)
659 {
660 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
661 return false;
662 }
663 return fEnabled;
664}
665
666bool UISession::acquireDnDMode(KDnDMode &enmMode)
667{
668 CMachine comMachine = machine();
669 if (comMachine.isNull())
670 return false;
671 const KDnDMode enmDnDMode = comMachine.GetDnDMode();
672 const bool fSuccess = comMachine.isOk();
673 if (!fSuccess)
674 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
675 else
676 enmMode = enmDnDMode;
677 return fSuccess;
678}
679
680bool UISession::setDnDMode(KDnDMode enmMode)
681{
682 CMachine comMachine = machine();
683 comMachine.SetDnDMode(enmMode);
684 const bool fSuccess = comMachine.isOk();
685 if (!fSuccess)
686 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
687 return fSuccess;
688}
689
690bool UISession::acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives)
691{
692 const CMachine comMachine = machine();
693 if (comMachine.isNull())
694 return false;
695 ulong cActualHardDisks = 0, cActualOpticalDrives = 0, cActualFloppyDrives = 0;
696 const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
697 bool fSuccess = comMachine.isOk();
698 if (!fSuccess)
699 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
700 else
701 {
702 foreach (const CMediumAttachment &comAttachment, comAttachments)
703 {
704 /* Get device type: */
705 const KDeviceType enmDeviceType = comAttachment.GetType();
706 fSuccess = comAttachment.isOk();
707 if (!fSuccess)
708 {
709 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
710 break;
711 }
712
713 /* And advance corresponding amount: */
714 switch (enmDeviceType)
715 {
716 case KDeviceType_HardDisk: ++cActualHardDisks; break;
717 case KDeviceType_DVD: ++cActualOpticalDrives; break;
718 case KDeviceType_Floppy: ++cActualFloppyDrives; break;
719 default: break;
720 }
721 }
722 }
723 if (fSuccess)
724 {
725 cHardDisks = cActualHardDisks;
726 cOpticalDrives = cActualOpticalDrives;
727 cFloppyDrives = cActualFloppyDrives;
728 }
729 return fSuccess;
730}
731
732bool UISession::storageDevices(KDeviceType enmActualDeviceType, QList<StorageDeviceInfo> &guiStorageDevices)
733{
734 const CMachine comMachine = machine();
735 const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
736 bool fSuccess = comMachine.isOk();
737 if (!fSuccess)
738 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
739 else
740 {
741 foreach (const CMediumAttachment &comAttachment, comAttachments)
742 {
743 /* Get device type: */
744 const KDeviceType enmDeviceType = comAttachment.GetType();
745 fSuccess = comAttachment.isOk();
746 if (!fSuccess)
747 {
748 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
749 break;
750 }
751 /* And make sure it's actual one: */
752 if (enmDeviceType != enmActualDeviceType)
753 continue;
754
755 /* Get controller name: */
756 const QString strControllerName = comAttachment.GetController();
757 fSuccess = comAttachment.isOk();
758 if (!fSuccess)
759 {
760 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
761 break;
762 }
763 /* And search for it's presence: */
764 const CStorageController comController = comMachine.GetStorageControllerByName(strControllerName);
765 fSuccess = comMachine.isOk();
766 if (!fSuccess)
767 {
768 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
769 break;
770 }
771
772 /* Fill structure fields: */
773 StorageDeviceInfo guiStorageDevice;
774 guiStorageDevice.m_strControllerName = strControllerName; // already confirmed
775 const KStorageBus enmStorageBus = comController.GetBus();
776 fSuccess = comController.isOk();
777 if (!fSuccess)
778 {
779 UINotificationMessage::cannotAcquireStorageControllerParameter(comController);
780 break;
781 }
782 switch (enmStorageBus)
783 {
784 case KStorageBus_IDE: guiStorageDevice.m_icon = UIIconPool::iconSet(":/ide_16px.png"); break;
785 case KStorageBus_SATA: guiStorageDevice.m_icon = UIIconPool::iconSet(":/sata_16px.png"); break;
786 case KStorageBus_SCSI: guiStorageDevice.m_icon = UIIconPool::iconSet(":/scsi_16px.png"); break;
787 case KStorageBus_Floppy: guiStorageDevice.m_icon = UIIconPool::iconSet(":/floppy_16px.png"); break;
788 case KStorageBus_SAS: guiStorageDevice.m_icon = UIIconPool::iconSet(":/sas_16px.png"); break;
789 case KStorageBus_USB: guiStorageDevice.m_icon = UIIconPool::iconSet(":/usb_16px.png"); break;
790 case KStorageBus_PCIe: guiStorageDevice.m_icon = UIIconPool::iconSet(":/pcie_16px.png"); break;
791 case KStorageBus_VirtioSCSI: guiStorageDevice.m_icon = UIIconPool::iconSet(":/virtio_scsi_16px.png"); break;
792 default: break;
793 }
794 const long iPort = comAttachment.GetPort();
795 fSuccess = comAttachment.isOk();
796 if (!fSuccess)
797 {
798 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
799 break;
800 }
801 const long iDevice = comAttachment.GetDevice();
802 fSuccess = comAttachment.isOk();
803 if (!fSuccess)
804 {
805 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
806 break;
807 }
808 if (fSuccess)
809 {
810 const StorageSlot guiStorageSlot(enmStorageBus, iPort, iDevice);
811 guiStorageDevice.m_guiStorageSlot = guiStorageSlot;
812 }
813
814 /* Append or break if necessary: */
815 if (fSuccess)
816 guiStorageDevices << guiStorageDevice;
817 else
818 break;
819 }
820 }
821 return fSuccess;
822}
823
824bool UISession::acquireEncryptedMedia(EncryptedMediumMap &media)
825{
826 EncryptedMediumMap encryptedMedia;
827 CMachine comMachine = machine();
828 const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
829 bool fSuccess = comMachine.isOk();
830 if (!fSuccess)
831 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
832 else
833 {
834 foreach (const CMediumAttachment &comAttachment, comAttachments)
835 {
836 const KDeviceType enmType = comAttachment.GetType();
837 fSuccess = comAttachment.isOk();
838 if (!fSuccess)
839 {
840 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
841 break;
842 }
843
844 /* Look for hard-drive attachments only: */
845 if (enmType != KDeviceType_HardDisk)
846 continue;
847
848 /* Get the attachment medium: */
849 const CMedium comMedium = comAttachment.GetMedium();
850 fSuccess = comAttachment.isOk();
851 if (!fSuccess)
852 {
853 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
854 break;
855 }
856
857 /* Get the medium ID: */
858 const QUuid uId = comMedium.GetId();
859 fSuccess = comMedium.isOk();
860 if (!fSuccess)
861 {
862 UINotificationMessage::cannotAcquireMediumParameter(comMedium);
863 break;
864 }
865
866 /* Update the map with this medium if it's encrypted: */
867 QString strCipher;
868 const QString strPasswordId = comMedium.GetEncryptionSettings(strCipher);
869 if (comMedium.isOk()) // GetEncryptionSettings failure is a valid case
870 encryptedMedia.insert(strPasswordId, uId);
871 }
872 }
873
874 if (fSuccess)
875 media = encryptedMedia;
876 return fSuccess;
877}
878
879bool UISession::addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend)
880{
881 CConsole comConsole = console();
882 comConsole.AddEncryptionPassword(strId, strPassword, fClearOnSuspend);
883 const bool fSuccess = comConsole.isOk();
884 if (!fSuccess)
885 msgCenter().cannotAddDiskEncryptionPassword(comConsole);
886 return fSuccess;
887}
888
889bool UISession::acquireAmountOfImmutableImages(ulong &cAmount)
890{
891 CMachine comMachine = machine();
892 return UIMediumTools::acquireAmountOfImmutableImages(comMachine, cAmount);
893}
894
895bool UISession::mountBootMedium(const QUuid &uMediumId)
896{
897 AssertReturn(!uMediumId.isNull(), false);
898
899 /* Get recommended controller bus & type: */
900 CVirtualBox comVBox = gpGlobalSession->virtualBox();
901
902 if (!comVBox.isOk())
903 {
904 UINotificationMessage::cannotAcquireVirtualBoxParameter(comVBox);
905 return false;
906 }
907
908 const KStorageBus enmRecommendedDvdBus = gpGlobalSession->guestOSTypeManager().getRecommendedDVDStorageBus(osTypeId());
909 const KStorageControllerType enmRecommendedDvdType = gpGlobalSession->guestOSTypeManager().getRecommendedDVDStorageController(osTypeId());
910
911 /* Search for an attachment of required bus & type: */
912 CMachine comMachine = machine();
913 CMediumAttachmentVector comMediumAttachments = comMachine.GetMediumAttachments();
914 bool fSuccess = comMachine.isOk();
915 if (!fSuccess)
916 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
917 else
918 {
919 CMediumAttachment comChosenAttachment;
920 QString strChosenControllerName;
921 LONG iChosenAttachmentPort = 0;
922 LONG iChosenAttachmentDevice = 0;
923 foreach (const CMediumAttachment &comAttachment, comMediumAttachments)
924 {
925 /* Get attachment type: */
926 const KDeviceType enmCurrentDeviceType = comAttachment.GetType();
927 fSuccess = comAttachment.isOk();
928 if (!fSuccess)
929 {
930 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
931 break;
932 }
933 /* And make sure it's DVD: */
934 if (enmCurrentDeviceType != KDeviceType_DVD)
935 continue;
936
937 /* Get controller name: */
938 const QString strControllerName = comAttachment.GetController();
939 fSuccess = comAttachment.isOk();
940 if (!fSuccess)
941 {
942 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
943 break;
944 }
945 /* And look for corresponding controller: */
946 const CStorageController comCurrentController = comMachine.GetStorageControllerByName(strControllerName);
947 fSuccess = comMachine.isOk();
948 if (!fSuccess)
949 {
950 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
951 break;
952 }
953
954 /* Get current controller bus: */
955 const KStorageBus enmCurrentBus = comCurrentController.GetBus();
956 fSuccess = comCurrentController.isOk();
957 if (!fSuccess)
958 {
959 UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController);
960 break;
961 }
962 /* Get current controller type: */
963 const KStorageControllerType enmCurrentType = comCurrentController.GetControllerType();
964 fSuccess = comCurrentController.isOk();
965 if (!fSuccess)
966 {
967 UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController);
968 break;
969 }
970 /* And check if they are suitable: */
971 if ( enmCurrentBus != enmRecommendedDvdBus
972 || enmCurrentType != enmRecommendedDvdType)
973 continue;
974
975 /* Get current attachment port: */
976 iChosenAttachmentPort = comAttachment.GetPort();
977 fSuccess = comAttachment.isOk();
978 if (!fSuccess)
979 {
980 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
981 break;
982 }
983 /* Get current attachment device: */
984 iChosenAttachmentDevice = comAttachment.GetDevice();
985 fSuccess = comAttachment.isOk();
986 if (!fSuccess)
987 {
988 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
989 break;
990 }
991
992 /* Everything is nice it seems: */
993 comChosenAttachment = comAttachment;
994 strChosenControllerName = strControllerName;
995 break;
996 }
997 AssertMsgReturn(!comChosenAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);
998
999 /* Get medium to mount: */
1000 const UIMedium guiMedium = gpMediumEnumerator->medium(uMediumId);
1001 const CMedium comMedium = guiMedium.medium();
1002
1003 /* Mount medium to the predefined port/device: */
1004 comMachine.MountMedium(strChosenControllerName,
1005 iChosenAttachmentPort, iChosenAttachmentDevice,
1006 comMedium, false /* force */);
1007 fSuccess = comMachine.isOk();
1008 if (!fSuccess)
1009 {
1010 QWidget *pParent = windowManager().realParentWindow(activeMachineWindow());
1011 msgCenter().cannotRemountMedium(machine(), guiMedium, true /* mount? */, false /* retry? */, pParent);
1012 }
1013 else
1014 fSuccess = saveSettings();
1015 }
1016
1017 return fSuccess;
1018}
1019
1020void UISession::prepareStorageMenu(QMenu *pMenu,
1021 QObject *pListener, const char *pszSlotName,
1022 const QString &strControllerName, const StorageSlot &storageSlot)
1023{
1024 CMachine comMachine = machine();
1025 UIMediumTools::prepareStorageMenu(pMenu,
1026 pListener, pszSlotName,
1027 comMachine, strControllerName, storageSlot);
1028}
1029
1030void UISession::updateMachineStorage(const UIMediumTarget &target, UIActionPool *pActionPool)
1031{
1032 CMachine comMachine = machine();
1033 UIMediumTools::updateMachineStorage(comMachine, target, pActionPool);
1034}
1035
1036void UISession::acquireWhetherUSBControllerEnabled(bool &fEnabled)
1037{
1038 fEnabled = false;
1039
1040 /* Check whether USB device filters are available: */
1041 CMachine comMachine = machine();
1042 if (comMachine.isNull())
1043 return;
1044 CUSBDeviceFilters comUSBDeviceFilters = comMachine.GetUSBDeviceFilters();
1045 if (!comMachine.isOk() || comUSBDeviceFilters.isNull())
1046 return;
1047 /* Check whether USB controllers are available: */
1048 CUSBControllerVector comUSBControllers = comMachine.GetUSBControllers();
1049 if (!comMachine.isOk() || comUSBControllers.isEmpty())
1050 return;
1051 /* Check whether USB proxy is available: */
1052 const BOOL fUSBProxyAvailable = comMachine.GetUSBProxyAvailable();
1053 if (!comMachine.isOk() || fUSBProxyAvailable == FALSE)
1054 return;
1055
1056 fEnabled = true;
1057}
1058
1059void UISession::acquireWhetherVideoInputDevicesEnabled(bool &fEnabled)
1060{
1061 fEnabled = false;
1062
1063 /* Check whether video input devices are available: */
1064 CHost comHost = gpGlobalSession->host();
1065 CHostVideoInputDeviceVector comVideoInputDevices = comHost.GetVideoInputDevices();
1066 if (!comHost.isOk() || comVideoInputDevices.isEmpty())
1067 return;
1068 /* Check whether USB controllers are available: */
1069 CMachine comMachine = machine();
1070 if (comMachine.isNull())
1071 return;
1072 CUSBControllerVector comUSBControllers = comMachine.GetUSBControllers();
1073 if (!comMachine.isOk() || comUSBControllers.isEmpty())
1074 return;
1075
1076 fEnabled = true;
1077}
1078
1079bool UISession::usbDevices(QList<USBDeviceInfo> &guiUSBDevices)
1080{
1081 const CHost comHost = gpGlobalSession->host();
1082 const CHostUSBDeviceVector comHostUSBDevices = comHost.GetUSBDevices();
1083 bool fSuccess = comHost.isOk();
1084 if (!fSuccess)
1085 UINotificationMessage::cannotAcquireHostParameter(comHost);
1086 else
1087 {
1088 foreach (const CHostUSBDevice &comHostUSBDevice, comHostUSBDevices)
1089 {
1090 /* Get USB device from current host USB device,
1091 * this stuff requires #include <VBox/com/VirtualBox.h> */
1092 const CUSBDevice comUSBDevice(comHostUSBDevice);
1093
1094 /* Fill structure fields: */
1095 USBDeviceInfo guiUSBDevice;
1096 if (fSuccess)
1097 {
1098 guiUSBDevice.m_uId = comUSBDevice.GetId();
1099 fSuccess = comUSBDevice.isOk();
1100 }
1101 if (fSuccess)
1102 {
1103 /// @todo make sure UIUSBTools::usbDetails is checked for errors as well
1104 guiUSBDevice.m_strName = usbDetails(comUSBDevice);
1105 fSuccess = comUSBDevice.isOk();
1106 }
1107 if (fSuccess)
1108 {
1109 /// @todo make sure UIUSBTools::usbToolTip is checked for errors as well
1110 guiUSBDevice.m_strToolTip = usbToolTip(comUSBDevice);
1111 fSuccess = comUSBDevice.isOk();
1112 }
1113 if (fSuccess)
1114 {
1115 /* Check if that USB device was already attached to this session;
1116 * Nothing to check for errors here because error is valid case as well. */
1117 const CUSBDevice comAttachedDevice = console().FindUSBDeviceById(guiUSBDevice.m_uId);
1118 guiUSBDevice.m_fIsChecked = !comAttachedDevice.isNull();
1119 }
1120 if (fSuccess)
1121 {
1122 guiUSBDevice.m_fIsEnabled = comHostUSBDevice.GetState() != KUSBDeviceState_Unavailable;
1123 fSuccess = comHostUSBDevice.isOk();
1124 }
1125
1126 /* Append or break if necessary: */
1127 if (fSuccess)
1128 guiUSBDevices << guiUSBDevice;
1129 else
1130 break;
1131 }
1132 }
1133 return fSuccess;
1134}
1135
1136bool UISession::attachUSBDevice(const QUuid &uId)
1137{
1138 CConsole comConsole = console();
1139 comConsole.AttachUSBDevice(uId, QString(""));
1140 const bool fSuccess = comConsole.isOk();
1141 if (!fSuccess)
1142 {
1143 CHost comHost = gpGlobalSession->host();
1144 /* Nothing to check for errors here because error is valid case as well. */
1145 CHostUSBDevice comHostUSBDevice = comHost.FindUSBDeviceById(uId);
1146 /* Get USB device from current host USB device,
1147 * this stuff requires #include <VBox/com/VirtualBox.h> */
1148 CUSBDevice comUSBDevice(comHostUSBDevice);
1149 UINotificationMessage::cannotAttachUSBDevice(comConsole, usbDetails(comUSBDevice));
1150 /// @todo make sure UIUSBTools::usbDetails is checked for errors as well
1151 }
1152 return fSuccess;
1153}
1154
1155bool UISession::detachUSBDevice(const QUuid &uId)
1156{
1157 CConsole comConsole = console();
1158 comConsole.DetachUSBDevice(uId);
1159 const bool fSuccess = comConsole.isOk();
1160 if (!fSuccess)
1161 {
1162 CUSBDevice comUSBDevice = CConsole(comConsole).FindUSBDeviceById(uId);
1163 UINotificationMessage::cannotDetachUSBDevice(comConsole, usbDetails(comUSBDevice));
1164 /// @todo make sure UIUSBTools::usbDetails is checked for errors as well
1165 }
1166 return fSuccess;
1167}
1168
1169bool UISession::webcamDevices(QList<WebcamDeviceInfo> &guiWebcamDevices)
1170{
1171 const CHost comHost = gpGlobalSession->host();
1172 const CHostVideoInputDeviceVector comHostVideoInputDevices = comHost.GetVideoInputDevices();
1173 bool fSuccess = comHost.isOk();
1174 if (!fSuccess)
1175 UINotificationMessage::cannotAcquireHostParameter(comHost);
1176 else
1177 {
1178 CConsole comConsole = console();
1179 CEmulatedUSB comEmulatedUSB = comConsole.GetEmulatedUSB();
1180 fSuccess = comConsole.isOk();
1181 if (!fSuccess)
1182 UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
1183 else
1184 {
1185 const QVector<QString> attachedWebcamPaths = comEmulatedUSB.GetWebcams();
1186 fSuccess = comEmulatedUSB.isOk();
1187 if (!fSuccess)
1188 UINotificationMessage::cannotAcquireEmulatedUSBParameter(comEmulatedUSB);
1189 else
1190 {
1191 foreach (const CHostVideoInputDevice &comHostVideoInputDevice, comHostVideoInputDevices)
1192 {
1193 /* Fill structure fields: */
1194 WebcamDeviceInfo guiWebcamDevice;
1195 if (fSuccess)
1196 {
1197 guiWebcamDevice.m_strName = comHostVideoInputDevice.GetName();
1198 fSuccess = comHostVideoInputDevice.isOk();
1199 }
1200 if (fSuccess)
1201 {
1202 guiWebcamDevice.m_strPath = comHostVideoInputDevice.GetPath();
1203 fSuccess = comHostVideoInputDevice.isOk();
1204 }
1205 if (fSuccess)
1206 {
1207 /// @todo make sure UIUSBTools::usbToolTip is checked for errors as well
1208 guiWebcamDevice.m_strToolTip = usbToolTip(comHostVideoInputDevice);
1209 fSuccess = comHostVideoInputDevice.isOk();
1210 }
1211 if (fSuccess)
1212 guiWebcamDevice.m_fIsChecked = attachedWebcamPaths.contains(guiWebcamDevice.m_strPath);
1213
1214 /* Append or break if necessary: */
1215 if (fSuccess)
1216 guiWebcamDevices << guiWebcamDevice;
1217 else
1218 break;
1219 }
1220 }
1221 }
1222 }
1223 return fSuccess;
1224}
1225
1226bool UISession::webcamAttach(const QString &strPath, const QString &strName)
1227{
1228 CConsole comConsole = console();
1229 CEmulatedUSB comDispatcher = comConsole.GetEmulatedUSB();
1230 bool fSuccess = comConsole.isOk();
1231 if (!fSuccess)
1232 UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
1233 else
1234 {
1235 comDispatcher.WebcamAttach(strPath, "");
1236 fSuccess = comDispatcher.isOk();
1237 if (!fSuccess)
1238 UINotificationMessage::cannotAttachWebCam(comDispatcher, strName, machineName());
1239 }
1240 return fSuccess;
1241}
1242
1243bool UISession::webcamDetach(const QString &strPath, const QString &strName)
1244{
1245 CConsole comConsole = console();
1246 CEmulatedUSB comDispatcher = comConsole.GetEmulatedUSB();
1247 bool fSuccess = comConsole.isOk();
1248 if (!fSuccess)
1249 UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
1250 else
1251 {
1252 comDispatcher.WebcamDetach(strPath);
1253 fSuccess = comDispatcher.isOk();
1254 if (!fSuccess)
1255 UINotificationMessage::cannotDetachWebCam(comDispatcher, strName, machineName());
1256 }
1257 return fSuccess;
1258}
1259
1260bool UISession::acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled)
1261{
1262 CMachine comMachine = machine();
1263 CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
1264 bool fSuccess = comMachine.isOk();
1265 if (!fSuccess)
1266 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1267 else
1268 {
1269 const BOOL fAdapterEnabled = comAdapter.GetEnabled();
1270 fSuccess = comAdapter.isOk();
1271 if (!fSuccess)
1272 UINotificationMessage::cannotAcquireNetworkAdapterParameter(comAdapter);
1273 else
1274 fEnabled = fAdapterEnabled == TRUE;
1275 }
1276 return fSuccess;
1277}
1278
1279bool UISession::acquireWhetherAtLeastOneNetworkAdapterEnabled(bool &fEnabled)
1280{
1281 /* Acquire architecture type: */
1282 KPlatformArchitecture enmArchType = KPlatformArchitecture_None;
1283 bool fSuccess = acquireArchitectureType(enmArchType);
1284 {
1285 /* Acquire system properties: */
1286 CVirtualBox comVBox = gpGlobalSession->virtualBox();
1287 AssertReturn(comVBox.isNotNull(), false);
1288 CPlatformProperties comProperties = comVBox.GetPlatformProperties(enmArchType);
1289 fSuccess = comVBox.isOk();
1290 if (!fSuccess)
1291 UINotificationMessage::cannotAcquireVirtualBoxParameter(comVBox);
1292 else
1293 {
1294 /* Acquire chipset type: */
1295 KChipsetType enmChipsetType = KChipsetType_Null;
1296 fSuccess = acquireChipsetType(enmChipsetType);
1297 if (fSuccess)
1298 {
1299 /* Acquire maximum network adapters count: */
1300 const ulong cMaxNetworkAdapters = comProperties.GetMaxNetworkAdapters(enmChipsetType);
1301 fSuccess = comProperties.isOk();
1302 if (!fSuccess)
1303 UINotificationMessage::cannotAcquirePlatformPropertiesParameter(comProperties);
1304 else
1305 {
1306 /* Search for 1st enabled adapter: */
1307 for (ulong uSlot = 0; uSlot < cMaxNetworkAdapters; ++uSlot)
1308 {
1309 bool fAdapterEnabled = false;
1310 fSuccess = acquireWhetherNetworkAdapterEnabled(uSlot, fAdapterEnabled);
1311 if (!fSuccess)
1312 break;
1313 if (!fAdapterEnabled)
1314 continue;
1315 fEnabled = true;
1316 break;
1317 }
1318 }
1319 }
1320 }
1321 }
1322 return fSuccess;
1323}
1324
1325bool UISession::acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected)
1326{
1327 CMachine comMachine = machine();
1328 CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
1329 bool fSuccess = comMachine.isOk();
1330 if (!fSuccess)
1331 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1332 else
1333 {
1334 const BOOL fCableConnected = comAdapter.GetCableConnected();
1335 fSuccess = comAdapter.isOk();
1336 if (!fSuccess)
1337 UINotificationMessage::cannotAcquireNetworkAdapterParameter(comAdapter);
1338 else
1339 fConnected = fCableConnected == TRUE;
1340 }
1341 return fSuccess;
1342}
1343
1344bool UISession::setNetworkCableConnected(ulong uSlot, bool fConnected)
1345{
1346 CMachine comMachine = machine();
1347 CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
1348 bool fSuccess = comMachine.isOk();
1349 if (!fSuccess)
1350 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1351 else
1352 {
1353 comAdapter.SetCableConnected(fConnected);
1354 fSuccess = comAdapter.isOk();
1355 if (!fSuccess)
1356 UINotificationMessage::cannotToggleNetworkCable(comAdapter, machineName(), fConnected);
1357 }
1358 return fSuccess;
1359}
1360
1361bool UISession::guestAdditionsUpgradable()
1362{
1363 if (!machine().isOk())
1364 return false;
1365
1366 /* Auto GA update is currently for Windows and Linux guests only */
1367 bool fIsWindowOrLinux = gpGlobalSession->guestOSTypeManager().isLinux(uimachine()->osTypeId())
1368 || gpGlobalSession->guestOSTypeManager().isWindows(uimachine()->osTypeId());
1369
1370 if (!fIsWindowOrLinux)
1371 return false;
1372
1373 /* Also check whether we have something to update automatically: */
1374 if (m_ulGuestAdditionsRunLevel < (ulong)KAdditionsRunLevelType_Userland)
1375 return false;
1376
1377 return true;
1378}
1379
1380bool UISession::acquireGuestAdditionsVersion(QString &strVersion)
1381{
1382 CGuest comGuest = guest();
1383 const QString strGAVersion = comGuest.GetAdditionsVersion();
1384 const bool fSuccess = comGuest.isOk();
1385 if (!fSuccess)
1386 UINotificationMessage::cannotAcquireGuestParameter(comGuest);
1387 else
1388 strVersion = strGAVersion;
1389 return fSuccess;
1390}
1391
1392bool UISession::acquireGuestAdditionsRevision(ulong &uRevision)
1393{
1394 CGuest comGuest = guest();
1395 const ULONG uGARevision = comGuest.GetAdditionsRevision();
1396 const bool fSuccess = comGuest.isOk();
1397 if (!fSuccess)
1398 UINotificationMessage::cannotAcquireGuestParameter(comGuest);
1399 else
1400 uRevision = uGARevision;
1401 return fSuccess;
1402}
1403
1404bool UISession::notifyGuiFocusChange(bool fInfocus)
1405{
1406 CMachine comMachine = machine();
1407 comMachine.SetGuestProperty(VBOX_GUI_FOCUS_CHANGE_GUEST_PROP_NAME, fInfocus ? "1" : "0", "RDONLYGUEST,TRANSIENT");
1408 return comMachine.isOk();
1409}
1410
1411bool UISession::acquireWhetherAudioAdapterPresent(bool &fPresent)
1412{
1413 CMachine comMachine = machine();
1414 if (comMachine.isNull())
1415 return false;
1416 CAudioSettings comSettings = comMachine.GetAudioSettings();
1417 const bool fSuccess = comMachine.isOk();
1418 if (!fSuccess)
1419 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1420 else
1421 {
1422 CAudioAdapter comAdapter = comSettings.GetAdapter();
1423 fPresent = comSettings.isOk() && comAdapter.isNotNull();
1424 }
1425 return fSuccess;
1426}
1427
1428bool UISession::acquireWhetherAudioAdapterEnabled(bool &fEnabled)
1429{
1430 CMachine comMachine = machine();
1431 CAudioSettings comSettings = comMachine.GetAudioSettings();
1432 bool fSuccess = comMachine.isOk();
1433 if (!fSuccess)
1434 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1435 else
1436 {
1437 CAudioAdapter comAdapter = comSettings.GetAdapter();
1438 fSuccess = comSettings.isOk();
1439 if (!fSuccess)
1440 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
1441 {
1442 const BOOL fAdapterEnabled = comAdapter.GetEnabled();
1443 fSuccess = comAdapter.isOk();
1444 if (!fSuccess)
1445 UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter);
1446 else
1447 fEnabled = fAdapterEnabled == TRUE;
1448 }
1449 }
1450 return fSuccess;
1451}
1452
1453bool UISession::acquireWhetherAudioAdapterOutputEnabled(bool &fEnabled)
1454{
1455 CMachine comMachine = machine();
1456 CAudioSettings comSettings = comMachine.GetAudioSettings();
1457 bool fSuccess = comMachine.isOk();
1458 if (!fSuccess)
1459 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1460 else
1461 {
1462 CAudioAdapter comAdapter = comSettings.GetAdapter();
1463 fSuccess = comSettings.isOk();
1464 if (!fSuccess)
1465 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
1466 {
1467 const BOOL fOutputEnabled = comAdapter.GetEnabledOut();
1468 fSuccess = comAdapter.isOk();
1469 if (!fSuccess)
1470 UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter);
1471 else
1472 fEnabled = fOutputEnabled == TRUE;
1473 }
1474 }
1475 return fSuccess;
1476}
1477
1478bool UISession::acquireWhetherAudioAdapterInputEnabled(bool &fEnabled)
1479{
1480 CMachine comMachine = machine();
1481 CAudioSettings comSettings = comMachine.GetAudioSettings();
1482 bool fSuccess = comMachine.isOk();
1483 if (!fSuccess)
1484 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1485 else
1486 {
1487 CAudioAdapter comAdapter = comSettings.GetAdapter();
1488 fSuccess = comSettings.isOk();
1489 if (!fSuccess)
1490 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
1491 {
1492 const BOOL fInputEnabled = comAdapter.GetEnabledIn();
1493 fSuccess = comAdapter.isOk();
1494 if (!fSuccess)
1495 UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter);
1496 else
1497 fEnabled = fInputEnabled == TRUE;
1498 }
1499 }
1500 return fSuccess;
1501}
1502
1503bool UISession::setAudioAdapterOutputEnabled(bool fEnabled)
1504{
1505 CMachine comMachine = machine();
1506 CAudioSettings comSettings = comMachine.GetAudioSettings();
1507 bool fSuccess = comMachine.isOk();
1508 if (!fSuccess)
1509 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1510 else
1511 {
1512 CAudioAdapter comAdapter = comSettings.GetAdapter();
1513 fSuccess = comSettings.isOk();
1514 if (!fSuccess)
1515 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
1516 {
1517 comAdapter.SetEnabledOut(fEnabled);
1518 fSuccess = comAdapter.isOk();
1519 if (!fSuccess)
1520 UINotificationMessage::cannotToggleAudioOutput(comAdapter, machineName(), fEnabled);
1521 }
1522 }
1523 return fSuccess;
1524}
1525
1526bool UISession::setAudioAdapterInputEnabled(bool fEnabled)
1527{
1528 CMachine comMachine = machine();
1529 CAudioSettings comSettings = comMachine.GetAudioSettings();
1530 bool fSuccess = comMachine.isOk();
1531 if (!fSuccess)
1532 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1533 else
1534 {
1535 CAudioAdapter comAdapter = comSettings.GetAdapter();
1536 fSuccess = comSettings.isOk();
1537 if (!fSuccess)
1538 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
1539 {
1540 comAdapter.SetEnabledIn(fEnabled);
1541 fSuccess = comAdapter.isOk();
1542 if (!fSuccess)
1543 UINotificationMessage::cannotToggleAudioInput(comAdapter, machineName(), fEnabled);
1544 }
1545 }
1546 return fSuccess;
1547}
1548
1549UIFrameBuffer *UISession::frameBuffer(ulong uScreenId) const
1550{
1551 return m_frameBufferVector.value((int)uScreenId, 0);
1552}
1553
1554QSize UISession::frameBufferSize(ulong uScreenId) const
1555{
1556 UIFrameBuffer *pFramebuffer = frameBuffer(uScreenId);
1557 return pFramebuffer ? QSize(pFramebuffer->width(), pFramebuffer->height()) : QSize();
1558}
1559
1560bool UISession::acquireGraphicsControllerType(KGraphicsControllerType &enmType)
1561{
1562 CMachine comMachine = machine();
1563 CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
1564 bool fSuccess = comMachine.isOk();
1565 if (!fSuccess)
1566 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1567 else
1568 {
1569 const KGraphicsControllerType enmControllerType = comAdapter.GetGraphicsControllerType();
1570 fSuccess = comAdapter.isOk();
1571 if (!fSuccess)
1572 UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
1573 else
1574 enmType = enmControllerType;
1575 }
1576 return fSuccess;
1577}
1578
1579bool UISession::acquireVRAMSize(ulong &uSize)
1580{
1581 CMachine comMachine = machine();
1582 CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
1583 bool fSuccess = comMachine.isOk();
1584 if (!fSuccess)
1585 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1586 else
1587 {
1588 const ULONG uVRAMSize = comAdapter.GetVRAMSize();
1589 fSuccess = comAdapter.isOk();
1590 if (!fSuccess)
1591 UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
1592 else
1593 uSize = uVRAMSize;
1594 }
1595 return fSuccess;
1596}
1597
1598bool UISession::acquireWhetherAccelerate3DEnabled(bool &fEnabled)
1599{
1600 CMachine comMachine = machine();
1601 CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
1602 bool fSuccess = comMachine.isOk();
1603 if (!fSuccess)
1604 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1605 else
1606 {
1607 const BOOL fAccelerate3DEnabeld = comAdapter.IsFeatureEnabled(KGraphicsFeature_Acceleration3D);
1608 fSuccess = comAdapter.isOk();
1609 if (!fSuccess)
1610 UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
1611 else
1612 fEnabled = fAccelerate3DEnabeld == TRUE;
1613 }
1614 return fSuccess;
1615}
1616
1617bool UISession::acquireMonitorCount(ulong &uCount)
1618{
1619 // WORKAROUND:
1620 // We certainly don't want to get into
1621 // 'no visible screens' case if something
1622 // gone wrong... Inventing sane default.
1623 uCount = 1;
1624
1625 CMachine comMachine = machine();
1626 if (comMachine.isNull())
1627 return false;
1628 CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
1629 bool fSuccess = comMachine.isOk();
1630 if (!fSuccess)
1631 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1632 else
1633 {
1634 const ULONG uMonitorCount = comAdapter.GetMonitorCount();
1635 fSuccess = comAdapter.isOk();
1636 if (!fSuccess)
1637 UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
1638 else
1639 uCount = uMonitorCount;
1640 }
1641 return fSuccess;
1642}
1643
1644bool UISession::acquireGuestScreenParameters(ulong uScreenId,
1645 ulong &uWidth, ulong &uHeight, ulong &uBitsPerPixel,
1646 long &xOrigin, long &yOrigin, KGuestMonitorStatus &enmMonitorStatus)
1647{
1648 CDisplay comDisplay = display();
1649 ULONG uGuestWidth = 0, uGuestHeight = 0, uGuestBitsPerPixel = 0;
1650 LONG iGuestXOrigin = 0, iGuestYOrigin = 0;
1651 KGuestMonitorStatus enmGuestMonitorStatus = KGuestMonitorStatus_Disabled;
1652 comDisplay.GetScreenResolution(uScreenId, uGuestWidth, uGuestHeight, uGuestBitsPerPixel,
1653 iGuestXOrigin, iGuestYOrigin, enmGuestMonitorStatus);
1654 const bool fSuccess = comDisplay.isOk();
1655 if (!fSuccess)
1656 UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
1657 else
1658 {
1659 uWidth = uGuestWidth;
1660 uHeight = uGuestHeight;
1661 uBitsPerPixel = uGuestBitsPerPixel;
1662 xOrigin = iGuestXOrigin;
1663 yOrigin = iGuestYOrigin;
1664 enmMonitorStatus = enmGuestMonitorStatus;
1665 }
1666 return fSuccess;
1667}
1668
1669bool UISession::acquireSavedGuestScreenInfo(ulong uScreenId,
1670 long &xOrigin, long &yOrigin,
1671 ulong &uWidth, ulong &uHeight, bool &fEnabled)
1672{
1673 CMachine comMachine = machine();
1674 ULONG uGuestXOrigin = 0, uGuestYOrigin = 0, uGuestWidth = 0, uGuestHeight = 0;
1675 BOOL fGuestEnabled = FALSE;
1676 comMachine.QuerySavedGuestScreenInfo(uScreenId, uGuestXOrigin, uGuestYOrigin, uGuestWidth, uGuestHeight, fGuestEnabled);
1677 const bool fSuccess = comMachine.isOk();
1678 if (!fSuccess)
1679 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1680 else
1681 {
1682 xOrigin = uGuestXOrigin;
1683 yOrigin = uGuestYOrigin;
1684 uWidth = uGuestWidth;
1685 uHeight = uGuestHeight;
1686 fEnabled = fGuestEnabled == TRUE;
1687 }
1688 return fSuccess;
1689}
1690
1691bool UISession::setVideoModeHint(ulong uScreenId, bool fEnabled, bool fChangeOrigin, long xOrigin, long yOrigin,
1692 ulong uWidth, ulong uHeight, ulong uBitsPerPixel, bool fNotify)
1693{
1694 CDisplay comDisplay = display();
1695 comDisplay.SetVideoModeHint(uScreenId, fEnabled, fChangeOrigin, xOrigin, yOrigin,
1696 uWidth, uHeight, uBitsPerPixel, fNotify);
1697 const bool fSuccess = comDisplay.isOk();
1698 if (!fSuccess)
1699 UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
1700 return fSuccess;
1701}
1702
1703bool UISession::acquireVideoModeHint(ulong uScreenId, bool &fEnabled, bool &fChangeOrigin,
1704 long &xOrigin, long &yOrigin, ulong &uWidth, ulong &uHeight,
1705 ulong &uBitsPerPixel)
1706{
1707 CDisplay comDisplay = display();
1708 BOOL fGuestEnabled = FALSE, fGuestChangeOrigin = FALSE;
1709 LONG iGuestXOrigin = 0, iGuestYOrigin = 0;
1710 ULONG uGuestWidth = 0, uGuestHeight = 0, uGuestBitsPerPixel = 0;
1711 comDisplay.GetVideoModeHint(uScreenId, fGuestEnabled, fGuestChangeOrigin,
1712 iGuestXOrigin, iGuestYOrigin, uGuestWidth, uGuestHeight,
1713 uGuestBitsPerPixel);
1714 const bool fSuccess = comDisplay.isOk();
1715 if (!fSuccess)
1716 UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
1717 else
1718 {
1719 fEnabled = fGuestEnabled == TRUE;
1720 fChangeOrigin = fGuestChangeOrigin == TRUE;
1721 xOrigin = iGuestXOrigin;
1722 yOrigin = iGuestYOrigin;
1723 uWidth = uGuestWidth;
1724 uHeight = uGuestHeight;
1725 uBitsPerPixel = uGuestBitsPerPixel;
1726 }
1727 return fSuccess;
1728}
1729
1730bool UISession::acquireScreenShot(ulong uScreenId, ulong uWidth, ulong uHeight, KBitmapFormat enmFormat, uchar *pBits)
1731{
1732 CDisplay comDisplay = display();
1733 bool fSuccess = false;
1734 /* For separate process: */
1735 if (uiCommon().isSeparateProcess())
1736 {
1737 /* Take screen-data to array first: */
1738 const QVector<BYTE> screenData = comDisplay.TakeScreenShotToArray(uScreenId, uWidth, uHeight, enmFormat);
1739 fSuccess = comDisplay.isOk();
1740 if (!fSuccess)
1741 UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
1742 else
1743 {
1744 /* And copy that data to screen-shot if it is Ok: */
1745 if (!screenData.isEmpty())
1746 memcpy(pBits, screenData.data(), uWidth * uHeight * 4);
1747 }
1748 }
1749 /* For the same process: */
1750 else
1751 {
1752 /* Take the screen-shot directly: */
1753 comDisplay.TakeScreenShot(uScreenId, pBits, uWidth, uHeight, enmFormat);
1754 fSuccess = comDisplay.isOk();
1755 if (!fSuccess && comDisplay.rc() != VBOX_E_NOT_SUPPORTED) /* VBOX_E_NOT_SUPPORTED: screens size 0x0 can't be snapshotted */
1756 UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
1757 }
1758 return fSuccess;
1759}
1760
1761bool UISession::acquireSavedScreenshotInfo(ulong uScreenId, ulong &uWidth, ulong &uHeight, QVector<KBitmapFormat> &formats)
1762{
1763 CMachine comMachine = machine();
1764 ULONG uGuestWidth = 0, uGuestHeight = 0;
1765 QVector<KBitmapFormat> guestFormats = comMachine.QuerySavedScreenshotInfo(uScreenId, uGuestWidth, uGuestHeight);
1766 const bool fSuccess = comMachine.isOk();
1767 if (!fSuccess)
1768 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1769 else
1770 {
1771 uWidth = uGuestWidth;
1772 uHeight = uGuestHeight;
1773 formats = guestFormats;
1774 }
1775 return fSuccess;
1776}
1777
1778bool UISession::acquireSavedScreenshot(ulong uScreenId, KBitmapFormat enmFormat,
1779 ulong &uWidth, ulong &uHeight, QVector<BYTE> &screenshot)
1780{
1781 CMachine comMachine = machine();
1782 ULONG uGuestWidth = 0, uGuestHeight = 0;
1783 const QVector<BYTE> guestScreenshot = comMachine.ReadSavedScreenshotToArray(uScreenId, enmFormat,
1784 uGuestWidth, uGuestHeight);
1785 const bool fSuccess = comMachine.isOk();
1786 if (!fSuccess)
1787 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1788 else
1789 {
1790 uWidth = uGuestWidth;
1791 uHeight = uGuestHeight;
1792 screenshot = guestScreenshot;
1793 }
1794 return fSuccess;
1795}
1796
1797bool UISession::notifyScaleFactorChange(ulong uScreenId, ulong uScaleFactorWMultiplied, ulong uScaleFactorHMultiplied)
1798{
1799 CDisplay comDisplay = display();
1800 comDisplay.NotifyScaleFactorChange(uScreenId, uScaleFactorWMultiplied, uScaleFactorHMultiplied);
1801 const bool fSuccess = comDisplay.isOk();
1802 if (!fSuccess)
1803 UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
1804 return fSuccess;
1805}
1806
1807bool UISession::notifyHiDPIOutputPolicyChange(bool fUnscaledHiDPI)
1808{
1809 CDisplay comDisplay = display();
1810 comDisplay.NotifyHiDPIOutputPolicyChange(fUnscaledHiDPI);
1811 const bool fSuccess = comDisplay.isOk();
1812 if (!fSuccess)
1813 UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
1814 return fSuccess;
1815}
1816
1817bool UISession::setSeamlessMode(bool fEnabled)
1818{
1819 CDisplay comDisplay = display();
1820 comDisplay.SetSeamlessMode(fEnabled);
1821 const bool fSuccess = comDisplay.isOk();
1822 if (!fSuccess)
1823 UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
1824 return fSuccess;
1825}
1826
1827bool UISession::viewportChanged(ulong uScreenId, ulong xOrigin, ulong yOrigin, ulong uWidth, ulong uHeight)
1828{
1829 CDisplay comDisplay = display();
1830 if (comDisplay.isNull())
1831 return false;
1832 comDisplay.ViewportChanged(uScreenId, xOrigin, yOrigin, uWidth, uHeight);
1833 const bool fSuccess = comDisplay.isOk();
1834 if (!fSuccess)
1835 UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
1836 return fSuccess;
1837}
1838
1839bool UISession::invalidateAndUpdate()
1840{
1841 CDisplay comDisplay = display();
1842 comDisplay.InvalidateAndUpdate();
1843 const bool fSuccess = comDisplay.isOk();
1844 if (!fSuccess)
1845 UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
1846 return fSuccess;
1847}
1848
1849bool UISession::invalidateAndUpdateScreen(ulong uScreenId)
1850{
1851 CDisplay comDisplay = display();
1852 comDisplay.InvalidateAndUpdateScreen(uScreenId);
1853 const bool fSuccess = comDisplay.isOk();
1854 if (!fSuccess)
1855 UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
1856 return fSuccess;
1857}
1858
1859bool UISession::acquireWhetherVRDEServerPresent(bool &fPresent)
1860{
1861 CMachine comMachine = machine();
1862 if (comMachine.isNull())
1863 return false;
1864 CVRDEServer comServer = comMachine.GetVRDEServer();
1865 fPresent = comMachine.isOk() && comServer.isNotNull();
1866 return true;
1867}
1868
1869bool UISession::acquireWhetherVRDEServerEnabled(bool &fEnabled)
1870{
1871 CMachine comMachine = machine();
1872 CVRDEServer comServer = comMachine.GetVRDEServer();
1873 bool fSuccess = comMachine.isOk();
1874 if (!fSuccess)
1875 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1876 else
1877 {
1878 const BOOL fServerEnabled = comServer.GetEnabled();
1879 fSuccess = comServer.isOk();
1880 if (!fSuccess)
1881 UINotificationMessage::cannotAcquireVRDEServerParameter(comServer);
1882 else
1883 fEnabled = fServerEnabled == TRUE;
1884 }
1885 return fSuccess;
1886}
1887
1888bool UISession::setVRDEServerEnabled(bool fEnabled)
1889{
1890 CMachine comMachine = machine();
1891 CVRDEServer comServer = comMachine.GetVRDEServer();
1892 bool fSuccess = comMachine.isOk();
1893 if (!fSuccess)
1894 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1895 else
1896 {
1897 comServer.SetEnabled(fEnabled);
1898 fSuccess = comServer.isOk();
1899 if (!fSuccess)
1900 UINotificationMessage::cannotToggleVRDEServer(comServer, machineName(), fEnabled);
1901 }
1902 return fSuccess;
1903}
1904
1905bool UISession::acquireVRDEServerPort(long &iPort)
1906{
1907 CConsole comConsole = console();
1908 const CVRDEServerInfo comVRDEServerInfo = comConsole.GetVRDEServerInfo();
1909 bool fSuccess = comConsole.isOk();
1910 if (!fSuccess)
1911 UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
1912 else
1913 {
1914 const LONG iVRDEPort = comVRDEServerInfo.GetPort();
1915 fSuccess = comVRDEServerInfo.isOk();
1916 if (!fSuccess)
1917 UINotificationMessage::cannotAcquireVRDEServerInfoParameter(comVRDEServerInfo);
1918 else
1919 iPort = iVRDEPort;
1920 }
1921 return fSuccess;
1922}
1923
1924bool UISession::acquireWhetherRecordingSettingsPresent(bool &fPresent)
1925{
1926 CMachine comMachine = machine();
1927 CRecordingSettings comSettings = comMachine.GetRecordingSettings();
1928 fPresent = comMachine.isOk() && comSettings.isNotNull();
1929 return true;
1930}
1931
1932bool UISession::acquireWhetherRecordingSettingsEnabled(bool &fEnabled)
1933{
1934 CMachine comMachine = machine();
1935 CRecordingSettings comSettings = comMachine.GetRecordingSettings();
1936 bool fSuccess = comMachine.isOk();
1937 if (!fSuccess)
1938 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1939 else
1940 {
1941 /** @todo r=andy Revamp this. */
1942 CProgress comProgress = comSettings.GetProgress();
1943 fEnabled = comProgress.isOk() && !comProgress.GetCompleted() && !comProgress.GetCanceled();
1944 }
1945 return fSuccess;
1946}
1947
1948bool UISession::setRecordingSettingsEnabled(bool fEnabled)
1949{
1950 CMachine comMachine = machine();
1951 CRecordingSettings comSettings = comMachine.GetRecordingSettings();
1952 bool fSuccess = comMachine.isOk();
1953 if (!fSuccess)
1954 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
1955 else
1956 {
1957 /** @todo r=andy Revamp this function to better use the progress object.
1958 * Probably also needs a bit of refactoring of the overall handling within FE/Qt. */
1959 CProgress comProgress;
1960 if (fEnabled)
1961 {
1962 comProgress = comSettings.Start();
1963 fSuccess = comSettings.isOk();
1964 if (!fSuccess)
1965 UINotificationMessage::cannotToggleRecording(comSettings, machineName(), fEnabled);
1966 }
1967 else
1968 {
1969 comProgress = comSettings.GetProgress();
1970 if (comProgress.isOk())
1971 comProgress.Cancel();
1972 else
1973 UINotificationMessage::cannotToggleRecording(comSettings, machineName(), fEnabled);
1974 }
1975
1976 }
1977 return fSuccess;
1978}
1979
1980bool UISession::acquireDeviceActivity(const QVector<KDeviceType> &deviceTypes, QVector<KDeviceActivity> &states)
1981{
1982 CConsole comConsole = console();
1983 const QVector<KDeviceActivity> currentStates = comConsole.GetDeviceActivity(deviceTypes);
1984 const bool fSuccess = comConsole.isOk();
1985 if (!fSuccess)
1986 UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
1987 else
1988 states = currentStates;
1989 return fSuccess;
1990}
1991
1992void UISession::acquireHardDiskStatusInfo(QString &strInfo, uint &cAttachmentsCount)
1993{
1994 CMachine comMachine = machine();
1995 if (comMachine.isNull())
1996 return;
1997 UIDetailsGenerator::acquireHardDiskStatusInfo(comMachine, strInfo, cAttachmentsCount);
1998}
1999
2000void UISession::acquireOpticalDiskStatusInfo(QString &strInfo, uint &cAttachmentsCount, uint &cAttachmentsMountedCount)
2001{
2002 CMachine comMachine = machine();
2003 if (comMachine.isNull())
2004 return;
2005 UIDetailsGenerator::acquireOpticalDiskStatusInfo(comMachine, strInfo, cAttachmentsCount, cAttachmentsMountedCount);
2006}
2007
2008void UISession::acquireFloppyDiskStatusInfo(QString &strInfo, uint &cAttachmentsCount, uint &cAttachmentsMountedCount)
2009{
2010 CMachine comMachine = machine();
2011 if (comMachine.isNull())
2012 return;
2013 UIDetailsGenerator::acquireFloppyDiskStatusInfo(comMachine, strInfo, cAttachmentsCount, cAttachmentsMountedCount);
2014}
2015
2016void UISession::acquireAudioStatusInfo(QString &strInfo, bool &fAudioEnabled, bool &fEnabledOutput, bool &fEnabledInput)
2017{
2018 CMachine comMachine = machine();
2019 if (comMachine.isNull())
2020 return;
2021 UIDetailsGenerator::acquireAudioStatusInfo(comMachine, strInfo, fAudioEnabled, fEnabledOutput, fEnabledInput);
2022}
2023
2024void UISession::acquireNetworkStatusInfo(QString &strInfo, bool &fAdaptersPresent, bool &fCablesDisconnected)
2025{
2026 CMachine comMachine = machine();
2027 if (comMachine.isNull())
2028 return;
2029 UIDetailsGenerator::acquireNetworkStatusInfo(comMachine, strInfo, fAdaptersPresent, fCablesDisconnected);
2030}
2031
2032void UISession::acquireUsbStatusInfo(QString &strInfo, bool &fUsbEnabled, uint &cUsbFilterCount)
2033{
2034 CMachine comMachine = machine();
2035 if (comMachine.isNull())
2036 return;
2037 CConsole comConsole = console();
2038 if (comConsole.isNull())
2039 return;
2040 UIDetailsGenerator::acquireUsbStatusInfo(comMachine, comConsole, strInfo, fUsbEnabled, cUsbFilterCount);
2041}
2042
2043void UISession::acquireSharedFoldersStatusInfo(QString &strInfo, uint &cFoldersCount)
2044{
2045 CMachine comMachine = machine();
2046 if (comMachine.isNull())
2047 return;
2048 CConsole comConsole = console();
2049 if (comConsole.isNull())
2050 return;
2051 CGuest comGuest = guest();
2052 if (comGuest.isNull())
2053 return;
2054 UIDetailsGenerator::acquireSharedFoldersStatusInfo(comMachine, comConsole, comGuest, strInfo, cFoldersCount);
2055}
2056
2057void UISession::acquireDisplayStatusInfo(QString &strInfo, uint &uVRAMSize, uint &cMonitorCount, bool &fAcceleration3D)
2058{
2059 CMachine comMachine = machine();
2060 if (comMachine.isNull())
2061 return;
2062 UIDetailsGenerator::acquireDisplayStatusInfo(comMachine, strInfo, uVRAMSize, cMonitorCount, fAcceleration3D);
2063}
2064
2065void UISession::acquireRecordingStatusInfo(QString &strInfo, bool &fRecordingEnabled, bool &fMachinePaused)
2066{
2067 CMachine comMachine = machine();
2068 if (comMachine.isNull())
2069 return;
2070 fMachinePaused = isPaused();
2071 UIDetailsGenerator::acquireRecordingStatusInfo(comMachine, strInfo, fRecordingEnabled);
2072}
2073
2074void UISession::acquireFeaturesStatusInfo(QString &strInfo, KVMExecutionEngine &enmEngine,
2075 bool fNestedPagingEnabled, bool fUxEnabled,
2076 KParavirtProvider enmProvider)
2077{
2078 CMachine comMachine = machine();
2079 if (comMachine.isNull())
2080 return;
2081 UIDetailsGenerator::acquireFeaturesStatusInfo(comMachine, strInfo,
2082 enmEngine,
2083 fNestedPagingEnabled, fUxEnabled,
2084 enmProvider);
2085}
2086
2087void UISession::generateMachineInformationGeneral(const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &fOptions,
2088 UITextTable &returnTable)
2089{
2090 CMachine comMachine = machine();
2091 returnTable = UIDetailsGenerator::generateMachineInformationGeneral(comMachine, fOptions);
2092}
2093
2094void UISession::generateMachineInformationSystem(const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem &fOptions,
2095 UITextTable &returnTable)
2096{
2097 CMachine comMachine = machine();
2098 returnTable = UIDetailsGenerator::generateMachineInformationSystem(comMachine, fOptions);
2099}
2100
2101void UISession::generateMachineInformationDisplay(const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay &fOptions,
2102 UITextTable &returnTable)
2103{
2104 CMachine comMachine = machine();
2105 returnTable = UIDetailsGenerator::generateMachineInformationDisplay(comMachine, fOptions);
2106}
2107
2108void UISession::generateMachineInformationStorage(const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage &fOptions,
2109 UITextTable &returnTable)
2110{
2111 CMachine comMachine = machine();
2112 returnTable = UIDetailsGenerator::generateMachineInformationStorage(comMachine, fOptions);
2113}
2114
2115void UISession::generateMachineInformationAudio(const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio &fOptions,
2116 UITextTable &returnTable)
2117{
2118 CMachine comMachine = machine();
2119 returnTable = UIDetailsGenerator::generateMachineInformationAudio(comMachine, fOptions);
2120}
2121
2122void UISession::generateMachineInformationNetwork(const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork &fOptions,
2123 UITextTable &returnTable)
2124{
2125 CMachine comMachine = machine();
2126 returnTable = UIDetailsGenerator::generateMachineInformationNetwork(comMachine, fOptions);
2127}
2128void UISession::generateMachineInformationSerial(const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial &fOptions,
2129 UITextTable &returnTable)
2130{
2131 CMachine comMachine = machine();
2132 returnTable = UIDetailsGenerator::generateMachineInformationSerial(comMachine, fOptions);
2133}
2134
2135void UISession::generateMachineInformationUSB(const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb &fOptions,
2136 UITextTable &returnTable)
2137{
2138 CMachine comMachine = machine();
2139 returnTable = UIDetailsGenerator::generateMachineInformationUSB(comMachine, fOptions);
2140}
2141
2142void UISession::generateMachineInformationSharedFolders(const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders &fOptions,
2143 UITextTable &returnTable)
2144{
2145 CMachine comMachine = machine();
2146 returnTable = UIDetailsGenerator::generateMachineInformationSharedFolders(comMachine, fOptions);
2147}
2148
2149bool UISession::setLogEnabled(bool fEnabled)
2150{
2151 CMachineDebugger comDebugger = debugger();
2152 comDebugger.SetLogEnabled(fEnabled ? TRUE : FALSE);
2153 const bool fSuccess = comDebugger.isOk();
2154 if (!fSuccess)
2155 UINotificationMessage::cannotChangeMachineDebuggerParameter(comDebugger);
2156 return fSuccess;
2157}
2158
2159bool UISession::acquireWhetherLogEnabled(bool &fEnabled)
2160{
2161 CMachineDebugger comDebugger = debugger();
2162 if (comDebugger.isNull())
2163 return false;
2164 const BOOL fLogEnabled = comDebugger.GetLogEnabled();
2165 const bool fSuccess = comDebugger.isOk();
2166 if (!fSuccess)
2167 UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
2168 else
2169 fEnabled = fLogEnabled == TRUE;
2170 return fSuccess;
2171}
2172
2173bool UISession::acquireLogFolder(QString &strFolder)
2174{
2175 CMachine comMachine = machine();
2176 const QString strLogFolder = comMachine.GetLogFolder();
2177 const bool fSuccess = comMachine.isOk();
2178 if (!fSuccess)
2179 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
2180 else
2181 strFolder = strLogFolder;
2182 return fSuccess;
2183}
2184
2185bool UISession::acquireEffectiveParavirtProvider(KParavirtProvider &enmProvider)
2186{
2187 CMachine comMachine = machine();
2188 if (comMachine.isNull())
2189 return false;
2190 const KParavirtProvider enmParavirtProvider = comMachine.GetEffectiveParavirtProvider();
2191 const bool fSuccess = comMachine.isOk();
2192 if (!fSuccess)
2193 UINotificationMessage::cannotAcquireMachineParameter(comMachine);
2194 else
2195 enmProvider = enmParavirtProvider;
2196 return fSuccess;
2197}
2198
2199bool UISession::acquireExecutionEngineType(KVMExecutionEngine &enmType)
2200{
2201 CMachineDebugger comDebugger = debugger();
2202 if (comDebugger.isNull())
2203 return false;
2204 const KVMExecutionEngine enmEngineType = comDebugger.GetExecutionEngine();
2205 const bool fSuccess = comDebugger.isOk();
2206 if (!fSuccess)
2207 UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
2208 else
2209 enmType = enmEngineType;
2210 return fSuccess;
2211}
2212
2213bool UISession::acquireWhetherHwVirtExNestedPagingEnabled(bool &fEnabled)
2214{
2215 CMachineDebugger comDebugger = debugger();
2216 if (comDebugger.isNull())
2217 return false;
2218 const BOOL fFeatureEnabled = comDebugger.GetHWVirtExNestedPagingEnabled();
2219 const bool fSuccess = comDebugger.isOk();
2220 if (!fSuccess)
2221 UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
2222 else
2223 fEnabled = fFeatureEnabled == TRUE;
2224 return fSuccess;
2225}
2226
2227bool UISession::acquireWhetherHwVirtExUXEnabled(bool &fEnabled)
2228{
2229 CMachineDebugger comDebugger = debugger();
2230 if (comDebugger.isNull())
2231 return false;
2232 const BOOL fFeatureEnabled = comDebugger.GetHWVirtExUXEnabled();
2233 const bool fSuccess = comDebugger.isOk();
2234 if (!fSuccess)
2235 UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
2236 else
2237 fEnabled = fFeatureEnabled == TRUE;
2238 return fSuccess;
2239}
2240
2241bool UISession::acquireEffectiveCPULoad(ulong &uLoad)
2242{
2243 CMachineDebugger comDebugger = debugger();
2244 ULONG uPctExecuting;
2245 ULONG uPctHalted;
2246 ULONG uPctOther;
2247 comDebugger.GetCPULoad(0x7fffffff, uPctExecuting, uPctHalted, uPctOther);
2248 const bool fSuccess = comDebugger.isOk();
2249 if (!fSuccess)
2250 UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
2251 else
2252 uLoad = uPctExecuting + uPctOther;
2253 return fSuccess;
2254}
2255
2256bool UISession::acquireUptime(LONG64 &iUpTime)
2257{
2258 CMachineDebugger comDebugger = debugger();
2259 const LONG64 iGuestUpTime = comDebugger.GetUptime();
2260 const bool fSuccess = comDebugger.isOk();
2261 if (!fSuccess)
2262 UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
2263 else
2264 iUpTime = iGuestUpTime;
2265 return fSuccess;
2266}
2267
2268#ifdef VBOX_WITH_DEBUGGER_GUI
2269bool UISession::dbgCreated(void *pActionDebug)
2270{
2271 if (m_pDbgGui)
2272 return true;
2273
2274 RTLDRMOD hLdrMod = uiCommon().getDebuggerModule();
2275 if (hLdrMod == NIL_RTLDRMOD)
2276 return false;
2277
2278 PFNDBGGUICREATE pfnGuiCreate;
2279 int rc = RTLdrGetSymbol(hLdrMod, "DBGGuiCreate", (void**)&pfnGuiCreate);
2280 if (RT_SUCCESS(rc))
2281 {
2282 ISession *pISession = session().raw();
2283 rc = pfnGuiCreate(pISession, &m_pDbgGui, &m_pDbgGuiVT);
2284 if (RT_SUCCESS(rc))
2285 {
2286 if ( DBGGUIVT_ARE_VERSIONS_COMPATIBLE(m_pDbgGuiVT->u32Version, DBGGUIVT_VERSION)
2287 || m_pDbgGuiVT->u32EndVersion == m_pDbgGuiVT->u32Version)
2288 {
2289 m_pDbgGuiVT->pfnSetParent(m_pDbgGui, activeMachineWindow());
2290 m_pDbgGuiVT->pfnSetMenu(m_pDbgGui, pActionDebug);
2291 dbgAdjustRelativePos();
2292 return true;
2293 }
2294
2295 LogRel(("GUI: DBGGuiCreate failed, incompatible versions (loaded %#x/%#x, expected %#x)\n",
2296 m_pDbgGuiVT->u32Version, m_pDbgGuiVT->u32EndVersion, DBGGUIVT_VERSION));
2297 }
2298 else
2299 LogRel(("GUI: DBGGuiCreate failed, rc=%Rrc\n", rc));
2300 }
2301 else
2302 LogRel(("GUI: RTLdrGetSymbol(,\"DBGGuiCreate\",) -> %Rrc\n", rc));
2303
2304 m_pDbgGui = 0;
2305 m_pDbgGuiVT = 0;
2306 return false;
2307}
2308
2309void UISession::dbgDestroy()
2310{
2311 if (m_pDbgGui)
2312 {
2313 m_pDbgGuiVT->pfnDestroy(m_pDbgGui);
2314 m_pDbgGui = 0;
2315 m_pDbgGuiVT = 0;
2316 }
2317}
2318
2319void UISession::dbgShowStatistics()
2320{
2321 const QByteArray &filterBytes = uiCommon().getDebuggerStatisticsFilter().toUtf8();
2322 const QByteArray &expandBytes = uiCommon().getDebuggerStatisticsExpand().toUtf8();
2323 const QByteArray &configBytes = uiCommon().getDebuggerStatisticsConfig().toUtf8();
2324 m_pDbgGuiVT->pfnShowStatistics(m_pDbgGui, filterBytes.constData(), expandBytes.constData(), configBytes.constData());
2325}
2326
2327void UISession::dbgShowCommandLine()
2328{
2329 m_pDbgGuiVT->pfnShowCommandLine(m_pDbgGui);
2330}
2331
2332void UISession::dbgAdjustRelativePos()
2333{
2334 if (m_pDbgGui)
2335 {
2336 const QRect rct = activeMachineWindow()->frameGeometry();
2337 m_pDbgGuiVT->pfnAdjustRelativePos(m_pDbgGui, rct.x(), rct.y(), rct.width(), rct.height());
2338 }
2339}
2340#endif /* VBOX_WITH_DEBUGGER_GUI */
2341
2342bool UISession::acquireWhetherGuestEnteredACPIMode(bool &fEntered)
2343{
2344 CConsole comConsole = console();
2345 const BOOL fGuestEntered = comConsole.GetGuestEnteredACPIMode();
2346 const bool fSuccess = comConsole.isOk();
2347 if (!fSuccess)
2348 UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
2349 else
2350 fEntered = fGuestEntered == TRUE;
2351 return fSuccess;
2352}
2353
2354void UISession::saveState()
2355{
2356 if ( isPaused()
2357 || (isRunning() && pause()))
2358 {
2359 /* Enable 'manual-override',
2360 * preventing automatic Runtime UI closing: */
2361 uimachine()->setManualOverrideMode(true);
2362
2363 /* Now, do the magic: */
2364 LogRel(("GUI: Saving VM state..\n"));
2365 UINotificationProgressMachineSaveState *pNotification =
2366 new UINotificationProgressMachineSaveState(machine());
2367 connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved,
2368 this, &UISession::sltHandleMachineStateSaved);
2369 gpNotificationCenter->append(pNotification);
2370 }
2371}
2372
2373void UISession::shutdown()
2374{
2375 /* Check whether guest is in proper mode: */
2376 bool fValidMode = false;
2377 acquireWhetherGuestEnteredACPIMode(fValidMode);
2378 if (!fValidMode)
2379 UINotificationMessage::cannotSendACPIToMachine();
2380 else
2381 {
2382 /* Now, do the magic: */
2383 LogRel(("GUI: Sending ACPI shutdown signal..\n"));
2384 CConsole comConsole = console();
2385 comConsole.PowerButton();
2386 if (!comConsole.isOk())
2387 UINotificationMessage::cannotACPIShutdownMachine(comConsole);
2388 }
2389}
2390
2391void UISession::powerOff(bool fIncludingDiscard)
2392{
2393 /* Enable 'manual-override',
2394 * preventing automatic Runtime UI closing: */
2395 uimachine()->setManualOverrideMode(true);
2396
2397 /* Now, do the magic: */
2398 LogRel(("GUI: Powering VM off..\n"));
2399 UINotificationProgressMachinePowerOff *pNotification =
2400 new UINotificationProgressMachinePowerOff(machine(),
2401 console(),
2402 fIncludingDiscard);
2403 connect(pNotification, &UINotificationProgressMachinePowerOff::sigMachinePoweredOff,
2404 this, &UISession::sltHandleMachinePoweredOff);
2405 gpNotificationCenter->append(pNotification);
2406}
2407
2408void UISession::sltInstallGuestAdditionsFrom(const QString &strSource)
2409{
2410 if (!guestAdditionsUpgradable())
2411 return sltMountDVDAdHoc(strSource);
2412
2413 /* Update guest additions automatically: */
2414 UINotificationProgressGuestAdditionsInstall *pNotification =
2415 new UINotificationProgressGuestAdditionsInstall(guest(), strSource);
2416 connect(pNotification, &UINotificationProgressGuestAdditionsInstall::sigGuestAdditionsInstallationFailed,
2417 this, &UISession::sltMountDVDAdHoc);
2418 gpNotificationCenter->append(pNotification);
2419}
2420
2421void UISession::sltMountDVDAdHoc(const QString &strSource)
2422{
2423 mountAdHocImage(KDeviceType_DVD, UIMediumDeviceType_DVD, strSource);
2424}
2425
2426void UISession::sltDetachCOM()
2427{
2428 /* Cleanup everything COM related: */
2429 cleanupFramebuffers();
2430 cleanupConsoleEventHandlers();
2431 cleanupCOMStuff();
2432}
2433
2434void UISession::sltStateChange(KMachineState enmState)
2435{
2436 /* Check if something had changed: */
2437 if (m_enmMachineState != enmState)
2438 {
2439 /* Store new data: */
2440 m_enmMachineStatePrevious = m_enmMachineState;
2441 m_enmMachineState = enmState;
2442
2443 /* Notify listeners about machine state changed: */
2444 emit sigMachineStateChange();
2445 }
2446}
2447
2448void UISession::sltAdditionsChange()
2449{
2450 /* Acquire actual states: */
2451 const ulong ulGuestAdditionsRunLevel = guest().GetAdditionsRunLevel();
2452 LONG64 iLastUpdatedIgnored;
2453 const bool fIsGuestSupportsGraphics = guest().GetFacilityStatus(KAdditionsFacilityType_Graphics, iLastUpdatedIgnored)
2454 == KAdditionsFacilityStatus_Active;
2455 const bool fIsGuestSupportsSeamless = guest().GetFacilityStatus(KAdditionsFacilityType_Seamless, iLastUpdatedIgnored)
2456 == KAdditionsFacilityStatus_Active;
2457
2458 /* Check if something had changed: */
2459 if ( m_ulGuestAdditionsRunLevel != ulGuestAdditionsRunLevel
2460 || m_fIsGuestSupportsGraphics != fIsGuestSupportsGraphics
2461 || m_fIsGuestSupportsSeamless != fIsGuestSupportsSeamless)
2462 {
2463 /* Store new data: */
2464 m_ulGuestAdditionsRunLevel = ulGuestAdditionsRunLevel;
2465 m_fIsGuestSupportsGraphics = fIsGuestSupportsGraphics;
2466 m_fIsGuestSupportsSeamless = fIsGuestSupportsSeamless;
2467
2468 /* Notify listeners about GA state really changed: */
2469 LogRel(("GUI: UISession::sltAdditionsChange: GA state really changed, notifying listeners.\n"));
2470 emit sigAdditionsStateActualChange();
2471 }
2472 else
2473 LogRel(("GUI: UISession::sltAdditionsChange: GA state doesn't really changed, still notifying listeners.\n"));
2474
2475 /* Notify listeners about GA state change event came: */
2476 emit sigAdditionsStateChange();
2477}
2478
2479void UISession::sltClipboardError(const QString &strMsg)
2480{
2481 UINotificationMessage::warnAboutClipboardError(strMsg);
2482}
2483
2484void UISession::sltHandleMachineStateSaved(bool fSuccess)
2485{
2486 /* Let user try again if saving failed: */
2487 if (!fSuccess)
2488 {
2489 /* Disable 'manual-override' finally: */
2490 uimachine()->setManualOverrideMode(false);
2491 }
2492 /* Close Runtime UI otherwise: */
2493 else
2494 uimachine()->closeRuntimeUI();
2495}
2496
2497void UISession::sltHandleMachinePoweredOff(bool fSuccess, bool fIncludingDiscard)
2498{
2499 /* Let user try again if power off failed: */
2500 if (!fSuccess)
2501 {
2502 /* Disable 'manual-override' finally: */
2503 uimachine()->setManualOverrideMode(false);
2504 }
2505 /* Check for other tasks otherwise: */
2506 else
2507 {
2508 if (fIncludingDiscard)
2509 {
2510 /* Now, do more magic! */
2511 UINotificationProgressSnapshotRestore *pNotification =
2512 new UINotificationProgressSnapshotRestore(uiCommon().managedVMUuid());
2513 connect(pNotification, &UINotificationProgressSnapshotRestore::sigSnapshotRestored,
2514 this, &UISession::sltHandleSnapshotRestored);
2515 gpNotificationCenter->append(pNotification);
2516 }
2517 else
2518 uimachine()->closeRuntimeUI();
2519 }
2520}
2521
2522void UISession::sltHandleSnapshotRestored(bool)
2523{
2524 /* Close Runtime UI independent of snapshot restoring state: */
2525 uimachine()->closeRuntimeUI();
2526}
2527
2528bool UISession::prepareCOMStuff()
2529{
2530 /* Open session: */
2531 m_comSession = openSession(uiCommon().managedVMUuid(),
2532 uiCommon().isSeparateProcess()
2533 ? KLockType_Shared
2534 : KLockType_VM);
2535 if (m_comSession.isNull())
2536 return false;
2537
2538 /* Get machine: */
2539 m_comMachine = m_comSession.GetMachine();
2540 if (m_comMachine.isNull())
2541 return false;
2542
2543 /* Get console: */
2544 m_comConsole = m_comSession.GetConsole();
2545 if (m_comConsole.isNull())
2546 return false;
2547
2548 /* Get display: */
2549 m_comDisplay = m_comConsole.GetDisplay();
2550 if (m_comDisplay.isNull())
2551 return false;
2552
2553 /* Get guest: */
2554 m_comGuest = m_comConsole.GetGuest();
2555 if (m_comGuest.isNull())
2556 return false;
2557
2558 /* Get mouse: */
2559 m_comMouse = m_comConsole.GetMouse();
2560 if (m_comMouse.isNull())
2561 return false;
2562
2563 /* Get keyboard: */
2564 m_comKeyboard = m_comConsole.GetKeyboard();
2565 if (m_comKeyboard.isNull())
2566 return false;
2567
2568 /* Get debugger: */
2569 m_comDebugger = m_comConsole.GetDebugger();
2570 if (m_comDebugger.isNull())
2571 return false;
2572
2573 /* Update machine attributes: */
2574 m_strMachineName = machine().GetName();
2575 m_strOSTypeId = machine().GetOSTypeId();
2576
2577 /* Update machine-state: */
2578 m_enmMachineState = machine().GetState();
2579
2580 /* True by default: */
2581 return true;
2582}
2583
2584void UISession::prepareConsoleEventHandlers()
2585{
2586 /* Create console event-handler: */
2587 m_pConsoleEventhandler = new UIConsoleEventHandler(this);
2588
2589 /* Console event connections: */
2590 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigAdditionsChange,
2591 this, &UISession::sltAdditionsChange);
2592 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigAudioAdapterChange,
2593 this, &UISession::sigAudioAdapterChange);
2594 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigClipboardModeChange,
2595 this, &UISession::sigClipboardModeChange);
2596 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigClipboardError,
2597 this, &UISession::sltClipboardError);
2598 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigCPUExecutionCapChange,
2599 this, &UISession::sigCPUExecutionCapChange);
2600 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigDnDModeChange,
2601 this, &UISession::sigDnDModeChange);
2602 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigGuestMonitorChange,
2603 this, &UISession::sigGuestMonitorChange);
2604 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMediumChange,
2605 this, &UISession::sigMediumChange);
2606 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigNetworkAdapterChange,
2607 this, &UISession::sigNetworkAdapterChange);
2608 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigRecordingChange,
2609 this, &UISession::sigRecordingChange);
2610 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigSharedFolderChange,
2611 this, &UISession::sigSharedFolderChange);
2612 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigStateChange,
2613 this, &UISession::sltStateChange);
2614 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigStorageDeviceChange,
2615 this, &UISession::sigStorageDeviceChange);
2616 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigUSBControllerChange,
2617 this, &UISession::sigUSBControllerChange);
2618 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigUSBDeviceStateChange,
2619 this, &UISession::sigUSBDeviceStateChange);
2620 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigVRDEChange,
2621 this, &UISession::sigVRDEChange);
2622 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigRuntimeError,
2623 this, &UISession::sigRuntimeError);
2624
2625#ifdef VBOX_WS_MAC
2626 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigShowWindow,
2627 this, &UISession::sigShowWindows, Qt::QueuedConnection);
2628#endif
2629
2630 /* Console keyboard connections: */
2631 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigKeyboardLedsChange,
2632 this, &UISession::sigKeyboardLedsChange);
2633
2634 /* Console mouse connections: */
2635 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMousePointerShapeChange,
2636 this, &UISession::sigMousePointerShapeChange);
2637 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMouseCapabilityChange,
2638 this, &UISession::sigMouseCapabilityChange);
2639 connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigCursorPositionChange,
2640 this, &UISession::sigCursorPositionChange);
2641}
2642
2643void UISession::prepareFramebuffers()
2644{
2645 /* Acquire guest-screen count: */
2646 ulong cGuestScreenCount = 0;
2647 acquireMonitorCount(cGuestScreenCount);
2648 m_frameBufferVector.resize(cGuestScreenCount);
2649
2650 /* Create new frame-buffers: */
2651 for (int iIndex = 0; iIndex < m_frameBufferVector.size(); ++iIndex)
2652 m_frameBufferVector[iIndex] = new UIFrameBuffer;
2653}
2654
2655void UISession::prepareConnections()
2656{
2657 /* UICommon connections: */
2658 connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UISession::sltDetachCOM);
2659}
2660
2661void UISession::prepareSignalHandling()
2662{
2663#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
2664 struct sigaction sa;
2665 sa.sa_sigaction = &signalHandlerSIGUSR1;
2666 sigemptyset(&sa.sa_mask);
2667 sa.sa_flags = SA_RESTART | SA_SIGINFO;
2668 sigaction(SIGUSR1, &sa, NULL);
2669#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
2670}
2671
2672void UISession::cleanupFramebuffers()
2673{
2674 /* Cleanup framebuffers finally: */
2675 for (int i = m_frameBufferVector.size() - 1; i >= 0; --i)
2676 {
2677 UIFrameBuffer *pFrameBuffer = m_frameBufferVector[i];
2678 if (pFrameBuffer)
2679 {
2680 /* Mark framebuffer as unused: */
2681 pFrameBuffer->setMarkAsUnused(true);
2682 /* Detach framebuffer from Display: */
2683 pFrameBuffer->detach();
2684 /* Delete framebuffer reference: */
2685 delete pFrameBuffer;
2686 }
2687 }
2688 m_frameBufferVector.clear();
2689}
2690
2691void UISession::cleanupConsoleEventHandlers()
2692{
2693 /* Destroy console event-handler: */
2694 delete m_pConsoleEventhandler;
2695 m_pConsoleEventhandler = 0;
2696}
2697
2698void UISession::cleanupCOMStuff()
2699{
2700 /* Detach debugger: */
2701 if (!m_comDebugger.isNull())
2702 m_comDebugger.detach();
2703
2704 /* Detach keyboard: */
2705 if (!m_comKeyboard.isNull())
2706 m_comKeyboard.detach();
2707
2708 /* Detach mouse: */
2709 if (!m_comMouse.isNull())
2710 m_comMouse.detach();
2711
2712 /* Detach guest: */
2713 if (!m_comGuest.isNull())
2714 m_comGuest.detach();
2715
2716 /* Detach display: */
2717 if (!m_comDisplay.isNull())
2718 m_comDisplay.detach();
2719
2720 /* Detach console: */
2721 if (!m_comConsole.isNull())
2722 m_comConsole.detach();
2723
2724 /* Detach machine: */
2725 if (!m_comMachine.isNull())
2726 m_comMachine.detach();
2727
2728 /* Close session: */
2729 if (!m_comSession.isNull() && gpGlobalSession->isVBoxSVCAvailable())
2730 {
2731 m_comSession.UnlockMachine();
2732 m_comSession.detach();
2733 }
2734}
2735
2736UIMachineLogic *UISession::machineLogic() const
2737{
2738 return uimachine() ? uimachine()->machineLogic() : 0;
2739}
2740
2741UIMachineWindow *UISession::activeMachineWindow() const
2742{
2743 return machineLogic() ? machineLogic()->activeMachineWindow() : 0;
2744}
2745
2746QWidget *UISession::mainMachineWindow() const
2747{
2748 return machineLogic() ? machineLogic()->mainMachineWindow() : 0;
2749}
2750
2751bool UISession::preprocessInitialization()
2752{
2753#ifdef VBOX_WITH_NETFLT
2754 /* Skip network interface name checks if VM in saved state: */
2755 if (!isSaved())
2756 {
2757 /* Make sure all the attached and enabled network
2758 * adapters are present on the host. This check makes sense
2759 * in two cases only - when attachement type is Bridged Network
2760 * or Host-only Interface. NOTE: Only currently enabled
2761 * attachement type is checked (incorrect parameters check for
2762 * currently disabled attachement types is skipped). */
2763 QStringList failedInterfaceNames;
2764 QStringList availableInterfaceNames;
2765
2766 /* Create host network interface names list: */
2767 foreach (const CHostNetworkInterface &comNetIface, gpGlobalSession->host().GetNetworkInterfaces())
2768 {
2769 availableInterfaceNames << comNetIface.GetName();
2770 availableInterfaceNames << comNetIface.GetShortName();
2771 }
2772
2773 /* Enumerate all the virtual network adapters: */
2774 CPlatform comPlatform = machine().GetPlatform();
2775 CPlatformProperties comProperties = gpGlobalSession->virtualBox().GetPlatformProperties(comPlatform.GetArchitecture());
2776 const ulong cCount = comProperties.GetMaxNetworkAdapters(comPlatform.GetChipsetType());
2777 for (ulong uAdapterIndex = 0; uAdapterIndex < cCount; ++uAdapterIndex)
2778 {
2779 CNetworkAdapter comNetworkAdapter = machine().GetNetworkAdapter(uAdapterIndex);
2780 if (comNetworkAdapter.GetEnabled())
2781 {
2782 /* Get physical network interface name for
2783 * currently enabled network attachement type: */
2784 QString strInterfaceName;
2785 switch (comNetworkAdapter.GetAttachmentType())
2786 {
2787 case KNetworkAttachmentType_Bridged:
2788 strInterfaceName = comNetworkAdapter.GetBridgedInterface();
2789 break;
2790# ifndef VBOX_WITH_VMNET
2791 case KNetworkAttachmentType_HostOnly:
2792 strInterfaceName = comNetworkAdapter.GetHostOnlyInterface();
2793 break;
2794# endif /* !VBOX_WITH_VMNET */
2795 default:
2796 break;
2797 }
2798
2799 if ( !strInterfaceName.isEmpty()
2800 && !availableInterfaceNames.contains(strInterfaceName))
2801 {
2802 LogRel(("GUI: Invalid network interface found: %s\n", strInterfaceName.toUtf8().constData()));
2803 failedInterfaceNames << QString("%1 (adapter %2)").arg(strInterfaceName).arg(uAdapterIndex + 1);
2804 }
2805 }
2806 }
2807
2808 /* Check if non-existent interfaces found: */
2809 if (!failedInterfaceNames.isEmpty())
2810 {
2811 if (msgCenter().warnAboutNetworkInterfaceNotFound(machineName(), failedInterfaceNames.join(", ")))
2812 machineLogic()->openNetworkSettingsDialog();
2813 else
2814 {
2815 LogRel(("GUI: Aborting startup due to preprocess initialization issue detected...\n"));
2816 return false;
2817 }
2818 }
2819 }
2820#endif /* VBOX_WITH_NETFLT */
2821
2822 /* Check for USB enumeration warning. Don't return false even if we have a warning: */
2823 CHost comHost = gpGlobalSession->host();
2824 if (comHost.GetUSBDevices().isEmpty() && comHost.isWarning())
2825 {
2826 /* Do not bitch if USB disabled: */
2827 if (!machine().GetUSBControllers().isEmpty())
2828 {
2829 /* Do not bitch if there are no filters (check if enabled too?): */
2830 if (!machine().GetUSBDeviceFilters().GetDeviceFilters().isEmpty())
2831 UINotificationMessage::cannotEnumerateHostUSBDevices(comHost);
2832 }
2833 }
2834
2835 /* True by default: */
2836 return true;
2837}
2838
2839bool UISession::mountAdHocImage(KDeviceType enmDeviceType, UIMediumDeviceType enmMediumType, const QString &strMediumName)
2840{
2841 /* Get VBox: */
2842 CVirtualBox comVBox = gpGlobalSession->virtualBox();
2843
2844 /* Prepare medium to mount: */
2845 UIMedium guiMedium;
2846
2847 /* The 'none' medium name means ejecting what ever is in the drive,
2848 * in that case => leave the guiMedium variable null. */
2849 if (strMediumName != "none")
2850 {
2851 /* Open the medium: */
2852 const CMedium comMedium = comVBox.OpenMedium(strMediumName, enmDeviceType, KAccessMode_ReadWrite, false /* fForceNewUuid */);
2853 if (!comVBox.isOk() || comMedium.isNull())
2854 {
2855 UINotificationMessage::cannotOpenMedium(comVBox, strMediumName);
2856 return false;
2857 }
2858
2859 /* Make sure medium ID is valid: */
2860 const QUuid uMediumId = comMedium.GetId();
2861 AssertReturn(!uMediumId.isNull(), false);
2862
2863 /* Try to find UIMedium among cached: */
2864 guiMedium = gpMediumEnumerator->medium(uMediumId);
2865 if (guiMedium.isNull())
2866 {
2867 /* Cache new one if necessary: */
2868 guiMedium = UIMedium(comMedium, enmMediumType, KMediumState_Created);
2869 gpMediumEnumerator->createMedium(guiMedium);
2870 }
2871 }
2872
2873 /* Search for a suitable storage slots: */
2874 QList<ExactStorageSlot> aFreeStorageSlots;
2875 QList<ExactStorageSlot> aBusyStorageSlots;
2876 foreach (const CStorageController &comController, machine().GetStorageControllers())
2877 {
2878 foreach (const CMediumAttachment &comAttachment, machine().GetMediumAttachmentsOfController(comController.GetName()))
2879 {
2880 /* Look for an optical devices only: */
2881 if (comAttachment.GetType() == enmDeviceType)
2882 {
2883 /* Append storage slot to corresponding list: */
2884 if (comAttachment.GetMedium().isNull())
2885 aFreeStorageSlots << ExactStorageSlot(comController.GetName(), comController.GetBus(),
2886 comAttachment.GetPort(), comAttachment.GetDevice());
2887 else
2888 aBusyStorageSlots << ExactStorageSlot(comController.GetName(), comController.GetBus(),
2889 comAttachment.GetPort(), comAttachment.GetDevice());
2890 }
2891 }
2892 }
2893
2894 /* Make sure at least one storage slot found: */
2895 QList<ExactStorageSlot> sStorageSlots = aFreeStorageSlots + aBusyStorageSlots;
2896 if (sStorageSlots.isEmpty())
2897 {
2898 UINotificationMessage::cannotMountImage(machineName(), strMediumName);
2899 return false;
2900 }
2901
2902 /* Try to mount medium into first available storage slot: */
2903 while (!sStorageSlots.isEmpty())
2904 {
2905 const ExactStorageSlot storageSlot = sStorageSlots.takeFirst();
2906 machine().MountMedium(storageSlot.controller, storageSlot.port, storageSlot.device, guiMedium.medium(), false /* force */);
2907 if (machine().isOk())
2908 break;
2909 }
2910
2911 /* Show error message if necessary: */
2912 if (!machine().isOk())
2913 {
2914 msgCenter().cannotRemountMedium(machine(), guiMedium, true /* mount? */, false /* retry? */, activeMachineWindow());
2915 return false;
2916 }
2917
2918 /* Save machine settings: */
2919 if (!saveSettings())
2920 return false;
2921
2922 /* True by default: */
2923 return true;
2924}
2925
2926void UISession::recacheMachineMedia()
2927{
2928 /* Compose a list of machine media: */
2929 CMediumVector comMedia;
2930
2931 /* Enumerate all the controllers: */
2932 foreach (const CStorageController &comController, machine().GetStorageControllers())
2933 {
2934 /* Enumerate all the attachments: */
2935 foreach (const CMediumAttachment &comAttachment, machine().GetMediumAttachmentsOfController(comController.GetName()))
2936 {
2937 /* Skip unrelated device types: */
2938 const KDeviceType enmDeviceType = comAttachment.GetType();
2939 if ( enmDeviceType != KDeviceType_HardDisk
2940 && enmDeviceType != KDeviceType_Floppy
2941 && enmDeviceType != KDeviceType_DVD)
2942 continue;
2943 if ( comAttachment.GetIsEjected()
2944 || comAttachment.GetMedium().isNull())
2945 continue;
2946 comMedia.append(comAttachment.GetMedium());
2947 }
2948 }
2949
2950 /* Start media enumeration: */
2951 gpMediumEnumerator->enumerateMedia(comMedia);
2952}
2953
2954/* static */
2955bool UISession::searchMaxSnapshotIndex(const CMachine &comMachine,
2956 const CSnapshot &comSnapshot,
2957 const QString &strNameTemplate,
2958 ulong &uIndex)
2959{
2960 bool fSuccess = true;
2961 ulong uMaxIndex = 0;
2962 const QRegularExpression re(QString("^") + strNameTemplate.arg("([0-9]+)") + QString("$"));
2963 if (!comSnapshot.isNull())
2964 {
2965 /* Check current snapshot name: */
2966 const QString strName = comSnapshot.GetName();
2967 fSuccess = comSnapshot.isOk();
2968 if (!fSuccess)
2969 UINotificationMessage::cannotAcquireSnapshotParameter(comSnapshot);
2970 else
2971 {
2972 const QRegularExpressionMatch mt = re.match(strName);
2973 if (mt.hasMatch())
2974 {
2975 const ulong uFoundIndex = mt.captured(1).toULong();
2976 uMaxIndex = uFoundIndex > uMaxIndex ? uFoundIndex : uMaxIndex;
2977 }
2978 /* Traversing all the snapshot children: */
2979 QVector<CSnapshot> comSnapshotChildren = comSnapshot.GetChildren();
2980 fSuccess = comSnapshot.isOk();
2981 if (!fSuccess)
2982 UINotificationMessage::cannotAcquireSnapshotParameter(comSnapshot);
2983 else
2984 foreach (const CSnapshot &comSnapshotChild, comSnapshotChildren)
2985 {
2986 ulong uMaxIndexOfChildren = 0;
2987 fSuccess = searchMaxSnapshotIndex(comMachine, comSnapshotChild, strNameTemplate, uMaxIndexOfChildren);
2988 if (!fSuccess)
2989 break;
2990 uMaxIndex = uMaxIndexOfChildren > uMaxIndex ? uMaxIndexOfChildren : uMaxIndex;
2991 }
2992 }
2993 }
2994 if (fSuccess)
2995 uIndex = uMaxIndex;
2996 return fSuccess;
2997}
2998
2999#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
3000/**
3001 * Custom signal handler. When switching VTs, we might not get release events
3002 * for Ctrl-Alt and in case a savestate is performed on the new VT, the VM will
3003 * be saved with modifier keys stuck. This is annoying enough for introducing
3004 * this hack.
3005 */
3006/* static */
3007static void signalHandlerSIGUSR1(int sig, siginfo_t * /* pInfo */, void * /*pSecret */)
3008{
3009 /* Only SIGUSR1 is interesting: */
3010 if (sig == SIGUSR1)
3011 if (gpMachine)
3012 gpMachine->machineLogic()->keyboardHandler()->releaseAllPressedKeys();
3013}
3014#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette