VirtualBox

Changeset 33963 in vbox for trunk/src/VBox/Frontends/VBoxSDL


Ignore:
Timestamp:
Nov 11, 2010 10:23:42 AM (14 years ago)
Author:
vboxsync
Message:

Main: moved listeners to location usable by fronends, rework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r33916 r33963  
    233233 * Event handler for VirtualBox events
    234234 */
    235 class VBoxSDLEventListener :
    236   VBOX_SCRIPTABLE_IMPL(IEventListener)
     235class VBoxSDLEventListener
    237236{
    238237public:
    239238    VBoxSDLEventListener()
    240239    {
    241 #if defined(RT_OS_WINDOWS)
    242         refcnt = 0;
    243 #endif
    244240    }
    245241
     
    248244    }
    249245
    250 #ifdef RT_OS_WINDOWS
    251     STDMETHOD_(ULONG, AddRef)()
    252     {
    253         return ::InterlockedIncrement(&refcnt);
    254     }
    255     STDMETHOD_(ULONG, Release)()
    256     {
    257         long cnt = ::InterlockedDecrement(&refcnt);
    258         if (cnt == 0)
    259             delete this;
    260         return cnt;
    261     }
    262 #endif
    263     VBOX_SCRIPTABLE_DISPATCH_IMPL(IEventListener)
    264 
    265     NS_DECL_ISUPPORTS
    266 
    267 
    268     STDMETHOD(HandleEvent)(IEvent * aEvent)
    269     {
    270         VBoxEventType_T aType = VBoxEventType_Invalid;
    271 
    272         aEvent->COMGETTER(Type)(&aType);
     246    STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent * aEvent)
     247    {
    273248        switch (aType)
    274249        {
     
    312287        return S_OK;
    313288    }
    314 
    315 private:
    316 #ifdef RT_OS_WINDOWS
    317     long refcnt;
    318 #endif
    319 
    320289};
    321290
     
    323292 * Event handler for machine events
    324293 */
    325 class VBoxSDLConsoleEventListener :
    326     VBOX_SCRIPTABLE_IMPL(IEventListener)
     294class VBoxSDLConsoleEventListener
    327295{
    328296public:
    329297    VBoxSDLConsoleEventListener() : m_fIgnorePowerOffEvents(false)
    330298    {
    331 #if defined(RT_OS_WINDOWS)
    332         refcnt = 0;
    333 #endif
    334299    }
    335300
     
    338303    }
    339304
    340 #ifdef RT_OS_WINDOWS
    341     STDMETHOD_(ULONG, AddRef)()
    342     {
    343         return ::InterlockedIncrement(&refcnt);
    344     }
    345     STDMETHOD_(ULONG, Release)()
    346     {
    347         long cnt = ::InterlockedDecrement(&refcnt);
    348         if (cnt == 0)
    349             delete this;
    350         return cnt;
    351     }
    352 #endif
    353     VBOX_SCRIPTABLE_DISPATCH_IMPL(IEventListener)
    354 
    355     NS_DECL_ISUPPORTS
    356 
    357     STDMETHOD(HandleEvent)(IEvent * aEvent)
    358     {
    359         VBoxEventType_T aType = VBoxEventType_Invalid;
    360 
    361         aEvent->COMGETTER(Type)(&aType);
     305    STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent * aEvent)
     306    {
    362307        // likely all this double copy is now excessive, and we can just use existing event object
    363308        // @todo: eliminate it
     
    567512
    568513private:
    569 #ifdef RT_OS_WINDOWS
    570     long refcnt;
    571 #endif
    572514    bool m_fIgnorePowerOffEvents;
    573515};
    574516
    575 #ifdef VBOX_WITH_XPCOM
    576 NS_DECL_CLASSINFO(VBoxSDLEventListener)
    577 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VBoxSDLEventListener, IEventListener)
    578 NS_DECL_CLASSINFO(VBoxSDLConsoleEventListener)
    579 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VBoxSDLConsoleEventListener, IEventListener)
    580 #endif /* VBOX_WITH_XPCOM */
    581517
    582518static void show_usage()
Note: See TracChangeset for help on using the changeset viewer.

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