VirtualBox

Ignore:
Timestamp:
Nov 11, 2010 9:41:52 AM (14 years ago)
Author:
vboxsync
Message:

Main: code for generic listener creation

File:
1 edited

Legend:

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

    r33676 r33959  
    3535#include <VBox/RemoteDesktop/VRDEOrders.h>
    3636
    37 class VRDPConsoleListener :
    38     VBOX_SCRIPTABLE_IMPL(IEventListener)
     37class VRDPConsoleListener
    3938{
    4039public:
     
    4241        : m_server(server)
    4342    {
    44 #ifndef VBOX_WITH_XPCOM
    45         refcnt = 0;
    46 #endif /* !VBOX_WITH_XPCOM */
    47     }
    48 
    49     virtual ~VRDPConsoleListener() {}
    50 
    51     NS_DECL_ISUPPORTS
    52 
    53 #ifndef VBOX_WITH_XPCOM
    54     STDMETHOD_(ULONG, AddRef)() {
    55         return ::InterlockedIncrement(&refcnt);
    56     }
    57     STDMETHOD_(ULONG, Release)()
    58     {
    59         long cnt = ::InterlockedDecrement(&refcnt);
    60         if (cnt == 0)
    61             delete this;
    62         return cnt;
    63     }
    64     STDMETHOD(QueryInterface)(REFIID riid , void **ppObj)
    65     {
    66         if (riid == IID_IUnknown) {
    67             *ppObj = (IUnknown*)this;
    68             AddRef();
    69             return S_OK;
    70         }
    71         if (riid == IID_IEventListener) {
    72             *ppObj = (IEventListener*)this;
    73             AddRef();
    74             return S_OK;
    75         }
    76         *ppObj = NULL;
    77         return E_NOINTERFACE;
    78     }
    79 #endif /* !VBOX_WITH_XPCOM */
    80 
    81 
    82     STDMETHOD(HandleEvent)(IEvent * aEvent)
    83     {
    84         VBoxEventType_T aType = VBoxEventType_Invalid;
    85 
    86         aEvent->COMGETTER(Type)(&aType);
     43    }
     44
     45    STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent * aEvent)
     46    {
    8747        switch (aType)
    8848        {
     
    145105                                         ULONG width, ULONG height, ComSafeArrayIn(BYTE,shape));
    146106    ConsoleVRDPServer *m_server;
    147 #ifndef VBOX_WITH_XPCOM
    148     long refcnt;
    149 #endif /* !VBOX_WITH_XPCOM */
    150107};
    151108
    152 #ifdef VBOX_WITH_XPCOM
    153 #include <nsMemory.h>
    154 NS_DECL_CLASSINFO(VRDPConsoleListener)
    155 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VRDPConsoleListener, IEventListener)
    156 #endif /* VBOX_WITH_XPCOM */
     109typedef ListenerImpl<VRDPConsoleListener, ConsoleVRDPServer*> VRDPConsoleListenerImpl;
     110
     111VBOX_LISTENER_DECLARE(VRDPConsoleListenerImpl)
    157112
    158113#ifdef DEBUG_sunlover
     
    12201175        ComPtr<IEventSource> es;
    12211176        console->COMGETTER(EventSource)(es.asOutParam());
    1222         mConsoleListener = new VRDPConsoleListener(this);
    1223         mConsoleListener->AddRef();
     1177        mConsoleListener = new VRDPConsoleListenerImpl(this);
    12241178        com::SafeArray <VBoxEventType_T> eventTypes;
    12251179        eventTypes.push_back(VBoxEventType_OnMousePointerShapeChanged);
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