1 /* 2 SPDX-FileCopyrightText: 2006-2007 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_DEVICEINTERFACE_H 8 #define SOLID_DEVICEINTERFACE_H 9 10 #include <QObject> 11 12 #include <solid/solid_export.h> 13 14 namespace Solid 15 { 16 class Device; 17 class DevicePrivate; 18 class Predicate; 19 class DeviceInterfacePrivate; 20 21 /** 22 * Base class of all the device interfaces. 23 * 24 * A device interface describes what a device can do. A device generally has 25 * a set of device interfaces. 26 */ 27 class SOLID_EXPORT DeviceInterface : public QObject 28 { 29 Q_OBJECT 30 Q_DECLARE_PRIVATE(DeviceInterface) 31 32 public: 33 /** 34 * This enum type defines the type of device interface that a Device can have. 35 * 36 * - Unknown : An undetermined device interface 37 * - Processor : A processor 38 * - Block : A block device 39 * - StorageAccess : A mechanism to access data on a storage device 40 * - StorageDrive : A storage drive 41 * - OpticalDrive : An optical drive (CD-ROM, DVD, ...) 42 * - StorageVolume : A volume 43 * - OpticalDisc : An optical disc 44 * - Camera : A digital camera 45 * - PortableMediaPlayer: A portable media player 46 * - NetworkShare: A network share interface 47 */ 48 enum Type { 49 Unknown = 0, 50 GenericInterface = 1, 51 Processor = 2, 52 Block = 3, 53 StorageAccess = 4, 54 StorageDrive = 5, 55 OpticalDrive = 6, 56 StorageVolume = 7, 57 OpticalDisc = 8, 58 Camera = 9, 59 PortableMediaPlayer = 10, 60 Battery = 12, 61 NetworkShare = 14, 62 Last = 0xffff, 63 }; 64 Q_ENUM(Type) 65 66 /** 67 * Destroys a DeviceInterface object. 68 */ 69 ~DeviceInterface() override; 70 71 /** 72 * Indicates if this device interface is valid. 73 * A device interface is considered valid if the device it is referring is available in the system. 74 * 75 * @return true if this device interface's device is available, false otherwise 76 */ 77 bool isValid() const; 78 79 /** 80 * 81 * @return the class name of the device interface type 82 */ 83 static QString typeToString(Type type); 84 85 /** 86 * 87 * @return the device interface type for the given class name 88 */ 89 static Type stringToType(const QString &type); 90 91 /** 92 * 93 * @return a description suitable to display in the UI of the device interface type 94 * @since 4.4 95 */ 96 static QString typeDescription(Type type); 97 98 protected: 99 /** 100 * @internal 101 * Creates a new DeviceInterface object. 102 * 103 * @param dd the private d member. It will take care of deleting it upon destruction. 104 * @param backendObject the device interface object provided by the backend 105 */ 106 DeviceInterface(DeviceInterfacePrivate &dd, QObject *backendObject); 107 108 DeviceInterfacePrivate *d_ptr; 109 110 private: 111 friend class Device; 112 friend class DevicePrivate; 113 }; 114 } 115 116 #endif 117