VirtualBox

Changeset 31652 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Aug 13, 2010 2:17:53 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64789
Message:

re-applied r64780

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/HostHardwareLinux.h

    r31648 r31652  
    109109typedef VBoxMainDriveInfo::DriveInfo DriveInfo;
    110110
     111
     112/** Vector type for the list of interfaces. */
     113#define VECTOR_TYPE       char *
     114#define VECTOR_TYPENAME   USBInterfaceList
     115static inline void USBInterfaceListCleanup(char **ppsz)
     116{
     117    RTStrFree(*ppsz);
     118}
     119#define VECTOR_DESTRUCTOR USBInterfaceListCleanup
     120#include "vector.h"
     121
     122/** Structure describing a host USB device */
     123typedef struct USBDeviceInfo
     124{
     125    /** The device node of the device. */
     126    char *mDevice;
     127    /** The system identifier of the device.  Specific to the probing
     128     * method. */
     129    char *mSysfsPath;
     130    /** Type for the list of interfaces. */
     131    USBInterfaceList mInterfaces;
     132} USBDeviceInfo;
     133
     134
     135/** Destructor. */
     136static inline void USBDevInfoCleanup(USBDeviceInfo *pSelf)
     137{
     138    RTStrFree(pSelf->mDevice);
     139    RTStrFree(pSelf->mSysfsPath);
     140    pSelf->mDevice = pSelf->mSysfsPath = NULL;
     141    USBInterfaceList_cleanup(&pSelf->mInterfaces);
     142}
     143
     144
     145/** Constructor - the strings will be duplicated. */
     146static inline int USBDevInfoInit(USBDeviceInfo *pSelf, const char *aDevice,
     147                                 const char *aSystemID)
     148{
     149    pSelf->mDevice = aDevice ? RTStrDup(aDevice) : NULL;
     150    pSelf->mSysfsPath = aSystemID ? RTStrDup(aSystemID) : NULL;
     151    if (   !USBInterfaceList_init(&pSelf->mInterfaces)
     152        || (aDevice && !pSelf->mDevice) || (aSystemID && ! pSelf->mSysfsPath))
     153    {
     154        USBDevInfoCleanup(pSelf);
     155        return 0;
     156    }
     157    return 1;
     158}
     159
     160
     161/** Vector type holding device information */
     162#define VECTOR_TYPE       USBDeviceInfo
     163#define VECTOR_TYPENAME   USBDeviceInfoList
     164#define VECTOR_DESTRUCTOR USBDevInfoCleanup
     165#include "vector.h"
     166
     167
    111168/**
    112169 * Class for probing and returning information about host USB devices.
     
    114171 * actual probing and use the iterator methods to get the result of the probe.
    115172 */
    116 class VBoxMainUSBDeviceInfo
    117 {
    118 public:
    119     /** Structure describing a host USB device */
    120     struct USBDeviceInfo
    121     {
    122         /** The device node of the device. */
    123         iprt::MiniString mDevice;
    124         /** The system identifier of the device.  Specific to the probing
    125          * method. */
    126         iprt::MiniString mSysfsPath;
    127         /** Type for the list of interfaces. */
    128         typedef std::vector<iprt::MiniString> InterfaceList;
    129         /** The system IDs of the device's interfaces. */
    130         InterfaceList mInterfaces;
    131 
    132         /** Constructors */
    133         USBDeviceInfo(const iprt::MiniString &aDevice,
    134                       const iprt::MiniString &aSystemID)
    135             : mDevice(aDevice),
    136               mSysfsPath(aSystemID)
    137         { }
    138     };
    139 
    140     /** List (resp vector) holding drive information */
    141     typedef std::vector<USBDeviceInfo> DeviceInfoList;
    142 
    143     /**
    144      * Search for host USB devices and rebuild the list, which remains empty
    145      * until the first time this method is called.
    146      * @returns iprt status code
    147      */
    148     int UpdateDevices ();
    149 
    150     /** Get the first element in the list of USB devices. */
    151     DeviceInfoList::const_iterator DevicesBegin()
    152     {
    153         return mDeviceList.begin();
    154     }
    155 
    156     /** Get the last element in the list of USB devices. */
    157     DeviceInfoList::const_iterator DevicesEnd()
    158     {
    159         return mDeviceList.end();
    160     }
    161 
    162 private:
     173typedef struct VBoxMainUSBDeviceInfo
     174{
    163175    /** The list of currently available USB devices */
    164     DeviceInfoList mDeviceList;
    165 };
    166 
    167 /** Convenience typedef. */
    168 typedef VBoxMainUSBDeviceInfo::DeviceInfoList USBDeviceInfoList;
    169 /** Convenience typedef. */
    170 typedef VBoxMainUSBDeviceInfo::USBDeviceInfo USBDeviceInfo;
    171 /** Convenience typedef. */
    172 typedef VBoxMainUSBDeviceInfo::USBDeviceInfo::InterfaceList USBInterfaceList;
     176    USBDeviceInfoList mDeviceList;
     177} VBoxMainUSBDeviceInfo;
     178
     179/** Constructor */
     180static inline int VBoxMainUSBDevInfoInit(VBoxMainUSBDeviceInfo *pSelf)
     181{
     182    return USBDeviceInfoList_init(&pSelf->mDeviceList);
     183}
     184
     185/** Destructor */
     186static inline void VBoxMainUSBDevInfoCleanup(VBoxMainUSBDeviceInfo *pSelf)
     187{
     188    USBDeviceInfoList_cleanup(&pSelf->mDeviceList);
     189}
     190
     191/**
     192 * Search for host USB devices and rebuild the list, which remains empty
     193 * until the first time this method is called.
     194 * @returns iprt status code
     195 */
     196int USBDevInfoUpdateDevices(VBoxMainUSBDeviceInfo *pSelf);
     197
     198
     199/** Get the first element in the list of USB devices. */
     200static inline const USBDeviceInfoList_iterator *USBDevInfoBegin
     201                (VBoxMainUSBDeviceInfo *pSelf)
     202{
     203    return USBDeviceInfoList_begin(&pSelf->mDeviceList);
     204}
     205
     206
     207/** Get the last element in the list of USB devices. */
     208static inline const USBDeviceInfoList_iterator *USBDevInfoEnd
     209                (VBoxMainUSBDeviceInfo *pSelf)
     210{
     211    return USBDeviceInfoList_end(&pSelf->mDeviceList);
     212}
     213
    173214
    174215/** Implementation of the hotplug waiter class below */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette