VirtualBox

source: vbox/trunk/src/VBox/Main/include/Global.h

Last change on this file was 102609, checked in by vboxsync, 5 months ago

Main/Global: Added some more stringify methods for Guest Control stuff [Doxygen fix].

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.1 KB
RevLine 
[9360]1/* $Id: Global.h 102609 2023-12-15 11:26:11Z vboxsync $ */
2/** @file
[34244]3 * VirtualBox COM API - Global Declarations and Definitions.
[9360]4 */
5
6/*
[98103]7 * Copyright (C) 2008-2023 Oracle and/or its affiliates.
[9360]8 *
[96407]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
[9360]26 */
27
[76562]28#ifndef MAIN_INCLUDED_Global_h
29#define MAIN_INCLUDED_Global_h
[76487]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[9360]33
[14667]34/* interface definitions */
35#include "VBox/com/VirtualBox.h"
36
[9360]37#include <VBox/ostypes.h>
38
39#include <iprt/types.h>
40
[101215]41/** @name Generic OS hint bits.
42 * @{
43 */
[15064]44#define VBOXOSHINT_NONE 0
45#define VBOXOSHINT_64BIT RT_BIT(0)
[101215]46#define VBOXOSHINT_EFI RT_BIT(1)
47#define VBOXOSHINT_USBHID RT_BIT(2)
48#define VBOXOSHINT_USBTABLET RT_BIT(3)
49#define VBOXOSHINT_RTCUTC RT_BIT(4)
50#define VBOXOSHINT_ACCEL2D RT_BIT(5)
51#define VBOXOSHINT_ACCEL3D RT_BIT(6)
52#define VBOXOSHINT_FLOPPY RT_BIT(7)
53#define VBOXOSHINT_NOUSB RT_BIT(8)
54#define VBOXOSHINT_TFRESET RT_BIT(9)
55#define VBOXOSHINT_USB3 RT_BIT(10)
56#define VBOXOSHINT_EFI_SECUREBOOT RT_BIT(11)
57#define VBOXOSHINT_TPM RT_BIT(12)
58#define VBOXOSHINT_TPM2 RT_BIT(13)
59#define VBOXOSHINT_WDDM_GRAPHICS RT_BIT(14)
60/** @} */
[15064]61
[101215]62/** @name x86-specific OS hint bits.
63 * @{
64 */
65#define VBOXOSHINT_X86_HWVIRTEX RT_BIT(15)
66#define VBOXOSHINT_X86_IOAPIC RT_BIT(16)
67#define VBOXOSHINT_X86_HPET RT_BIT(17)
68#define VBOXOSHINT_X86_PAE RT_BIT(18)
69#define VBOXOSHINT_X86_X2APIC RT_BIT(19)
70/** @} */
71
[34244]72/** The VBoxVRDP kludge extension pack name.
73 *
74 * This is not a valid extension pack name (dashes are not allowed), and
75 * hence will not conflict with real extension packs.
76 */
77#define VBOXVRDP_KLUDGE_EXTPACK_NAME "Built-in-VBoxVRDP"
78
[94714]79/** The VBoxPuelCrypto kludge extension pack name.
80 *
81 * This is not a valid extension pack name (dashes are not allowed), and
82 * hence will not conflict with real extension packs.
83 */
84#define VBOXPUELCRYPTO_KLUDGE_EXTPACK_NAME "Built-in-VBoxPuelCrypto"
85
[9360]86/**
87 * Contains global static definitions that can be referenced by all COM classes
88 * regardless of the apartment.
89 */
90class Global
91{
92public:
93
94 /** Represents OS Type <-> string mappings. */
[9361]95 struct OSType
[9360]96 {
[101683]97 const char *familyId; /* utf-8, e.g. Linux or MacOS */
98 const char *familyDescription; /* utf-8, e.g. Linux or Mac OS X */
99 const char *subtype; /* utf-8, the subtype of the family e.g. Debian or FreeBSD */
100 const char *id; /* utf-8, VM config file value e.g. Debian12_64 */
101 const char *description; /* utf-8, e.g. "Debian 12 Bookworm (64-bit)" */
102 const char *guestAdditionsInstallPkgName; /* utf-8, e.g. "VBoxLinuxAdditions.run" */
103 const VBOXOSTYPE osType; /* enum, e.g. VBOXOSTYPE_Debian12_x64 */
[26389]104 const uint32_t osHint;
[91470]105 const uint32_t recommendedCPUCount;
[26389]106 const uint32_t recommendedRAM;
107 const uint32_t recommendedVRAM;
[32531]108 const uint64_t recommendedHDD;
[75817]109 const GraphicsControllerType_T graphicsControllerType;
[26389]110 const NetworkAdapterType_T networkAdapterType;
111 const uint32_t numSerialEnabled;
[28825]112 const StorageControllerType_T dvdStorageControllerType;
113 const StorageBus_T dvdStorageBusType;
114 const StorageControllerType_T hdStorageControllerType;
115 const StorageBus_T hdStorageBusType;
[32120]116 const ChipsetType_T chipsetType;
[87241]117 const IommuType_T iommuType;
[33447]118 const AudioControllerType_T audioControllerType;
[56459]119 const AudioCodecType_T audioCodecType;
[9360]120 };
121
[39248]122 static const OSType sOSTypes[];
[63431]123 static size_t cOSTypes;
[9360]124
[39248]125 /**
126 * Maps VBOXOSTYPE to the OS type which is used in VM configs.
127 */
[23648]128 static const char *OSTypeId(VBOXOSTYPE aOSType);
[15762]129
130 /**
[67733]131 * Maps an OS type ID string to index into sOSTypes.
132 * @returns index on success, UINT32_MAX if not found.
133 */
134 static uint32_t getOSTypeIndexFromId(const char *pszId);
135
136 /**
[15762]137 * Returns @c true if the given machine state is an online state. This is a
138 * recommended way to detect if the VM is online (being executed in a
139 * dedicated process) or not. Note that some online states are also
[65158]140 * transitional states (see #IsTransient()).
[15762]141 */
[23648]142 static bool IsOnline(MachineState_T aState)
[15762]143 {
144 return aState >= MachineState_FirstOnline &&
145 aState <= MachineState_LastOnline;
146 }
147
148 /**
149 * Returns @c true if the given machine state is a transient state. This is
150 * a recommended way to detect if the VM is performing some potentially
[28205]151 * lengthy operation (such as starting, stopping, saving, deleting
[15762]152 * snapshot, etc.). Note some (but not all) transitional states are also
153 * online states (see #IsOnline()).
154 */
[23648]155 static bool IsTransient(MachineState_T aState)
[15762]156 {
157 return aState >= MachineState_FirstTransient &&
158 aState <= MachineState_LastTransient;
159 }
160
161 /**
[24301]162 * Shortcut to <tt>IsOnline(aState) || IsTransient(aState)</tt>. When it returns
[65120]163 * @c false, the VM is turned off (no VM process) and not busy with
[15762]164 * another exclusive operation.
165 */
[23648]166 static bool IsOnlineOrTransient(MachineState_T aState)
[15762]167 {
[23648]168 return IsOnline(aState) || IsTransient(aState);
[15762]169 }
170
171 /**
[93410]172 * Stringify a machine state - translated.
[23648]173 *
[93410]174 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
175 * version of this method.
176 *
[23648]177 * @returns Pointer to a read only string.
178 * @param aState Valid machine state.
179 */
180 static const char *stringifyMachineState(MachineState_T aState);
[23675]181
182 /**
[93410]183 * Stringify a session state - translated.
[23675]184 *
[93410]185 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
186 * version of this method.
187 *
[23675]188 * @returns Pointer to a read only string.
189 * @param aState Valid session state.
190 */
[23676]191 static const char *stringifySessionState(SessionState_T aState);
[24618]192
193 /**
[93480]194 * Stringify a device type.
[93405]195 *
[93410]196 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
197 * version of this method.
198 *
[93405]199 * @returns Pointer to a read only string.
[93480]200 * @param aType The device type.
[93405]201 */
[93480]202 static const char *stringifyDeviceType(DeviceType_T aType);
[93405]203
204 /**
[102601]205 * Stringify a guest session status.
206 *
207 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
208 * version of this method.
209 *
210 * @returns Pointer to a read only string.
211 * @param aStatus The guest session status.
212 */
213 static const char *stringifyGuestSessionStatus(GuestSessionStatus_T aStatus);
214
215 /**
216 * Stringify a process status.
217 *
218 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
219 * version of this method.
220 *
221 * @returns Pointer to a read only string.
222 * @param aStatus The process status.
223 */
224 static const char *stringifyProcessStatus(ProcessStatus_T aStatus);
225
226 /**
227 * Stringify a process wait result.
228 *
229 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
230 * version of this method.
231 *
232 * @returns Pointer to a read only string.
[102608]233 * @param aWaitResult The process wait result.
[102601]234 */
235 static const char *stringifyProcessWaitResult(ProcessWaitResult_T aWaitResult);
236
237 /**
[102609]238 * Stringify a file status.
[102601]239 *
240 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
241 * version of this method.
242 *
243 * @returns Pointer to a read only string.
244 * @param aStatus The file status.
245 */
246 static const char *stringifyFileStatus(FileStatus_T aStatus);
247
248 /**
249 * Stringify a filesystem object type.
250 *
251 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
252 * version of this method.
253 *
254 * @returns Pointer to a read only string.
[102608]255 * @param aType The filesystem object type.
[102601]256 */
257 static const char *stringifyFsObjType(FsObjType_T aType);
258
259 /**
[101460]260 * Stringify a platform architecture to a string.
261 *
262 * @returns Platform architecture as a string.
263 * @param aEnmArchitecture Platform architecture to convert.
264 */
265 static const char *stringifyPlatformArchitecture(PlatformArchitecture_T aEnmArchitecture);
266
267 /**
[93480]268 * Stringify a storage controller type.
[24933]269 *
[93410]270 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
271 * version of this method.
272 *
[24933]273 * @returns Pointer to a read only string.
[93480]274 * @param aType The storage controller type.
[24933]275 */
[93480]276 static const char *stringifyStorageControllerType(StorageControllerType_T aType);
[24933]277
[93480]278#if 0 /* unused */
[24933]279 /**
[93480]280 * Stringify a storage bus type.
281 *
282 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
283 * version of this method.
284 *
285 * @returns Pointer to a read only string.
286 * @param aBus The storage bus type.
287 */
288 static const char *stringifyStorageBus(StorageBus_T aBus);
289
290 /**
[46775]291 * Stringify a reason.
292 *
[93410]293 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
294 * version of this method.
295 *
[46775]296 * @returns Pointer to a read only string.
297 * @param aReason The reason code.
298 */
299 static const char *stringifyReason(Reason_T aReason);
[93410]300#endif
[46775]301
302 /**
[24618]303 * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
304 *
305 * @returns VBox status code.
306 * @param aComStatus COM status code.
307 */
308 static int vboxStatusCodeFromCOM(HRESULT aComStatus);
309
310 /**
311 * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
312 *
[33540]313 * This is mainly intended for dealing with vboxStatusCodeFromCOM() return
[24618]314 * values. If used on anything else, it won't be able to cope with most of the
315 * input!
316 *
317 * @returns COM status code.
318 * @param aVBoxStatus VBox status code.
319 */
320 static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
[9360]321};
322
[76562]323#endif /* !MAIN_INCLUDED_Global_h */
[14949]324/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use