Changeset 54131 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 10, 2015 6:03:20 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 98156
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp
r52730 r54131 5 5 6 6 /* 7 * Copyright (C) 2010-201 2Oracle Corporation7 * Copyright (C) 2010-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 38 38 { 39 39 if (!m_pInstance) 40 m_pInstance = new UIVirtualBoxEventHandler ();40 m_pInstance = new UIVirtualBoxEventHandler; 41 41 return m_pInstance; 42 42 } … … 54 54 UIVirtualBoxEventHandler::UIVirtualBoxEventHandler() 55 55 { 56 // RTPrintf("Self add: %RTthrd\n", RTThreadSelf()); 57 const CVirtualBox &vbox = vboxGlobal().virtualBox(); 56 /* Create Main-event listener instance: */ 58 57 ComObjPtr<UIMainEventListenerImpl> pListener; 59 58 pListener.createObject(); 60 pListener->init(new UIMainEventListener (), this);59 pListener->init(new UIMainEventListener, this); 61 60 m_mainEventListener = CEventListener(pListener); 61 62 /* Get VirtualBox: */ 63 const CVirtualBox vbox = vboxGlobal().virtualBox(); 64 AssertWrapperOk(vbox); 65 /* Get event-source: */ 66 CEventSource eventSource = vbox.GetEventSource(); 67 AssertWrapperOk(eventSource); 68 /* Register listener for expected event-types: */ 62 69 QVector<KVBoxEventType> events; 63 70 events … … 69 76 << KVBoxEventType_OnSnapshotDeleted 70 77 << KVBoxEventType_OnSnapshotChanged; 78 eventSource.RegisterListener(m_mainEventListener, events, TRUE); 79 AssertWrapperOk(eventSource); 71 80 72 vbox.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE); 73 AssertWrapperOk(vbox); 74 81 /* Prepare connections: */ 75 82 connect(pListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)), 76 83 this, SIGNAL(sigMachineStateChange(QString, KMachineState)), 77 84 Qt::QueuedConnection); 78 79 85 connect(pListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)), 80 86 this, SIGNAL(sigMachineDataChange(QString)), 81 87 Qt::QueuedConnection); 82 83 88 connect(pListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)), 84 89 this, SIGNAL(sigMachineRegistered(QString, bool)), 85 90 Qt::QueuedConnection); 86 87 91 connect(pListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)), 88 92 this, SIGNAL(sigSessionStateChange(QString, KSessionState)), 89 93 Qt::QueuedConnection); 90 91 94 connect(pListener->getWrapped(), SIGNAL(sigSnapshotTake(QString, QString)), 92 95 this, SIGNAL(sigSnapshotTake(QString, QString)), 93 96 Qt::QueuedConnection); 94 95 97 connect(pListener->getWrapped(), SIGNAL(sigSnapshotDelete(QString, QString)), 96 98 this, SIGNAL(sigSnapshotDelete(QString, QString)), 97 99 Qt::QueuedConnection); 98 99 100 connect(pListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)), 100 101 this, SIGNAL(sigSnapshotChange(QString, QString)), … … 104 105 UIVirtualBoxEventHandler::~UIVirtualBoxEventHandler() 105 106 { 106 const CVirtualBox &vbox = vboxGlobal().virtualBox(); 107 vbox.GetEventSource().UnregisterListener(m_mainEventListener); 107 /* Get VirtualBox: */ 108 const CVirtualBox vbox = vboxGlobal().virtualBox(); 109 AssertWrapperOk(vbox); 110 /* Get event-source: */ 111 CEventSource eventSource = vbox.GetEventSource(); 112 AssertWrapperOk(eventSource); 113 /* Unregister listener: */ 114 eventSource.UnregisterListener(m_mainEventListener); 108 115 } 116 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h
r52727 r54131 4 4 5 5 /* 6 * Copyright (C) 2010-201 2Oracle Corporation6 * Copyright (C) 2010-2015 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 15 15 */ 16 16 17 #ifndef __ UIVirtualBoxEventHandler_h__18 #define __ UIVirtualBoxEventHandler_h__17 #ifndef ___UIVirtualBoxEventHandler_h___ 18 #define ___UIVirtualBoxEventHandler_h___ 19 19 20 20 /* COM includes: */ … … 22 22 #include "CEventListener.h" 23 23 24 class UIVirtualBoxEventHandler: public QObject 24 /** Active event handler singleton for the CVirtualBox event-source. */ 25 class UIVirtualBoxEventHandler : public QObject 25 26 { 26 27 Q_OBJECT; 27 28 29 signals: 30 31 /** Notifies listeners about @a state change event for the machine with @a strId. */ 32 void sigMachineStateChange(QString strId, KMachineState state); 33 /** Notifies listeners about data change event for the machine with @a strId. */ 34 void sigMachineDataChange(QString strId); 35 /** Notifies listeners about machine with @a strId was @a fRegistered. */ 36 void sigMachineRegistered(QString strId, bool fRegistered); 37 /** Notifies listeners about @a state change event for the session of the machine with @a strId. */ 38 void sigSessionStateChange(QString strId, KSessionState state); 39 /** Notifies listeners about snapshot with @a strSnapshotId was taken for the machine with @a strId. */ 40 void sigSnapshotTake(QString strId, QString strSnapshotId); 41 /** Notifies listeners about snapshot with @a strSnapshotId was deleted for the machine with @a strId. */ 42 void sigSnapshotDelete(QString strId, QString strSnapshotId); 43 /** Notifies listeners about snapshot with @a strSnapshotId was changed for the machine with @a strId. */ 44 void sigSnapshotChange(QString strId, QString strSnapshotId); 45 28 46 public: 47 48 /** Returns singleton instance created by the factory. */ 29 49 static UIVirtualBoxEventHandler* instance(); 50 /** Destroys singleton instance created by the factory. */ 30 51 static void destroy(); 31 52 32 signals: 33 /* VirtualBox main signals */ 34 void sigMachineStateChange(QString strId, KMachineState state); 35 void sigMachineDataChange(QString strId); 36 void sigMachineRegistered(QString strId, bool fRegistered); 37 void sigSessionStateChange(QString strId, KSessionState state); 38 void sigSnapshotTake(QString strId, QString strSnapshotId); 39 void sigSnapshotDelete(QString strId, QString strSnapshotId); 40 void sigSnapshotChange(QString strId, QString strSnapshotId); 53 private: 41 54 42 private: 55 /** Constructor. */ 43 56 UIVirtualBoxEventHandler(); 57 /** Destructor. */ 44 58 ~UIVirtualBoxEventHandler(); 45 59 46 /* Private member vars*/60 /** Holds the static singleton instance. */ 47 61 static UIVirtualBoxEventHandler *m_pInstance; 62 /** Holds the COM event-listener instance. */ 48 63 CEventListener m_mainEventListener; 49 64 }; … … 51 66 #define gVBoxEvents UIVirtualBoxEventHandler::instance() 52 67 53 #endif /* !__UIVirtualBoxEventHandler_h__ */ 54 68 #endif /* !___UIVirtualBoxEventHandler_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.