VirtualBox

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

Last change on this file since 100347 was 98382, checked in by vboxsync, 2 years ago

Merging r155235 and r155243 from gui4 branch: FE/Qt: Runtime UI: Small cleanup in UISession code related to action-pool, additions stuff and UIConsoleEventHandler.

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

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