VirtualBox

Ignore:
Timestamp:
Jan 21, 2009 1:55:57 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
41863
Message:

Main: more Linux host USB enumeration adjustments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/linux/HostHardwareLinux.cpp

    r16093 r16137  
    8585                                     const char *pszKey, const char *pszValue,
    8686                                     RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> *pMessage);
    87 static bool dbusMessageIsNonEmptyArray(DBusMessage *pMessage);
    8887static int halGetPropertyStrings (DBusConnection *pConnection,
    8988                                  const char *pszUdi, size_t cKeys,
     
    194193    try
    195194    {
     195        bool halSuccess = false;
    196196        mDeviceList.clear();
    197197#if defined(RT_OS_LINUX)
    198198#ifdef VBOX_WITH_DBUS
    199199        if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing()))
    200             rc = getUSBDeviceInfoFromHal(&mDeviceList, &success);
    201         if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing()))
    202             rc = getOldUSBDeviceInfoFromHal(&mDeviceList, &success);
     200            rc = getUSBDeviceInfoFromHal(&mDeviceList, &halSuccess);
     201        /* Try the old API if the new one *succeeded* as only one of them will
     202         * pick up devices anyway. */
     203        if (RT_SUCCESS (rc) && halSuccess && (!success || testing()))
     204            rc = getOldUSBDeviceInfoFromHal(&mDeviceList, &halSuccess);
     205        if (!success)
     206            success = halSuccess;
    203207#endif /* VBOX_WITH_DBUS defined */
    204208#endif /* RT_OS_LINUX */
     
    740744
    741745/**
    742  * Checks whether a message is a non-empty array or something else.
    743  * @returns true if it is, false otherwise.
    744  */
    745 /* static */
    746 bool dbusMessageIsNonEmptyArray(DBusMessage *pMessage)
    747 {
    748     bool fSuccess = true;
    749     DBusMessageIter iterArray, iterItems;
    750     dbus_message_iter_init (pMessage, &iterArray);
    751     if (dbus_message_iter_get_arg_type (&iterArray) != DBUS_TYPE_ARRAY)
    752         fSuccess = false;
    753     if (fSuccess)
    754         dbus_message_iter_recurse (&iterArray, &iterItems);
    755     if (fSuccess && dbus_message_iter_get_arg_type (&iterItems) == DBUS_TYPE_INVALID)
    756         fSuccess = false;
    757     return fSuccess;
    758 }
    759 
    760 /**
    761746 * Read a set of string properties for a device.  If some of the properties are
    762747 * not of type DBUS_TYPE_STRING then a NULL pointer will be returned for them.
     
    988973        rc = halGetPropertyStrings (dbusConnection.get(), pszUdi, RT_ELEMENTS (papszKeys),
    989974                                    papszKeys, papszValues, &replyGet);
    990         std::string description;
    991975        const char *pszDevice = papszValues[0], *pszSysfsPath = papszValues[1];
    992976        /* Get the interfaces. */
     
    10631047        const char *pszUdi;
    10641048        dbus_message_iter_get_basic (&iterUdis, &pszUdi);
    1065         static const char *papszKeys[] = { "linux.device_file", "linux.sysfs_path",
    1066                                            "info.parent" };
     1049        static const char *papszKeys[] = { "linux.device_file", "info.parent" };
    10671050        char *papszValues[RT_ELEMENTS (papszKeys)];
    10681051        rc = halGetPropertyStrings (dbusConnection.get(), pszUdi, RT_ELEMENTS (papszKeys),
    10691052                                    papszKeys, papszValues, &replyGet);
    1070         std::string description;
    1071         const char *pszDevice = papszValues[0], *pszSysfsPath = papszValues[1],
    1072                    *pszParent = papszValues[2];
     1053        const char *pszDevice = papszValues[0], *pszSysfsPath = papszValues[1];
    10731054        /* Get the interfaces. */
    10741055        if (!!replyGet && pszDevice && pszSysfsPath)
    10751056        {
    10761057            USBDeviceInfo info (pszDevice, pszSysfsPath);
    1077             bool ifaceSuccess = true;  /* If we can't get the interfaces, just
    1078                                         * skip this one device. */           
    1079             rc = getUSBInterfacesFromHal (&info.mInterfaces, pszParent, &ifaceSuccess);
     1058            bool ifaceSuccess = false;  /* If we can't get the interfaces, just
     1059                                         * skip this one device. */           
     1060            rc = getUSBInterfacesFromHal (&info.mInterfaces, pszSysfsPath,
     1061                                          &ifaceSuccess);
    10801062            if (RT_SUCCESS(rc) && halSuccess && ifaceSuccess)
    10811063                pList->push_back (info);
     
    11521134        rc = halGetPropertyStrings (dbusConnection.get(), pszUdi, RT_ELEMENTS (papszKeys),
    11531135                                    papszKeys, papszValues, &replyGet);
    1154         std::string description;
    11551136        const char *pszSysfsPath = papszValues[0], *pszInfoSubsystem = papszValues[1],
    11561137                   *pszLinuxSubsystem = papszValues[2];
Note: See TracChangeset for help on using the changeset viewer.

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