VirtualBox

Ignore:
Timestamp:
Jul 5, 2010 5:08:55 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63362
Message:

Main, some frontends: removing callbacks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r30032 r30627  
    647647    }
    648648
    649     mParent->RegisterCallback (this);
     649    {
     650        // register listener for state change events
     651        ComPtr<IEventSource> es;
     652        mParent->COMGETTER(EventSource)(es.asOutParam());
     653        com::SafeArray <VBoxEventType_T> eventTypes;
     654        eventTypes.push_back(VBoxEventType_OnStateChange);
     655        es->RegisterListener(this, ComSafeArrayAsInParam(eventTypes), true);
     656    }
    650657
    651658    /* Confirm a successful initialization */
     
    673680
    674681    if (mParent)
    675         mParent->UnregisterCallback (this);
     682    {
     683        ComPtr<IEventSource> es;
     684        mParent->COMGETTER(EventSource)(es.asOutParam());
     685        es->UnregisterListener(this);
     686    }
    676687
    677688    unconst(mParent) = NULL;
     
    725736}
    726737
    727 // IConsoleCallback method
    728 STDMETHODIMP Display::OnStateChange(MachineState_T machineState)
    729 {
    730     if (   machineState == MachineState_Running
    731         || machineState == MachineState_Teleporting
    732         || machineState == MachineState_LiveSnapshotting
    733        )
    734     {
    735         LogFlowFunc(("Machine is running.\n"));
    736 
    737         mfMachineRunning = true;
    738     }
    739     else
    740         mfMachineRunning = false;
     738// IEventListener method
     739STDMETHODIMP Display::HandleEvent(IEvent * aEvent)
     740{
     741    VBoxEventType_T aType = VBoxEventType_Invalid;
     742
     743    aEvent->COMGETTER(Type)(&aType);
     744    switch (aType)
     745    {
     746        case VBoxEventType_OnStateChange:
     747        {
     748            ComPtr<IStateChangeEvent> scev = aEvent;
     749            Assert(scev);
     750            MachineState_T machineState;
     751            scev->COMGETTER(State)(&machineState);
     752            if (   machineState == MachineState_Running
     753                   || machineState == MachineState_Teleporting
     754                   || machineState == MachineState_LiveSnapshotting
     755                   )
     756            {
     757                LogFlowFunc(("Machine is running.\n"));
     758
     759                mfMachineRunning = true;
     760            }
     761            else
     762                mfMachineRunning = false;
     763            break;
     764        }
     765        default:
     766            AssertFailed();
     767    }
    741768
    742769    return S_OK;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette