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