VirtualBox

Changeset 34527 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 30, 2010 4:25:01 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt4: use IListener template

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIExtraDataEventHandler.cpp

    r30871 r34527  
    252252//    RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
    253253    const CVirtualBox &vbox = vboxGlobal().virtualBox();
    254     UIMainEventListener *pListener = new UIMainEventListener(this);
     254    UIMainEventListenerImpl *pListener = new UIMainEventListenerImpl(this);
    255255    m_mainEventListener = CEventListener(pListener);
    256256    QVector<KVBoxEventType> events;
     
    264264    /* This is a vetoable event, so we have to respond to the event and have to
    265265     * use a direct connection therefor. */
    266     connect(pListener, SIGNAL(sigExtraDataCanChange(QString, QString, QString, bool&, QString&)),
     266    connect(pListener->getWrapped(), SIGNAL(sigExtraDataCanChange(QString, QString, QString, bool&, QString&)),
    267267            m_pHandler, SLOT(sltExtraDataCanChange(QString, QString, QString, bool&, QString&)),
    268268            Qt::DirectConnection);
    269269
    270270    /* Use a direct connection to the helper class. */
    271     connect(pListener, SIGNAL(sigExtraDataChange(QString, QString, QString)),
     271    connect(pListener->getWrapped(), SIGNAL(sigExtraDataChange(QString, QString, QString)),
    272272            m_pHandler, SLOT(sltExtraDataChange(QString, QString, QString)),
    273273            Qt::DirectConnection);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.cpp

    r33386 r34527  
    2525//#include <iprt/stream.h>
    2626
    27 #ifndef Q_WS_WIN
    28 NS_DECL_CLASSINFO(UIMainEventListener)
    29 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(UIMainEventListener, IEventListener)
    30 #endif
    31 
    3227UIMainEventListener::UIMainEventListener(QObject * /* pParent */)
    3328//  : QObject(pParent) /* Todo: Not sure if pParent should delete this. Especially on Win there is ref counting implemented. */
    3429  : QObject()
    35 #ifdef Q_WS_WIN
    36   , m_refcnt(0)
    37 #endif /* Q_WS_WIN */
    3830{
    3931    /* For queued events we have to extra register our enums/interface classes
     
    5547 * make sense to use passive listeners, and peek up events in main thread.
    5648 */
    57 STDMETHODIMP UIMainEventListener::HandleEvent(IEvent *pEvent)
     49STDMETHODIMP UIMainEventListener::HandleEvent(VBoxEventType_T /* type */, IEvent *pEvent)
    5850{
    5951    CEvent event(pEvent);
     
    222214    return S_OK;
    223215}
     216
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.h

    r33540 r34527  
    2323#include "COMDefs.h"
    2424
     25/* VBox includes */
     26#include <VBox/com/listeners.h>
     27
    2528/* Note: On a first look this may seems a little bit complicated.
    2629 * There are two reasons to use a separate class here which handles the events
     
    3538 * queue and deliver it later on. */
    3639
    37 class UIMainEventListener: public QObject , VBOX_SCRIPTABLE_IMPL(IEventListener)
     40class UIMainEventListener: public QObject
    3841{
    3942    Q_OBJECT;
    4043
    4144public:
    42     NS_DECL_ISUPPORTS
    43     VBOX_SCRIPTABLE_DISPATCH_IMPL(IEventListener)
    44 
    4545    UIMainEventListener(QObject *pParent);
    4646
    47 #ifdef Q_WS_WIN
    48     STDMETHOD_(ULONG, AddRef)()
    49     {
    50         return ::InterlockedIncrement(&m_refcnt);
    51     }
    52     STDMETHOD_(ULONG, Release)()
    53     {
    54         long cnt = ::InterlockedDecrement(&m_refcnt);
    55         if (cnt == 0)
    56             delete this;
    57         return cnt;
    58     }
    59 #endif /* Q_WS_WIN */
    60 
    61     STDMETHOD(HandleEvent)(IEvent *pEvent);
     47    STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *pEvent);
    6248
    6349signals:
     
    8470    void sigCanShowWindow(bool &fVeto, QString &strReason); /* use Qt::DirectConnection */
    8571    void sigShowWindow(LONG64 &winId); /* use Qt::DirectConnection */
     72};
    8673
    87 #ifdef Q_WS_WIN
    88 private:
    89     /* Private member vars */
    90     long m_refcnt;
    91 #endif /* Q_WS_WIN */
    92 };
     74/* Wrap the IListener interface around our implementation class. */
     75typedef ListenerImpl<UIMainEventListener, QObject*> UIMainEventListenerImpl;
    9376
    9477#endif /* !__UIMainEventListener_h__ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.cpp

    r31816 r34527  
    5959
    6060//    RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
    61     UIMainEventListener *pListener = new UIMainEventListener(this);
     61    UIMainEventListenerImpl *pListener = new UIMainEventListenerImpl(this);
    6262    m_mainEventListener = CEventListener(pListener);
    6363    QVector<KVBoxEventType> events;
     
    8181    AssertWrapperOk(console);
    8282
    83     connect(pListener, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
     83    connect(pListener->getWrapped(), SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
    8484            this, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
    8585            Qt::QueuedConnection);
    8686
    87     connect(pListener, SIGNAL(sigMouseCapabilityChange(bool, bool, bool)),
     87    connect(pListener->getWrapped(), SIGNAL(sigMouseCapabilityChange(bool, bool, bool)),
    8888            this, SIGNAL(sigMouseCapabilityChange(bool, bool, bool)),
    8989            Qt::QueuedConnection);
    9090
    91     connect(pListener, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
     91    connect(pListener->getWrapped(), SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
    9292            this, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
    9393            Qt::QueuedConnection);
    9494
    95     connect(pListener, SIGNAL(sigStateChange(KMachineState)),
     95    connect(pListener->getWrapped(), SIGNAL(sigStateChange(KMachineState)),
    9696            this, SIGNAL(sigStateChange(KMachineState)),
    9797            Qt::QueuedConnection);
    9898
    99     connect(pListener, SIGNAL(sigAdditionsChange()),
     99    connect(pListener->getWrapped(), SIGNAL(sigAdditionsChange()),
    100100            this, SIGNAL(sigAdditionsChange()),
    101101            Qt::QueuedConnection);
    102102
    103     connect(pListener, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
     103    connect(pListener->getWrapped(), SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
    104104            this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
    105105            Qt::QueuedConnection);
    106106
    107     connect(pListener, SIGNAL(sigMediumChange(CMediumAttachment)),
     107    connect(pListener->getWrapped(), SIGNAL(sigMediumChange(CMediumAttachment)),
    108108            this, SIGNAL(sigMediumChange(CMediumAttachment)),
    109109            Qt::QueuedConnection);
    110110
    111     connect(pListener, SIGNAL(sigUSBControllerChange()),
     111    connect(pListener->getWrapped(), SIGNAL(sigUSBControllerChange()),
    112112            this, SIGNAL(sigUSBControllerChange()),
    113113            Qt::QueuedConnection);
    114114
    115     connect(pListener, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
     115    connect(pListener->getWrapped(), SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
    116116            this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
    117117            Qt::QueuedConnection);
    118118
    119     connect(pListener, SIGNAL(sigSharedFolderChange()),
     119    connect(pListener->getWrapped(), SIGNAL(sigSharedFolderChange()),
    120120            this, SIGNAL(sigSharedFolderChange()),
    121121            Qt::QueuedConnection);
    122122
    123     connect(pListener, SIGNAL(sigRuntimeError(bool, QString, QString)),
     123    connect(pListener->getWrapped(), SIGNAL(sigRuntimeError(bool, QString, QString)),
    124124            this, SIGNAL(sigRuntimeError(bool, QString, QString)),
    125125            Qt::QueuedConnection);
     
    127127    /* This is a vetoable event, so we have to respond to the event and have to
    128128     * use a direct connection therefor. */
    129     connect(pListener, SIGNAL(sigCanShowWindow(bool&, QString&)),
     129    connect(pListener->getWrapped(), SIGNAL(sigCanShowWindow(bool&, QString&)),
    130130            this, SLOT(sltCanShowWindow(bool&, QString&)),
    131131            Qt::DirectConnection);
     
    133133    /* This returns a winId, so we have to respond to the event and have to use
    134134     * a direct connection therefor. */
    135     connect(pListener, SIGNAL(sigShowWindow(LONG64&)),
     135    connect(pListener->getWrapped(), SIGNAL(sigShowWindow(LONG64&)),
    136136            this, SLOT(sltShowWindow(LONG64&)),
    137137            Qt::DirectConnection);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp

    r30879 r34527  
    5252//    RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
    5353    const CVirtualBox &vbox = vboxGlobal().virtualBox();
    54     UIMainEventListener *pListener = new UIMainEventListener(this);
     54    UIMainEventListenerImpl *pListener = new UIMainEventListenerImpl(this);
    5555    m_mainEventListener = CEventListener(pListener);
    5656    QVector<KVBoxEventType> events;
     
    6565    AssertWrapperOk(vbox);
    6666
    67     connect(pListener, SIGNAL(sigMachineStateChange(QString, KMachineState)),
     67    connect(pListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)),
    6868            this, SIGNAL(sigMachineStateChange(QString, KMachineState)),
    6969            Qt::QueuedConnection);
    7070
    71     connect(pListener, SIGNAL(sigMachineDataChange(QString)),
     71    connect(pListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)),
    7272            this, SIGNAL(sigMachineDataChange(QString)),
    7373            Qt::QueuedConnection);
    7474
    75     connect(pListener, SIGNAL(sigMachineRegistered(QString, bool)),
     75    connect(pListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)),
    7676            this, SIGNAL(sigMachineRegistered(QString, bool)),
    7777            Qt::QueuedConnection);
    7878
    79     connect(pListener, SIGNAL(sigSessionStateChange(QString, KSessionState)),
     79    connect(pListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)),
    8080            this, SIGNAL(sigSessionStateChange(QString, KSessionState)),
    8181            Qt::QueuedConnection);
    8282
    83     connect(pListener, SIGNAL(sigSnapshotChange(QString, QString)),
     83    connect(pListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)),
    8484            this, SIGNAL(sigSnapshotChange(QString, QString)),
    8585            Qt::QueuedConnection);
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