| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2005 Kevin Ottens <ervin@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 | */ |
| 6 | |
| 7 | #ifndef SOLID_IFACES_DEVICEMANAGER_H |
| 8 | #define SOLID_IFACES_DEVICEMANAGER_H |
| 9 | |
| 10 | #include <QObject> |
| 11 | |
| 12 | #include <QStringList> |
| 13 | |
| 14 | #include <solid/deviceinterface.h> |
| 15 | |
| 16 | namespace Solid |
| 17 | { |
| 18 | namespace Ifaces |
| 19 | { |
| 20 | /** |
| 21 | * This class specifies the interface a backend will have to implement in |
| 22 | * order to be used in the system. |
| 23 | * |
| 24 | * A device manager allows to query the underlying platform to discover the |
| 25 | * available devices. It has also the responsibility to notify when a device |
| 26 | * appears or disappears. |
| 27 | */ |
| 28 | class DeviceManager : public QObject |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | |
| 32 | public: |
| 33 | /** |
| 34 | * Constructs a DeviceManager |
| 35 | */ |
| 36 | DeviceManager(QObject *parent = nullptr); |
| 37 | /** |
| 38 | * Destructs a DeviceManager object |
| 39 | */ |
| 40 | ~DeviceManager() override; |
| 41 | |
| 42 | /** |
| 43 | * Retrieves the prefix used for the UDIs off all the devices |
| 44 | * reported by the device manager |
| 45 | */ |
| 46 | virtual QString udiPrefix() const = 0; |
| 47 | |
| 48 | /** |
| 49 | * Retrieves a set of interfaces the backend supports |
| 50 | */ |
| 51 | virtual QSet<Solid::DeviceInterface::Type> supportedInterfaces() const = 0; |
| 52 | |
| 53 | /** |
| 54 | * Retrieves the Universal Device Identifier (UDI) of all the devices |
| 55 | * available in the system. This identifier is unique for each device |
| 56 | * in the system. |
| 57 | * |
| 58 | * @returns the UDIs of all the devices in the system |
| 59 | */ |
| 60 | virtual QStringList allDevices() = 0; |
| 61 | |
| 62 | /** |
| 63 | * Retrieves the Universal Device Identifier (UDI) of all the devices |
| 64 | * matching the given constraints (parent and device interface) |
| 65 | * |
| 66 | * @param parentUdi UDI of the parent of the devices we're searching for, or QString() |
| 67 | * if there's no constraint on the parent |
| 68 | * @param type DeviceInterface type available on the devices we're looking for, or DeviceInterface::Unknown |
| 69 | * if there's no constraint on the device interfaces |
| 70 | * @returns the UDIs of all the devices having the given parent and device interface |
| 71 | */ |
| 72 | virtual QStringList devicesFromQuery(const QString &parentUdi, Solid::DeviceInterface::Type type = Solid::DeviceInterface::Unknown) = 0; |
| 73 | |
| 74 | /** |
| 75 | * Instantiates a new Device object from this backend given its UDI. |
| 76 | * |
| 77 | * @param udi the identifier of the device instantiated |
| 78 | * @returns a new Device object if there's a device having the given UDI, nullptr otherwise |
| 79 | */ |
| 80 | virtual std::unique_ptr<QObject> createDevice(const QString &udi) = 0; |
| 81 | |
| 82 | Q_SIGNALS: |
| 83 | /** |
| 84 | * This signal is emitted when a new device appears in the system. |
| 85 | * |
| 86 | * @param udi the new device identifier |
| 87 | */ |
| 88 | void deviceAdded(const QString &udi); |
| 89 | |
| 90 | /** |
| 91 | * This signal is emitted when a device disappears from the system. |
| 92 | * |
| 93 | * @param udi the old device identifier |
| 94 | */ |
| 95 | void deviceRemoved(const QString &udi); |
| 96 | }; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | #endif |
| 101 | |