summaryrefslogtreecommitdiff
authoralwin <alwin>2004-02-19 11:38:19 (UTC)
committer alwin <alwin>2004-02-19 11:38:19 (UTC)
commitb0019ad8b4a0d69dfd98fe4aa599600746eac20f (patch) (unidiff)
tree8a77c163eab658f9cca5c573b8999905f9d26c87
parentfd12f140cefd20ff7658b695c657c3a6a838da19 (diff)
downloadopie-b0019ad8b4a0d69dfd98fe4aa599600746eac20f.zip
opie-b0019ad8b4a0d69dfd98fe4aa599600746eac20f.tar.gz
opie-b0019ad8b4a0d69dfd98fe4aa599600746eac20f.tar.bz2
when going to suspend, a QCopEnvelope message will send
( "QPE/System","aboutSuspend()" )
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp50
-rw-r--r--libopie2/opiecore/device/odevice.h43
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp43
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp43
4 files changed, 94 insertions, 85 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 72b9ac7..7d67efe 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,381 +1,382 @@
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#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie; 63using namespace Opie;
64 64
65ODevice *ODevice::inst() 65ODevice *ODevice::inst()
66{ 66{
67 static ODevice *dev = 0; 67 static ODevice *dev = 0;
68 68
69 // rewrite this to only use /proc/cpuinfo or so 69 // rewrite this to only use /proc/cpuinfo or so
70 70
71 if ( !dev ) 71 if ( !dev )
72 { 72 {
73 QFile f( PATH_PROC_CPUINFO ); 73 QFile f( PATH_PROC_CPUINFO );
74 if ( f.open( IO_ReadOnly ) ) 74 if ( f.open( IO_ReadOnly ) )
75 { 75 {
76 QTextStream s( &f ); 76 QTextStream s( &f );
77 while ( !s.atEnd() ) 77 while ( !s.atEnd() )
78 { 78 {
79 QString line; 79 QString line;
80 line = s.readLine(); 80 line = s.readLine();
81 if ( line.startsWith( "Hardware" ) ) 81 if ( line.startsWith( "Hardware" ) )
82 { 82 {
83 qDebug( "ODevice() - found '%s'", (const char*) line ); 83 qDebug( "ODevice() - found '%s'", (const char*) line );
84 if ( line.contains( "sharp", false ) ) dev = new Zaurus(); 84 if ( line.contains( "sharp", false ) ) dev = new Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); 85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); 86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Jornada(); 87 else if ( line.contains( "jornada", false ) ) dev = new Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Ramses(); 88 else if ( line.contains( "ramses", false ) ) dev = new Ramses();
89 else qWarning( "ODevice() - unknown hardware - using default." ); 89 else qWarning( "ODevice() - unknown hardware - using default." );
90 break; 90 break;
91 } 91 }
92 } 92 }
93 } 93 }
94 else 94 else
95 { 95 {
96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); 96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." );
97 } 97 }
98 if ( !dev ) dev = new ODevice(); 98 if ( !dev ) dev = new ODevice();
99 dev->init(); 99 dev->init();
100 } 100 }
101 return dev; 101 return dev;
102} 102}
103 103
104ODevice::ODevice() 104ODevice::ODevice()
105{ 105{
106 d = new ODeviceData; 106 d = new ODeviceData;
107 107
108 d->m_modelstr = "Unknown"; 108 d->m_modelstr = "Unknown";
109 d->m_model = Model_Unknown; 109 d->m_model = Model_Unknown;
110 d->m_vendorstr = "Unknown"; 110 d->m_vendorstr = "Unknown";
111 d->m_vendor = Vendor_Unknown; 111 d->m_vendor = Vendor_Unknown;
112 d->m_systemstr = "Unknown"; 112 d->m_systemstr = "Unknown";
113 d->m_system = System_Unknown; 113 d->m_system = System_Unknown;
114 d->m_sysverstr = "0.0"; 114 d->m_sysverstr = "0.0";
115 d->m_rotation = Rot0; 115 d->m_rotation = Rot0;
116 d->m_direction = CW; 116 d->m_direction = CW;
117 117
118 d->m_holdtime = 1000; // 1000ms 118 d->m_holdtime = 1000; // 1000ms
119 d->m_buttons = 0; 119 d->m_buttons = 0;
120 d->m_cpu_frequencies = new QStrList; 120 d->m_cpu_frequencies = new QStrList;
121} 121}
122 122
123void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 123void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
124{ 124{
125 if ( msg == "deviceButtonMappingChanged()" ) { 125 if ( msg == "deviceButtonMappingChanged()" ) {
126 reloadButtonMapping(); 126 reloadButtonMapping();
127 } 127 }
128} 128}
129 129
130void ODevice::init() 130void ODevice::init()
131{ 131{
132} 132}
133 133
134/** 134/**
135* This method initialises the button mapping 135* This method initialises the button mapping
136*/ 136*/
137void ODevice::initButtons() 137void ODevice::initButtons()
138{ 138{
139 if ( d->m_buttons ) 139 if ( d->m_buttons )
140 return; 140 return;
141 141
142 qDebug ( "init Buttons" ); 142 qDebug ( "init Buttons" );
143 d->m_buttons = new QValueList <ODeviceButton>; 143 d->m_buttons = new QValueList <ODeviceButton>;
144 144
145 reloadButtonMapping(); 145 reloadButtonMapping();
146 146
147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
148 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 148 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
149} 149}
150 150
151ODevice::~ODevice() 151ODevice::~ODevice()
152{ 152{
153// we leak m_devicebuttons and m_cpu_frequency 153// we leak m_devicebuttons and m_cpu_frequency
154// but it's a singleton and it is not so importantant 154// but it's a singleton and it is not so importantant
155// -zecke 155// -zecke
156 delete d; 156 delete d;
157} 157}
158 158
159bool ODevice::setSoftSuspend ( bool /*soft*/ ) 159bool ODevice::setSoftSuspend ( bool /*soft*/ )
160{ 160{
161 return false; 161 return false;
162} 162}
163 163
164//#include <linux/apm_bios.h> 164//#include <linux/apm_bios.h>
165 165
166#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 166#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
167 167
168/** 168/**
169* This method will try to suspend the device 169* This method will try to suspend the device
170* It only works if the user is the QWS Server and the apm application 170* It only works if the user is the QWS Server and the apm application
171* is installed. 171* is installed.
172* It tries to suspend and then waits some time cause some distributions 172* It tries to suspend and then waits some time cause some distributions
173* do have asynchronus apm implementations. 173* do have asynchronus apm implementations.
174* This method will either fail and return false or it'll suspend the 174* This method will either fail and return false or it'll suspend the
175* device and return once the device got woken up 175* device and return once the device got woken up
176* 176*
177* @return if the device got suspended 177* @return if the device got suspended
178*/ 178*/
179bool ODevice::suspend() 179bool ODevice::suspend()
180{ 180{
181 qDebug("ODevice::suspend"); 181 qDebug("ODevice::suspend");
182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
183 return false; 183 return false;
184 184
185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
186 return false; 186 return false;
187 187
188 bool res = false; 188 bool res = false;
189 189 ODevice::sendSuspendmsg();
190
190 struct timeval tvs, tvn; 191 struct timeval tvs, tvn;
191 ::gettimeofday ( &tvs, 0 ); 192 ::gettimeofday ( &tvs, 0 );
192 193
193 ::sync(); // flush fs caches 194 ::sync(); // flush fs caches
194 res = ( ::system ( "apm --suspend" ) == 0 ); 195 res = ( ::system ( "apm --suspend" ) == 0 );
195 196
196 // This is needed because the iPAQ apm implementation is asynchronous and we 197 // This is needed because the iPAQ apm implementation is asynchronous and we
197 // can not be sure when exactly the device is really suspended 198 // can not be sure when exactly the device is really suspended
198 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
199 200
200 if ( res ) { 201 if ( res ) {
201 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
202 ::usleep ( 200 * 1000 ); 203 ::usleep ( 200 * 1000 );
203 ::gettimeofday ( &tvn, 0 ); 204 ::gettimeofday ( &tvn, 0 );
204 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
205 } 206 }
206 207
207 return res; 208 return res;
208} 209}
209 210
210//#include <linux/fb.h> better not rely on kernel headers in userspace ... 211//#include <linux/fb.h> better not rely on kernel headers in userspace ...
211 212
212#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
213 214
214/* VESA Blanking Levels */ 215/* VESA Blanking Levels */
215#define VESA_NO_BLANKING 0 216#define VESA_NO_BLANKING 0
216#define VESA_VSYNC_SUSPEND 1 217#define VESA_VSYNC_SUSPEND 1
217#define VESA_HSYNC_SUSPEND 2 218#define VESA_HSYNC_SUSPEND 2
218#define VESA_POWERDOWN 3 219#define VESA_POWERDOWN 3
219 220
220/** 221/**
221* This sets the display on or off 222* This sets the display on or off
222*/ 223*/
223bool ODevice::setDisplayStatus ( bool on ) 224bool ODevice::setDisplayStatus ( bool on )
224{ 225{
225 qDebug("ODevice::setDisplayStatus(%d)", on); 226 qDebug("ODevice::setDisplayStatus(%d)", on);
226 227
227 if ( d->m_model == Model_Unknown ) 228 if ( d->m_model == Model_Unknown )
228 return false; 229 return false;
229 230
230 bool res = false; 231 bool res = false;
231 int fd; 232 int fd;
232 233
233 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
234 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
235 ::close ( fd ); 236 ::close ( fd );
236 } 237 }
237 return res; 238 return res;
238} 239}
239 240
240/** 241/**
241* This sets the display brightness 242* This sets the display brightness
242* 243*
243* @param p The brightness to be set on a scale from 0 to 255 244* @param p The brightness to be set on a scale from 0 to 255
244* @return success or failure 245* @return success or failure
245*/ 246*/
246bool ODevice::setDisplayBrightness ( int p) 247bool ODevice::setDisplayBrightness ( int p)
247{ 248{
248 Q_UNUSED( p ) 249 Q_UNUSED( p )
249 return false; 250 return false;
250} 251}
251 252
252/** 253/**
253* @return returns the number of steppings on the brightness slider 254* @return returns the number of steppings on the brightness slider
254* in the Light-'n-Power settings. 255* in the Light-'n-Power settings.
255*/ 256*/
256int ODevice::displayBrightnessResolution() const 257int ODevice::displayBrightnessResolution() const
257{ 258{
258 return 16; 259 return 16;
259} 260}
260 261
261/** 262/**
262* This sets the display contrast 263* This sets the display contrast
263* @param p The contrast to be set on a scale from 0 to 255 264* @param p The contrast to be set on a scale from 0 to 255
264* @return success or failure 265* @return success or failure
265*/ 266*/
266bool ODevice::setDisplayContrast ( int p) 267bool ODevice::setDisplayContrast ( int p)
267{ 268{
268 Q_UNUSED( p ) 269 Q_UNUSED( p )
269 return false; 270 return false;
270} 271}
271 272
272/** 273/**
273* @return return the max value for the brightness settings slider 274* @return return the max value for the brightness settings slider
274* or 0 if the device doesn't support setting of a contrast 275* or 0 if the device doesn't support setting of a contrast
275*/ 276*/
276int ODevice::displayContrastResolution() const 277int ODevice::displayContrastResolution() const
277{ 278{
278 return 0; 279 return 0;
279} 280}
280 281
281/** 282/**
282* This returns the vendor as string 283* This returns the vendor as string
283* @return Vendor as QString 284* @return Vendor as QString
284*/ 285*/
285QString ODevice::vendorString() const 286QString ODevice::vendorString() const
286{ 287{
287 return d->m_vendorstr; 288 return d->m_vendorstr;
288} 289}
289 290
290/** 291/**
291* This returns the vendor as one of the values of OVendor 292* This returns the vendor as one of the values of OVendor
292* @return OVendor 293* @return OVendor
293*/ 294*/
294OVendor ODevice::vendor() const 295OVendor ODevice::vendor() const
295{ 296{
296 return d->m_vendor; 297 return d->m_vendor;
297} 298}
298 299
299/** 300/**
300* This returns the model as a string 301* This returns the model as a string
301* @return A string representing the model 302* @return A string representing the model
302*/ 303*/
303QString ODevice::modelString() const 304QString ODevice::modelString() const
304{ 305{
305 return d->m_modelstr; 306 return d->m_modelstr;
306} 307}
307 308
308/** 309/**
309* This does return the OModel used 310* This does return the OModel used
310*/ 311*/
311OModel ODevice::model() const 312OModel ODevice::model() const
312{ 313{
313 return d->m_model; 314 return d->m_model;
314} 315}
315 316
316/** 317/**
317* This does return the systen name 318* This does return the systen name
318*/ 319*/
319QString ODevice::systemString() const 320QString ODevice::systemString() const
320{ 321{
321 return d->m_systemstr; 322 return d->m_systemstr;
322} 323}
323 324
324/** 325/**
325* Return System as OSystem value 326* Return System as OSystem value
326*/ 327*/
327OSystem ODevice::system() const 328OSystem ODevice::system() const
328{ 329{
329 return d->m_system; 330 return d->m_system;
330} 331}
331 332
332/** 333/**
333* @return the version string of the base system 334* @return the version string of the base system
334*/ 335*/
335QString ODevice::systemVersionString() const 336QString ODevice::systemVersionString() const
336{ 337{
337 return d->m_sysverstr; 338 return d->m_sysverstr;
338} 339}
339 340
340/** 341/**
341* @return the current Transformation 342* @return the current Transformation
342*/ 343*/
343Transformation ODevice::rotation() const 344Transformation ODevice::rotation() const
344{ 345{
345 return d->m_rotation; 346 return d->m_rotation;
346} 347}
347 348
348/** 349/**
349* @return the current rotation direction 350* @return the current rotation direction
350*/ 351*/
351ODirection ODevice::direction() const 352ODirection ODevice::direction() const
352{ 353{
353 return d->m_direction; 354 return d->m_direction;
354} 355}
355 356
356/** 357/**
357* This plays an alarm sound 358* This plays an alarm sound
358*/ 359*/
359void ODevice::playAlarmSound() 360void ODevice::playAlarmSound()
360{ 361{
361#ifndef QT_NO_SOUND 362#ifndef QT_NO_SOUND
362 static Sound snd ( "alarm" ); 363 static Sound snd ( "alarm" );
363 364
364 if ( snd. isFinished()) 365 if ( snd. isFinished())
365 snd. play(); 366 snd. play();
366#endif 367#endif
367} 368}
368 369
369/** 370/**
370* This plays a key sound 371* This plays a key sound
371*/ 372*/
372void ODevice::playKeySound() 373void ODevice::playKeySound()
373{ 374{
374#ifndef QT_NO_SOUND 375#ifndef QT_NO_SOUND
375 static Sound snd ( "keysound" ); 376 static Sound snd ( "keysound" );
376 377
377 if ( snd. isFinished()) 378 if ( snd. isFinished())
378 snd. play(); 379 snd. play();
379#endif 380#endif
380} 381}
381 382
@@ -431,192 +432,197 @@ bool ODevice::setLedState ( OLed which, OLedState st )
431 return false; 432 return false;
432} 433}
433 434
434/** 435/**
435* @return if the device has a light sensor 436* @return if the device has a light sensor
436*/ 437*/
437bool ODevice::hasLightSensor() const 438bool ODevice::hasLightSensor() const
438{ 439{
439 return false; 440 return false;
440} 441}
441 442
442/** 443/**
443* @return a value from the light sensor 444* @return a value from the light sensor
444*/ 445*/
445int ODevice::readLightSensor() 446int ODevice::readLightSensor()
446{ 447{
447 return -1; 448 return -1;
448} 449}
449 450
450/** 451/**
451* @return the light sensor resolution 452* @return the light sensor resolution
452*/ 453*/
453int ODevice::lightSensorResolution() const 454int ODevice::lightSensorResolution() const
454{ 455{
455 return 0; 456 return 0;
456} 457}
457 458
458/** 459/**
459* @return if the device has a hinge sensor 460* @return if the device has a hinge sensor
460*/ 461*/
461bool ODevice::hasHingeSensor() const 462bool ODevice::hasHingeSensor() const
462{ 463{
463 return false; 464 return false;
464} 465}
465 466
466/** 467/**
467* @return a value from the hinge sensor 468* @return a value from the hinge sensor
468*/ 469*/
469OHingeStatus ODevice::readHingeSensor() 470OHingeStatus ODevice::readHingeSensor()
470{ 471{
471 return CASE_UNKNOWN; 472 return CASE_UNKNOWN;
472} 473}
473 474
474/** 475/**
475* @return a list with CPU frequencies supported by the hardware 476* @return a list with CPU frequencies supported by the hardware
476*/ 477*/
477const QStrList &ODevice::allowedCpuFrequencies() const 478const QStrList &ODevice::allowedCpuFrequencies() const
478{ 479{
479 return *d->m_cpu_frequencies; 480 return *d->m_cpu_frequencies;
480} 481}
481 482
482 483
483/** 484/**
484* Set desired CPU frequency 485* Set desired CPU frequency
485* 486*
486* @param index index into d->m_cpu_frequencies of the frequency to be set 487* @param index index into d->m_cpu_frequencies of the frequency to be set
487*/ 488*/
488bool ODevice::setCurrentCpuFrequency(uint index) 489bool ODevice::setCurrentCpuFrequency(uint index)
489{ 490{
490 if (index >= d->m_cpu_frequencies->count()) 491 if (index >= d->m_cpu_frequencies->count())
491 return false; 492 return false;
492 493
493 char *freq = d->m_cpu_frequencies->at(index); 494 char *freq = d->m_cpu_frequencies->at(index);
494 qWarning("set freq to %s", freq); 495 qWarning("set freq to %s", freq);
495 496
496 int fd; 497 int fd;
497 498
498 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 499 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
499 char writeCommand[50]; 500 char writeCommand[50];
500 const int count = sprintf(writeCommand, "%s\n", freq); 501 const int count = sprintf(writeCommand, "%s\n", freq);
501 int res = (::write(fd, writeCommand, count) != -1); 502 int res = (::write(fd, writeCommand, count) != -1);
502 ::close(fd); 503 ::close(fd);
503 return res; 504 return res;
504 } 505 }
505 506
506 return false; 507 return false;
507} 508}
508 509
509 510
510/** 511/**
511* @return a list of hardware buttons 512* @return a list of hardware buttons
512*/ 513*/
513const QValueList <ODeviceButton> &ODevice::buttons() 514const QValueList <ODeviceButton> &ODevice::buttons()
514{ 515{
515 initButtons(); 516 initButtons();
516 517
517 return *d->m_buttons; 518 return *d->m_buttons;
518} 519}
519 520
520/** 521/**
521* @return The amount of time that would count as a hold 522* @return The amount of time that would count as a hold
522*/ 523*/
523uint ODevice::buttonHoldTime() const 524uint ODevice::buttonHoldTime() const
524{ 525{
525 return d->m_holdtime; 526 return d->m_holdtime;
526} 527}
527 528
528/** 529/**
529* This method return a ODeviceButton for a key code 530* This method return a ODeviceButton for a key code
530* or 0 if no special hardware button is available for the device 531* or 0 if no special hardware button is available for the device
531* 532*
532* @return The devicebutton or 0l 533* @return The devicebutton or 0l
533* @see ODeviceButton 534* @see ODeviceButton
534*/ 535*/
535const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 536const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
536{ 537{
537 initButtons(); 538 initButtons();
538 539
539 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 540 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
540 if ( (*it). keycode() == code ) 541 if ( (*it). keycode() == code )
541 return &(*it); 542 return &(*it);
542 } 543 }
543 return 0; 544 return 0;
544} 545}
545 546
546void ODevice::reloadButtonMapping() 547void ODevice::reloadButtonMapping()
547{ 548{
548 initButtons(); 549 initButtons();
549 550
550 Config cfg ( "ButtonSettings" ); 551 Config cfg ( "ButtonSettings" );
551 552
552 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 553 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
553 ODeviceButton &b = ( *d->m_buttons ) [i]; 554 ODeviceButton &b = ( *d->m_buttons ) [i];
554 QString group = "Button" + QString::number ( i ); 555 QString group = "Button" + QString::number ( i );
555 556
556 QCString pch, hch; 557 QCString pch, hch;
557 QCString pm, hm; 558 QCString pm, hm;
558 QByteArray pdata, hdata; 559 QByteArray pdata, hdata;
559 560
560 if ( cfg. hasGroup ( group )) { 561 if ( cfg. hasGroup ( group )) {
561 cfg. setGroup ( group ); 562 cfg. setGroup ( group );
562 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 563 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
563 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 564 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
564 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 565 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
565 566
566 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 567 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
567 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 568 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
568 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 569 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
569 } 570 }
570 571
571 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 572 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
572 573
573 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 574 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
574 } 575 }
575} 576}
576 577
577void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 578void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
578{ 579{
579 initButtons(); 580 initButtons();
580 581
581 QString mb_chan; 582 QString mb_chan;
582 583
583 if ( button >= (int) d->m_buttons->count()) 584 if ( button >= (int) d->m_buttons->count())
584 return; 585 return;
585 586
586 ODeviceButton &b = ( *d->m_buttons ) [button]; 587 ODeviceButton &b = ( *d->m_buttons ) [button];
587 b. setPressedAction ( action ); 588 b. setPressedAction ( action );
588 589
589 mb_chan=b. pressedAction(). channel(); 590 mb_chan=b. pressedAction(). channel();
590 591
591 Config buttonFile ( "ButtonSettings" ); 592 Config buttonFile ( "ButtonSettings" );
592 buttonFile. setGroup ( "Button" + QString::number ( button )); 593 buttonFile. setGroup ( "Button" + QString::number ( button ));
593 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
594 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
595 596
596 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
597 598
598 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
599} 600}
600 601
601void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 602void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
602{ 603{
603 initButtons(); 604 initButtons();
604 605
605 if ( button >= (int) d->m_buttons->count()) 606 if ( button >= (int) d->m_buttons->count())
606 return; 607 return;
607 608
608 ODeviceButton &b = ( *d->m_buttons ) [button]; 609 ODeviceButton &b = ( *d->m_buttons ) [button];
609 b. setHeldAction ( action ); 610 b. setHeldAction ( action );
610 611
611 Config buttonFile ( "ButtonSettings" ); 612 Config buttonFile ( "ButtonSettings" );
612 buttonFile. setGroup ( "Button" + QString::number ( button )); 613 buttonFile. setGroup ( "Button" + QString::number ( button ));
613 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
614 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
615 616
616 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
617 618
618 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
619} 620}
620void ODevice::virtual_hook(int, void* ){ 621void ODevice::virtual_hook(int, void* ){
621 622
622} 623}
624
625void ODevice::sendSuspendmsg()
626{
627 QCopEnvelope ( "QPE/System", "aboutSuspend()" );
628}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 791ccb3..bccb449 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,331 +1,332 @@
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_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie 43namespace Opie
44{ 44{
45 class ODeviceData; 45 class ODeviceData;
46/** 46/**
47 * The available devices 47 * The available devices
48 */ 48 */
49enum OModel { 49enum OModel {
50 Model_Unknown, // = 0 50 Model_Unknown, // = 0
51 51
52 Model_Series_Mask = 0xff000000, 52 Model_Series_Mask = 0xff000000,
53 53
54 Model_iPAQ = ( 1 << 24 ), 54 Model_iPAQ = ( 1 << 24 ),
55 55
56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
63 63
64 Model_Jornada = ( 6 << 24 ), 64 Model_Jornada = ( 6 << 24 ),
65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
66 66
67 Model_Zaurus = ( 2 << 24 ), 67 Model_Zaurus = ( 2 << 24 ),
68 68
69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
73 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 73 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
74 74
75 Model_SIMpad = ( 3 << 24 ), 75 Model_SIMpad = ( 3 << 24 ),
76 76
77 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 77 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
78 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 78 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
79 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 79 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
80 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 80 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
81 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 81 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
82 82
83 Model_Ramses = ( 4 << 24 ), 83 Model_Ramses = ( 4 << 24 ),
84 84
85 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 85 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
86 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 86 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
87 87
88 Model_Yopy = ( 5 << 24 ), 88 Model_Yopy = ( 5 << 24 ),
89 89
90 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 90 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
91 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 91 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
92 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 92 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
93 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 93 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
94 94
95}; 95};
96 96
97/** 97/**
98 * The vendor of the device 98 * The vendor of the device
99 */ 99 */
100enum OVendor { 100enum OVendor {
101 Vendor_Unknown, 101 Vendor_Unknown,
102 102
103 Vendor_HP, 103 Vendor_HP,
104 Vendor_Sharp, 104 Vendor_Sharp,
105 Vendor_SIEMENS, 105 Vendor_SIEMENS,
106 Vendor_MundN, 106 Vendor_MundN,
107 Vendor_GMate, 107 Vendor_GMate,
108}; 108};
109 109
110/** 110/**
111 * The System used 111 * The System used
112 */ 112 */
113enum OSystem { 113enum OSystem {
114 System_Unknown, 114 System_Unknown,
115 115
116 System_Familiar, 116 System_Familiar,
117 System_Zaurus, 117 System_Zaurus,
118 System_OpenZaurus, 118 System_OpenZaurus,
119 System_Linupy, 119 System_Linupy,
120}; 120};
121 121
122enum OLedState { 122enum OLedState {
123 Led_Off, 123 Led_Off,
124 Led_On, 124 Led_On,
125 Led_BlinkSlow, 125 Led_BlinkSlow,
126 Led_BlinkFast 126 Led_BlinkFast
127}; 127};
128 128
129enum OLed { 129enum OLed {
130 Led_Mail, 130 Led_Mail,
131 Led_Power, 131 Led_Power,
132 Led_BlueTooth 132 Led_BlueTooth
133}; 133};
134 134
135enum OHardKey { 135enum OHardKey {
136 HardKey_Datebook = Qt::Key_F9, 136 HardKey_Datebook = Qt::Key_F9,
137 HardKey_Contacts = Qt::Key_F10, 137 HardKey_Contacts = Qt::Key_F10,
138 HardKey_Menu = Qt::Key_F11, 138 HardKey_Menu = Qt::Key_F11,
139 HardKey_Home = Qt::Key_F12, 139 HardKey_Home = Qt::Key_F12,
140 HardKey_Mail = Qt::Key_F13, 140 HardKey_Mail = Qt::Key_F13,
141 HardKey_Record = Qt::Key_F24, 141 HardKey_Record = Qt::Key_F24,
142 HardKey_Suspend = Qt::Key_F34, 142 HardKey_Suspend = Qt::Key_F34,
143 HardKey_Backlight = Qt::Key_F35, 143 HardKey_Backlight = Qt::Key_F35,
144 HardKey_Action = Qt::Key_F10, 144 HardKey_Action = Qt::Key_F10,
145 HardKey_OK = Qt::Key_F11, 145 HardKey_OK = Qt::Key_F11,
146 HardKey_End = Qt::Key_F12, 146 HardKey_End = Qt::Key_F12,
147}; 147};
148 148
149enum ODirection { 149enum ODirection {
150 CW = 0, 150 CW = 0,
151 CCW = 1, 151 CCW = 1,
152 Flip = 2, 152 Flip = 2,
153}; 153};
154 154
155enum OHingeStatus { 155enum OHingeStatus {
156 CASE_CLOSED = 3, 156 CASE_CLOSED = 3,
157 CASE_PORTRAIT = 2, 157 CASE_PORTRAIT = 2,
158 CASE_LANDSCAPE = 0, 158 CASE_LANDSCAPE = 0,
159 CASE_UNKNOWN = 1, 159 CASE_UNKNOWN = 1,
160}; 160};
161 161
162/** 162/**
163 * A singleton which gives informations about device specefic option 163 * A singleton which gives informations about device specefic option
164 * like the Hardware used, LEDs, the Base Distribution and 164 * like the Hardware used, LEDs, the Base Distribution and
165 * hardware key mappings. 165 * hardware key mappings.
166 * 166 *
167 * @short A small class for device specefic options 167 * @short A small class for device specefic options
168 * @see QObject 168 * @see QObject
169 * @author Robert Griebl 169 * @author Robert Griebl
170 * @version 1.0 170 * @version 1.0
171 */ 171 */
172class ODevice : public QObject 172class ODevice : public QObject
173{ 173{
174 Q_OBJECT 174 Q_OBJECT
175 175
176private: 176private:
177 /* disable copy */ 177 /* disable copy */
178 ODevice ( const ODevice & ); 178 ODevice ( const ODevice & );
179 179
180protected: 180protected:
181 ODevice(); 181 ODevice();
182 virtual void init(); 182 virtual void init();
183 virtual void initButtons(); 183 virtual void initButtons();
184 static void sendSuspendmsg();
184 185
185 ODeviceData *d; 186 ODeviceData *d;
186 187
187public: 188public:
188 // sandman do we want to allow destructions? -zecke? 189 // sandman do we want to allow destructions? -zecke?
189 virtual ~ODevice(); 190 virtual ~ODevice();
190 191
191 static ODevice *inst(); 192 static ODevice *inst();
192 193
193 // information 194 // information
194 195
195 QString modelString() const; 196 QString modelString() const;
196 OModel model() const; 197 OModel model() const;
197 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 198 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
198 199
199 QString vendorString() const; 200 QString vendorString() const;
200 OVendor vendor() const; 201 OVendor vendor() const;
201 202
202 QString systemString() const; 203 QString systemString() const;
203 OSystem system() const; 204 OSystem system() const;
204 205
205 QString systemVersionString() const; 206 QString systemVersionString() const;
206 207
207 virtual Transformation rotation() const; 208 virtual Transformation rotation() const;
208 virtual ODirection direction() const; 209 virtual ODirection direction() const;
209 210
210 // system 211 // system
211 212
212 virtual bool setSoftSuspend ( bool on ); 213 virtual bool setSoftSuspend ( bool on );
213 virtual bool suspend(); 214 virtual bool suspend();
214 215
215 virtual bool setDisplayStatus ( bool on ); 216 virtual bool setDisplayStatus ( bool on );
216 virtual bool setDisplayBrightness ( int brightness ); 217 virtual bool setDisplayBrightness ( int brightness );
217 virtual int displayBrightnessResolution() const; 218 virtual int displayBrightnessResolution() const;
218 virtual bool setDisplayContrast ( int contrast ); 219 virtual bool setDisplayContrast ( int contrast );
219 virtual int displayContrastResolution() const; 220 virtual int displayContrastResolution() const;
220 221
221 // don't add new virtual methods, use this: 222 // don't add new virtual methods, use this:
222 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 223 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
223 // and in your subclass do do overwrite 224 // and in your subclass do do overwrite
224 //protected virtual int virtual_hook(int, void *) 225 //protected virtual int virtual_hook(int, void *)
225 // which is defined below 226 // which is defined below
226 227
227 // input / output 228 // input / output
228 virtual void playAlarmSound(); 229 virtual void playAlarmSound();
229 virtual void playKeySound(); 230 virtual void playKeySound();
230 virtual void playTouchSound(); 231 virtual void playTouchSound();
231 232
232 virtual QValueList <OLed> ledList() const; 233 virtual QValueList <OLed> ledList() const;
233 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 234 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
234 virtual OLedState ledState ( OLed led ) const; 235 virtual OLedState ledState ( OLed led ) const;
235 virtual bool setLedState ( OLed led, OLedState st ); 236 virtual bool setLedState ( OLed led, OLedState st );
236 237
237 virtual bool hasLightSensor() const; 238 virtual bool hasLightSensor() const;
238 virtual int readLightSensor(); 239 virtual int readLightSensor();
239 virtual int lightSensorResolution() const; 240 virtual int lightSensorResolution() const;
240 241
241 virtual bool hasHingeSensor() const; 242 virtual bool hasHingeSensor() const;
242 virtual OHingeStatus readHingeSensor(); 243 virtual OHingeStatus readHingeSensor();
243 244
244 const QStrList &allowedCpuFrequencies() const; 245 const QStrList &allowedCpuFrequencies() const;
245 bool setCurrentCpuFrequency(uint index); 246 bool setCurrentCpuFrequency(uint index);
246 247
247 /** 248 /**
248 * Returns the available buttons on this device. The number and location 249 * Returns the available buttons on this device. The number and location
249 * of buttons will vary depending on the device. Button numbers will be assigned 250 * of buttons will vary depending on the device. Button numbers will be assigned
250 * by the device manufacturer and will be from most preferred button to least preffered 251 * by the device manufacturer and will be from most preferred button to least preffered
251 * button. Note that this list only contains "user mappable" buttons. 252 * button. Note that this list only contains "user mappable" buttons.
252 * 253 *
253 * @todo Make method const and take care of calling initButtons or make that const too 254 * @todo Make method const and take care of calling initButtons or make that const too
254 * 255 *
255 */ 256 */
256 const QValueList<ODeviceButton> &buttons(); 257 const QValueList<ODeviceButton> &buttons();
257 258
258 /** 259 /**
259 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 260 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
260 * returns 0L 261 * returns 0L
261 */ 262 */
262 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 263 const ODeviceButton *buttonForKeycode ( ushort keyCode );
263 264
264 /** 265 /**
265 * Reassigns the pressed action for \a button. To return to the factory 266 * Reassigns the pressed action for \a button. To return to the factory
266 * default pass an empty string as \a qcopMessage. 267 * default pass an empty string as \a qcopMessage.
267 */ 268 */
268 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 269 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
269 270
270 /** 271 /**
271 * Reassigns the held action for \a button. To return to the factory 272 * Reassigns the held action for \a button. To return to the factory
272 * default pass an empty string as \a qcopMessage. 273 * default pass an empty string as \a qcopMessage.
273 */ 274 */
274 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 275 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
275 276
276 /** 277 /**
277 * How long (in ms) you have to press a button for a "hold" action 278 * How long (in ms) you have to press a button for a "hold" action
278 */ 279 */
279 uint buttonHoldTime() const; 280 uint buttonHoldTime() const;
280 281
281signals: 282signals:
282 void buttonMappingChanged(); 283 void buttonMappingChanged();
283 284
284private slots: 285private slots:
285 void systemMessage ( const QCString &, const QByteArray & ); 286 void systemMessage ( const QCString &, const QByteArray & );
286 287
287protected: 288protected:
288 void reloadButtonMapping(); 289 void reloadButtonMapping();
289 /* ugly virtual hook */ 290 /* ugly virtual hook */
290 virtual void virtual_hook( int id, void* data ); 291 virtual void virtual_hook( int id, void* data );
291}; 292};
292 293
293class ODeviceData { 294class ODeviceData {
294 295
295 public: 296 public:
296 QString m_vendorstr; 297 QString m_vendorstr;
297 OVendor m_vendor; 298 OVendor m_vendor;
298 299
299 QString m_modelstr; 300 QString m_modelstr;
300 OModel m_model; 301 OModel m_model;
301 302
302 QString m_systemstr; 303 QString m_systemstr;
303 OSystem m_system; 304 OSystem m_system;
304 305
305 QString m_sysverstr; 306 QString m_sysverstr;
306 307
307 Transformation m_rotation; 308 Transformation m_rotation;
308 ODirection m_direction; 309 ODirection m_direction;
309 310
310 QValueList <ODeviceButton> *m_buttons; 311 QValueList <ODeviceButton> *m_buttons;
311 uint m_holdtime; 312 uint m_holdtime;
312 QStrList *m_cpu_frequencies; 313 QStrList *m_cpu_frequencies;
313}; 314};
314 315
315} 316}
316 317
317static inline bool isQWS() 318static inline bool isQWS()
318{ 319{
319 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 320 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
320} 321}
321 322
322static QCString makeChannel ( const char *str ) 323static QCString makeChannel ( const char *str )
323{ 324{
324 if ( str && !::strchr ( str, '/' )) 325 if ( str && !::strchr ( str, '/' ))
325 return QCString ( "QPE/Application/" ) + str; 326 return QCString ( "QPE/Application/" ) + str;
326 else 327 else
327 return str; 328 return str;
328} 329}
329 330
330#endif 331#endif
331 332
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 4397b78..31b9297 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,391 +1,392 @@
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#include "odevice_simpad.h" 30#include "odevice_simpad.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58struct s_button simpad_buttons [] = { 58struct s_button simpad_buttons [] = {
59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
61 "devicebuttons/simpad_lower_up", 61 "devicebuttons/simpad_lower_up",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
66 "devicebuttons/simpad_lower_down", 66 "devicebuttons/simpad_lower_down",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
71 "devicebuttons/simpad_lower_right", 71 "devicebuttons/simpad_lower_right",
72 "QPE/TaskBar", "toggleMenu()", 72 "QPE/TaskBar", "toggleMenu()",
73 "QPE/TaskBar", "toggleStartMenu()" }, 73 "QPE/TaskBar", "toggleStartMenu()" },
74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
76 "devicebuttons/simpad_lower_left", 76 "devicebuttons/simpad_lower_left",
77 "mail", "raise()", 77 "mail", "raise()",
78 "mail", "newMail()" }, 78 "mail", "newMail()" },
79 79
80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
82 "devicebuttons/simpad_upper_up", 82 "devicebuttons/simpad_upper_up",
83 "QPE/Launcher", "home()", 83 "QPE/Launcher", "home()",
84 "buttonsettings", "raise()" }, 84 "buttonsettings", "raise()" },
85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
87 "devicebuttons/simpad_upper_down", 87 "devicebuttons/simpad_upper_down",
88 "addressbook", "raise()", 88 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 89 "addressbook", "beamBusinessCard()" },
90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
92 "devicebuttons/simpad_upper_right", 92 "devicebuttons/simpad_upper_right",
93 "QPE/TaskBar", "toggleMenu()", 93 "QPE/TaskBar", "toggleMenu()",
94 "QPE/TaskBar", "toggleStartMenu()" }, 94 "QPE/TaskBar", "toggleStartMenu()" },
95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
97 "devicebuttons/simpad_upper_left", 97 "devicebuttons/simpad_upper_left",
98 "QPE/Rotation", "flip()", 98 "QPE/Rotation", "flip()",
99 "QPE/Rotation", "flip()" }, 99 "QPE/Rotation", "flip()" },
100 /* 100 /*
101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
103 "devicebuttons/simpad_lower_upper", 103 "devicebuttons/simpad_lower_upper",
104 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
105 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
106 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 106 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
108 "devicebuttons/simpad_upper_lower", 108 "devicebuttons/simpad_upper_lower",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 */ 111 */
112}; 112};
113 113
114void SIMpad::init() 114void SIMpad::init()
115{ 115{
116 d->m_vendorstr = "SIEMENS"; 116 d->m_vendorstr = "SIEMENS";
117 d->m_vendor = Vendor_SIEMENS; 117 d->m_vendor = Vendor_SIEMENS;
118 118
119 QFile f ( "/proc/hal/model" ); 119 QFile f ( "/proc/hal/model" );
120 120
121 //TODO Implement model checking 121 //TODO Implement model checking
122 //FIXME For now we assume an SL4 122 //FIXME For now we assume an SL4
123 123
124 d->m_modelstr = "SL4"; 124 d->m_modelstr = "SL4";
125 d->m_model = Model_SIMpad_SL4; 125 d->m_model = Model_SIMpad_SL4;
126 126
127 switch ( d->m_model ) { 127 switch ( d->m_model ) {
128 default: 128 default:
129 d->m_rotation = Rot0; 129 d->m_rotation = Rot0;
130 d->m_direction = CCW; 130 d->m_direction = CCW;
131 d->m_holdtime = 1000; // 1000ms 131 d->m_holdtime = 1000; // 1000ms
132 132
133 break; 133 break;
134 } 134 }
135 135
136 f. setName ( "/etc/familiar-version" ); 136 f. setName ( "/etc/familiar-version" );
137 if ( f. open ( IO_ReadOnly )) { 137 if ( f. open ( IO_ReadOnly )) {
138 d->m_systemstr = "Familiar"; 138 d->m_systemstr = "Familiar";
139 d->m_system = System_Familiar; 139 d->m_system = System_Familiar;
140 140
141 QTextStream ts ( &f ); 141 QTextStream ts ( &f );
142 d->m_sysverstr = ts. readLine(). mid ( 10 ); 142 d->m_sysverstr = ts. readLine(). mid ( 10 );
143 143
144 f. close(); 144 f. close();
145 } else { 145 } else {
146 f. setName ( "/etc/oz_version" ); 146 f. setName ( "/etc/oz_version" );
147 147
148 if ( f. open ( IO_ReadOnly )) { 148 if ( f. open ( IO_ReadOnly )) {
149 d->m_systemstr = "OpenEmbedded/SIMpad"; 149 d->m_systemstr = "OpenEmbedded/SIMpad";
150 d->m_system = System_OpenZaurus; 150 d->m_system = System_OpenZaurus;
151 151
152 QTextStream ts ( &f ); 152 QTextStream ts ( &f );
153 ts.setDevice ( &f ); 153 ts.setDevice ( &f );
154 d->m_sysverstr = ts. readLine(); 154 d->m_sysverstr = ts. readLine();
155 f. close(); 155 f. close();
156 } 156 }
157 } 157 }
158 158
159 m_leds [0] = m_leds [1] = Led_Off; 159 m_leds [0] = m_leds [1] = Led_Off;
160 160
161 m_power_timer = 0; 161 m_power_timer = 0;
162 162
163} 163}
164 164
165void SIMpad::initButtons() 165void SIMpad::initButtons()
166{ 166{
167 if ( d->m_buttons ) 167 if ( d->m_buttons )
168 return; 168 return;
169 169
170 if ( isQWS( ) ) 170 if ( isQWS( ) )
171 QWSServer::setKeyboardFilter ( this ); 171 QWSServer::setKeyboardFilter ( this );
172 172
173 d->m_buttons = new QValueList <ODeviceButton>; 173 d->m_buttons = new QValueList <ODeviceButton>;
174 174
175 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 175 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
176 s_button *sb = simpad_buttons + i; 176 s_button *sb = simpad_buttons + i;
177 ODeviceButton b; 177 ODeviceButton b;
178 178
179 if (( sb->model & d->m_model ) == d->m_model ) { 179 if (( sb->model & d->m_model ) == d->m_model ) {
180 b. setKeycode ( sb->code ); 180 b. setKeycode ( sb->code );
181 b. setUserText ( QObject::tr ( "Button", sb->utext )); 181 b. setUserText ( QObject::tr ( "Button", sb->utext ));
182 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 182 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
183 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 183 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
184 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 184 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
185 185
186 d->m_buttons->append ( b ); 186 d->m_buttons->append ( b );
187 } 187 }
188 } 188 }
189 reloadButtonMapping(); 189 reloadButtonMapping();
190 190
191 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 191 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
192 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 192 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
193} 193}
194 194
195// SIMpad boardcontrol register CS3 195// SIMpad boardcontrol register CS3
196#define SIMPAD_BOARDCONTROL "/proc/cs3" 196#define SIMPAD_BOARDCONTROL "/proc/cs3"
197#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 197#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
198#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 198#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
199#define SIMPAD_EN1 0x0004 // This is only for EPROM's 199#define SIMPAD_EN1 0x0004 // This is only for EPROM's
200#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 200#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
201#define SIMPAD_DISPLAY_ON 0x0010 201#define SIMPAD_DISPLAY_ON 0x0010
202#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 202#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
203#define SIMPAD_MQ_RESET 0x0040 203#define SIMPAD_MQ_RESET 0x0040
204#define SIMPAD_PCMCIA_RESET 0x0080 204#define SIMPAD_PCMCIA_RESET 0x0080
205#define SIMPAD_DECT_POWER_ON 0x0100 205#define SIMPAD_DECT_POWER_ON 0x0100
206#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 206#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
207#define SIMPAD_RS232_ON 0x0400 207#define SIMPAD_RS232_ON 0x0400
208#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 208#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
209#define SIMPAD_LED2_ON 0x1000 209#define SIMPAD_LED2_ON 0x1000
210#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 210#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
211#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 211#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
212#define SIMPAD_RESET_SIMCARD 0x8000 212#define SIMPAD_RESET_SIMCARD 0x8000
213 213
214//SIMpad touchscreen backlight strength control 214//SIMpad touchscreen backlight strength control
215#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 215#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
216#define SIMPAD_BACKLIGHT_MASK 0x00a10044 216#define SIMPAD_BACKLIGHT_MASK 0x00a10044
217 217
218QValueList <OLed> SIMpad::ledList() const 218QValueList <OLed> SIMpad::ledList() const
219{ 219{
220 QValueList <OLed> vl; 220 QValueList <OLed> vl;
221 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 221 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
222 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 222 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
223 return vl; 223 return vl;
224} 224}
225 225
226QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 226QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
227{ 227{
228 QValueList <OLedState> vl; 228 QValueList <OLedState> vl;
229 229
230 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 230 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
231 vl << Led_Off << Led_On; 231 vl << Led_Off << Led_On;
232 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 232 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
233 //vl << Led_Off; 233 //vl << Led_Off;
234 return vl; 234 return vl;
235} 235}
236 236
237OLedState SIMpad::ledState ( OLed l ) const 237OLedState SIMpad::ledState ( OLed l ) const
238{ 238{
239 switch ( l ) { 239 switch ( l ) {
240 case Led_Power: 240 case Led_Power:
241 return m_leds [0]; 241 return m_leds [0];
242 //case Led_Mail: 242 //case Led_Mail:
243 //return m_leds [1]; 243 //return m_leds [1];
244 default: 244 default:
245 return Led_Off; 245 return Led_Off;
246 } 246 }
247} 247}
248 248
249bool SIMpad::setLedState ( OLed l, OLedState st ) 249bool SIMpad::setLedState ( OLed l, OLedState st )
250{ 250{
251#if 0 251#if 0
252 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 252 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
253 253
254 /*TODO Implement this like that: 254 /*TODO Implement this like that:
255 read from cs3 255 read from cs3
256 && with SIMPAD_LED2_ON 256 && with SIMPAD_LED2_ON
257 write to cs3 */ 257 write to cs3 */
258 m_leds [0] = st; 258 m_leds [0] = st;
259 return true; 259 return true;
260 } 260 }
261 } 261 }
262 } 262 }
263 263
264#endif 264#endif
265 return false; 265 return false;
266} 266}
267 267
268 268
269bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 269bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
270{ 270{
271 //TODO 271 //TODO
272 return false; 272 return false;
273} 273}
274 274
275void SIMpad::timerEvent ( QTimerEvent * ) 275void SIMpad::timerEvent ( QTimerEvent * )
276{ 276{
277 killTimer ( m_power_timer ); 277 killTimer ( m_power_timer );
278 m_power_timer = 0; 278 m_power_timer = 0;
279 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 279 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
281} 281}
282 282
283 283
284void SIMpad::playAlarmSound() 284void SIMpad::playAlarmSound()
285{ 285{
286#ifndef QT_NO_SOUND 286#ifndef QT_NO_SOUND
287 static Sound snd ( "alarm" ); 287 static Sound snd ( "alarm" );
288 int fd; 288 int fd;
289 int vol; 289 int vol;
290 bool vol_reset = false; 290 bool vol_reset = false;
291 291
292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
294 Config cfg ( "qpe" ); 294 Config cfg ( "qpe" );
295 cfg. setGroup ( "Volume" ); 295 cfg. setGroup ( "Volume" );
296 296
297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
298 if ( volalarm < 0 ) 298 if ( volalarm < 0 )
299 volalarm = 0; 299 volalarm = 0;
300 else if ( volalarm > 100 ) 300 else if ( volalarm > 100 )
301 volalarm = 100; 301 volalarm = 100;
302 volalarm |= ( volalarm << 8 ); 302 volalarm |= ( volalarm << 8 );
303 303
304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
305 vol_reset = true; 305 vol_reset = true;
306 } 306 }
307 } 307 }
308 308
309 snd. play(); 309 snd. play();
310 while ( !snd. isFinished()) 310 while ( !snd. isFinished())
311 qApp->processEvents(); 311 qApp->processEvents();
312 312
313 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
314 if ( vol_reset ) 314 if ( vol_reset )
315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
316 ::close ( fd ); 316 ::close ( fd );
317 } 317 }
318#endif 318#endif
319} 319}
320 320
321 321
322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
323{ 323{
324 qDebug( "ODevice for SIMpad: suspend()" ); 324 qDebug( "ODevice for SIMpad: suspend()" );
325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
326 return false; 326 return false;
327 327
328 bool res = false; 328 bool res = false;
329 ODevice::sendSuspendmsg();
329 330
330 struct timeval tvs, tvn; 331 struct timeval tvs, tvn;
331 ::gettimeofday ( &tvs, 0 ); 332 ::gettimeofday ( &tvs, 0 );
332 333
333 ::sync(); // flush fs caches 334 ::sync(); // flush fs caches
334 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 335 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
335 336
336 return res; 337 return res;
337} 338}
338 339
339 340
340bool SIMpad::setSoftSuspend ( bool soft ) 341bool SIMpad::setSoftSuspend ( bool soft )
341{ 342{
342 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 343 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
343 return false; 344 return false;
344} 345}
345 346
346 347
347bool SIMpad::setDisplayStatus ( bool on ) 348bool SIMpad::setDisplayStatus ( bool on )
348{ 349{
349 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 350 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
350 351
351 bool res = false; 352 bool res = false;
352 int fd; 353 int fd;
353 354
354 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 355 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
355 356
356 res = ( ::system( (const char*) cmdline ) == 0 ); 357 res = ( ::system( (const char*) cmdline ) == 0 );
357 358
358 return res; 359 return res;
359} 360}
360 361
361 362
362bool SIMpad::setDisplayBrightness ( int bright ) 363bool SIMpad::setDisplayBrightness ( int bright )
363{ 364{
364 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 365 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
365 bool res = false; 366 bool res = false;
366 int fd; 367 int fd;
367 368
368 if ( bright > 255 ) 369 if ( bright > 255 )
369 bright = 255; 370 bright = 255;
370 if ( bright < 1 ) 371 if ( bright < 1 )
371 bright = 0; 372 bright = 0;
372 373
373 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 374 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
374 int value = 255 - bright; 375 int value = 255 - bright;
375 const int mask = SIMPAD_BACKLIGHT_MASK; 376 const int mask = SIMPAD_BACKLIGHT_MASK;
376 value = value << 8; 377 value = value << 8;
377 value += mask; 378 value += mask;
378 char writeCommand[100]; 379 char writeCommand[100];
379 const int count = sprintf( writeCommand, "0x%x\n", value ); 380 const int count = sprintf( writeCommand, "0x%x\n", value );
380 res = ( ::write ( fd, writeCommand, count ) != -1 ); 381 res = ( ::write ( fd, writeCommand, count ) != -1 );
381 ::close ( fd ); 382 ::close ( fd );
382 } 383 }
383 return res; 384 return res;
384} 385}
385 386
386 387
387int SIMpad::displayBrightnessResolution() const 388int SIMpad::displayBrightnessResolution() const
388{ 389{
389 return 255; // All SIMpad models share the same display 390 return 255; // All SIMpad models share the same display
390} 391}
391 392
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 8bff770..9d23a12 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,216 +1,216 @@
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#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58struct z_button z_buttons [] = { 58struct z_button z_buttons [] = {
59 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 59 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
60 "devicebuttons/z_calendar", 60 "devicebuttons/z_calendar",
61 "datebook", "nextView()", 61 "datebook", "nextView()",
62 "today", "raise()" }, 62 "today", "raise()" },
63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
64 "devicebuttons/z_contact", 64 "devicebuttons/z_contact",
65 "addressbook", "raise()", 65 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 66 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
68 "devicebuttons/z_home", 68 "devicebuttons/z_home",
69 "QPE/Launcher", "home()", 69 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 70 "buttonsettings", "raise()" },
71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
72 "devicebuttons/z_menu", 72 "devicebuttons/z_menu",
73 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
74 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
75 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 75 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
76 "devicebuttons/z_mail", 76 "devicebuttons/z_mail",
77 "mail", "raise()", 77 "mail", "raise()",
78 "mail", "newMail()" }, 78 "mail", "newMail()" },
79}; 79};
80 80
81struct z_button z_buttons_c700 [] = { 81struct z_button z_buttons_c700 [] = {
82 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 82 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
83 "devicebuttons/z_calendar", 83 "devicebuttons/z_calendar",
84 "datebook", "nextView()", 84 "datebook", "nextView()",
85 "today", "raise()" }, 85 "today", "raise()" },
86 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 86 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
87 "devicebuttons/z_contact", 87 "devicebuttons/z_contact",
88 "addressbook", "raise()", 88 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 89 "addressbook", "beamBusinessCard()" },
90 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 90 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
91 "devicebuttons/z_home", 91 "devicebuttons/z_home",
92 "QPE/Launcher", "home()", 92 "QPE/Launcher", "home()",
93 "buttonsettings", "raise()" }, 93 "buttonsettings", "raise()" },
94 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 94 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
95 "devicebuttons/z_menu", 95 "devicebuttons/z_menu",
96 "QPE/TaskBar", "toggleMenu()", 96 "QPE/TaskBar", "toggleMenu()",
97 "QPE/TaskBar", "toggleStartMenu()" }, 97 "QPE/TaskBar", "toggleStartMenu()" },
98 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 98 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
99 "devicebuttons/z_hinge", 99 "devicebuttons/z_hinge",
100 "QPE/Rotation", "rotateDefault()", 100 "QPE/Rotation", "rotateDefault()",
101 "QPE/Dummy", "doNothing()" }, 101 "QPE/Dummy", "doNothing()" },
102}; 102};
103 103
104// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 104// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
105// class up into individual classes. We need three classes 105// class up into individual classes. We need three classes
106// 106//
107// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 107// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
108// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 108// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
109// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 109// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
110// 110//
111// Only question right now is: Do we really need to do it? Because as soon 111// Only question right now is: Do we really need to do it? Because as soon
112// as the OpenZaurus kernel is ready, there will be a unified interface for all 112// as the OpenZaurus kernel is ready, there will be a unified interface for all
113// Zaurus models (concerning apm, backlight, buttons, etc.) 113// Zaurus models (concerning apm, backlight, buttons, etc.)
114// 114//
115// Comments? - mickeyl. 115// Comments? - mickeyl.
116 116
117void Zaurus::init() 117void Zaurus::init()
118{ 118{
119 d->m_vendorstr = "Sharp"; 119 d->m_vendorstr = "Sharp";
120 d->m_vendor = Vendor_Sharp; 120 d->m_vendor = Vendor_Sharp;
121 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 121 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
122 122
123 // QFile f ( "/proc/filesystems" ); 123 // QFile f ( "/proc/filesystems" );
124 QString model; 124 QString model;
125 125
126 // It isn't a good idea to check the system configuration to 126 // It isn't a good idea to check the system configuration to
127 // detect the distribution ! 127 // detect the distribution !
128 // Otherwise it may happen that any other distribution is detected as openzaurus, just 128 // Otherwise it may happen that any other distribution is detected as openzaurus, just
129 // because it uses a jffs2 filesystem.. 129 // because it uses a jffs2 filesystem..
130 // (eilers) 130 // (eilers)
131 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { 131 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
132 QFile f ("/etc/oz_version"); 132 QFile f ("/etc/oz_version");
133 if ( f.exists() ){ 133 if ( f.exists() ){
134 d->m_vendorstr = "OpenZaurus Team"; 134 d->m_vendorstr = "OpenZaurus Team";
135 d->m_systemstr = "OpenZaurus"; 135 d->m_systemstr = "OpenZaurus";
136 d->m_system = System_OpenZaurus; 136 d->m_system = System_OpenZaurus;
137 137
138 if ( f. open ( IO_ReadOnly )) { 138 if ( f. open ( IO_ReadOnly )) {
139 QTextStream ts ( &f ); 139 QTextStream ts ( &f );
140 d->m_sysverstr = ts. readLine();//. mid ( 10 ); 140 d->m_sysverstr = ts. readLine();//. mid ( 10 );
141 f. close(); 141 f. close();
142 } 142 }
143 143
144 // Openzaurus sometimes uses the embedix kernel! 144 // Openzaurus sometimes uses the embedix kernel!
145 // => Check whether this is an embedix kernel 145 // => Check whether this is an embedix kernel
146 FILE *uname = popen("uname -r", "r"); 146 FILE *uname = popen("uname -r", "r");
147 QString line; 147 QString line;
148 if ( f.open(IO_ReadOnly, uname) ) { 148 if ( f.open(IO_ReadOnly, uname) ) {
149 QTextStream ts ( &f ); 149 QTextStream ts ( &f );
150 line = ts. readLine(); 150 line = ts. readLine();
151 int loc = line. find ( "embedix" ); 151 int loc = line. find ( "embedix" );
152 if ( loc != -1 ) 152 if ( loc != -1 )
153 m_embedix = true; 153 m_embedix = true;
154 else 154 else
155 m_embedix = false; 155 m_embedix = false;
156 f. close(); 156 f. close();
157 } 157 }
158 pclose(uname); 158 pclose(uname);
159 } 159 }
160 else { 160 else {
161 d->m_systemstr = "Zaurus"; 161 d->m_systemstr = "Zaurus";
162 d->m_system = System_Zaurus; 162 d->m_system = System_Zaurus;
163 } 163 }
164 164
165 f. setName ( "/proc/cpuinfo" ); 165 f. setName ( "/proc/cpuinfo" );
166 if ( f. open ( IO_ReadOnly ) ) { 166 if ( f. open ( IO_ReadOnly ) ) {
167 QTextStream ts ( &f ); 167 QTextStream ts ( &f );
168 QString line; 168 QString line;
169 while( line = ts. readLine() ) { 169 while( line = ts. readLine() ) {
170 if ( line. left ( 8 ) == "Hardware" ) 170 if ( line. left ( 8 ) == "Hardware" )
171 break; 171 break;
172 } 172 }
173 int loc = line. find ( ":" ); 173 int loc = line. find ( ":" );
174 if ( loc != -1 ) 174 if ( loc != -1 )
175 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 175 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
176 } 176 }
177 177
178 if ( model == "SHARP Corgi" ) { 178 if ( model == "SHARP Corgi" ) {
179 d->m_model = Model_Zaurus_SLC7x0; 179 d->m_model = Model_Zaurus_SLC7x0;
180 d->m_modelstr = "Zaurus SL-C700"; 180 d->m_modelstr = "Zaurus SL-C700";
181 } else if ( model == "SHARP Shepherd" ) { 181 } else if ( model == "SHARP Shepherd" ) {
182 d->m_model = Model_Zaurus_SLC7x0; 182 d->m_model = Model_Zaurus_SLC7x0;
183 d->m_modelstr = "Zaurus SL-C750"; 183 d->m_modelstr = "Zaurus SL-C750";
184 } else if ( model == "SHARP Husky" ) { 184 } else if ( model == "SHARP Husky" ) {
185 d->m_model = Model_Zaurus_SLC7x0; 185 d->m_model = Model_Zaurus_SLC7x0;
186 d->m_modelstr = "Zaurus SL-C760"; 186 d->m_modelstr = "Zaurus SL-C760";
187 } else if ( model == "SHARP Poodle" ) { 187 } else if ( model == "SHARP Poodle" ) {
188 d->m_model = Model_Zaurus_SLB600; 188 d->m_model = Model_Zaurus_SLB600;
189 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 189 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
190 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 190 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
191 d->m_model = Model_Zaurus_SL5500; 191 d->m_model = Model_Zaurus_SL5500;
192 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 192 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
193 } else { 193 } else {
194 d->m_model = Model_Zaurus_SL5500; 194 d->m_model = Model_Zaurus_SL5500;
195 d->m_modelstr = "Zaurus (Model unknown)"; 195 d->m_modelstr = "Zaurus (Model unknown)";
196 } 196 }
197 197
198 bool flipstate = false; 198 bool flipstate = false;
199 switch ( d->m_model ) { 199 switch ( d->m_model ) {
200 case Model_Zaurus_SLA300: 200 case Model_Zaurus_SLA300:
201 d->m_rotation = Rot0; 201 d->m_rotation = Rot0;
202 break; 202 break;
203 case Model_Zaurus_SLC7x0: 203 case Model_Zaurus_SLC7x0:
204 d->m_rotation = rotation(); 204 d->m_rotation = rotation();
205 d->m_direction = direction(); 205 d->m_direction = direction();
206 break; 206 break;
207 case Model_Zaurus_SLB600: 207 case Model_Zaurus_SLB600:
208 case Model_Zaurus_SL5500: 208 case Model_Zaurus_SL5500:
209 case Model_Zaurus_SL5000: 209 case Model_Zaurus_SL5000:
210 default: 210 default:
211 d->m_rotation = Rot270; 211 d->m_rotation = Rot270;
212 break; 212 break;
213 } 213 }
214 m_leds [0] = Led_Off; 214 m_leds [0] = Led_Off;
215} 215}
216 216
@@ -377,315 +377,316 @@ void Zaurus::buzzer ( int sound )
377 } 377 }
378 } 378 }
379 379
380 snd. play(); 380 snd. play();
381 while ( !snd. isFinished()) 381 while ( !snd. isFinished())
382 qApp->processEvents(); 382 qApp->processEvents();
383 383
384 if ( fd >= 0 ) { 384 if ( fd >= 0 ) {
385 if ( vol_reset ) 385 if ( vol_reset )
386 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 386 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
387 ::close ( fd ); 387 ::close ( fd );
388 } 388 }
389 } else { 389 } else {
390 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 390 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
391 391
392 if ( fd >= 0 ) { 392 if ( fd >= 0 ) {
393 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 393 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
394 ::close ( fd ); 394 ::close ( fd );
395 } 395 }
396 396
397 } 397 }
398#endif 398#endif
399} 399}
400 400
401 401
402void Zaurus::playAlarmSound() 402void Zaurus::playAlarmSound()
403{ 403{
404 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 404 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
405} 405}
406 406
407void Zaurus::playTouchSound() 407void Zaurus::playTouchSound()
408{ 408{
409 buzzer ( SHARP_BUZ_TOUCHSOUND ); 409 buzzer ( SHARP_BUZ_TOUCHSOUND );
410} 410}
411 411
412void Zaurus::playKeySound() 412void Zaurus::playKeySound()
413{ 413{
414 buzzer ( SHARP_BUZ_KEYSOUND ); 414 buzzer ( SHARP_BUZ_KEYSOUND );
415} 415}
416 416
417 417
418QValueList <OLed> Zaurus::ledList() const 418QValueList <OLed> Zaurus::ledList() const
419{ 419{
420 QValueList <OLed> vl; 420 QValueList <OLed> vl;
421 vl << Led_Mail; 421 vl << Led_Mail;
422 return vl; 422 return vl;
423} 423}
424 424
425QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 425QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
426{ 426{
427 QValueList <OLedState> vl; 427 QValueList <OLedState> vl;
428 428
429 if ( l == Led_Mail ) 429 if ( l == Led_Mail )
430 vl << Led_Off << Led_On << Led_BlinkSlow; 430 vl << Led_Off << Led_On << Led_BlinkSlow;
431 return vl; 431 return vl;
432} 432}
433 433
434OLedState Zaurus::ledState ( OLed which ) const 434OLedState Zaurus::ledState ( OLed which ) const
435{ 435{
436 if ( which == Led_Mail ) 436 if ( which == Led_Mail )
437 return m_leds [0]; 437 return m_leds [0];
438 else 438 else
439 return Led_Off; 439 return Led_Off;
440} 440}
441 441
442bool Zaurus::setLedState ( OLed which, OLedState st ) 442bool Zaurus::setLedState ( OLed which, OLedState st )
443{ 443{
444 if (!m_embedix) // Currently not supported on non_embedix kernels 444 if (!m_embedix) // Currently not supported on non_embedix kernels
445 return false; 445 return false;
446 446
447 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 447 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
448 448
449 if ( which == Led_Mail ) { 449 if ( which == Led_Mail ) {
450 if ( fd >= 0 ) { 450 if ( fd >= 0 ) {
451 struct sharp_led_status leds; 451 struct sharp_led_status leds;
452 ::memset ( &leds, 0, sizeof( leds )); 452 ::memset ( &leds, 0, sizeof( leds ));
453 leds. which = SHARP_LED_MAIL_EXISTS; 453 leds. which = SHARP_LED_MAIL_EXISTS;
454 bool ok = true; 454 bool ok = true;
455 455
456 switch ( st ) { 456 switch ( st ) {
457 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 457 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
458 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 458 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
459 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 459 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
460 default : ok = false; 460 default : ok = false;
461 } 461 }
462 462
463 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 463 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
464 m_leds [0] = st; 464 m_leds [0] = st;
465 return true; 465 return true;
466 } 466 }
467 } 467 }
468 } 468 }
469 return false; 469 return false;
470} 470}
471 471
472bool Zaurus::setSoftSuspend ( bool soft ) 472bool Zaurus::setSoftSuspend ( bool soft )
473{ 473{
474 if (!m_embedix) { 474 if (!m_embedix) {
475 /* non-Embedix kernels dont have kernel autosuspend */ 475 /* non-Embedix kernels dont have kernel autosuspend */
476 return ODevice::setSoftSuspend( soft ); 476 return ODevice::setSoftSuspend( soft );
477 } 477 }
478 478
479 bool res = false; 479 bool res = false;
480 int fd; 480 int fd;
481 481
482 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 482 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
483 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 483 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
484 484
485 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 485 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
486 486
487 if ( sources >= 0 ) { 487 if ( sources >= 0 ) {
488 if ( soft ) 488 if ( soft )
489 sources &= ~APM_EVT_POWER_BUTTON; 489 sources &= ~APM_EVT_POWER_BUTTON;
490 else 490 else
491 sources |= APM_EVT_POWER_BUTTON; 491 sources |= APM_EVT_POWER_BUTTON;
492 492
493 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 493 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
494 res = true; 494 res = true;
495 else 495 else
496 perror ( "APM_IOCGEVTSRC" ); 496 perror ( "APM_IOCGEVTSRC" );
497 } 497 }
498 else 498 else
499 perror ( "APM_IOCGEVTSRC" ); 499 perror ( "APM_IOCGEVTSRC" );
500 500
501 ::close ( fd ); 501 ::close ( fd );
502 } 502 }
503 else 503 else
504 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 504 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
505 505
506 return res; 506 return res;
507} 507}
508 508
509 509
510bool Zaurus::setDisplayBrightness ( int bright ) 510bool Zaurus::setDisplayBrightness ( int bright )
511{ 511{
512 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 512 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
513 bool res = false; 513 bool res = false;
514 int fd; 514 int fd;
515 515
516 if ( bright > 255 ) bright = 255; 516 if ( bright > 255 ) bright = 255;
517 if ( bright < 0 ) bright = 0; 517 if ( bright < 0 ) bright = 0;
518 518
519 if ( m_embedix ) 519 if ( m_embedix )
520 { 520 {
521 if ( d->m_model == Model_Zaurus_SLC7x0 ) 521 if ( d->m_model == Model_Zaurus_SLC7x0 )
522 { 522 {
523 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 523 //qDebug( "using special treatment for devices with the corgi backlight interface" );
524 // special treatment for devices with the corgi backlight interface 524 // special treatment for devices with the corgi backlight interface
525 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 525 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
526 { 526 {
527 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 527 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
528 char writeCommand[100]; 528 char writeCommand[100];
529 const int count = sprintf( writeCommand, "0x%x\n", value ); 529 const int count = sprintf( writeCommand, "0x%x\n", value );
530 res = ( ::write ( fd, writeCommand, count ) != -1 ); 530 res = ( ::write ( fd, writeCommand, count ) != -1 );
531 ::close ( fd ); 531 ::close ( fd );
532 } 532 }
533 return res; 533 return res;
534 } 534 }
535 else 535 else
536 { 536 {
537 // standard treatment for devices with the dumb embedix frontlight interface 537 // standard treatment for devices with the dumb embedix frontlight interface
538 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 538 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
539 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 539 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
540 if ( bright && !bl ) 540 if ( bright && !bl )
541 bl = 1; 541 bl = 1;
542 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 542 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
543 ::close ( fd ); 543 ::close ( fd );
544 } 544 }
545 } 545 }
546 } 546 }
547 else 547 else
548 { 548 {
549 // special treatment for the OpenZaurus unified interface 549 // special treatment for the OpenZaurus unified interface
550 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 550 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
551 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 551 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
552 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 552 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
553 ::close ( fd ); 553 ::close ( fd );
554 } 554 }
555 } 555 }
556 return res; 556 return res;
557} 557}
558 558
559bool Zaurus::suspend() 559bool Zaurus::suspend()
560{ 560{
561 qDebug("ODevice::suspend"); 561 qDebug("ODevice::suspend");
562 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 562 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
563 return false; 563 return false;
564 564
565 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 565 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
566 return false; 566 return false;
567 567
568 bool res = false; 568 bool res = false;
569 ODevice::sendSuspendmsg();
569 570
570 struct timeval tvs, tvn; 571 struct timeval tvs, tvn;
571 ::gettimeofday ( &tvs, 0 ); 572 ::gettimeofday ( &tvs, 0 );
572 573
573 ::sync(); // flush fs caches 574 ::sync(); // flush fs caches
574 res = ( ::system ( "apm --suspend" ) == 0 ); 575 res = ( ::system ( "apm --suspend" ) == 0 );
575 576
576 // This is needed because the iPAQ apm implementation is asynchronous and we 577 // This is needed because the iPAQ apm implementation is asynchronous and we
577 // can not be sure when exactly the device is really suspended 578 // can not be sure when exactly the device is really suspended
578 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 579 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
579 580
580 if ( res ) { 581 if ( res ) {
581 do { // Yes, wait 15 seconds. This APM bug sucks big time. 582 do { // Yes, wait 15 seconds. This APM bug sucks big time.
582 ::usleep ( 200 * 1000 ); 583 ::usleep ( 200 * 1000 );
583 ::gettimeofday ( &tvn, 0 ); 584 ::gettimeofday ( &tvn, 0 );
584 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 585 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
585 } 586 }
586 587
587 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 588 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
588 return res; 589 return res;
589} 590}
590 591
591 592
592Transformation Zaurus::rotation() const 593Transformation Zaurus::rotation() const
593{ 594{
594 Transformation rot; 595 Transformation rot;
595 int handle = 0; 596 int handle = 0;
596 int retval = 0; 597 int retval = 0;
597 598
598 switch ( d->m_model ) { 599 switch ( d->m_model ) {
599 case Model_Zaurus_SLC7x0: 600 case Model_Zaurus_SLC7x0:
600 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 601 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
601 if (handle == -1) { 602 if (handle == -1) {
602 return Rot270; 603 return Rot270;
603 } else { 604 } else {
604 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 605 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
605 ::close (handle); 606 ::close (handle);
606 607
607 if (retval == 2 ) 608 if (retval == 2 )
608 rot = Rot0; 609 rot = Rot0;
609 else 610 else
610 rot = Rot270; 611 rot = Rot270;
611 } 612 }
612 break; 613 break;
613 case Model_Zaurus_SLA300: 614 case Model_Zaurus_SLA300:
614 case Model_Zaurus_SLB600: 615 case Model_Zaurus_SLB600:
615 case Model_Zaurus_SL5500: 616 case Model_Zaurus_SL5500:
616 case Model_Zaurus_SL5000: 617 case Model_Zaurus_SL5000:
617 default: 618 default:
618 rot = d->m_rotation; 619 rot = d->m_rotation;
619 break; 620 break;
620 } 621 }
621 622
622 return rot; 623 return rot;
623} 624}
624ODirection Zaurus::direction() const 625ODirection Zaurus::direction() const
625{ 626{
626 ODirection dir; 627 ODirection dir;
627 int handle = 0; 628 int handle = 0;
628 int retval = 0; 629 int retval = 0;
629 switch ( d->m_model ) { 630 switch ( d->m_model ) {
630 case Model_Zaurus_SLC7x0: 631 case Model_Zaurus_SLC7x0:
631 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 632 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
632 if (handle == -1) { 633 if (handle == -1) {
633 dir = CW; 634 dir = CW;
634 } else { 635 } else {
635 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 636 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
636 ::close (handle); 637 ::close (handle);
637 if (retval == 2 ) 638 if (retval == 2 )
638 dir = CCW; 639 dir = CCW;
639 else 640 else
640 dir = CW; 641 dir = CW;
641 } 642 }
642 break; 643 break;
643 case Model_Zaurus_SLA300: 644 case Model_Zaurus_SLA300:
644 case Model_Zaurus_SLB600: 645 case Model_Zaurus_SLB600:
645 case Model_Zaurus_SL5500: 646 case Model_Zaurus_SL5500:
646 case Model_Zaurus_SL5000: 647 case Model_Zaurus_SL5000:
647 default: 648 default:
648 dir = d->m_direction; 649 dir = d->m_direction;
649 break; 650 break;
650 } 651 }
651 return dir; 652 return dir;
652 653
653} 654}
654 655
655int Zaurus::displayBrightnessResolution() const 656int Zaurus::displayBrightnessResolution() const
656{ 657{
657 if (m_embedix) 658 if (m_embedix)
658 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; 659 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
659 else 660 else
660 return 256; 661 return 256;
661} 662}
662 663
663bool Zaurus::hasHingeSensor() const 664bool Zaurus::hasHingeSensor() const
664{ 665{
665 return d->m_model == Model_Zaurus_SLC7x0; 666 return d->m_model == Model_Zaurus_SLC7x0;
666} 667}
667 668
668OHingeStatus Zaurus::readHingeSensor() 669OHingeStatus Zaurus::readHingeSensor()
669{ 670{
670 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 671 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
671 if (handle == -1) 672 if (handle == -1)
672 { 673 {
673 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 674 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
674 return CASE_UNKNOWN; 675 return CASE_UNKNOWN;
675 } 676 }
676 else 677 else
677 { 678 {
678 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 679 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
679 ::close (handle); 680 ::close (handle);
680 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 681 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
681 { 682 {
682 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 683 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
683 return static_cast<OHingeStatus>( retval ); 684 return static_cast<OHingeStatus>( retval );
684 } 685 }
685 else 686 else
686 { 687 {
687 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 688 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
688 return CASE_UNKNOWN; 689 return CASE_UNKNOWN;
689 } 690 }
690 } 691 }
691} 692}