1 | /* $Id: UIGuestOSType.h 103906 2024-03-18 18:37:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIGuestOSType class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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_UIGuestOSType_h
|
---|
29 | #define FEQT_INCLUDED_SRC_globals_UIGuestOSType_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QMap>
|
---|
36 | #include <QString>
|
---|
37 | #include <QVector>
|
---|
38 |
|
---|
39 | /* COM includes: */
|
---|
40 | #include "CGuestOSType.h"
|
---|
41 |
|
---|
42 | /** Represents guest OS family info. */
|
---|
43 | struct UIFamilyInfo
|
---|
44 | {
|
---|
45 | /** Constructs empty family info. */
|
---|
46 | UIFamilyInfo()
|
---|
47 | : m_enmArch(KPlatformArchitecture_None)
|
---|
48 | , m_fSupported(false)
|
---|
49 | {}
|
---|
50 |
|
---|
51 | /** Constructs family info.
|
---|
52 | * @param strId Brings the family ID.
|
---|
53 | * @param strDescription Brings the family description.
|
---|
54 | * @param enmArch Brings the family architecture.
|
---|
55 | * @param fSupported Brings whether family is supported. */
|
---|
56 | UIFamilyInfo(const QString &strId,
|
---|
57 | const QString &strDescription,
|
---|
58 | KPlatformArchitecture enmArch,
|
---|
59 | bool fSupported)
|
---|
60 | : m_strId(strId)
|
---|
61 | , m_strDescription(strDescription)
|
---|
62 | , m_enmArch(enmArch)
|
---|
63 | , m_fSupported(fSupported)
|
---|
64 | {}
|
---|
65 |
|
---|
66 | /** Returns whether this family info has the same id as @a other. */
|
---|
67 | bool operator==(const UIFamilyInfo &other) const
|
---|
68 | {
|
---|
69 | return m_strId == other.m_strId;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /** Holds family id. */
|
---|
73 | QString m_strId;
|
---|
74 | /** Holds family description. */
|
---|
75 | QString m_strDescription;
|
---|
76 | /** Holds family architecture. */
|
---|
77 | KPlatformArchitecture m_enmArch;
|
---|
78 | /** Holds whether family is supported. */
|
---|
79 | bool m_fSupported;
|
---|
80 | };
|
---|
81 |
|
---|
82 | /** Represents guest OS subtype info. */
|
---|
83 | struct UISubtypeInfo
|
---|
84 | {
|
---|
85 | /** Constructs empty subtype info. */
|
---|
86 | UISubtypeInfo()
|
---|
87 | : m_enmArch(KPlatformArchitecture_None)
|
---|
88 | , m_fSupported(false)
|
---|
89 | {}
|
---|
90 |
|
---|
91 | /** Constructs subtype info.
|
---|
92 | * @param strName Brings the name.
|
---|
93 | * @param enmArch Brings the architecture type.
|
---|
94 | * @param fSupported Brings whether subtype is supported. */
|
---|
95 | UISubtypeInfo(const QString &strName,
|
---|
96 | KPlatformArchitecture enmArch,
|
---|
97 | bool fSupported)
|
---|
98 | : m_strName(strName)
|
---|
99 | , m_enmArch(enmArch)
|
---|
100 | , m_fSupported(fSupported)
|
---|
101 | {}
|
---|
102 |
|
---|
103 | /** Returns whether this subtype info has the same name as @a other. */
|
---|
104 | bool operator==(const UISubtypeInfo &other) const
|
---|
105 | {
|
---|
106 | return m_strName == other.m_strName;
|
---|
107 | }
|
---|
108 |
|
---|
109 | /** Holds the name. */
|
---|
110 | QString m_strName;
|
---|
111 | /** Holds the architecture. */
|
---|
112 | KPlatformArchitecture m_enmArch;
|
---|
113 | /** Holds whether subtype is supported. */
|
---|
114 | bool m_fSupported;
|
---|
115 | };
|
---|
116 |
|
---|
117 | /** A wrapper around CGuestOSType. Some of the properties are cached here for performance. */
|
---|
118 | class SHARED_LIBRARY_STUFF UIGuestOSType
|
---|
119 | {
|
---|
120 |
|
---|
121 | public:
|
---|
122 |
|
---|
123 | UIGuestOSType(const CGuestOSType &comGuestOSType, bool fSupported);
|
---|
124 | UIGuestOSType();
|
---|
125 |
|
---|
126 | bool isSupported() const;
|
---|
127 |
|
---|
128 | const QString &getFamilyId() const;
|
---|
129 | const QString &getFamilyDescription() const;
|
---|
130 | const QString &getId() const;
|
---|
131 | const QString &getSubtype() const;
|
---|
132 | const QString &getDescription() const;
|
---|
133 |
|
---|
134 | /** @name Wrapper getters for CGuestOSType member.
|
---|
135 | * @{ */
|
---|
136 | KStorageBus getRecommendedHDStorageBus() const;
|
---|
137 | ULONG getRecommendedRAM() const;
|
---|
138 | KStorageBus getRecommendedDVDStorageBus() const;
|
---|
139 | ULONG getRecommendedCPUCount() const;
|
---|
140 | KFirmwareType getRecommendedFirmware() const;
|
---|
141 | bool getRecommendedFloppy() const;
|
---|
142 | LONG64 getRecommendedHDD() const;
|
---|
143 | KGraphicsControllerType getRecommendedGraphicsController() const;
|
---|
144 | KStorageControllerType getRecommendedDVDStorageController() const;
|
---|
145 | bool is64Bit() const;
|
---|
146 | KPlatformArchitecture getPlatformArchitecture() const;
|
---|
147 | /** @} */
|
---|
148 |
|
---|
149 | bool isOk() const;
|
---|
150 |
|
---|
151 | private:
|
---|
152 |
|
---|
153 | CGuestOSType m_comGuestOSType;
|
---|
154 |
|
---|
155 | bool m_fSupported;
|
---|
156 |
|
---|
157 | /** @name CGuestOSType properties. Cached here for a faster access.
|
---|
158 | * @{ */
|
---|
159 | mutable QString m_strFamilyId;
|
---|
160 | mutable QString m_strFamilyDescription;
|
---|
161 | mutable QString m_strId;
|
---|
162 | mutable QString m_strSubtype;
|
---|
163 | mutable QString m_strDescription;
|
---|
164 | /** @} */
|
---|
165 | };
|
---|
166 |
|
---|
167 | /** A wrapper and manager class for Guest OS types (IGuestOSType). Logically we structure os types into families
|
---|
168 | * e.g. Window, Linux etc. Some families have so-called subtypes which for Linux corresponds to distros, while some
|
---|
169 | * families have no subtype. Under subtypes (and when no subtype exists direcly under family) we have guest os
|
---|
170 | * types, e.g. Debian12_x64 etc. */
|
---|
171 | class SHARED_LIBRARY_STUFF UIGuestOSTypeManager
|
---|
172 | {
|
---|
173 | public:
|
---|
174 |
|
---|
175 | /** OS info pair. 'first' is id and 'second' is description. */
|
---|
176 | typedef QPair<QString, QString> UIGuestInfoPair;
|
---|
177 | /** A list of all OS families. */
|
---|
178 | typedef QVector<UIFamilyInfo> UIGuestOSFamilyInfo;
|
---|
179 | /** A list of all OS subtypes. */
|
---|
180 | typedef QVector<UISubtypeInfo> UIGuestOSSubtypeInfo;
|
---|
181 | /** A list of all OS type pairs. */
|
---|
182 | typedef QVector<UIGuestInfoPair> UIGuestOSTypeInfo;
|
---|
183 |
|
---|
184 | /** Constructs guest OS type manager. */
|
---|
185 | UIGuestOSTypeManager() {}
|
---|
186 | /** Prohibits to copy guest OS type manager. */
|
---|
187 | UIGuestOSTypeManager(const UIGuestOSTypeManager &other) = delete;
|
---|
188 |
|
---|
189 | /** Re-create the guest OS type database. */
|
---|
190 | void reCacheGuestOSTypes();
|
---|
191 |
|
---|
192 | /** Returns a list of all families.
|
---|
193 | * @param fListAll Brings whether a list of all families is requested, supported otherwise.
|
---|
194 | * @param exceptions Brings the list of families to be included even if they are restricted. */
|
---|
195 | UIGuestOSFamilyInfo getFamilies(bool fListAll = true,
|
---|
196 | const QStringList &exceptions = QStringList(),
|
---|
197 | KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
198 | /** Returns the list of subtypes for @p strFamilyId. This may be an empty list.
|
---|
199 | * @param fListAll Brings whether a list of all subtypes is requested, supported otherwise.
|
---|
200 | * @param exceptions Brings the list of subtypes to be included even if they are restricted. */
|
---|
201 | UIGuestOSSubtypeInfo getSubtypesForFamilyId(const QString &strFamilyId,
|
---|
202 | bool fListAll = true,
|
---|
203 | const QStringList &exceptions = QStringList(),
|
---|
204 | KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
205 | /** Returns a list of OS types for the @p strFamilyId.
|
---|
206 | * @param fListAll Brings whether a list of all types is requested, supported otherwise.
|
---|
207 | * @param exceptions Brings the list of types to be included even if they are restricted. */
|
---|
208 | UIGuestOSTypeInfo getTypesForFamilyId(const QString &strFamilyId,
|
---|
209 | bool fListAll = true,
|
---|
210 | const QStringList &exceptions = QStringList(),
|
---|
211 | KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
212 | /** Returns a list of OS types for the @p strSubtype.
|
---|
213 | * @param fListAll Brings whether a list of all types is requested, supported otherwise.
|
---|
214 | * @param exceptions Brings the list of types to be included even if they are restricted. */
|
---|
215 | UIGuestOSTypeInfo getTypesForSubtype(const QString &strSubtype,
|
---|
216 | bool fListAll = true,
|
---|
217 | const QStringList &exceptions = QStringList(),
|
---|
218 | KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
|
---|
219 |
|
---|
220 | /** Returns whether specified @a strOSTypeId is of DOS type. */
|
---|
221 | static bool isDOSType(const QString &strOSTypeId);
|
---|
222 |
|
---|
223 | /** @name Getters for UIGuestOSType properties.
|
---|
224 | * They utilize a map for faster access to UIGuestOSType instance with @p strTypeId.
|
---|
225 | * @{ */
|
---|
226 | QString getFamilyId(const QString &strTypeId) const;
|
---|
227 | QString getSubtype(const QString &strTypeId) const;
|
---|
228 | KGraphicsControllerType getRecommendedGraphicsController(const QString &strTypeId) const;
|
---|
229 | ULONG getRecommendedRAM(const QString &strTypeId) const;
|
---|
230 | ULONG getRecommendedCPUCount(const QString &strTypeId) const;
|
---|
231 | KFirmwareType getRecommendedFirmware(const QString &strTypeId) const;
|
---|
232 | QString getDescription(const QString &strTypeId) const;
|
---|
233 | LONG64 getRecommendedHDD(const QString &strTypeId) const;
|
---|
234 | KStorageBus getRecommendedHDStorageBus(const QString &strTypeId) const;
|
---|
235 | KStorageBus getRecommendedDVDStorageBus(const QString &strTypeId) const;
|
---|
236 | bool getRecommendedFloppy(const QString &strTypeId) const;
|
---|
237 | KStorageControllerType getRecommendedDVDStorageController(const QString &strTypeId) const;
|
---|
238 | bool isLinux(const QString &strTypeId) const;
|
---|
239 | bool isWindows(const QString &strTypeId) const;
|
---|
240 | bool is64Bit(const QString &strOSTypeId) const;
|
---|
241 | KPlatformArchitecture getPlatformArchitecture(const QString &strTypeId) const;
|
---|
242 | /** @} */
|
---|
243 |
|
---|
244 | private:
|
---|
245 |
|
---|
246 | /** Adds certain @a comType to internal cache. */
|
---|
247 | void addGuestOSType(const CGuestOSType &comType);
|
---|
248 |
|
---|
249 | /** Holds the list of supported guest OS type IDs. */
|
---|
250 | QStringList m_supportedGuestOSTypeIDs;
|
---|
251 |
|
---|
252 | /** The type list. Here it is a pointer to QVector to delay definition of UIGuestOSType. */
|
---|
253 | QVector<UIGuestOSType> m_guestOSTypes;
|
---|
254 | /** A map to prevent linear search of UIGuestOSType instances wrt. typeId. Key is typeId and value
|
---|
255 | * is index to m_guestOSTypes list. */
|
---|
256 | QMap<QString, int> m_typeIdIndexMap;
|
---|
257 |
|
---|
258 | /** Hold the list of guest OS family info. */
|
---|
259 | UIGuestOSFamilyInfo m_guestOSFamilies;
|
---|
260 | /** Hold the list of guest OS subtype info. */
|
---|
261 | QMap<QString, UIGuestOSSubtypeInfo> m_guestOSSubtypes;
|
---|
262 | };
|
---|
263 |
|
---|
264 | #endif /* !FEQT_INCLUDED_SRC_globals_UIGuestOSType_h */
|
---|