Changeset 60227 in vbox
- Timestamp:
- Mar 28, 2016 5:38:54 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106261
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r60129 r60227 537 537 src/runtime/UIActionPoolRuntime.cpp \ 538 538 src/runtime/UIAddDiskEncryptionPasswordDialog.cpp \ 539 src/runtime/UIConsoleEventHandler.cpp \ 539 540 src/runtime/UIFrameBuffer.cpp \ 540 541 src/runtime/UIIndicatorsPool.cpp \ 541 542 src/runtime/UIStatusBarEditorWindow.cpp \ 542 543 src/selector/UIActionPoolSelector.cpp \ 544 src/selector/UIVirtualBoxEventHandler.cpp \ 543 545 src/selector/UIVMDesktop.cpp \ 544 546 src/settings/machine/UIMachineSettingsStorage.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r60222 r60227 61 61 /* COM includes: */ 62 62 # include "COMEnums.h" 63 # include "CEventListener.h" 63 64 # include "CEventSource.h" 64 65 # include "CVirtualBox.h" … … 92 93 public: 93 94 94 /** Constructs private proxyon the basis of passed @a pParent. */95 /** Constructs event proxy object on the basis of passed @a pParent. */ 95 96 UIExtraDataEventHandler(QObject *pParent); 96 97 public slots: 97 /** Destructs event proxy object. */ 98 ~UIExtraDataEventHandler(); 99 100 protected slots: 98 101 99 102 /** Preprocess 'extra-data can change' event: */ … … 102 105 void sltPreprocessExtraDataChange(QString strMachineID, QString strKey, QString strValue); 103 106 107 protected: 108 109 /** @name Prepare/Cleanup cascade. 110 * @{ */ 111 /** Prepares all. */ 112 void prepare(); 113 /** Prepares listener. */ 114 void prepareListener(); 115 /** Prepares connections. */ 116 void prepareConnections(); 117 118 /** Cleanups connections. */ 119 void cleanupConnections(); 120 /** Cleanups listener. */ 121 void cleanupListener(); 122 /** Cleanups all. */ 123 void cleanup(); 124 /** @} */ 125 104 126 private: 127 128 /** Holds the Qt event listener instance. */ 129 ComObjPtr<UIMainEventListenerImpl> m_pQtListener; 130 /** Holds the COM event listener instance. */ 131 CEventListener m_comEventListener; 105 132 106 133 /** Protects sltPreprocessExtraDataChange. */ … … 111 138 : QObject(pParent) 112 139 { 140 /* Prepare: */ 141 prepare(); 142 } 143 144 UIExtraDataEventHandler::~UIExtraDataEventHandler() 145 { 146 /* Cleanup: */ 147 cleanup(); 148 } 149 150 void UIExtraDataEventHandler::prepare() 151 { 152 /* Prepare: */ 153 prepareListener(); 154 prepareConnections(); 155 } 156 157 void UIExtraDataEventHandler::prepareListener() 158 { 159 /* Create event listener instance: */ 160 m_pQtListener.createObject(); 161 m_pQtListener->init(new UIMainEventListener, this); 162 m_comEventListener = CEventListener(m_pQtListener); 163 164 /* Get VirtualBox: */ 165 const CVirtualBox vbox = vboxGlobal().virtualBox(); 166 AssertWrapperOk(vbox); 167 /* Get event-source: */ 168 CEventSource eventSourceVirtualBox = vbox.GetEventSource(); 169 AssertWrapperOk(eventSourceVirtualBox); 170 /* Register listener for expected event-types: */ 171 QVector<KVBoxEventType> vboxEvents; 172 vboxEvents 173 << KVBoxEventType_OnExtraDataCanChange 174 << KVBoxEventType_OnExtraDataChanged; 175 eventSourceVirtualBox.RegisterListener(m_comEventListener, vboxEvents, TRUE); 176 AssertWrapperOk(eventSourceVirtualBox); 177 } 178 179 void UIExtraDataEventHandler::prepareConnections() 180 { 181 /* Create direct (sync) connections for signals of main listener: */ 182 connect(m_pQtListener->getWrapped(), SIGNAL(sigExtraDataCanChange(QString, QString, QString, bool&, QString&)), 183 this, SLOT(sltPreprocessExtraDataCanChange(QString, QString, QString, bool&, QString&)), 184 Qt::DirectConnection); 185 connect(m_pQtListener->getWrapped(), SIGNAL(sigExtraDataChange(QString, QString, QString)), 186 this, SLOT(sltPreprocessExtraDataChange(QString, QString, QString)), 187 Qt::DirectConnection); 188 } 189 190 void UIExtraDataEventHandler::cleanupConnections() 191 { 192 /* Nothing for now. */ 193 } 194 195 void UIExtraDataEventHandler::cleanupListener() 196 { 197 /* Make sure VBoxSVC is available: */ 198 if (!vboxGlobal().isVBoxSVCAvailable()) 199 return; 200 201 /* Unregister Main event-listener: */ 202 const CVirtualBox vbox = vboxGlobal().virtualBox(); 203 AssertWrapperOk(vbox); 204 /* Get event-source: */ 205 CEventSource eventSourceVirtualBox = vbox.GetEventSource(); 206 AssertWrapperOk(eventSourceVirtualBox); 207 /* Unregister listener: */ 208 eventSourceVirtualBox.UnregisterListener(m_comEventListener); 209 } 210 211 void UIExtraDataEventHandler::cleanup() 212 { 213 /* Cleanup: */ 214 cleanupConnections(); 215 cleanupListener(); 113 216 } 114 217 … … 3997 4100 AssertPtrReturnVoid(m_pHandler); 3998 4101 { 3999 /* Create queued (async) connections to signals of private proxy: */4102 /* Create queued (async) connections for signals of event proxy object: */ 4000 4103 connect(m_pHandler, SIGNAL(sigExtraDataChange(QString, QString, QString)), 4001 4104 this, SLOT(sltExtraDataChange(QString, QString, QString)), 4002 4105 Qt::QueuedConnection); 4003 4004 /* Prepare Main event-listener: */ 4005 prepareMainEventListener(); 4006 } 4007 } 4008 4009 void UIExtraDataManager::prepareMainEventListener() 4010 { 4011 /* Register Main event-listener: */ 4012 const CVirtualBox vbox = vboxGlobal().virtualBox(); 4013 ComObjPtr<UIMainEventListenerImpl> pListener; 4014 pListener.createObject(); 4015 pListener->init(new UIMainEventListener, this); 4016 m_listener = CEventListener(pListener); 4017 QVector<KVBoxEventType> events; 4018 events 4019 << KVBoxEventType_OnExtraDataCanChange 4020 << KVBoxEventType_OnExtraDataChanged; 4021 vbox.GetEventSource().RegisterListener(m_listener, events, TRUE); 4022 AssertWrapperOk(vbox); 4023 4024 /* This is a vetoable event, so we have to respond to the event and have to use a direct connection therefor: */ 4025 connect(pListener->getWrapped(), SIGNAL(sigExtraDataCanChange(QString, QString, QString, bool&, QString&)), 4026 m_pHandler, SLOT(sltPreprocessExtraDataCanChange(QString, QString, QString, bool&, QString&)), 4027 Qt::DirectConnection); 4028 /* Use a direct connection to the helper class: */ 4029 connect(pListener->getWrapped(), SIGNAL(sigExtraDataChange(QString, QString, QString)), 4030 m_pHandler, SLOT(sltPreprocessExtraDataChange(QString, QString, QString)), 4031 Qt::DirectConnection); 4106 } 4032 4107 } 4033 4108 … … 4038 4113 } 4039 4114 #endif /* DEBUG */ 4040 4041 void UIExtraDataManager::cleanupMainEventListener()4042 {4043 /* Make sure VBoxSVC is available: */4044 if (!vboxGlobal().isVBoxSVCAvailable())4045 return;4046 4047 /* Unregister Main event-listener: */4048 const CVirtualBox vbox = vboxGlobal().virtualBox();4049 vbox.GetEventSource().UnregisterListener(m_listener);4050 }4051 4115 4052 4116 void UIExtraDataManager::cleanup() … … 4056 4120 cleanupWindow(); 4057 4121 #endif /* DEBUG */ 4058 /* Cleanup Main event-listener: */4059 cleanupMainEventListener();4060 4122 } 4061 4123 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r60183 r60227 28 28 /* GUI includes: */ 29 29 #include "UIExtraDataDefs.h" 30 31 /* COM includes: */32 #include "CEventListener.h"33 30 34 31 /* Forward declarations: */ … … 571 568 /** Prepare extra-data event-handler. */ 572 569 void prepareExtraDataEventHandler(); 573 /** Prepare Main event-listener. */574 void prepareMainEventListener();575 570 #ifdef DEBUG 576 571 // /** Prepare window. */ … … 580 575 void cleanupWindow(); 581 576 #endif /* DEBUG */ 582 /** Cleanup Main event-listener. */583 void cleanupMainEventListener();584 577 // /** Cleanup extra-data event-handler. */ 585 578 // void cleanupExtraDataEventHandler(); … … 625 618 static UIExtraDataManager *m_spInstance; 626 619 627 /** Holds main event-listener instance. */628 CEventListener m_listener;629 620 /** Holds extra-data event-handler instance. */ 630 621 UIExtraDataEventHandler *m_pHandler; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.cpp
r60226 r60227 22 22 /* GUI includes: */ 23 23 # include "UIConsoleEventHandler.h" 24 # include "UIMainEventListener.h" 24 25 # include "VBoxGlobal.h" 25 26 # include "UISession.h" … … 29 30 30 31 /* COM includes: */ 32 # include "CEventListener.h" 33 # include "CEventSource.h" 31 34 # include "CConsole.h" 32 # include "CEventSource.h"33 35 34 36 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 35 37 36 38 37 /* static */ 38 UIConsoleEventHandler *UIConsoleEventHandler::m_spInstance = 0; 39 40 /* static */ 41 void UIConsoleEventHandler::create(UISession *pSession) 42 { 43 if (!m_spInstance) 44 m_spInstance = new UIConsoleEventHandler(pSession); 45 } 46 47 /* static */ 48 void UIConsoleEventHandler::destroy() 49 { 50 if (m_spInstance) 51 { 52 delete m_spInstance; 53 m_spInstance = 0; 54 } 55 } 56 57 UIConsoleEventHandler::UIConsoleEventHandler(UISession *pSession) 58 : m_pSession(pSession) 39 /** Private QObject extension 40 * providing UIConsoleEventHandler with the CConsole event-source. */ 41 class UIConsoleEventHandlerProxy : public QObject 42 { 43 Q_OBJECT; 44 45 signals: 46 47 /** Notifies about mouse pointer become @a fVisible and his shape changed to @a fAlpha, @a hotCorner, @a size and @a shape. */ 48 void sigMousePointerShapeChange(bool fVisible, bool fAlpha, QPoint hotCorner, QSize size, QVector<uint8_t> shape); 49 /** Notifies about mouse capability change to @a fSupportsAbsolute, @a fSupportsRelative, @a fSupportsMultiTouch and @a fNeedsHostCursor. */ 50 void sigMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fSupportsMultiTouch, bool fNeedsHostCursor); 51 /** Notifies about keyboard LEDs change for @a fNumLock, @a fCapsLock and @a fScrollLock. */ 52 void sigKeyboardLedsChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock); 53 /** Notifies about machine @a state change. */ 54 void sigStateChange(KMachineState state); 55 /** Notifies about guest additions state change. */ 56 void sigAdditionsChange(); 57 /** Notifies about network @a adapter state change. */ 58 void sigNetworkAdapterChange(CNetworkAdapter adapter); 59 /** Notifies about storage device change for @a attachment, which was @a fRemoved and it was @a fSilent for guest. */ 60 void sigStorageDeviceChange(CMediumAttachment attachment, bool fRemoved, bool fSilent); 61 /** Notifies about storage medium @a attachment state change. */ 62 void sigMediumChange(CMediumAttachment attachment); 63 /** Notifies about VRDE device state change. */ 64 void sigVRDEChange(); 65 /** Notifies about Video Capture device state change. */ 66 void sigVideoCaptureChange(); 67 /** Notifies about USB controller state change. */ 68 void sigUSBControllerChange(); 69 /** Notifies about USB @a device state change to @a fAttached, holding additional @a error information. */ 70 void sigUSBDeviceStateChange(CUSBDevice device, bool fAttached, CVirtualBoxErrorInfo error); 71 /** Notifies about shared folder state change. */ 72 void sigSharedFolderChange(); 73 /** Notifies about CPU execution-cap change. */ 74 void sigCPUExecutionCapChange(); 75 /** Notifies about guest-screen configuration change of @a type for @a uScreenId with @a screenGeo. */ 76 void sigGuestMonitorChange(KGuestMonitorChangedEventType type, ulong uScreenId, QRect screenGeo); 77 /** Notifies about Runtime error with @a strErrorId which is @a fFatal and have @a strMessage. */ 78 void sigRuntimeError(bool fFatal, QString strErrorId, QString strMessage); 79 #ifdef RT_OS_DARWIN 80 /** Notifies about VM window should be shown. */ 81 void sigShowWindow(); 82 #endif /* RT_OS_DARWIN */ 83 84 public: 85 86 /** Constructs event proxy object on the basis of passed @a pParent and @a pSession. */ 87 UIConsoleEventHandlerProxy(QObject *pParent, UISession *pSession); 88 /** Destructs event proxy object. */ 89 ~UIConsoleEventHandlerProxy(); 90 91 protected: 92 93 /** @name Prepare/Cleanup cascade. 94 * @{ */ 95 /** Prepares all. */ 96 void prepare(); 97 /** Prepares listener. */ 98 void prepareListener(); 99 /** Prepares connections. */ 100 void prepareConnections(); 101 102 /** Cleanups connections. */ 103 void cleanupConnections(); 104 /** Cleanups listener. */ 105 void cleanupListener(); 106 /** Cleanups all. */ 107 void cleanup(); 108 /** @} */ 109 110 private slots: 111 112 /** @name Slots for waitable signals. 113 * @{ */ 114 /** Returns whether VM window can be shown. */ 115 void sltCanShowWindow(bool &fVeto, QString &strReason); 116 /** Shows VM window if possible. */ 117 void sltShowWindow(qint64 &winId); 118 /** @} */ 119 120 private: 121 122 /** Holds the UI session reference. */ 123 UISession *m_pSession; 124 125 /** Holds the Qt event listener instance. */ 126 ComObjPtr<UIMainEventListenerImpl> m_pQtListener; 127 /** Holds the COM event listener instance. */ 128 CEventListener m_comEventListener; 129 }; 130 131 132 /********************************************************************************************************************************* 133 * Class UIConsoleEventHandlerProxy implementation. * 134 *********************************************************************************************************************************/ 135 136 UIConsoleEventHandlerProxy::UIConsoleEventHandlerProxy(QObject *pParent, UISession *pSession) 137 : QObject(pParent) 138 , m_pSession(pSession) 59 139 { 60 140 /* Prepare: */ … … 62 142 } 63 143 64 UIConsoleEventHandler ::~UIConsoleEventHandler()144 UIConsoleEventHandlerProxy::~UIConsoleEventHandlerProxy() 65 145 { 66 146 /* Cleanup: */ … … 68 148 } 69 149 70 void UIConsoleEventHandler ::prepare()150 void UIConsoleEventHandlerProxy::prepare() 71 151 { 72 152 /* Prepare: */ … … 75 155 } 76 156 77 void UIConsoleEventHandler ::prepareListener()157 void UIConsoleEventHandlerProxy::prepareListener() 78 158 { 79 159 /* Make sure session is passed: */ … … 116 196 } 117 197 118 void UIConsoleEventHandler ::prepareConnections()119 { 120 /* Create queued (async) connections for non-waitable signals: */198 void UIConsoleEventHandlerProxy::prepareConnections() 199 { 200 /* Create direct (sync) connections for signals of main listener: */ 121 201 connect(m_pQtListener->getWrapped(), SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)), 122 202 this, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)), 123 Qt:: QueuedConnection);203 Qt::DirectConnection); 124 204 connect(m_pQtListener->getWrapped(), SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)), 125 205 this, SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)), 126 Qt:: QueuedConnection);206 Qt::DirectConnection); 127 207 connect(m_pQtListener->getWrapped(), SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)), 128 208 this, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)), 129 Qt:: QueuedConnection);209 Qt::DirectConnection); 130 210 connect(m_pQtListener->getWrapped(), SIGNAL(sigStateChange(KMachineState)), 131 211 this, SIGNAL(sigStateChange(KMachineState)), 132 Qt:: QueuedConnection);212 Qt::DirectConnection); 133 213 connect(m_pQtListener->getWrapped(), SIGNAL(sigAdditionsChange()), 134 214 this, SIGNAL(sigAdditionsChange()), 135 Qt:: QueuedConnection);215 Qt::DirectConnection); 136 216 connect(m_pQtListener->getWrapped(), SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)), 137 217 this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)), 138 Qt:: QueuedConnection);218 Qt::DirectConnection); 139 219 connect(m_pQtListener->getWrapped(), SIGNAL(sigStorageDeviceChange(CMediumAttachment, bool, bool)), 140 220 this, SIGNAL(sigStorageDeviceChange(CMediumAttachment, bool, bool)), 141 Qt:: QueuedConnection);221 Qt::DirectConnection); 142 222 connect(m_pQtListener->getWrapped(), SIGNAL(sigMediumChange(CMediumAttachment)), 143 223 this, SIGNAL(sigMediumChange(CMediumAttachment)), 144 Qt:: QueuedConnection);224 Qt::DirectConnection); 145 225 connect(m_pQtListener->getWrapped(), SIGNAL(sigVRDEChange()), 146 226 this, SIGNAL(sigVRDEChange()), 147 Qt:: QueuedConnection);227 Qt::DirectConnection); 148 228 connect(m_pQtListener->getWrapped(), SIGNAL(sigVideoCaptureChange()), 149 229 this, SIGNAL(sigVideoCaptureChange()), 150 Qt:: QueuedConnection);230 Qt::DirectConnection); 151 231 connect(m_pQtListener->getWrapped(), SIGNAL(sigUSBControllerChange()), 152 232 this, SIGNAL(sigUSBControllerChange()), 153 Qt:: QueuedConnection);233 Qt::DirectConnection); 154 234 connect(m_pQtListener->getWrapped(), SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)), 155 235 this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)), 156 Qt:: QueuedConnection);236 Qt::DirectConnection); 157 237 connect(m_pQtListener->getWrapped(), SIGNAL(sigSharedFolderChange()), 158 238 this, SIGNAL(sigSharedFolderChange()), 159 Qt:: QueuedConnection);239 Qt::DirectConnection); 160 240 connect(m_pQtListener->getWrapped(), SIGNAL(sigCPUExecutionCapChange()), 161 241 this, SIGNAL(sigCPUExecutionCapChange()), 162 Qt:: QueuedConnection);242 Qt::DirectConnection); 163 243 connect(m_pQtListener->getWrapped(), SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)), 164 244 this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)), 165 Qt:: QueuedConnection);245 Qt::DirectConnection); 166 246 connect(m_pQtListener->getWrapped(), SIGNAL(sigRuntimeError(bool, QString, QString)), 167 247 this, SIGNAL(sigRuntimeError(bool, QString, QString)), 168 Qt::QueuedConnection); 169 170 /* Create direct (sync) connections for waitable signals: */ 248 Qt::DirectConnection); 171 249 connect(m_pQtListener->getWrapped(), SIGNAL(sigCanShowWindow(bool &, QString &)), 172 250 this, SLOT(sltCanShowWindow(bool &, QString &)), … … 177 255 } 178 256 179 void UIConsoleEventHandler ::cleanupConnections()257 void UIConsoleEventHandlerProxy::cleanupConnections() 180 258 { 181 259 /* Nothing for now. */ 182 260 } 183 261 184 void UIConsoleEventHandler ::cleanupListener()262 void UIConsoleEventHandlerProxy::cleanupListener() 185 263 { 186 264 /* Make sure session is passed: */ … … 198 276 } 199 277 200 void UIConsoleEventHandler ::cleanup()278 void UIConsoleEventHandlerProxy::cleanup() 201 279 { 202 280 /* Cleanup: */ … … 205 283 } 206 284 207 void UIConsoleEventHandler ::sltCanShowWindow(bool & /* fVeto */, QString & /* strReason */)285 void UIConsoleEventHandlerProxy::sltCanShowWindow(bool & /* fVeto */, QString & /* strReason */) 208 286 { 209 287 /* Nothing for now. */ 210 288 } 211 289 212 void UIConsoleEventHandler ::sltShowWindow(qint64 &winId)290 void UIConsoleEventHandlerProxy::sltShowWindow(qint64 &winId) 213 291 { 214 292 #ifdef Q_WS_MAC … … 228 306 } 229 307 308 309 /********************************************************************************************************************************* 310 * Class UIConsoleEventHandler implementation. * 311 *********************************************************************************************************************************/ 312 313 /* static */ 314 UIConsoleEventHandler *UIConsoleEventHandler::m_spInstance = 0; 315 316 /* static */ 317 void UIConsoleEventHandler::create(UISession *pSession) 318 { 319 if (!m_spInstance) 320 m_spInstance = new UIConsoleEventHandler(pSession); 321 } 322 323 /* static */ 324 void UIConsoleEventHandler::destroy() 325 { 326 if (m_spInstance) 327 { 328 delete m_spInstance; 329 m_spInstance = 0; 330 } 331 } 332 333 UIConsoleEventHandler::UIConsoleEventHandler(UISession *pSession) 334 : m_pProxy(new UIConsoleEventHandlerProxy(this, pSession)) 335 { 336 /* Prepare: */ 337 prepare(); 338 } 339 340 void UIConsoleEventHandler::prepare() 341 { 342 /* Prepare: */ 343 prepareConnections(); 344 } 345 346 void UIConsoleEventHandler::prepareConnections() 347 { 348 /* Create queued (async) connections for signals of event proxy object: */ 349 connect(m_pProxy, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)), 350 this, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)), 351 Qt::QueuedConnection); 352 connect(m_pProxy, SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)), 353 this, SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)), 354 Qt::QueuedConnection); 355 connect(m_pProxy, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)), 356 this, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)), 357 Qt::QueuedConnection); 358 connect(m_pProxy, SIGNAL(sigStateChange(KMachineState)), 359 this, SIGNAL(sigStateChange(KMachineState)), 360 Qt::QueuedConnection); 361 connect(m_pProxy, SIGNAL(sigAdditionsChange()), 362 this, SIGNAL(sigAdditionsChange()), 363 Qt::QueuedConnection); 364 connect(m_pProxy, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)), 365 this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)), 366 Qt::QueuedConnection); 367 connect(m_pProxy, SIGNAL(sigStorageDeviceChange(CMediumAttachment, bool, bool)), 368 this, SIGNAL(sigStorageDeviceChange(CMediumAttachment, bool, bool)), 369 Qt::QueuedConnection); 370 connect(m_pProxy, SIGNAL(sigMediumChange(CMediumAttachment)), 371 this, SIGNAL(sigMediumChange(CMediumAttachment)), 372 Qt::QueuedConnection); 373 connect(m_pProxy, SIGNAL(sigVRDEChange()), 374 this, SIGNAL(sigVRDEChange()), 375 Qt::QueuedConnection); 376 connect(m_pProxy, SIGNAL(sigVideoCaptureChange()), 377 this, SIGNAL(sigVideoCaptureChange()), 378 Qt::QueuedConnection); 379 connect(m_pProxy, SIGNAL(sigUSBControllerChange()), 380 this, SIGNAL(sigUSBControllerChange()), 381 Qt::QueuedConnection); 382 connect(m_pProxy, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)), 383 this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)), 384 Qt::QueuedConnection); 385 connect(m_pProxy, SIGNAL(sigSharedFolderChange()), 386 this, SIGNAL(sigSharedFolderChange()), 387 Qt::QueuedConnection); 388 connect(m_pProxy, SIGNAL(sigCPUExecutionCapChange()), 389 this, SIGNAL(sigCPUExecutionCapChange()), 390 Qt::QueuedConnection); 391 connect(m_pProxy, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)), 392 this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)), 393 Qt::QueuedConnection); 394 connect(m_pProxy, SIGNAL(sigRuntimeError(bool, QString, QString)), 395 this, SIGNAL(sigRuntimeError(bool, QString, QString)), 396 Qt::QueuedConnection); 397 #ifdef RT_OS_DARWIN 398 connect(m_pProxy, SIGNAL(sigShowWindow(qint64 &)), 399 this, SIGNAL(sigShowWindow(qint64 &)), 400 Qt::QueuedConnection); 401 #endif /* RT_OS_DARWIN */ 402 } 403 404 #include "UIConsoleEventHandler.moc" 405 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h
r60225 r60227 22 22 #include <QObject> 23 23 24 /* GUI includes: */25 #include "UIMainEventListener.h"26 27 24 /* COM includes: */ 28 25 #include "COMEnums.h" 29 #include "CEventListener.h"30 26 #include "CVirtualBoxErrorInfo.h" 31 27 #include "CMediumAttachment.h" … … 34 30 35 31 /* Forward declarations: */ 32 class UIConsoleEventHandlerProxy; 36 33 class UISession; 37 34 … … 95 92 /** Constructs console event handler for passed @a pSession. */ 96 93 UIConsoleEventHandler(UISession *pSession); 97 /** Destructs console event handler. */98 ~UIConsoleEventHandler();99 94 100 /** @name Prepare /Cleanupcascade.95 /** @name Prepare cascade. 101 96 * @{ */ 102 97 /** Prepares all. */ 103 98 void prepare(); 104 /** Prepares listener. */105 void prepareListener();106 99 /** Prepares connections. */ 107 100 void prepareConnections(); 108 109 /** Cleanups connections. */110 void cleanupConnections();111 /** Cleanups listener. */112 void cleanupListener();113 /** Cleanups all. */114 void cleanup();115 101 /** @} */ 116 117 private slots:118 119 /** Returns whether VM window can be shown. */120 void sltCanShowWindow(bool &fVeto, QString &strReason);121 /** Shows VM window if possible. */122 void sltShowWindow(qint64 &winId);123 102 124 103 private: … … 127 106 static UIConsoleEventHandler *m_spInstance; 128 107 129 /** Holds the Qt event listener instance. */ 130 ComObjPtr<UIMainEventListenerImpl> m_pQtListener; 131 /** Holds the COM event listener instance. */ 132 CEventListener m_comEventListener; 133 134 /** Holds the UI session reference. */ 135 UISession *m_pSession; 108 /** Holds the console event proxy instance. */ 109 UIConsoleEventHandlerProxy *m_pProxy; 136 110 }; 137 111 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp
r60225 r60227 22 22 /* GUI includes: */ 23 23 # include "UIVirtualBoxEventHandler.h" 24 # include "UIMainEventListener.h" 24 25 # include "VBoxGlobal.h" 25 26 26 27 /* COM includes: */ 28 # include "CEventListener.h" 27 29 # include "CEventSource.h" 30 # include "CVirtualBox.h" 31 # include "CVirtualBoxClient.h" 28 32 29 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 30 34 31 35 32 /* static */ 33 UIVirtualBoxEventHandler *UIVirtualBoxEventHandler::m_spInstance = 0; 34 35 /* static */ 36 UIVirtualBoxEventHandler* UIVirtualBoxEventHandler::instance() 37 { 38 if (!m_spInstance) 39 m_spInstance = new UIVirtualBoxEventHandler; 40 return m_spInstance; 41 } 42 43 /* static */ 44 void UIVirtualBoxEventHandler::destroy() 45 { 46 if (m_spInstance) 47 { 48 delete m_spInstance; 49 m_spInstance = 0; 50 } 51 } 52 53 UIVirtualBoxEventHandler::UIVirtualBoxEventHandler() 36 /** Private QObject extension 37 * providing UIVirtualBoxEventHandler with the CVirtualBoxClient and CVirtualBox event-sources. */ 38 class UIVirtualBoxEventHandlerProxy : public QObject 39 { 40 Q_OBJECT; 41 42 signals: 43 44 /** Notifies about the VBoxSVC become @a fAvailable. */ 45 void sigVBoxSVCAvailabilityChange(bool fAvailable); 46 47 /** Notifies about @a state change event for the machine with @a strId. */ 48 void sigMachineStateChange(QString strId, KMachineState state); 49 /** Notifies about data change event for the machine with @a strId. */ 50 void sigMachineDataChange(QString strId); 51 /** Notifies about machine with @a strId was @a fRegistered. */ 52 void sigMachineRegistered(QString strId, bool fRegistered); 53 /** Notifies about @a state change event for the session of the machine with @a strId. */ 54 void sigSessionStateChange(QString strId, KSessionState state); 55 /** Notifies about snapshot with @a strSnapshotId was taken for the machine with @a strId. */ 56 void sigSnapshotTake(QString strId, QString strSnapshotId); 57 /** Notifies about snapshot with @a strSnapshotId was deleted for the machine with @a strId. */ 58 void sigSnapshotDelete(QString strId, QString strSnapshotId); 59 /** Notifies about snapshot with @a strSnapshotId was changed for the machine with @a strId. */ 60 void sigSnapshotChange(QString strId, QString strSnapshotId); 61 /** Notifies about snapshot with @a strSnapshotId was restored for the machine with @a strId. */ 62 void sigSnapshotRestore(QString strId, QString strSnapshotId); 63 64 public: 65 66 /** Constructs event proxy object on the basis of passed @a pParent. */ 67 UIVirtualBoxEventHandlerProxy(QObject *pParent); 68 /** Destructs event proxy object. */ 69 ~UIVirtualBoxEventHandlerProxy(); 70 71 protected: 72 73 /** @name Prepare/Cleanup cascade. 74 * @{ */ 75 /** Prepares all. */ 76 void prepare(); 77 /** Prepares listener. */ 78 void prepareListener(); 79 /** Prepares connections. */ 80 void prepareConnections(); 81 82 /** Cleanups connections. */ 83 void cleanupConnections(); 84 /** Cleanups listener. */ 85 void cleanupListener(); 86 /** Cleanups all. */ 87 void cleanup(); 88 /** @} */ 89 90 private: 91 92 /** Holds the Qt event listener instance. */ 93 ComObjPtr<UIMainEventListenerImpl> m_pQtListener; 94 /** Holds the COM event listener instance. */ 95 CEventListener m_comEventListener; 96 }; 97 98 99 /********************************************************************************************************************************* 100 * Class UIVirtualBoxEventHandlerProxy implementation. * 101 *********************************************************************************************************************************/ 102 103 UIVirtualBoxEventHandlerProxy::UIVirtualBoxEventHandlerProxy(QObject *pParent) 104 : QObject(pParent) 54 105 { 55 106 /* Prepare: */ … … 57 108 } 58 109 59 UIVirtualBoxEventHandler ::~UIVirtualBoxEventHandler()110 UIVirtualBoxEventHandlerProxy::~UIVirtualBoxEventHandlerProxy() 60 111 { 61 112 /* Cleanup: */ … … 63 114 } 64 115 65 void UIVirtualBoxEventHandler ::prepare()116 void UIVirtualBoxEventHandlerProxy::prepare() 66 117 { 67 118 /* Prepare: */ … … 70 121 } 71 122 72 void UIVirtualBoxEventHandler ::prepareListener()123 void UIVirtualBoxEventHandlerProxy::prepareListener() 73 124 { 74 125 /* Create Main event listener instance: */ … … 111 162 } 112 163 113 void UIVirtualBoxEventHandler ::prepareConnections()114 { 115 /* Create queued (async) connections for non-waitable signals: */164 void UIVirtualBoxEventHandlerProxy::prepareConnections() 165 { 166 /* Create direct (sync) connections for signals of main listener: */ 116 167 connect(m_pQtListener->getWrapped(), SIGNAL(sigVBoxSVCAvailabilityChange(bool)), 117 168 this, SIGNAL(sigVBoxSVCAvailabilityChange(bool)), 118 Qt:: QueuedConnection);169 Qt::DirectConnection); 119 170 connect(m_pQtListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)), 120 171 this, SIGNAL(sigMachineStateChange(QString, KMachineState)), 121 Qt:: QueuedConnection);172 Qt::DirectConnection); 122 173 connect(m_pQtListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)), 123 174 this, SIGNAL(sigMachineDataChange(QString)), 124 Qt:: QueuedConnection);175 Qt::DirectConnection); 125 176 connect(m_pQtListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)), 126 177 this, SIGNAL(sigMachineRegistered(QString, bool)), 127 Qt:: QueuedConnection);178 Qt::DirectConnection); 128 179 connect(m_pQtListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)), 129 180 this, SIGNAL(sigSessionStateChange(QString, KSessionState)), 130 Qt:: QueuedConnection);181 Qt::DirectConnection); 131 182 connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotTake(QString, QString)), 132 183 this, SIGNAL(sigSnapshotTake(QString, QString)), 133 Qt:: QueuedConnection);184 Qt::DirectConnection); 134 185 connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotDelete(QString, QString)), 135 186 this, SIGNAL(sigSnapshotDelete(QString, QString)), 136 Qt:: QueuedConnection);187 Qt::DirectConnection); 137 188 connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)), 138 189 this, SIGNAL(sigSnapshotChange(QString, QString)), 139 Qt:: QueuedConnection);190 Qt::DirectConnection); 140 191 connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotRestore(QString, QString)), 141 192 this, SIGNAL(sigSnapshotRestore(QString, QString)), 142 Qt:: QueuedConnection);143 } 144 145 void UIVirtualBoxEventHandler ::cleanupConnections()193 Qt::DirectConnection); 194 } 195 196 void UIVirtualBoxEventHandlerProxy::cleanupConnections() 146 197 { 147 198 /* Nothing for now. */ 148 199 } 149 200 150 void UIVirtualBoxEventHandler ::cleanupListener()201 void UIVirtualBoxEventHandlerProxy::cleanupListener() 151 202 { 152 203 /* Get VirtualBox: */ … … 169 220 } 170 221 171 void UIVirtualBoxEventHandler ::cleanup()222 void UIVirtualBoxEventHandlerProxy::cleanup() 172 223 { 173 224 /* Cleanup: */ … … 176 227 } 177 228 229 230 /********************************************************************************************************************************* 231 * Class UIVirtualBoxEventHandler implementation. * 232 *********************************************************************************************************************************/ 233 234 /* static */ 235 UIVirtualBoxEventHandler *UIVirtualBoxEventHandler::m_spInstance = 0; 236 237 /* static */ 238 UIVirtualBoxEventHandler* UIVirtualBoxEventHandler::instance() 239 { 240 if (!m_spInstance) 241 m_spInstance = new UIVirtualBoxEventHandler; 242 return m_spInstance; 243 } 244 245 /* static */ 246 void UIVirtualBoxEventHandler::destroy() 247 { 248 if (m_spInstance) 249 { 250 delete m_spInstance; 251 m_spInstance = 0; 252 } 253 } 254 255 UIVirtualBoxEventHandler::UIVirtualBoxEventHandler() 256 : m_pProxy(new UIVirtualBoxEventHandlerProxy(this)) 257 { 258 /* Prepare: */ 259 prepare(); 260 } 261 262 void UIVirtualBoxEventHandler::prepare() 263 { 264 /* Prepare: */ 265 prepareConnections(); 266 } 267 268 void UIVirtualBoxEventHandler::prepareConnections() 269 { 270 /* Create queued (async) connections for signals of event proxy object: */ 271 connect(m_pProxy, SIGNAL(sigVBoxSVCAvailabilityChange(bool)), 272 this, SIGNAL(sigVBoxSVCAvailabilityChange(bool)), 273 Qt::QueuedConnection); 274 connect(m_pProxy, SIGNAL(sigMachineStateChange(QString, KMachineState)), 275 this, SIGNAL(sigMachineStateChange(QString, KMachineState)), 276 Qt::QueuedConnection); 277 connect(m_pProxy, SIGNAL(sigMachineDataChange(QString)), 278 this, SIGNAL(sigMachineDataChange(QString)), 279 Qt::QueuedConnection); 280 connect(m_pProxy, SIGNAL(sigMachineRegistered(QString, bool)), 281 this, SIGNAL(sigMachineRegistered(QString, bool)), 282 Qt::QueuedConnection); 283 connect(m_pProxy, SIGNAL(sigSessionStateChange(QString, KSessionState)), 284 this, SIGNAL(sigSessionStateChange(QString, KSessionState)), 285 Qt::QueuedConnection); 286 connect(m_pProxy, SIGNAL(sigSnapshotTake(QString, QString)), 287 this, SIGNAL(sigSnapshotTake(QString, QString)), 288 Qt::QueuedConnection); 289 connect(m_pProxy, SIGNAL(sigSnapshotDelete(QString, QString)), 290 this, SIGNAL(sigSnapshotDelete(QString, QString)), 291 Qt::QueuedConnection); 292 connect(m_pProxy, SIGNAL(sigSnapshotChange(QString, QString)), 293 this, SIGNAL(sigSnapshotChange(QString, QString)), 294 Qt::QueuedConnection); 295 connect(m_pProxy, SIGNAL(sigSnapshotRestore(QString, QString)), 296 this, SIGNAL(sigSnapshotRestore(QString, QString)), 297 Qt::QueuedConnection); 298 } 299 300 #include "UIVirtualBoxEventHandler.moc" 301 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h
r60225 r60227 22 22 #include <QObject> 23 23 24 /* GUI includes: */25 #include "UIMainEventListener.h"26 27 24 /* COM includes: */ 28 25 #include "COMEnums.h" 29 #include "CEventListener.h" 26 27 /* Forward declarations: */ 28 class UIVirtualBoxEventHandlerProxy; 30 29 31 30 … … 69 68 /** Constructs VirtualBox event handler. */ 70 69 UIVirtualBoxEventHandler(); 71 /** Destructs VirtualBox event handler. */72 ~UIVirtualBoxEventHandler();73 70 74 /** @name Prepare /Cleanupcascade.71 /** @name Prepare cascade. 75 72 * @{ */ 76 73 /** Prepares all. */ 77 74 void prepare(); 78 /** Prepares listener. */79 void prepareListener();80 75 /** Prepares connections. */ 81 76 void prepareConnections(); 82 83 /** Cleanups connections. */84 void cleanupConnections();85 /** Cleanups listener. */86 void cleanupListener();87 /** Cleanups all. */88 void cleanup();89 77 /** @} */ 90 78 … … 94 82 static UIVirtualBoxEventHandler *m_spInstance; 95 83 96 /** Holds the Qt event listener instance. */ 97 ComObjPtr<UIMainEventListenerImpl> m_pQtListener; 98 /** Holds the COM event listener instance. */ 99 CEventListener m_comEventListener; 84 /** Holds the VirtualBox event proxy instance. */ 85 UIVirtualBoxEventHandlerProxy *m_pProxy; 100 86 }; 101 87
Note:
See TracChangeset
for help on using the changeset viewer.