|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QHALSERVICE_H |
|
43 #define QHALSERVICE_H |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 |
|
56 #include <qmobilityglobal.h> |
|
57 |
|
58 #include <QtDBus/QtDBus> |
|
59 #include <QtDBus/QDBusConnection> |
|
60 #include <QtDBus/QDBusError> |
|
61 #include <QtDBus/QDBusInterface> |
|
62 #include <QtDBus/QDBusMessage> |
|
63 #include <QtDBus/QDBusReply> |
|
64 #include <QtDBus/QDBusPendingCallWatcher> |
|
65 |
|
66 #include <QVariantList> |
|
67 |
|
68 #define HAL_DBUS_SERVICE "org.freedesktop.Hal" |
|
69 |
|
70 #define HAL_DBUS_PATH "/org/freedesktop/Hal" |
|
71 #define HAL_DBUS_INTERFACE "org.freedesktop.Hal" |
|
72 |
|
73 #define HAL_DBUS_MANAGER_PATH "/org/freedesktop/Hal/Manager" |
|
74 #define HAL_DBUS_MANAGER_INTERFACE "org.freedesktop.Hal.Manager" |
|
75 |
|
76 #define HAL_DEVICE_PATH "/org/freedesktop/Hal/Device" |
|
77 #define HAL_DEVICE_INTERFACE "org.freedesktop.Hal.Device" |
|
78 |
|
79 #define HAL_DEVICES_PATH "/org/freedesktop/Hal/devices" |
|
80 |
|
81 #define HAL_DEVICES_LAPTOPPANEL_INTERFACE "org.freedesktop.Hal.Device.LaptopPanel" |
|
82 #define HAL_DEVICE_KILLSWITCH_INTERFACE "org.freedesktop.Hal.Device.KillSwitch" |
|
83 |
|
84 QTM_BEGIN_NAMESPACE |
|
85 |
|
86 typedef struct halProp { |
|
87 QString propertyName; |
|
88 bool added; |
|
89 bool removed; |
|
90 } HalProperty; |
|
91 |
|
92 typedef QList<HalProperty> QHalPropertyList; |
|
93 |
|
94 QTM_END_NAMESPACE |
|
95 |
|
96 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QHalPropertyList)) |
|
97 |
|
98 QTM_BEGIN_NAMESPACE |
|
99 |
|
100 class QHalInterfacePrivate; |
|
101 class QHalInterface : public QObject |
|
102 { |
|
103 Q_OBJECT |
|
104 |
|
105 public: |
|
106 |
|
107 QHalInterface(QObject *parent = 0); |
|
108 ~QHalInterface(); |
|
109 |
|
110 bool isValid(); |
|
111 QDBusInterface *connectionInterface() const; |
|
112 QStringList findDeviceByCapability(const QString &cap); |
|
113 QStringList getAllDevices(); |
|
114 bool deviceExists(const QString &path); |
|
115 |
|
116 private Q_SLOTS: |
|
117 private: |
|
118 QHalInterfacePrivate *d; |
|
119 |
|
120 }; |
|
121 |
|
122 class QHalDeviceInterfacePrivate; |
|
123 class QHalDeviceInterface : public QObject |
|
124 { |
|
125 Q_OBJECT |
|
126 |
|
127 public: |
|
128 QHalDeviceInterface(const QString &devicePathName, QObject *parent = 0); |
|
129 ~QHalDeviceInterface(); |
|
130 |
|
131 bool isValid(); |
|
132 bool getPropertyBool(const QString &prop); |
|
133 QString getPropertyString(const QString &prop); |
|
134 QStringList getPropertyStringList(const QString &prop); |
|
135 qint32 getPropertyInt(const QString &prop); |
|
136 |
|
137 bool queryCapability(const QString &cap); |
|
138 bool setConnections(); |
|
139 bool propertyExists(const QString &); |
|
140 |
|
141 Q_SIGNALS: |
|
142 void propertyModified( int, QVariantList); |
|
143 |
|
144 private: |
|
145 QHalDeviceInterfacePrivate *d; |
|
146 |
|
147 }; |
|
148 |
|
149 class QHalDeviceLaptopPanelInterfacePrivate; |
|
150 class QHalDeviceLaptopPanelInterface : public QObject |
|
151 { |
|
152 Q_OBJECT |
|
153 |
|
154 public: |
|
155 QHalDeviceLaptopPanelInterface(const QString &devicePathName, QObject *parent = 0); |
|
156 ~QHalDeviceLaptopPanelInterface(); |
|
157 bool isValid(); |
|
158 public: |
|
159 quint32 getBrightness(); |
|
160 void setBrightness(quint32); |
|
161 |
|
162 private: |
|
163 QHalDeviceLaptopPanelInterfacePrivate *d; |
|
164 }; |
|
165 |
|
166 class QHalDeviceKillSwitchInterfacePrivate; |
|
167 class QHalDeviceKillSwitchInterface : public QObject |
|
168 { |
|
169 Q_OBJECT |
|
170 |
|
171 public: |
|
172 QHalDeviceKillSwitchInterface(const QString &devicePathName, QObject *parent = 0); |
|
173 ~QHalDeviceKillSwitchInterface(); |
|
174 bool isValid(); |
|
175 public: |
|
176 quint32 getPower(); //returns 1 if on |
|
177 |
|
178 private: |
|
179 QHalDeviceKillSwitchInterfacePrivate *d; |
|
180 }; |
|
181 |
|
182 QTM_END_NAMESPACE |
|
183 |
|
184 #endif // |