1
/* This file is part of the KDE project
2
Copyright (C) 2005 Kevin Ottens <ervin@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License version 2 as published by the Free Software Foundation.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
20
#ifndef SOLID_IFACES_DEVICE_H
21
#define SOLID_IFACES_DEVICE_H
28
#include <kdelibs_export.h>
30
#include <solid/capability.h>
31
#include <solid/device.h>
38
* This class specifies the interface a device will have to comply to in order to be used in the system.
40
* Backends will have to implement it to gather and modify data in the underlying system.
41
* Each device has a set of key/values pair describing its properties. It has also a list of capabilities
42
* describing what the device actually is (a cdrom drive, a portable media player, etc.)
44
* @author Kevin Ottens <ervin@kde.org>
46
class SOLIDIFACES_EXPORT Device : public QObject
54
Device( QObject *parent = 0 );
56
* Destruct the Device object
62
* Retrieves the Universal Device Identifier (UDI) of the Device.
63
* This identifier is unique for each device in the system.
65
* @returns the Universal Device Identifier of the current device
67
virtual QString udi() const = 0;
70
* Retrieves the Universal Device Identifier (UDI) of the Device's
73
* @returns the Universal Device Identifier of the parent device
75
virtual QString parentUdi() const;
79
* Retrieves the name of the device vendor.
81
* @return the vendor name
83
virtual QString vendor() const = 0;
86
* Retrieves the name of the product corresponding to this device.
88
* @return the product name
90
virtual QString product() const = 0;
94
* Changes the value of a property.
96
* @param key the property name
97
* @param value the new value of this property
98
* @returns true if the operation succeeded, false otherwise
100
virtual bool setProperty( const QString &key, const QVariant &value );
103
* Retrieves the value of a property.
105
* @param key the property name
106
* @returns the property value or QVariant() if the property doesn't exist
108
virtual QVariant property( const QString &key ) const = 0;
111
* Retrieves all the properties of this device.
113
* @returns all properties in a map
115
virtual QMap<QString, QVariant> allProperties() const = 0;
118
* Removes a property.
120
* @param key the property name
121
* @returns true if the operation succeeded, false otherwise
123
virtual bool removeProperty( const QString &key );
126
* Tests if a property exist.
128
* @param key the property name
129
* @returns true if the property exists in this device, false otherwise
131
virtual bool propertyExists( const QString &key ) const = 0;
134
* Adds a capability to this device.
136
* @param capability the capability type
137
* @returns true if the operation succeeded, false otherwise
139
virtual bool addCapability( const Solid::Capability::Type &capability );
142
* Tests if a property exist.
144
* @param capability the capability type
145
* @returns true if the capability is provided by this device, false otherwise
147
virtual bool queryCapability( const Solid::Capability::Type &capability ) const = 0;
150
* Create a specialized interface to interact with the device corresponding to
151
* a particular capability.
153
* @param capability the capability type
154
* @returns a pointer to the capability interfaces if supported by the device, 0 otherwise
156
virtual QObject *createCapability( const Solid::Capability::Type &capability ) = 0;
159
* Locks a device, giving a reason for such a lock.
160
* A localized version of the provided reason can be displayed to the user.
162
* @param reason a message explaining why we locked the device
163
* @returns true if the operation succeeded, false otherwise
165
virtual bool lock(const QString &reason);
168
* Unlocks a previously locked device.
170
* @returns true if the operation succeeded, false otherwise
172
virtual bool unlock();
175
* Tests if the device is locked.
177
* @return true if the device is locked, false otherwise
179
virtual bool isLocked() const;
182
* Retrieves the reason for a lock.
184
* @return the lock reason if the device is locked, QString() otherwise
186
virtual QString lockReason() const;
190
* This signal is emitted when a property is changed in the device.
192
* @param changes the map describing the property changes that
193
* occurred in the device, keys are property name and values
194
* describe the kind of change done on the device property
195
* (added/removed/modified), it's one of the type Solid::Device::PropertyChange
197
void propertyChanged( const QMap<QString,int> &changes );
200
* This signal is emitted when an event occurred in the device.
201
* For example when a button is pressed.
203
* @param condition the condition name
204
* @param reason a message explaining why the condition has been raised
206
void conditionRaised( const QString &condition, const QString &reason );