From cf27a056b8ebf62ceb4710ba9cbe1ee61ce9d8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 23 Apr 2015 15:07:30 +0200 Subject: [PATCH] [udev] Read property on UdevDevice --- udev.cpp | 17 +++++++++++++++++ udev.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/udev.cpp b/udev.cpp index bb4b20a0fc..2832d69a14 100644 --- a/udev.cpp +++ b/udev.cpp @@ -189,4 +189,21 @@ int UdevDevice::sysNum() const return QByteArray(udev_device_get_sysnum(m_device)).toInt(); } +const char *UdevDevice::property(const char *key) +{ + if (!m_device) { + return nullptr; + } + return udev_device_get_property_value(m_device, key); +} + +bool UdevDevice::hasProperty(const char *key, const char *value) +{ + const char *p = property(key); + if (!p) { + return false; + } + return qstrcmp(p, value) == 0; +} + } diff --git a/udev.h b/udev.h index 6960110ac1..bf165c7de1 100644 --- a/udev.h +++ b/udev.h @@ -37,6 +37,8 @@ public: udev_device *getParentWithSubsystemDevType(const char *subsystem, const char *devtype = nullptr) const; const char *devNode(); int sysNum() const; + const char *property(const char *key); + bool hasProperty(const char *key, const char *value); operator udev_device*() const { return m_device;