| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2009 Benjamin K. Stuhl <bks24@cornell.edu> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 | */ |
| 6 | |
| 7 | #ifndef UDEVQTCLIENT_H |
| 8 | #define UDEVQTCLIENT_H |
| 9 | |
| 10 | #include <QObject> |
| 11 | #include <QString> |
| 12 | #include <QStringList> |
| 13 | #include <QVariant> |
| 14 | |
| 15 | #include "udevqtdevice.h" |
| 16 | |
| 17 | namespace UdevQt |
| 18 | { |
| 19 | class ClientPrivate; |
| 20 | class Client : public QObject |
| 21 | { |
| 22 | Q_OBJECT |
| 23 | |
| 24 | Q_PROPERTY(QStringList watchedSubsystems READ watchedSubsystems WRITE setWatchedSubsystems) |
| 25 | |
| 26 | public: |
| 27 | Client(QObject *parent = nullptr); |
| 28 | Client(const QStringList &subsystemList, QObject *parent = nullptr); |
| 29 | ~Client() override; |
| 30 | |
| 31 | QStringList watchedSubsystems() const; |
| 32 | void setWatchedSubsystems(const QStringList &subsystemList); |
| 33 | |
| 34 | DeviceList allDevices(); |
| 35 | DeviceList devicesByProperty(const QString &property, const QVariant &value); |
| 36 | DeviceList devicesBySubsystem(const QString &subsystem); |
| 37 | /*! |
| 38 | * Returns a list of devices matching any of the given subsystems AND any of the properties. |
| 39 | * |
| 40 | * (subsystem1 || subsystem2 || ...) && (property1 || property2 || ...) |
| 41 | */ |
| 42 | DeviceList devicesBySubsystemsAndProperties(const QStringList &subsystems, const QVariantMap &properties); |
| 43 | Device deviceByDeviceFile(const QString &deviceFile); |
| 44 | Device deviceBySysfsPath(const QString &sysfsPath); |
| 45 | Device deviceBySubsystemAndName(const QString &subsystem, const QString &name); |
| 46 | |
| 47 | Q_SIGNALS: |
| 48 | void deviceAdded(const UdevQt::Device &dev); |
| 49 | void deviceRemoved(const UdevQt::Device &dev); |
| 50 | void deviceChanged(const UdevQt::Device &dev); |
| 51 | void deviceOnlined(const UdevQt::Device &dev); |
| 52 | void deviceOfflined(const UdevQt::Device &dev); |
| 53 | void deviceBound(const UdevQt::Device &dev); |
| 54 | void deviceUnbound(const UdevQt::Device &dev); |
| 55 | |
| 56 | private: |
| 57 | friend class ClientPrivate; |
| 58 | ClientPrivate *d; |
| 59 | }; |
| 60 | |
| 61 | } |
| 62 | |
| 63 | #endif |
| 64 | |