VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp@ 35740

Last change on this file since 35740 was 35722, checked in by vboxsync, 13 years ago

Main: reworked listener objects creation, fixes Win problems with events, few cleanups

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/* $Id: UIVirtualBoxEventHandler.cpp 35722 2011-01-26 16:37:16Z vboxsync $ */
2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * UIVirtualBoxEventHandler class implementation
6 */
7
8/*
9 * Copyright (C) 2010 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20/* Local includes */
21#include "UIVirtualBoxEventHandler.h"
22#include "UIMainEventListener.h"
23#include "VBoxGlobal.h"
24
25/* Global includes */
26//#include <iprt/thread.h>
27//#include <iprt/stream.h>
28
29/* static */
30UIVirtualBoxEventHandler *UIVirtualBoxEventHandler::m_pInstance = 0;
31
32/* static */
33UIVirtualBoxEventHandler* UIVirtualBoxEventHandler::instance()
34{
35 if (!m_pInstance)
36 m_pInstance = new UIVirtualBoxEventHandler();
37 return m_pInstance;
38}
39
40/* static */
41void UIVirtualBoxEventHandler::destroy()
42{
43 if (m_pInstance)
44 {
45 delete m_pInstance;
46 m_pInstance = 0;
47 }
48}
49
50UIVirtualBoxEventHandler::UIVirtualBoxEventHandler()
51{
52// RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
53 const CVirtualBox &vbox = vboxGlobal().virtualBox();
54 ComObjPtr<UIMainEventListenerImpl> pListener;
55 pListener.createObject();
56 pListener->init(new UIMainEventListener(), this);
57 m_mainEventListener = CEventListener(pListener);
58 QVector<KVBoxEventType> events;
59 events
60 << KVBoxEventType_OnMachineStateChanged
61 << KVBoxEventType_OnMachineDataChanged
62 << KVBoxEventType_OnMachineRegistered
63 << KVBoxEventType_OnSessionStateChanged
64 << KVBoxEventType_OnSnapshotChanged;
65
66 vbox.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE);
67 AssertWrapperOk(vbox);
68
69 connect(pListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)),
70 this, SIGNAL(sigMachineStateChange(QString, KMachineState)),
71 Qt::QueuedConnection);
72
73 connect(pListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)),
74 this, SIGNAL(sigMachineDataChange(QString)),
75 Qt::QueuedConnection);
76
77 connect(pListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)),
78 this, SIGNAL(sigMachineRegistered(QString, bool)),
79 Qt::QueuedConnection);
80
81 connect(pListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)),
82 this, SIGNAL(sigSessionStateChange(QString, KSessionState)),
83 Qt::QueuedConnection);
84
85 connect(pListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)),
86 this, SIGNAL(sigSnapshotChange(QString, QString)),
87 Qt::QueuedConnection);
88}
89
90UIVirtualBoxEventHandler::~UIVirtualBoxEventHandler()
91{
92 const CVirtualBox &vbox = vboxGlobal().virtualBox();
93 vbox.GetEventSource().UnregisterListener(m_mainEventListener);
94}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use