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