VirtualBox

Changeset 54131 in vbox for trunk


Ignore:
Timestamp:
Feb 10, 2015 6:03:20 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
98156
Message:

FE/Qt: VirtualBox event-handler cleanup/rework (step 1).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp

    r52730 r54131  
    55
    66/*
    7  * Copyright (C) 2010-2012 Oracle Corporation
     7 * Copyright (C) 2010-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3838{
    3939    if (!m_pInstance)
    40         m_pInstance = new UIVirtualBoxEventHandler();
     40        m_pInstance = new UIVirtualBoxEventHandler;
    4141    return m_pInstance;
    4242}
     
    5454UIVirtualBoxEventHandler::UIVirtualBoxEventHandler()
    5555{
    56 //    RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
    57     const CVirtualBox &vbox = vboxGlobal().virtualBox();
     56    /* Create Main-event listener instance: */
    5857    ComObjPtr<UIMainEventListenerImpl> pListener;
    5958    pListener.createObject();
    60     pListener->init(new UIMainEventListener(), this);
     59    pListener->init(new UIMainEventListener, this);
    6160    m_mainEventListener = CEventListener(pListener);
     61
     62    /* Get VirtualBox: */
     63    const CVirtualBox vbox = vboxGlobal().virtualBox();
     64    AssertWrapperOk(vbox);
     65    /* Get event-source: */
     66    CEventSource eventSource = vbox.GetEventSource();
     67    AssertWrapperOk(eventSource);
     68    /* Register listener for expected event-types: */
    6269    QVector<KVBoxEventType> events;
    6370    events
     
    6976        << KVBoxEventType_OnSnapshotDeleted
    7077        << KVBoxEventType_OnSnapshotChanged;
     78    eventSource.RegisterListener(m_mainEventListener, events, TRUE);
     79    AssertWrapperOk(eventSource);
    7180
    72     vbox.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE);
    73     AssertWrapperOk(vbox);
    74 
     81    /* Prepare connections: */
    7582    connect(pListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)),
    7683            this, SIGNAL(sigMachineStateChange(QString, KMachineState)),
    7784            Qt::QueuedConnection);
    78 
    7985    connect(pListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)),
    8086            this, SIGNAL(sigMachineDataChange(QString)),
    8187            Qt::QueuedConnection);
    82 
    8388    connect(pListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)),
    8489            this, SIGNAL(sigMachineRegistered(QString, bool)),
    8590            Qt::QueuedConnection);
    86 
    8791    connect(pListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)),
    8892            this, SIGNAL(sigSessionStateChange(QString, KSessionState)),
    8993            Qt::QueuedConnection);
    90 
    9194    connect(pListener->getWrapped(), SIGNAL(sigSnapshotTake(QString, QString)),
    9295            this, SIGNAL(sigSnapshotTake(QString, QString)),
    9396            Qt::QueuedConnection);
    94 
    9597    connect(pListener->getWrapped(), SIGNAL(sigSnapshotDelete(QString, QString)),
    9698            this, SIGNAL(sigSnapshotDelete(QString, QString)),
    9799            Qt::QueuedConnection);
    98 
    99100    connect(pListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)),
    100101            this, SIGNAL(sigSnapshotChange(QString, QString)),
     
    104105UIVirtualBoxEventHandler::~UIVirtualBoxEventHandler()
    105106{
    106     const CVirtualBox &vbox = vboxGlobal().virtualBox();
    107     vbox.GetEventSource().UnregisterListener(m_mainEventListener);
     107    /* Get VirtualBox: */
     108    const CVirtualBox vbox = vboxGlobal().virtualBox();
     109    AssertWrapperOk(vbox);
     110    /* Get event-source: */
     111    CEventSource eventSource = vbox.GetEventSource();
     112    AssertWrapperOk(eventSource);
     113    /* Unregister listener: */
     114    eventSource.UnregisterListener(m_mainEventListener);
    108115}
     116
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h

    r52727 r54131  
    44
    55/*
    6  * Copyright (C) 2010-2012 Oracle Corporation
     6 * Copyright (C) 2010-2015 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1515 */
    1616
    17 #ifndef __UIVirtualBoxEventHandler_h__
    18 #define __UIVirtualBoxEventHandler_h__
     17#ifndef ___UIVirtualBoxEventHandler_h___
     18#define ___UIVirtualBoxEventHandler_h___
    1919
    2020/* COM includes: */
     
    2222#include "CEventListener.h"
    2323
    24 class UIVirtualBoxEventHandler: public QObject
     24/** Active event handler singleton for the CVirtualBox event-source. */
     25class UIVirtualBoxEventHandler : public QObject
    2526{
    2627    Q_OBJECT;
    2728
     29signals:
     30
     31    /** Notifies listeners about @a state change event for the machine with @a strId. */
     32    void sigMachineStateChange(QString strId, KMachineState state);
     33    /** Notifies listeners about data change event for the machine with @a strId. */
     34    void sigMachineDataChange(QString strId);
     35    /** Notifies listeners about machine with @a strId was @a fRegistered. */
     36    void sigMachineRegistered(QString strId, bool fRegistered);
     37    /** Notifies listeners about @a state change event for the session of the machine with @a strId. */
     38    void sigSessionStateChange(QString strId, KSessionState state);
     39    /** Notifies listeners about snapshot with @a strSnapshotId was taken for the machine with @a strId. */
     40    void sigSnapshotTake(QString strId, QString strSnapshotId);
     41    /** Notifies listeners about snapshot with @a strSnapshotId was deleted for the machine with @a strId. */
     42    void sigSnapshotDelete(QString strId, QString strSnapshotId);
     43    /** Notifies listeners about snapshot with @a strSnapshotId was changed for the machine with @a strId. */
     44    void sigSnapshotChange(QString strId, QString strSnapshotId);
     45
    2846public:
     47
     48    /** Returns singleton instance created by the factory. */
    2949    static UIVirtualBoxEventHandler* instance();
     50    /** Destroys singleton instance created by the factory. */
    3051    static void destroy();
    3152
    32 signals:
    33     /* VirtualBox main signals */
    34     void sigMachineStateChange(QString strId, KMachineState state);
    35     void sigMachineDataChange(QString strId);
    36     void sigMachineRegistered(QString strId, bool fRegistered);
    37     void sigSessionStateChange(QString strId, KSessionState state);
    38     void sigSnapshotTake(QString strId, QString strSnapshotId);
    39     void sigSnapshotDelete(QString strId, QString strSnapshotId);
    40     void sigSnapshotChange(QString strId, QString strSnapshotId);
     53private:
    4154
    42 private:
     55    /** Constructor. */
    4356    UIVirtualBoxEventHandler();
     57    /** Destructor. */
    4458    ~UIVirtualBoxEventHandler();
    4559
    46     /* Private member vars */
     60    /** Holds the static singleton instance. */
    4761    static UIVirtualBoxEventHandler *m_pInstance;
     62    /** Holds the COM event-listener instance. */
    4863    CEventListener m_mainEventListener;
    4964};
     
    5166#define gVBoxEvents UIVirtualBoxEventHandler::instance()
    5267
    53 #endif /* !__UIVirtualBoxEventHandler_h__ */
    54 
     68#endif /* !___UIVirtualBoxEventHandler_h___ */
Note: See TracChangeset for help on using the changeset viewer.

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