From bec580f3c5ece606a30bd9897a4fa6eb99e93a8a Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 12 Apr 2021 19:53:50 +0200 Subject: [PATCH] udev: Add a method to get all properties of an UdevDevice It's useful for debugging. --- src/udev.cpp | 15 +++++++++++++++ src/udev.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/udev.cpp b/src/udev.cpp index 395391bf9a..ec5ea70585 100644 --- a/src/udev.cpp +++ b/src/udev.cpp @@ -256,6 +256,21 @@ const char *UdevDevice::property(const char *key) return udev_device_get_property_value(m_device, key); } +QMap UdevDevice::properties() const +{ + QMap r; + if (!m_device) { + return r; + } + + auto it = udev_device_get_properties_list_entry(m_device); + auto current = it; + udev_list_entry_foreach (current, it) { + r.insert(udev_list_entry_get_name(current), udev_list_entry_get_value(current)); + } + return r; +} + bool UdevDevice::hasProperty(const char *key, const char *value) { const char *p = property(key); diff --git a/src/udev.h b/src/udev.h index 777a27c9f7..7cbbe57f19 100644 --- a/src/udev.h +++ b/src/udev.h @@ -34,6 +34,8 @@ public: const char *property(const char *key); bool hasProperty(const char *key, const char *value); + QMap properties() const; + operator udev_device*() const { return m_device; }