<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Rūdolfs,<br>
<br>
<div class="moz-cite-prefix">On 07.11.2017 01:14, Rūdolfs Bundulis
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAHtFw6114um9QUwFTiV2eFuGR25Xjk0y4uXZ1wUOXDnA9kuobQ@mail.gmail.com">
<div dir="ltr">Hi Klaus,
<div><br>
</div>
<div>thanks for the response. Yeah the example seems very
similar. The thing i was wondering about - the xpcom samples
do stuff with the <span style="color:rgb(0,0,0);white-space:pre-wrap">nsIEventQueue,</span></div>
<div><span style="color:rgb(0,0,0);white-space:pre-wrap">which I only instantiate but do not poll in any way (there are so many sources involving this that I got confused). Should I be doing something -</span></div>
<div><span style="color:rgb(0,0,0);white-space:pre-wrap">like calling the EventLoop() method to actually make the events route? Since everything else apart the event callbacks (which I didn't need so far,</span></div>
<div><span style="color:rgb(0,0,0);white-space:pre-wrap">but now I need to know when the machine has been stopped) was working fine I just didn't care. But if running/polling this queue actually pumps</span></div>
<div><span style="color:rgb(0,0,0);white-space:pre-wrap">some internal event loop which in turn fires the callbacks that could be the thing I'm missing.</span></div>
</div>
</blockquote>
Running the event queue is a must have for anything more complicated
than doing a few API calls and then immediately terminating. Many
activities in XPCOM are bolted to events (which are processed
internally by XPCOM), and not doing it causes excessive memory
consumption and strange malfunctions, especially if your API client
doesn't do much else than waiting for API level event callbacks to
arrive. I don't have any real evidence why it would cause callbacks
to be not invoked (e.g. "VBoxManage guestcontrol watch" also creates
active listeners and is simply waiting until Ctrl-C is pressed, with
some sleeping but not caring about the event queue, which is not
ideal).<br>
<br>
Can't guarantee that it'll help.<br>
<br>
Klaus<br>
<br>
<blockquote type="cite"
cite="mid:CAHtFw6114um9QUwFTiV2eFuGR25Xjk0y4uXZ1wUOXDnA9kuobQ@mail.gmail.com">
<div dir="ltr">
<div class="gmail_extra"><br>
<div class="gmail_quote">2017-11-06 22:39 GMT+02:00 Klaus
Espenlaub <span dir="ltr"><<a
href="mailto:klaus.espenlaub@oracle.com" target="_blank"
moz-do-not-send="true">klaus.espenlaub@oracle.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">Hi Rūdolfs,<br>
<span class="gmail-"><br>
On 05.11.2017 17:05, Rūdolfs Bundulis wrote:<br>
> Hi,<br>
><br>
> I'm having issues adding an active event listener
via the XPCOM api.<br>
> I've created a class from the template in the
documentation:<br>
><br>
</span>[...]<br>
<span class="gmail-">><br>
> and put the NS_IMPL_ISUPPORTS1(<wbr>CVirtualBoxEventListener,<br>
> IEventListener) macro in my cpp file. But the
HandleEvent method is<br>
> never called. I register the listener by getting
the event source from<br>
> the console object like this (sorry for all the
macros, that I have<br>
> for exception handling):<br>
><br>
</span>[...]<br>
<span class="gmail-">><br>
> No events are triggered but on shutdown the VBOX
XPCOM runtime<br>
> actually releases the object so it seems that it is
aware of it. With<br>
> active mode, is there anything else I should be
calling? I looked up<br>
> some python examples which do call a python VBOX
API method<br>
> waitForEvents. Is there something similar in the
C++ XPCOM API?<br>
<br>
</span>Most python examples I'm aware of use passive event
delivery, so aren't<br>
relevant when you've decided to go for active event
delivery. Also the<br>
VirtualBox GUI is not a good example any more since it's
been converted<br>
to passive event delivery a while ago (IIRC 5.0 still had
the active<br>
variant), so let's go for one of the most simple places I
could find,<br>
VBoxSDL:<br>
<a
href="https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://www.virtualbox.org/<wbr>browser/vbox/trunk/src/VBox/<wbr>Frontends/VBoxSDL/VBoxSDL.cpp</a><br>
<br>
Still it uses templates (ListenerImpl<>) and lots
of magic wrappers to<br>
abstract over the differences between COM and XPCOM (which
lots of<br>
people would like to use but so far we didn't manage to
include in a<br>
sensible way in the SDK package), which needs way more
apologies than<br>
your couple of comparably harmless macros for error
checking. The<br>
ListenerImpl<> template is defined in<br>
<a
href="https://www.virtualbox.org/browser/vbox/trunk/include/VBox/com/listeners.h"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://www.virtualbox.org/<wbr>browser/vbox/trunk/include/<wbr>VBox/com/listeners.h</a><br>
and the rest (if you really need to know) in the same
directory.<br>
<br>
The C bindings example would have both active and passive
event delivery<br>
as compile-time option, but that's too low level I
assume...<br>
<br>
Hope this gives enough inspiration to identify the problem
- your code<br>
didn't look far off the track.<br>
<br>
Klaus</blockquote>
</div>
</div>
</div>
</blockquote>
</body>
</html>