コード例 #1
0
ファイル: UIMediumEnumerator.cpp プロジェクト: jeppeter/vbox
UIMediumEnumerator::UIMediumEnumerator()
    : m_fMediumEnumerationInProgress(false)
{
    /* Allow UIMedium to be used in inter-thread signals: */
    qRegisterMetaType<UIMedium>();

    /* Prepare Main event handlers: */
    connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltHandleMachineUpdate(QString)));
    connect(gVBoxEvents, SIGNAL(sigSnapshotTake(QString, QString)), this, SLOT(sltHandleMachineUpdate(QString)));
    connect(gVBoxEvents, SIGNAL(sigSnapshotDelete(QString, QString)), this, SLOT(sltHandleSnapshotDeleted(QString, QString)));
    connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltHandleMachineUpdate(QString)));
    connect(gVBoxEvents, SIGNAL(sigSnapshotRestore(QString, QString)), this, SLOT(sltHandleSnapshotDeleted(QString, QString)));
    connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)), this, SLOT(sltHandleMachineRegistration(QString, bool)));

    /* Listen for global thread-pool: */
    connect(vboxGlobal().threadPool(), SIGNAL(sigTaskComplete(UITask*)), this, SLOT(sltHandleMediumEnumerationTaskComplete(UITask*)));
}
コード例 #2
0
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;
}