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