UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent) : QIWithRetranslateUI<QWidget>(pParent) , m_machineState(KMachineState_Null) , m_pUpdateTimer(new QTimer(this)) , m_vMargin(10) , m_pbgImage(0) , m_pPreviewImg(0) , m_pGlossyImg(0) { m_session.createInstance(CLSID_Session); setContentsMargins(0, 5, 0, 5); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); /* Connect the update timer */ connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview())); /* Connect the machine state event */ connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString, KMachineState))); /* Create the context menu */ setContextMenuPolicy(Qt::DefaultContextMenu); m_pUpdateTimerMenu = new QMenu(this); QActionGroup *pUpdateTimeG = new QActionGroup(this); pUpdateTimeG->setExclusive(true); for(int i = 0; i < UpdateEnd; ++i) { QAction *pUpdateTime = new QAction(pUpdateTimeG); pUpdateTime->setData(i); pUpdateTime->setCheckable(true); pUpdateTimeG->addAction(pUpdateTime); m_pUpdateTimerMenu->addAction(pUpdateTime); m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime; } m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(Update500ms)]); /* Default value */ UpdateInterval interval = Update1000ms; QString strInterval = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_PreviewUpdate); if (strInterval == "disabled") interval = UpdateDisabled; else if (strInterval == "500") interval = Update500ms; else if (strInterval == "1000") interval = Update1000ms; else if (strInterval == "2000") interval = Update2000ms; else if (strInterval == "5000") interval = Update5000ms; else if (strInterval == "10000") interval = Update10000ms; /* Initialize with the new update interval */ setUpdateInterval(interval, false); /* Retranslate the UI */ retranslateUi(); }
UIVirtualBoxEventHandler::UIVirtualBoxEventHandler() { // RTPrintf("Self add: %RTthrd\n", RTThreadSelf()); const CVirtualBox &vbox = vboxGlobal().virtualBox(); ComObjPtr<UIMainEventListenerImpl> pListener; pListener.createObject(); pListener->init(new UIMainEventListener(), this); m_mainEventListener = CEventListener(pListener); QVector<KVBoxEventType> events; events << KVBoxEventType_OnMachineStateChanged << KVBoxEventType_OnMachineDataChanged << KVBoxEventType_OnMachineRegistered << KVBoxEventType_OnSessionStateChanged << KVBoxEventType_OnSnapshotTaken << KVBoxEventType_OnSnapshotDeleted << KVBoxEventType_OnSnapshotChanged; vbox.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE); AssertWrapperOk(vbox); connect(pListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SIGNAL(sigMachineStateChange(QString, KMachineState)), Qt::QueuedConnection); connect(pListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)), this, SIGNAL(sigMachineDataChange(QString)), Qt::QueuedConnection); connect(pListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)), this, SIGNAL(sigMachineRegistered(QString, bool)), Qt::QueuedConnection); connect(pListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SIGNAL(sigSessionStateChange(QString, KSessionState)), Qt::QueuedConnection); connect(pListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)), this, SIGNAL(sigSnapshotChange(QString, QString)), Qt::QueuedConnection); }
void UIGDetailsSet::prepareConnections() { /* Global-events connections: */ connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString))); connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltMachineAttributesChange(QString))); connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltMachineAttributesChange(QString))); connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltMachineAttributesChange(QString))); /* Meidum-enumeration connections: */ connect(&vboxGlobal(), SIGNAL(mediumEnumStarted()), this, SLOT(sltUpdateAppearance())); connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltUpdateAppearance())); }
/* Constructor: */ UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent) : QIWithRetranslateUI<QWidget>(pParent) , m_machineState(KMachineState_Null) , m_pUpdateTimer(new QTimer(this)) , m_vMargin(10) , m_pbgImage(0) , m_pPreviewImg(0) , m_pGlossyImg(0) { /* Setup contents: */ setContentsMargins(0, 5, 0, 5); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); /* Create session instance: */ m_session.createInstance(CLSID_Session); /* Create the context menu: */ setContextMenuPolicy(Qt::DefaultContextMenu); m_pUpdateTimerMenu = new QMenu(this); QActionGroup *pUpdateTimeG = new QActionGroup(this); pUpdateTimeG->setExclusive(true); for(int i = 0; i < UpdateInterval_Max; ++i) { QAction *pUpdateTime = new QAction(pUpdateTimeG); pUpdateTime->setData(i); pUpdateTime->setCheckable(true); pUpdateTimeG->addAction(pUpdateTime); m_pUpdateTimerMenu->addAction(pUpdateTime); m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime; } m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(UpdateInterval_500ms)]); /* Load preview update interval: */ QString strInterval = vboxGlobal().virtualBox().GetExtraData(GUI_PreviewUpdate); /* Parse loaded value: */ UpdateInterval interval = m_intervals.key(strInterval, UpdateInterval_1000ms); /* Initialize with the new update interval: */ setUpdateInterval(interval, false); /* Setup connections: */ connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview())); connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString, KMachineState))); /* Retranslate the UI */ retranslateUi(); }
void UIGChooser::prepareConnections() { /* Chooser-model connections: */ connect(m_pChooserModel, SIGNAL(sigRootItemResized(const QSizeF&, int)), m_pChooserView, SLOT(sltHandleRootItemResized(const QSizeF&, int))); connect(m_pChooserModel, SIGNAL(sigSelectionChanged()), this, SIGNAL(sigSelectionChanged())); connect(m_pChooserModel, SIGNAL(sigSlidingStarted()), this, SIGNAL(sigSlidingStarted())); /* Chooser-view connections: */ connect(m_pChooserView, SIGNAL(sigResized()), m_pChooserModel, SLOT(sltHandleViewResized())); /* Global connections: */ connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), m_pChooserModel, SLOT(sltMachineStateChanged(QString, KMachineState))); connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), m_pChooserModel, SLOT(sltMachineDataChanged(QString))); connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)), m_pChooserModel, SLOT(sltMachineRegistered(QString, bool))); connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), m_pChooserModel, SLOT(sltSessionStateChanged(QString, KSessionState))); connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), m_pChooserModel, SLOT(sltSnapshotChanged(QString, QString))); }
UIGDetailsSet::UIGDetailsSet(UIGDetailsItem *pParent) : UIGDetailsItem(pParent) , m_iStep(-1) , m_iLastStep(-1) { /* Setup size-policy: */ setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); /* Add item to the parent: */ parentItem()->addItem(this); /* Prepare connections: */ connect(this, SIGNAL(sigStartFirstStep(QString)), this, SLOT(sltFirstStep(QString)), Qt::QueuedConnection); connect(this, SIGNAL(sigElementPrepared(QString)), this, SLOT(sltNextStep(QString)), Qt::QueuedConnection); connect(this, SIGNAL(sigSetPrepared()), this, SLOT(sltSetPrepared()), Qt::QueuedConnection); connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString))); connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltMachineAttributesChange(QString))); connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltMachineAttributesChange(QString))); connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltMachineAttributesChange(QString))); connect(&vboxGlobal(), SIGNAL(mediumEnumStarted()), this, SLOT(sltUpdateAppearance())); connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltUpdateAppearance())); }
void UIMachineWindow::cleanupSessionConnections() { /* We should stop watching for console events: */ disconnect(uisession(), SIGNAL(sigMachineStateChange()), this, SLOT(sltMachineStateChanged())); }
void UIMachineWindow::prepareSessionConnections() { /* We should watch for console events: */ connect(uisession(), SIGNAL(sigMachineStateChange()), this, SLOT(sltMachineStateChanged())); }
VBoxSnapshotsWgt::VBoxSnapshotsWgt (QWidget *aParent) : QIWithRetranslateUI <QWidget> (aParent) , mCurSnapshotItem (0) , mEditProtector (false) , mSnapshotActionGroup (new QActionGroup (this)) , mCurStateActionGroup (new QActionGroup (this)) , mRestoreSnapshotAction (new QAction (mSnapshotActionGroup)) , mDeleteSnapshotAction (new QAction (mSnapshotActionGroup)) , mShowSnapshotDetailsAction (new QAction (mSnapshotActionGroup)) , mTakeSnapshotAction (new QAction (mCurStateActionGroup)) , mCloneSnapshotAction(new QAction(mCurStateActionGroup)) , m_fShapshotOperationsAllowed(false) { /* Apply UI decorations */ Ui::VBoxSnapshotsWgt::setupUi (this); mTreeWidget->header()->hide(); /* The snapshots widget is not very useful if there are a lot * of snapshots in a tree and the current Qt style decides not * to draw lines (branches) between the snapshot nodes; it is * then often unclear which snapshot is a child of another. * So on platforms whose styles do not normally draw branches, * we use QWindowsStyle which is present on every platform and * draws required thing like we want. */ // #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) QWindowsStyle *treeWidgetStyle = new QWindowsStyle; mTreeWidget->setStyle (treeWidgetStyle); connect (mTreeWidget, SIGNAL (destroyed (QObject *)), treeWidgetStyle, SLOT (deleteLater())); // #endif /* ToolBar creation */ UIToolBar *toolBar = new UIToolBar (this); toolBar->setUsesTextLabel (false); toolBar->setIconSize (QSize (22, 22)); toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); toolBar->addAction (mTakeSnapshotAction); toolBar->addSeparator(); toolBar->addAction (mRestoreSnapshotAction); toolBar->addAction (mDeleteSnapshotAction); toolBar->addAction (mShowSnapshotDetailsAction); toolBar->addSeparator(); toolBar->addAction(mCloneSnapshotAction); ((QVBoxLayout*)layout())->insertWidget (0, toolBar); /* Setup actions */ mRestoreSnapshotAction->setIcon(UIIconPool::iconSetFull( QSize (22, 22), QSize (16, 16), ":/snapshot_restore_22px.png", ":/snapshot_restore_16px.png", ":/snapshot_restore_disabled_22px.png", ":/snapshot_restore_disabled_16px.png")); mDeleteSnapshotAction->setIcon(UIIconPool::iconSetFull( QSize (22, 22), QSize (16, 16), ":/snapshot_delete_22px.png", ":/snapshot_delete_16px.png", ":/snapshot_delete_disabled_22px.png", ":/snapshot_delete_disabled_16px.png")); mShowSnapshotDetailsAction->setIcon(UIIconPool::iconSetFull( QSize (22, 22), QSize (16, 16), ":/snapshot_show_details_22px.png", ":/snapshot_show_details_16px.png", ":/snapshot_show_details_disabled_22px.png", ":/snapshot_details_show_disabled_16px.png")); mTakeSnapshotAction->setIcon(UIIconPool::iconSetFull( QSize (22, 22), QSize (16, 16), ":/snapshot_take_22px.png", ":/snapshot_take_16px.png", ":/snapshot_take_disabled_22px.png", ":/snapshot_take_disabled_16px.png")); mCloneSnapshotAction->setIcon(UIIconPool::iconSetFull( QSize (22, 22), QSize (16, 16), ":/vm_clone_22px.png", ":/vm_clone_16px.png", ":/vm_clone_disabled_22px.png", ":/vm_clone_disabled_16px.png")); mRestoreSnapshotAction->setShortcut (QString ("Ctrl+Shift+R")); mDeleteSnapshotAction->setShortcut (QString ("Ctrl+Shift+D")); mShowSnapshotDetailsAction->setShortcut (QString ("Ctrl+Space")); mTakeSnapshotAction->setShortcut (QString ("Ctrl+Shift+S")); mCloneSnapshotAction->setShortcut(QString ("Ctrl+Shift+C")); mAgeUpdateTimer.setSingleShot (true); /* Setup connections */ connect (mTreeWidget, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT (onCurrentChanged (QTreeWidgetItem*))); connect (mTreeWidget, SIGNAL (customContextMenuRequested (const QPoint&)), this, SLOT (onContextMenuRequested (const QPoint&))); connect (mTreeWidget, SIGNAL (itemChanged (QTreeWidgetItem*, int)), this, SLOT (onItemChanged (QTreeWidgetItem*))); connect(mTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT (sltItemDoubleClicked(QTreeWidgetItem*))); connect (mTakeSnapshotAction, SIGNAL (triggered()), this, SLOT (sltTakeSnapshot())); connect (mRestoreSnapshotAction, SIGNAL (triggered()), this, SLOT (sltRestoreSnapshot())); connect (mDeleteSnapshotAction, SIGNAL (triggered()), this, SLOT (sltDeleteSnapshot())); connect (mShowSnapshotDetailsAction, SIGNAL (triggered()), this, SLOT (sltShowSnapshotDetails())); connect (mCloneSnapshotAction, SIGNAL(triggered()), this, SLOT(sltCloneSnapshot())); connect (gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(machineDataChanged(QString))); connect (gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(machineStateChanged(QString, KMachineState))); connect (gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sessionStateChanged(QString, KSessionState))); connect (&mAgeUpdateTimer, SIGNAL (timeout()), this, SLOT (updateSnapshotsAge())); retranslateUi(); }
void UIMachineWindow::prepareSessionConnections() { /* Machine state-change updater: */ connect(uisession(), SIGNAL(sigMachineStateChange()), this, SLOT(sltMachineStateChanged())); }
STDMETHODIMP UIMainEventListener::HandleEvent(VBoxEventType_T, IEvent *pEvent) { /* Try to acquire COM cleanup protection token first: */ if (!vboxGlobal().comTokenTryLockForRead()) return S_OK; CEvent comEvent(pEvent); //printf("Event received: %d\n", comEvent.GetType()); switch (comEvent.GetType()) { case KVBoxEventType_OnVBoxSVCAvailabilityChanged: { CVBoxSVCAvailabilityChangedEvent comEventSpecific(pEvent); emit sigVBoxSVCAvailabilityChange(comEventSpecific.GetAvailable()); break; } case KVBoxEventType_OnMachineStateChanged: { CMachineStateChangedEvent comEventSpecific(pEvent); emit sigMachineStateChange(comEventSpecific.GetMachineId(), comEventSpecific.GetState()); break; } case KVBoxEventType_OnMachineDataChanged: { CMachineDataChangedEvent comEventSpecific(pEvent); emit sigMachineDataChange(comEventSpecific.GetMachineId()); break; } case KVBoxEventType_OnMachineRegistered: { CMachineRegisteredEvent comEventSpecific(pEvent); emit sigMachineRegistered(comEventSpecific.GetMachineId(), comEventSpecific.GetRegistered()); break; } case KVBoxEventType_OnSessionStateChanged: { CSessionStateChangedEvent comEventSpecific(pEvent); emit sigSessionStateChange(comEventSpecific.GetMachineId(), comEventSpecific.GetState()); break; } case KVBoxEventType_OnSnapshotTaken: { CSnapshotTakenEvent comEventSpecific(pEvent); emit sigSnapshotTake(comEventSpecific.GetMachineId(), comEventSpecific.GetSnapshotId()); break; } case KVBoxEventType_OnSnapshotDeleted: { CSnapshotDeletedEvent comEventSpecific(pEvent); emit sigSnapshotDelete(comEventSpecific.GetMachineId(), comEventSpecific.GetSnapshotId()); break; } case KVBoxEventType_OnSnapshotChanged: { CSnapshotChangedEvent comEventSpecific(pEvent); emit sigSnapshotChange(comEventSpecific.GetMachineId(), comEventSpecific.GetSnapshotId()); break; } case KVBoxEventType_OnSnapshotRestored: { CSnapshotRestoredEvent comEventSpecific(pEvent); emit sigSnapshotRestore(comEventSpecific.GetMachineId(), comEventSpecific.GetSnapshotId()); break; } case KVBoxEventType_OnExtraDataCanChange: { CExtraDataCanChangeEvent comEventSpecific(pEvent); /* Has to be done in place to give an answer: */ bool fVeto = false; QString strReason; emit sigExtraDataCanChange(comEventSpecific.GetMachineId(), comEventSpecific.GetKey(), comEventSpecific.GetValue(), fVeto, strReason); if (fVeto) comEventSpecific.AddVeto(strReason); break; } case KVBoxEventType_OnExtraDataChanged: { CExtraDataChangedEvent comEventSpecific(pEvent); emit sigExtraDataChange(comEventSpecific.GetMachineId(), comEventSpecific.GetKey(), comEventSpecific.GetValue()); break; } case KVBoxEventType_OnStorageControllerChanged: { CStorageControllerChangedEvent comEventSpecific(pEvent); emit sigStorageControllerChange(comEventSpecific.GetMachinId(), comEventSpecific.GetControllerName()); break; } case KVBoxEventType_OnStorageDeviceChanged: { CStorageDeviceChangedEvent comEventSpecific(pEvent); emit sigStorageDeviceChange(comEventSpecific.GetStorageDevice(), comEventSpecific.GetRemoved(), comEventSpecific.GetSilent()); break; } case KVBoxEventType_OnMediumChanged: { CMediumChangedEvent comEventSpecific(pEvent); emit sigMediumChange(comEventSpecific.GetMediumAttachment()); break; } case KVBoxEventType_OnMediumConfigChanged: { CMediumConfigChangedEvent comEventSpecific(pEvent); emit sigMediumConfigChange(comEventSpecific.GetMedium()); break; } case KVBoxEventType_OnMediumRegistered: { CMediumRegisteredEvent comEventSpecific(pEvent); emit sigMediumRegistered(comEventSpecific.GetMediumId(), comEventSpecific.GetMediumType(), comEventSpecific.GetRegistered()); break; } case KVBoxEventType_OnMousePointerShapeChanged: { CMousePointerShapeChangedEvent comEventSpecific(pEvent); emit sigMousePointerShapeChange(comEventSpecific.GetVisible(), comEventSpecific.GetAlpha(), QPoint(comEventSpecific.GetXhot(), comEventSpecific.GetYhot()), QSize(comEventSpecific.GetWidth(), comEventSpecific.GetHeight()), comEventSpecific.GetShape()); break; } case KVBoxEventType_OnMouseCapabilityChanged: { CMouseCapabilityChangedEvent comEventSpecific(pEvent); emit sigMouseCapabilityChange(comEventSpecific.GetSupportsAbsolute(), comEventSpecific.GetSupportsRelative(), comEventSpecific.GetSupportsMultiTouch(), comEventSpecific.GetNeedsHostCursor()); break; } case KVBoxEventType_OnCursorPositionChanged: { CCursorPositionChangedEvent comEventSpecific(pEvent); emit sigCursorPositionChange(comEventSpecific.GetHasData(), (unsigned long)comEventSpecific.GetX(), (unsigned long)comEventSpecific.GetY()); break; } case KVBoxEventType_OnKeyboardLedsChanged: { CKeyboardLedsChangedEvent comEventSpecific(pEvent); emit sigKeyboardLedsChangeEvent(comEventSpecific.GetNumLock(), comEventSpecific.GetCapsLock(), comEventSpecific.GetScrollLock()); break; } case KVBoxEventType_OnStateChanged: { CStateChangedEvent comEventSpecific(pEvent); emit sigStateChange(comEventSpecific.GetState()); break; } case KVBoxEventType_OnAdditionsStateChanged: { emit sigAdditionsChange(); break; } case KVBoxEventType_OnNetworkAdapterChanged: { CNetworkAdapterChangedEvent comEventSpecific(pEvent); emit sigNetworkAdapterChange(comEventSpecific.GetNetworkAdapter()); break; } case KVBoxEventType_OnVRDEServerChanged: case KVBoxEventType_OnVRDEServerInfoChanged: { emit sigVRDEChange(); break; } case KVBoxEventType_OnRecordingChanged: { emit sigRecordingChange(); break; } case KVBoxEventType_OnUSBControllerChanged: { emit sigUSBControllerChange(); break; } case KVBoxEventType_OnUSBDeviceStateChanged: { CUSBDeviceStateChangedEvent comEventSpecific(pEvent); emit sigUSBDeviceStateChange(comEventSpecific.GetDevice(), comEventSpecific.GetAttached(), comEventSpecific.GetError()); break; } case KVBoxEventType_OnSharedFolderChanged: { emit sigSharedFolderChange(); break; } case KVBoxEventType_OnCPUExecutionCapChanged: { emit sigCPUExecutionCapChange(); break; } case KVBoxEventType_OnGuestMonitorChanged: { CGuestMonitorChangedEvent comEventSpecific(pEvent); emit sigGuestMonitorChange(comEventSpecific.GetChangeType(), comEventSpecific.GetScreenId(), QRect(comEventSpecific.GetOriginX(), comEventSpecific.GetOriginY(), comEventSpecific.GetWidth(), comEventSpecific.GetHeight())); break; } case KVBoxEventType_OnRuntimeError: { CRuntimeErrorEvent comEventSpecific(pEvent); emit sigRuntimeError(comEventSpecific.GetFatal(), comEventSpecific.GetId(), comEventSpecific.GetMessage()); break; } case KVBoxEventType_OnCanShowWindow: { CCanShowWindowEvent comEventSpecific(pEvent); /* Has to be done in place to give an answer: */ bool fVeto = false; QString strReason; emit sigCanShowWindow(fVeto, strReason); if (fVeto) comEventSpecific.AddVeto(strReason); else comEventSpecific.AddApproval(strReason); break; } case KVBoxEventType_OnShowWindow: { CShowWindowEvent comEventSpecific(pEvent); /* Has to be done in place to give an answer: */ qint64 winId = comEventSpecific.GetWinId(); if (winId != 0) break; /* Already set by some listener. */ emit sigShowWindow(winId); comEventSpecific.SetWinId(winId); break; } case KVBoxEventType_OnAudioAdapterChanged: { emit sigAudioAdapterChange(); break; } case KVBoxEventType_OnProgressPercentageChanged: { CProgressPercentageChangedEvent comEventSpecific(pEvent); emit sigProgressPercentageChange(comEventSpecific.GetProgressId(), (int)comEventSpecific.GetPercent()); break; } case KVBoxEventType_OnProgressTaskCompleted: { CProgressTaskCompletedEvent comEventSpecific(pEvent); emit sigProgressTaskComplete(comEventSpecific.GetProgressId()); break; } case KVBoxEventType_OnGuestSessionRegistered: { CGuestSessionRegisteredEvent comEventSpecific(pEvent); if (comEventSpecific.GetRegistered()) emit sigGuestSessionRegistered(comEventSpecific.GetSession()); else emit sigGuestSessionUnregistered(comEventSpecific.GetSession()); break; } case KVBoxEventType_OnGuestProcessRegistered: { CGuestProcessRegisteredEvent comEventSpecific(pEvent); if (comEventSpecific.GetRegistered()) emit sigGuestProcessRegistered(comEventSpecific.GetProcess()); else emit sigGuestProcessUnregistered(comEventSpecific.GetProcess()); break; } case KVBoxEventType_OnGuestSessionStateChanged: { CGuestSessionStateChangedEvent comEventSpecific(pEvent); emit sigGuestSessionStatedChanged(comEventSpecific); break; } case KVBoxEventType_OnGuestProcessInputNotify: case KVBoxEventType_OnGuestProcessOutput: { break; } case KVBoxEventType_OnGuestProcessStateChanged: { CGuestProcessStateChangedEvent comEventSpecific(pEvent); comEventSpecific.GetError(); emit sigGuestProcessStateChanged(comEventSpecific); break; } case KVBoxEventType_OnGuestFileRegistered: case KVBoxEventType_OnGuestFileStateChanged: case KVBoxEventType_OnGuestFileOffsetChanged: case KVBoxEventType_OnGuestFileRead: case KVBoxEventType_OnGuestFileWrite: { break; } default: break; } /* Unlock COM cleanup protection token: */ vboxGlobal().comTokenUnlock(); return S_OK; }
/** * @todo: instead of double wrapping of events into signals maybe it * make sense to use passive listeners, and peek up events in main thread. */ STDMETHODIMP UIMainEventListener::HandleEvent(VBoxEventType_T /* type */, IEvent *pEvent) { CEvent event(pEvent); // printf("Event received: %d\n", event.GetType()); switch(event.GetType()) { /* * All VirtualBox Events */ case KVBoxEventType_OnMachineStateChanged: { CMachineStateChangedEvent es(pEvent); emit sigMachineStateChange(es.GetMachineId(), es.GetState()); break; } case KVBoxEventType_OnMachineDataChanged: { CMachineDataChangedEvent es(pEvent); emit sigMachineDataChange(es.GetMachineId()); break; } case KVBoxEventType_OnExtraDataCanChange: { CExtraDataCanChangeEvent es(pEvent); /* Has to be done in place to give an answer */ bool fVeto = false; QString strReason; emit sigExtraDataCanChange(es.GetMachineId(), es.GetKey(), es.GetValue(), fVeto, strReason); if (fVeto) es.AddVeto(strReason); break; } case KVBoxEventType_OnExtraDataChanged: { CExtraDataChangedEvent es(pEvent); emit sigExtraDataChange(es.GetMachineId(), es.GetKey(), es.GetValue()); break; } /* Not used: case KVBoxEventType_OnMediumRegistered: */ case KVBoxEventType_OnMachineRegistered: { CMachineRegisteredEvent es(pEvent); emit sigMachineRegistered(es.GetMachineId(), es.GetRegistered()); break; } case KVBoxEventType_OnSessionStateChanged: { CSessionStateChangedEvent es(pEvent); emit sigSessionStateChange(es.GetMachineId(), es.GetState()); break; } /* Not used: case KVBoxEventType_OnSnapshotTaken: case KVBoxEventType_OnSnapshotDeleted: */ case KVBoxEventType_OnSnapshotChanged: { CSnapshotChangedEvent es(pEvent); emit sigSnapshotChange(es.GetMachineId(), es.GetSnapshotId()); break; } /* Not used: case KVBoxEventType_OnGuestPropertyChange: */ /* * All Console Events */ case KVBoxEventType_OnMousePointerShapeChanged: { CMousePointerShapeChangedEvent es(pEvent); emit sigMousePointerShapeChange(es.GetVisible(), es.GetAlpha(), QPoint(es.GetXhot(), es.GetYhot()), QSize(es.GetWidth(), es.GetHeight()), es.GetShape()); break; } case KVBoxEventType_OnMouseCapabilityChanged: { CMouseCapabilityChangedEvent es(pEvent); emit sigMouseCapabilityChange(es.GetSupportsAbsolute(), es.GetSupportsRelative(), es.GetNeedsHostCursor()); break; } case KVBoxEventType_OnKeyboardLedsChanged: { CKeyboardLedsChangedEvent es(pEvent); emit sigKeyboardLedsChangeEvent(es.GetNumLock(), es.GetCapsLock(), es.GetScrollLock()); break; } case KVBoxEventType_OnStateChanged: { CStateChangedEvent es(pEvent); emit sigStateChange(es.GetState()); break; } case KVBoxEventType_OnAdditionsStateChanged: { emit sigAdditionsChange(); break; } case KVBoxEventType_OnNetworkAdapterChanged: { CNetworkAdapterChangedEvent es(pEvent); emit sigNetworkAdapterChange(es.GetNetworkAdapter()); break; } /* Not used * case KVBoxEventType_OnSerialPortChanged: case KVBoxEventType_OnParallelPortChanged: case KVBoxEventType_OnStorageControllerChanged: */ case KVBoxEventType_OnMediumChanged: { CMediumChangedEvent es(pEvent); emit sigMediumChange(es.GetMediumAttachment()); break; } /* Not used * case KVBoxEventType_OnCPUChange: */ case KVBoxEventType_OnVRDEServerChanged: case KVBoxEventType_OnVRDEServerInfoChanged: { emit sigVRDEChange(); break; } case KVBoxEventType_OnUSBControllerChanged: { emit sigUSBControllerChange(); break; } case KVBoxEventType_OnUSBDeviceStateChanged: { CUSBDeviceStateChangedEvent es(pEvent); emit sigUSBDeviceStateChange(es.GetDevice(), es.GetAttached(), es.GetError()); break; } case KVBoxEventType_OnSharedFolderChanged: { emit sigSharedFolderChange(); break; } case KVBoxEventType_OnRuntimeError: { CRuntimeErrorEvent es(pEvent); emit sigRuntimeError(es.GetFatal(), es.GetId(), es.GetMessage()); break; } case KVBoxEventType_OnCanShowWindow: { CCanShowWindowEvent es(pEvent); /* Has to be done in place to give an answer */ bool fVeto = false; QString strReason; emit sigCanShowWindow(fVeto, strReason); if (fVeto) es.AddVeto(strReason); break; } case KVBoxEventType_OnShowWindow: { CShowWindowEvent es(pEvent); /* Has to be done in place to give an answer */ LONG64 winId; emit sigShowWindow(winId); es.SetWinId(winId); break; } case KVBoxEventType_OnCPUExecutionCapChanged: { emit sigCPUExecutionCapChange(); break; } case KVBoxEventType_OnGuestMonitorChanged: { CGuestMonitorChangedEvent es(pEvent); emit sigGuestMonitorChange(es.GetChangeType(), es.GetScreenId(), QRect(es.GetOriginX(), es.GetOriginY(), es.GetWidth(), es.GetHeight())); break; } default: break; } return S_OK; }