author | sandman <sandman> | 2002-11-20 22:50:41 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-20 22:50:41 (UTC) |
commit | 9cef034e112118ad388b0678cd492d81b1695021 (patch) (unidiff) | |
tree | ac3da27c6ccc31663583a2f223098765f5d2d4a3 | |
parent | 15c598ff6bc390ca0d2b0c82b236b4dd3257bb99 (diff) | |
download | opie-9cef034e112118ad388b0678cd492d81b1695021.zip opie-9cef034e112118ad388b0678cd492d81b1695021.tar.gz opie-9cef034e112118ad388b0678cd492d81b1695021.tar.bz2 |
Reverting back to use system ( "apm --suspend" );, even though I don't
like it. It is needed since a real apm implementation only allows suspends
by uid == 0, which doesn't work with a multi-user Opie.
So making apm SUID root and calling it on suspend is the only option here.
-rw-r--r-- | libopie/odevice.cpp | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 2d2f7db..d8415ad 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,960 +1,950 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <linux/soundcard.h> | 26 | #include <linux/soundcard.h> |
27 | #include <math.h> | 27 | #include <math.h> |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpe/sound.h> | 33 | #include <qpe/sound.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | 36 | ||
37 | #include "odevice.h" | 37 | #include "odevice.h" |
38 | 38 | ||
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | 40 | ||
41 | 41 | ||
42 | // _IO and friends are only defined in kernel headers ... | 42 | // _IO and friends are only defined in kernel headers ... |
43 | 43 | ||
44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
45 | 45 | ||
46 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 46 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
47 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 47 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
48 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 48 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
49 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 49 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
50 | 50 | ||
51 | using namespace Opie; | 51 | using namespace Opie; |
52 | 52 | ||
53 | class ODeviceData { | 53 | class ODeviceData { |
54 | public: | 54 | public: |
55 | bool m_qwsserver; | 55 | bool m_qwsserver; |
56 | 56 | ||
57 | QString m_vendorstr; | 57 | QString m_vendorstr; |
58 | OVendor m_vendor; | 58 | OVendor m_vendor; |
59 | 59 | ||
60 | QString m_modelstr; | 60 | QString m_modelstr; |
61 | OModel m_model; | 61 | OModel m_model; |
62 | 62 | ||
63 | QString m_systemstr; | 63 | QString m_systemstr; |
64 | OSystem m_system; | 64 | OSystem m_system; |
65 | 65 | ||
66 | QString m_sysverstr; | 66 | QString m_sysverstr; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | 69 | ||
70 | class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { | 70 | class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { |
71 | protected: | 71 | protected: |
72 | virtual void init ( ); | 72 | virtual void init ( ); |
73 | 73 | ||
74 | public: | 74 | public: |
75 | virtual bool setSoftSuspend ( bool soft ); | 75 | virtual bool setSoftSuspend ( bool soft ); |
76 | 76 | ||
77 | virtual bool setDisplayBrightness ( int b ); | 77 | virtual bool setDisplayBrightness ( int b ); |
78 | virtual int displayBrightnessResolution ( ) const; | 78 | virtual int displayBrightnessResolution ( ) const; |
79 | 79 | ||
80 | virtual void alarmSound ( ); | 80 | virtual void alarmSound ( ); |
81 | 81 | ||
82 | virtual QValueList <OLed> ledList ( ) const; | 82 | virtual QValueList <OLed> ledList ( ) const; |
83 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 83 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
84 | virtual OLedState ledState ( OLed led ) const; | 84 | virtual OLedState ledState ( OLed led ) const; |
85 | virtual bool setLedState ( OLed led, OLedState st ); | 85 | virtual bool setLedState ( OLed led, OLedState st ); |
86 | 86 | ||
87 | virtual bool hasLightSensor ( ) const; | 87 | virtual bool hasLightSensor ( ) const; |
88 | virtual int readLightSensor ( ); | 88 | virtual int readLightSensor ( ); |
89 | virtual int lightSensorResolution ( ) const; | 89 | virtual int lightSensorResolution ( ) const; |
90 | 90 | ||
91 | //virtual QValueList <int> keyList ( ) const; | 91 | //virtual QValueList <int> keyList ( ) const; |
92 | 92 | ||
93 | protected: | 93 | protected: |
94 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 94 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
95 | virtual void timerEvent ( QTimerEvent *te ); | 95 | virtual void timerEvent ( QTimerEvent *te ); |
96 | 96 | ||
97 | int m_power_timer; | 97 | int m_power_timer; |
98 | 98 | ||
99 | OLedState m_leds [2]; | 99 | OLedState m_leds [2]; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | class Zaurus : public ODevice { | 102 | class Zaurus : public ODevice { |
103 | protected: | 103 | protected: |
104 | virtual void init ( ); | 104 | virtual void init ( ); |
105 | 105 | ||
106 | public: | 106 | public: |
107 | virtual bool setSoftSuspend ( bool soft ); | 107 | virtual bool setSoftSuspend ( bool soft ); |
108 | 108 | ||
109 | virtual bool setDisplayBrightness ( int b ); | 109 | virtual bool setDisplayBrightness ( int b ); |
110 | virtual int displayBrightnessResolution ( ) const; | 110 | virtual int displayBrightnessResolution ( ) const; |
111 | 111 | ||
112 | virtual void alarmSound ( ); | 112 | virtual void alarmSound ( ); |
113 | virtual void keySound ( ); | 113 | virtual void keySound ( ); |
114 | virtual void touchSound ( ); | 114 | virtual void touchSound ( ); |
115 | 115 | ||
116 | virtual QValueList <OLed> ledList ( ) const; | 116 | virtual QValueList <OLed> ledList ( ) const; |
117 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 117 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
118 | virtual OLedState ledState ( OLed led ) const; | 118 | virtual OLedState ledState ( OLed led ) const; |
119 | virtual bool setLedState ( OLed led, OLedState st ); | 119 | virtual bool setLedState ( OLed led, OLedState st ); |
120 | 120 | ||
121 | //virtual QValueList <int> keyList ( ) const; | 121 | //virtual QValueList <int> keyList ( ) const; |
122 | 122 | ||
123 | protected: | 123 | protected: |
124 | virtual void buzzer ( int snd ); | 124 | virtual void buzzer ( int snd ); |
125 | 125 | ||
126 | OLedState m_leds [1]; | 126 | OLedState m_leds [1]; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | 129 | ||
130 | 130 | ||
131 | 131 | ||
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | ODevice *ODevice::inst ( ) | 135 | ODevice *ODevice::inst ( ) |
136 | { | 136 | { |
137 | static ODevice *dev = 0; | 137 | static ODevice *dev = 0; |
138 | 138 | ||
139 | if ( !dev ) { | 139 | if ( !dev ) { |
140 | if ( QFile::exists ( "/proc/hal/model" )) | 140 | if ( QFile::exists ( "/proc/hal/model" )) |
141 | dev = new iPAQ ( ); | 141 | dev = new iPAQ ( ); |
142 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 142 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
143 | dev = new Zaurus ( ); | 143 | dev = new Zaurus ( ); |
144 | else | 144 | else |
145 | dev = new ODevice ( ); | 145 | dev = new ODevice ( ); |
146 | 146 | ||
147 | dev-> init ( ); | 147 | dev-> init ( ); |
148 | } | 148 | } |
149 | return dev; | 149 | return dev; |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | /************************************************** | 153 | /************************************************** |
154 | * | 154 | * |
155 | * common | 155 | * common |
156 | * | 156 | * |
157 | **************************************************/ | 157 | **************************************************/ |
158 | 158 | ||
159 | 159 | ||
160 | ODevice::ODevice ( ) | 160 | ODevice::ODevice ( ) |
161 | { | 161 | { |
162 | d = new ODeviceData; | 162 | d = new ODeviceData; |
163 | 163 | ||
164 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 164 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
165 | 165 | ||
166 | d-> m_modelstr = "Unknown"; | 166 | d-> m_modelstr = "Unknown"; |
167 | d-> m_model = Model_Unknown; | 167 | d-> m_model = Model_Unknown; |
168 | d-> m_vendorstr = "Unkown"; | 168 | d-> m_vendorstr = "Unkown"; |
169 | d-> m_vendor = Vendor_Unknown; | 169 | d-> m_vendor = Vendor_Unknown; |
170 | d-> m_systemstr = "Unkown"; | 170 | d-> m_systemstr = "Unkown"; |
171 | d-> m_system = System_Unknown; | 171 | d-> m_system = System_Unknown; |
172 | d-> m_sysverstr = "0.0"; | 172 | d-> m_sysverstr = "0.0"; |
173 | } | 173 | } |
174 | 174 | ||
175 | void ODevice::init ( ) | 175 | void ODevice::init ( ) |
176 | { | 176 | { |
177 | } | 177 | } |
178 | 178 | ||
179 | ODevice::~ODevice ( ) | 179 | ODevice::~ODevice ( ) |
180 | { | 180 | { |
181 | delete d; | 181 | delete d; |
182 | } | 182 | } |
183 | 183 | ||
184 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 184 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
185 | { | 185 | { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | 188 | ||
189 | //#include <linux/apm_bios.h> | 189 | //#include <linux/apm_bios.h> |
190 | 190 | ||
191 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 191 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
192 | 192 | ||
193 | 193 | ||
194 | bool ODevice::suspend ( ) | 194 | bool ODevice::suspend ( ) |
195 | { | 195 | { |
196 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 196 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
197 | return false; | 197 | return false; |
198 | 198 | ||
199 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 199 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
200 | return false; | 200 | return false; |
201 | 201 | ||
202 | int fd; | ||
203 | bool res = false; | 202 | bool res = false; |
204 | 203 | ||
205 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 204 | struct timeval tvs, tvn; |
206 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 205 | ::gettimeofday ( &tvs, 0 ); |
207 | struct timeval tvs, tvn; | ||
208 | |||
209 | // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped | ||
210 | ::gettimeofday ( &tvs, 0 ); | ||
211 | 206 | ||
212 | ::sync ( ); // flush fs caches | 207 | ::sync ( ); // flush fs caches |
213 | 208 | res = ( ::system ( "apm --suspend" ) == 0 ); | |
214 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending | 209 | |
215 | ::close ( fd ); | 210 | // This is needed because the iPAQ apm implementation is asynchronous and we |
216 | 211 | // can not be sure when exactly the device is really suspended | |
217 | if ( res ) { | 212 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
218 | // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group | 213 | |
219 | 214 | if ( res ) { | |
220 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 215 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
221 | ::usleep ( 200 * 1000 ); | 216 | ::usleep ( 200 * 1000 ); |
222 | ::gettimeofday ( &tvn, 0 ); | 217 | ::gettimeofday ( &tvn, 0 ); |
223 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 218 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
224 | |||
225 | // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group | ||
226 | } | ||
227 | |||
228 | // ::signal ( SIGTSTP, SIG_DFL ); | ||
229 | } | 219 | } |
230 | 220 | ||
231 | return res; | 221 | return res; |
232 | } | 222 | } |
233 | 223 | ||
234 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 224 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
235 | 225 | ||
236 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 226 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
237 | 227 | ||
238 | /* VESA Blanking Levels */ | 228 | /* VESA Blanking Levels */ |
239 | #define VESA_NO_BLANKING 0 | 229 | #define VESA_NO_BLANKING 0 |
240 | #define VESA_VSYNC_SUSPEND 1 | 230 | #define VESA_VSYNC_SUSPEND 1 |
241 | #define VESA_HSYNC_SUSPEND 2 | 231 | #define VESA_HSYNC_SUSPEND 2 |
242 | #define VESA_POWERDOWN 3 | 232 | #define VESA_POWERDOWN 3 |
243 | 233 | ||
244 | 234 | ||
245 | bool ODevice::setDisplayStatus ( bool on ) | 235 | bool ODevice::setDisplayStatus ( bool on ) |
246 | { | 236 | { |
247 | if ( d-> m_model == Model_Unknown ) | 237 | if ( d-> m_model == Model_Unknown ) |
248 | return false; | 238 | return false; |
249 | 239 | ||
250 | bool res = false; | 240 | bool res = false; |
251 | int fd; | 241 | int fd; |
252 | 242 | ||
253 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 243 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
254 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 244 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
255 | ::close ( fd ); | 245 | ::close ( fd ); |
256 | } | 246 | } |
257 | return res; | 247 | return res; |
258 | } | 248 | } |
259 | 249 | ||
260 | bool ODevice::setDisplayBrightness ( int ) | 250 | bool ODevice::setDisplayBrightness ( int ) |
261 | { | 251 | { |
262 | return false; | 252 | return false; |
263 | } | 253 | } |
264 | 254 | ||
265 | int ODevice::displayBrightnessResolution ( ) const | 255 | int ODevice::displayBrightnessResolution ( ) const |
266 | { | 256 | { |
267 | return 16; | 257 | return 16; |
268 | } | 258 | } |
269 | 259 | ||
270 | QString ODevice::vendorString ( ) const | 260 | QString ODevice::vendorString ( ) const |
271 | { | 261 | { |
272 | return d-> m_vendorstr; | 262 | return d-> m_vendorstr; |
273 | } | 263 | } |
274 | 264 | ||
275 | OVendor ODevice::vendor ( ) const | 265 | OVendor ODevice::vendor ( ) const |
276 | { | 266 | { |
277 | return d-> m_vendor; | 267 | return d-> m_vendor; |
278 | } | 268 | } |
279 | 269 | ||
280 | QString ODevice::modelString ( ) const | 270 | QString ODevice::modelString ( ) const |
281 | { | 271 | { |
282 | return d-> m_modelstr; | 272 | return d-> m_modelstr; |
283 | } | 273 | } |
284 | 274 | ||
285 | OModel ODevice::model ( ) const | 275 | OModel ODevice::model ( ) const |
286 | { | 276 | { |
287 | return d-> m_model; | 277 | return d-> m_model; |
288 | } | 278 | } |
289 | 279 | ||
290 | QString ODevice::systemString ( ) const | 280 | QString ODevice::systemString ( ) const |
291 | { | 281 | { |
292 | return d-> m_systemstr; | 282 | return d-> m_systemstr; |
293 | } | 283 | } |
294 | 284 | ||
295 | OSystem ODevice::system ( ) const | 285 | OSystem ODevice::system ( ) const |
296 | { | 286 | { |
297 | return d-> m_system; | 287 | return d-> m_system; |
298 | } | 288 | } |
299 | 289 | ||
300 | QString ODevice::systemVersionString ( ) const | 290 | QString ODevice::systemVersionString ( ) const |
301 | { | 291 | { |
302 | return d-> m_sysverstr; | 292 | return d-> m_sysverstr; |
303 | } | 293 | } |
304 | 294 | ||
305 | void ODevice::alarmSound ( ) | 295 | void ODevice::alarmSound ( ) |
306 | { | 296 | { |
307 | #ifndef QT_NO_SOUND | 297 | #ifndef QT_NO_SOUND |
308 | static Sound snd ( "alarm" ); | 298 | static Sound snd ( "alarm" ); |
309 | 299 | ||
310 | if ( snd. isFinished ( )) | 300 | if ( snd. isFinished ( )) |
311 | snd. play ( ); | 301 | snd. play ( ); |
312 | #endif | 302 | #endif |
313 | } | 303 | } |
314 | 304 | ||
315 | void ODevice::keySound ( ) | 305 | void ODevice::keySound ( ) |
316 | { | 306 | { |
317 | #ifndef QT_NO_SOUND | 307 | #ifndef QT_NO_SOUND |
318 | static Sound snd ( "keysound" ); | 308 | static Sound snd ( "keysound" ); |
319 | 309 | ||
320 | if ( snd. isFinished ( )) | 310 | if ( snd. isFinished ( )) |
321 | snd. play ( ); | 311 | snd. play ( ); |
322 | #endif | 312 | #endif |
323 | } | 313 | } |
324 | 314 | ||
325 | void ODevice::touchSound ( ) | 315 | void ODevice::touchSound ( ) |
326 | { | 316 | { |
327 | 317 | ||
328 | #ifndef QT_NO_SOUND | 318 | #ifndef QT_NO_SOUND |
329 | static Sound snd ( "touchsound" ); | 319 | static Sound snd ( "touchsound" ); |
330 | 320 | ||
331 | if ( snd. isFinished ( )) | 321 | if ( snd. isFinished ( )) |
332 | snd. play ( ); | 322 | snd. play ( ); |
333 | #endif | 323 | #endif |
334 | } | 324 | } |
335 | 325 | ||
336 | 326 | ||
337 | QValueList <OLed> ODevice::ledList ( ) const | 327 | QValueList <OLed> ODevice::ledList ( ) const |
338 | { | 328 | { |
339 | return QValueList <OLed> ( ); | 329 | return QValueList <OLed> ( ); |
340 | } | 330 | } |
341 | 331 | ||
342 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 332 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
343 | { | 333 | { |
344 | return QValueList <OLedState> ( ); | 334 | return QValueList <OLedState> ( ); |
345 | } | 335 | } |
346 | 336 | ||
347 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 337 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
348 | { | 338 | { |
349 | return Led_Off; | 339 | return Led_Off; |
350 | } | 340 | } |
351 | 341 | ||
352 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 342 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
353 | { | 343 | { |
354 | return false; | 344 | return false; |
355 | } | 345 | } |
356 | 346 | ||
357 | bool ODevice::hasLightSensor ( ) const | 347 | bool ODevice::hasLightSensor ( ) const |
358 | { | 348 | { |
359 | return false; | 349 | return false; |
360 | } | 350 | } |
361 | 351 | ||
362 | int ODevice::readLightSensor ( ) | 352 | int ODevice::readLightSensor ( ) |
363 | { | 353 | { |
364 | return -1; | 354 | return -1; |
365 | } | 355 | } |
366 | 356 | ||
367 | int ODevice::lightSensorResolution ( ) const | 357 | int ODevice::lightSensorResolution ( ) const |
368 | { | 358 | { |
369 | return 0; | 359 | return 0; |
370 | } | 360 | } |
371 | 361 | ||
372 | //QValueList <int> ODevice::keyList ( ) const | 362 | //QValueList <int> ODevice::keyList ( ) const |
373 | //{ | 363 | //{ |
374 | //return QValueList <int> ( ); | 364 | //return QValueList <int> ( ); |
375 | //} | 365 | //} |
376 | 366 | ||
377 | 367 | ||
378 | 368 | ||
379 | /************************************************** | 369 | /************************************************** |
380 | * | 370 | * |
381 | * iPAQ | 371 | * iPAQ |
382 | * | 372 | * |
383 | **************************************************/ | 373 | **************************************************/ |
384 | 374 | ||
385 | void iPAQ::init ( ) | 375 | void iPAQ::init ( ) |
386 | { | 376 | { |
387 | d-> m_vendorstr = "HP"; | 377 | d-> m_vendorstr = "HP"; |
388 | d-> m_vendor = Vendor_HP; | 378 | d-> m_vendor = Vendor_HP; |
389 | 379 | ||
390 | QFile f ( "/proc/hal/model" ); | 380 | QFile f ( "/proc/hal/model" ); |
391 | 381 | ||
392 | if ( f. open ( IO_ReadOnly )) { | 382 | if ( f. open ( IO_ReadOnly )) { |
393 | QTextStream ts ( &f ); | 383 | QTextStream ts ( &f ); |
394 | 384 | ||
395 | d-> m_modelstr = "H" + ts. readLine ( ); | 385 | d-> m_modelstr = "H" + ts. readLine ( ); |
396 | 386 | ||
397 | if ( d-> m_modelstr == "H3100" ) | 387 | if ( d-> m_modelstr == "H3100" ) |
398 | d-> m_model = Model_iPAQ_H31xx; | 388 | d-> m_model = Model_iPAQ_H31xx; |
399 | else if ( d-> m_modelstr == "H3600" ) | 389 | else if ( d-> m_modelstr == "H3600" ) |
400 | d-> m_model = Model_iPAQ_H36xx; | 390 | d-> m_model = Model_iPAQ_H36xx; |
401 | else if ( d-> m_modelstr == "H3700" ) | 391 | else if ( d-> m_modelstr == "H3700" ) |
402 | d-> m_model = Model_iPAQ_H37xx; | 392 | d-> m_model = Model_iPAQ_H37xx; |
403 | else if ( d-> m_modelstr == "H3800" ) | 393 | else if ( d-> m_modelstr == "H3800" ) |
404 | d-> m_model = Model_iPAQ_H38xx; | 394 | d-> m_model = Model_iPAQ_H38xx; |
405 | else if ( d-> m_modelstr == "H3900" ) | 395 | else if ( d-> m_modelstr == "H3900" ) |
406 | d-> m_model = Model_iPAQ_H39xx; | 396 | d-> m_model = Model_iPAQ_H39xx; |
407 | else | 397 | else |
408 | d-> m_model = Model_Unknown; | 398 | d-> m_model = Model_Unknown; |
409 | 399 | ||
410 | f. close ( ); | 400 | f. close ( ); |
411 | } | 401 | } |
412 | 402 | ||
413 | f. setName ( "/etc/familiar-version" ); | 403 | f. setName ( "/etc/familiar-version" ); |
414 | if ( f. open ( IO_ReadOnly )) { | 404 | if ( f. open ( IO_ReadOnly )) { |
415 | d-> m_systemstr = "Familiar"; | 405 | d-> m_systemstr = "Familiar"; |
416 | d-> m_system = System_Familiar; | 406 | d-> m_system = System_Familiar; |
417 | 407 | ||
418 | QTextStream ts ( &f ); | 408 | QTextStream ts ( &f ); |
419 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 409 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
420 | 410 | ||
421 | f. close ( ); | 411 | f. close ( ); |
422 | } | 412 | } |
423 | 413 | ||
424 | m_leds [0] = m_leds [1] = Led_Off; | 414 | m_leds [0] = m_leds [1] = Led_Off; |
425 | 415 | ||
426 | m_power_timer = 0; | 416 | m_power_timer = 0; |
427 | 417 | ||
428 | if ( d-> m_qwsserver ) | 418 | if ( d-> m_qwsserver ) |
429 | QWSServer::setKeyboardFilter ( this ); | 419 | QWSServer::setKeyboardFilter ( this ); |
430 | } | 420 | } |
431 | 421 | ||
432 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 422 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
433 | 423 | ||
434 | typedef struct { | 424 | typedef struct { |
435 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 425 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
436 | unsigned char TotalTime; /* Units of 5 seconds */ | 426 | unsigned char TotalTime; /* Units of 5 seconds */ |
437 | unsigned char OnTime; /* units of 100m/s */ | 427 | unsigned char OnTime; /* units of 100m/s */ |
438 | unsigned char OffTime; /* units of 100m/s */ | 428 | unsigned char OffTime; /* units of 100m/s */ |
439 | } LED_IN; | 429 | } LED_IN; |
440 | 430 | ||
441 | typedef struct { | 431 | typedef struct { |
442 | unsigned char mode; | 432 | unsigned char mode; |
443 | unsigned char pwr; | 433 | unsigned char pwr; |
444 | unsigned char brightness; | 434 | unsigned char brightness; |
445 | } FLITE_IN; | 435 | } FLITE_IN; |
446 | 436 | ||
447 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 437 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
448 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 438 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
449 | 439 | ||
450 | 440 | ||
451 | 441 | ||
452 | QValueList <OLed> iPAQ::ledList ( ) const | 442 | QValueList <OLed> iPAQ::ledList ( ) const |
453 | { | 443 | { |
454 | QValueList <OLed> vl; | 444 | QValueList <OLed> vl; |
455 | vl << Led_Power; | 445 | vl << Led_Power; |
456 | 446 | ||
457 | if ( d-> m_model == Model_iPAQ_H38xx ) | 447 | if ( d-> m_model == Model_iPAQ_H38xx ) |
458 | vl << Led_BlueTooth; | 448 | vl << Led_BlueTooth; |
459 | return vl; | 449 | return vl; |
460 | } | 450 | } |
461 | 451 | ||
462 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 452 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
463 | { | 453 | { |
464 | QValueList <OLedState> vl; | 454 | QValueList <OLedState> vl; |
465 | 455 | ||
466 | if ( l == Led_Power ) | 456 | if ( l == Led_Power ) |
467 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 457 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
468 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 458 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
469 | vl << Led_Off; // << Led_On << ??? | 459 | vl << Led_Off; // << Led_On << ??? |
470 | 460 | ||
471 | return vl; | 461 | return vl; |
472 | } | 462 | } |
473 | 463 | ||
474 | OLedState iPAQ::ledState ( OLed l ) const | 464 | OLedState iPAQ::ledState ( OLed l ) const |
475 | { | 465 | { |
476 | switch ( l ) { | 466 | switch ( l ) { |
477 | case Led_Power: | 467 | case Led_Power: |
478 | return m_leds [0]; | 468 | return m_leds [0]; |
479 | case Led_BlueTooth: | 469 | case Led_BlueTooth: |
480 | return m_leds [1]; | 470 | return m_leds [1]; |
481 | default: | 471 | default: |
482 | return Led_Off; | 472 | return Led_Off; |
483 | } | 473 | } |
484 | } | 474 | } |
485 | 475 | ||
486 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 476 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
487 | { | 477 | { |
488 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 478 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
489 | 479 | ||
490 | if ( l == Led_Power ) { | 480 | if ( l == Led_Power ) { |
491 | if ( fd >= 0 ) { | 481 | if ( fd >= 0 ) { |
492 | LED_IN leds; | 482 | LED_IN leds; |
493 | ::memset ( &leds, 0, sizeof( leds )); | 483 | ::memset ( &leds, 0, sizeof( leds )); |
494 | leds. TotalTime = 0; | 484 | leds. TotalTime = 0; |
495 | leds. OnTime = 0; | 485 | leds. OnTime = 0; |
496 | leds. OffTime = 1; | 486 | leds. OffTime = 1; |
497 | leds. OffOnBlink = 2; | 487 | leds. OffOnBlink = 2; |
498 | 488 | ||
499 | switch ( st ) { | 489 | switch ( st ) { |
500 | case Led_Off : leds. OffOnBlink = 0; break; | 490 | case Led_Off : leds. OffOnBlink = 0; break; |
501 | case Led_On : leds. OffOnBlink = 1; break; | 491 | case Led_On : leds. OffOnBlink = 1; break; |
502 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 492 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
503 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 493 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
504 | } | 494 | } |
505 | 495 | ||
506 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 496 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
507 | m_leds [0] = st; | 497 | m_leds [0] = st; |
508 | return true; | 498 | return true; |
509 | } | 499 | } |
510 | } | 500 | } |
511 | } | 501 | } |
512 | return false; | 502 | return false; |
513 | } | 503 | } |
514 | 504 | ||
515 | 505 | ||
516 | //QValueList <int> iPAQ::keyList ( ) const | 506 | //QValueList <int> iPAQ::keyList ( ) const |
517 | //{ | 507 | //{ |
518 | //QValueList <int> vl; | 508 | //QValueList <int> vl; |
519 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; | 509 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; |
520 | //return vl; | 510 | //return vl; |
521 | //} | 511 | //} |
522 | 512 | ||
523 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 513 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
524 | { | 514 | { |
525 | int newkeycode = keycode; | 515 | int newkeycode = keycode; |
526 | 516 | ||
527 | 517 | ||
528 | // simple susbstitutions | 518 | // simple susbstitutions |
529 | switch ( d-> m_model ) { | 519 | switch ( d-> m_model ) { |
530 | case Model_iPAQ_H38xx: | 520 | case Model_iPAQ_H38xx: |
531 | // H38xx has no "Q" key anymore - this is now the Mail key | 521 | // H38xx has no "Q" key anymore - this is now the Mail key |
532 | if ( keycode == HardKey_Menu ) | 522 | if ( keycode == HardKey_Menu ) |
533 | newkeycode = HardKey_Mail; | 523 | newkeycode = HardKey_Mail; |
534 | //nobreak | 524 | //nobreak |
535 | 525 | ||
536 | case Model_iPAQ_H31xx: | 526 | case Model_iPAQ_H31xx: |
537 | // Rotate cursor keys 180° | 527 | // Rotate cursor keys 180° |
538 | switch ( keycode ) { | 528 | switch ( keycode ) { |
539 | case Key_Left : newkeycode = Key_Right; break; | 529 | case Key_Left : newkeycode = Key_Right; break; |
540 | case Key_Right: newkeycode = Key_Left; break; | 530 | case Key_Right: newkeycode = Key_Left; break; |
541 | case Key_Up : newkeycode = Key_Down; break; | 531 | case Key_Up : newkeycode = Key_Down; break; |
542 | case Key_Down : newkeycode = Key_Up; break; | 532 | case Key_Down : newkeycode = Key_Up; break; |
543 | } | 533 | } |
544 | //nobreak; | 534 | //nobreak; |
545 | 535 | ||
546 | case Model_iPAQ_H36xx: | 536 | case Model_iPAQ_H36xx: |
547 | case Model_iPAQ_H37xx: | 537 | case Model_iPAQ_H37xx: |
548 | // map Power Button short/long press to F34/F35 | 538 | // map Power Button short/long press to F34/F35 |
549 | if ( keycode == Key_SysReq ) { | 539 | if ( keycode == Key_SysReq ) { |
550 | if ( isPress ) { | 540 | if ( isPress ) { |
551 | if ( m_power_timer ) | 541 | if ( m_power_timer ) |
552 | killTimer ( m_power_timer ); | 542 | killTimer ( m_power_timer ); |
553 | m_power_timer = startTimer ( 500 ); | 543 | m_power_timer = startTimer ( 500 ); |
554 | } | 544 | } |
555 | else if ( m_power_timer ) { | 545 | else if ( m_power_timer ) { |
556 | killTimer ( m_power_timer ); | 546 | killTimer ( m_power_timer ); |
557 | m_power_timer = 0; | 547 | m_power_timer = 0; |
558 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 548 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
559 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 549 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
560 | } | 550 | } |
561 | newkeycode = Key_unknown; | 551 | newkeycode = Key_unknown; |
562 | } | 552 | } |
563 | //nobreak; | 553 | //nobreak; |
564 | 554 | ||
565 | default: | 555 | default: |
566 | break; | 556 | break; |
567 | } | 557 | } |
568 | 558 | ||
569 | if ( newkeycode != keycode ) { | 559 | if ( newkeycode != keycode ) { |
570 | if ( newkeycode != Key_unknown ) | 560 | if ( newkeycode != Key_unknown ) |
571 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 561 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
572 | return true; | 562 | return true; |
573 | } | 563 | } |
574 | else | 564 | else |
575 | return false; | 565 | return false; |
576 | } | 566 | } |
577 | 567 | ||
578 | void iPAQ::timerEvent ( QTimerEvent * ) | 568 | void iPAQ::timerEvent ( QTimerEvent * ) |
579 | { | 569 | { |
580 | killTimer ( m_power_timer ); | 570 | killTimer ( m_power_timer ); |
581 | m_power_timer = 0; | 571 | m_power_timer = 0; |
582 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 572 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
583 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 573 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
584 | } | 574 | } |
585 | 575 | ||
586 | 576 | ||
587 | void iPAQ::alarmSound ( ) | 577 | void iPAQ::alarmSound ( ) |
588 | { | 578 | { |
589 | #ifndef QT_NO_SOUND | 579 | #ifndef QT_NO_SOUND |
590 | static Sound snd ( "alarm" ); | 580 | static Sound snd ( "alarm" ); |
591 | int fd; | 581 | int fd; |
592 | int vol; | 582 | int vol; |
593 | bool vol_reset = false; | 583 | bool vol_reset = false; |
594 | 584 | ||
595 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 585 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
596 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 586 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
597 | Config cfg ( "qpe" ); | 587 | Config cfg ( "qpe" ); |
598 | cfg. setGroup ( "Volume" ); | 588 | cfg. setGroup ( "Volume" ); |
599 | 589 | ||
600 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 590 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
601 | if ( volalarm < 0 ) | 591 | if ( volalarm < 0 ) |
602 | volalarm = 0; | 592 | volalarm = 0; |
603 | else if ( volalarm > 100 ) | 593 | else if ( volalarm > 100 ) |
604 | volalarm = 100; | 594 | volalarm = 100; |
605 | volalarm |= ( volalarm << 8 ); | 595 | volalarm |= ( volalarm << 8 ); |
606 | 596 | ||
607 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 597 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
608 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 598 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
609 | vol_reset = true; | 599 | vol_reset = true; |
610 | } | 600 | } |
611 | } | 601 | } |
612 | } | 602 | } |
613 | 603 | ||
614 | snd. play ( ); | 604 | snd. play ( ); |
615 | while ( !snd. isFinished ( )) | 605 | while ( !snd. isFinished ( )) |
616 | qApp-> processEvents ( ); | 606 | qApp-> processEvents ( ); |
617 | 607 | ||
618 | if ( fd >= 0 ) { | 608 | if ( fd >= 0 ) { |
619 | if ( vol_reset ) | 609 | if ( vol_reset ) |
620 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 610 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
621 | ::close ( fd ); | 611 | ::close ( fd ); |
622 | } | 612 | } |
623 | #endif | 613 | #endif |
624 | } | 614 | } |
625 | 615 | ||
626 | 616 | ||
627 | bool iPAQ::setSoftSuspend ( bool soft ) | 617 | bool iPAQ::setSoftSuspend ( bool soft ) |
628 | { | 618 | { |
629 | bool res = false; | 619 | bool res = false; |
630 | int fd; | 620 | int fd; |
631 | 621 | ||
632 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 622 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
633 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 623 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
634 | res = true; | 624 | res = true; |
635 | else | 625 | else |
636 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 626 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
637 | 627 | ||
638 | ::close ( fd ); | 628 | ::close ( fd ); |
639 | } | 629 | } |
640 | else | 630 | else |
641 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 631 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
642 | 632 | ||
643 | return res; | 633 | return res; |
644 | } | 634 | } |
645 | 635 | ||
646 | 636 | ||
647 | bool iPAQ::setDisplayBrightness ( int bright ) | 637 | bool iPAQ::setDisplayBrightness ( int bright ) |
648 | { | 638 | { |
649 | bool res = false; | 639 | bool res = false; |
650 | int fd; | 640 | int fd; |
651 | 641 | ||
652 | if ( bright > 255 ) | 642 | if ( bright > 255 ) |
653 | bright = 255; | 643 | bright = 255; |
654 | if ( bright < 0 ) | 644 | if ( bright < 0 ) |
655 | bright = 0; | 645 | bright = 0; |
656 | 646 | ||
657 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 647 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
658 | FLITE_IN bl; | 648 | FLITE_IN bl; |
659 | bl. mode = 1; | 649 | bl. mode = 1; |
660 | bl. pwr = bright ? 1 : 0; | 650 | bl. pwr = bright ? 1 : 0; |
661 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 651 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
662 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 652 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
663 | ::close ( fd ); | 653 | ::close ( fd ); |
664 | } | 654 | } |
665 | return res; | 655 | return res; |
666 | } | 656 | } |
667 | 657 | ||
668 | int iPAQ::displayBrightnessResolution ( ) const | 658 | int iPAQ::displayBrightnessResolution ( ) const |
669 | { | 659 | { |
670 | switch ( model ( )) { | 660 | switch ( model ( )) { |
671 | case Model_iPAQ_H31xx: | 661 | case Model_iPAQ_H31xx: |
672 | case Model_iPAQ_H36xx: | 662 | case Model_iPAQ_H36xx: |
673 | case Model_iPAQ_H37xx: | 663 | case Model_iPAQ_H37xx: |
674 | return 128; // really 256, but >128 could damage the LCD | 664 | return 128; // really 256, but >128 could damage the LCD |
675 | 665 | ||
676 | case Model_iPAQ_H38xx: | 666 | case Model_iPAQ_H38xx: |
677 | case Model_iPAQ_H39xx: | 667 | case Model_iPAQ_H39xx: |
678 | return 64; | 668 | return 64; |
679 | 669 | ||
680 | default: | 670 | default: |
681 | return 2; | 671 | return 2; |
682 | } | 672 | } |
683 | } | 673 | } |
684 | 674 | ||
685 | 675 | ||
686 | bool iPAQ::hasLightSensor ( ) const | 676 | bool iPAQ::hasLightSensor ( ) const |
687 | { | 677 | { |
688 | return true; | 678 | return true; |
689 | } | 679 | } |
690 | 680 | ||
691 | int iPAQ::readLightSensor ( ) | 681 | int iPAQ::readLightSensor ( ) |
692 | { | 682 | { |
693 | int fd; | 683 | int fd; |
694 | int val = -1; | 684 | int val = -1; |
695 | 685 | ||
696 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 686 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
697 | char buffer [8]; | 687 | char buffer [8]; |
698 | 688 | ||
699 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 689 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
700 | char *endptr; | 690 | char *endptr; |
701 | 691 | ||
702 | buffer [4] = 0; | 692 | buffer [4] = 0; |
703 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 693 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
704 | 694 | ||
705 | if ( *endptr != 0 ) | 695 | if ( *endptr != 0 ) |
706 | val = -1; | 696 | val = -1; |
707 | } | 697 | } |
708 | ::close ( fd ); | 698 | ::close ( fd ); |
709 | } | 699 | } |
710 | 700 | ||
711 | return val; | 701 | return val; |
712 | } | 702 | } |
713 | 703 | ||
714 | int iPAQ::lightSensorResolution ( ) const | 704 | int iPAQ::lightSensorResolution ( ) const |
715 | { | 705 | { |
716 | return 256; | 706 | return 256; |
717 | } | 707 | } |
718 | 708 | ||
719 | /************************************************** | 709 | /************************************************** |
720 | * | 710 | * |
721 | * Zaurus | 711 | * Zaurus |
722 | * | 712 | * |
723 | **************************************************/ | 713 | **************************************************/ |
724 | 714 | ||
725 | 715 | ||
726 | 716 | ||
727 | void Zaurus::init ( ) | 717 | void Zaurus::init ( ) |
728 | { | 718 | { |
729 | d-> m_modelstr = "Zaurus SL5000"; | 719 | d-> m_modelstr = "Zaurus SL5000"; |
730 | d-> m_model = Model_Zaurus_SL5000; | 720 | d-> m_model = Model_Zaurus_SL5000; |
731 | d-> m_vendorstr = "Sharp"; | 721 | d-> m_vendorstr = "Sharp"; |
732 | d-> m_vendor = Vendor_Sharp; | 722 | d-> m_vendor = Vendor_Sharp; |
733 | 723 | ||
734 | QFile f ( "/proc/filesystems" ); | 724 | QFile f ( "/proc/filesystems" ); |
735 | 725 | ||
736 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 726 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
737 | d-> m_systemstr = "OpenZaurus"; | 727 | d-> m_systemstr = "OpenZaurus"; |
738 | d-> m_system = System_OpenZaurus; | 728 | d-> m_system = System_OpenZaurus; |
739 | 729 | ||
740 | f. close ( ); | 730 | f. close ( ); |
741 | 731 | ||
742 | f. setName ( "/etc/oz_version" ); | 732 | f. setName ( "/etc/oz_version" ); |
743 | if ( f. open ( IO_ReadOnly )) { | 733 | if ( f. open ( IO_ReadOnly )) { |
744 | QTextStream ts ( &f ); | 734 | QTextStream ts ( &f ); |
745 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 735 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
746 | f. close ( ); | 736 | f. close ( ); |
747 | } | 737 | } |
748 | } | 738 | } |
749 | else { | 739 | else { |
750 | d-> m_systemstr = "Zaurus"; | 740 | d-> m_systemstr = "Zaurus"; |
751 | d-> m_system = System_Zaurus; | 741 | d-> m_system = System_Zaurus; |
752 | } | 742 | } |
753 | 743 | ||
754 | 744 | ||
755 | m_leds [0] = Led_Off; | 745 | m_leds [0] = Led_Off; |
756 | } | 746 | } |
757 | 747 | ||
758 | #include <unistd.h> | 748 | #include <unistd.h> |
759 | #include <fcntl.h> | 749 | #include <fcntl.h> |
760 | #include <sys/ioctl.h> | 750 | #include <sys/ioctl.h> |
761 | 751 | ||
762 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 752 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
763 | 753 | ||
764 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 754 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
765 | 755 | ||
766 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 756 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
767 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 757 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
768 | 758 | ||
769 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 759 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
770 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 760 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
771 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 761 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
772 | 762 | ||
773 | /* --- for SHARP_BUZZER device --- */ | 763 | /* --- for SHARP_BUZZER device --- */ |
774 | 764 | ||
775 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 765 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
776 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 766 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
777 | 767 | ||
778 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 768 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
779 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 769 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
780 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 770 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
781 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 771 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
782 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 772 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
783 | 773 | ||
784 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 774 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
785 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 775 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
786 | 776 | ||
787 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 777 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
788 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 778 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
789 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 779 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
790 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 780 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
791 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 781 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
792 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 782 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
793 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 783 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
794 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 784 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
795 | 785 | ||
796 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 786 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
797 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 787 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
798 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 788 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
799 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 789 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
800 | // | 790 | // |
801 | 791 | ||
802 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 792 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
803 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 793 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
804 | 794 | ||
805 | typedef struct sharp_led_status { | 795 | typedef struct sharp_led_status { |
806 | int which; /* select which LED status is wanted. */ | 796 | int which; /* select which LED status is wanted. */ |
807 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 797 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
808 | } sharp_led_status; | 798 | } sharp_led_status; |
809 | 799 | ||
810 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 800 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
811 | 801 | ||
812 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 802 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
813 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 803 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
814 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 804 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
815 | 805 | ||
816 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 806 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
817 | 807 | ||
818 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 808 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
819 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 809 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
820 | #define APM_EVT_POWER_BUTTON (1 << 0) | 810 | #define APM_EVT_POWER_BUTTON (1 << 0) |
821 | 811 | ||
822 | #define FL_IOCTL_STEP_CONTRAST 100 | 812 | #define FL_IOCTL_STEP_CONTRAST 100 |
823 | 813 | ||
824 | 814 | ||
825 | void Zaurus::buzzer ( int sound ) | 815 | void Zaurus::buzzer ( int sound ) |
826 | { | 816 | { |
827 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 817 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
828 | 818 | ||
829 | if ( fd >= 0 ) | 819 | if ( fd >= 0 ) |
830 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 820 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
831 | } | 821 | } |
832 | 822 | ||
833 | 823 | ||
834 | void Zaurus::alarmSound ( ) | 824 | void Zaurus::alarmSound ( ) |
835 | { | 825 | { |
836 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 826 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
837 | } | 827 | } |
838 | 828 | ||
839 | void Zaurus::touchSound ( ) | 829 | void Zaurus::touchSound ( ) |
840 | { | 830 | { |
841 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 831 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
842 | } | 832 | } |
843 | 833 | ||
844 | void Zaurus::keySound ( ) | 834 | void Zaurus::keySound ( ) |
845 | { | 835 | { |
846 | buzzer ( SHARP_BUZ_KEYSOUND ); | 836 | buzzer ( SHARP_BUZ_KEYSOUND ); |
847 | } | 837 | } |
848 | 838 | ||
849 | 839 | ||
850 | QValueList <OLed> Zaurus::ledList ( ) const | 840 | QValueList <OLed> Zaurus::ledList ( ) const |
851 | { | 841 | { |
852 | QValueList <OLed> vl; | 842 | QValueList <OLed> vl; |
853 | vl << Led_Mail; | 843 | vl << Led_Mail; |
854 | return vl; | 844 | return vl; |
855 | } | 845 | } |
856 | 846 | ||
857 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 847 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
858 | { | 848 | { |
859 | QValueList <OLedState> vl; | 849 | QValueList <OLedState> vl; |
860 | 850 | ||
861 | if ( l == Led_Mail ) | 851 | if ( l == Led_Mail ) |
862 | vl << Led_Off << Led_On << Led_BlinkSlow; | 852 | vl << Led_Off << Led_On << Led_BlinkSlow; |
863 | return vl; | 853 | return vl; |
864 | } | 854 | } |
865 | 855 | ||
866 | OLedState Zaurus::ledState ( OLed which ) const | 856 | OLedState Zaurus::ledState ( OLed which ) const |
867 | { | 857 | { |
868 | if ( which == Led_Mail ) | 858 | if ( which == Led_Mail ) |
869 | return m_leds [0]; | 859 | return m_leds [0]; |
870 | else | 860 | else |
871 | return Led_Off; | 861 | return Led_Off; |
872 | } | 862 | } |
873 | 863 | ||
874 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 864 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
875 | { | 865 | { |
876 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 866 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
877 | 867 | ||
878 | if ( which == Led_Mail ) { | 868 | if ( which == Led_Mail ) { |
879 | if ( fd >= 0 ) { | 869 | if ( fd >= 0 ) { |
880 | struct sharp_led_status leds; | 870 | struct sharp_led_status leds; |
881 | ::memset ( &leds, 0, sizeof( leds )); | 871 | ::memset ( &leds, 0, sizeof( leds )); |
882 | leds. which = SHARP_LED_MAIL_EXISTS; | 872 | leds. which = SHARP_LED_MAIL_EXISTS; |
883 | bool ok = true; | 873 | bool ok = true; |
884 | 874 | ||
885 | switch ( st ) { | 875 | switch ( st ) { |
886 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 876 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
887 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 877 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
888 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 878 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
889 | default : ok = false; | 879 | default : ok = false; |
890 | } | 880 | } |
891 | 881 | ||
892 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 882 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
893 | m_leds [0] = st; | 883 | m_leds [0] = st; |
894 | return true; | 884 | return true; |
895 | } | 885 | } |
896 | } | 886 | } |
897 | } | 887 | } |
898 | return false; | 888 | return false; |
899 | } | 889 | } |
900 | 890 | ||
901 | bool Zaurus::setSoftSuspend ( bool soft ) | 891 | bool Zaurus::setSoftSuspend ( bool soft ) |
902 | { | 892 | { |
903 | bool res = false; | 893 | bool res = false; |
904 | int fd; | 894 | int fd; |
905 | 895 | ||
906 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 896 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
907 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 897 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
908 | 898 | ||
909 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 899 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
910 | 900 | ||
911 | if ( sources >= 0 ) { | 901 | if ( sources >= 0 ) { |
912 | if ( soft ) | 902 | if ( soft ) |
913 | sources &= ~APM_EVT_POWER_BUTTON; | 903 | sources &= ~APM_EVT_POWER_BUTTON; |
914 | else | 904 | else |
915 | sources |= APM_EVT_POWER_BUTTON; | 905 | sources |= APM_EVT_POWER_BUTTON; |
916 | 906 | ||
917 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 907 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
918 | res = true; | 908 | res = true; |
919 | else | 909 | else |
920 | perror ( "APM_IOCGEVTSRC" ); | 910 | perror ( "APM_IOCGEVTSRC" ); |
921 | } | 911 | } |
922 | else | 912 | else |
923 | perror ( "APM_IOCGEVTSRC" ); | 913 | perror ( "APM_IOCGEVTSRC" ); |
924 | 914 | ||
925 | ::close ( fd ); | 915 | ::close ( fd ); |
926 | } | 916 | } |
927 | else | 917 | else |
928 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 918 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
929 | 919 | ||
930 | return res; | 920 | return res; |
931 | } | 921 | } |
932 | 922 | ||
933 | 923 | ||
934 | bool Zaurus::setDisplayBrightness ( int bright ) | 924 | bool Zaurus::setDisplayBrightness ( int bright ) |
935 | { | 925 | { |
936 | bool res = false; | 926 | bool res = false; |
937 | int fd; | 927 | int fd; |
938 | 928 | ||
939 | if ( bright > 255 ) | 929 | if ( bright > 255 ) |
940 | bright = 255; | 930 | bright = 255; |
941 | if ( bright < 0 ) | 931 | if ( bright < 0 ) |
942 | bright = 0; | 932 | bright = 0; |
943 | 933 | ||
944 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 934 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
945 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 935 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
946 | if ( bright && !bl ) | 936 | if ( bright && !bl ) |
947 | bl = 1; | 937 | bl = 1; |
948 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 938 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
949 | ::close ( fd ); | 939 | ::close ( fd ); |
950 | } | 940 | } |
951 | return res; | 941 | return res; |
952 | } | 942 | } |
953 | 943 | ||
954 | 944 | ||
955 | int Zaurus::displayBrightnessResolution ( ) const | 945 | int Zaurus::displayBrightnessResolution ( ) const |
956 | { | 946 | { |
957 | return 5; | 947 | return 5; |
958 | } | 948 | } |
959 | 949 | ||
960 | 950 | ||