- Timestamp:
- Jan 20, 2009 8:31:56 AM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/vbox-dbus.h
r16006 r16068 69 69 70 70 #define DBUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" 71 #define DBUS_TYPE_INVALID ((int) '\0') 71 72 #define DBUS_TYPE_STRING ((int) 's') 72 73 #define DBUS_TYPE_ARRAY ((int) 'a') -
trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
r16044 r16068 77 77 #ifdef VBOX_WITH_DBUS 78 78 /* These must be extern to be usable in the RTMemAutoPtr template */ 79 extern void halShutdown (DBusConnection *pConnection);80 extern void halShutdownPrivate (DBusConnection *pConnection);81 82 static int halInit(RTMemAutoPtr <DBusConnection, halShutdown> *pConnection);83 static int halInitPrivate(RTMemAutoPtr <DBusConnection, halShutdownPrivate> *pConnection);79 extern void VBoxHalShutdown (DBusConnection *pConnection); 80 extern void VBoxHalShutdownPrivate (DBusConnection *pConnection); 81 82 static int halInit(RTMemAutoPtr <DBusConnection, VBoxHalShutdown> *pConnection); 83 static int halInitPrivate(RTMemAutoPtr <DBusConnection, VBoxHalShutdownPrivate> *pConnection); 84 84 static int halFindDeviceStringMatch (DBusConnection *pConnection, 85 85 const char *pszKey, const char *pszValue, 86 86 RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> *pMessage); 87 static bool dbusMessageIsNonEmptyArray(DBusMessage *pMessage); 87 88 static int halGetPropertyStrings (DBusConnection *pConnection, 88 89 const char *pszUdi, size_t cKeys, … … 212 213 #if defined RT_OS_LINUX && defined VBOX_WITH_DBUS 213 214 /** The connection to DBus */ 214 RTMemAutoPtr <DBusConnection, halShutdownPrivate> mConnection;215 RTMemAutoPtr <DBusConnection, VBoxHalShutdownPrivate> mConnection; 215 216 /** Semaphore which is set when a device is hotplugged and reset when 216 217 * it is read. */ … … 553 554 */ 554 555 /* static */ 555 int halInit (RTMemAutoPtr <DBusConnection, halShutdown> *pConnection)556 int halInit (RTMemAutoPtr <DBusConnection, VBoxHalShutdown> *pConnection) 556 557 { 557 558 AssertReturn(VALID_PTR (pConnection), VERR_INVALID_POINTER); … … 601 602 */ 602 603 /* static */ 603 int halInitPrivate (RTMemAutoPtr <DBusConnection, halShutdownPrivate> *pConnection)604 int halInitPrivate (RTMemAutoPtr <DBusConnection, VBoxHalShutdownPrivate> *pConnection) 604 605 { 605 606 AssertReturn(VALID_PTR (pConnection), VERR_INVALID_POINTER); … … 643 644 */ 644 645 /* static */ 645 void halShutdown (DBusConnection *pConnection)646 void VBoxHalShutdown (DBusConnection *pConnection) 646 647 { 647 648 AssertReturnVoid(VALID_PTR (pConnection)); … … 665 666 */ 666 667 /* static */ 667 void halShutdownPrivate (DBusConnection *pConnection)668 void VBoxHalShutdownPrivate (DBusConnection *pConnection) 668 669 { 669 670 AssertReturnVoid(VALID_PTR (pConnection)); … … 733 734 dbusError.FlowLog(); 734 735 return rc; 736 } 737 738 /** 739 * Checks whether a message is a non-empty array or something else. 740 * @returns true if it is, false otherwise. 741 */ 742 /* static */ 743 bool dbusMessageIsNonEmptyArray(DBusMessage *pMessage) 744 { 745 bool fSuccess = true; 746 DBusMessageIter iterArray, iterItems; 747 dbus_message_iter_init (pMessage, &iterArray); 748 if (dbus_message_iter_get_arg_type (&iterArray) != DBUS_TYPE_ARRAY) 749 fSuccess = false; 750 if (fSuccess) 751 dbus_message_iter_recurse (&iterArray, &iterItems); 752 if (fSuccess && dbus_message_iter_get_arg_type (&iterItems) == DBUS_TYPE_INVALID) 753 fSuccess = false; 754 return fSuccess; 735 755 } 736 756 … … 852 872 853 873 RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> message, replyFind, replyGet; 854 RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection;874 RTMemAutoPtr <DBusConnection, VBoxHalShutdown> dbusConnection; 855 875 DBusMessageIter iterFind, iterUdis; 856 876 … … 929 949 930 950 RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> message, replyFind, replyGet; 931 RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection;951 RTMemAutoPtr <DBusConnection, VBoxHalShutdown> dbusConnection; 932 952 DBusMessageIter iterFind, iterUdis; 933 953 … … 939 959 rc = halFindDeviceStringMatch (dbusConnection.get(), "info.subsystem", 940 960 "usb_device", &replyFind); 941 if (RT_SUCCESS(rc) && ! replyFind) /* "Old" syntax. */961 if (RT_SUCCESS(rc) && !dbusMessageIsNonEmptyArray (replyFind.get())) /* "Old" syntax. */ 942 962 rc = halFindDeviceStringMatch (dbusConnection.get(), 943 963 "linux.subsystem", "usb_device", … … 1014 1034 1015 1035 RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> message, replyFind, replyGet; 1016 RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection;1036 RTMemAutoPtr <DBusConnection, VBoxHalShutdown> dbusConnection; 1017 1037 DBusMessageIter iterFind, iterUdis; 1018 1038 … … 1043 1063 const char *pszUdi; 1044 1064 dbus_message_iter_get_basic (&iterUdis, &pszUdi); 1045 static const char *papszKeys[] = { "linux.sysfs_path", "info.subsystem" }; 1065 static const char *papszKeys[] = { "linux.sysfs_path", "info.subsystem", 1066 "linux.subsystem" }; 1046 1067 char *papszValues[RT_ELEMENTS (papszKeys)]; 1047 1068 rc = halGetPropertyStrings (dbusConnection.get(), pszUdi, RT_ELEMENTS (papszKeys), 1048 1069 papszKeys, papszValues, &replyGet); 1049 1070 std::string description; 1050 const char *pszSysfsPath = papszValues[0], *pszSubsystem = papszValues[1]; 1071 const char *pszSysfsPath = papszValues[0], *pszInfoSubsystem = papszValues[1], 1072 *pszLinuxSubsystem = papszValues[2]; 1051 1073 if (!replyGet) 1052 1074 halSuccess = false; … … 1054 1076 halSuccess = false; 1055 1077 if ( halSuccess && RT_SUCCESS (rc) 1056 && RTStrCmp (pszSubsystem, "usb_device") != 0) /* Children of buses can also be devices. */ 1078 && RTStrCmp (pszInfoSubsystem, "usb_device") != 0 /* Children of buses can also be devices. */ 1079 && RTStrCmp (pszLinuxSubsystem, "usb_device") != 0) 1057 1080 pList->push_back (pszSysfsPath); 1058 1081 }
Note:
See TracChangeset
for help on using the changeset viewer.