Changeset View
Changeset View
Standalone View
Standalone View
x11/kde4-workspace/files/patch-usbview
Use libusb-1 to query info about usb devices on all platforms, leave old | Use libusb-1 to query info about usb devices on all platforms, leave old | ||||
method as a fallback for Linux only. | method as a fallback for Linux only. | ||||
Remove *BSD specific code, it doesn't work on FreeBSD 8.x and greater. | Remove *BSD specific code, it doesn't work on FreeBSD 8.x and greater. | ||||
Old code probably works on NetBSD, but let it use libusb-1 as well. | Old code probably works on NetBSD, but let it use libusb-1 as well. | ||||
Use DeviceNotifier instead of polling. | Use DeviceNotifier instead of polling. | ||||
--- /dev/null | --- cmake/modules/FindLibUSB1.cmake.orig 2016-12-13 11:26:31 UTC | ||||
+++ cmake/modules/FindLibUSB1.cmake | +++ cmake/modules/FindLibUSB1.cmake | ||||
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||||
+# - Try to find libusb v1.0 library | +# - Try to find libusb v1.0 library | ||||
+# Once done this defines | +# Once done this defines | ||||
+# | +# | ||||
+# LIBUSB1_FOUND - system has libusb | +# LIBUSB1_FOUND - system has libusb | ||||
+# LIBUSB1_INCLUDE_DIR - libusb include directory | +# LIBUSB1_INCLUDE_DIR - libusb include directory | ||||
+# LIBUSB1_LIBRARY - libusb library | +# LIBUSB1_LIBRARY - libusb library | ||||
+ | + | ||||
+find_package(PkgConfig) | +find_package(PkgConfig) | ||||
+pkg_check_modules(PC_LIBUSB1 QUIET libusb-1.0) | +pkg_check_modules(PC_LIBUSB1 QUIET libusb-1.0) | ||||
+ | + | ||||
+find_path(LIBUSB1_INCLUDE_DIR libusb.h | +find_path(LIBUSB1_INCLUDE_DIR libusb.h | ||||
+ HINTS ${PC_LIBUSB1_INCLUDEDIR} ${PC_LIBUSB1_INCLUDE_DIRS}) | + HINTS ${PC_LIBUSB1_INCLUDEDIR} ${PC_LIBUSB1_INCLUDE_DIRS}) | ||||
+ | + | ||||
+# On FreeBSD libusb provides both v0.1 and v1.0 API | +# On FreeBSD libusb provides both v0.1 and v1.0 API | ||||
+find_library(LIBUSB1_LIBRARY NAMES usb-1.0 usb | +find_library(LIBUSB1_LIBRARY NAMES usb-1.0 usb | ||||
+ HINTS ${PC_LIBUSB1_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS}) | + HINTS ${PC_LIBUSB1_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS}) | ||||
+ | + | ||||
+include(FindPackageHandleStandardArgs) | +include(FindPackageHandleStandardArgs) | ||||
+find_package_handle_standard_args(LIBUSB1 DEFAULT_MSG LIBUSB1_LIBRARY LIBUSB1_INCLUDE_DIR) | +find_package_handle_standard_args(LIBUSB1 DEFAULT_MSG LIBUSB1_LIBRARY LIBUSB1_INCLUDE_DIR) | ||||
+ | + | ||||
+mark_as_advanced(LIBUSB1_INCLUDE_DIR LIBUSB1_LIBRARY) | +mark_as_advanced(LIBUSB1_INCLUDE_DIR LIBUSB1_LIBRARY) | ||||
--- kinfocenter/Modules/usbview/CMakeLists.txt | --- kinfocenter/Modules/usbview/CMakeLists.txt.orig 2015-06-26 03:17:21 UTC | ||||
+++ kinfocenter/Modules/usbview/CMakeLists.txt | +++ kinfocenter/Modules/usbview/CMakeLists.txt | ||||
@@ -1,15 +1,25 @@ | @@ -1,15 +1,25 @@ | ||||
+macro_optional_find_package(LibUSB1) | +macro_optional_find_package(LibUSB1) | ||||
+macro_bool_to_01(LIBUSB1_FOUND HAVE_LIBUSB1) | +macro_bool_to_01(LIBUSB1_FOUND HAVE_LIBUSB1) | ||||
+macro_log_feature(LIBUSB1_FOUND "libusb-1" "User level access to USB devices" "http://libusb.sourceforge.net/" FALSE "" "Provides usb info support in KControl.") | +macro_log_feature(LIBUSB1_FOUND "libusb-1" "User level access to USB devices" "http://libusb.sourceforge.net/" FALSE "" "Provides usb info support in KControl.") | ||||
- | - | ||||
+configure_file (config-kcmusb.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kcmusb.h ) | +configure_file (config-kcmusb.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kcmusb.h ) | ||||
Show All 13 Lines | |||||
-target_link_libraries(kcm_usb ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY}) | -target_link_libraries(kcm_usb ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY}) | ||||
+target_link_libraries(kcm_usb ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} ${QT_QTGUI_LIBRARY}) | +target_link_libraries(kcm_usb ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} ${QT_QTGUI_LIBRARY}) | ||||
+if (LIBUSB1_FOUND) | +if (LIBUSB1_FOUND) | ||||
+ target_link_libraries(kcm_usb ${LIBUSB1_LIBRARY}) | + target_link_libraries(kcm_usb ${LIBUSB1_LIBRARY}) | ||||
+endif (LIBUSB1_FOUND) | +endif (LIBUSB1_FOUND) | ||||
install(TARGETS kcm_usb DESTINATION ${PLUGIN_INSTALL_DIR} ) | install(TARGETS kcm_usb DESTINATION ${PLUGIN_INSTALL_DIR} ) | ||||
--- /dev/null | --- kinfocenter/Modules/usbview/config-kcmusb.h.cmake.orig 2016-12-13 11:26:31 UTC | ||||
+++ kinfocenter/Modules/usbview/config-kcmusb.h.cmake | +++ kinfocenter/Modules/usbview/config-kcmusb.h.cmake | ||||
@@ -0,0 +1,2 @@ | @@ -0,0 +1,2 @@ | ||||
+/* Defined if you have libusb */ | +/* Defined if you have libusb */ | ||||
+#cmakedefine HAVE_LIBUSB1 1 | +#cmakedefine HAVE_LIBUSB1 1 | ||||
--- kinfocenter/Modules/usbview/kcmusb.cpp | --- kinfocenter/Modules/usbview/kcmusb.cpp.orig 2015-06-26 03:17:21 UTC | ||||
+++ kinfocenter/Modules/usbview/kcmusb.cpp | +++ kinfocenter/Modules/usbview/kcmusb.cpp | ||||
@@ -12,7 +12,6 @@ | @@ -12,7 +12,6 @@ | ||||
#include <QLayout> | #include <QLayout> | ||||
#include <QSplitter> | #include <QSplitter> | ||||
#include <QtGui/QTextEdit> | #include <QtGui/QTextEdit> | ||||
-#include <QTimer> | -#include <QTimer> | ||||
#include <QHBoxLayout> | #include <QHBoxLayout> | ||||
#include <QList> | #include <QList> | ||||
#include <QTreeWidget> | #include <QTreeWidget> | ||||
@@ -20,6 +19,7 @@ | @@ -20,6 +19,7 @@ | ||||
#include <kaboutdata.h> | #include <kaboutdata.h> | ||||
#include <kdialog.h> | #include <kdialog.h> | ||||
+#include <solid/devicenotifier.h> | +#include <solid/devicenotifier.h> | ||||
#include <KPluginFactory> | #include <KPluginFactory> | ||||
#include <KPluginLoader> | #include <KPluginLoader> | ||||
@@ -63,11 +63,8 @@ USBViewer::USBViewer(QWidget *parent, const QVariantList &) : | @@ -63,11 +63,8 @@ USBViewer::USBViewer(QWidget *parent, co | ||||
_details = new QTextEdit(splitter); | _details = new QTextEdit(splitter); | ||||
_details->setReadOnly(true); | _details->setReadOnly(true); | ||||
- QTimer *refreshTimer = new QTimer(this); | - QTimer *refreshTimer = new QTimer(this); | ||||
- // 1 sec seems to be a good compromise between latency and polling load. | - // 1 sec seems to be a good compromise between latency and polling load. | ||||
- refreshTimer->start(1000); | - refreshTimer->start(1000); | ||||
- | - | ||||
- connect(refreshTimer, SIGNAL(timeout()), SLOT(refresh())); | - connect(refreshTimer, SIGNAL(timeout()), SLOT(refresh())); | ||||
+ connect(Solid::DeviceNotifier::instance(),SIGNAL(deviceAdded(QString)), SLOT(refresh())); | + connect(Solid::DeviceNotifier::instance(),SIGNAL(deviceAdded(QString)), SLOT(refresh())); | ||||
+ connect(Solid::DeviceNotifier::instance(),SIGNAL(deviceRemoved(const QString)), SLOT(refresh())); | + connect(Solid::DeviceNotifier::instance(),SIGNAL(deviceRemoved(const QString)), SLOT(refresh())); | ||||
connect(_devices, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*))); | connect(_devices, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*))); | ||||
KAboutData *about = new KAboutData(I18N_NOOP("kcmusb"), 0, ki18n("KDE USB Viewer"), | KAboutData *about = new KAboutData(I18N_NOOP("kcmusb"), 0, ki18n("KDE USB Viewer"), | ||||
@@ -113,8 +110,12 @@ static void delete_recursive(QTreeWidgetItem *item, const QMap<int, QTreeWidgetI | @@ -113,8 +110,12 @@ static void delete_recursive(QTreeWidget | ||||
void USBViewer::refresh() { | void USBViewer::refresh() { | ||||
QMap<int, QTreeWidgetItem*> new_items; | QMap<int, QTreeWidgetItem*> new_items; | ||||
+#if defined(HAVE_LIBUSB1) | +#if defined(HAVE_LIBUSB1) | ||||
+ USBDevice::parse(); | + USBDevice::parse(); | ||||
+#else | +#else | ||||
if (!USBDevice::parse("/proc/bus/usb/devices")) | if (!USBDevice::parse("/proc/bus/usb/devices")) | ||||
USBDevice::parseSys("/sys/bus/usb/devices"); | USBDevice::parseSys("/sys/bus/usb/devices"); | ||||
+#endif | +#endif | ||||
int level = 0; | int level = 0; | ||||
bool found = true; | bool found = true; | ||||
--- kinfocenter/Modules/usbview/usbdevices.cpp | --- kinfocenter/Modules/usbview/usbdevices.cpp.orig 2015-06-26 03:17:21 UTC | ||||
+++ kinfocenter/Modules/usbview/usbdevices.cpp | +++ kinfocenter/Modules/usbview/usbdevices.cpp | ||||
@@ -27,9 +27,9 @@ | @@ -27,9 +27,9 @@ | ||||
#include <math.h> | #include <math.h> | ||||
-#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) | -#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) | ||||
-#include <sys/ioctl.h> | -#include <sys/ioctl.h> | ||||
-#include <sys/param.h> | -#include <sys/param.h> | ||||
+#include <config-kcmusb.h> | +#include <config-kcmusb.h> | ||||
+#if defined(HAVE_LIBUSB1) | +#if defined(HAVE_LIBUSB1) | ||||
+#include <libusb.h> | +#include <libusb.h> | ||||
#endif | #endif | ||||
QList<USBDevice*> USBDevice::_devices; | QList<USBDevice*> USBDevice::_devices; | ||||
@@ -48,6 +48,7 @@ USBDevice::~USBDevice() { | @@ -48,6 +48,7 @@ USBDevice::~USBDevice() { | ||||
} | } | ||||
+#if !defined(HAVE_LIBUSB1) | +#if !defined(HAVE_LIBUSB1) | ||||
static QString catFile(QString fname) { | static QString catFile(QString fname) { | ||||
char buffer[256]; | char buffer[256]; | ||||
QString result; | QString result; | ||||
@@ -129,6 +130,7 @@ void USBDevice::parseLine(const QString& line) { | @@ -129,6 +130,7 @@ void USBDevice::parseLine(const QString& | ||||
} else if (line.startsWith("P:")) | } else if (line.startsWith("P:")) | ||||
sscanf(line.toLocal8Bit().data(), "P: Vendor=%x ProdID=%x Rev=%x.%x", &_vendorID, &_prodID, &_revMajor, &_revMinor); | sscanf(line.toLocal8Bit().data(), "P: Vendor=%x ProdID=%x Rev=%x.%x", &_vendorID, &_prodID, &_revMajor, &_revMinor); | ||||
} | } | ||||
+#endif // !defined(HAVE_LIBUSB1) | +#endif // !defined(HAVE_LIBUSB1) | ||||
USBDevice* USBDevice::find(int bus, int device) { | USBDevice* USBDevice::find(int bus, int device) { | ||||
foreach(USBDevice* usbDevice, _devices) { | foreach(USBDevice* usbDevice, _devices) { | ||||
@@ -160,6 +162,10 @@ QString USBDevice::dump() { | @@ -160,6 +162,10 @@ QString USBDevice::dump() { | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | |||||
+ return true; | + return true; | ||||
+} | +} | ||||
+ | + | ||||
+#else // defined(HAVE_LIBUSB1) | +#else // defined(HAVE_LIBUSB1) | ||||
+#if defined(Q_OS_LINUX) | +#if defined(Q_OS_LINUX) | ||||
bool USBDevice::parse(const QString &fname) { | bool USBDevice::parse(const QString &fname) { | ||||
_devices.clear(); | _devices.clear(); | ||||
@@ -290,146 +362,19 @@ bool USBDevice::parseSys(const QString &dname) { | @@ -290,146 +362,19 @@ bool USBDevice::parseSys(const QString & | ||||
return d.count(); | return d.count(); | ||||
} | } | ||||
-#else | -#else | ||||
- | - | ||||
-// Unused by *BSD | -// Unused by *BSD | ||||
-bool USBDevice::parseSys(const QString &fname) | -bool USBDevice::parseSys(const QString &fname) | ||||
-{ | -{ | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | + Q_UNUSED(dname) | ||||
return true; | return true; | ||||
} | } | ||||
-# endif // defined(DISABLE_USBDEVICES_FREEBSD) | -# endif // defined(DISABLE_USBDEVICES_FREEBSD) | ||||
-#endif // !(defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)) | -#endif // !(defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)) | ||||
+#endif // defined(Q_OS_LINUX) | +#endif // defined(Q_OS_LINUX) | ||||
+#endif // defined(HAVE_LIBUSB1) | +#endif // defined(HAVE_LIBUSB1) | ||||
--- kinfocenter/Modules/usbview/usbdevices.h | --- kinfocenter/Modules/usbview/usbdevices.h.orig 2015-06-26 03:17:21 UTC | ||||
+++ kinfocenter/Modules/usbview/usbdevices.h | +++ kinfocenter/Modules/usbview/usbdevices.h | ||||
@@ -14,18 +14,9 @@ | @@ -14,18 +14,9 @@ | ||||
#include <QList> | #include <QList> | ||||
#include <QString> | #include <QString> | ||||
-#if defined(__DragonFly__) | -#if defined(__DragonFly__) | ||||
-#include <bus/usb/usb.h> | -#include <bus/usb/usb.h> | ||||
-#include <QStringList> | -#include <QStringList> | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |