VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.h@ 82781

Last change on this file since 82781 was 81592, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9598: Introducing UIMousePointerShapeData, a separate class for wrapping consolidated mouse pointer shape information; Using it to wrap data received via Main API events and pass through GUI to subscribed listeners.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.0 KB
Line 
1/* $Id: UIMainEventListener.h 81592 2019-10-30 16:39:09Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMainEventListener class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_globals_UIMainEventListener_h
19#define FEQT_INCLUDED_SRC_globals_UIMainEventListener_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QList>
26#include <QObject>
27#include <QRect>
28
29/* GUI includes: */
30#include "UILibraryDefs.h"
31
32/* COM includes: */
33#include "COMEnums.h"
34#include "CGuestProcess.h"
35#include "CGuestSession.h"
36#include "CMedium.h"
37#include "CMediumAttachment.h"
38#include "CNetworkAdapter.h"
39#include "CUSBDevice.h"
40#include "CVirtualBoxErrorInfo.h"
41
42/* Other VBox includes: */
43#include <VBox/com/listeners.h> /** @todo This drags in VirtualBox.h! It may be possible avoid it for XPCOM, but not COM due to VBoxEventType_T. */
44
45/* Forward declarations: */
46class QPoint;
47class QString;
48class UIMainEventListeningThread;
49class UIMousePointerShapeData;
50class CEventListener;
51class CEventSource;
52class CGuestProcessStateChangedEvent;
53class CGuestSessionStateChangedEvent;
54
55/* Note: On a first look this may seems a little bit complicated.
56 * There are two reasons to use a separate class here which handles the events
57 * and forward them to the public class as signals. The first one is that on
58 * some platforms (e.g. Win32) this events not arrive in the main GUI thread.
59 * So there we have to make sure they are first delivered to the main GUI
60 * thread and later executed there. The second reason is, that the initiator
61 * method may hold a lock on a object which has to be manipulated in the event
62 * consumer. Doing this without being asynchronous would lead to a dead lock. To
63 * avoid both problems we send signals as a queued connection to the event
64 * consumer. Qt will create a event for us, place it in the main GUI event
65 * queue and deliver it later on. */
66
67/** Main event listener. */
68class SHARED_LIBRARY_STUFF UIMainEventListener : public QObject
69{
70 Q_OBJECT;
71
72signals:
73
74 /** @name VirtualBoxClient related signals
75 * @{ */
76 /** Notifies about the VBoxSVC become @a fAvailable. */
77 void sigVBoxSVCAvailabilityChange(bool fAvailable);
78 /** @} */
79
80 /** @name VirtualBox related signals
81 * @{ */
82 /** Notifies about @a state change event for the machine with @a uId. */
83 void sigMachineStateChange(const QUuid &uId, const KMachineState state);
84 /** Notifies about data change event for the machine with @a uId. */
85 void sigMachineDataChange(const QUuid &uId);
86 /** Notifies about machine with @a uId was @a fRegistered. */
87 void sigMachineRegistered(const QUuid &uId, const bool fRegistered);
88 /** Notifies about @a state change event for the session of the machine with @a uId. */
89 void sigSessionStateChange(const QUuid &uId, const KSessionState state);
90 /** Notifies about snapshot with @a uSnapshotId was taken for the machine with @a uId. */
91 void sigSnapshotTake(const QUuid &uId, const QUuid &uSnapshotId);
92 /** Notifies about snapshot with @a uSnapshotId was deleted for the machine with @a uId. */
93 void sigSnapshotDelete(const QUuid &uId, const QUuid &uSnapshotId);
94 /** Notifies about snapshot with @a uSnapshotId was changed for the machine with @a uId. */
95 void sigSnapshotChange(const QUuid &uId, const QUuid &uSnapshotId);
96 /** Notifies about snapshot with @a uSnapshotId was restored for the machine with @a uId. */
97 void sigSnapshotRestore(const QUuid &uId, const QUuid &uSnapshotId);
98 /** @} */
99
100 /** @name VirtualBox Extra-data related signals
101 * @{ */
102 /** Notifies about extra-data of the machine with @a uId can be changed for the key @a strKey to value @a strValue. */
103 void sigExtraDataCanChange(const QUuid &uId, const QString &strKey, const QString &strValue, bool &fVeto, QString &strVetoReason); /* use Qt::DirectConnection */
104 /** Notifies about extra-data of the machine with @a uId changed for the key @a strKey to value @a strValue. */
105 void sigExtraDataChange(const QUuid &uId, const QString &strKey, const QString &strValue);
106 /** @} */
107
108 /** @name VirtualBox Medium related signals
109 * @{ */
110 /** Notifies about storage controller change.
111 * @param uMachineId Brings the ID of machine corresponding controller belongs to.
112 * @param strControllerName Brings the name of controller this event is related to. */
113 void sigStorageControllerChange(const QUuid &uMachineId, const QString &strControllerName);
114 /** Notifies about storage device change.
115 * @param comAttachment Brings corresponding attachment.
116 * @param fRemoved Brings whether medium is removed or added.
117 * @param fSilent Brings whether this change has gone silent for guest. */
118 void sigStorageDeviceChange(CMediumAttachment comAttachment, bool fRemoved, bool fSilent);
119
120 /** Notifies about storage medium @a comAttachment state change. */
121 void sigMediumChange(CMediumAttachment comAttachment);
122 /** Notifies about storage @a comMedium config change. */
123 void sigMediumConfigChange(CMedium comMedium);
124 /** Notifies about storage medium is (un)registered.
125 * @param uMediumId Brings corresponding medium ID.
126 * @param enmMediumType Brings corresponding medium type.
127 * @param fRegistered Brings whether medium is registered or unregistered. */
128 void sigMediumRegistered(const QUuid &uMediumId, KDeviceType enmMediumType, bool fRegistered);
129 /** @} */
130
131 /** @name Console related signals
132 * @{ */
133 /** Notifies about mouse pointer @a shapeData change. */
134 void sigMousePointerShapeChange(const UIMousePointerShapeData &shapeData);
135 /** Notifies about mouse capability change to @a fSupportsAbsolute, @a fSupportsRelative, @a fSupportsMultiTouch and @a fNeedsHostCursor. */
136 void sigMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fSupportsMultiTouch, bool fNeedsHostCursor);
137 /** Notifies about guest request to change the cursor position to @a uX * @a uY.
138 * @param fContainsData Brings whether the @a uX and @a uY values are valid and could be used by the GUI now. */
139 void sigCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY);
140 /** Notifies about keyboard LEDs change for @a fNumLock, @a fCapsLock and @a fScrollLock. */
141 void sigKeyboardLedsChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock);
142 /** Notifies about machine @a state change. */
143 void sigStateChange(KMachineState state);
144 /** Notifies about guest additions state change. */
145 void sigAdditionsChange();
146 /** Notifies about network @a adapter state change. */
147 void sigNetworkAdapterChange(CNetworkAdapter comAdapter);
148 /** Notifies about VRDE device state change. */
149 void sigVRDEChange();
150 /** Notifies about recording state change. */
151 void sigRecordingChange();
152 /** Notifies about USB controller state change. */
153 void sigUSBControllerChange();
154 /** Notifies about USB @a device state change to @a fAttached, holding additional @a error information. */
155 void sigUSBDeviceStateChange(CUSBDevice comDevice, bool fAttached, CVirtualBoxErrorInfo comError);
156 /** Notifies about shared folder state change. */
157 void sigSharedFolderChange();
158 /** Notifies about CPU execution-cap change. */
159 void sigCPUExecutionCapChange();
160 /** Notifies about guest-screen configuration change of @a type for @a uScreenId with @a screenGeo. */
161 void sigGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
162 /** Notifies about Runtime error with @a strErrorId which is @a fFatal and have @a strMessage. */
163 void sigRuntimeError(bool fFatal, QString strErrorId, QString strMessage);
164 /** Notifies about VM window can be shown, allowing to prevent it by @a fVeto with @a strReason. */
165 void sigCanShowWindow(bool &fVeto, QString &strReason); /* use Qt::DirectConnection */
166 /** Notifies about VM window with specified @a winId should be shown. */
167 void sigShowWindow(qint64 &winId); /* use Qt::DirectConnection */
168 /** Notifies about audio adapter state change. */
169 void sigAudioAdapterChange();
170 /** Notifies about the clipboard mode change. */
171 void sigClipboardModeChange(KClipboardMode enmClipboardMode);
172 /** Notifies about the drag and drop mode change. */
173 void sigDnDModeChange(KDnDMode enmDnDMode);
174 /** @} */
175
176 /** @name Progress related signals
177 * @{ */
178 /** Notifies about @a iPercent change for progress with @a uProgressId. */
179 void sigProgressPercentageChange(const QUuid &uProgressId, const int iPercent);
180 /** Notifies about task complete for progress with @a uProgressId. */
181 void sigProgressTaskComplete(const QUuid &uProgressId);
182 /** @} */
183
184 /** @name Guest Session related signals
185 * @{ */
186 /** Notifies about guest session (un)registered event @a is the (un)registed guest session. */
187 void sigGuestSessionRegistered(CGuestSession comGuestSession);
188 void sigGuestSessionUnregistered(CGuestSession comGuestSession);
189
190 /** Notifies about guest process (un)registered event @a is the (un)registed guest process. */
191 void sigGuestProcessRegistered(CGuestProcess comGuestProcess);
192 void sigGuestProcessUnregistered(CGuestProcess comGuestProcess);
193 void sigGuestSessionStatedChanged(const CGuestSessionStateChangedEvent &comEvent);
194 void sigGuestProcessStateChanged(const CGuestProcessStateChangedEvent &comEvent);
195 /** @} */
196
197public:
198
199 /** Constructs main event listener. */
200 UIMainEventListener();
201
202 /** Initialization routine. */
203 HRESULT init(QObject *pParent) { Q_UNUSED(pParent); return S_OK; }
204 /** Deinitialization routine. */
205 void uninit() {}
206
207 /** Registers event @a source for passive event @a listener. */
208 void registerSource(const CEventSource &comSource, const CEventListener &comListener);
209 /** Unregisters event sources. */
210 void unregisterSources();
211
212 /** Main event handler routine. */
213 STDMETHOD(HandleEvent)(VBoxEventType_T enmType, IEvent *pEvent);
214
215 /** Holds the list of threads handling passive event listening. */
216 QList<UIMainEventListeningThread*> m_threads;
217};
218
219/** Wraps the IListener interface around our implementation class. */
220typedef ListenerImpl<UIMainEventListener, QObject*> UIMainEventListenerImpl;
221
222#endif /* !FEQT_INCLUDED_SRC_globals_UIMainEventListener_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use