VirtualBox

source: vbox/trunk/src/VBox/Main/include/HostHardwareLinux.h@ 25414

Last change on this file since 25414 was 25349, checked in by vboxsync, 15 years ago

iprt/ministring_cpp.h -> iprt/cpp/ministring.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 6.6 KB
Line 
1/* $Id: HostHardwareLinux.h 25349 2009-12-13 17:23:32Z vboxsync $ */
2/** @file
3 * Classes for handling hardware detection under Linux.
4 *
5 * Please feel free to expand these to work for other systems (Solaris!) or to
6 * add new ones for other systems.
7 */
8
9/*
10 * Copyright (C) 2008-2009 Sun Microsystems, Inc.
11 *
12 * This file is part of VirtualBox Open Source Edition (OSE), as
13 * available from http://www.virtualbox.org. This file is free software;
14 * you can redistribute it and/or modify it under the terms of the GNU
15 * General Public License (GPL) as published by the Free Software
16 * Foundation, in version 2 as it comes in the "COPYING" file of the
17 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21 * Clara, CA 95054 USA or visit http://www.sun.com if you need
22 * additional information or have any questions.
23 */
24
25#ifndef ____H_HOSTHARDWARELINUX
26# define ____H_HOSTHARDWARELINUX
27
28#include <iprt/err.h>
29#include <iprt/cpp/ministring.h>
30#include <vector>
31
32/**
33 * Class for probing and returning information about host DVD and floppy
34 * drives. To use this class, create an instance, call one of the update
35 * methods to do the actual probing and use the iterator methods to get the
36 * result of the probe.
37 */
38class VBoxMainDriveInfo
39{
40public:
41 /** Structure describing a host drive */
42 struct DriveInfo
43 {
44 /** The device node of the drive. */
45 iprt::MiniString mDevice;
46 /** The hal unique device identifier, if available. */
47 iprt::MiniString mUdi;
48 /** A textual description of the drive. */
49 iprt::MiniString mDescription;
50
51 /** Constructors */
52 DriveInfo(const iprt::MiniString &aDevice,
53 const iprt::MiniString &aUdi = "",
54 const iprt::MiniString &aDescription = "")
55 : mDevice(aDevice),
56 mUdi(aUdi),
57 mDescription(aDescription)
58 { }
59 };
60
61 /** List (resp vector) holding drive information */
62 typedef std::vector<DriveInfo> DriveInfoList;
63
64 /**
65 * Search for host floppy drives and rebuild the list, which remains empty
66 * until the first time this method is called.
67 * @returns iprt status code
68 */
69 int updateFloppies();
70
71 /**
72 * Search for host DVD drives and rebuild the list, which remains empty
73 * until the first time this method is called.
74 * @returns iprt status code
75 */
76 int updateDVDs();
77
78 /** Get the first element in the list of floppy drives. */
79 DriveInfoList::const_iterator FloppyBegin()
80 {
81 return mFloppyList.begin();
82 }
83
84 /** Get the last element in the list of floppy drives. */
85 DriveInfoList::const_iterator FloppyEnd()
86 {
87 return mFloppyList.end();
88 }
89
90 /** Get the first element in the list of DVD drives. */
91 DriveInfoList::const_iterator DVDBegin()
92 {
93 return mDVDList.begin();
94 }
95
96 /** Get the last element in the list of DVD drives. */
97 DriveInfoList::const_iterator DVDEnd()
98 {
99 return mDVDList.end();
100 }
101private:
102 /** The list of currently available floppy drives */
103 DriveInfoList mFloppyList;
104 /** The list of currently available DVD drives */
105 DriveInfoList mDVDList;
106};
107
108/** Convenience typedef. */
109typedef VBoxMainDriveInfo::DriveInfoList DriveInfoList;
110/** Convenience typedef. */
111typedef VBoxMainDriveInfo::DriveInfo DriveInfo;
112
113/**
114 * Class for probing and returning information about host USB devices.
115 * To use this class, create an instance, call the update methods to do the
116 * actual probing and use the iterator methods to get the result of the probe.
117 */
118class VBoxMainUSBDeviceInfo
119{
120public:
121 /** Structure describing a host USB device */
122 struct USBDeviceInfo
123 {
124 /** The device node of the device. */
125 iprt::MiniString mDevice;
126 /** The sysfs path of the device. */
127 iprt::MiniString mSysfsPath;
128 /** Type for the list of interfaces. */
129 typedef std::vector<iprt::MiniString> InterfaceList;
130 /** The sysfs paths of the device's interfaces. */
131 InterfaceList mInterfaces;
132
133 /** Constructors */
134 USBDeviceInfo(const iprt::MiniString &aDevice,
135 const iprt::MiniString &aSysfsPath)
136 : mDevice(aDevice),
137 mSysfsPath(aSysfsPath)
138 { }
139 };
140
141 /** List (resp vector) holding drive information */
142 typedef std::vector<USBDeviceInfo> DeviceInfoList;
143
144 /**
145 * Search for host USB devices and rebuild the list, which remains empty
146 * until the first time this method is called.
147 * @returns iprt status code
148 */
149 int UpdateDevices ();
150
151 /** Get the first element in the list of USB devices. */
152 DeviceInfoList::const_iterator DevicesBegin()
153 {
154 return mDeviceList.begin();
155 }
156
157 /** Get the last element in the list of USB devices. */
158 DeviceInfoList::const_iterator DevicesEnd()
159 {
160 return mDeviceList.end();
161 }
162
163private:
164 /** The list of currently available USB devices */
165 DeviceInfoList mDeviceList;
166};
167
168/** Convenience typedef. */
169typedef VBoxMainUSBDeviceInfo::DeviceInfoList USBDeviceInfoList;
170/** Convenience typedef. */
171typedef VBoxMainUSBDeviceInfo::USBDeviceInfo USBDeviceInfo;
172/** Convenience typedef. */
173typedef VBoxMainUSBDeviceInfo::USBDeviceInfo::InterfaceList USBInterfaceList;
174
175/**
176 * Class for waiting for a hotplug event. To use this class, create an
177 * instance and call the @a Wait() method, which blocks until an event or a
178 * user-triggered interruption occurs. Call @a Interrupt() to interrupt the
179 * wait before an event occurs.
180 */
181class VBoxMainHotplugWaiter
182{
183 /** Opaque context struct. */
184 struct Context;
185
186 /** Opaque waiter context. */
187 Context *mContext;
188public:
189 /** Constructor */
190 VBoxMainHotplugWaiter (void);
191 /** Destructor. */
192 ~VBoxMainHotplugWaiter (void);
193 /**
194 * Wait for a hotplug event.
195 *
196 * @returns VINF_SUCCESS if an event occurred or if Interrupt() was called.
197 * @returns VERR_TRY_AGAIN if the wait failed but this might (!) be a
198 * temporary failure.
199 * @returns VERR_NOT_SUPPORTED if the wait failed and will definitely not
200 * succeed if retried.
201 * @returns Possibly other iprt status codes otherwise.
202 * @param cMillies How long to wait for at most.
203 */
204 int Wait (unsigned cMillies);
205 /**
206 * Interrupts an active wait. In the current implementation, the wait
207 * may not return until up to two seconds after calling this method.
208 */
209 void Interrupt (void);
210};
211
212#endif /* ____H_HOSTHARDWARELINUX */
213/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use