VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.h@ 104158

Last change on this file since 104158 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/* $Id: UIMediumEnumerator.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMediumEnumerator class declaration.
4 */
5
6/*
7 * Copyright (C) 2013-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_medium_UIMediumEnumerator_h
29#define FEQT_INCLUDED_SRC_medium_UIMediumEnumerator_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QObject>
36#include <QSet>
37
38/* GUI includes: */
39#include "QIWithRetranslateUI.h"
40#include "UILibraryDefs.h"
41#include "UIMedium.h"
42
43/* COM includes: */
44# include "CMedium.h"
45# include "CMediumAttachment.h"
46
47/* Forward declarations: */
48class UITask;
49class UIThreadPool;
50
51/** A map of CMedium objects ordered by their IDs. */
52typedef QMap<QUuid, CMedium> CMediumMap;
53
54/** QObject extension operating as medium-enumeration object.
55 * Manages access to cached UIMedium information via public API.
56 * Updates cache on corresponding Main events using thread-pool interface. */
57class SHARED_LIBRARY_STUFF UIMediumEnumerator : public QIWithRetranslateUI3<QObject>
58{
59 Q_OBJECT;
60
61signals:
62
63 /** Notifies listeners about UIMedium with @a uMediumID created. */
64 void sigMediumCreated(const QUuid &uMediumID);
65 /** Notifies listeners about UIMedium with @a uMediumID deleted. */
66 void sigMediumDeleted(const QUuid &uMediumID);
67
68 /** Notifies listeners about consolidated medium-enumeration process has started. */
69 void sigMediumEnumerationStarted();
70 /** Notifies listeners about UIMedium with @a uMediumID updated. */
71 void sigMediumEnumerated(const QUuid &uMediumID);
72 /** Notifies listeners about consolidated medium-enumeration process has finished. */
73 void sigMediumEnumerationFinished();
74
75public:
76
77 /** Constructs medium-enumerator object. */
78 UIMediumEnumerator();
79
80 /** Returns cached UIMedium ID list. */
81 QList<QUuid> mediumIDs() const;
82 /** Returns a wrapper of cached UIMedium with specified @a uMediumID. */
83 UIMedium medium(const QUuid &uMediumID) const;
84
85 /** Creates UIMedium thus caching it internally on the basis of passed @a guiMedium information. */
86 void createMedium(const UIMedium &guiMedium);
87
88 /** Returns whether full consolidated medium-enumeration process is requested. */
89 bool isFullMediumEnumerationRequested() const { return m_fFullMediumEnumerationRequested; }
90 /** Returns whether any consolidated medium-enumeration process is in progress. */
91 bool isMediumEnumerationInProgress() const { return m_fMediumEnumerationInProgress; }
92 /** Makes a request to enumerate specified @a comMedia.
93 * @note Empty passed map means that full/overall medium-enumeration is requested.
94 * In that case previous map will be replaced with the new one, values
95 * present in both maps will be merged from the previous to new one.
96 * @note Non-empty passed map means that additional medium-enumeration is requested.
97 * In that case previous map will be extended with the new one, values
98 * present in both maps will be merged from the previous to new one. */
99 void enumerateMedia(const CMediumVector &comMedia = CMediumVector());
100 /** Refresh all the lightweight UIMedium information for all the cached UIMedium(s).
101 * @note Please note that this is a lightweight version, which doesn't perform
102 * heavy state/accessibility checks thus doesn't require to be performed
103 * by a worker COM-aware thread. */
104 void refreshMedia();
105
106protected:
107
108 /** Handles translation event. */
109 virtual void retranslateUi() RT_OVERRIDE;
110
111private slots:
112
113 /** Handles machine-data-change event for a machine with specified @a uMachineId. */
114 void sltHandleMachineDataChange(const QUuid &uMachineId);
115
116 /** Handles signal about storage controller change.
117 * @param uMachineId Brings the ID of machine corresponding controller belongs to.
118 * @param strControllerName Brings the name of controller this event is related to. */
119 void sltHandleStorageControllerChange(const QUuid &uMachineId, const QString &strControllerName);
120 /** Handles signal about storage device change.
121 * @param comAttachment Brings corresponding attachment.
122 * @param fRemoved Brings whether medium is removed or added.
123 * @param fSilent Brings whether this change has gone silent for guest. */
124 void sltHandleStorageDeviceChange(CMediumAttachment comAttachment, bool fRemoved, bool fSilent);
125 /** Handles signal about storage medium @a comAttachment state change. */
126 void sltHandleMediumChange(CMediumAttachment comAttachment);
127 /** Handles signal about storage @a comMedium config change. */
128 void sltHandleMediumConfigChange(CMedium comMedium);
129 /** Handles signal about storage medium is (un)registered.
130 * @param uMediumId Brings corresponding medium ID.
131 * @param enmMediumType Brings corresponding medium type.
132 * @param fRegistered Brings whether medium is registered or unregistered. */
133 void sltHandleMediumRegistered(const QUuid &uMediumId, KDeviceType enmMediumType, bool fRegistered);
134
135 /** Handles medium-enumeration @a pTask complete signal. */
136 void sltHandleMediumEnumerationTaskComplete(UITask *pTask);
137
138private:
139
140 /** Creates medium-enumeration task for certain @a guiMedium. */
141 void createMediumEnumerationTask(const UIMedium &guiMedium);
142 /** Adds NULL UIMedium to specified @a outputMedia map. */
143 void addNullMediumToMap(UIMediumMap &outputMedia);
144 /** Adds @a inputMedia to specified @a outputMedia map. */
145 void addMediaToMap(const CMediumVector &inputMedia, UIMediumMap &outputMedia);
146
147 /** Parses incoming @a comAttachment, enumerating the media it has attached.
148 * @param result Brings the list of previously enumerated media
149 * IDs to be appended with newly enumerated. */
150 void parseAttachment(CMediumAttachment comAttachment, QList<QUuid> &result);
151 /** Parses incoming @a comMedium, enumerating the media it represents.
152 * @param result Brings the list of previously enumerated media
153 * IDs to be appended with newly enumerated. */
154 void parseMedium(CMedium comMedium, QList<QUuid> &result);
155
156 /** Enumerates all the known media attached to machine with certain @a uMachineId.
157 * @param result Brings the list of previously enumerated media
158 * IDs to be appended with newly enumerated. */
159 void enumerateAllMediaOfMachineWithId(const QUuid &uMachineId, QList<QUuid> &result);
160 /** Enumerates all the children media of medium with certain @a uMediumId.
161 * @param result Brings the list of previously enumerated media
162 * IDs to be appended with newly enumerated. */
163 void enumerateAllMediaOfMediumWithId(const QUuid &uMediumId, QList<QUuid> &result);
164
165 /** Holds whether full consolidated medium-enumeration process is requested. */
166 bool m_fFullMediumEnumerationRequested;
167 /** Holds whether any consolidated medium-enumeration process is in progress. */
168 bool m_fMediumEnumerationInProgress;
169
170 /** Holds a set of current medium-enumeration tasks. */
171 QSet<UITask*> m_tasks;
172
173 /** Holds a map of currently cached (enumerated) media. */
174 UIMediumMap m_media;
175 /** Holds a set of currently registered media IDs. */
176 QSet<QUuid> m_registeredMediaIds;
177};
178
179#endif /* !FEQT_INCLUDED_SRC_medium_UIMediumEnumerator_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