1 /* 2 Copyright 2006-2007 Kevin Ottens <ervin@kde.org> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) version 3, or any 8 later version accepted by the membership of KDE e.V. (or its 9 successor approved by the membership of KDE e.V.), which shall 10 act as a proxy defined in Section 6 of version 3 of the license. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with this library. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef SOLID_DEVICEINTERFACE_H 22 #define SOLID_DEVICEINTERFACE_H 23 24 #include <QObject> 25 #if QT_VERSION < 0x050000 26 #include <QBool> 27 #endif 28 29 #include <solid-lite/solid_export.h> 30 31 namespace Solid 32 { 33 class Device; 34 class DevicePrivate; 35 class Predicate; 36 class DeviceInterfacePrivate; 37 38 /** 39 * Base class of all the device interfaces. 40 * 41 * A device interface describes what a device can do. A device generally has 42 * a set of device interfaces. 43 */ 44 class SOLID_EXPORT DeviceInterface : public QObject 45 { 46 Q_OBJECT 47 Q_ENUMS(Type) 48 Q_DECLARE_PRIVATE(DeviceInterface) 49 50 public: 51 /** 52 * This enum type defines the type of device interface that a Device can have. 53 * 54 * - Unknown : An undetermined device interface 55 * - Processor : A processor 56 * - Block : A block device 57 * - StorageAccess : A mechanism to access data on a storage device 58 * - StorageDrive : A storage drive 59 * - OpticalDrive : An optical drive (CD-ROM, DVD, ...) 60 * - StorageVolume : A volume 61 * - OpticalDisc : An optical disc 62 * - Camera : A digital camera 63 * - PortableMediaPlayer: A portable media player 64 * - NetworkInterface: A network interface 65 * - SerialInterface: A serial interface 66 * - SmartCardReader: A smart card reader interface 67 * - NetworkShare: A network share interface 68 */ 69 enum Type { Unknown = 0, GenericInterface = 1, /*Processor = 2, */ 70 Block = 3, StorageAccess = 4, StorageDrive = 5, 71 OpticalDrive = 6, StorageVolume = 7, OpticalDisc = 8, 72 /*Camera = 9, */PortableMediaPlayer = 10, 73 /*NetworkInterface = 11, AcAdapter = 12, Battery = 13, 74 Button = 14, AudioInterface = 15, DvbInterface = 16, Video = 17, 75 SerialInterface = 18, SmartCardReader = 19, InternetGateway = 20, 76 NetworkShare = 21, */ Last = 0xffff }; 77 78 /** 79 * Destroys a DeviceInterface object. 80 */ 81 ~DeviceInterface() override; 82 83 /** 84 * Indicates if this device interface is valid. 85 * A device interface is considered valid if the device it is referring is available in the system. 86 * 87 * @return true if this device interface's device is available, false otherwise 88 */ 89 bool isValid() const; 90 91 /** 92 * 93 * @return the class name of the device interface type 94 */ 95 static QString typeToString(Type type); 96 97 /** 98 * 99 * @return the device interface type for the given class name 100 */ 101 static Type stringToType(const QString &type); 102 103 /** 104 * 105 * @return a description suitable to display in the UI of the device interface type 106 * @since 4.4 107 */ 108 static QString typeDescription(Type type); 109 110 protected: 111 /** 112 * @internal 113 * Creates a new DeviceInterface object. 114 * 115 * @param dd the private d member. It will take care of deleting it upon destruction. 116 * @param backendObject the device interface object provided by the backend 117 */ 118 DeviceInterface(DeviceInterfacePrivate &dd, QObject *backendObject); 119 120 DeviceInterfacePrivate *d_ptr; 121 122 private: 123 friend class Device; 124 friend class DevicePrivate; 125 }; 126 } 127 128 #endif 129