~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to solid/solid/ifaces/device.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
    Copyright (C) 2005 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 Library General Public
 
6
    License version 2 as published by the Free Software Foundation.
 
7
 
 
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.
 
12
 
 
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.
 
17
 
 
18
*/
 
19
 
 
20
#ifndef SOLID_IFACES_DEVICE_H
 
21
#define SOLID_IFACES_DEVICE_H
 
22
 
 
23
#include <QObject>
 
24
#include <QVariant>
 
25
#include <QString>
 
26
#include <QMap>
 
27
 
 
28
#include <kdelibs_export.h>
 
29
 
 
30
#include <solid/capability.h>
 
31
#include <solid/device.h>
 
32
 
 
33
namespace Solid
 
34
{
 
35
namespace Ifaces
 
36
{
 
37
    /**
 
38
     * This class specifies the interface a device will have to comply to in order to be used in the system.
 
39
     *
 
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.)
 
43
     *
 
44
     * @author Kevin Ottens <ervin@kde.org>
 
45
     */
 
46
    class SOLIDIFACES_EXPORT Device : public QObject
 
47
    {
 
48
        Q_OBJECT
 
49
 
 
50
    public:
 
51
        /**
 
52
         * Constructs a Device
 
53
         */
 
54
        Device( QObject *parent = 0 );
 
55
        /**
 
56
         * Destruct the Device object
 
57
         */
 
58
        virtual ~Device();
 
59
 
 
60
 
 
61
        /**
 
62
         * Retrieves the Universal Device Identifier (UDI) of the Device.
 
63
         * This identifier is unique for each device in the system.
 
64
         *
 
65
         * @returns the Universal Device Identifier of the current device
 
66
         */
 
67
        virtual QString udi() const = 0;
 
68
 
 
69
        /**
 
70
         * Retrieves the Universal Device Identifier (UDI) of the Device's
 
71
         * parent.
 
72
         *
 
73
         * @returns the Universal Device Identifier of the parent device
 
74
         */
 
75
        virtual QString parentUdi() const;
 
76
 
 
77
 
 
78
        /**
 
79
         * Retrieves the name of the device vendor.
 
80
         *
 
81
         * @return the vendor name
 
82
         */
 
83
        virtual QString vendor() const = 0;
 
84
 
 
85
        /**
 
86
         * Retrieves the name of the product corresponding to this device.
 
87
         *
 
88
         * @return the product name
 
89
         */
 
90
        virtual QString product() const = 0;
 
91
 
 
92
 
 
93
        /**
 
94
         * Changes the value of a property.
 
95
         *
 
96
         * @param key the property name
 
97
         * @param value the new value of this property
 
98
         * @returns true if the operation succeeded, false otherwise
 
99
         */
 
100
        virtual bool setProperty( const QString &key, const QVariant &value );
 
101
 
 
102
        /**
 
103
         * Retrieves the value of a property.
 
104
         *
 
105
         * @param key the property name
 
106
         * @returns the property value or QVariant() if the property doesn't exist
 
107
         */
 
108
        virtual QVariant property( const QString &key ) const = 0;
 
109
 
 
110
        /**
 
111
         * Retrieves all the properties of this device.
 
112
         *
 
113
         * @returns all properties in a map
 
114
         */
 
115
        virtual QMap<QString, QVariant> allProperties() const = 0;
 
116
 
 
117
        /**
 
118
         * Removes a property.
 
119
         *
 
120
         * @param key the property name
 
121
         * @returns true if the operation succeeded, false otherwise
 
122
         */
 
123
        virtual bool removeProperty( const QString &key );
 
124
 
 
125
        /**
 
126
         * Tests if a property exist.
 
127
         *
 
128
         * @param key the property name
 
129
         * @returns true if the property exists in this device, false otherwise
 
130
         */
 
131
        virtual bool propertyExists( const QString &key ) const = 0;
 
132
 
 
133
        /**
 
134
         * Adds a capability to this device.
 
135
         *
 
136
         * @param capability the capability type
 
137
         * @returns true if the operation succeeded, false otherwise
 
138
         */
 
139
        virtual bool addCapability( const Solid::Capability::Type &capability );
 
140
 
 
141
        /**
 
142
         * Tests if a property exist.
 
143
         *
 
144
         * @param capability the capability type
 
145
         * @returns true if the capability is provided by this device, false otherwise
 
146
         */
 
147
        virtual bool queryCapability( const Solid::Capability::Type &capability ) const = 0;
 
148
 
 
149
        /**
 
150
         * Create a specialized interface to interact with the device corresponding to
 
151
         * a particular capability.
 
152
         *
 
153
         * @param capability the capability type
 
154
         * @returns a pointer to the capability interfaces if supported by the device, 0 otherwise
 
155
         */
 
156
        virtual QObject *createCapability( const Solid::Capability::Type &capability ) = 0;
 
157
 
 
158
        /**
 
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.
 
161
         *
 
162
         * @param reason a message explaining why we locked the device
 
163
         * @returns true if the operation succeeded, false otherwise
 
164
         */
 
165
        virtual bool lock(const QString &reason);
 
166
 
 
167
        /**
 
168
         * Unlocks a previously locked device.
 
169
         *
 
170
         * @returns true if the operation succeeded, false otherwise
 
171
         */
 
172
        virtual bool unlock();
 
173
 
 
174
        /**
 
175
         * Tests if the device is locked.
 
176
         *
 
177
         * @return true if the device is locked, false otherwise
 
178
         */
 
179
        virtual bool isLocked() const;
 
180
 
 
181
        /**
 
182
         * Retrieves the reason for a lock.
 
183
         *
 
184
         * @return the lock reason if the device is locked, QString() otherwise
 
185
         */
 
186
        virtual QString lockReason() const;
 
187
 
 
188
    Q_SIGNALS:
 
189
        /**
 
190
         * This signal is emitted when a property is changed in the device.
 
191
         *
 
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
 
196
         */
 
197
        void propertyChanged( const QMap<QString,int> &changes );
 
198
 
 
199
        /**
 
200
         * This signal is emitted when an event occurred in the device.
 
201
         * For example when a button is pressed.
 
202
         *
 
203
         * @param condition the condition name
 
204
         * @param reason a message explaining why the condition has been raised
 
205
         */
 
206
        void conditionRaised( const QString &condition, const QString &reason );
 
207
    };
 
208
}
 
209
}
 
210
 
 
211
#endif