File indexing completed on 2024-05-12 04:01:52
0001 /* 0002 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef SOLID_IFACES_GENERICINTERFACE_H 0008 #define SOLID_IFACES_GENERICINTERFACE_H 0009 0010 #include <QObject> 0011 0012 #include <QMap> 0013 #include <QVariant> 0014 0015 namespace Solid 0016 { 0017 namespace Ifaces 0018 { 0019 /** 0020 * Generic interface to deal with a device. It exposes a set of properties 0021 * and is organized a a key/value set. 0022 * 0023 * Warning: Using this class could expose some backend specific details 0024 * and lead to non portable code. Use it at your own risk, or during 0025 * transitional phases when the provided device interfaces don't 0026 * provide the necessary methods. 0027 */ 0028 class GenericInterface 0029 { 0030 public: 0031 /** 0032 * Destroys a GenericInterface object. 0033 */ 0034 virtual ~GenericInterface(); 0035 0036 /** 0037 * Retrieves the value of a property. 0038 * 0039 * @param key the property name 0040 * @returns the property value or QVariant() if the property doesn't exist 0041 */ 0042 virtual QVariant property(const QString &key) const = 0; 0043 0044 /** 0045 * Retrieves all the properties of this device. 0046 * 0047 * @returns all properties in a map 0048 */ 0049 virtual QMap<QString, QVariant> allProperties() const = 0; 0050 0051 /** 0052 * Tests if a property exist. 0053 * 0054 * @param key the property name 0055 * @returns true if the property exists in this device, false otherwise 0056 */ 0057 virtual bool propertyExists(const QString &key) const = 0; 0058 0059 protected: 0060 // Q_SIGNALS: 0061 /** 0062 * This signal is emitted when a property is changed in the device. 0063 * 0064 * @param changes the map describing the property changes that 0065 * occurred in the device, keys are property name and values 0066 * describe the kind of change done on the device property 0067 * (added/removed/modified), it's one of the type Solid::Device::PropertyChange 0068 */ 0069 virtual void propertyChanged(const QMap<QString, int> &changes) = 0; 0070 0071 /** 0072 * This signal is emitted when an event occurred in the device. 0073 * For example when a button is pressed. 0074 * 0075 * @param condition the condition name 0076 * @param reason a message explaining why the condition has been raised 0077 */ 0078 virtual void conditionRaised(const QString &condition, const QString &reason) = 0; 0079 }; 0080 } 0081 } 0082 0083 Q_DECLARE_INTERFACE(Solid::Ifaces::GenericInterface, "org.kde.Solid.Ifaces.GenericInterface/0.1") 0084 0085 #endif