Changeset 21436 in vbox for trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
- Timestamp:
- Jul 9, 2009 12:24:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
r21432 r21436 54 54 # include <errno.h> 55 55 #endif /* RT_OS_LINUX */ 56 #include <string>57 56 #include <vector> 58 57 … … 94 93 const char *pszKey, 95 94 const char *pszValue, 96 std::vector< std::string> *pMatches);95 std::vector<iprt::MiniString> *pMatches); 97 96 */ 98 97 static int halGetPropertyStrings (DBusConnection *pConnection, … … 104 103 const char *pszUdi, size_t cProps, 105 104 const char **papszKeys, 106 std::vector< std::string> *pMatches,105 std::vector<iprt::MiniString> *pMatches, 107 106 bool *pfMatches, bool *pfSuccess); 108 107 */ … … 111 110 static int getUSBDeviceInfoFromHal(USBDeviceInfoList *pList, bool *pfSuccess); 112 111 static int getOldUSBDeviceInfoFromHal(USBDeviceInfoList *pList, bool *pfSuccess); 113 static int getUSBInterfacesFromHal(std::vector < std::string> *pList,112 static int getUSBInterfacesFromHal(std::vector <iprt::MiniString> *pList, 114 113 const char *pcszUdi, bool *pfSuccess); 115 114 static DBusHandlerResult dbusFilterFunction (DBusConnection *pConnection, … … 814 813 /** 815 814 * Find the UDIs of hal entries that contain Key=Value property and return the 816 * result on the end of a vector of std::string.815 * result on the end of a vector of iprt::MiniString. 817 816 * @returns iprt status code. If a non-fatal error occurs, we return success 818 817 * but set *pfSuccess to false. … … 820 819 * @param pszKey the property key 821 820 * @param pszValue the property value 822 * @param pMatches pointer to an array of std::string to append the821 * @param pMatches pointer to an array of iprt::MiniString to append the 823 822 * results to. NOT optional. 824 823 * @param pfSuccess will be set to true if the operation succeeds … … 827 826 int halFindDeviceStringMatchVector (DBusConnection *pConnection, 828 827 const char *pszKey, const char *pszValue, 829 std::vector< std::string> *pMatches,828 std::vector<iprt::MiniString> *pMatches, 830 829 bool *pfSuccess) 831 830 { … … 985 984 * @param cProps the number of property values to look up 986 985 * @param papszKeys the keys of the properties to be looked up 987 * @param pMatches pointer to an empty array of std::string to append the986 * @param pMatches pointer to an empty array of iprt::MiniString to append the 988 987 * results to. NOT optional. 989 988 * @param pfMatches pointer to an array of boolean values indicating … … 997 996 const char *pszUdi, size_t cProps, 998 997 const char **papszKeys, 999 std::vector< std::string> *pMatches,998 std::vector<iprt::MiniString> *pMatches, 1000 999 bool *pfMatches, bool *pfSuccess) 1001 1000 { … … 1070 1069 DBusMessageIter iterFind, iterUdis; 1071 1070 1072 rc = halInit (&dbusConnection); 1073 if (!dbusConnection) 1074 halSuccess = false; 1075 if (halSuccess && RT_SUCCESS (rc)) 1076 { 1077 rc = halFindDeviceStringMatch (dbusConnection.get(), "storage.drive_type", 1078 isDVD ? "cdrom" : "floppy", &replyFind); 1079 if (!replyFind) 1071 try 1072 { 1073 rc = halInit (&dbusConnection); 1074 if (!dbusConnection) 1080 1075 halSuccess = false; 1081 }1082 if (halSuccess && RT_SUCCESS (rc))1083 {1084 dbus_message_iter_init (replyFind.get(), &iterFind);1085 if (dbus_message_iter_get_arg_type (&iterFind) != DBUS_TYPE_ARRAY)1086 halSuccess = false;1087 }1088 if (halSuccess && RT_SUCCESS (rc))1089 dbus_message_iter_recurse (&iterFind, &iterUdis);1090 for (; halSuccess && RT_SUCCESS (rc)1091 && dbus_message_iter_get_arg_type (&iterUdis) == DBUS_TYPE_STRING;1092 dbus_message_iter_next(&iterUdis))1093 {1094 /* Now get all properties from the iterator */1095 const char *pszUdi;1096 dbus_message_iter_get_basic (&iterUdis, &pszUdi);1097 static const char *papszKeys[] =1098 { "block.device", "info.product", "info.vendor" };1099 char *papszValues[RT_ELEMENTS (papszKeys)];1100 rc = halGetPropertyStrings (dbusConnection.get(), pszUdi, RT_ELEMENTS (papszKeys),1101 papszKeys, papszValues, &replyGet);1102 std::string description;1103 const char *pszDevice = papszValues[0], *pszProduct = papszValues[1],1104 *pszVendor = papszValues[2];1105 if (!!replyGet && pszDevice == NULL)1106 halSuccess = false;1107 if (!!replyGet && pszDevice != NULL)1108 {1109 if ((pszVendor != NULL) && (pszVendor[0] != '\0'))1110 (description += pszVendor) += " ";1111 if ( (pszProduct != NULL && pszProduct[0] != '\0'))1112 description += pszProduct;1113 try1076 if (halSuccess && RT_SUCCESS (rc)) 1077 { 1078 rc = halFindDeviceStringMatch (dbusConnection.get(), "storage.drive_type", 1079 isDVD ? "cdrom" : "floppy", &replyFind); 1080 if (!replyFind) 1081 halSuccess = false; 1082 } 1083 if (halSuccess && RT_SUCCESS (rc)) 1084 { 1085 dbus_message_iter_init (replyFind.get(), &iterFind); 1086 if (dbus_message_iter_get_arg_type (&iterFind) != DBUS_TYPE_ARRAY) 1087 halSuccess = false; 1088 } 1089 if (halSuccess && RT_SUCCESS (rc)) 1090 dbus_message_iter_recurse (&iterFind, &iterUdis); 1091 for (; halSuccess && RT_SUCCESS (rc) 1092 && dbus_message_iter_get_arg_type (&iterUdis) == DBUS_TYPE_STRING; 1093 dbus_message_iter_next(&iterUdis)) 1094 { 1095 /* Now get all properties from the iterator */ 1096 const char *pszUdi; 1097 dbus_message_iter_get_basic (&iterUdis, &pszUdi); 1098 static const char *papszKeys[] = 1099 { "block.device", "info.product", "info.vendor" }; 1100 char *papszValues[RT_ELEMENTS (papszKeys)]; 1101 rc = halGetPropertyStrings (dbusConnection.get(), pszUdi, RT_ELEMENTS (papszKeys), 1102 papszKeys, papszValues, &replyGet); 1103 iprt::MiniString description; 1104 const char *pszDevice = papszValues[0], *pszProduct = papszValues[1], 1105 *pszVendor = papszValues[2]; 1106 if (!!replyGet && pszDevice == NULL) 1107 halSuccess = false; 1108 if (!!replyGet && pszDevice != NULL) 1114 1109 { 1110 if ((pszVendor != NULL) && (pszVendor[0] != '\0')) 1111 { 1112 description.append(pszVendor); 1113 description.append(" "); 1114 } 1115 if ((pszProduct != NULL && pszProduct[0] != '\0')) 1116 description.append(pszProduct); 1115 1117 pList->push_back (DriveInfo (pszDevice, pszUdi, description)); 1116 1118 } 1117 catch(std::bad_alloc &e) 1118 { 1119 rc = VERR_NO_MEMORY; 1120 } 1121 } 1122 } 1123 if (dbusError.HasName (DBUS_ERROR_NO_MEMORY)) 1119 } 1120 if (dbusError.HasName (DBUS_ERROR_NO_MEMORY)) 1121 rc = VERR_NO_MEMORY; 1122 if (pfSuccess != NULL) 1123 *pfSuccess = halSuccess; 1124 } 1125 catch(std::bad_alloc &e) 1126 { 1124 1127 rc = VERR_NO_MEMORY; 1125 if (pfSuccess != NULL) 1126 *pfSuccess = halSuccess; 1128 } 1127 1129 LogFlow (("rc=%Rrc, halSuccess=%d\n", rc, halSuccess)); 1128 1130 dbusError.FlowLog(); … … 1315 1317 */ 1316 1318 /* static */ 1317 int getUSBInterfacesFromHal(std::vector <std::string> *pList,1319 int getUSBInterfacesFromHal(std::vector<iprt::MiniString> *pList, 1318 1320 const char *pcszUdi, bool *pfSuccess) 1319 1321 {
Note:
See TracChangeset
for help on using the changeset viewer.