1 | /* $Id: UIMediumDefs.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMedium related declarations.
|
---|
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_medium_UIMediumDefs_h
|
---|
29 | #define FEQT_INCLUDED_SRC_medium_UIMediumDefs_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QtGlobal>
|
---|
36 | #include <QString>
|
---|
37 |
|
---|
38 | /* GUI includes: */
|
---|
39 | #include "UILibraryDefs.h"
|
---|
40 |
|
---|
41 | /* COM includes: */
|
---|
42 | #include "KDeviceType.h"
|
---|
43 | #include "KStorageBus.h"
|
---|
44 |
|
---|
45 | /* Forward declarations: */
|
---|
46 | class CVirtualBox;
|
---|
47 |
|
---|
48 |
|
---|
49 | /** Medium formats. */
|
---|
50 | enum UIMediumFormat
|
---|
51 | {
|
---|
52 | UIMediumFormat_VDI,
|
---|
53 | UIMediumFormat_VMDK,
|
---|
54 | UIMediumFormat_VHD,
|
---|
55 | UIMediumFormat_Parallels,
|
---|
56 | UIMediumFormat_QED,
|
---|
57 | UIMediumFormat_QCOW,
|
---|
58 | };
|
---|
59 |
|
---|
60 | /** UIMediumDefs namespace. */
|
---|
61 | namespace UIMediumDefs
|
---|
62 | {
|
---|
63 | /** UIMedium types. */
|
---|
64 | enum UIMediumDeviceType
|
---|
65 | {
|
---|
66 | UIMediumDeviceType_HardDisk,
|
---|
67 | UIMediumDeviceType_DVD,
|
---|
68 | UIMediumDeviceType_Floppy,
|
---|
69 | UIMediumDeviceType_All,
|
---|
70 | UIMediumDeviceType_Invalid
|
---|
71 | };
|
---|
72 |
|
---|
73 | /** Converts global medium type (KDeviceType) to local (UIMediumDeviceType). */
|
---|
74 | SHARED_LIBRARY_STUFF UIMediumDeviceType mediumTypeToLocal(KDeviceType globalType);
|
---|
75 | /** Convert local medium type (UIMediumDeviceType) to global (KDeviceType). */
|
---|
76 | SHARED_LIBRARY_STUFF KDeviceType mediumTypeToGlobal(UIMediumDeviceType localType);
|
---|
77 |
|
---|
78 | /** Returns medium formats which are currently supported by @a comVBox for the given @a enmDeviceType. */
|
---|
79 | QList<QPair<QString, QString> > MediumBackends(const CVirtualBox &comVBox, KDeviceType enmDeviceType);
|
---|
80 | /** Returns which hard disk formats are currently supported by @a comVBox. */
|
---|
81 | QList<QPair<QString, QString> > HDDBackends(const CVirtualBox &comVBox);
|
---|
82 | /** Returns which optical disk formats are currently supported by @a comVBox. */
|
---|
83 | QList<QPair<QString, QString> > DVDBackends(const CVirtualBox &comVBox);
|
---|
84 | /** Returns which floppy disk formats are currently supported by @a comVBox. */
|
---|
85 | QList<QPair<QString, QString> > FloppyBackends(const CVirtualBox &comVBox);
|
---|
86 |
|
---|
87 | /** Returns the first file extension of the list of file extension support for the @a enmDeviceType. */
|
---|
88 | QString getPreferredExtensionForMedium(KDeviceType enmDeviceType);
|
---|
89 | }
|
---|
90 | /* Using this namespace globally: */
|
---|
91 | using namespace UIMediumDefs;
|
---|
92 |
|
---|
93 | /** Medium-target. */
|
---|
94 | struct UIMediumTarget
|
---|
95 | {
|
---|
96 | /** Medium-target types. */
|
---|
97 | enum UIMediumTargetType
|
---|
98 | {
|
---|
99 | UIMediumTargetType_WithID,
|
---|
100 | UIMediumTargetType_WithLocation,
|
---|
101 | UIMediumTargetType_WithFileDialog,
|
---|
102 | UIMediumTargetType_CreateAdHocVISO,
|
---|
103 | UIMediumTargetType_CreateFloppyDisk
|
---|
104 | };
|
---|
105 |
|
---|
106 | /** Medium-target constructor. */
|
---|
107 | UIMediumTarget(const QString &strName = QString(), qint32 iPort = 0, qint32 iDevice = 0,
|
---|
108 | UIMediumDeviceType aMediumType = UIMediumDeviceType_Invalid,
|
---|
109 | UIMediumTargetType aType = UIMediumTargetType_WithID, const QString &strData = QString())
|
---|
110 | : name(strName), port(iPort), device(iDevice)
|
---|
111 | , mediumType(aMediumType)
|
---|
112 | , type(aType), data(strData)
|
---|
113 | {}
|
---|
114 |
|
---|
115 | /** Determines controller name. */
|
---|
116 | QString name;
|
---|
117 | /** Determines controller port. */
|
---|
118 | qint32 port;
|
---|
119 | /** Determines controller device. */
|
---|
120 | qint32 device;
|
---|
121 |
|
---|
122 | /** Determines medium-target medium-type. */
|
---|
123 | UIMediumDeviceType mediumType;
|
---|
124 |
|
---|
125 | /** Determines medium-target type. */
|
---|
126 | UIMediumTargetType type;
|
---|
127 | /** Depending on medium-target type holds <i>ID</i> or <i>location</i>. */
|
---|
128 | QString data;
|
---|
129 | };
|
---|
130 |
|
---|
131 | /** Storage-slot struct. */
|
---|
132 | struct StorageSlot
|
---|
133 | {
|
---|
134 | StorageSlot() : bus(KStorageBus_Null), port(0), device(0) {}
|
---|
135 | StorageSlot(const StorageSlot &other) : bus(other.bus), port(other.port), device(other.device) {}
|
---|
136 | StorageSlot(KStorageBus otherBus, qint32 iPort, qint32 iDevice) : bus(otherBus), port(iPort), device(iDevice) {}
|
---|
137 | StorageSlot& operator=(const StorageSlot &other) { bus = other.bus; port = other.port; device = other.device; return *this; }
|
---|
138 | bool operator==(const StorageSlot &other) const { return bus == other.bus && port == other.port && device == other.device; }
|
---|
139 | bool operator!=(const StorageSlot &other) const { return bus != other.bus || port != other.port || device != other.device; }
|
---|
140 | bool operator<(const StorageSlot &other) const { return (bus < other.bus) ||
|
---|
141 | (bus == other.bus && port < other.port) ||
|
---|
142 | (bus == other.bus && port == other.port && device < other.device); }
|
---|
143 | bool operator>(const StorageSlot &other) const { return (bus > other.bus) ||
|
---|
144 | (bus == other.bus && port > other.port) ||
|
---|
145 | (bus == other.bus && port == other.port && device > other.device); }
|
---|
146 | bool isNull() const { return bus == KStorageBus_Null; }
|
---|
147 | KStorageBus bus; qint32 port; qint32 device;
|
---|
148 | };
|
---|
149 |
|
---|
150 | /** Storage-slot struct extension with exact controller name. */
|
---|
151 | struct ExactStorageSlot : public StorageSlot
|
---|
152 | {
|
---|
153 | ExactStorageSlot(const QString &strController,
|
---|
154 | KStorageBus enmBus, qint32 iPort, qint32 iDevice)
|
---|
155 | : StorageSlot(enmBus, iPort, iDevice)
|
---|
156 | , controller(strController)
|
---|
157 | {}
|
---|
158 | QString controller;
|
---|
159 | };
|
---|
160 |
|
---|
161 | /* Let QMetaType know about our types: */
|
---|
162 | Q_DECLARE_METATYPE(UIMediumDeviceType);
|
---|
163 | Q_DECLARE_METATYPE(UIMediumTarget);
|
---|
164 | Q_DECLARE_METATYPE(StorageSlot);
|
---|
165 |
|
---|
166 | #endif /* !FEQT_INCLUDED_SRC_medium_UIMediumDefs_h */
|
---|