[vbox-dev] XPCOM EventListener

Rūdolfs Bundulis rudolfs.bundulis at gmail.com
Sun Nov 5 16:05:18 GMT 2017


Hi,

I'm having issues adding an active event listener via the XPCOM api. I've
created a class from the template in the documentation:

#pragma once

#include <VirtualBox_XPCOM.h>

namespace VirtualBox
{

class CVirtualBoxEventListener : public IEventListener
{
public:
NS_DECL_ISUPPORTS
        NS_DECL_IEVENTLISTENER
};

}

and put the NS_IMPL_ISUPPORTS1(CVirtualBoxEventListener, IEventListener)
macro in my cpp file. But the HandleEvent method is never called. I
register the listener by getting the event source from the console object
like this (sorry for all the macros, that I have for exception handling):

CComPtr<IEventSource> pEventSource;
CHECK_VIRTUALBOXAPI(m_pConsole->GetEventSource(getter_AddRefs(pEventSource)),
"could not retrieve virtual machine event source object");
PRUint32 nMachineStateChangeEvent = VBoxEventType_OnMachineStateChanged;
CHECK_VIRTUALBOXAPI(pEventSource->RegisterListener(m_pMachineStateChangeEventListener,
1, &nMachineStateChangeEvent, true), "could not register virtual machine
state change event listener");

No events are triggered but on shutdown the VBOX XPCOM runtime actually
releases the object so it seems that it is aware of it. With active mode,
is there anything else I should be calling? I looked up some python
examples which do call a python VBOX API method waitForEvents. Is there
something similar in the C++ XPCOM API?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20171105/4548c8e0/attachment.html>


More information about the vbox-dev mailing list