VirtualBox

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

Last change on this file since 102493 was 100737, checked in by vboxsync, 14 months ago

API/FE/Qt: bugref:10466. bugref:10465. Adding a new event to signal successful uninstallation of extension pack. And GUI side of the code to handl this event.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.4 KB
Line 
1/* $Id: UIMainEventListener.h 100737 2023-07-30 09:48:13Z 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 /** Notifies about ext.pack installation @a strname is the name of the installed ext. pack. */
126 void sigExtensionPackInstalled(const QString &strName);
127 /** Notifies about ext.pack uninstallation @a strname is the name of the installed ext. pack. */
128 void sigExtensionPackUninstalled(const QString &strName);
129 /** @} */
130
131 /** @name VirtualBox Extra-data related signals
132 * @{ */
133 /** Notifies about extra-data of the machine with @a uId can be changed for the key @a strKey to value @a strValue. */
134 void sigExtraDataCanChange(const QUuid &uId, const QString &strKey, const QString &strValue, bool &fVeto, QString &strVetoReason); /* use Qt::DirectConnection */
135 /** Notifies about extra-data of the machine with @a uId changed for the key @a strKey to value @a strValue. */
136 void sigExtraDataChange(const QUuid &uId, const QString &strKey, const QString &strValue);
137 /** @} */
138
139 /** @name VirtualBox Medium related signals
140 * @{ */
141 /** Notifies about storage controller change.
142 * @param uMachineId Brings the ID of machine corresponding controller belongs to.
143 * @param strControllerName Brings the name of controller this event is related to. */
144 void sigStorageControllerChange(const QUuid &uMachineId, const QString &strControllerName);
145 /** Notifies about storage device change.
146 * @param comAttachment Brings corresponding attachment.
147 * @param fRemoved Brings whether medium is removed or added.
148 * @param fSilent Brings whether this change has gone silent for guest. */
149 void sigStorageDeviceChange(CMediumAttachment comAttachment, bool fRemoved, bool fSilent);
150
151 /** Notifies about storage medium @a comAttachment state change. */
152 void sigMediumChange(CMediumAttachment comAttachment);
153 /** Notifies about storage @a comMedium config change. */
154 void sigMediumConfigChange(CMedium comMedium);
155 /** Notifies about storage medium is (un)registered.
156 * @param uMediumId Brings corresponding medium ID.
157 * @param enmMediumType Brings corresponding medium type.
158 * @param fRegistered Brings whether medium is registered or unregistered. */
159 void sigMediumRegistered(const QUuid &uMediumId, KDeviceType enmMediumType, bool fRegistered);
160 /** @} */
161
162 /** @name Console related signals
163 * @{ */
164 /** Notifies about mouse pointer @a shapeData change. */
165 void sigMousePointerShapeChange(const UIMousePointerShapeData &shapeData);
166 /** Notifies about mouse capability change to @a fSupportsAbsolute, @a fSupportsRelative,
167 * @a fSupportsTouchScreen, @a fSupportsTouchPad and @a fNeedsHostCursor. */
168 void sigMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative,
169 bool fSupportsTouchScreen, bool fSupportsTouchPad,
170 bool fNeedsHostCursor);
171 /** Notifies about guest request to change the cursor position to @a uX * @a uY.
172 * @param fContainsData Brings whether the @a uX and @a uY values are valid and could be used by the GUI now. */
173 void sigCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY);
174 /** Notifies about keyboard LEDs change for @a fNumLock, @a fCapsLock and @a fScrollLock. */
175 void sigKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
176 /** Notifies about machine @a state change. */
177 void sigStateChange(KMachineState state);
178 /** Notifies about guest additions state change. */
179 void sigAdditionsChange();
180 /** Notifies about network @a adapter state change. */
181 void sigNetworkAdapterChange(CNetworkAdapter comAdapter);
182 /** Notifies about VRDE device state change. */
183 void sigVRDEChange();
184 /** Notifies about recording state change. */
185 void sigRecordingChange();
186 /** Notifies about USB controller state change. */
187 void sigUSBControllerChange();
188 /** Notifies about USB @a device state change to @a fAttached, holding additional @a error information. */
189 void sigUSBDeviceStateChange(CUSBDevice comDevice, bool fAttached, CVirtualBoxErrorInfo comError);
190 /** Notifies about shared folder state change. */
191 void sigSharedFolderChange();
192 /** Notifies about CPU execution-cap change. */
193 void sigCPUExecutionCapChange();
194 /** Notifies about guest-screen configuration change of @a type for @a uScreenId with @a screenGeo. */
195 void sigGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
196 /** Notifies about Runtime error with @a strErrorId which is @a fFatal and have @a strMessage. */
197 void sigRuntimeError(bool fFatal, QString strErrorId, QString strMessage);
198 /** Notifies about VM window can be shown, allowing to prevent it by @a fVeto with @a strReason. */
199 void sigCanShowWindow(bool &fVeto, QString &strReason); /* use Qt::DirectConnection */
200 /** Notifies about VM window with specified @a winId should be shown. */
201 void sigShowWindow(qint64 &winId); /* use Qt::DirectConnection */
202 /** Notifies about audio adapter state change. */
203 void sigAudioAdapterChange();
204 /** Notifies about the clipboard mode change. */
205 void sigClipboardModeChange(KClipboardMode enmClipboardMode);
206 /** Notifies about a clipboard error. */
207 void sigClipboardError(QString strId, QString strMsg, long rcError);
208 /** Notifies about the drag and drop mode change. */
209 void sigDnDModeChange(KDnDMode enmDnDMode);
210 /** @} */
211
212 /** @name Progress related signals
213 * @{ */
214 /** Notifies about @a iPercent change for progress with @a uProgressId. */
215 void sigProgressPercentageChange(const QUuid &uProgressId, const int iPercent);
216 /** Notifies about task complete for progress with @a uProgressId. */
217 void sigProgressTaskComplete(const QUuid &uProgressId);
218 /** @} */
219
220 /** @name Guest Session related signals
221 * @{ */
222 /** Notifies about guest session (un)registered event @a is the (un)registed guest session. */
223 void sigGuestSessionRegistered(CGuestSession comGuestSession);
224 void sigGuestSessionUnregistered(CGuestSession comGuestSession);
225
226 /** Notifies about guest process (un)registered event @a is the (un)registed guest process. */
227 void sigGuestProcessRegistered(CGuestProcess comGuestProcess);
228 void sigGuestProcessUnregistered(CGuestProcess comGuestProcess);
229 void sigGuestSessionStatedChanged(const CGuestSessionStateChangedEvent &comEvent);
230 void sigGuestProcessStateChanged(const CGuestProcessStateChangedEvent &comEvent);
231 /** @} */
232
233public:
234
235 /** Constructs main event listener. */
236 UIMainEventListener();
237
238 /** Initialization routine. */
239 HRESULT init(QObject *pParent) { Q_UNUSED(pParent); return S_OK; }
240 /** Deinitialization routine. */
241 void uninit() {}
242
243 /** Registers event source for passive event listener by creating a listening thread.
244 * @param comSource Brings event source we are creating listening thread for.
245 * @param comListener Brings event listener we are creating listening thread for.
246 * @param escapeEventTypes Brings a set of escape event types which commands listener to finish. */
247 void registerSource(const CEventSource &comSource,
248 const CEventListener &comListener,
249 const QSet<KVBoxEventType> &escapeEventTypes = QSet<KVBoxEventType>());
250 /** Unregisters event sources. */
251 void unregisterSources();
252
253 /** Main event handler routine. */
254 STDMETHOD(HandleEvent)(VBoxEventType_T enmType, IEvent *pEvent);
255
256 /** Holds the list of threads handling passive event listening. */
257 QList<UIMainEventListeningThread*> m_threads;
258
259private slots:
260
261 /** Handles thread finished signal. */
262 void sltHandleThreadFinished();
263};
264
265/** Wraps the IListener interface around our implementation class. */
266typedef ListenerImpl<UIMainEventListener, QObject*> UIMainEventListenerImpl;
267
268#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