1 | /* $Id: UISession.cpp 101316 2023-09-29 13:40:05Z 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::acquireDnDMode(KDnDMode &enmMode)
|
---|
609 | {
|
---|
610 | CMachine comMachine = machine();
|
---|
611 | if (comMachine.isNull())
|
---|
612 | return false;
|
---|
613 | const KDnDMode enmDnDMode = comMachine.GetDnDMode();
|
---|
614 | const bool fSuccess = comMachine.isOk();
|
---|
615 | if (!fSuccess)
|
---|
616 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
617 | else
|
---|
618 | enmMode = enmDnDMode;
|
---|
619 | return fSuccess;
|
---|
620 | }
|
---|
621 |
|
---|
622 | bool UISession::setDnDMode(KDnDMode enmMode)
|
---|
623 | {
|
---|
624 | CMachine comMachine = machine();
|
---|
625 | comMachine.SetDnDMode(enmMode);
|
---|
626 | const bool fSuccess = comMachine.isOk();
|
---|
627 | if (!fSuccess)
|
---|
628 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
629 | return fSuccess;
|
---|
630 | }
|
---|
631 |
|
---|
632 | bool UISession::acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives)
|
---|
633 | {
|
---|
634 | const CMachine comMachine = machine();
|
---|
635 | if (comMachine.isNull())
|
---|
636 | return false;
|
---|
637 | ulong cActualHardDisks = 0, cActualOpticalDrives = 0, cActualFloppyDrives = 0;
|
---|
638 | const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
|
---|
639 | bool fSuccess = comMachine.isOk();
|
---|
640 | if (!fSuccess)
|
---|
641 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
642 | else
|
---|
643 | {
|
---|
644 | foreach (const CMediumAttachment &comAttachment, comAttachments)
|
---|
645 | {
|
---|
646 | /* Get device type: */
|
---|
647 | const KDeviceType enmDeviceType = comAttachment.GetType();
|
---|
648 | fSuccess = comAttachment.isOk();
|
---|
649 | if (!fSuccess)
|
---|
650 | {
|
---|
651 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
652 | break;
|
---|
653 | }
|
---|
654 |
|
---|
655 | /* And advance corresponding amount: */
|
---|
656 | switch (enmDeviceType)
|
---|
657 | {
|
---|
658 | case KDeviceType_HardDisk: ++cActualHardDisks; break;
|
---|
659 | case KDeviceType_DVD: ++cActualOpticalDrives; break;
|
---|
660 | case KDeviceType_Floppy: ++cActualFloppyDrives; break;
|
---|
661 | default: break;
|
---|
662 | }
|
---|
663 | }
|
---|
664 | }
|
---|
665 | if (fSuccess)
|
---|
666 | {
|
---|
667 | cHardDisks = cActualHardDisks;
|
---|
668 | cOpticalDrives = cActualOpticalDrives;
|
---|
669 | cFloppyDrives = cActualFloppyDrives;
|
---|
670 | }
|
---|
671 | return fSuccess;
|
---|
672 | }
|
---|
673 |
|
---|
674 | bool UISession::storageDevices(KDeviceType enmActualDeviceType, QList<StorageDeviceInfo> &guiStorageDevices)
|
---|
675 | {
|
---|
676 | const CMachine comMachine = machine();
|
---|
677 | const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
|
---|
678 | bool fSuccess = comMachine.isOk();
|
---|
679 | if (!fSuccess)
|
---|
680 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
681 | else
|
---|
682 | {
|
---|
683 | foreach (const CMediumAttachment &comAttachment, comAttachments)
|
---|
684 | {
|
---|
685 | /* Get device type: */
|
---|
686 | const KDeviceType enmDeviceType = comAttachment.GetType();
|
---|
687 | fSuccess = comAttachment.isOk();
|
---|
688 | if (!fSuccess)
|
---|
689 | {
|
---|
690 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
691 | break;
|
---|
692 | }
|
---|
693 | /* And make sure it's actual one: */
|
---|
694 | if (enmDeviceType != enmActualDeviceType)
|
---|
695 | continue;
|
---|
696 |
|
---|
697 | /* Get controller name: */
|
---|
698 | const QString strControllerName = comAttachment.GetController();
|
---|
699 | fSuccess = comAttachment.isOk();
|
---|
700 | if (!fSuccess)
|
---|
701 | {
|
---|
702 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
703 | break;
|
---|
704 | }
|
---|
705 | /* And search for it's presence: */
|
---|
706 | const CStorageController comController = comMachine.GetStorageControllerByName(strControllerName);
|
---|
707 | fSuccess = comMachine.isOk();
|
---|
708 | if (!fSuccess)
|
---|
709 | {
|
---|
710 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
711 | break;
|
---|
712 | }
|
---|
713 |
|
---|
714 | /* Fill structure fields: */
|
---|
715 | StorageDeviceInfo guiStorageDevice;
|
---|
716 | guiStorageDevice.m_strControllerName = strControllerName; // already confirmed
|
---|
717 | const KStorageBus enmStorageBus = comController.GetBus();
|
---|
718 | fSuccess = comController.isOk();
|
---|
719 | if (!fSuccess)
|
---|
720 | {
|
---|
721 | UINotificationMessage::cannotAcquireStorageControllerParameter(comController);
|
---|
722 | break;
|
---|
723 | }
|
---|
724 | switch (enmStorageBus)
|
---|
725 | {
|
---|
726 | case KStorageBus_IDE: guiStorageDevice.m_icon = UIIconPool::iconSet(":/ide_16px.png"); break;
|
---|
727 | case KStorageBus_SATA: guiStorageDevice.m_icon = UIIconPool::iconSet(":/sata_16px.png"); break;
|
---|
728 | case KStorageBus_SCSI: guiStorageDevice.m_icon = UIIconPool::iconSet(":/scsi_16px.png"); break;
|
---|
729 | case KStorageBus_Floppy: guiStorageDevice.m_icon = UIIconPool::iconSet(":/floppy_16px.png"); break;
|
---|
730 | case KStorageBus_SAS: guiStorageDevice.m_icon = UIIconPool::iconSet(":/sas_16px.png"); break;
|
---|
731 | case KStorageBus_USB: guiStorageDevice.m_icon = UIIconPool::iconSet(":/usb_16px.png"); break;
|
---|
732 | case KStorageBus_PCIe: guiStorageDevice.m_icon = UIIconPool::iconSet(":/pcie_16px.png"); break;
|
---|
733 | case KStorageBus_VirtioSCSI: guiStorageDevice.m_icon = UIIconPool::iconSet(":/virtio_scsi_16px.png"); break;
|
---|
734 | default: break;
|
---|
735 | }
|
---|
736 | const long iPort = comAttachment.GetPort();
|
---|
737 | fSuccess = comAttachment.isOk();
|
---|
738 | if (!fSuccess)
|
---|
739 | {
|
---|
740 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
741 | break;
|
---|
742 | }
|
---|
743 | const long iDevice = comAttachment.GetDevice();
|
---|
744 | fSuccess = comAttachment.isOk();
|
---|
745 | if (!fSuccess)
|
---|
746 | {
|
---|
747 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
748 | break;
|
---|
749 | }
|
---|
750 | if (fSuccess)
|
---|
751 | {
|
---|
752 | const StorageSlot guiStorageSlot(enmStorageBus, iPort, iDevice);
|
---|
753 | guiStorageDevice.m_guiStorageSlot = guiStorageSlot;
|
---|
754 | }
|
---|
755 |
|
---|
756 | /* Append or break if necessary: */
|
---|
757 | if (fSuccess)
|
---|
758 | guiStorageDevices << guiStorageDevice;
|
---|
759 | else
|
---|
760 | break;
|
---|
761 | }
|
---|
762 | }
|
---|
763 | return fSuccess;
|
---|
764 | }
|
---|
765 |
|
---|
766 | bool UISession::acquireEncryptedMedia(EncryptedMediumMap &media)
|
---|
767 | {
|
---|
768 | EncryptedMediumMap encryptedMedia;
|
---|
769 | CMachine comMachine = machine();
|
---|
770 | const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
|
---|
771 | bool fSuccess = comMachine.isOk();
|
---|
772 | if (!fSuccess)
|
---|
773 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
774 | else
|
---|
775 | {
|
---|
776 | foreach (const CMediumAttachment &comAttachment, comAttachments)
|
---|
777 | {
|
---|
778 | const KDeviceType enmType = comAttachment.GetType();
|
---|
779 | fSuccess = comAttachment.isOk();
|
---|
780 | if (!fSuccess)
|
---|
781 | {
|
---|
782 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
783 | break;
|
---|
784 | }
|
---|
785 |
|
---|
786 | /* Look for hard-drive attachments only: */
|
---|
787 | if (enmType != KDeviceType_HardDisk)
|
---|
788 | continue;
|
---|
789 |
|
---|
790 | /* Get the attachment medium: */
|
---|
791 | const CMedium comMedium = comAttachment.GetMedium();
|
---|
792 | fSuccess = comAttachment.isOk();
|
---|
793 | if (!fSuccess)
|
---|
794 | {
|
---|
795 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
796 | break;
|
---|
797 | }
|
---|
798 |
|
---|
799 | /* Get the medium ID: */
|
---|
800 | const QUuid uId = comMedium.GetId();
|
---|
801 | fSuccess = comMedium.isOk();
|
---|
802 | if (!fSuccess)
|
---|
803 | {
|
---|
804 | UINotificationMessage::cannotAcquireMediumParameter(comMedium);
|
---|
805 | break;
|
---|
806 | }
|
---|
807 |
|
---|
808 | /* Update the map with this medium if it's encrypted: */
|
---|
809 | QString strCipher;
|
---|
810 | const QString strPasswordId = comMedium.GetEncryptionSettings(strCipher);
|
---|
811 | if (comMedium.isOk()) // GetEncryptionSettings failure is a valid case
|
---|
812 | encryptedMedia.insert(strPasswordId, uId);
|
---|
813 | }
|
---|
814 | }
|
---|
815 |
|
---|
816 | if (fSuccess)
|
---|
817 | media = encryptedMedia;
|
---|
818 | return fSuccess;
|
---|
819 | }
|
---|
820 |
|
---|
821 | bool UISession::addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend)
|
---|
822 | {
|
---|
823 | CConsole comConsole = console();
|
---|
824 | comConsole.AddEncryptionPassword(strId, strPassword, fClearOnSuspend);
|
---|
825 | const bool fSuccess = comConsole.isOk();
|
---|
826 | if (!fSuccess)
|
---|
827 | msgCenter().cannotAddDiskEncryptionPassword(comConsole);
|
---|
828 | return fSuccess;
|
---|
829 | }
|
---|
830 |
|
---|
831 | bool UISession::acquireAmountOfImmutableImages(ulong &cAmount)
|
---|
832 | {
|
---|
833 | CMachine comMachine = machine();
|
---|
834 | return UICommon::acquireAmountOfImmutableImages(comMachine, cAmount);
|
---|
835 | }
|
---|
836 |
|
---|
837 | bool UISession::mountBootMedium(const QUuid &uMediumId)
|
---|
838 | {
|
---|
839 | AssertReturn(!uMediumId.isNull(), false);
|
---|
840 |
|
---|
841 | /* Get recommended controller bus & type: */
|
---|
842 | CVirtualBox comVBox = uiCommon().virtualBox();
|
---|
843 |
|
---|
844 | if (!comVBox.isOk())
|
---|
845 | {
|
---|
846 | UINotificationMessage::cannotAcquireVirtualBoxParameter(comVBox);
|
---|
847 | return false;
|
---|
848 | }
|
---|
849 |
|
---|
850 | const KStorageBus enmRecommendedDvdBus = uiCommon().guestOSTypeManager().getRecommendedDVDStorageBus(osTypeId());
|
---|
851 | const KStorageControllerType enmRecommendedDvdType = uiCommon().guestOSTypeManager().getRecommendedDVDStorageController(osTypeId());
|
---|
852 |
|
---|
853 | /* Search for an attachment of required bus & type: */
|
---|
854 | CMachine comMachine = machine();
|
---|
855 | CMediumAttachmentVector comMediumAttachments = comMachine.GetMediumAttachments();
|
---|
856 | bool fSuccess = comMachine.isOk();
|
---|
857 | if (!fSuccess)
|
---|
858 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
859 | else
|
---|
860 | {
|
---|
861 | CMediumAttachment comChosenAttachment;
|
---|
862 | QString strChosenControllerName;
|
---|
863 | LONG iChosenAttachmentPort = 0;
|
---|
864 | LONG iChosenAttachmentDevice = 0;
|
---|
865 | foreach (const CMediumAttachment &comAttachment, comMediumAttachments)
|
---|
866 | {
|
---|
867 | /* Get attachment type: */
|
---|
868 | const KDeviceType enmCurrentDeviceType = comAttachment.GetType();
|
---|
869 | fSuccess = comAttachment.isOk();
|
---|
870 | if (!fSuccess)
|
---|
871 | {
|
---|
872 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
873 | break;
|
---|
874 | }
|
---|
875 | /* And make sure it's DVD: */
|
---|
876 | if (enmCurrentDeviceType != KDeviceType_DVD)
|
---|
877 | continue;
|
---|
878 |
|
---|
879 | /* Get controller name: */
|
---|
880 | const QString strControllerName = comAttachment.GetController();
|
---|
881 | fSuccess = comAttachment.isOk();
|
---|
882 | if (!fSuccess)
|
---|
883 | {
|
---|
884 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
885 | break;
|
---|
886 | }
|
---|
887 | /* And look for corresponding controller: */
|
---|
888 | const CStorageController comCurrentController = comMachine.GetStorageControllerByName(strControllerName);
|
---|
889 | fSuccess = comMachine.isOk();
|
---|
890 | if (!fSuccess)
|
---|
891 | {
|
---|
892 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
893 | break;
|
---|
894 | }
|
---|
895 |
|
---|
896 | /* Get current controller bus: */
|
---|
897 | const KStorageBus enmCurrentBus = comCurrentController.GetBus();
|
---|
898 | fSuccess = comCurrentController.isOk();
|
---|
899 | if (!fSuccess)
|
---|
900 | {
|
---|
901 | UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController);
|
---|
902 | break;
|
---|
903 | }
|
---|
904 | /* Get current controller type: */
|
---|
905 | const KStorageControllerType enmCurrentType = comCurrentController.GetControllerType();
|
---|
906 | fSuccess = comCurrentController.isOk();
|
---|
907 | if (!fSuccess)
|
---|
908 | {
|
---|
909 | UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController);
|
---|
910 | break;
|
---|
911 | }
|
---|
912 | /* And check if they are suitable: */
|
---|
913 | if ( enmCurrentBus != enmRecommendedDvdBus
|
---|
914 | || enmCurrentType != enmRecommendedDvdType)
|
---|
915 | continue;
|
---|
916 |
|
---|
917 | /* Get current attachment port: */
|
---|
918 | iChosenAttachmentPort = comAttachment.GetPort();
|
---|
919 | fSuccess = comAttachment.isOk();
|
---|
920 | if (!fSuccess)
|
---|
921 | {
|
---|
922 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
923 | break;
|
---|
924 | }
|
---|
925 | /* Get current attachment device: */
|
---|
926 | iChosenAttachmentDevice = comAttachment.GetDevice();
|
---|
927 | fSuccess = comAttachment.isOk();
|
---|
928 | if (!fSuccess)
|
---|
929 | {
|
---|
930 | UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
|
---|
931 | break;
|
---|
932 | }
|
---|
933 |
|
---|
934 | /* Everything is nice it seems: */
|
---|
935 | comChosenAttachment = comAttachment;
|
---|
936 | strChosenControllerName = strControllerName;
|
---|
937 | break;
|
---|
938 | }
|
---|
939 | AssertMsgReturn(!comChosenAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);
|
---|
940 |
|
---|
941 | /* Get medium to mount: */
|
---|
942 | const UIMedium guiMedium = uiCommon().medium(uMediumId);
|
---|
943 | const CMedium comMedium = guiMedium.medium();
|
---|
944 |
|
---|
945 | /* Mount medium to the predefined port/device: */
|
---|
946 | comMachine.MountMedium(strChosenControllerName,
|
---|
947 | iChosenAttachmentPort, iChosenAttachmentDevice,
|
---|
948 | comMedium, false /* force */);
|
---|
949 | fSuccess = comMachine.isOk();
|
---|
950 | if (!fSuccess)
|
---|
951 | {
|
---|
952 | QWidget *pParent = windowManager().realParentWindow(activeMachineWindow());
|
---|
953 | msgCenter().cannotRemountMedium(machine(), guiMedium, true /* mount? */, false /* retry? */, pParent);
|
---|
954 | }
|
---|
955 | else
|
---|
956 | fSuccess = saveSettings();
|
---|
957 | }
|
---|
958 |
|
---|
959 | return fSuccess;
|
---|
960 | }
|
---|
961 |
|
---|
962 | void UISession::prepareStorageMenu(QMenu *pMenu,
|
---|
963 | QObject *pListener, const char *pszSlotName,
|
---|
964 | const QString &strControllerName, const StorageSlot &storageSlot)
|
---|
965 | {
|
---|
966 | CMachine comMachine = machine();
|
---|
967 | uiCommon().prepareStorageMenu(pMenu,
|
---|
968 | pListener, pszSlotName,
|
---|
969 | comMachine, strControllerName, storageSlot);
|
---|
970 | }
|
---|
971 |
|
---|
972 | void UISession::updateMachineStorage(const UIMediumTarget &target, UIActionPool *pActionPool)
|
---|
973 | {
|
---|
974 | CMachine comMachine = machine();
|
---|
975 | uiCommon().updateMachineStorage(comMachine, target, pActionPool);
|
---|
976 | }
|
---|
977 |
|
---|
978 | void UISession::acquireWhetherUSBControllerEnabled(bool &fEnabled)
|
---|
979 | {
|
---|
980 | fEnabled = false;
|
---|
981 |
|
---|
982 | /* Check whether USB device filters are available: */
|
---|
983 | CMachine comMachine = machine();
|
---|
984 | if (comMachine.isNull())
|
---|
985 | return;
|
---|
986 | CUSBDeviceFilters comUSBDeviceFilters = comMachine.GetUSBDeviceFilters();
|
---|
987 | if (!comMachine.isOk() || comUSBDeviceFilters.isNull())
|
---|
988 | return;
|
---|
989 | /* Check whether USB controllers are available: */
|
---|
990 | CUSBControllerVector comUSBControllers = comMachine.GetUSBControllers();
|
---|
991 | if (!comMachine.isOk() || comUSBControllers.isEmpty())
|
---|
992 | return;
|
---|
993 | /* Check whether USB proxy is available: */
|
---|
994 | const BOOL fUSBProxyAvailable = comMachine.GetUSBProxyAvailable();
|
---|
995 | if (!comMachine.isOk() || fUSBProxyAvailable == FALSE)
|
---|
996 | return;
|
---|
997 |
|
---|
998 | fEnabled = true;
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | void UISession::acquireWhetherVideoInputDevicesEnabled(bool &fEnabled)
|
---|
1002 | {
|
---|
1003 | fEnabled = false;
|
---|
1004 |
|
---|
1005 | /* Check whether video input devices are available: */
|
---|
1006 | CHost comHost = uiCommon().host();
|
---|
1007 | CHostVideoInputDeviceVector comVideoInputDevices = comHost.GetVideoInputDevices();
|
---|
1008 | if (!comHost.isOk() || comVideoInputDevices.isEmpty())
|
---|
1009 | return;
|
---|
1010 | /* Check whether USB controllers are available: */
|
---|
1011 | CMachine comMachine = machine();
|
---|
1012 | if (comMachine.isNull())
|
---|
1013 | return;
|
---|
1014 | CUSBControllerVector comUSBControllers = comMachine.GetUSBControllers();
|
---|
1015 | if (!comMachine.isOk() || comUSBControllers.isEmpty())
|
---|
1016 | return;
|
---|
1017 |
|
---|
1018 | fEnabled = true;
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | bool UISession::usbDevices(QList<USBDeviceInfo> &guiUSBDevices)
|
---|
1022 | {
|
---|
1023 | const CHost comHost = uiCommon().host();
|
---|
1024 | const CHostUSBDeviceVector comHostUSBDevices = comHost.GetUSBDevices();
|
---|
1025 | bool fSuccess = comHost.isOk();
|
---|
1026 | if (!fSuccess)
|
---|
1027 | UINotificationMessage::cannotAcquireHostParameter(comHost);
|
---|
1028 | else
|
---|
1029 | {
|
---|
1030 | foreach (const CHostUSBDevice &comHostUSBDevice, comHostUSBDevices)
|
---|
1031 | {
|
---|
1032 | /* Get USB device from current host USB device,
|
---|
1033 | * this stuff requires #include <VBox/com/VirtualBox.h> */
|
---|
1034 | const CUSBDevice comUSBDevice(comHostUSBDevice);
|
---|
1035 |
|
---|
1036 | /* Fill structure fields: */
|
---|
1037 | USBDeviceInfo guiUSBDevice;
|
---|
1038 | if (fSuccess)
|
---|
1039 | {
|
---|
1040 | guiUSBDevice.m_uId = comUSBDevice.GetId();
|
---|
1041 | fSuccess = comUSBDevice.isOk();
|
---|
1042 | }
|
---|
1043 | if (fSuccess)
|
---|
1044 | {
|
---|
1045 | /// @todo make sure UICommon::usbDetails is checked for errors as well
|
---|
1046 | guiUSBDevice.m_strName = uiCommon().usbDetails(comUSBDevice);
|
---|
1047 | fSuccess = comUSBDevice.isOk();
|
---|
1048 | }
|
---|
1049 | if (fSuccess)
|
---|
1050 | {
|
---|
1051 | /// @todo make sure UICommon::usbToolTip is checked for errors as well
|
---|
1052 | guiUSBDevice.m_strToolTip = uiCommon().usbToolTip(comUSBDevice);
|
---|
1053 | fSuccess = comUSBDevice.isOk();
|
---|
1054 | }
|
---|
1055 | if (fSuccess)
|
---|
1056 | {
|
---|
1057 | /* Check if that USB device was already attached to this session;
|
---|
1058 | * Nothing to check for errors here because error is valid case as well. */
|
---|
1059 | const CUSBDevice comAttachedDevice = console().FindUSBDeviceById(guiUSBDevice.m_uId);
|
---|
1060 | guiUSBDevice.m_fIsChecked = !comAttachedDevice.isNull();
|
---|
1061 | }
|
---|
1062 | if (fSuccess)
|
---|
1063 | {
|
---|
1064 | guiUSBDevice.m_fIsEnabled = comHostUSBDevice.GetState() != KUSBDeviceState_Unavailable;
|
---|
1065 | fSuccess = comHostUSBDevice.isOk();
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | /* Append or break if necessary: */
|
---|
1069 | if (fSuccess)
|
---|
1070 | guiUSBDevices << guiUSBDevice;
|
---|
1071 | else
|
---|
1072 | break;
|
---|
1073 | }
|
---|
1074 | }
|
---|
1075 | return fSuccess;
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 | bool UISession::attachUSBDevice(const QUuid &uId)
|
---|
1079 | {
|
---|
1080 | CConsole comConsole = console();
|
---|
1081 | comConsole.AttachUSBDevice(uId, QString(""));
|
---|
1082 | const bool fSuccess = comConsole.isOk();
|
---|
1083 | if (!fSuccess)
|
---|
1084 | {
|
---|
1085 | CHost comHost = uiCommon().host();
|
---|
1086 | /* Nothing to check for errors here because error is valid case as well. */
|
---|
1087 | CHostUSBDevice comHostUSBDevice = comHost.FindUSBDeviceById(uId);
|
---|
1088 | /* Get USB device from current host USB device,
|
---|
1089 | * this stuff requires #include <VBox/com/VirtualBox.h> */
|
---|
1090 | CUSBDevice comUSBDevice(comHostUSBDevice);
|
---|
1091 | UINotificationMessage::cannotAttachUSBDevice(comConsole, uiCommon().usbDetails(comUSBDevice));
|
---|
1092 | /// @todo make sure UICommon::usbDetails is checked for errors as well
|
---|
1093 | }
|
---|
1094 | return fSuccess;
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 | bool UISession::detachUSBDevice(const QUuid &uId)
|
---|
1098 | {
|
---|
1099 | CConsole comConsole = console();
|
---|
1100 | comConsole.DetachUSBDevice(uId);
|
---|
1101 | const bool fSuccess = comConsole.isOk();
|
---|
1102 | if (!fSuccess)
|
---|
1103 | {
|
---|
1104 | CUSBDevice comUSBDevice = CConsole(comConsole).FindUSBDeviceById(uId);
|
---|
1105 | UINotificationMessage::cannotDetachUSBDevice(comConsole, uiCommon().usbDetails(comUSBDevice));
|
---|
1106 | /// @todo make sure UICommon::usbDetails is checked for errors as well
|
---|
1107 | }
|
---|
1108 | return fSuccess;
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 | bool UISession::webcamDevices(QList<WebcamDeviceInfo> &guiWebcamDevices)
|
---|
1112 | {
|
---|
1113 | const CHost comHost = uiCommon().host();
|
---|
1114 | const CHostVideoInputDeviceVector comHostVideoInputDevices = comHost.GetVideoInputDevices();
|
---|
1115 | bool fSuccess = comHost.isOk();
|
---|
1116 | if (!fSuccess)
|
---|
1117 | UINotificationMessage::cannotAcquireHostParameter(comHost);
|
---|
1118 | else
|
---|
1119 | {
|
---|
1120 | CConsole comConsole = console();
|
---|
1121 | CEmulatedUSB comEmulatedUSB = comConsole.GetEmulatedUSB();
|
---|
1122 | fSuccess = comConsole.isOk();
|
---|
1123 | if (!fSuccess)
|
---|
1124 | UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
|
---|
1125 | else
|
---|
1126 | {
|
---|
1127 | const QVector<QString> attachedWebcamPaths = comEmulatedUSB.GetWebcams();
|
---|
1128 | fSuccess = comEmulatedUSB.isOk();
|
---|
1129 | if (!fSuccess)
|
---|
1130 | UINotificationMessage::cannotAcquireEmulatedUSBParameter(comEmulatedUSB);
|
---|
1131 | else
|
---|
1132 | {
|
---|
1133 | foreach (const CHostVideoInputDevice &comHostVideoInputDevice, comHostVideoInputDevices)
|
---|
1134 | {
|
---|
1135 | /* Fill structure fields: */
|
---|
1136 | WebcamDeviceInfo guiWebcamDevice;
|
---|
1137 | if (fSuccess)
|
---|
1138 | {
|
---|
1139 | guiWebcamDevice.m_strName = comHostVideoInputDevice.GetName();
|
---|
1140 | fSuccess = comHostVideoInputDevice.isOk();
|
---|
1141 | }
|
---|
1142 | if (fSuccess)
|
---|
1143 | {
|
---|
1144 | guiWebcamDevice.m_strPath = comHostVideoInputDevice.GetPath();
|
---|
1145 | fSuccess = comHostVideoInputDevice.isOk();
|
---|
1146 | }
|
---|
1147 | if (fSuccess)
|
---|
1148 | {
|
---|
1149 | /// @todo make sure UICommon::usbToolTip is checked for errors as well
|
---|
1150 | guiWebcamDevice.m_strToolTip = uiCommon().usbToolTip(comHostVideoInputDevice);
|
---|
1151 | fSuccess = comHostVideoInputDevice.isOk();
|
---|
1152 | }
|
---|
1153 | if (fSuccess)
|
---|
1154 | guiWebcamDevice.m_fIsChecked = attachedWebcamPaths.contains(guiWebcamDevice.m_strPath);
|
---|
1155 |
|
---|
1156 | /* Append or break if necessary: */
|
---|
1157 | if (fSuccess)
|
---|
1158 | guiWebcamDevices << guiWebcamDevice;
|
---|
1159 | else
|
---|
1160 | break;
|
---|
1161 | }
|
---|
1162 | }
|
---|
1163 | }
|
---|
1164 | }
|
---|
1165 | return fSuccess;
|
---|
1166 | }
|
---|
1167 |
|
---|
1168 | bool UISession::webcamAttach(const QString &strPath, const QString &strName)
|
---|
1169 | {
|
---|
1170 | CConsole comConsole = console();
|
---|
1171 | CEmulatedUSB comDispatcher = comConsole.GetEmulatedUSB();
|
---|
1172 | bool fSuccess = comConsole.isOk();
|
---|
1173 | if (!fSuccess)
|
---|
1174 | UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
|
---|
1175 | else
|
---|
1176 | {
|
---|
1177 | comDispatcher.WebcamAttach(strPath, "");
|
---|
1178 | fSuccess = comDispatcher.isOk();
|
---|
1179 | if (!fSuccess)
|
---|
1180 | UINotificationMessage::cannotAttachWebCam(comDispatcher, strName, machineName());
|
---|
1181 | }
|
---|
1182 | return fSuccess;
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 | bool UISession::webcamDetach(const QString &strPath, const QString &strName)
|
---|
1186 | {
|
---|
1187 | CConsole comConsole = console();
|
---|
1188 | CEmulatedUSB comDispatcher = comConsole.GetEmulatedUSB();
|
---|
1189 | bool fSuccess = comConsole.isOk();
|
---|
1190 | if (!fSuccess)
|
---|
1191 | UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
|
---|
1192 | else
|
---|
1193 | {
|
---|
1194 | comDispatcher.WebcamDetach(strPath);
|
---|
1195 | fSuccess = comDispatcher.isOk();
|
---|
1196 | if (!fSuccess)
|
---|
1197 | UINotificationMessage::cannotDetachWebCam(comDispatcher, strName, machineName());
|
---|
1198 | }
|
---|
1199 | return fSuccess;
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | bool UISession::acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled)
|
---|
1203 | {
|
---|
1204 | CMachine comMachine = machine();
|
---|
1205 | CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
|
---|
1206 | bool fSuccess = comMachine.isOk();
|
---|
1207 | if (!fSuccess)
|
---|
1208 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1209 | else
|
---|
1210 | {
|
---|
1211 | const BOOL fAdapterEnabled = comAdapter.GetEnabled();
|
---|
1212 | fSuccess = comAdapter.isOk();
|
---|
1213 | if (!fSuccess)
|
---|
1214 | UINotificationMessage::cannotAcquireNetworkAdapterParameter(comAdapter);
|
---|
1215 | else
|
---|
1216 | fEnabled = fAdapterEnabled == TRUE;
|
---|
1217 | }
|
---|
1218 | return fSuccess;
|
---|
1219 | }
|
---|
1220 |
|
---|
1221 | bool UISession::acquireWhetherAtLeastOneNetworkAdapterEnabled(bool &fEnabled)
|
---|
1222 | {
|
---|
1223 | /* Acquire system properties: */
|
---|
1224 | CVirtualBox comVBox = uiCommon().virtualBox();
|
---|
1225 | AssertReturn(comVBox.isNotNull(), false);
|
---|
1226 | CPlatformProperties comProperties = comVBox.GetPlatformProperties(KPlatformArchitecture_x86);
|
---|
1227 | if (!comVBox.isOk())
|
---|
1228 | {
|
---|
1229 | UINotificationMessage::cannotAcquireVirtualBoxParameter(comVBox);
|
---|
1230 | return false;
|
---|
1231 | }
|
---|
1232 |
|
---|
1233 | /* Acquire chipset type: */
|
---|
1234 | KChipsetType enmChipsetType = KChipsetType_Null;
|
---|
1235 | bool fSuccess = acquireChipsetType(enmChipsetType);
|
---|
1236 | if (fSuccess)
|
---|
1237 | {
|
---|
1238 | /* Acquire maximum network adapters count: */
|
---|
1239 | const ulong uSlots = comProperties.GetMaxNetworkAdapters(enmChipsetType);
|
---|
1240 | fSuccess = comProperties.isOk();
|
---|
1241 | if (!fSuccess)
|
---|
1242 | UINotificationMessage::cannotAcquirePlatformPropertiesParameter(comProperties);
|
---|
1243 | else
|
---|
1244 | {
|
---|
1245 | /* Search for 1st enabled adapter: */
|
---|
1246 | for (ulong uSlot = 0; uSlot < uSlots; ++uSlot)
|
---|
1247 | {
|
---|
1248 | bool fAdapterEnabled = false;
|
---|
1249 | fSuccess = acquireWhetherNetworkAdapterEnabled(uSlot, fAdapterEnabled);
|
---|
1250 | if (!fSuccess)
|
---|
1251 | break;
|
---|
1252 | if (!fAdapterEnabled)
|
---|
1253 | continue;
|
---|
1254 | fEnabled = true;
|
---|
1255 | break;
|
---|
1256 | }
|
---|
1257 | }
|
---|
1258 | }
|
---|
1259 | return fSuccess;
|
---|
1260 | }
|
---|
1261 |
|
---|
1262 | bool UISession::acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected)
|
---|
1263 | {
|
---|
1264 | CMachine comMachine = machine();
|
---|
1265 | CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
|
---|
1266 | bool fSuccess = comMachine.isOk();
|
---|
1267 | if (!fSuccess)
|
---|
1268 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1269 | else
|
---|
1270 | {
|
---|
1271 | const BOOL fCableConnected = comAdapter.GetCableConnected();
|
---|
1272 | fSuccess = comAdapter.isOk();
|
---|
1273 | if (!fSuccess)
|
---|
1274 | UINotificationMessage::cannotAcquireNetworkAdapterParameter(comAdapter);
|
---|
1275 | else
|
---|
1276 | fConnected = fCableConnected == TRUE;
|
---|
1277 | }
|
---|
1278 | return fSuccess;
|
---|
1279 | }
|
---|
1280 |
|
---|
1281 | bool UISession::setNetworkCableConnected(ulong uSlot, bool fConnected)
|
---|
1282 | {
|
---|
1283 | CMachine comMachine = machine();
|
---|
1284 | CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
|
---|
1285 | bool fSuccess = comMachine.isOk();
|
---|
1286 | if (!fSuccess)
|
---|
1287 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1288 | else
|
---|
1289 | {
|
---|
1290 | comAdapter.SetCableConnected(fConnected);
|
---|
1291 | fSuccess = comAdapter.isOk();
|
---|
1292 | if (!fSuccess)
|
---|
1293 | UINotificationMessage::cannotToggleNetworkCable(comAdapter, machineName(), fConnected);
|
---|
1294 | }
|
---|
1295 | return fSuccess;
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | bool UISession::guestAdditionsUpgradable()
|
---|
1299 | {
|
---|
1300 | if (!machine().isOk())
|
---|
1301 | return false;
|
---|
1302 |
|
---|
1303 | /* Auto GA update is currently for Windows and Linux guests only */
|
---|
1304 | bool fIsWindowOrLinux = uiCommon().guestOSTypeManager().isLinux(uimachine()->osTypeId())
|
---|
1305 | || uiCommon().guestOSTypeManager().isWindows(uimachine()->osTypeId());
|
---|
1306 |
|
---|
1307 | if (!fIsWindowOrLinux)
|
---|
1308 | return false;
|
---|
1309 |
|
---|
1310 | /* Also check whether we have something to update automatically: */
|
---|
1311 | if (m_ulGuestAdditionsRunLevel < (ulong)KAdditionsRunLevelType_Userland)
|
---|
1312 | return false;
|
---|
1313 |
|
---|
1314 | return true;
|
---|
1315 | }
|
---|
1316 |
|
---|
1317 | bool UISession::acquireGuestAdditionsVersion(QString &strVersion)
|
---|
1318 | {
|
---|
1319 | CGuest comGuest = guest();
|
---|
1320 | const QString strGAVersion = comGuest.GetAdditionsVersion();
|
---|
1321 | const bool fSuccess = comGuest.isOk();
|
---|
1322 | if (!fSuccess)
|
---|
1323 | UINotificationMessage::cannotAcquireGuestParameter(comGuest);
|
---|
1324 | else
|
---|
1325 | strVersion = strGAVersion;
|
---|
1326 | return fSuccess;
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | bool UISession::acquireGuestAdditionsRevision(ulong &uRevision)
|
---|
1330 | {
|
---|
1331 | CGuest comGuest = guest();
|
---|
1332 | const ULONG uGARevision = comGuest.GetAdditionsRevision();
|
---|
1333 | const bool fSuccess = comGuest.isOk();
|
---|
1334 | if (!fSuccess)
|
---|
1335 | UINotificationMessage::cannotAcquireGuestParameter(comGuest);
|
---|
1336 | else
|
---|
1337 | uRevision = uGARevision;
|
---|
1338 | return fSuccess;
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 | bool UISession::acquireWhetherAudioAdapterPresent(bool &fPresent)
|
---|
1342 | {
|
---|
1343 | CMachine comMachine = machine();
|
---|
1344 | if (comMachine.isNull())
|
---|
1345 | return false;
|
---|
1346 | CAudioSettings comSettings = comMachine.GetAudioSettings();
|
---|
1347 | const bool fSuccess = comMachine.isOk();
|
---|
1348 | if (!fSuccess)
|
---|
1349 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1350 | else
|
---|
1351 | {
|
---|
1352 | CAudioAdapter comAdapter = comSettings.GetAdapter();
|
---|
1353 | fPresent = comSettings.isOk() && comAdapter.isNotNull();
|
---|
1354 | }
|
---|
1355 | return fSuccess;
|
---|
1356 | }
|
---|
1357 |
|
---|
1358 | bool UISession::acquireWhetherAudioAdapterEnabled(bool &fEnabled)
|
---|
1359 | {
|
---|
1360 | CMachine comMachine = machine();
|
---|
1361 | CAudioSettings comSettings = comMachine.GetAudioSettings();
|
---|
1362 | bool fSuccess = comMachine.isOk();
|
---|
1363 | if (!fSuccess)
|
---|
1364 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1365 | else
|
---|
1366 | {
|
---|
1367 | CAudioAdapter comAdapter = comSettings.GetAdapter();
|
---|
1368 | fSuccess = comSettings.isOk();
|
---|
1369 | if (!fSuccess)
|
---|
1370 | UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
|
---|
1371 | {
|
---|
1372 | const BOOL fAdapterEnabled = comAdapter.GetEnabled();
|
---|
1373 | fSuccess = comAdapter.isOk();
|
---|
1374 | if (!fSuccess)
|
---|
1375 | UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter);
|
---|
1376 | else
|
---|
1377 | fEnabled = fAdapterEnabled == TRUE;
|
---|
1378 | }
|
---|
1379 | }
|
---|
1380 | return fSuccess;
|
---|
1381 | }
|
---|
1382 |
|
---|
1383 | bool UISession::acquireWhetherAudioAdapterOutputEnabled(bool &fEnabled)
|
---|
1384 | {
|
---|
1385 | CMachine comMachine = machine();
|
---|
1386 | CAudioSettings comSettings = comMachine.GetAudioSettings();
|
---|
1387 | bool fSuccess = comMachine.isOk();
|
---|
1388 | if (!fSuccess)
|
---|
1389 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1390 | else
|
---|
1391 | {
|
---|
1392 | CAudioAdapter comAdapter = comSettings.GetAdapter();
|
---|
1393 | fSuccess = comSettings.isOk();
|
---|
1394 | if (!fSuccess)
|
---|
1395 | UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
|
---|
1396 | {
|
---|
1397 | const BOOL fOutputEnabled = comAdapter.GetEnabledOut();
|
---|
1398 | fSuccess = comAdapter.isOk();
|
---|
1399 | if (!fSuccess)
|
---|
1400 | UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter);
|
---|
1401 | else
|
---|
1402 | fEnabled = fOutputEnabled == TRUE;
|
---|
1403 | }
|
---|
1404 | }
|
---|
1405 | return fSuccess;
|
---|
1406 | }
|
---|
1407 |
|
---|
1408 | bool UISession::acquireWhetherAudioAdapterInputEnabled(bool &fEnabled)
|
---|
1409 | {
|
---|
1410 | CMachine comMachine = machine();
|
---|
1411 | CAudioSettings comSettings = comMachine.GetAudioSettings();
|
---|
1412 | bool fSuccess = comMachine.isOk();
|
---|
1413 | if (!fSuccess)
|
---|
1414 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1415 | else
|
---|
1416 | {
|
---|
1417 | CAudioAdapter comAdapter = comSettings.GetAdapter();
|
---|
1418 | fSuccess = comSettings.isOk();
|
---|
1419 | if (!fSuccess)
|
---|
1420 | UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
|
---|
1421 | {
|
---|
1422 | const BOOL fInputEnabled = comAdapter.GetEnabledIn();
|
---|
1423 | fSuccess = comAdapter.isOk();
|
---|
1424 | if (!fSuccess)
|
---|
1425 | UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter);
|
---|
1426 | else
|
---|
1427 | fEnabled = fInputEnabled == TRUE;
|
---|
1428 | }
|
---|
1429 | }
|
---|
1430 | return fSuccess;
|
---|
1431 | }
|
---|
1432 |
|
---|
1433 | bool UISession::setAudioAdapterOutputEnabled(bool fEnabled)
|
---|
1434 | {
|
---|
1435 | CMachine comMachine = machine();
|
---|
1436 | CAudioSettings comSettings = comMachine.GetAudioSettings();
|
---|
1437 | bool fSuccess = comMachine.isOk();
|
---|
1438 | if (!fSuccess)
|
---|
1439 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1440 | else
|
---|
1441 | {
|
---|
1442 | CAudioAdapter comAdapter = comSettings.GetAdapter();
|
---|
1443 | fSuccess = comSettings.isOk();
|
---|
1444 | if (!fSuccess)
|
---|
1445 | UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings);
|
---|
1446 | {
|
---|
1447 | comAdapter.SetEnabledOut(fEnabled);
|
---|
1448 | fSuccess = comAdapter.isOk();
|
---|
1449 | if (!fSuccess)
|
---|
1450 | UINotificationMessage::cannotToggleAudioOutput(comAdapter, machineName(), fEnabled);
|
---|
1451 | }
|
---|
1452 | }
|
---|
1453 | return fSuccess;
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | bool UISession::setAudioAdapterInputEnabled(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.SetEnabledIn(fEnabled);
|
---|
1471 | fSuccess = comAdapter.isOk();
|
---|
1472 | if (!fSuccess)
|
---|
1473 | UINotificationMessage::cannotToggleAudioInput(comAdapter, machineName(), fEnabled);
|
---|
1474 | }
|
---|
1475 | }
|
---|
1476 | return fSuccess;
|
---|
1477 | }
|
---|
1478 |
|
---|
1479 | UIFrameBuffer *UISession::frameBuffer(ulong uScreenId) const
|
---|
1480 | {
|
---|
1481 | return m_frameBufferVector.value((int)uScreenId, 0);
|
---|
1482 | }
|
---|
1483 |
|
---|
1484 | QSize UISession::frameBufferSize(ulong uScreenId) const
|
---|
1485 | {
|
---|
1486 | UIFrameBuffer *pFramebuffer = frameBuffer(uScreenId);
|
---|
1487 | return pFramebuffer ? QSize(pFramebuffer->width(), pFramebuffer->height()) : QSize();
|
---|
1488 | }
|
---|
1489 |
|
---|
1490 | bool UISession::acquireGraphicsControllerType(KGraphicsControllerType &enmType)
|
---|
1491 | {
|
---|
1492 | CMachine comMachine = machine();
|
---|
1493 | CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
|
---|
1494 | bool fSuccess = comMachine.isOk();
|
---|
1495 | if (!fSuccess)
|
---|
1496 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1497 | else
|
---|
1498 | {
|
---|
1499 | const KGraphicsControllerType enmControllerType = comAdapter.GetGraphicsControllerType();
|
---|
1500 | fSuccess = comAdapter.isOk();
|
---|
1501 | if (!fSuccess)
|
---|
1502 | UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
|
---|
1503 | else
|
---|
1504 | enmType = enmControllerType;
|
---|
1505 | }
|
---|
1506 | return fSuccess;
|
---|
1507 | }
|
---|
1508 |
|
---|
1509 | bool UISession::acquireVRAMSize(ulong &uSize)
|
---|
1510 | {
|
---|
1511 | CMachine comMachine = machine();
|
---|
1512 | CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
|
---|
1513 | bool fSuccess = comMachine.isOk();
|
---|
1514 | if (!fSuccess)
|
---|
1515 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1516 | else
|
---|
1517 | {
|
---|
1518 | const ULONG uVRAMSize = comAdapter.GetVRAMSize();
|
---|
1519 | fSuccess = comAdapter.isOk();
|
---|
1520 | if (!fSuccess)
|
---|
1521 | UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
|
---|
1522 | else
|
---|
1523 | uSize = uVRAMSize;
|
---|
1524 | }
|
---|
1525 | return fSuccess;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | bool UISession::acquireWhetherAccelerate3DEnabled(bool &fEnabled)
|
---|
1529 | {
|
---|
1530 | CMachine comMachine = machine();
|
---|
1531 | CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
|
---|
1532 | bool fSuccess = comMachine.isOk();
|
---|
1533 | if (!fSuccess)
|
---|
1534 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1535 | else
|
---|
1536 | {
|
---|
1537 | const BOOL fAccelerate3DEnabeld = comAdapter.GetAccelerate3DEnabled();
|
---|
1538 | fSuccess = comAdapter.isOk();
|
---|
1539 | if (!fSuccess)
|
---|
1540 | UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
|
---|
1541 | else
|
---|
1542 | fEnabled = fAccelerate3DEnabeld == TRUE;
|
---|
1543 | }
|
---|
1544 | return fSuccess;
|
---|
1545 | }
|
---|
1546 |
|
---|
1547 | bool UISession::acquireMonitorCount(ulong &uCount)
|
---|
1548 | {
|
---|
1549 | // WORKAROUND:
|
---|
1550 | // We certainly don't want to get into
|
---|
1551 | // 'no visible screens' case if something
|
---|
1552 | // gone wrong... Inventing sane default.
|
---|
1553 | uCount = 1;
|
---|
1554 |
|
---|
1555 | CMachine comMachine = machine();
|
---|
1556 | if (comMachine.isNull())
|
---|
1557 | return false;
|
---|
1558 | CGraphicsAdapter comAdapter = comMachine.GetGraphicsAdapter();
|
---|
1559 | bool fSuccess = comMachine.isOk();
|
---|
1560 | if (!fSuccess)
|
---|
1561 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1562 | else
|
---|
1563 | {
|
---|
1564 | const ULONG uMonitorCount = comAdapter.GetMonitorCount();
|
---|
1565 | fSuccess = comAdapter.isOk();
|
---|
1566 | if (!fSuccess)
|
---|
1567 | UINotificationMessage::cannotAcquireGraphicsAdapterParameter(comAdapter);
|
---|
1568 | else
|
---|
1569 | uCount = uMonitorCount;
|
---|
1570 | }
|
---|
1571 | return fSuccess;
|
---|
1572 | }
|
---|
1573 |
|
---|
1574 | bool UISession::acquireGuestScreenParameters(ulong uScreenId,
|
---|
1575 | ulong &uWidth, ulong &uHeight, ulong &uBitsPerPixel,
|
---|
1576 | long &xOrigin, long &yOrigin, KGuestMonitorStatus &enmMonitorStatus)
|
---|
1577 | {
|
---|
1578 | CDisplay comDisplay = display();
|
---|
1579 | ULONG uGuestWidth = 0, uGuestHeight = 0, uGuestBitsPerPixel = 0;
|
---|
1580 | LONG iGuestXOrigin = 0, iGuestYOrigin = 0;
|
---|
1581 | KGuestMonitorStatus enmGuestMonitorStatus = KGuestMonitorStatus_Disabled;
|
---|
1582 | comDisplay.GetScreenResolution(uScreenId, uGuestWidth, uGuestHeight, uGuestBitsPerPixel,
|
---|
1583 | iGuestXOrigin, iGuestYOrigin, enmGuestMonitorStatus);
|
---|
1584 | const bool fSuccess = comDisplay.isOk();
|
---|
1585 | if (!fSuccess)
|
---|
1586 | UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
|
---|
1587 | else
|
---|
1588 | {
|
---|
1589 | uWidth = uGuestWidth;
|
---|
1590 | uHeight = uGuestHeight;
|
---|
1591 | uBitsPerPixel = uGuestBitsPerPixel;
|
---|
1592 | xOrigin = iGuestXOrigin;
|
---|
1593 | yOrigin = iGuestYOrigin;
|
---|
1594 | enmMonitorStatus = enmGuestMonitorStatus;
|
---|
1595 | }
|
---|
1596 | return fSuccess;
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | bool UISession::acquireSavedGuestScreenInfo(ulong uScreenId,
|
---|
1600 | long &xOrigin, long &yOrigin,
|
---|
1601 | ulong &uWidth, ulong &uHeight, bool &fEnabled)
|
---|
1602 | {
|
---|
1603 | CMachine comMachine = machine();
|
---|
1604 | ULONG uGuestXOrigin = 0, uGuestYOrigin = 0, uGuestWidth = 0, uGuestHeight = 0;
|
---|
1605 | BOOL fGuestEnabled = FALSE;
|
---|
1606 | comMachine.QuerySavedGuestScreenInfo(uScreenId, uGuestXOrigin, uGuestYOrigin, uGuestWidth, uGuestHeight, fGuestEnabled);
|
---|
1607 | const bool fSuccess = comMachine.isOk();
|
---|
1608 | if (!fSuccess)
|
---|
1609 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1610 | else
|
---|
1611 | {
|
---|
1612 | xOrigin = uGuestXOrigin;
|
---|
1613 | yOrigin = uGuestYOrigin;
|
---|
1614 | uWidth = uGuestWidth;
|
---|
1615 | uHeight = uGuestHeight;
|
---|
1616 | fEnabled = fGuestEnabled == TRUE;
|
---|
1617 | }
|
---|
1618 | return fSuccess;
|
---|
1619 | }
|
---|
1620 |
|
---|
1621 | bool UISession::setVideoModeHint(ulong uScreenId, bool fEnabled, bool fChangeOrigin, long xOrigin, long yOrigin,
|
---|
1622 | ulong uWidth, ulong uHeight, ulong uBitsPerPixel, bool fNotify)
|
---|
1623 | {
|
---|
1624 | CDisplay comDisplay = display();
|
---|
1625 | comDisplay.SetVideoModeHint(uScreenId, fEnabled, fChangeOrigin, xOrigin, yOrigin,
|
---|
1626 | uWidth, uHeight, uBitsPerPixel, fNotify);
|
---|
1627 | const bool fSuccess = comDisplay.isOk();
|
---|
1628 | if (!fSuccess)
|
---|
1629 | UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
|
---|
1630 | return fSuccess;
|
---|
1631 | }
|
---|
1632 |
|
---|
1633 | bool UISession::acquireVideoModeHint(ulong uScreenId, bool &fEnabled, bool &fChangeOrigin,
|
---|
1634 | long &xOrigin, long &yOrigin, ulong &uWidth, ulong &uHeight,
|
---|
1635 | ulong &uBitsPerPixel)
|
---|
1636 | {
|
---|
1637 | CDisplay comDisplay = display();
|
---|
1638 | BOOL fGuestEnabled = FALSE, fGuestChangeOrigin = FALSE;
|
---|
1639 | LONG iGuestXOrigin = 0, iGuestYOrigin = 0;
|
---|
1640 | ULONG uGuestWidth = 0, uGuestHeight = 0, uGuestBitsPerPixel = 0;
|
---|
1641 | comDisplay.GetVideoModeHint(uScreenId, fGuestEnabled, fGuestChangeOrigin,
|
---|
1642 | iGuestXOrigin, iGuestYOrigin, uGuestWidth, uGuestHeight,
|
---|
1643 | uGuestBitsPerPixel);
|
---|
1644 | const bool fSuccess = comDisplay.isOk();
|
---|
1645 | if (!fSuccess)
|
---|
1646 | UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
|
---|
1647 | else
|
---|
1648 | {
|
---|
1649 | fEnabled = fGuestEnabled == TRUE;
|
---|
1650 | fChangeOrigin = fGuestChangeOrigin == TRUE;
|
---|
1651 | xOrigin = iGuestXOrigin;
|
---|
1652 | yOrigin = iGuestYOrigin;
|
---|
1653 | uWidth = uGuestWidth;
|
---|
1654 | uHeight = uGuestHeight;
|
---|
1655 | uBitsPerPixel = uGuestBitsPerPixel;
|
---|
1656 | }
|
---|
1657 | return fSuccess;
|
---|
1658 | }
|
---|
1659 |
|
---|
1660 | bool UISession::acquireScreenShot(ulong uScreenId, ulong uWidth, ulong uHeight, KBitmapFormat enmFormat, uchar *pBits)
|
---|
1661 | {
|
---|
1662 | CDisplay comDisplay = display();
|
---|
1663 | bool fSuccess = false;
|
---|
1664 | /* For separate process: */
|
---|
1665 | if (uiCommon().isSeparateProcess())
|
---|
1666 | {
|
---|
1667 | /* Take screen-data to array first: */
|
---|
1668 | const QVector<BYTE> screenData = comDisplay.TakeScreenShotToArray(uScreenId, uWidth, uHeight, enmFormat);
|
---|
1669 | fSuccess = comDisplay.isOk();
|
---|
1670 | if (!fSuccess)
|
---|
1671 | UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
|
---|
1672 | else
|
---|
1673 | {
|
---|
1674 | /* And copy that data to screen-shot if it is Ok: */
|
---|
1675 | if (!screenData.isEmpty())
|
---|
1676 | memcpy(pBits, screenData.data(), uWidth * uHeight * 4);
|
---|
1677 | }
|
---|
1678 | }
|
---|
1679 | /* For the same process: */
|
---|
1680 | else
|
---|
1681 | {
|
---|
1682 | /* Take the screen-shot directly: */
|
---|
1683 | comDisplay.TakeScreenShot(uScreenId, pBits, uWidth, uHeight, enmFormat);
|
---|
1684 | fSuccess = comDisplay.isOk();
|
---|
1685 | if (!fSuccess)
|
---|
1686 | UINotificationMessage::cannotAcquireDisplayParameter(comDisplay);
|
---|
1687 | }
|
---|
1688 | return fSuccess;
|
---|
1689 | }
|
---|
1690 |
|
---|
1691 | bool UISession::acquireSavedScreenshotInfo(ulong uScreenId, ulong &uWidth, ulong &uHeight, QVector<KBitmapFormat> &formats)
|
---|
1692 | {
|
---|
1693 | CMachine comMachine = machine();
|
---|
1694 | ULONG uGuestWidth = 0, uGuestHeight = 0;
|
---|
1695 | QVector<KBitmapFormat> guestFormats = comMachine.QuerySavedScreenshotInfo(uScreenId, uGuestWidth, uGuestHeight);
|
---|
1696 | const bool fSuccess = comMachine.isOk();
|
---|
1697 | if (!fSuccess)
|
---|
1698 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1699 | else
|
---|
1700 | {
|
---|
1701 | uWidth = uGuestWidth;
|
---|
1702 | uHeight = uGuestHeight;
|
---|
1703 | formats = guestFormats;
|
---|
1704 | }
|
---|
1705 | return fSuccess;
|
---|
1706 | }
|
---|
1707 |
|
---|
1708 | bool UISession::acquireSavedScreenshot(ulong uScreenId, KBitmapFormat enmFormat,
|
---|
1709 | ulong &uWidth, ulong &uHeight, QVector<BYTE> &screenshot)
|
---|
1710 | {
|
---|
1711 | CMachine comMachine = machine();
|
---|
1712 | ULONG uGuestWidth = 0, uGuestHeight = 0;
|
---|
1713 | const QVector<BYTE> guestScreenshot = comMachine.ReadSavedScreenshotToArray(uScreenId, enmFormat,
|
---|
1714 | uGuestWidth, uGuestHeight);
|
---|
1715 | const bool fSuccess = comMachine.isOk();
|
---|
1716 | if (!fSuccess)
|
---|
1717 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1718 | else
|
---|
1719 | {
|
---|
1720 | uWidth = uGuestWidth;
|
---|
1721 | uHeight = uGuestHeight;
|
---|
1722 | screenshot = guestScreenshot;
|
---|
1723 | }
|
---|
1724 | return fSuccess;
|
---|
1725 | }
|
---|
1726 |
|
---|
1727 | bool UISession::notifyScaleFactorChange(ulong uScreenId, ulong uScaleFactorWMultiplied, ulong uScaleFactorHMultiplied)
|
---|
1728 | {
|
---|
1729 | CDisplay comDisplay = display();
|
---|
1730 | comDisplay.NotifyScaleFactorChange(uScreenId, uScaleFactorWMultiplied, uScaleFactorHMultiplied);
|
---|
1731 | const bool fSuccess = comDisplay.isOk();
|
---|
1732 | if (!fSuccess)
|
---|
1733 | UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
|
---|
1734 | return fSuccess;
|
---|
1735 | }
|
---|
1736 |
|
---|
1737 | bool UISession::notifyHiDPIOutputPolicyChange(bool fUnscaledHiDPI)
|
---|
1738 | {
|
---|
1739 | CDisplay comDisplay = display();
|
---|
1740 | comDisplay.NotifyHiDPIOutputPolicyChange(fUnscaledHiDPI);
|
---|
1741 | const bool fSuccess = comDisplay.isOk();
|
---|
1742 | if (!fSuccess)
|
---|
1743 | UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
|
---|
1744 | return fSuccess;
|
---|
1745 | }
|
---|
1746 |
|
---|
1747 | bool UISession::setSeamlessMode(bool fEnabled)
|
---|
1748 | {
|
---|
1749 | CDisplay comDisplay = display();
|
---|
1750 | comDisplay.SetSeamlessMode(fEnabled);
|
---|
1751 | const bool fSuccess = comDisplay.isOk();
|
---|
1752 | if (!fSuccess)
|
---|
1753 | UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
|
---|
1754 | return fSuccess;
|
---|
1755 | }
|
---|
1756 |
|
---|
1757 | bool UISession::viewportChanged(ulong uScreenId, ulong xOrigin, ulong yOrigin, ulong uWidth, ulong uHeight)
|
---|
1758 | {
|
---|
1759 | CDisplay comDisplay = display();
|
---|
1760 | if (comDisplay.isNull())
|
---|
1761 | return false;
|
---|
1762 | comDisplay.ViewportChanged(uScreenId, xOrigin, yOrigin, uWidth, uHeight);
|
---|
1763 | const bool fSuccess = comDisplay.isOk();
|
---|
1764 | if (!fSuccess)
|
---|
1765 | UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
|
---|
1766 | return fSuccess;
|
---|
1767 | }
|
---|
1768 |
|
---|
1769 | bool UISession::invalidateAndUpdate()
|
---|
1770 | {
|
---|
1771 | CDisplay comDisplay = display();
|
---|
1772 | comDisplay.InvalidateAndUpdate();
|
---|
1773 | const bool fSuccess = comDisplay.isOk();
|
---|
1774 | if (!fSuccess)
|
---|
1775 | UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
|
---|
1776 | return fSuccess;
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | bool UISession::invalidateAndUpdateScreen(ulong uScreenId)
|
---|
1780 | {
|
---|
1781 | CDisplay comDisplay = display();
|
---|
1782 | comDisplay.InvalidateAndUpdateScreen(uScreenId);
|
---|
1783 | const bool fSuccess = comDisplay.isOk();
|
---|
1784 | if (!fSuccess)
|
---|
1785 | UINotificationMessage::cannotChangeDisplayParameter(comDisplay);
|
---|
1786 | return fSuccess;
|
---|
1787 | }
|
---|
1788 |
|
---|
1789 | bool UISession::acquireWhetherVRDEServerPresent(bool &fPresent)
|
---|
1790 | {
|
---|
1791 | CMachine comMachine = machine();
|
---|
1792 | if (comMachine.isNull())
|
---|
1793 | return false;
|
---|
1794 | CVRDEServer comServer = comMachine.GetVRDEServer();
|
---|
1795 | fPresent = comMachine.isOk() && comServer.isNotNull();
|
---|
1796 | return true;
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 | bool UISession::acquireWhetherVRDEServerEnabled(bool &fEnabled)
|
---|
1800 | {
|
---|
1801 | CMachine comMachine = machine();
|
---|
1802 | CVRDEServer comServer = comMachine.GetVRDEServer();
|
---|
1803 | bool fSuccess = comMachine.isOk();
|
---|
1804 | if (!fSuccess)
|
---|
1805 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1806 | else
|
---|
1807 | {
|
---|
1808 | const BOOL fServerEnabled = comServer.GetEnabled();
|
---|
1809 | fSuccess = comServer.isOk();
|
---|
1810 | if (!fSuccess)
|
---|
1811 | UINotificationMessage::cannotAcquireVRDEServerParameter(comServer);
|
---|
1812 | else
|
---|
1813 | fEnabled = fServerEnabled == TRUE;
|
---|
1814 | }
|
---|
1815 | return fSuccess;
|
---|
1816 | }
|
---|
1817 |
|
---|
1818 | bool UISession::setVRDEServerEnabled(bool fEnabled)
|
---|
1819 | {
|
---|
1820 | CMachine comMachine = machine();
|
---|
1821 | CVRDEServer comServer = comMachine.GetVRDEServer();
|
---|
1822 | bool fSuccess = comMachine.isOk();
|
---|
1823 | if (!fSuccess)
|
---|
1824 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1825 | else
|
---|
1826 | {
|
---|
1827 | comServer.SetEnabled(fEnabled);
|
---|
1828 | fSuccess = comServer.isOk();
|
---|
1829 | if (!fSuccess)
|
---|
1830 | UINotificationMessage::cannotToggleVRDEServer(comServer, machineName(), fEnabled);
|
---|
1831 | }
|
---|
1832 | return fSuccess;
|
---|
1833 | }
|
---|
1834 |
|
---|
1835 | bool UISession::acquireVRDEServerPort(long &iPort)
|
---|
1836 | {
|
---|
1837 | CConsole comConsole = console();
|
---|
1838 | const CVRDEServerInfo comVRDEServerInfo = comConsole.GetVRDEServerInfo();
|
---|
1839 | bool fSuccess = comConsole.isOk();
|
---|
1840 | if (!fSuccess)
|
---|
1841 | UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
|
---|
1842 | else
|
---|
1843 | {
|
---|
1844 | const LONG iVRDEPort = comVRDEServerInfo.GetPort();
|
---|
1845 | fSuccess = comVRDEServerInfo.isOk();
|
---|
1846 | if (!fSuccess)
|
---|
1847 | UINotificationMessage::cannotAcquireVRDEServerInfoParameter(comVRDEServerInfo);
|
---|
1848 | else
|
---|
1849 | iPort = iVRDEPort;
|
---|
1850 | }
|
---|
1851 | return fSuccess;
|
---|
1852 | }
|
---|
1853 |
|
---|
1854 | bool UISession::acquireWhetherRecordingSettingsPresent(bool &fPresent)
|
---|
1855 | {
|
---|
1856 | CMachine comMachine = machine();
|
---|
1857 | CRecordingSettings comSettings = comMachine.GetRecordingSettings();
|
---|
1858 | fPresent = comMachine.isOk() && comSettings.isNotNull();
|
---|
1859 | return true;
|
---|
1860 | }
|
---|
1861 |
|
---|
1862 | bool UISession::acquireWhetherRecordingSettingsEnabled(bool &fEnabled)
|
---|
1863 | {
|
---|
1864 | CMachine comMachine = machine();
|
---|
1865 | CRecordingSettings comSettings = comMachine.GetRecordingSettings();
|
---|
1866 | bool fSuccess = comMachine.isOk();
|
---|
1867 | if (!fSuccess)
|
---|
1868 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1869 | else
|
---|
1870 | {
|
---|
1871 | const BOOL fSettingsEnabled = comSettings.GetEnabled();
|
---|
1872 | fSuccess = comSettings.isOk();
|
---|
1873 | if (!fSuccess)
|
---|
1874 | UINotificationMessage::cannotAcquireRecordingSettingsParameter(comSettings);
|
---|
1875 | else
|
---|
1876 | fEnabled = fSettingsEnabled == TRUE;
|
---|
1877 | }
|
---|
1878 | return fSuccess;
|
---|
1879 | }
|
---|
1880 |
|
---|
1881 | bool UISession::setRecordingSettingsEnabled(bool fEnabled)
|
---|
1882 | {
|
---|
1883 | CMachine comMachine = machine();
|
---|
1884 | CRecordingSettings comSettings = comMachine.GetRecordingSettings();
|
---|
1885 | bool fSuccess = comMachine.isOk();
|
---|
1886 | if (!fSuccess)
|
---|
1887 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
1888 | else
|
---|
1889 | {
|
---|
1890 | comSettings.SetEnabled(fEnabled);
|
---|
1891 | fSuccess = comSettings.isOk();
|
---|
1892 | if (!fSuccess)
|
---|
1893 | UINotificationMessage::cannotToggleRecording(comSettings, machineName(), fEnabled);
|
---|
1894 | }
|
---|
1895 | return fSuccess;
|
---|
1896 | }
|
---|
1897 |
|
---|
1898 | bool UISession::acquireDeviceActivity(const QVector<KDeviceType> &deviceTypes, QVector<KDeviceActivity> &states)
|
---|
1899 | {
|
---|
1900 | CConsole comConsole = console();
|
---|
1901 | const QVector<KDeviceActivity> currentStates = comConsole.GetDeviceActivity(deviceTypes);
|
---|
1902 | const bool fSuccess = comConsole.isOk();
|
---|
1903 | if (!fSuccess)
|
---|
1904 | UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
|
---|
1905 | else
|
---|
1906 | states = currentStates;
|
---|
1907 | return fSuccess;
|
---|
1908 | }
|
---|
1909 |
|
---|
1910 | void UISession::acquireHardDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent)
|
---|
1911 | {
|
---|
1912 | CMachine comMachine = machine();
|
---|
1913 | if (comMachine.isNull())
|
---|
1914 | return;
|
---|
1915 | UIDetailsGenerator::acquireHardDiskStatusInfo(comMachine, strInfo, fAttachmentsPresent);
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 | void UISession::acquireOpticalDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
|
---|
1919 | {
|
---|
1920 | CMachine comMachine = machine();
|
---|
1921 | if (comMachine.isNull())
|
---|
1922 | return;
|
---|
1923 | UIDetailsGenerator::acquireOpticalDiskStatusInfo(comMachine, strInfo, fAttachmentsPresent, fAttachmentsMounted);
|
---|
1924 | }
|
---|
1925 |
|
---|
1926 | void UISession::acquireFloppyDiskStatusInfo(QString &strInfo, bool &fAttachmentsPresent, bool &fAttachmentsMounted)
|
---|
1927 | {
|
---|
1928 | CMachine comMachine = machine();
|
---|
1929 | if (comMachine.isNull())
|
---|
1930 | return;
|
---|
1931 | UIDetailsGenerator::acquireFloppyDiskStatusInfo(comMachine, strInfo, fAttachmentsPresent, fAttachmentsMounted);
|
---|
1932 | }
|
---|
1933 |
|
---|
1934 | void UISession::acquireAudioStatusInfo(QString &strInfo, bool &fAudioEnabled, bool &fEnabledOutput, bool &fEnabledInput)
|
---|
1935 | {
|
---|
1936 | CMachine comMachine = machine();
|
---|
1937 | if (comMachine.isNull())
|
---|
1938 | return;
|
---|
1939 | UIDetailsGenerator::acquireAudioStatusInfo(comMachine, strInfo, fAudioEnabled, fEnabledOutput, fEnabledInput);
|
---|
1940 | }
|
---|
1941 |
|
---|
1942 | void UISession::acquireNetworkStatusInfo(QString &strInfo, bool &fAdaptersPresent, bool &fCablesDisconnected)
|
---|
1943 | {
|
---|
1944 | CMachine comMachine = machine();
|
---|
1945 | if (comMachine.isNull())
|
---|
1946 | return;
|
---|
1947 | UIDetailsGenerator::acquireNetworkStatusInfo(comMachine, strInfo, fAdaptersPresent, fCablesDisconnected);
|
---|
1948 | }
|
---|
1949 |
|
---|
1950 | void UISession::acquireUsbStatusInfo(QString &strInfo, bool &fUsbEnableds)
|
---|
1951 | {
|
---|
1952 | CMachine comMachine = machine();
|
---|
1953 | if (comMachine.isNull())
|
---|
1954 | return;
|
---|
1955 | CConsole comConsole = console();
|
---|
1956 | if (comConsole.isNull())
|
---|
1957 | return;
|
---|
1958 | UIDetailsGenerator::acquireUsbStatusInfo(comMachine, comConsole, strInfo, fUsbEnableds);
|
---|
1959 | }
|
---|
1960 |
|
---|
1961 | void UISession::acquireSharedFoldersStatusInfo(QString &strInfo, bool &fFoldersPresent)
|
---|
1962 | {
|
---|
1963 | CMachine comMachine = machine();
|
---|
1964 | if (comMachine.isNull())
|
---|
1965 | return;
|
---|
1966 | CConsole comConsole = console();
|
---|
1967 | if (comConsole.isNull())
|
---|
1968 | return;
|
---|
1969 | CGuest comGuest = guest();
|
---|
1970 | if (comGuest.isNull())
|
---|
1971 | return;
|
---|
1972 | UIDetailsGenerator::acquireSharedFoldersStatusInfo(comMachine, comConsole, comGuest, strInfo, fFoldersPresent);
|
---|
1973 | }
|
---|
1974 |
|
---|
1975 | void UISession::acquireDisplayStatusInfo(QString &strInfo, bool &fAcceleration3D)
|
---|
1976 | {
|
---|
1977 | CMachine comMachine = machine();
|
---|
1978 | if (comMachine.isNull())
|
---|
1979 | return;
|
---|
1980 | UIDetailsGenerator::acquireDisplayStatusInfo(comMachine, strInfo, fAcceleration3D);
|
---|
1981 | }
|
---|
1982 |
|
---|
1983 | void UISession::acquireRecordingStatusInfo(QString &strInfo, bool &fRecordingEnabled, bool &fMachinePaused)
|
---|
1984 | {
|
---|
1985 | CMachine comMachine = machine();
|
---|
1986 | if (comMachine.isNull())
|
---|
1987 | return;
|
---|
1988 | fMachinePaused = isPaused();
|
---|
1989 | UIDetailsGenerator::acquireRecordingStatusInfo(comMachine, strInfo, fRecordingEnabled);
|
---|
1990 | }
|
---|
1991 |
|
---|
1992 | void UISession::acquireFeaturesStatusInfo(QString &strInfo, KVMExecutionEngine &enmEngine,
|
---|
1993 | bool fNestedPagingEnabled, bool fUxEnabled,
|
---|
1994 | KParavirtProvider enmProvider)
|
---|
1995 | {
|
---|
1996 | CMachine comMachine = machine();
|
---|
1997 | if (comMachine.isNull())
|
---|
1998 | return;
|
---|
1999 | UIDetailsGenerator::acquireFeaturesStatusInfo(comMachine, strInfo,
|
---|
2000 | enmEngine,
|
---|
2001 | fNestedPagingEnabled, fUxEnabled,
|
---|
2002 | enmProvider);
|
---|
2003 | }
|
---|
2004 |
|
---|
2005 | void UISession::generateMachineInformationGeneral(const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &fOptions,
|
---|
2006 | UITextTable &returnTable)
|
---|
2007 | {
|
---|
2008 | CMachine comMachine = machine();
|
---|
2009 | returnTable = UIDetailsGenerator::generateMachineInformationGeneral(comMachine, fOptions);
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | void UISession::generateMachineInformationSystem(const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem &fOptions,
|
---|
2013 | UITextTable &returnTable)
|
---|
2014 | {
|
---|
2015 | CMachine comMachine = machine();
|
---|
2016 | returnTable = UIDetailsGenerator::generateMachineInformationSystem(comMachine, fOptions);
|
---|
2017 | }
|
---|
2018 |
|
---|
2019 | void UISession::generateMachineInformationDisplay(const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay &fOptions,
|
---|
2020 | UITextTable &returnTable)
|
---|
2021 | {
|
---|
2022 | CMachine comMachine = machine();
|
---|
2023 | returnTable = UIDetailsGenerator::generateMachineInformationDisplay(comMachine, fOptions);
|
---|
2024 | }
|
---|
2025 |
|
---|
2026 | void UISession::generateMachineInformationStorage(const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage &fOptions,
|
---|
2027 | UITextTable &returnTable)
|
---|
2028 | {
|
---|
2029 | CMachine comMachine = machine();
|
---|
2030 | returnTable = UIDetailsGenerator::generateMachineInformationStorage(comMachine, fOptions);
|
---|
2031 | }
|
---|
2032 |
|
---|
2033 | void UISession::generateMachineInformationAudio(const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio &fOptions,
|
---|
2034 | UITextTable &returnTable)
|
---|
2035 | {
|
---|
2036 | CMachine comMachine = machine();
|
---|
2037 | returnTable = UIDetailsGenerator::generateMachineInformationAudio(comMachine, fOptions);
|
---|
2038 | }
|
---|
2039 |
|
---|
2040 | void UISession::generateMachineInformationNetwork(const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork &fOptions,
|
---|
2041 | UITextTable &returnTable)
|
---|
2042 | {
|
---|
2043 | CMachine comMachine = machine();
|
---|
2044 | returnTable = UIDetailsGenerator::generateMachineInformationNetwork(comMachine, fOptions);
|
---|
2045 | }
|
---|
2046 | void UISession::generateMachineInformationSerial(const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial &fOptions,
|
---|
2047 | UITextTable &returnTable)
|
---|
2048 | {
|
---|
2049 | CMachine comMachine = machine();
|
---|
2050 | returnTable = UIDetailsGenerator::generateMachineInformationSerial(comMachine, fOptions);
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | void UISession::generateMachineInformationUSB(const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb &fOptions,
|
---|
2054 | UITextTable &returnTable)
|
---|
2055 | {
|
---|
2056 | CMachine comMachine = machine();
|
---|
2057 | returnTable = UIDetailsGenerator::generateMachineInformationUSB(comMachine, fOptions);
|
---|
2058 | }
|
---|
2059 |
|
---|
2060 | void UISession::generateMachineInformationSharedFolders(const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders &fOptions,
|
---|
2061 | UITextTable &returnTable)
|
---|
2062 | {
|
---|
2063 | CMachine comMachine = machine();
|
---|
2064 | returnTable = UIDetailsGenerator::generateMachineInformationSharedFolders(comMachine, fOptions);
|
---|
2065 | }
|
---|
2066 |
|
---|
2067 | bool UISession::setLogEnabled(bool fEnabled)
|
---|
2068 | {
|
---|
2069 | CMachineDebugger comDebugger = debugger();
|
---|
2070 | comDebugger.SetLogEnabled(fEnabled ? TRUE : FALSE);
|
---|
2071 | const bool fSuccess = comDebugger.isOk();
|
---|
2072 | if (!fSuccess)
|
---|
2073 | UINotificationMessage::cannotChangeMachineDebuggerParameter(comDebugger);
|
---|
2074 | return fSuccess;
|
---|
2075 | }
|
---|
2076 |
|
---|
2077 | bool UISession::acquireWhetherLogEnabled(bool &fEnabled)
|
---|
2078 | {
|
---|
2079 | CMachineDebugger comDebugger = debugger();
|
---|
2080 | if (comDebugger.isNull())
|
---|
2081 | return false;
|
---|
2082 | const BOOL fLogEnabled = comDebugger.GetLogEnabled();
|
---|
2083 | const bool fSuccess = comDebugger.isOk();
|
---|
2084 | if (!fSuccess)
|
---|
2085 | UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
|
---|
2086 | else
|
---|
2087 | fEnabled = fLogEnabled == TRUE;
|
---|
2088 | return fSuccess;
|
---|
2089 | }
|
---|
2090 |
|
---|
2091 | bool UISession::acquireLogFolder(QString &strFolder)
|
---|
2092 | {
|
---|
2093 | CMachine comMachine = machine();
|
---|
2094 | const QString strLogFolder = comMachine.GetLogFolder();
|
---|
2095 | const bool fSuccess = comMachine.isOk();
|
---|
2096 | if (!fSuccess)
|
---|
2097 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
2098 | else
|
---|
2099 | strFolder = strLogFolder;
|
---|
2100 | return fSuccess;
|
---|
2101 | }
|
---|
2102 |
|
---|
2103 | bool UISession::acquireEffectiveParavirtProvider(KParavirtProvider &enmProvider)
|
---|
2104 | {
|
---|
2105 | CMachine comMachine = machine();
|
---|
2106 | if (comMachine.isNull())
|
---|
2107 | return false;
|
---|
2108 | const KParavirtProvider enmParavirtProvider = comMachine.GetEffectiveParavirtProvider();
|
---|
2109 | const bool fSuccess = comMachine.isOk();
|
---|
2110 | if (!fSuccess)
|
---|
2111 | UINotificationMessage::cannotAcquireMachineParameter(comMachine);
|
---|
2112 | else
|
---|
2113 | enmProvider = enmParavirtProvider;
|
---|
2114 | return fSuccess;
|
---|
2115 | }
|
---|
2116 |
|
---|
2117 | bool UISession::acquireExecutionEngineType(KVMExecutionEngine &enmType)
|
---|
2118 | {
|
---|
2119 | CMachineDebugger comDebugger = debugger();
|
---|
2120 | if (comDebugger.isNull())
|
---|
2121 | return false;
|
---|
2122 | const KVMExecutionEngine enmEngineType = comDebugger.GetExecutionEngine();
|
---|
2123 | const bool fSuccess = comDebugger.isOk();
|
---|
2124 | if (!fSuccess)
|
---|
2125 | UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
|
---|
2126 | else
|
---|
2127 | enmType = enmEngineType;
|
---|
2128 | return fSuccess;
|
---|
2129 | }
|
---|
2130 |
|
---|
2131 | bool UISession::acquireWhetherHwVirtExNestedPagingEnabled(bool &fEnabled)
|
---|
2132 | {
|
---|
2133 | CMachineDebugger comDebugger = debugger();
|
---|
2134 | if (comDebugger.isNull())
|
---|
2135 | return false;
|
---|
2136 | const BOOL fFeatureEnabled = comDebugger.GetHWVirtExNestedPagingEnabled();
|
---|
2137 | const bool fSuccess = comDebugger.isOk();
|
---|
2138 | if (!fSuccess)
|
---|
2139 | UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
|
---|
2140 | else
|
---|
2141 | fEnabled = fFeatureEnabled == TRUE;
|
---|
2142 | return fSuccess;
|
---|
2143 | }
|
---|
2144 |
|
---|
2145 | bool UISession::acquireWhetherHwVirtExUXEnabled(bool &fEnabled)
|
---|
2146 | {
|
---|
2147 | CMachineDebugger comDebugger = debugger();
|
---|
2148 | if (comDebugger.isNull())
|
---|
2149 | return false;
|
---|
2150 | const BOOL fFeatureEnabled = comDebugger.GetHWVirtExUXEnabled();
|
---|
2151 | const bool fSuccess = comDebugger.isOk();
|
---|
2152 | if (!fSuccess)
|
---|
2153 | UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
|
---|
2154 | else
|
---|
2155 | fEnabled = fFeatureEnabled == TRUE;
|
---|
2156 | return fSuccess;
|
---|
2157 | }
|
---|
2158 |
|
---|
2159 | bool UISession::acquireEffectiveCPULoad(ulong &uLoad)
|
---|
2160 | {
|
---|
2161 | CMachineDebugger comDebugger = debugger();
|
---|
2162 | ULONG uPctExecuting;
|
---|
2163 | ULONG uPctHalted;
|
---|
2164 | ULONG uPctOther;
|
---|
2165 | comDebugger.GetCPULoad(0x7fffffff, uPctExecuting, uPctHalted, uPctOther);
|
---|
2166 | const bool fSuccess = comDebugger.isOk();
|
---|
2167 | if (!fSuccess)
|
---|
2168 | UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
|
---|
2169 | else
|
---|
2170 | uLoad = uPctExecuting + uPctOther;
|
---|
2171 | return fSuccess;
|
---|
2172 | }
|
---|
2173 |
|
---|
2174 | bool UISession::acquireUptime(LONG64 &iUpTime)
|
---|
2175 | {
|
---|
2176 | CMachineDebugger comDebugger = debugger();
|
---|
2177 | const LONG64 iGuestUpTime = comDebugger.GetUptime();
|
---|
2178 | const bool fSuccess = comDebugger.isOk();
|
---|
2179 | if (!fSuccess)
|
---|
2180 | UINotificationMessage::cannotAcquireMachineDebuggerParameter(comDebugger);
|
---|
2181 | else
|
---|
2182 | iUpTime = iGuestUpTime;
|
---|
2183 | return fSuccess;
|
---|
2184 | }
|
---|
2185 |
|
---|
2186 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
2187 | bool UISession::dbgCreated(void *pActionDebug)
|
---|
2188 | {
|
---|
2189 | if (m_pDbgGui)
|
---|
2190 | return true;
|
---|
2191 |
|
---|
2192 | RTLDRMOD hLdrMod = uiCommon().getDebuggerModule();
|
---|
2193 | if (hLdrMod == NIL_RTLDRMOD)
|
---|
2194 | return false;
|
---|
2195 |
|
---|
2196 | PFNDBGGUICREATE pfnGuiCreate;
|
---|
2197 | int rc = RTLdrGetSymbol(hLdrMod, "DBGGuiCreate", (void**)&pfnGuiCreate);
|
---|
2198 | if (RT_SUCCESS(rc))
|
---|
2199 | {
|
---|
2200 | ISession *pISession = session().raw();
|
---|
2201 | rc = pfnGuiCreate(pISession, &m_pDbgGui, &m_pDbgGuiVT);
|
---|
2202 | if (RT_SUCCESS(rc))
|
---|
2203 | {
|
---|
2204 | if ( DBGGUIVT_ARE_VERSIONS_COMPATIBLE(m_pDbgGuiVT->u32Version, DBGGUIVT_VERSION)
|
---|
2205 | || m_pDbgGuiVT->u32EndVersion == m_pDbgGuiVT->u32Version)
|
---|
2206 | {
|
---|
2207 | m_pDbgGuiVT->pfnSetParent(m_pDbgGui, activeMachineWindow());
|
---|
2208 | m_pDbgGuiVT->pfnSetMenu(m_pDbgGui, pActionDebug);
|
---|
2209 | dbgAdjustRelativePos();
|
---|
2210 | return true;
|
---|
2211 | }
|
---|
2212 |
|
---|
2213 | LogRel(("GUI: DBGGuiCreate failed, incompatible versions (loaded %#x/%#x, expected %#x)\n",
|
---|
2214 | m_pDbgGuiVT->u32Version, m_pDbgGuiVT->u32EndVersion, DBGGUIVT_VERSION));
|
---|
2215 | }
|
---|
2216 | else
|
---|
2217 | LogRel(("GUI: DBGGuiCreate failed, rc=%Rrc\n", rc));
|
---|
2218 | }
|
---|
2219 | else
|
---|
2220 | LogRel(("GUI: RTLdrGetSymbol(,\"DBGGuiCreate\",) -> %Rrc\n", rc));
|
---|
2221 |
|
---|
2222 | m_pDbgGui = 0;
|
---|
2223 | m_pDbgGuiVT = 0;
|
---|
2224 | return false;
|
---|
2225 | }
|
---|
2226 |
|
---|
2227 | void UISession::dbgDestroy()
|
---|
2228 | {
|
---|
2229 | if (m_pDbgGui)
|
---|
2230 | {
|
---|
2231 | m_pDbgGuiVT->pfnDestroy(m_pDbgGui);
|
---|
2232 | m_pDbgGui = 0;
|
---|
2233 | m_pDbgGuiVT = 0;
|
---|
2234 | }
|
---|
2235 | }
|
---|
2236 |
|
---|
2237 | void UISession::dbgShowStatistics()
|
---|
2238 | {
|
---|
2239 | const QByteArray &expandBytes = uiCommon().getDebuggerStatisticsExpand().toUtf8();
|
---|
2240 | const QByteArray &filterBytes = uiCommon().getDebuggerStatisticsFilter().toUtf8();
|
---|
2241 | m_pDbgGuiVT->pfnShowStatistics(m_pDbgGui, filterBytes.constData(), expandBytes.constData());
|
---|
2242 | }
|
---|
2243 |
|
---|
2244 | void UISession::dbgShowCommandLine()
|
---|
2245 | {
|
---|
2246 | m_pDbgGuiVT->pfnShowCommandLine(m_pDbgGui);
|
---|
2247 | }
|
---|
2248 |
|
---|
2249 | void UISession::dbgAdjustRelativePos()
|
---|
2250 | {
|
---|
2251 | if (m_pDbgGui)
|
---|
2252 | {
|
---|
2253 | const QRect rct = activeMachineWindow()->frameGeometry();
|
---|
2254 | m_pDbgGuiVT->pfnAdjustRelativePos(m_pDbgGui, rct.x(), rct.y(), rct.width(), rct.height());
|
---|
2255 | }
|
---|
2256 | }
|
---|
2257 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
2258 |
|
---|
2259 | bool UISession::acquireWhetherGuestEnteredACPIMode(bool &fEntered)
|
---|
2260 | {
|
---|
2261 | CConsole comConsole = console();
|
---|
2262 | const BOOL fGuestEntered = comConsole.GetGuestEnteredACPIMode();
|
---|
2263 | const bool fSuccess = comConsole.isOk();
|
---|
2264 | if (!fSuccess)
|
---|
2265 | UINotificationMessage::cannotAcquireConsoleParameter(comConsole);
|
---|
2266 | else
|
---|
2267 | fEntered = fGuestEntered == TRUE;
|
---|
2268 | return fSuccess;
|
---|
2269 | }
|
---|
2270 |
|
---|
2271 | void UISession::saveState()
|
---|
2272 | {
|
---|
2273 | if ( isPaused()
|
---|
2274 | || (isRunning() && pause()))
|
---|
2275 | {
|
---|
2276 | /* Enable 'manual-override',
|
---|
2277 | * preventing automatic Runtime UI closing: */
|
---|
2278 | uimachine()->setManualOverrideMode(true);
|
---|
2279 |
|
---|
2280 | /* Now, do the magic: */
|
---|
2281 | LogRel(("GUI: Saving VM state..\n"));
|
---|
2282 | UINotificationProgressMachineSaveState *pNotification =
|
---|
2283 | new UINotificationProgressMachineSaveState(machine());
|
---|
2284 | connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved,
|
---|
2285 | this, &UISession::sltHandleMachineStateSaved);
|
---|
2286 | gpNotificationCenter->append(pNotification);
|
---|
2287 | }
|
---|
2288 | }
|
---|
2289 |
|
---|
2290 | void UISession::shutdown()
|
---|
2291 | {
|
---|
2292 | /* Check whether guest is in proper mode: */
|
---|
2293 | bool fValidMode = false;
|
---|
2294 | acquireWhetherGuestEnteredACPIMode(fValidMode);
|
---|
2295 | if (!fValidMode)
|
---|
2296 | UINotificationMessage::cannotSendACPIToMachine();
|
---|
2297 | else
|
---|
2298 | {
|
---|
2299 | /* Now, do the magic: */
|
---|
2300 | LogRel(("GUI: Sending ACPI shutdown signal..\n"));
|
---|
2301 | CConsole comConsole = console();
|
---|
2302 | comConsole.PowerButton();
|
---|
2303 | if (!comConsole.isOk())
|
---|
2304 | UINotificationMessage::cannotACPIShutdownMachine(comConsole);
|
---|
2305 | }
|
---|
2306 | }
|
---|
2307 |
|
---|
2308 | void UISession::powerOff(bool fIncludingDiscard)
|
---|
2309 | {
|
---|
2310 | /* Enable 'manual-override',
|
---|
2311 | * preventing automatic Runtime UI closing: */
|
---|
2312 | uimachine()->setManualOverrideMode(true);
|
---|
2313 |
|
---|
2314 | /* Now, do the magic: */
|
---|
2315 | LogRel(("GUI: Powering VM off..\n"));
|
---|
2316 | UINotificationProgressMachinePowerOff *pNotification =
|
---|
2317 | new UINotificationProgressMachinePowerOff(machine(),
|
---|
2318 | console(),
|
---|
2319 | fIncludingDiscard);
|
---|
2320 | connect(pNotification, &UINotificationProgressMachinePowerOff::sigMachinePoweredOff,
|
---|
2321 | this, &UISession::sltHandleMachinePoweredOff);
|
---|
2322 | gpNotificationCenter->append(pNotification);
|
---|
2323 | }
|
---|
2324 |
|
---|
2325 | void UISession::sltInstallGuestAdditionsFrom(const QString &strSource)
|
---|
2326 | {
|
---|
2327 | if (!guestAdditionsUpgradable())
|
---|
2328 | return sltMountDVDAdHoc(strSource);
|
---|
2329 |
|
---|
2330 | /* Update guest additions automatically: */
|
---|
2331 | UINotificationProgressGuestAdditionsInstall *pNotification =
|
---|
2332 | new UINotificationProgressGuestAdditionsInstall(guest(), strSource);
|
---|
2333 | connect(pNotification, &UINotificationProgressGuestAdditionsInstall::sigGuestAdditionsInstallationFailed,
|
---|
2334 | this, &UISession::sltMountDVDAdHoc);
|
---|
2335 | gpNotificationCenter->append(pNotification);
|
---|
2336 | }
|
---|
2337 |
|
---|
2338 | void UISession::sltMountDVDAdHoc(const QString &strSource)
|
---|
2339 | {
|
---|
2340 | mountAdHocImage(KDeviceType_DVD, UIMediumDeviceType_DVD, strSource);
|
---|
2341 | }
|
---|
2342 |
|
---|
2343 | void UISession::sltDetachCOM()
|
---|
2344 | {
|
---|
2345 | /* Cleanup everything COM related: */
|
---|
2346 | cleanupFramebuffers();
|
---|
2347 | cleanupConsoleEventHandlers();
|
---|
2348 | cleanupCOMStuff();
|
---|
2349 | }
|
---|
2350 |
|
---|
2351 | void UISession::sltStateChange(KMachineState enmState)
|
---|
2352 | {
|
---|
2353 | /* Check if something had changed: */
|
---|
2354 | if (m_enmMachineState != enmState)
|
---|
2355 | {
|
---|
2356 | /* Store new data: */
|
---|
2357 | m_enmMachineStatePrevious = m_enmMachineState;
|
---|
2358 | m_enmMachineState = enmState;
|
---|
2359 |
|
---|
2360 | /* Notify listeners about machine state changed: */
|
---|
2361 | emit sigMachineStateChange();
|
---|
2362 | }
|
---|
2363 | }
|
---|
2364 |
|
---|
2365 | void UISession::sltAdditionsChange()
|
---|
2366 | {
|
---|
2367 | /* Acquire actual states: */
|
---|
2368 | const ulong ulGuestAdditionsRunLevel = guest().GetAdditionsRunLevel();
|
---|
2369 | LONG64 iLastUpdatedIgnored;
|
---|
2370 | const bool fIsGuestSupportsGraphics = guest().GetFacilityStatus(KAdditionsFacilityType_Graphics, iLastUpdatedIgnored)
|
---|
2371 | == KAdditionsFacilityStatus_Active;
|
---|
2372 | const bool fIsGuestSupportsSeamless = guest().GetFacilityStatus(KAdditionsFacilityType_Seamless, iLastUpdatedIgnored)
|
---|
2373 | == KAdditionsFacilityStatus_Active;
|
---|
2374 |
|
---|
2375 | /* Check if something had changed: */
|
---|
2376 | if ( m_ulGuestAdditionsRunLevel != ulGuestAdditionsRunLevel
|
---|
2377 | || m_fIsGuestSupportsGraphics != fIsGuestSupportsGraphics
|
---|
2378 | || m_fIsGuestSupportsSeamless != fIsGuestSupportsSeamless)
|
---|
2379 | {
|
---|
2380 | /* Store new data: */
|
---|
2381 | m_ulGuestAdditionsRunLevel = ulGuestAdditionsRunLevel;
|
---|
2382 | m_fIsGuestSupportsGraphics = fIsGuestSupportsGraphics;
|
---|
2383 | m_fIsGuestSupportsSeamless = fIsGuestSupportsSeamless;
|
---|
2384 |
|
---|
2385 | /* Notify listeners about GA state really changed: */
|
---|
2386 | LogRel(("GUI: UISession::sltAdditionsChange: GA state really changed, notifying listeners.\n"));
|
---|
2387 | emit sigAdditionsStateActualChange();
|
---|
2388 | }
|
---|
2389 | else
|
---|
2390 | LogRel(("GUI: UISession::sltAdditionsChange: GA state doesn't really changed, still notifying listeners.\n"));
|
---|
2391 |
|
---|
2392 | /* Notify listeners about GA state change event came: */
|
---|
2393 | emit sigAdditionsStateChange();
|
---|
2394 | }
|
---|
2395 |
|
---|
2396 | void UISession::sltHandleMachineStateSaved(bool fSuccess)
|
---|
2397 | {
|
---|
2398 | /* Let user try again if saving failed: */
|
---|
2399 | if (!fSuccess)
|
---|
2400 | {
|
---|
2401 | /* Disable 'manual-override' finally: */
|
---|
2402 | uimachine()->setManualOverrideMode(false);
|
---|
2403 | }
|
---|
2404 | /* Close Runtime UI otherwise: */
|
---|
2405 | else
|
---|
2406 | uimachine()->closeRuntimeUI();
|
---|
2407 | }
|
---|
2408 |
|
---|
2409 | void UISession::sltHandleMachinePoweredOff(bool fSuccess, bool fIncludingDiscard)
|
---|
2410 | {
|
---|
2411 | /* Let user try again if power off failed: */
|
---|
2412 | if (!fSuccess)
|
---|
2413 | {
|
---|
2414 | /* Disable 'manual-override' finally: */
|
---|
2415 | uimachine()->setManualOverrideMode(false);
|
---|
2416 | }
|
---|
2417 | /* Check for other tasks otherwise: */
|
---|
2418 | else
|
---|
2419 | {
|
---|
2420 | if (fIncludingDiscard)
|
---|
2421 | {
|
---|
2422 | /* Now, do more magic! */
|
---|
2423 | UINotificationProgressSnapshotRestore *pNotification =
|
---|
2424 | new UINotificationProgressSnapshotRestore(uiCommon().managedVMUuid());
|
---|
2425 | connect(pNotification, &UINotificationProgressSnapshotRestore::sigSnapshotRestored,
|
---|
2426 | this, &UISession::sltHandleSnapshotRestored);
|
---|
2427 | gpNotificationCenter->append(pNotification);
|
---|
2428 | }
|
---|
2429 | else
|
---|
2430 | uimachine()->closeRuntimeUI();
|
---|
2431 | }
|
---|
2432 | }
|
---|
2433 |
|
---|
2434 | void UISession::sltHandleSnapshotRestored(bool)
|
---|
2435 | {
|
---|
2436 | /* Close Runtime UI independent of snapshot restoring state: */
|
---|
2437 | uimachine()->closeRuntimeUI();
|
---|
2438 | }
|
---|
2439 |
|
---|
2440 | bool UISession::prepareCOMStuff()
|
---|
2441 | {
|
---|
2442 | /* Open session: */
|
---|
2443 | m_comSession = uiCommon().openSession(uiCommon().managedVMUuid(),
|
---|
2444 | uiCommon().isSeparateProcess()
|
---|
2445 | ? KLockType_Shared
|
---|
2446 | : KLockType_VM);
|
---|
2447 | if (m_comSession.isNull())
|
---|
2448 | return false;
|
---|
2449 |
|
---|
2450 | /* Get machine: */
|
---|
2451 | m_comMachine = m_comSession.GetMachine();
|
---|
2452 | if (m_comMachine.isNull())
|
---|
2453 | return false;
|
---|
2454 |
|
---|
2455 | /* Get console: */
|
---|
2456 | m_comConsole = m_comSession.GetConsole();
|
---|
2457 | if (m_comConsole.isNull())
|
---|
2458 | return false;
|
---|
2459 |
|
---|
2460 | /* Get display: */
|
---|
2461 | m_comDisplay = m_comConsole.GetDisplay();
|
---|
2462 | if (m_comDisplay.isNull())
|
---|
2463 | return false;
|
---|
2464 |
|
---|
2465 | /* Get guest: */
|
---|
2466 | m_comGuest = m_comConsole.GetGuest();
|
---|
2467 | if (m_comGuest.isNull())
|
---|
2468 | return false;
|
---|
2469 |
|
---|
2470 | /* Get mouse: */
|
---|
2471 | m_comMouse = m_comConsole.GetMouse();
|
---|
2472 | if (m_comMouse.isNull())
|
---|
2473 | return false;
|
---|
2474 |
|
---|
2475 | /* Get keyboard: */
|
---|
2476 | m_comKeyboard = m_comConsole.GetKeyboard();
|
---|
2477 | if (m_comKeyboard.isNull())
|
---|
2478 | return false;
|
---|
2479 |
|
---|
2480 | /* Get debugger: */
|
---|
2481 | m_comDebugger = m_comConsole.GetDebugger();
|
---|
2482 | if (m_comDebugger.isNull())
|
---|
2483 | return false;
|
---|
2484 |
|
---|
2485 | /* Update machine attributes: */
|
---|
2486 | m_strMachineName = machine().GetName();
|
---|
2487 | m_strOSTypeId = machine().GetOSTypeId();
|
---|
2488 |
|
---|
2489 | /* Update machine-state: */
|
---|
2490 | m_enmMachineState = machine().GetState();
|
---|
2491 |
|
---|
2492 | /* True by default: */
|
---|
2493 | return true;
|
---|
2494 | }
|
---|
2495 |
|
---|
2496 | void UISession::prepareConsoleEventHandlers()
|
---|
2497 | {
|
---|
2498 | /* Create console event-handler: */
|
---|
2499 | m_pConsoleEventhandler = new UIConsoleEventHandler(this);
|
---|
2500 |
|
---|
2501 | /* Console event connections: */
|
---|
2502 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigAdditionsChange,
|
---|
2503 | this, &UISession::sltAdditionsChange);
|
---|
2504 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigAudioAdapterChange,
|
---|
2505 | this, &UISession::sigAudioAdapterChange);
|
---|
2506 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigClipboardModeChange,
|
---|
2507 | this, &UISession::sigClipboardModeChange);
|
---|
2508 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigClipboardError,
|
---|
2509 | this, &UISession::sigClipboardError);
|
---|
2510 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigCPUExecutionCapChange,
|
---|
2511 | this, &UISession::sigCPUExecutionCapChange);
|
---|
2512 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigDnDModeChange,
|
---|
2513 | this, &UISession::sigDnDModeChange);
|
---|
2514 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigGuestMonitorChange,
|
---|
2515 | this, &UISession::sigGuestMonitorChange);
|
---|
2516 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMediumChange,
|
---|
2517 | this, &UISession::sigMediumChange);
|
---|
2518 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigNetworkAdapterChange,
|
---|
2519 | this, &UISession::sigNetworkAdapterChange);
|
---|
2520 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigRecordingChange,
|
---|
2521 | this, &UISession::sigRecordingChange);
|
---|
2522 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigSharedFolderChange,
|
---|
2523 | this, &UISession::sigSharedFolderChange);
|
---|
2524 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigStateChange,
|
---|
2525 | this, &UISession::sltStateChange);
|
---|
2526 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigStorageDeviceChange,
|
---|
2527 | this, &UISession::sigStorageDeviceChange);
|
---|
2528 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigUSBControllerChange,
|
---|
2529 | this, &UISession::sigUSBControllerChange);
|
---|
2530 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigUSBDeviceStateChange,
|
---|
2531 | this, &UISession::sigUSBDeviceStateChange);
|
---|
2532 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigVRDEChange,
|
---|
2533 | this, &UISession::sigVRDEChange);
|
---|
2534 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigRuntimeError,
|
---|
2535 | this, &UISession::sigRuntimeError);
|
---|
2536 |
|
---|
2537 | #ifdef VBOX_WS_MAC
|
---|
2538 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigShowWindow,
|
---|
2539 | this, &UISession::sigShowWindows, Qt::QueuedConnection);
|
---|
2540 | #endif
|
---|
2541 |
|
---|
2542 | /* Console keyboard connections: */
|
---|
2543 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigKeyboardLedsChange,
|
---|
2544 | this, &UISession::sigKeyboardLedsChange);
|
---|
2545 |
|
---|
2546 | /* Console mouse connections: */
|
---|
2547 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMousePointerShapeChange,
|
---|
2548 | this, &UISession::sigMousePointerShapeChange);
|
---|
2549 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigMouseCapabilityChange,
|
---|
2550 | this, &UISession::sigMouseCapabilityChange);
|
---|
2551 | connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigCursorPositionChange,
|
---|
2552 | this, &UISession::sigCursorPositionChange);
|
---|
2553 | }
|
---|
2554 |
|
---|
2555 | void UISession::prepareFramebuffers()
|
---|
2556 | {
|
---|
2557 | /* Acquire guest-screen count: */
|
---|
2558 | ulong cGuestScreenCount = 0;
|
---|
2559 | acquireMonitorCount(cGuestScreenCount);
|
---|
2560 | m_frameBufferVector.resize(cGuestScreenCount);
|
---|
2561 |
|
---|
2562 | /* Create new frame-buffers: */
|
---|
2563 | for (int iIndex = 0; iIndex < m_frameBufferVector.size(); ++iIndex)
|
---|
2564 | m_frameBufferVector[iIndex] = new UIFrameBuffer;
|
---|
2565 | }
|
---|
2566 |
|
---|
2567 | void UISession::prepareConnections()
|
---|
2568 | {
|
---|
2569 | /* UICommon connections: */
|
---|
2570 | connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UISession::sltDetachCOM);
|
---|
2571 | }
|
---|
2572 |
|
---|
2573 | void UISession::prepareSignalHandling()
|
---|
2574 | {
|
---|
2575 | #ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
|
---|
2576 | struct sigaction sa;
|
---|
2577 | sa.sa_sigaction = &signalHandlerSIGUSR1;
|
---|
2578 | sigemptyset(&sa.sa_mask);
|
---|
2579 | sa.sa_flags = SA_RESTART | SA_SIGINFO;
|
---|
2580 | sigaction(SIGUSR1, &sa, NULL);
|
---|
2581 | #endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
|
---|
2582 | }
|
---|
2583 |
|
---|
2584 | void UISession::cleanupFramebuffers()
|
---|
2585 | {
|
---|
2586 | /* Cleanup framebuffers finally: */
|
---|
2587 | for (int i = m_frameBufferVector.size() - 1; i >= 0; --i)
|
---|
2588 | {
|
---|
2589 | UIFrameBuffer *pFrameBuffer = m_frameBufferVector[i];
|
---|
2590 | if (pFrameBuffer)
|
---|
2591 | {
|
---|
2592 | /* Mark framebuffer as unused: */
|
---|
2593 | pFrameBuffer->setMarkAsUnused(true);
|
---|
2594 | /* Detach framebuffer from Display: */
|
---|
2595 | pFrameBuffer->detach();
|
---|
2596 | /* Delete framebuffer reference: */
|
---|
2597 | delete pFrameBuffer;
|
---|
2598 | }
|
---|
2599 | }
|
---|
2600 | m_frameBufferVector.clear();
|
---|
2601 | }
|
---|
2602 |
|
---|
2603 | void UISession::cleanupConsoleEventHandlers()
|
---|
2604 | {
|
---|
2605 | /* Destroy console event-handler: */
|
---|
2606 | delete m_pConsoleEventhandler;
|
---|
2607 | m_pConsoleEventhandler = 0;
|
---|
2608 | }
|
---|
2609 |
|
---|
2610 | void UISession::cleanupCOMStuff()
|
---|
2611 | {
|
---|
2612 | /* Detach debugger: */
|
---|
2613 | if (!m_comDebugger.isNull())
|
---|
2614 | m_comDebugger.detach();
|
---|
2615 |
|
---|
2616 | /* Detach keyboard: */
|
---|
2617 | if (!m_comKeyboard.isNull())
|
---|
2618 | m_comKeyboard.detach();
|
---|
2619 |
|
---|
2620 | /* Detach mouse: */
|
---|
2621 | if (!m_comMouse.isNull())
|
---|
2622 | m_comMouse.detach();
|
---|
2623 |
|
---|
2624 | /* Detach guest: */
|
---|
2625 | if (!m_comGuest.isNull())
|
---|
2626 | m_comGuest.detach();
|
---|
2627 |
|
---|
2628 | /* Detach display: */
|
---|
2629 | if (!m_comDisplay.isNull())
|
---|
2630 | m_comDisplay.detach();
|
---|
2631 |
|
---|
2632 | /* Detach console: */
|
---|
2633 | if (!m_comConsole.isNull())
|
---|
2634 | m_comConsole.detach();
|
---|
2635 |
|
---|
2636 | /* Detach machine: */
|
---|
2637 | if (!m_comMachine.isNull())
|
---|
2638 | m_comMachine.detach();
|
---|
2639 |
|
---|
2640 | /* Close session: */
|
---|
2641 | if (!m_comSession.isNull() && uiCommon().isVBoxSVCAvailable())
|
---|
2642 | {
|
---|
2643 | m_comSession.UnlockMachine();
|
---|
2644 | m_comSession.detach();
|
---|
2645 | }
|
---|
2646 | }
|
---|
2647 |
|
---|
2648 | UIMachineLogic *UISession::machineLogic() const
|
---|
2649 | {
|
---|
2650 | return uimachine() ? uimachine()->machineLogic() : 0;
|
---|
2651 | }
|
---|
2652 |
|
---|
2653 | UIMachineWindow *UISession::activeMachineWindow() const
|
---|
2654 | {
|
---|
2655 | return machineLogic() ? machineLogic()->activeMachineWindow() : 0;
|
---|
2656 | }
|
---|
2657 |
|
---|
2658 | QWidget *UISession::mainMachineWindow() const
|
---|
2659 | {
|
---|
2660 | return machineLogic() ? machineLogic()->mainMachineWindow() : 0;
|
---|
2661 | }
|
---|
2662 |
|
---|
2663 | bool UISession::preprocessInitialization()
|
---|
2664 | {
|
---|
2665 | #ifdef VBOX_WITH_NETFLT
|
---|
2666 | /* Skip network interface name checks if VM in saved state: */
|
---|
2667 | if (!isSaved())
|
---|
2668 | {
|
---|
2669 | /* Make sure all the attached and enabled network
|
---|
2670 | * adapters are present on the host. This check makes sense
|
---|
2671 | * in two cases only - when attachement type is Bridged Network
|
---|
2672 | * or Host-only Interface. NOTE: Only currently enabled
|
---|
2673 | * attachement type is checked (incorrect parameters check for
|
---|
2674 | * currently disabled attachement types is skipped). */
|
---|
2675 | QStringList failedInterfaceNames;
|
---|
2676 | QStringList availableInterfaceNames;
|
---|
2677 |
|
---|
2678 | /* Create host network interface names list: */
|
---|
2679 | foreach (const CHostNetworkInterface &comNetIface, uiCommon().host().GetNetworkInterfaces())
|
---|
2680 | {
|
---|
2681 | availableInterfaceNames << comNetIface.GetName();
|
---|
2682 | availableInterfaceNames << comNetIface.GetShortName();
|
---|
2683 | }
|
---|
2684 |
|
---|
2685 | /* Enumerate all the virtual network adapters: */
|
---|
2686 | CPlatform comPlatform = machine().GetPlatform();
|
---|
2687 | CPlatformProperties comProperties = uiCommon().virtualBox().GetPlatformProperties(comPlatform.GetArchitecture());
|
---|
2688 | const ulong cCount = comProperties.GetMaxNetworkAdapters(comPlatform.GetChipsetType());
|
---|
2689 | for (ulong uAdapterIndex = 0; uAdapterIndex < cCount; ++uAdapterIndex)
|
---|
2690 | {
|
---|
2691 | CNetworkAdapter comNetworkAdapter = machine().GetNetworkAdapter(uAdapterIndex);
|
---|
2692 | if (comNetworkAdapter.GetEnabled())
|
---|
2693 | {
|
---|
2694 | /* Get physical network interface name for
|
---|
2695 | * currently enabled network attachement type: */
|
---|
2696 | QString strInterfaceName;
|
---|
2697 | switch (comNetworkAdapter.GetAttachmentType())
|
---|
2698 | {
|
---|
2699 | case KNetworkAttachmentType_Bridged:
|
---|
2700 | strInterfaceName = comNetworkAdapter.GetBridgedInterface();
|
---|
2701 | break;
|
---|
2702 | # ifndef VBOX_WITH_VMNET
|
---|
2703 | case KNetworkAttachmentType_HostOnly:
|
---|
2704 | strInterfaceName = comNetworkAdapter.GetHostOnlyInterface();
|
---|
2705 | break;
|
---|
2706 | # endif /* !VBOX_WITH_VMNET */
|
---|
2707 | default:
|
---|
2708 | break;
|
---|
2709 | }
|
---|
2710 |
|
---|
2711 | if ( !strInterfaceName.isEmpty()
|
---|
2712 | && !availableInterfaceNames.contains(strInterfaceName))
|
---|
2713 | {
|
---|
2714 | LogRel(("GUI: Invalid network interface found: %s\n", strInterfaceName.toUtf8().constData()));
|
---|
2715 | failedInterfaceNames << QString("%1 (adapter %2)").arg(strInterfaceName).arg(uAdapterIndex + 1);
|
---|
2716 | }
|
---|
2717 | }
|
---|
2718 | }
|
---|
2719 |
|
---|
2720 | /* Check if non-existent interfaces found: */
|
---|
2721 | if (!failedInterfaceNames.isEmpty())
|
---|
2722 | {
|
---|
2723 | if (msgCenter().warnAboutNetworkInterfaceNotFound(machineName(), failedInterfaceNames.join(", ")))
|
---|
2724 | machineLogic()->openNetworkSettingsDialog();
|
---|
2725 | else
|
---|
2726 | {
|
---|
2727 | LogRel(("GUI: Aborting startup due to preprocess initialization issue detected...\n"));
|
---|
2728 | return false;
|
---|
2729 | }
|
---|
2730 | }
|
---|
2731 | }
|
---|
2732 | #endif /* VBOX_WITH_NETFLT */
|
---|
2733 |
|
---|
2734 | /* Check for USB enumeration warning. Don't return false even if we have a warning: */
|
---|
2735 | CHost comHost = uiCommon().host();
|
---|
2736 | if (comHost.GetUSBDevices().isEmpty() && comHost.isWarning())
|
---|
2737 | {
|
---|
2738 | /* Do not bitch if USB disabled: */
|
---|
2739 | if (!machine().GetUSBControllers().isEmpty())
|
---|
2740 | {
|
---|
2741 | /* Do not bitch if there are no filters (check if enabled too?): */
|
---|
2742 | if (!machine().GetUSBDeviceFilters().GetDeviceFilters().isEmpty())
|
---|
2743 | UINotificationMessage::cannotEnumerateHostUSBDevices(comHost);
|
---|
2744 | }
|
---|
2745 | }
|
---|
2746 |
|
---|
2747 | /* True by default: */
|
---|
2748 | return true;
|
---|
2749 | }
|
---|
2750 |
|
---|
2751 | bool UISession::mountAdHocImage(KDeviceType enmDeviceType, UIMediumDeviceType enmMediumType, const QString &strMediumName)
|
---|
2752 | {
|
---|
2753 | /* Get VBox: */
|
---|
2754 | CVirtualBox comVBox = uiCommon().virtualBox();
|
---|
2755 |
|
---|
2756 | /* Prepare medium to mount: */
|
---|
2757 | UIMedium guiMedium;
|
---|
2758 |
|
---|
2759 | /* The 'none' medium name means ejecting what ever is in the drive,
|
---|
2760 | * in that case => leave the guiMedium variable null. */
|
---|
2761 | if (strMediumName != "none")
|
---|
2762 | {
|
---|
2763 | /* Open the medium: */
|
---|
2764 | const CMedium comMedium = comVBox.OpenMedium(strMediumName, enmDeviceType, KAccessMode_ReadWrite, false /* fForceNewUuid */);
|
---|
2765 | if (!comVBox.isOk() || comMedium.isNull())
|
---|
2766 | {
|
---|
2767 | UINotificationMessage::cannotOpenMedium(comVBox, strMediumName);
|
---|
2768 | return false;
|
---|
2769 | }
|
---|
2770 |
|
---|
2771 | /* Make sure medium ID is valid: */
|
---|
2772 | const QUuid uMediumId = comMedium.GetId();
|
---|
2773 | AssertReturn(!uMediumId.isNull(), false);
|
---|
2774 |
|
---|
2775 | /* Try to find UIMedium among cached: */
|
---|
2776 | guiMedium = uiCommon().medium(uMediumId);
|
---|
2777 | if (guiMedium.isNull())
|
---|
2778 | {
|
---|
2779 | /* Cache new one if necessary: */
|
---|
2780 | guiMedium = UIMedium(comMedium, enmMediumType, KMediumState_Created);
|
---|
2781 | uiCommon().createMedium(guiMedium);
|
---|
2782 | }
|
---|
2783 | }
|
---|
2784 |
|
---|
2785 | /* Search for a suitable storage slots: */
|
---|
2786 | QList<ExactStorageSlot> aFreeStorageSlots;
|
---|
2787 | QList<ExactStorageSlot> aBusyStorageSlots;
|
---|
2788 | foreach (const CStorageController &comController, machine().GetStorageControllers())
|
---|
2789 | {
|
---|
2790 | foreach (const CMediumAttachment &comAttachment, machine().GetMediumAttachmentsOfController(comController.GetName()))
|
---|
2791 | {
|
---|
2792 | /* Look for an optical devices only: */
|
---|
2793 | if (comAttachment.GetType() == enmDeviceType)
|
---|
2794 | {
|
---|
2795 | /* Append storage slot to corresponding list: */
|
---|
2796 | if (comAttachment.GetMedium().isNull())
|
---|
2797 | aFreeStorageSlots << ExactStorageSlot(comController.GetName(), comController.GetBus(),
|
---|
2798 | comAttachment.GetPort(), comAttachment.GetDevice());
|
---|
2799 | else
|
---|
2800 | aBusyStorageSlots << ExactStorageSlot(comController.GetName(), comController.GetBus(),
|
---|
2801 | comAttachment.GetPort(), comAttachment.GetDevice());
|
---|
2802 | }
|
---|
2803 | }
|
---|
2804 | }
|
---|
2805 |
|
---|
2806 | /* Make sure at least one storage slot found: */
|
---|
2807 | QList<ExactStorageSlot> sStorageSlots = aFreeStorageSlots + aBusyStorageSlots;
|
---|
2808 | if (sStorageSlots.isEmpty())
|
---|
2809 | {
|
---|
2810 | UINotificationMessage::cannotMountImage(machineName(), strMediumName);
|
---|
2811 | return false;
|
---|
2812 | }
|
---|
2813 |
|
---|
2814 | /* Try to mount medium into first available storage slot: */
|
---|
2815 | while (!sStorageSlots.isEmpty())
|
---|
2816 | {
|
---|
2817 | const ExactStorageSlot storageSlot = sStorageSlots.takeFirst();
|
---|
2818 | machine().MountMedium(storageSlot.controller, storageSlot.port, storageSlot.device, guiMedium.medium(), false /* force */);
|
---|
2819 | if (machine().isOk())
|
---|
2820 | break;
|
---|
2821 | }
|
---|
2822 |
|
---|
2823 | /* Show error message if necessary: */
|
---|
2824 | if (!machine().isOk())
|
---|
2825 | {
|
---|
2826 | msgCenter().cannotRemountMedium(machine(), guiMedium, true /* mount? */, false /* retry? */, activeMachineWindow());
|
---|
2827 | return false;
|
---|
2828 | }
|
---|
2829 |
|
---|
2830 | /* Save machine settings: */
|
---|
2831 | if (!saveSettings())
|
---|
2832 | return false;
|
---|
2833 |
|
---|
2834 | /* True by default: */
|
---|
2835 | return true;
|
---|
2836 | }
|
---|
2837 |
|
---|
2838 | void UISession::recacheMachineMedia()
|
---|
2839 | {
|
---|
2840 | /* Compose a list of machine media: */
|
---|
2841 | CMediumVector comMedia;
|
---|
2842 |
|
---|
2843 | /* Enumerate all the controllers: */
|
---|
2844 | foreach (const CStorageController &comController, machine().GetStorageControllers())
|
---|
2845 | {
|
---|
2846 | /* Enumerate all the attachments: */
|
---|
2847 | foreach (const CMediumAttachment &comAttachment, machine().GetMediumAttachmentsOfController(comController.GetName()))
|
---|
2848 | {
|
---|
2849 | /* Skip unrelated device types: */
|
---|
2850 | const KDeviceType enmDeviceType = comAttachment.GetType();
|
---|
2851 | if ( enmDeviceType != KDeviceType_HardDisk
|
---|
2852 | && enmDeviceType != KDeviceType_Floppy
|
---|
2853 | && enmDeviceType != KDeviceType_DVD)
|
---|
2854 | continue;
|
---|
2855 | if ( comAttachment.GetIsEjected()
|
---|
2856 | || comAttachment.GetMedium().isNull())
|
---|
2857 | continue;
|
---|
2858 | comMedia.append(comAttachment.GetMedium());
|
---|
2859 | }
|
---|
2860 | }
|
---|
2861 |
|
---|
2862 | /* Start media enumeration: */
|
---|
2863 | uiCommon().enumerateMedia(comMedia);
|
---|
2864 | }
|
---|
2865 |
|
---|
2866 | /* static */
|
---|
2867 | bool UISession::searchMaxSnapshotIndex(const CMachine &comMachine,
|
---|
2868 | const CSnapshot &comSnapshot,
|
---|
2869 | const QString &strNameTemplate,
|
---|
2870 | ulong &uIndex)
|
---|
2871 | {
|
---|
2872 | bool fSuccess = true;
|
---|
2873 | ulong uMaxIndex = 0;
|
---|
2874 | QRegExp regExp(QString("^") + strNameTemplate.arg("([0-9]+)") + QString("$"));
|
---|
2875 | if (!comSnapshot.isNull())
|
---|
2876 | {
|
---|
2877 | /* Check current snapshot name: */
|
---|
2878 | const QString strName = comSnapshot.GetName();
|
---|
2879 | fSuccess = comSnapshot.isOk();
|
---|
2880 | if (!fSuccess)
|
---|
2881 | UINotificationMessage::cannotAcquireSnapshotParameter(comSnapshot);
|
---|
2882 | else
|
---|
2883 | {
|
---|
2884 | const int iPos = regExp.indexIn(strName);
|
---|
2885 | if (iPos != -1)
|
---|
2886 | uMaxIndex = regExp.cap(1).toULong() > uMaxIndex ? regExp.cap(1).toULong() : uMaxIndex;
|
---|
2887 | /* Traversing all the snapshot children: */
|
---|
2888 | QVector<CSnapshot> comSnapshotChildren = comSnapshot.GetChildren();
|
---|
2889 | fSuccess = comSnapshot.isOk();
|
---|
2890 | if (!fSuccess)
|
---|
2891 | UINotificationMessage::cannotAcquireSnapshotParameter(comSnapshot);
|
---|
2892 | else
|
---|
2893 | foreach (const CSnapshot &comSnapshotChild, comSnapshotChildren)
|
---|
2894 | {
|
---|
2895 | ulong uMaxIndexOfChildren = 0;
|
---|
2896 | fSuccess = searchMaxSnapshotIndex(comMachine, comSnapshotChild, strNameTemplate, uMaxIndexOfChildren);
|
---|
2897 | if (!fSuccess)
|
---|
2898 | break;
|
---|
2899 | uMaxIndex = uMaxIndexOfChildren > uMaxIndex ? uMaxIndexOfChildren : uMaxIndex;
|
---|
2900 | }
|
---|
2901 | }
|
---|
2902 | }
|
---|
2903 | if (fSuccess)
|
---|
2904 | uIndex = uMaxIndex;
|
---|
2905 | return fSuccess;
|
---|
2906 | }
|
---|
2907 |
|
---|
2908 | #ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
|
---|
2909 | /**
|
---|
2910 | * Custom signal handler. When switching VTs, we might not get release events
|
---|
2911 | * for Ctrl-Alt and in case a savestate is performed on the new VT, the VM will
|
---|
2912 | * be saved with modifier keys stuck. This is annoying enough for introducing
|
---|
2913 | * this hack.
|
---|
2914 | */
|
---|
2915 | /* static */
|
---|
2916 | static void signalHandlerSIGUSR1(int sig, siginfo_t * /* pInfo */, void * /*pSecret */)
|
---|
2917 | {
|
---|
2918 | /* Only SIGUSR1 is interesting: */
|
---|
2919 | if (sig == SIGUSR1)
|
---|
2920 | if (gpMachine)
|
---|
2921 | gpMachine->machineLogic()->keyboardHandler()->releaseAllPressedKeys();
|
---|
2922 | }
|
---|
2923 | #endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
|
---|