summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/device.pro2
-rw-r--r--libopie2/opiecore/device/odevice.cpp14
-rw-r--r--libopie2/opiecore/device/odevice_abstractmobiledevice.cpp119
-rw-r--r--libopie2/opiecore/device/odevice_abstractmobiledevice.h64
-rw-r--r--libopie2/opiecore/device/odevice_beagle.h4
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h4
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp21
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h5
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h6
-rw-r--r--libopie2/opiecore/device/odevice_yopy.h4
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp36
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h5
14 files changed, 204 insertions, 84 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro
index 9a409e1..08bd4e1 100644
--- a/libopie2/opiecore/device/device.pro
+++ b/libopie2/opiecore/device/device.pro
@@ -1,22 +1,24 @@
1HEADERS += device/odevice.h \ 1HEADERS += device/odevice.h \
2 device/odevicebutton.h \ 2 device/odevicebutton.h \
3 device/odevice_abstractmobiledevice.h \
3 device/odevice_beagle.h \ 4 device/odevice_beagle.h \
4 device/odevice_ipaq.h \ 5 device/odevice_ipaq.h \
5 device/odevice_jornada.h \ 6 device/odevice_jornada.h \
6 device/odevice_ramses.h \ 7 device/odevice_ramses.h \
7 device/odevice_simpad.h \ 8 device/odevice_simpad.h \
8 device/odevice_zaurus.h \ 9 device/odevice_zaurus.h \
9 device/odevice_genuineintel.h \ 10 device/odevice_genuineintel.h \
10 device/odevice_yopy.h 11 device/odevice_yopy.h
11 12
12SOURCES += device/odevice.cpp \ 13SOURCES += device/odevice.cpp \
13 device/odevicebutton.cpp \ 14 device/odevicebutton.cpp \
15 device/odevice_abstractmobiledevice.cpp \
14 device/odevice_beagle.cpp \ 16 device/odevice_beagle.cpp \
15 device/odevice_ipaq.cpp \ 17 device/odevice_ipaq.cpp \
16 device/odevice_jornada.cpp\ 18 device/odevice_jornada.cpp\
17 device/odevice_ramses.cpp \ 19 device/odevice_ramses.cpp \
18 device/odevice_simpad.cpp \ 20 device/odevice_simpad.cpp \
19 device/odevice_zaurus.cpp \ 21 device/odevice_zaurus.cpp \
20 device/odevice_genuineintel.cpp \ 22 device/odevice_genuineintel.cpp \
21 device/odevice_yopy.cpp 23 device/odevice_yopy.cpp
22 24
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 2c5190c..ed705a6 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -161,222 +161,208 @@ ODevice *ODevice::inst()
161 if ( !dev ) dev = new ODevice(); 161 if ( !dev ) dev = new ODevice();
162 dev->init(cpu_info); 162 dev->init(cpu_info);
163 } 163 }
164 return dev; 164 return dev;
165} 165}
166 166
167ODevice::ODevice() 167ODevice::ODevice()
168{ 168{
169 d = new ODeviceData; 169 d = new ODeviceData;
170 170
171 d->m_modelstr = "Unknown"; 171 d->m_modelstr = "Unknown";
172 d->m_model = Model_Unknown; 172 d->m_model = Model_Unknown;
173 d->m_vendorstr = "Unknown"; 173 d->m_vendorstr = "Unknown";
174 d->m_vendor = Vendor_Unknown; 174 d->m_vendor = Vendor_Unknown;
175 d->m_systemstr = "Unknown"; 175 d->m_systemstr = "Unknown";
176 d->m_system = System_Unknown; 176 d->m_system = System_Unknown;
177 d->m_sysverstr = "0.0"; 177 d->m_sysverstr = "0.0";
178 d->m_rotation = Rot0; 178 d->m_rotation = Rot0;
179 d->m_direction = CW; 179 d->m_direction = CW;
180 180
181 d->m_holdtime = 1000; // 1000ms 181 d->m_holdtime = 1000; // 1000ms
182 d->m_buttons = 0; 182 d->m_buttons = 0;
183 d->m_cpu_frequencies = new QStrList; 183 d->m_cpu_frequencies = new QStrList;
184 184
185 185
186 /* mixer */ 186 /* mixer */
187 d->m_sound = d->m_vol = d->m_mixer = -1; 187 d->m_sound = d->m_vol = d->m_mixer = -1;
188 188
189 /* System QCopChannel created */ 189 /* System QCopChannel created */
190 d->m_initializedButtonQcop = false; 190 d->m_initializedButtonQcop = false;
191 191
192 // New distribution detection code first checks for legacy distributions, 192 // New distribution detection code first checks for legacy distributions,
193 // identified by /etc/familiar-version or /etc/oz_version. 193 // identified by /etc/familiar-version or /etc/oz_version.
194 // Then check for OpenEmbedded and lastly, read /etc/issue 194 // Then check for OpenEmbedded and lastly, read /etc/issue
195 195
196 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 196 for ( unsigned int i = 0; i < sizeof distributions; ++i )
197 { 197 {
198 if ( QFile::exists( distributions[i].sysvfile ) ) 198 if ( QFile::exists( distributions[i].sysvfile ) )
199 { 199 {
200 d->m_systemstr = distributions[i].sysstr; 200 d->m_systemstr = distributions[i].sysstr;
201 d->m_system = distributions[i].system; 201 d->m_system = distributions[i].system;
202 d->m_sysverstr = "<Unknown>"; 202 d->m_sysverstr = "<Unknown>";
203 QFile f( distributions[i].sysvfile ); 203 QFile f( distributions[i].sysvfile );
204 if ( f.open( IO_ReadOnly ) ) 204 if ( f.open( IO_ReadOnly ) )
205 { 205 {
206 QTextStream ts( &f ); 206 QTextStream ts( &f );
207 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 207 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
208 } 208 }
209 break; 209 break;
210 } 210 }
211 } 211 }
212} 212}
213 213
214void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 214void ODevice::systemMessage( const QCString &msg, const QByteArray & )
215{ 215{
216 if ( msg == "deviceButtonMappingChanged()" ) { 216 if ( msg == "deviceButtonMappingChanged()" ) {
217 reloadButtonMapping(); 217 reloadButtonMapping();
218 } 218 }
219} 219}
220 220
221void ODevice::init(const QString&) 221void ODevice::init(const QString&)
222{ 222{
223} 223}
224 224
225/** 225/**
226* This method initialises the button mapping 226* This method initialises the button mapping
227*/ 227*/
228void ODevice::initButtons() 228void ODevice::initButtons()
229{ 229{
230 if ( d->m_buttons ) 230 if ( d->m_buttons )
231 return; 231 return;
232 232
233 qDebug ( "init Buttons" ); 233 qDebug ( "init Buttons" );
234 d->m_buttons = new QValueList <ODeviceButton>; 234 d->m_buttons = new QValueList <ODeviceButton>;
235 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 235 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
236 default_button *db = default_buttons + i; 236 default_button *db = default_buttons + i;
237 ODeviceButton b; 237 ODeviceButton b;
238 b. setKeycode ( db->code ); 238 b. setKeycode ( db->code );
239 b. setUserText ( QObject::tr ( "Button", db->utext )); 239 b. setUserText ( QObject::tr ( "Button", db->utext ));
240 b. setPixmap ( Resource::loadPixmap ( db->pix )); 240 b. setPixmap ( Resource::loadPixmap ( db->pix ));
241 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 241 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
242 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 242 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
243 d->m_buttons->append ( b ); 243 d->m_buttons->append ( b );
244 } 244 }
245 245
246 reloadButtonMapping(); 246 reloadButtonMapping();
247} 247}
248 248
249ODevice::~ODevice() 249ODevice::~ODevice()
250{ 250{
251// we leak m_devicebuttons and m_cpu_frequency 251// we leak m_devicebuttons and m_cpu_frequency
252// but it's a singleton and it is not so importantant 252// but it's a singleton and it is not so importantant
253// -zecke 253// -zecke
254 delete d; 254 delete d;
255} 255}
256 256
257//#include <linux/apm_bios.h>
258
259#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
260
261/** 257/**
262* This method will try to suspend the device 258* This method will try to suspend the device
263* It only works if the user is the QWS Server and the apm application 259* It only works if the user is the QWS Server and the apm application
264* is installed. 260* is installed.
265* It tries to suspend and then waits some time cause some distributions 261* It tries to suspend and then waits some time cause some distributions
266* do have asynchronus apm implementations. 262* do have asynchronus apm implementations.
267* This method will either fail and return false or it'll suspend the 263* This method will either fail and return false or it'll suspend the
268* device and return once the device got woken up 264* device and return once the device got woken up
269* 265*
270* @return if the device got suspended 266* @return if the device got suspended
271*/ 267*/
272bool ODevice::suspend() 268bool ODevice::suspend()
273{ 269{
274 return false; // default implementation == unknown device or qvfb 270 return false; // default implementation == unknown device or qvfb
275} 271}
276 272
277//#include <linux/fb.h> better not rely on kernel headers in userspace ...
278
279#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
280
281/* VESA Blanking Levels */
282#define VESA_NO_BLANKING 0
283#define VESA_VSYNC_SUSPEND 1
284#define VESA_HSYNC_SUSPEND 2
285#define VESA_POWERDOWN 3
286
287/** 273/**
288* This sets the display on or off 274* This sets the display on or off
289*/ 275*/
290bool ODevice::setDisplayStatus( bool on ) 276bool ODevice::setDisplayStatus( bool on )
291{ 277{
292 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); 278 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on );
293 return false; // don't do anything for unknown models 279 return false; // don't do anything for unknown models
294} 280}
295 281
296/** 282/**
297* This sets the display brightness 283* This sets the display brightness
298* 284*
299* @param b The brightness to be set on a scale from 0 to 255 285* @param b The brightness to be set on a scale from 0 to 255
300* @return success or failure 286* @return success or failure
301*/ 287*/
302bool ODevice::setDisplayBrightness( int b ) 288bool ODevice::setDisplayBrightness( int b )
303{ 289{
304 qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); 290 qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b );
305 return false; 291 return false;
306} 292}
307 293
308/** 294/**
309 * 295 *
310 * @returns the number of steppings on the brightness slider 296 * @returns the number of steppings on the brightness slider
311 * in the Light-'n-Power settings. Values smaller than zero and bigger 297 * in the Light-'n-Power settings. Values smaller than zero and bigger
312 * than 255 do not make sense. 298 * than 255 do not make sense.
313 * 299 *
314 * \sa QSlider::setLineStep 300 * \sa QSlider::setLineStep
315 * \sa QSlider::setPageStep 301 * \sa QSlider::setPageStep
316 */ 302 */
317int ODevice::displayBrightnessResolution() const 303int ODevice::displayBrightnessResolution() const
318{ 304{
319 qDebug( "ODevice::displayBrightnessResolution() - please override me." ); 305 qDebug( "ODevice::displayBrightnessResolution() - please override me." );
320 return 16; 306 return 16;
321} 307}
322 308
323/** 309/**
324* This sets the display contrast 310* This sets the display contrast
325* @param p The contrast to be set on a scale from 0 to 255 311* @param p The contrast to be set on a scale from 0 to 255
326* @returns success or failure 312* @returns success or failure
327*/ 313*/
328bool ODevice::setDisplayContrast( int p ) 314bool ODevice::setDisplayContrast( int p )
329{ 315{
330 qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); 316 qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p );
331 return false; 317 return false;
332} 318}
333 319
334/** 320/**
335* @returns the maximum value for the contrast settings slider 321* @returns the maximum value for the contrast settings slider
336* or 0 if the device doesn't support setting of a contrast 322* or 0 if the device doesn't support setting of a contrast
337*/ 323*/
338int ODevice::displayContrastResolution() const 324int ODevice::displayContrastResolution() const
339{ 325{
340 qDebug( "ODevice::displayBrightnessResolution() - please override me." ); 326 qDebug( "ODevice::displayBrightnessResolution() - please override me." );
341 return 0; 327 return 0;
342} 328}
343 329
344/** 330/**
345* This returns the vendor as string 331* This returns the vendor as string
346* @return Vendor as QString 332* @return Vendor as QString
347*/ 333*/
348QString ODevice::vendorString() const 334QString ODevice::vendorString() const
349{ 335{
350 return d->m_vendorstr; 336 return d->m_vendorstr;
351} 337}
352 338
353/** 339/**
354* This returns the vendor as one of the values of OVendor 340* This returns the vendor as one of the values of OVendor
355* @return OVendor 341* @return OVendor
356*/ 342*/
357OVendor ODevice::vendor() const 343OVendor ODevice::vendor() const
358{ 344{
359 return d->m_vendor; 345 return d->m_vendor;
360} 346}
361 347
362/** 348/**
363* This returns the model as a string 349* This returns the model as a string
364* @return A string representing the model 350* @return A string representing the model
365*/ 351*/
366QString ODevice::modelString() const 352QString ODevice::modelString() const
367{ 353{
368 return d->m_modelstr; 354 return d->m_modelstr;
369} 355}
370 356
371/** 357/**
372* This does return the OModel used 358* This does return the OModel used
373*/ 359*/
374OModel ODevice::model() const 360OModel ODevice::model() const
375{ 361{
376 return d->m_model; 362 return d->m_model;
377} 363}
378 364
379/** 365/**
380* This does return the systen name 366* This does return the systen name
381*/ 367*/
382QString ODevice::systemString() const 368QString ODevice::systemString() const
diff --git a/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp b/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp
new file mode 100644
index 0000000..f3f6af5
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp
@@ -0,0 +1,119 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org>
4 Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org>
5 Copyright (C) 2002, 2003 Robert Griebl <sandman@handhelds.org>
6
7
8 =.
9 .=l.
10           .>+-=
11 _;:,     .>    :=|. This program is free software; you can
12.> <`_,   >  .   <= redistribute it and/or modify it under
13:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
14.="- .-=="i,     .._ License as published by the Free Software
15 - .   .-<_>     .<> Foundation; either version 2 of the License,
16     ._= =}       : or (at your option) any later version.
17    .%`+i>       _;_.
18    .i_,=:_.      -<s. This program is distributed in the hope that
19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
20    : ..    .:,     . . . without even the implied warranty of
21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
23..}^=.=       =       ; Library General Public License for more
24++=   -.     .`     .: details.
25 :     =  ...= . :.=-
26 -.   .:....=;==+<; You should have received a copy of the GNU
27  -_. . .   )=.  = Library General Public License along with
28    --        :-=` this library; see the file COPYING.LIB.
29 If not, write to the Free Software Foundation,
30 Inc., 59 Temple Place - Suite 330,
31 Boston, MA 02111-1307, USA.
32*/
33
34#include "odevice_abstractmobiledevice.h"
35
36#include <sys/time.h>
37#include <sys/ioctl.h>
38
39#include <time.h>
40#include <fcntl.h>
41#include <unistd.h>
42#include <stdlib.h>
43
44namespace Opie {
45namespace Core {
46OAbstractMobileDevice::OAbstractMobileDevice()
47 : m_timeOut( 1500 )
48{}
49
50/**
51 * @short Time to wait for the asynchronos APM implementation to suspend
52 *
53 * Milli Seconds to wait before returning from the suspend method.
54 * This is needed due asynchrnonus implementations of the APM bios.
55 *
56 */
57void OAbstractMobileDevice::setAPMTimeOut( int time ) {
58 m_timeOut = time;
59}
60
61
62bool OAbstractMobileDevice::suspend() {
63 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
64 return false;
65
66 bool res = false;
67 ODevice::sendSuspendmsg();
68
69 struct timeval tvs, tvn;
70 ::gettimeofday ( &tvs, 0 );
71
72 ::sync(); // flush fs caches
73 res = ( ::system ( "apm --suspend" ) == 0 );
74
75 // This is needed because some apm implementations are asynchronous and we
76 // can not be sure when exactly the device is really suspended
77 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
78
79 if ( res ) {
80 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
81 ::usleep ( 200 * 1000 );
82 ::gettimeofday ( &tvn, 0 );
83 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut );
84 }
85
86 return res;
87}
88
89//#include <linux/fb.h> better not rely on kernel headers in userspace ...
90
91// _IO and friends are only defined in kernel headers ...
92#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
93#define OD_IO(type,number) OD_IOC(0,type,number,0)
94
95#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
96
97/* VESA Blanking Levels */
98#define VESA_NO_BLANKING 0
99#define VESA_VSYNC_SUSPEND 1
100#define VESA_HSYNC_SUSPEND 2
101#define VESA_POWERDOWN 3
102
103bool OAbstractMobileDevice::setDisplayStatus ( bool on ) {
104 bool res = false;
105 int fd;
106
107#ifdef QT_QWS_DEVFS
108 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
109#else
110 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
111#endif
112 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
113 ::close ( fd );
114 }
115
116 return res;
117}
118}
119}
diff --git a/libopie2/opiecore/device/odevice_abstractmobiledevice.h b/libopie2/opiecore/device/odevice_abstractmobiledevice.h
new file mode 100644
index 0000000..9467e82
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_abstractmobiledevice.h
@@ -0,0 +1,64 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org>
4 Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org>
5
6
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31*/
32
33#ifndef OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE
34#define OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE
35
36#include "odevice.h"
37
38namespace Opie {
39namespace Core {
40/**
41 * @short Common Implementations for Linux Handheld Devices
42 *
43 * Abstract Class with implementation for suspending using
44 * asynchrnonus apm implementations and displaystatus using
45 * the Linux Frame Buffer API
46 *
47 */
48class OAbstractMobileDevice : public ODevice {
49 Q_OBJECT
50protected:
51 OAbstractMobileDevice();
52 void setAPMTimeOut( int time );
53public:
54 virtual bool suspend();
55 virtual bool setDisplayStatus(bool);
56
57private:
58 int m_timeOut;
59};
60}
61}
62
63
64#endif
diff --git a/libopie2/opiecore/device/odevice_beagle.h b/libopie2/opiecore/device/odevice_beagle.h
index 17b040c..697d689 100644
--- a/libopie2/opiecore/device/odevice_beagle.h
+++ b/libopie2/opiecore/device/odevice_beagle.h
@@ -1,61 +1,61 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OPIE_CORE_DEVICE_BEAGLE_H 30#ifndef OPIE_CORE_DEVICE_BEAGLE_H
31#define OPIE_CORE_DEVICE_BEAGLE_H 31#define OPIE_CORE_DEVICE_BEAGLE_H
32 32
33#include "odevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Beagle : public ODevice { 38class Beagle : public OAbstractMobileDevice {
39public: 39public:
40 Beagle(); 40 Beagle();
41 ~Beagle(); 41 ~Beagle();
42 42
43//@{ 43//@{
44 void init( const QString& init ); 44 void init( const QString& init );
45 void initButtons(); 45 void initButtons();
46//@} 46//@}
47 47
48 48
49//@{ 49//@{
50 bool setDisplayStatus( bool on ); 50 bool setDisplayStatus( bool on );
51 int displayBrightnessResolution()const; 51 int displayBrightnessResolution()const;
52 bool setDisplayBrightness( int brightness ); 52 bool setDisplayBrightness( int brightness );
53//@} 53//@}
54 54
55}; 55};
56} 56}
57} 57}
58} 58}
59 59
60 60
61#endif 61#endif
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index b1dac74..1889467 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -1,88 +1,88 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_IPAQ 30#ifndef ODEVICE_IPAQ
31#define ODEVICE_IPAQ 31#define ODEVICE_IPAQ
32 32
33#include "odevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
43{ 43{
44 44
45 protected: 45 protected:
46 virtual void init(const QString&); 46 virtual void init(const QString&);
47 virtual void initButtons(); 47 virtual void initButtons();
48 48
49 public: 49 public:
50 virtual bool setDisplayBrightness( int b ); 50 virtual bool setDisplayBrightness( int b );
51 virtual int displayBrightnessResolution() const; 51 virtual int displayBrightnessResolution() const;
52 52
53 virtual void playAlarmSound(); 53 virtual void playAlarmSound();
54 54
55 virtual QValueList <OLed> ledList() const; 55 virtual QValueList <OLed> ledList() const;
56 virtual QValueList <OLedState> ledStateList( OLed led ) const; 56 virtual QValueList <OLedState> ledStateList( OLed led ) const;
57 virtual OLedState ledState( OLed led ) const; 57 virtual OLedState ledState( OLed led ) const;
58 virtual bool setLedState( OLed led, OLedState st ); 58 virtual bool setLedState( OLed led, OLedState st );
59 59
60 virtual bool hasLightSensor() const; 60 virtual bool hasLightSensor() const;
61 virtual int readLightSensor(); 61 virtual int readLightSensor();
62 virtual int lightSensorResolution() const; 62 virtual int lightSensorResolution() const;
63 63
64 protected: 64 protected:
65 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 65 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
66 virtual void timerEvent( QTimerEvent *te ); 66 virtual void timerEvent( QTimerEvent *te );
67 67
68 int m_power_timer; 68 int m_power_timer;
69 69
70 OLedState m_leds [2]; 70 OLedState m_leds [2];
71}; 71};
72 72
73struct i_button { 73struct i_button {
74 uint model; 74 uint model;
75 Qt::Key code; 75 Qt::Key code;
76 char *utext; 76 char *utext;
77 char *pix; 77 char *pix;
78 char *fpressedservice; 78 char *fpressedservice;
79 char *fpressedaction; 79 char *fpressedaction;
80 char *fheldservice; 80 char *fheldservice;
81 char *fheldaction; 81 char *fheldaction;
82}; 82};
83 83
84} 84}
85} 85}
86} 86}
87 87
88#endif 88#endif
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 8141f1c..5f95e42 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -77,128 +77,107 @@ typedef struct {
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 79
80using namespace Opie::Core; 80using namespace Opie::Core;
81using namespace Opie::Core::Internal; 81using namespace Opie::Core::Internal;
82 82
83struct j_button jornada56x_buttons [] = { 83struct j_button jornada56x_buttons [] = {
84 { Model_Jornada_56x, 84 { Model_Jornada_56x,
85 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 85 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
86 "devicebuttons/jornada56x_calendar", 86 "devicebuttons/jornada56x_calendar",
87 "datebook", "nextView()", 87 "datebook", "nextView()",
88 "today", "raise()" }, 88 "today", "raise()" },
89 { Model_Jornada_56x, 89 { Model_Jornada_56x,
90 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 90 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
91 "devicebuttons/jornada56x_contact", 91 "devicebuttons/jornada56x_contact",
92 "addressbook", "raise()", 92 "addressbook", "raise()",
93 "addressbook", "beamBusinessCard()" }, 93 "addressbook", "beamBusinessCard()" },
94 { Model_Jornada_56x, 94 { Model_Jornada_56x,
95 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), 95 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"),
96 "devicebuttons/jornada56x_todo", 96 "devicebuttons/jornada56x_todo",
97 "todolist", "raise()", 97 "todolist", "raise()",
98 "todolist", "create()" }, 98 "todolist", "create()" },
99 { Model_Jornada_56x, 99 { Model_Jornada_56x,
100 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), 100 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"),
101 "devicebuttons/jornada56x_home", 101 "devicebuttons/jornada56x_home",
102 "QPE/Launcher", "home()", 102 "QPE/Launcher", "home()",
103 "buttonsettings", "raise()" }, 103 "buttonsettings", "raise()" },
104 { Model_Jornada_56x, 104 { Model_Jornada_56x,
105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), 105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"),
106 "devicebuttons/jornada56x_record", 106 "devicebuttons/jornada56x_record",
107 "QPE/VMemo", "toggleRecord()", 107 "QPE/VMemo", "toggleRecord()",
108 "sound", "raise()" }, 108 "sound", "raise()" },
109}; 109};
110 110
111void Jornada::init(const QString&) 111void Jornada::init(const QString&)
112{ 112{
113 d->m_vendorstr = "HP"; 113 d->m_vendorstr = "HP";
114 d->m_vendor = Vendor_HP; 114 d->m_vendor = Vendor_HP;
115 d->m_modelstr = "Jornada 56x"; 115 d->m_modelstr = "Jornada 56x";
116 d->m_model = Model_Jornada_56x; 116 d->m_model = Model_Jornada_56x;
117 d->m_rotation = Rot0; 117 d->m_rotation = Rot0;
118 //Distribution detecting code is now in base class 118 //Distribution detecting code is now in base class
119} 119}
120 120
121void Jornada::initButtons() 121void Jornada::initButtons()
122{ 122{
123 if ( d->m_buttons ) 123 if ( d->m_buttons )
124 return; 124 return;
125 125
126 d->m_buttons = new QValueList <ODeviceButton>; 126 d->m_buttons = new QValueList <ODeviceButton>;
127 127
128 for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { 128 for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) {
129 j_button *ib = jornada56x_buttons + i; 129 j_button *ib = jornada56x_buttons + i;
130 ODeviceButton b; 130 ODeviceButton b;
131 131
132 if (( ib->model & d->m_model ) == d->m_model ) { 132 if (( ib->model & d->m_model ) == d->m_model ) {
133 b. setKeycode ( ib->code ); 133 b. setKeycode ( ib->code );
134 b. setUserText ( QObject::tr ( "Button", ib->utext )); 134 b. setUserText ( QObject::tr ( "Button", ib->utext ));
135 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 135 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
136 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 136 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
137 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 137 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
138 138
139 d->m_buttons->append ( b ); 139 d->m_buttons->append ( b );
140 } 140 }
141 } 141 }
142 reloadButtonMapping(); 142 reloadButtonMapping();
143} 143}
144 144
145int Jornada::displayBrightnessResolution() const 145int Jornada::displayBrightnessResolution() const
146{ 146{
147 return 255; 147 return 255;
148} 148}
149 149
150 150
151bool Jornada::setDisplayBrightness( int bright ) 151bool Jornada::setDisplayBrightness( int bright )
152{ 152{
153 bool res = false; 153 bool res = false;
154 154
155 if ( bright > 255 ) 155 if ( bright > 255 )
156 bright = 255; 156 bright = 255;
157 if ( bright < 0 ) 157 if ( bright < 0 )
158 bright = 0; 158 bright = 0;
159 159
160 QString cmdline; 160 QString cmdline;
161 161
162 if ( !bright ) 162 if ( !bright )
163 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); 163 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power");
164 else 164 else
165 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright ); 165 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright );
166 166
167 res = ( ::system( (const char*) cmdline ) == 0 ); 167 res = ( ::system( (const char*) cmdline ) == 0 );
168 168
169 return res; 169 return res;
170} 170}
171 171
172 172
173bool Jornada::suspend( )
174{
175 qDebug("ODevice::suspend");
176 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
177 return false;
178
179 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
180 return false;
181
182 bool res = false;
183 ODevice::sendSuspendmsg();
184
185 struct timeval tvs;
186 ::gettimeofday ( &tvs, 0 );
187
188 ::sync(); // flush fs caches
189 res = ( ::system ( "apm --suspend" ) == 0 );
190
191 return res;
192}
193
194bool Jornada::setDisplayStatus ( bool on ) 173bool Jornada::setDisplayStatus ( bool on )
195{ 174{
196 bool res = false; 175 bool res = false;
197 176
198 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 177 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
199 178
200 res = ( ::system( (const char*) cmdline ) == 0 ); 179 res = ( ::system( (const char*) cmdline ) == 0 );
201 180
202 return res; 181 return res;
203} 182}
204 183
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
index b17fa8b..480efff 100644
--- a/libopie2/opiecore/device/odevice_jornada.h
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -1,67 +1,66 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_JORNADA 30#ifndef ODEVICE_JORNADA
31#define ODEVICE_JORNADA 31#define ODEVICE_JORNADA
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Jornada : public ODevice 38class Jornada : public OAbstractMobileDevice
39{ 39{
40 40
41 protected: 41 protected:
42 virtual void init(const QString&); 42 virtual void init(const QString&);
43 virtual void initButtons(); 43 virtual void initButtons();
44 44
45 public: 45 public:
46 virtual bool suspend ( );
47 virtual bool setDisplayBrightness ( int b ); 46 virtual bool setDisplayBrightness ( int b );
48 virtual bool setDisplayStatus ( bool on); 47 virtual bool setDisplayStatus ( bool on);
49 virtual int displayBrightnessResolution() const; 48 virtual int displayBrightnessResolution() const;
50}; 49};
51 50
52struct j_button { 51struct j_button {
53 uint model; 52 uint model;
54 Qt::Key code; 53 Qt::Key code;
55 char *utext; 54 char *utext;
56 char *pix; 55 char *pix;
57 char *fpressedservice; 56 char *fpressedservice;
58 char *fpressedaction; 57 char *fpressedaction;
59 char *fheldservice; 58 char *fheldservice;
60 char *fheldaction; 59 char *fheldaction;
61}; 60};
62 61
63} 62}
64} 63}
65} 64}
66#endif 65#endif
67 66
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
index bbd3862..50963dc 100644
--- a/libopie2/opiecore/device/odevice_ramses.h
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -1,69 +1,69 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_RAMSES 30#ifndef ODEVICE_RAMSES
31#define ODEVICE_RAMSES 31#define ODEVICE_RAMSES
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34/* QT */ 34/* QT */
35#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
36 36
37 37
38#ifndef OD_IOC 38#ifndef OD_IOC
39#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 39#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
40#define OD_IO(type,number) OD_IOC(0,type,number,0) 40#define OD_IO(type,number) OD_IOC(0,type,number,0)
41#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 41#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
42#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 42#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
43#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 43#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
44#endif 44#endif
45 45
46 46
47 47
48namespace Opie { 48namespace Opie {
49namespace Core { 49namespace Core {
50namespace Internal { 50namespace Internal {
51 51
52class Ramses : public ODevice 52class Ramses : public ODevice
53{ 53{
54 protected: 54 protected:
55 virtual void init(const QString&); 55 virtual void init(const QString&);
56 56
57 public: 57 public:
58 virtual bool suspend(); 58 virtual bool suspend();
59 59
60 virtual bool setDisplayBrightness( int b ); 60 virtual bool setDisplayBrightness( int b );
61 virtual int displayBrightnessResolution() const; 61 virtual int displayBrightnessResolution() const;
62 virtual void playAlarmSound(); 62 virtual void playAlarmSound();
63}; 63};
64 64
65} 65}
66} 66}
67} 67}
68 68
69#endif 69#endif
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index d6c2c80..550da5e 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -239,162 +239,162 @@ static bool setCS3Bit( bool bitset, int bit ) {
239 if ( !ok ) 239 if ( !ok )
240 return false; 240 return false;
241 241
242 file.close(); 242 file.close();
243 243
244 /* 244 /*
245 * change the value 245 * change the value
246 */ 246 */
247 val = bitset ? (val | bit) : (val & ~bit); 247 val = bitset ? (val | bit) : (val & ~bit);
248 248
249 /* 249 /*
250 * write it back 250 * write it back
251 */ 251 */
252 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); 252 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY );
253 if ( cs3_fd < 0 ) 253 if ( cs3_fd < 0 )
254 return false; 254 return false;
255 255
256 char line[32]; 256 char line[32];
257 ::snprintf(line, sizeof(line), "0x%04x\n", val); 257 ::snprintf(line, sizeof(line), "0x%04x\n", val);
258 ::write(cs3_fd, line, strlen(line)); 258 ::write(cs3_fd, line, strlen(line));
259 ::close(cs3_fd); 259 ::close(cs3_fd);
260 260
261 return true; 261 return true;
262} 262}
263 263
264 264
265QValueList <OLed> SIMpad::ledList() const 265QValueList <OLed> SIMpad::ledList() const
266{ 266{
267 QValueList <OLed> vl; 267 QValueList <OLed> vl;
268 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 268 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
269 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 269 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
270 return vl; 270 return vl;
271} 271}
272 272
273QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 273QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
274{ 274{
275 QValueList <OLedState> vl; 275 QValueList <OLedState> vl;
276 276
277 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 277 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
278 vl << Led_Off << Led_On; 278 vl << Led_Off << Led_On;
279 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 279 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
280 //vl << Led_Off; 280 //vl << Led_Off;
281 return vl; 281 return vl;
282} 282}
283 283
284OLedState SIMpad::ledState ( OLed l ) const 284OLedState SIMpad::ledState ( OLed l ) const
285{ 285{
286 switch ( l ) { 286 switch ( l ) {
287 case Led_Power: 287 case Led_Power:
288 return m_leds [0]; 288 return m_leds [0];
289 //case Led_Mail: 289 //case Led_Mail:
290 // return m_leds [1]; 290 // return m_leds [1];
291 default: 291 default:
292 return Led_Off; 292 return Led_Off;
293 } 293 }
294} 294}
295 295
296bool SIMpad::setLedState ( OLed l, OLedState st ) 296bool SIMpad::setLedState ( OLed l, OLedState st )
297{ 297{
298 if ( l == Led_Power ) { 298 if ( l == Led_Power ) {
299 m_leds [0] = st; 299 m_leds [0] = st;
300 setCS3Bit(st == Led_On, SIMPAD_LED2_ON); 300 setCS3Bit(st == Led_On, SIMPAD_LED2_ON);
301 return true; 301 return true;
302 } 302 }
303 303
304 return false; 304 return false;
305} 305}
306 306
307void SIMpad::timerEvent ( QTimerEvent * ) 307void SIMpad::timerEvent ( QTimerEvent * )
308{ 308{
309 killTimer ( m_power_timer ); 309 killTimer ( m_power_timer );
310 m_power_timer = 0; 310 m_power_timer = 0;
311 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 311 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
312 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 312 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
313} 313}
314 314
315 315
316void SIMpad::playAlarmSound() 316void SIMpad::playAlarmSound()
317{ 317{
318#ifndef QT_NO_SOUND 318#ifndef QT_NO_SOUND
319 static Sound snd ( "alarm" ); 319 static Sound snd ( "alarm" );
320 if(!snd.isFinished()) 320 if(!snd.isFinished())
321 return; 321 return;
322 322
323 /* save as the Sound is static! */ 323 /* save as the Sound is static! */
324 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); 324 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
325 snd. play(); 325 snd. play();
326#endif 326#endif
327} 327}
328 328
329 329
330bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 330bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
331{ 331{
332 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 332 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
333 return false; 333 return false;
334 334
335 bool res = ODevice::suspend(); 335 bool res = OAbstractMobileDevice::suspend();
336 336
337 /* 337 /*
338 * restore the screen content if we really 338 * restore the screen content if we really
339 * supended the device 339 * supended the device
340 */ 340 */
341 if ( res ) 341 if ( res )
342 updateAllWidgets(); 342 updateAllWidgets();
343 343
344 return res; 344 return res;
345} 345}
346 346
347bool SIMpad::setDisplayStatus ( bool on ) 347bool SIMpad::setDisplayStatus ( bool on )
348{ 348{
349 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 349 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
350 350
351 return setCS3Bit(on, SIMPAD_DISPLAY_ON); 351 return setCS3Bit(on, SIMPAD_DISPLAY_ON);
352} 352}
353 353
354 354
355bool SIMpad::setDisplayBrightness ( int bright ) 355bool SIMpad::setDisplayBrightness ( int bright )
356{ 356{
357 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 357 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
358 bool res = false; 358 bool res = false;
359 int fd; 359 int fd;
360 360
361 if ( bright > 255 ) 361 if ( bright > 255 )
362 bright = 255; 362 bright = 255;
363 if ( bright < 1 ) 363 if ( bright < 1 )
364 bright = 0; 364 bright = 0;
365 365
366 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 366 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
367 QCString str = QFile::encodeName( QString::number(bright)); 367 QCString str = QFile::encodeName( QString::number(bright));
368 res = ( ::write(fd, str, str.length()) != -1 ); 368 res = ( ::write(fd, str, str.length()) != -1 );
369 ::close ( fd ); 369 ::close ( fd );
370 } 370 }
371 return res; 371 return res;
372} 372}
373 373
374 374
375int SIMpad::displayBrightnessResolution() const 375int SIMpad::displayBrightnessResolution() const
376{ 376{
377 return 255; // All SIMpad models share the same display 377 return 255; // All SIMpad models share the same display
378} 378}
379 379
380 380
381/* 381/*
382 * The MQ200 DRAM content is lost during suspend 382 * The MQ200 DRAM content is lost during suspend
383 * so we will just repaint every widget on resume 383 * so we will just repaint every widget on resume
384 */ 384 */
385void SIMpad::updateAllWidgets() { 385void SIMpad::updateAllWidgets() {
386 QWidgetList *list = QApplication::allWidgets(); 386 QWidgetList *list = QApplication::allWidgets();
387 QWidgetListIt it( *list ); 387 QWidgetListIt it( *list );
388 QWidget *wid; 388 QWidget *wid;
389 389
390 while ((wid=it.current()) != 0 ) { 390 while ((wid=it.current()) != 0 ) {
391 wid->update(); 391 wid->update();
392 ++it; 392 ++it;
393 } 393 }
394 394
395 delete list; 395 delete list;
396} 396}
397 397
398} 398}
399} 399}
400} 400}
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index 41b94d1..1276603 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,75 +1,75 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class SIMpad : public ODevice 42class SIMpad : public OAbstractMobileDevice
43{ 43{
44 protected: 44 protected:
45 virtual void init(const QString&); 45 virtual void init(const QString&);
46 virtual void initButtons(); 46 virtual void initButtons();
47 47
48 public: 48 public:
49 virtual bool suspend(); 49 virtual bool suspend();
50 50
51 virtual bool setDisplayStatus( bool on ); 51 virtual bool setDisplayStatus( bool on );
52 virtual bool setDisplayBrightness( int b ); 52 virtual bool setDisplayBrightness( int b );
53 virtual int displayBrightnessResolution() const; 53 virtual int displayBrightnessResolution() const;
54 54
55 virtual void playAlarmSound(); 55 virtual void playAlarmSound();
56 56
57 virtual QValueList <OLed> ledList() const; 57 virtual QValueList <OLed> ledList() const;
58 virtual QValueList <OLedState> ledStateList( OLed led ) const; 58 virtual QValueList <OLedState> ledStateList( OLed led ) const;
59 virtual OLedState ledState( OLed led ) const; 59 virtual OLedState ledState( OLed led ) const;
60 virtual bool setLedState( OLed led, OLedState st ); 60 virtual bool setLedState( OLed led, OLedState st );
61 61
62protected: 62protected:
63 virtual void timerEvent( QTimerEvent *te ); 63 virtual void timerEvent( QTimerEvent *te );
64 64
65 int m_power_timer; 65 int m_power_timer;
66 66
67 OLedState m_leds [2]; 67 OLedState m_leds [2];
68private: 68private:
69 static void updateAllWidgets(); 69 static void updateAllWidgets();
70}; 70};
71} 71}
72} 72}
73} 73}
74 74
75#endif 75#endif
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h
index f6bf061..02a19c9 100644
--- a/libopie2/opiecore/device/odevice_yopy.h
+++ b/libopie2/opiecore/device/odevice_yopy.h
@@ -1,67 +1,67 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org> 3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6          .>+-= 6          .>+-=
7_;:,     .>    :=|. This program is free software; you can 7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License, 11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version. 12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_. 13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that 14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of 16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21:     =  ...= . :.=- 21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU 22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with 23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB. 24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_YOPY 30#ifndef ODEVICE_YOPY
31#define ODEVICE_YOPY 31#define ODEVICE_YOPY
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Yopy : public ODevice 38class Yopy : public OAbstractMobileDevice
39{ 39{
40 protected: 40 protected:
41 41
42 virtual void init(const QString&); 42 virtual void init(const QString&);
43 virtual void initButtons(); 43 virtual void initButtons();
44 44
45 public: 45 public:
46 virtual bool suspend(); 46 virtual bool suspend();
47 47
48 virtual bool setDisplayBrightness ( int b ); 48 virtual bool setDisplayBrightness ( int b );
49 virtual int displayBrightnessResolution() const; 49 virtual int displayBrightnessResolution() const;
50}; 50};
51 51
52struct yopy_button 52struct yopy_button
53{ 53{
54 Qt::Key code; 54 Qt::Key code;
55 char *utext; 55 char *utext;
56 char *pix; 56 char *pix;
57 char *fpressedservice; 57 char *fpressedservice;
58 char *fpressedaction; 58 char *fpressedaction;
59 char *fheldservice; 59 char *fheldservice;
60 char *fheldaction; 60 char *fheldaction;
61}; 61};
62 62
63} 63}
64} 64}
65} 65}
66 66
67#endif 67#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 82e127e..67dfa41 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -39,192 +39,196 @@
39#include <opie2/oinputsystem.h> 39#include <opie2/oinputsystem.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60struct z_button z_buttons [] = { 60struct z_button z_buttons [] = {
61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
62 "devicebuttons/z_calendar", 62 "devicebuttons/z_calendar",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
66 "devicebuttons/z_contact", 66 "devicebuttons/z_contact",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
70 "devicebuttons/z_home", 70 "devicebuttons/z_home",
71 "QPE/Launcher", "home()", 71 "QPE/Launcher", "home()",
72 "buttonsettings", "raise()" }, 72 "buttonsettings", "raise()" },
73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
74 "devicebuttons/z_menu", 74 "devicebuttons/z_menu",
75 "QPE/TaskBar", "toggleMenu()", 75 "QPE/TaskBar", "toggleMenu()",
76 "QPE/TaskBar", "toggleStartMenu()" }, 76 "QPE/TaskBar", "toggleStartMenu()" },
77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
78 "devicebuttons/z_mail", 78 "devicebuttons/z_mail",
79 "opiemail", "raise()", 79 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 80 "opiemail", "newMail()" },
81}; 81};
82 82
83struct z_button z_buttons_c700 [] = { 83struct z_button z_buttons_c700 [] = {
84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
85 "devicebuttons/z_calendar", 85 "devicebuttons/z_calendar",
86 "datebook", "nextView()", 86 "datebook", "nextView()",
87 "today", "raise()" }, 87 "today", "raise()" },
88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
89 "devicebuttons/z_contact", 89 "devicebuttons/z_contact",
90 "addressbook", "raise()", 90 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 91 "addressbook", "beamBusinessCard()" },
92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
93 "devicebuttons/z_home", 93 "devicebuttons/z_home",
94 "QPE/Launcher", "home()", 94 "QPE/Launcher", "home()",
95 "buttonsettings", "raise()" }, 95 "buttonsettings", "raise()" },
96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/z_menu", 97 "devicebuttons/z_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
101 "devicebuttons/z_mail", 101 "devicebuttons/z_mail",
102 "opiemail", "raise()", 102 "opiemail", "raise()",
103 "opiemail", "newMail()" }, 103 "opiemail", "newMail()" },
104 104
105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
106 "devicebuttons/z_hinge1", 106 "devicebuttons/z_hinge1",
107 "QPE/Rotation", "rotateDefault()", 107 "QPE/Rotation", "rotateDefault()",
108 "QPE/Rotation", "rotateDefault()" }, 108 "QPE/Rotation", "rotateDefault()" },
109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
110 "devicebuttons/z_hinge2", 110 "devicebuttons/z_hinge2",
111 "QPE/Rotation", "rotateDefault()", 111 "QPE/Rotation", "rotateDefault()",
112 "QPE/Rotation", "rotateDefault()" }, 112 "QPE/Rotation", "rotateDefault()" },
113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
114 "devicebuttons/z_hinge3", 114 "devicebuttons/z_hinge3",
115 "QPE/Rotation", "rotateDefault()", 115 "QPE/Rotation", "rotateDefault()",
116 "QPE/Rotation", "rotateDefault()" }, 116 "QPE/Rotation", "rotateDefault()" },
117}; 117};
118 118
119// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 119// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
120// class up into individual classes. We need three classes 120// class up into individual classes. We need three classes
121// 121//
122// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 122// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
123// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 123// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
124// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) 124// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000)
125// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 125// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
126// 126//
127// Only question right now is: Do we really need to do it? Because as soon 127// Only question right now is: Do we really need to do it? Because as soon
128// as the OpenZaurus kernel is ready, there will be a unified interface for all 128// as the OpenZaurus kernel is ready, there will be a unified interface for all
129// Zaurus models (concerning apm, backlight, buttons, etc.) 129// Zaurus models (concerning apm, backlight, buttons, etc.)
130// 130//
131// Comments? - mickeyl. 131// Comments? - mickeyl.
132 132
133void Zaurus::init(const QString& cpu_info) 133void Zaurus::init(const QString& cpu_info)
134{ 134{
135 // Set the time to wait until the system is realy suspended
136 // the delta between apm --suspend and sleeping
137 setAPMTimeOut( 15000 );
138
135 // generic distribution code already scanned /etc/issue at that point - 139 // generic distribution code already scanned /etc/issue at that point -
136 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 140 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
137 if ( d->m_sysverstr.contains( "embedix", false ) ) 141 if ( d->m_sysverstr.contains( "embedix", false ) )
138 { 142 {
139 d->m_vendorstr = "Sharp"; 143 d->m_vendorstr = "Sharp";
140 d->m_vendor = Vendor_Sharp; 144 d->m_vendor = Vendor_Sharp;
141 d->m_systemstr = "Zaurus"; 145 d->m_systemstr = "Zaurus";
142 d->m_system = System_Zaurus; 146 d->m_system = System_Zaurus;
143 m_embedix = true; 147 m_embedix = true;
144 } 148 }
145 else 149 else
146 { 150 {
147 d->m_vendorstr = "OpenZaurus Team"; 151 d->m_vendorstr = "OpenZaurus Team";
148 d->m_systemstr = "OpenZaurus"; 152 d->m_systemstr = "OpenZaurus";
149 d->m_system = System_OpenZaurus; 153 d->m_system = System_OpenZaurus;
150 // sysver already gathered 154 // sysver already gathered
151 155
152 // OpenZaurus sometimes uses the embedix kernel, check if this is one 156 // OpenZaurus sometimes uses the embedix kernel, check if this is one
153 FILE *uname = popen("uname -r", "r"); 157 FILE *uname = popen("uname -r", "r");
154 QFile f; 158 QFile f;
155 QString line; 159 QString line;
156 if ( f.open(IO_ReadOnly, uname) ) { 160 if ( f.open(IO_ReadOnly, uname) ) {
157 QTextStream ts ( &f ); 161 QTextStream ts ( &f );
158 line = ts. readLine(); 162 line = ts. readLine();
159 int loc = line. find ( "embedix" ); 163 int loc = line. find ( "embedix" );
160 if ( loc != -1 ) 164 if ( loc != -1 )
161 m_embedix = true; 165 m_embedix = true;
162 else 166 else
163 m_embedix = false; 167 m_embedix = false;
164 f.close(); 168 f.close();
165 } 169 }
166 pclose(uname); 170 pclose(uname);
167 } 171 }
168 172
169 // check the Zaurus model 173 // check the Zaurus model
170 QString model; 174 QString model;
171 int loc = cpu_info.find( ":" ); 175 int loc = cpu_info.find( ":" );
172 if ( loc != -1 ) 176 if ( loc != -1 )
173 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 177 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
174 else 178 else
175 model = cpu_info; 179 model = cpu_info;
176 180
177 if ( model == "SHARP Corgi" ) { 181 if ( model == "SHARP Corgi" ) {
178 d->m_model = Model_Zaurus_SLC7x0; 182 d->m_model = Model_Zaurus_SLC7x0;
179 d->m_modelstr = "Zaurus SL-C700"; 183 d->m_modelstr = "Zaurus SL-C700";
180 } else if ( model == "SHARP Shepherd" ) { 184 } else if ( model == "SHARP Shepherd" ) {
181 d->m_model = Model_Zaurus_SLC7x0; 185 d->m_model = Model_Zaurus_SLC7x0;
182 d->m_modelstr = "Zaurus SL-C750"; 186 d->m_modelstr = "Zaurus SL-C750";
183 } else if ( model == "SHARP Husky" ) { 187 } else if ( model == "SHARP Husky" ) {
184 d->m_model = Model_Zaurus_SLC7x0; 188 d->m_model = Model_Zaurus_SLC7x0;
185 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 189 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
186 } else if ( model == "SHARP Boxer" ) { 190 } else if ( model == "SHARP Boxer" ) {
187 d->m_model = Model_Zaurus_SLC7x0; 191 d->m_model = Model_Zaurus_SLC7x0;
188 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 192 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
189 } else if ( model == "SHARP Poodle" ) { 193 } else if ( model == "SHARP Poodle" ) {
190 d->m_model = Model_Zaurus_SLB600; 194 d->m_model = Model_Zaurus_SLB600;
191 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 195 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
192 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 196 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
193 d->m_model = Model_Zaurus_SL5500; 197 d->m_model = Model_Zaurus_SL5500;
194 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 198 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
195 } else if ( model == "SHARP Tosa" ) { 199 } else if ( model == "SHARP Tosa" ) {
196 d->m_model = Model_Zaurus_SL6000; 200 d->m_model = Model_Zaurus_SL6000;
197 d->m_modelstr = "Zaurus SL-6000"; 201 d->m_modelstr = "Zaurus SL-6000";
198 } else if ( model == "SHARP Spitz" ) { 202 } else if ( model == "SHARP Spitz" ) {
199 d->m_model = Model_Zaurus_SLC3000; 203 d->m_model = Model_Zaurus_SLC3000;
200 d->m_modelstr = "Zaurus SL-C3000"; 204 d->m_modelstr = "Zaurus SL-C3000";
201 } else { 205 } else {
202 d->m_model = Model_Zaurus_SL5500; 206 d->m_model = Model_Zaurus_SL5500;
203 d->m_modelstr = "Unknown Zaurus"; 207 d->m_modelstr = "Unknown Zaurus";
204 } 208 }
205 209
206 // set initial rotation 210 // set initial rotation
207 switch( d->m_model ) { 211 switch( d->m_model ) {
208 case Model_Zaurus_SL6000: // fallthrough 212 case Model_Zaurus_SL6000: // fallthrough
209 case Model_Zaurus_SLA300: 213 case Model_Zaurus_SLA300:
210 d->m_rotation = Rot0; 214 d->m_rotation = Rot0;
211 break; 215 break;
212 case Model_Zaurus_SLC3000: // fallthrough 216 case Model_Zaurus_SLC3000: // fallthrough
213 case Model_Zaurus_SLC7x0: 217 case Model_Zaurus_SLC7x0:
214 d->m_rotation = rotation(); 218 d->m_rotation = rotation();
215 d->m_direction = direction(); 219 d->m_direction = direction();
216 break; 220 break;
217 case Model_Zaurus_SLB600: // fallthrough 221 case Model_Zaurus_SLB600: // fallthrough
218 case Model_Zaurus_SL5000: // fallthrough 222 case Model_Zaurus_SL5000: // fallthrough
219 case Model_Zaurus_SL5500: // fallthrough 223 case Model_Zaurus_SL5500: // fallthrough
220 default: 224 default:
221 d->m_rotation = Rot270; 225 d->m_rotation = Rot270;
222 break; 226 break;
223 } 227 }
224 m_leds[0] = Led_Off; 228 m_leds[0] = Led_Off;
225 229
226 if ( m_embedix ) 230 if ( m_embedix )
227 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); 231 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr );
228 else 232 else
229 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 233 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
230} 234}
@@ -389,224 +393,192 @@ bool Zaurus::setLedState( OLed which, OLedState st )
389 m_leds [0] = st; 393 m_leds [0] = st;
390 return true; 394 return true;
391 } 395 }
392 } 396 }
393 } 397 }
394 return false; 398 return false;
395} 399}
396 400
397int Zaurus::displayBrightnessResolution() const 401int Zaurus::displayBrightnessResolution() const
398{ 402{
399 int res = 1; 403 int res = 1;
400 if (m_embedix) 404 if (m_embedix)
401 { 405 {
402 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 406 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
403 if ( fd ) 407 if ( fd )
404 { 408 {
405 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 409 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
406 ::close( fd ); 410 ::close( fd );
407 return value ? value : res; 411 return value ? value : res;
408 } 412 }
409 } 413 }
410 else 414 else
411 { 415 {
412 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 416 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
413 if ( fd ) 417 if ( fd )
414 { 418 {
415 char buf[100]; 419 char buf[100];
416 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 420 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
417 ::close( fd ); 421 ::close( fd );
418 } 422 }
419 } 423 }
420 return res; 424 return res;
421} 425}
422 426
423bool Zaurus::setDisplayBrightness( int bright ) 427bool Zaurus::setDisplayBrightness( int bright )
424{ 428{
425 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 429 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
426 bool res = false; 430 bool res = false;
427 431
428 if ( bright > 255 ) bright = 255; 432 if ( bright > 255 ) bright = 255;
429 if ( bright < 0 ) bright = 0; 433 if ( bright < 0 ) bright = 0;
430 434
431 int numberOfSteps = displayBrightnessResolution(); 435 int numberOfSteps = displayBrightnessResolution();
432 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 436 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
433 437
434 if ( m_embedix ) 438 if ( m_embedix )
435 { 439 {
436 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 440 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
437 if ( fd ) 441 if ( fd )
438 { 442 {
439 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 443 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
440 ::close( fd ); 444 ::close( fd );
441 } 445 }
442 } 446 }
443 else 447 else
444 { 448 {
445 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 449 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
446 if ( fd ) 450 if ( fd )
447 { 451 {
448 char buf[100]; 452 char buf[100];
449 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 453 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
450 res = ( ::write( fd, &buf[0], len ) == 0 ); 454 res = ( ::write( fd, &buf[0], len ) == 0 );
451 ::close( fd ); 455 ::close( fd );
452 } 456 }
453 } 457 }
454 return res; 458 return res;
455} 459}
456 460
457bool Zaurus::setDisplayStatus( bool on ) 461bool Zaurus::setDisplayStatus( bool on )
458{ 462{
459 bool res = false; 463 bool res = false;
460 if ( m_embedix ) 464 if ( m_embedix )
461 { 465 {
462 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 466 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
463 if ( fd ) 467 if ( fd )
464 { 468 {
465 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 469 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
466 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 470 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
467 ::close ( fd ); 471 ::close ( fd );
468 } 472 }
469 } 473 }
470 else 474 else
471 { 475 {
472 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 476 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
473 if ( fd ) 477 if ( fd )
474 { 478 {
475 char buf[10]; 479 char buf[10];
476 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 480 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
477 buf[1] = '\0'; 481 buf[1] = '\0';
478 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 482 res = ( ::write( fd, &buf[0], 2 ) == 0 );
479 ::close( fd ); 483 ::close( fd );
480 } 484 }
481 } 485 }
482 return res; 486 return res;
483} 487}
484 488
485bool Zaurus::suspend()
486{
487 qDebug("ODevice::suspend");
488 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
489 return false;
490
491 if ( d->m_model == Model_Unknown ) // better don't suspend on unknown devices
492 return false;
493
494 bool res = false;
495 ODevice::sendSuspendmsg();
496
497 struct timeval tvs, tvn;
498 ::gettimeofday ( &tvs, 0 );
499
500 ::sync(); // flush fs caches
501 res = ( ::system ( "apm --suspend" ) == 0 );
502
503 // This is needed because the apm implementation is asynchronous and we
504 // can not be sure when exactly the device is really suspended
505 if ( res ) {
506 do { // Yes, wait 15 seconds. This APM sucks big time.
507 ::usleep ( 200 * 1000 );
508 ::gettimeofday ( &tvn, 0 );
509 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
510 }
511
512 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
513 return res;
514}
515
516
517Transformation Zaurus::rotation() const 489Transformation Zaurus::rotation() const
518{ 490{
519 qDebug( "Zaurus::rotation()" ); 491 qDebug( "Zaurus::rotation()" );
520 Transformation rot; 492 Transformation rot;
521 493
522 switch ( d->m_model ) { 494 switch ( d->m_model ) {
523 case Model_Zaurus_SLC3000: // fallthrough 495 case Model_Zaurus_SLC3000: // fallthrough
524 case Model_Zaurus_SLC7x0: 496 case Model_Zaurus_SLC7x0:
525 { 497 {
526 OHingeStatus hs = readHingeSensor(); 498 OHingeStatus hs = readHingeSensor();
527 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 499 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
528 500
529 if ( m_embedix ) 501 if ( m_embedix )
530 { 502 {
531 if ( hs == CASE_PORTRAIT ) rot = Rot0; 503 if ( hs == CASE_PORTRAIT ) rot = Rot0;
532 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 504 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
533 else rot = Rot270; 505 else rot = Rot270;
534 } 506 }
535 else 507 else
536 { 508 {
537 if ( hs == CASE_PORTRAIT ) rot = Rot90; 509 if ( hs == CASE_PORTRAIT ) rot = Rot90;
538 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 510 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
539 else rot = Rot0; 511 else rot = Rot0;
540 } 512 }
541 } 513 }
542 break; 514 break;
543 case Model_Zaurus_SL6000: 515 case Model_Zaurus_SL6000:
544 case Model_Zaurus_SLB600: 516 case Model_Zaurus_SLB600:
545 case Model_Zaurus_SLA300: 517 case Model_Zaurus_SLA300:
546 case Model_Zaurus_SL5500: 518 case Model_Zaurus_SL5500:
547 case Model_Zaurus_SL5000: 519 case Model_Zaurus_SL5000:
548 default: 520 default:
549 rot = d->m_rotation; 521 rot = d->m_rotation;
550 break; 522 break;
551 } 523 }
552 524
553 return rot; 525 return rot;
554} 526}
555ODirection Zaurus::direction() const 527ODirection Zaurus::direction() const
556{ 528{
557 ODirection dir; 529 ODirection dir;
558 530
559 switch ( d->m_model ) { 531 switch ( d->m_model ) {
560 case Model_Zaurus_SLC3000: // fallthrough 532 case Model_Zaurus_SLC3000: // fallthrough
561 case Model_Zaurus_SLC7x0: { 533 case Model_Zaurus_SLC7x0: {
562 OHingeStatus hs = readHingeSensor(); 534 OHingeStatus hs = readHingeSensor();
563 if ( hs == CASE_PORTRAIT ) dir = CCW; 535 if ( hs == CASE_PORTRAIT ) dir = CCW;
564 else if ( hs == CASE_UNKNOWN ) dir = CCW; 536 else if ( hs == CASE_UNKNOWN ) dir = CCW;
565 else dir = CW; 537 else dir = CW;
566 } 538 }
567 break; 539 break;
568 case Model_Zaurus_SL6000: 540 case Model_Zaurus_SL6000:
569 case Model_Zaurus_SLA300: 541 case Model_Zaurus_SLA300:
570 case Model_Zaurus_SLB600: 542 case Model_Zaurus_SLB600:
571 case Model_Zaurus_SL5500: 543 case Model_Zaurus_SL5500:
572 case Model_Zaurus_SL5000: 544 case Model_Zaurus_SL5000:
573 default: dir = d->m_direction; 545 default: dir = d->m_direction;
574 break; 546 break;
575 } 547 }
576 return dir; 548 return dir;
577 549
578} 550}
579 551
580bool Zaurus::hasHingeSensor() const 552bool Zaurus::hasHingeSensor() const
581{ 553{
582 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; 554 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
583} 555}
584 556
585OHingeStatus Zaurus::readHingeSensor() const 557OHingeStatus Zaurus::readHingeSensor() const
586{ 558{
587 if (m_embedix) 559 if (m_embedix)
588 { 560 {
589 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 561 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
590 if (handle == -1) 562 if (handle == -1)
591 { 563 {
592 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 564 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
593 return CASE_UNKNOWN; 565 return CASE_UNKNOWN;
594 } 566 }
595 else 567 else
596 { 568 {
597 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 569 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
598 ::close (handle); 570 ::close (handle);
599 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 571 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
600 { 572 {
601 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 573 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
602 return static_cast<OHingeStatus>( retval ); 574 return static_cast<OHingeStatus>( retval );
603 } 575 }
604 else 576 else
605 { 577 {
606 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 578 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
607 return CASE_UNKNOWN; 579 return CASE_UNKNOWN;
608 } 580 }
609 } 581 }
610 } 582 }
611 else 583 else
612 { 584 {
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 80593ce..6e6ca46 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,140 +1,139 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35#ifndef ARRAY_SIZE 35#ifndef ARRAY_SIZE
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37#endif 37#endif
38 38
39// _IO and friends are only defined in kernel headers ... 39// _IO and friends are only defined in kernel headers ...
40#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 40#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
41#define OD_IO(type,number) OD_IOC(0,type,number,0) 41#define OD_IO(type,number) OD_IOC(0,type,number,0)
42#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 42#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
43#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 43#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
44#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 44#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
45 45
46// Audio 46// Audio
47#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 47#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
48 48
49#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 49#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
50#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 50#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
51 51
52#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 52#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
53#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 53#define SHARP_BUZ_KEYSOUND 2 /* key sound */
54#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 54#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
55 55
56#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 56#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
57#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 57#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
58#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 58#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
59#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 59#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
60#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 60#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
61 61
62// LED 62// LED
63#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 63#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
64#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 64#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
65#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 65#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
66 66
67#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 67#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
68#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 68#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
69#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 69#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
70 70
71// Rotation and Power Management 71// Rotation and Power Management
72#define SHARP_IOCTL_GET_ROTATION 0x413c 72#define SHARP_IOCTL_GET_ROTATION 0x413c
73 73
74#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 74#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
75#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 75#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
76#define APM_EVT_POWER_BUTTON (1 << 0) 76#define APM_EVT_POWER_BUTTON (1 << 0)
77 77
78// Brightness Embedix 78// Brightness Embedix
79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" 79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
80#define SHARP_FL_IOCTL_ON 1 80#define SHARP_FL_IOCTL_ON 1
81#define SHARP_FL_IOCTL_OFF 2 81#define SHARP_FL_IOCTL_OFF 2
82#define SHARP_FL_IOCTL_STEP_CONTRAST 100 82#define SHARP_FL_IOCTL_STEP_CONTRAST 100
83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
84#define SHARP_FL_IOCTL_GET_STEP 102 84#define SHARP_FL_IOCTL_GET_STEP 102
85 85
86// Vesa Standard 86// Vesa Standard
87 #define FB_BLANK_UNBLANK 0 87 #define FB_BLANK_UNBLANK 0
88 #define FB_BLANK_POWERDOWN 4 88 #define FB_BLANK_POWERDOWN 4
89 89
90namespace Opie { 90namespace Opie {
91namespace Core { 91namespace Core {
92namespace Internal { 92namespace Internal {
93 93
94class Zaurus : public ODevice 94class Zaurus : public OAbstractMobileDevice
95{ 95{
96 protected: 96 protected:
97 virtual void init(const QString&); 97 virtual void init(const QString&);
98 virtual void initButtons(); 98 virtual void initButtons();
99 99
100 public: 100 public:
101 virtual bool setDisplayBrightness( int b ); 101 virtual bool setDisplayBrightness( int b );
102 virtual bool setDisplayStatus( bool on ); 102 virtual bool setDisplayStatus( bool on );
103 virtual int displayBrightnessResolution() const; 103 virtual int displayBrightnessResolution() const;
104 104
105 virtual void playAlarmSound(); 105 virtual void playAlarmSound();
106 virtual void playKeySound(); 106 virtual void playKeySound();
107 virtual void playTouchSound(); 107 virtual void playTouchSound();
108 108
109 virtual QValueList <OLed> ledList() const; 109 virtual QValueList <OLed> ledList() const;
110 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 110 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
111 virtual OLedState ledState( OLed led ) const; 111 virtual OLedState ledState( OLed led ) const;
112 virtual bool setLedState( OLed led, OLedState st ); 112 virtual bool setLedState( OLed led, OLedState st );
113 113
114 virtual bool hasHingeSensor() const; 114 virtual bool hasHingeSensor() const;
115 virtual OHingeStatus readHingeSensor() const; 115 virtual OHingeStatus readHingeSensor() const;
116 116
117 virtual bool suspend();
118 virtual Transformation rotation() const; 117 virtual Transformation rotation() const;
119 virtual ODirection direction() const; 118 virtual ODirection direction() const;
120 119
121 protected: 120 protected:
122 virtual void buzzer( int snd ); 121 virtual void buzzer( int snd );
123 122
124 OLedState m_leds[1]; 123 OLedState m_leds[1];
125 bool m_embedix; 124 bool m_embedix;
126}; 125};
127 126
128struct z_button { 127struct z_button {
129 Qt::Key code; 128 Qt::Key code;
130 char *utext; 129 char *utext;
131 char *pix; 130 char *pix;
132 char *fpressedservice; 131 char *fpressedservice;
133 char *fpressedaction; 132 char *fpressedaction;
134 char *fheldservice; 133 char *fheldservice;
135 char *fheldaction; 134 char *fheldaction;
136}; 135};
137} 136}
138} 137}
139} 138}
140#endif 139#endif