VirtualBox

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

Last change on this file was 103803, checked in by vboxsync, 2 months ago

FE/Qt. bugref:10618. Splitting COMEnums.h file into individual enum header files.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use