VirtualBox

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

Last change on this file since 14991 was 14991, checked in by vboxsync, 16 years ago

Main: rework the Linux host drive code to use libdbus-1 directly instead of libhal

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.8 KB
Line 
1/* $Id: HostHardwareLinux.h 14991 2008-12-04 15:17:33Z vboxsync $ */
2/** @file
3 * Classes for handling hardware detection under Linux. Please feel free to
4 * expand these to work for other systems (Solaris!) or to add new ones for
5 * other systems.
6 */
7
8/*
9 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#include <iprt/err.h>
25#include <string>
26#include <vector>
27
28/** This should only be enabled when testing. It causes all methods to be used
29 * when probing for drives instead of stopping as soon as one method is
30 * successful. This is a global instead of a define in order to keep the test
31 * code closer to the real code. */
32extern bool g_testHostHardwareLinux;
33
34/**
35 * Class for probing and returning information about host DVD and floppy drives
36 */
37class VBoxMainDriveInfo
38{
39public:
40 /** Structure describing a host drive */
41 struct DriveInfo
42 {
43 /** The device node of the drive. */
44 std::string mDevice;
45 /** The hal unique device identifier, if available. */
46 std::string mUdi;
47 /** A textual description of the drive. */
48 std::string mDescription;
49
50 /** Constructors */
51 DriveInfo (std::string aDevice, std::string aUdi, std::string aDescription)
52 : mDevice (aDevice), mUdi (aUdi), mDescription (aDescription) {}
53 DriveInfo (std::string aDevice, std::string aUdi,
54 const char *aDescription = NULL)
55 : mDevice (aDevice), mUdi (aUdi),
56 mDescription (aDescription != NULL ? aDescription : std::string ()) {}
57 DriveInfo (std::string aDevice, const char *aUdi = NULL,
58 const char *aDescription = NULL)
59 : mDevice (aDevice), mUdi (aUdi != NULL ? aUdi : std::string ()),
60 mDescription (aDescription != NULL ? aDescription : std::string ()) {}
61 };
62
63 /** List (resp vector) holding drive information */
64 typedef std::vector <DriveInfo> DriveInfoList;
65
66 /**
67 * Search for host floppy drives and rebuild the list, which remains empty
68 * until the first time it is called.
69 * @returns iprt status code
70 */
71 int updateFloppies ();
72
73 /**
74 * Search for host DVD drives and rebuild the list, which remains empty
75 * until the first time it is called.
76 * @returns iprt status code
77 */
78 int updateDVDs ();
79
80 /** Get the first element in the list of floppy drives. */
81 DriveInfoList::const_iterator FloppyBegin()
82 {
83 return mFloppyList.begin();
84 }
85
86 /** Get the last element in the list of floppy drives. */
87 DriveInfoList::const_iterator FloppyEnd()
88 {
89 return mFloppyList.end();
90 }
91
92 /** Get the first element in the list of DVD drives. */
93 DriveInfoList::const_iterator DVDBegin()
94 {
95 return mDVDList.begin();
96 }
97
98 /** Get the last element in the list of DVD drives. */
99 DriveInfoList::const_iterator DVDEnd()
100 {
101 return mDVDList.end();
102 }
103private:
104 /** The list of currently available floppy drives */
105 DriveInfoList mFloppyList;
106 /** The list of currently available DVD drives */
107 DriveInfoList mDVDList;
108};
109
110typedef VBoxMainDriveInfo::DriveInfoList DriveInfoList;
111typedef VBoxMainDriveInfo::DriveInfo DriveInfo;
112
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