summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp26
2 files changed, 8 insertions, 20 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index cf2061b..af77ed1 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,809 +1,807 @@
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_beagle.h" 30#include "odevice_beagle.h"
31#include "odevice_ipaq.h" 31#include "odevice_ipaq.h"
32#include "odevice_jornada.h" 32#include "odevice_jornada.h"
33#include "odevice_ramses.h" 33#include "odevice_ramses.h"
34#include "odevice_simpad.h" 34#include "odevice_simpad.h"
35#include "odevice_yopy.h" 35#include "odevice_yopy.h"
36#include "odevice_zaurus.h" 36#include "odevice_zaurus.h"
37#include "odevice_genuineintel.h" 37#include "odevice_genuineintel.h"
38 38
39/* QT */ 39/* QT */
40#include <qapplication.h> 40#include <qapplication.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qwindowsystem_qws.h> 43#include <qwindowsystem_qws.h>
44 44
45/* OPIE */ 45/* OPIE */
46#include <qpe/config.h> 46#include <qpe/config.h>
47#include <qpe/resource.h> 47#include <qpe/resource.h>
48#include <qpe/sound.h> 48#include <qpe/sound.h>
49#include <qpe/qcopenvelope_qws.h> 49#include <qpe/qcopenvelope_qws.h>
50#include <qpe/sound.h> 50#include <qpe/sound.h>
51#include <opie2/okeyfilter.h> 51#include <opie2/okeyfilter.h>
52 52
53/* STD */ 53/* STD */
54#include <fcntl.h> 54#include <fcntl.h>
55#include <math.h> 55#include <math.h>
56#include <stdlib.h> 56#include <stdlib.h>
57#include <signal.h> 57#include <signal.h>
58#include <sys/ioctl.h> 58#include <sys/ioctl.h>
59#include <sys/time.h> 59#include <sys/time.h>
60#include <unistd.h> 60#include <unistd.h>
61#ifndef QT_NO_SOUND 61#ifndef QT_NO_SOUND
62#include <linux/soundcard.h> 62#include <linux/soundcard.h>
63#endif 63#endif
64 64
65namespace Opie { 65namespace Opie {
66namespace Core { 66namespace Core {
67 67
68static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 68static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
69 69
70 70
71/* STATIC and common implementation */ 71/* STATIC and common implementation */
72/* EXPORT */ ODistribution distributions[] = { 72/* EXPORT */ ODistribution distributions[] = {
73 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 73 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
74 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 74 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
75 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 75 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
76 { System_Unknown, "Linux", "/etc/issue" }, 76 { System_Unknown, "Linux", "/etc/issue" },
77}; 77};
78 78
79 79
80/* EXPORT */ bool isQWS(){ 80/* EXPORT */ bool isQWS(){
81 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 81 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
82} 82}
83 83
84/* EXPORT */ QCString makeChannel ( const char *str ){ 84/* EXPORT */ QCString makeChannel ( const char *str ){
85 if ( str && !::strchr ( str, '/' )) 85 if ( str && !::strchr ( str, '/' ))
86 return QCString ( "QPE/Application/" ) + str; 86 return QCString ( "QPE/Application/" ) + str;
87 else 87 else
88 return str; 88 return str;
89} 89}
90 90
91 91
92 92
93/* Now the default implementation of ODevice */ 93/* Now the default implementation of ODevice */
94 94
95struct default_button default_buttons [] = { 95struct default_button default_buttons [] = {
96 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 96 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
97 "devicebuttons/z_calendar", 97 "devicebuttons/z_calendar",
98 "datebook", "nextView()", 98 "datebook", "nextView()",
99 "today", "raise()" }, 99 "today", "raise()" },
100 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 100 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
101 "devicebuttons/z_contact", 101 "devicebuttons/z_contact",
102 "addressbook", "raise()", 102 "addressbook", "raise()",
103 "addressbook", "beamBusinessCard()" }, 103 "addressbook", "beamBusinessCard()" },
104 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 104 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
105 "devicebuttons/z_home", 105 "devicebuttons/z_home",
106 "QPE/Launcher", "home()", 106 "QPE/Launcher", "home()",
107 "buttonsettings", "raise()" }, 107 "buttonsettings", "raise()" },
108 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 108 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
109 "devicebuttons/z_menu", 109 "devicebuttons/z_menu",
110 "QPE/TaskBar", "toggleMenu()", 110 "QPE/TaskBar", "toggleMenu()",
111 "QPE/TaskBar", "toggleStartMenu()" }, 111 "QPE/TaskBar", "toggleStartMenu()" },
112 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 112 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
113 "devicebuttons/z_mail", 113 "devicebuttons/z_mail",
114 "opiemail", "raise()", 114 "opiemail", "raise()",
115 "opiemail", "newMail()" }, 115 "opiemail", "newMail()" },
116}; 116};
117 117
118ODevice *ODevice::inst() 118ODevice *ODevice::inst()
119{ 119{
120 static ODevice *dev = 0; 120 static ODevice *dev = 0;
121
122 // rewrite this to only use /proc/cpuinfo or so
123 QString cpu_info; 121 QString cpu_info;
124 122
125 if ( !dev ) 123 if ( !dev )
126 { 124 {
127 QFile f( PATH_PROC_CPUINFO ); 125 QFile f( PATH_PROC_CPUINFO );
128 if ( f.open( IO_ReadOnly ) ) 126 if ( f.open( IO_ReadOnly ) )
129 { 127 {
130 QTextStream s( &f ); 128 QTextStream s( &f );
131 while ( !s.atEnd() ) 129 while ( !s.atEnd() )
132 { 130 {
133 QString line; 131 QString line;
134 line = s.readLine(); 132 line = s.readLine();
135 if ( line.startsWith( "Hardware" ) ) 133 if ( line.startsWith( "Hardware" ) )
136 { 134 {
137 qDebug( "ODevice() - found '%s'", (const char*) line ); 135 qDebug( "ODevice() - found '%s'", (const char*) line );
138 cpu_info = line; 136 cpu_info = line;
139 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
140 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
141 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
142 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
143 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
144 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 142 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
145 else qWarning( "ODevice() - unknown hardware - using default." ); 143 else qWarning( "ODevice() - unknown hardware - using default." );
146 break; 144 break;
147 } else if ( line.startsWith( "vendor_id" ) ) { 145 } else if ( line.startsWith( "vendor_id" ) ) {
148 qDebug( "ODevice() - found '%s'", (const char*) line ); 146 qDebug( "ODevice() - found '%s'", (const char*) line );
149 cpu_info = line; 147 cpu_info = line;
150 if( line.contains( "genuineintel", false ) ) { 148 if( line.contains( "genuineintel", false ) ) {
151 dev = new Internal::GenuineIntel(); 149 dev = new Internal::GenuineIntel();
152 break; 150 break;
153 } 151 }
154 } 152 }
155 } 153 }
156 } 154 }
157 else 155 else
158 { 156 {
159 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 157 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
160 } 158 }
161 if ( !dev ) dev = new ODevice(); 159 if ( !dev ) dev = new ODevice();
162 dev->init(cpu_info); 160 dev->init(cpu_info);
163 } 161 }
164 return dev; 162 return dev;
165} 163}
166 164
167ODevice::ODevice() 165ODevice::ODevice()
168{ 166{
169 d = new ODeviceData; 167 d = new ODeviceData;
170 168
171 d->m_modelstr = "Unknown"; 169 d->m_modelstr = "Unknown";
172 d->m_model = Model_Unknown; 170 d->m_model = Model_Unknown;
173 d->m_vendorstr = "Unknown"; 171 d->m_vendorstr = "Unknown";
174 d->m_vendor = Vendor_Unknown; 172 d->m_vendor = Vendor_Unknown;
175 d->m_systemstr = "Unknown"; 173 d->m_systemstr = "Unknown";
176 d->m_system = System_Unknown; 174 d->m_system = System_Unknown;
177 d->m_sysverstr = "0.0"; 175 d->m_sysverstr = "0.0";
178 d->m_rotation = Rot0; 176 d->m_rotation = Rot0;
179 d->m_direction = CW; 177 d->m_direction = CW;
180 178
181 d->m_holdtime = 1000; // 1000ms 179 d->m_holdtime = 1000; // 1000ms
182 d->m_buttons = 0; 180 d->m_buttons = 0;
183 d->m_cpu_frequencies = new QStrList; 181 d->m_cpu_frequencies = new QStrList;
184 182
185 183
186 /* mixer */ 184 /* mixer */
187 d->m_sound = d->m_vol = d->m_mixer = -1; 185 d->m_sound = d->m_vol = d->m_mixer = -1;
188 186
189 /* System QCopChannel created */ 187 /* System QCopChannel created */
190 d->m_initializedButtonQcop = false; 188 d->m_initializedButtonQcop = false;
191 189
192 // New distribution detection code first checks for legacy distributions, 190 // New distribution detection code first checks for legacy distributions,
193 // identified by /etc/familiar-version or /etc/oz_version. 191 // identified by /etc/familiar-version or /etc/oz_version.
194 // Then check for OpenEmbedded and lastly, read /etc/issue 192 // Then check for OpenEmbedded and lastly, read /etc/issue
195 193
196 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 194 for ( unsigned int i = 0; i < sizeof distributions; ++i )
197 { 195 {
198 if ( QFile::exists( distributions[i].sysvfile ) ) 196 if ( QFile::exists( distributions[i].sysvfile ) )
199 { 197 {
200 d->m_systemstr = distributions[i].sysstr; 198 d->m_systemstr = distributions[i].sysstr;
201 d->m_system = distributions[i].system; 199 d->m_system = distributions[i].system;
202 d->m_sysverstr = "<Unknown>"; 200 d->m_sysverstr = "<Unknown>";
203 QFile f( distributions[i].sysvfile ); 201 QFile f( distributions[i].sysvfile );
204 if ( f.open( IO_ReadOnly ) ) 202 if ( f.open( IO_ReadOnly ) )
205 { 203 {
206 QTextStream ts( &f ); 204 QTextStream ts( &f );
207 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 205 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
208 } 206 }
209 break; 207 break;
210 } 208 }
211 } 209 }
212} 210}
213 211
214void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 212void ODevice::systemMessage( const QCString &msg, const QByteArray & )
215{ 213{
216 if ( msg == "deviceButtonMappingChanged()" ) { 214 if ( msg == "deviceButtonMappingChanged()" ) {
217 reloadButtonMapping(); 215 reloadButtonMapping();
218 } 216 }
219} 217}
220 218
221void ODevice::init(const QString&) 219void ODevice::init(const QString&)
222{ 220{
223} 221}
224 222
225/** 223/**
226* This method initialises the button mapping 224* This method initialises the button mapping
227*/ 225*/
228void ODevice::initButtons() 226void ODevice::initButtons()
229{ 227{
230 if ( d->m_buttons ) 228 if ( d->m_buttons )
231 return; 229 return;
232 230
233 qDebug ( "init Buttons" ); 231 qDebug ( "init Buttons" );
234 d->m_buttons = new QValueList <ODeviceButton>; 232 d->m_buttons = new QValueList <ODeviceButton>;
235 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 233 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
236 default_button *db = default_buttons + i; 234 default_button *db = default_buttons + i;
237 ODeviceButton b; 235 ODeviceButton b;
238 b. setKeycode ( db->code ); 236 b. setKeycode ( db->code );
239 b. setUserText ( QObject::tr ( "Button", db->utext )); 237 b. setUserText ( QObject::tr ( "Button", db->utext ));
240 b. setPixmap ( Resource::loadPixmap ( db->pix )); 238 b. setPixmap ( Resource::loadPixmap ( db->pix ));
241 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 239 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
242 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 240 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
243 d->m_buttons->append ( b ); 241 d->m_buttons->append ( b );
244 } 242 }
245 243
246 reloadButtonMapping(); 244 reloadButtonMapping();
247} 245}
248 246
249ODevice::~ODevice() 247ODevice::~ODevice()
250{ 248{
251// we leak m_devicebuttons and m_cpu_frequency 249// we leak m_devicebuttons and m_cpu_frequency
252// but it's a singleton and it is not so importantant 250// but it's a singleton and it is not so importantant
253// -zecke 251// -zecke
254 delete d; 252 delete d;
255} 253}
256 254
257/** 255/**
258* This method will try to suspend the device 256* This method will try to suspend the device
259* It only works if the user is the QWS Server and the apm application 257* It only works if the user is the QWS Server and the apm application
260* is installed. 258* is installed.
261* It tries to suspend and then waits some time cause some distributions 259* It tries to suspend and then waits some time cause some distributions
262* do have asynchronus apm implementations. 260* do have asynchronus apm implementations.
263* This method will either fail and return false or it'll suspend the 261* This method will either fail and return false or it'll suspend the
264* device and return once the device got woken up 262* device and return once the device got woken up
265* 263*
266* @return if the device got suspended 264* @return if the device got suspended
267*/ 265*/
268bool ODevice::suspend() 266bool ODevice::suspend()
269{ 267{
270 return false; // default implementation == unknown device or qvfb 268 return false; // default implementation == unknown device or qvfb
271} 269}
272 270
273/** 271/**
274* This sets the display on or off 272* This sets the display on or off
275*/ 273*/
276bool ODevice::setDisplayStatus( bool on ) 274bool ODevice::setDisplayStatus( bool on )
277{ 275{
278 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); 276 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on );
279 return false; // don't do anything for unknown models 277 return false; // don't do anything for unknown models
280} 278}
281 279
282/** 280/**
283* This sets the display brightness 281* This sets the display brightness
284* 282*
285* @param b The brightness to be set on a scale from 0 to 255 283* @param b The brightness to be set on a scale from 0 to 255
286* @return success or failure 284* @return success or failure
287*/ 285*/
288bool ODevice::setDisplayBrightness( int b ) 286bool ODevice::setDisplayBrightness( int b )
289{ 287{
290 qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); 288 qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b );
291 return false; 289 return false;
292} 290}
293 291
294/** 292/**
295 * 293 *
296 * @returns the number of steppings on the brightness slider 294 * @returns the number of steppings on the brightness slider
297 * in the Light-'n-Power settings. Values smaller than zero and bigger 295 * in the Light-'n-Power settings. Values smaller than zero and bigger
298 * than 255 do not make sense. 296 * than 255 do not make sense.
299 * 297 *
300 * \sa QSlider::setLineStep 298 * \sa QSlider::setLineStep
301 * \sa QSlider::setPageStep 299 * \sa QSlider::setPageStep
302 */ 300 */
303int ODevice::displayBrightnessResolution() const 301int ODevice::displayBrightnessResolution() const
304{ 302{
305 qDebug( "ODevice::displayBrightnessResolution() - please override me." ); 303 qDebug( "ODevice::displayBrightnessResolution() - please override me." );
306 return 16; 304 return 16;
307} 305}
308 306
309/** 307/**
310* This sets the display contrast 308* This sets the display contrast
311* @param p The contrast to be set on a scale from 0 to 255 309* @param p The contrast to be set on a scale from 0 to 255
312* @returns success or failure 310* @returns success or failure
313*/ 311*/
314bool ODevice::setDisplayContrast( int p ) 312bool ODevice::setDisplayContrast( int p )
315{ 313{
316 qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); 314 qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p );
317 return false; 315 return false;
318} 316}
319 317
320/** 318/**
321* @returns the maximum value for the contrast settings slider 319* @returns the maximum value for the contrast settings slider
322* or 0 if the device doesn't support setting of a contrast 320* or 0 if the device doesn't support setting of a contrast
323*/ 321*/
324int ODevice::displayContrastResolution() const 322int ODevice::displayContrastResolution() const
325{ 323{
326 qDebug( "ODevice::displayBrightnessResolution() - please override me." ); 324 qDebug( "ODevice::displayBrightnessResolution() - please override me." );
327 return 0; 325 return 0;
328} 326}
329 327
330/** 328/**
331* This returns the vendor as string 329* This returns the vendor as string
332* @return Vendor as QString 330* @return Vendor as QString
333*/ 331*/
334QString ODevice::vendorString() const 332QString ODevice::vendorString() const
335{ 333{
336 return d->m_vendorstr; 334 return d->m_vendorstr;
337} 335}
338 336
339/** 337/**
340* This returns the vendor as one of the values of OVendor 338* This returns the vendor as one of the values of OVendor
341* @return OVendor 339* @return OVendor
342*/ 340*/
343OVendor ODevice::vendor() const 341OVendor ODevice::vendor() const
344{ 342{
345 return d->m_vendor; 343 return d->m_vendor;
346} 344}
347 345
348/** 346/**
349* This returns the model as a string 347* This returns the model as a string
350* @return A string representing the model 348* @return A string representing the model
351*/ 349*/
352QString ODevice::modelString() const 350QString ODevice::modelString() const
353{ 351{
354 return d->m_modelstr; 352 return d->m_modelstr;
355} 353}
356 354
357/** 355/**
358* This does return the OModel used 356* This does return the OModel used
359*/ 357*/
360OModel ODevice::model() const 358OModel ODevice::model() const
361{ 359{
362 return d->m_model; 360 return d->m_model;
363} 361}
364 362
365/** 363/**
366* This does return the systen name 364* This does return the systen name
367*/ 365*/
368QString ODevice::systemString() const 366QString ODevice::systemString() const
369{ 367{
370 return d->m_systemstr; 368 return d->m_systemstr;
371} 369}
372 370
373/** 371/**
374* Return System as OSystem value 372* Return System as OSystem value
375*/ 373*/
376OSystem ODevice::system() const 374OSystem ODevice::system() const
377{ 375{
378 return d->m_system; 376 return d->m_system;
379} 377}
380 378
381/** 379/**
382* @return the version string of the base system 380* @return the version string of the base system
383*/ 381*/
384QString ODevice::systemVersionString() const 382QString ODevice::systemVersionString() const
385{ 383{
386 return d->m_sysverstr; 384 return d->m_sysverstr;
387} 385}
388 386
389/** 387/**
390* @return the current Transformation 388* @return the current Transformation
391*/ 389*/
392Transformation ODevice::rotation() const 390Transformation ODevice::rotation() const
393{ 391{
394 return d->m_rotation; 392 return d->m_rotation;
395} 393}
396 394
397/** 395/**
398* @return the current rotation direction 396* @return the current rotation direction
399*/ 397*/
400ODirection ODevice::direction() const 398ODirection ODevice::direction() const
401{ 399{
402 return d->m_direction; 400 return d->m_direction;
403} 401}
404 402
405/** 403/**
406* This plays an alarm sound 404* This plays an alarm sound
407*/ 405*/
408void ODevice::playAlarmSound() 406void ODevice::playAlarmSound()
409{ 407{
410#ifndef QT_NO_SOUND 408#ifndef QT_NO_SOUND
411 static Sound snd ( "alarm" ); 409 static Sound snd ( "alarm" );
412 410
413 if ( snd. isFinished()) 411 if ( snd. isFinished())
414 snd. play(); 412 snd. play();
415#endif 413#endif
416} 414}
417 415
418/** 416/**
419* This plays a key sound 417* This plays a key sound
420*/ 418*/
421void ODevice::playKeySound() 419void ODevice::playKeySound()
422{ 420{
423#ifndef QT_NO_SOUND 421#ifndef QT_NO_SOUND
424 static Sound snd ( "keysound" ); 422 static Sound snd ( "keysound" );
425 423
426 if ( snd. isFinished()) 424 if ( snd. isFinished())
427 snd. play(); 425 snd. play();
428#endif 426#endif
429} 427}
430 428
431/** 429/**
432* This plays a touch sound 430* This plays a touch sound
433*/ 431*/
434void ODevice::playTouchSound() 432void ODevice::playTouchSound()
435{ 433{
436#ifndef QT_NO_SOUND 434#ifndef QT_NO_SOUND
437 static Sound snd ( "touchsound" ); 435 static Sound snd ( "touchsound" );
438 436
439 if ( snd. isFinished()) 437 if ( snd. isFinished())
440 snd. play(); 438 snd. play();
441#endif 439#endif
442} 440}
443 441
444/** 442/**
445* This method will return a list of leds 443* This method will return a list of leds
446* available on this device 444* available on this device
447* @return a list of LEDs. 445* @return a list of LEDs.
448*/ 446*/
449QValueList <OLed> ODevice::ledList() const 447QValueList <OLed> ODevice::ledList() const
450{ 448{
451 return QValueList <OLed>(); 449 return QValueList <OLed>();
452} 450}
453 451
454/** 452/**
455* This does return the state of the LEDs 453* This does return the state of the LEDs
456*/ 454*/
457QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 455QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
458{ 456{
459 return QValueList <OLedState>(); 457 return QValueList <OLedState>();
460} 458}
461 459
462/** 460/**
463* @return the state for a given OLed 461* @return the state for a given OLed
464*/ 462*/
465OLedState ODevice::ledState ( OLed /*which*/ ) const 463OLedState ODevice::ledState ( OLed /*which*/ ) const
466{ 464{
467 return Led_Off; 465 return Led_Off;
468} 466}
469 467
470/** 468/**
471* Set the state for a LED 469* Set the state for a LED
472* @param which Which OLed to use 470* @param which Which OLed to use
473* @param st The state to set 471* @param st The state to set
474* @return success or failure 472* @return success or failure
475*/ 473*/
476bool ODevice::setLedState ( OLed which, OLedState st ) 474bool ODevice::setLedState ( OLed which, OLedState st )
477{ 475{
478 Q_UNUSED( which ) 476 Q_UNUSED( which )
479 Q_UNUSED( st ) 477 Q_UNUSED( st )
480 return false; 478 return false;
481} 479}
482 480
483/** 481/**
484* @return if the device has a light sensor 482* @return if the device has a light sensor
485*/ 483*/
486bool ODevice::hasLightSensor() const 484bool ODevice::hasLightSensor() const
487{ 485{
488 return false; 486 return false;
489} 487}
490 488
491/** 489/**
492* @return a value from the light sensor 490* @return a value from the light sensor
493*/ 491*/
494int ODevice::readLightSensor() 492int ODevice::readLightSensor()
495{ 493{
496 return -1; 494 return -1;
497} 495}
498 496
499/** 497/**
500* @return the light sensor resolution 498* @return the light sensor resolution
501*/ 499*/
502int ODevice::lightSensorResolution() const 500int ODevice::lightSensorResolution() const
503{ 501{
504 return 0; 502 return 0;
505} 503}
506 504
507/** 505/**
508* @return if the device has a hinge sensor 506* @return if the device has a hinge sensor
509*/ 507*/
510bool ODevice::hasHingeSensor() const 508bool ODevice::hasHingeSensor() const
511{ 509{
512 return false; 510 return false;
513} 511}
514 512
515/** 513/**
516* @return a value from the hinge sensor 514* @return a value from the hinge sensor
517*/ 515*/
518OHingeStatus ODevice::readHingeSensor()const 516OHingeStatus ODevice::readHingeSensor()const
519{ 517{
520 return CASE_UNKNOWN; 518 return CASE_UNKNOWN;
521} 519}
522 520
523/** 521/**
524* @return a list with CPU frequencies supported by the hardware 522* @return a list with CPU frequencies supported by the hardware
525*/ 523*/
526const QStrList &ODevice::allowedCpuFrequencies() const 524const QStrList &ODevice::allowedCpuFrequencies() const
527{ 525{
528 return *d->m_cpu_frequencies; 526 return *d->m_cpu_frequencies;
529} 527}
530 528
531 529
532/** 530/**
533* Set desired CPU frequency 531* Set desired CPU frequency
534* 532*
535* @param index index into d->m_cpu_frequencies of the frequency to be set 533* @param index index into d->m_cpu_frequencies of the frequency to be set
536*/ 534*/
537bool ODevice::setCurrentCpuFrequency(uint index) 535bool ODevice::setCurrentCpuFrequency(uint index)
538{ 536{
539 if (index >= d->m_cpu_frequencies->count()) 537 if (index >= d->m_cpu_frequencies->count())
540 return false; 538 return false;
541 539
542 char *freq = d->m_cpu_frequencies->at(index); 540 char *freq = d->m_cpu_frequencies->at(index);
543 qWarning("set freq to %s", freq); 541 qWarning("set freq to %s", freq);
544 542
545 int fd; 543 int fd;
546 544
547 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 545 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
548 char writeCommand[50]; 546 char writeCommand[50];
549 const int count = sprintf(writeCommand, "%s\n", freq); 547 const int count = sprintf(writeCommand, "%s\n", freq);
550 int res = (::write(fd, writeCommand, count) != -1); 548 int res = (::write(fd, writeCommand, count) != -1);
551 ::close(fd); 549 ::close(fd);
552 return res; 550 return res;
553 } 551 }
554 552
555 return false; 553 return false;
556} 554}
557 555
558 556
559/** 557/**
560* @return a list of hardware buttons 558* @return a list of hardware buttons
561*/ 559*/
562const QValueList <ODeviceButton> &ODevice::buttons() 560const QValueList <ODeviceButton> &ODevice::buttons()
563{ 561{
564 initButtons(); 562 initButtons();
565 563
566 return *d->m_buttons; 564 return *d->m_buttons;
567} 565}
568 566
569/** 567/**
570* @return The amount of time that would count as a hold 568* @return The amount of time that would count as a hold
571*/ 569*/
572uint ODevice::buttonHoldTime() const 570uint ODevice::buttonHoldTime() const
573{ 571{
574 return d->m_holdtime; 572 return d->m_holdtime;
575} 573}
576 574
577/** 575/**
578* This method return a ODeviceButton for a key code 576* This method return a ODeviceButton for a key code
579* or 0 if no special hardware button is available for the device 577* or 0 if no special hardware button is available for the device
580* 578*
581* @return The devicebutton or 0l 579* @return The devicebutton or 0l
582* @see ODeviceButton 580* @see ODeviceButton
583*/ 581*/
584const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 582const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
585{ 583{
586 initButtons(); 584 initButtons();
587 585
588 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 586 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
589 if ( (*it).keycode() == code ) 587 if ( (*it).keycode() == code )
590 return &(*it); 588 return &(*it);
591 } 589 }
592 return 0; 590 return 0;
593} 591}
594 592
595void ODevice::reloadButtonMapping() 593void ODevice::reloadButtonMapping()
596{ 594{
597 if(!d->m_buttons) 595 if(!d->m_buttons)
598 initButtons(); 596 initButtons();
599 597
600 if(!d->m_initializedButtonQcop) { 598 if(!d->m_initializedButtonQcop) {
601 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); 599 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel");
602 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), 600 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)),
603 this,SLOT(systemMessage(const QCString&,const QByteArray&))); 601 this,SLOT(systemMessage(const QCString&,const QByteArray&)));
604 d->m_initializedButtonQcop = true; 602 d->m_initializedButtonQcop = true;
605 } 603 }
606 604
607 Config cfg ( "ButtonSettings" ); 605 Config cfg ( "ButtonSettings" );
608 606
609 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 607 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
610 ODeviceButton &b = ( *d->m_buttons ) [i]; 608 ODeviceButton &b = ( *d->m_buttons ) [i];
611 QString group = "Button" + QString::number ( i ); 609 QString group = "Button" + QString::number ( i );
612 610
613 QCString pch, hch; 611 QCString pch, hch;
614 QCString pm, hm; 612 QCString pm, hm;
615 QByteArray pdata, hdata; 613 QByteArray pdata, hdata;
616 614
617 if ( cfg. hasGroup ( group )) { 615 if ( cfg. hasGroup ( group )) {
618 cfg. setGroup ( group ); 616 cfg. setGroup ( group );
619 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 617 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
620 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 618 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
621 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 619 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
622 620
623 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 621 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
624 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 622 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
625 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 623 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
626 } 624 }
627 625
628 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 626 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
629 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 627 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
630 } 628 }
631} 629}
632 630
633void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 631void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
634{ 632{
635 initButtons(); 633 initButtons();
636 634
637 QString mb_chan; 635 QString mb_chan;
638 636
639 if ( button >= (int) d->m_buttons->count()) 637 if ( button >= (int) d->m_buttons->count())
640 return; 638 return;
641 639
642 ODeviceButton &b = ( *d->m_buttons ) [button]; 640 ODeviceButton &b = ( *d->m_buttons ) [button];
643 b. setPressedAction ( action ); 641 b. setPressedAction ( action );
644 642
645 mb_chan=b. pressedAction(). channel(); 643 mb_chan=b. pressedAction(). channel();
646 644
647 Config buttonFile ( "ButtonSettings" ); 645 Config buttonFile ( "ButtonSettings" );
648 buttonFile. setGroup ( "Button" + QString::number ( button )); 646 buttonFile. setGroup ( "Button" + QString::number ( button ));
649 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 647 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
650 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 648 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
651 649
652// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 650// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
653 651
654 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 652 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
655} 653}
656 654
657void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 655void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
658{ 656{
659 initButtons(); 657 initButtons();
660 658
661 if ( button >= (int) d->m_buttons->count()) 659 if ( button >= (int) d->m_buttons->count())
662 return; 660 return;
663 661
664 ODeviceButton &b = ( *d->m_buttons ) [button]; 662 ODeviceButton &b = ( *d->m_buttons ) [button];
665 b. setHeldAction ( action ); 663 b. setHeldAction ( action );
666 664
667 Config buttonFile ( "ButtonSettings" ); 665 Config buttonFile ( "ButtonSettings" );
668 buttonFile. setGroup ( "Button" + QString::number ( button )); 666 buttonFile. setGroup ( "Button" + QString::number ( button ));
669 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 667 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
670 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 668 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
671 669
672// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 670// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
673 671
674 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 672 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
675} 673}
676 674
677/** 675/**
678 * @internal 676 * @internal
679 */ 677 */
680void ODevice::virtual_hook(int, void* ){ 678void ODevice::virtual_hook(int, void* ){
681 679
682} 680}
683 681
684/** 682/**
685 * \brief Send a QCOP Message before suspending 683 * \brief Send a QCOP Message before suspending
686 * 684 *
687 * Sends a QCOP message to channel QPE/System 685 * Sends a QCOP message to channel QPE/System
688 * with the message "aboutToSuspend()" if this 686 * with the message "aboutToSuspend()" if this
689 * is the windowing server. 687 * is the windowing server.
690 * 688 *
691 * Call this in your custom \sa suspend() Method 689 * Call this in your custom \sa suspend() Method
692 * before going to suspend. 690 * before going to suspend.
693 * 691 *
694 */ 692 */
695void ODevice::sendSuspendmsg() 693void ODevice::sendSuspendmsg()
696{ 694{
697 if ( isQWS() ) 695 if ( isQWS() )
698 return; 696 return;
699 697
700 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 698 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
701} 699}
702 700
703/** 701/**
704 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters 702 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
705 * 703 *
706 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard 704 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
707 * Filters. This function is the only way to prepend a KeyFilter. 705 * Filters. This function is the only way to prepend a KeyFilter.
708 * 706 *
709 * @param aFilter The KeyFilter to be prepended to the list of filters 707 * @param aFilter The KeyFilter to be prepended to the list of filters
710 * 708 *
711 * @see Opie::Core::OKeyFilter 709 * @see Opie::Core::OKeyFilter
712 * @see Opie::Core::OKeyFilter::inst() 710 * @see Opie::Core::OKeyFilter::inst()
713 */ 711 */
714void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 712void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
715{ 713{
716 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 714 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
717} 715}
718 716
719/** 717/**
720 * \brief Remove the QWSServer::KeyboardFilter in the param from the list 718 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
721 * 719 *
722 * Remove the QWSServer::KeyboardFilter \par aFilter from the List 720 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
723 * of Keyfilters. Call this when you delete the KeyFilter! 721 * of Keyfilters. Call this when you delete the KeyFilter!
724 * 722 *
725 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter 723 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
726 * @see Opie::Core::ODevice::addPreHandler 724 * @see Opie::Core::ODevice::addPreHandler
727 */ 725 */
728void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 726void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
729{ 727{
730 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 728 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
731} 729}
732 730
733 731
734/** 732/**
735 * @internal 733 * @internal
736 * 734 *
737 * @see changeMixerForAlarm 735 * @see changeMixerForAlarm
738 */ 736 */
739void ODevice::playingStopped() { 737void ODevice::playingStopped() {
740 if ( sender() ) 738 if ( sender() )
741 const_cast<QObject*>(sender())->disconnect( this ); 739 const_cast<QObject*>(sender())->disconnect( this );
742 740
743#ifndef QT_NO_SOUND 741#ifndef QT_NO_SOUND
744 if ( d->m_sound >= 0 ) { 742 if ( d->m_sound >= 0 ) {
745 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); 743 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
746 ::close ( d->m_sound ); 744 ::close ( d->m_sound );
747 } 745 }
748#endif 746#endif
749} 747}
750 748
751 749
752/** 750/**
753 * \brief Change the Volume for the Alarm and set it back after playing is finished 751 * \brief Change the Volume for the Alarm and set it back after playing is finished
754 * 752 *
755 * If you play an Alarm Sound you might want to change the Mixer to 753 * If you play an Alarm Sound you might want to change the Mixer to
756 * full volume and ignore the user setting. After it \sa Sound::isFinished 754 * full volume and ignore the user setting. After it \sa Sound::isFinished
757 * you would turn the volume back to the user preference. 755 * you would turn the volume back to the user preference.
758 * The problem is that we used to enter the event loop while waiting 756 * The problem is that we used to enter the event loop while waiting
759 * for the sound to be finished triggering all kind of reentrance 757 * for the sound to be finished triggering all kind of reentrance
760 * problems what a library shouldn't introduce. 758 * problems what a library shouldn't introduce.
761 * Instead of manually waiting for the sound to be finished use 759 * Instead of manually waiting for the sound to be finished use
762 * this Method and it will automatically restore the Mixer to 760 * this Method and it will automatically restore the Mixer to
763 * the user configuration after the sound finished playing. 761 * the user configuration after the sound finished playing.
764 * 762 *
765 * Note: The onwership of \param snd is not transfered and playing 763 * Note: The onwership of \param snd is not transfered and playing
766 * is not started in this method. If 'snd' gets deleted before 764 * is not started in this method. If 'snd' gets deleted before
767 * playing is finished the volume doesn't get set back to 765 * playing is finished the volume doesn't get set back to
768 * the user preference! 766 * the user preference!
769 * 767 *
770 * \code 768 * \code
771 * static Sound snd("alarm"); 769 * static Sound snd("alarm");
772 * if(!snd.isFinished()) 770 * if(!snd.isFinished())
773 * return; 771 * return;
774 * 772 *
775 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); 773 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd );
776 * snd.play() 774 * snd.play()
777 * \endcode 775 * \endcode
778 * 776 *
779 * 777 *
780 * 778 *
781 * @param mixer The mixer number/channel to use 779 * @param mixer The mixer number/channel to use
782 * @param file The file name. If you convert from QString use QFile::encodeName 780 * @param file The file name. If you convert from QString use QFile::encodeName
783 * @param snd The sound to wait for finishing 781 * @param snd The sound to wait for finishing
784 * 782 *
785 */ 783 */
786void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { 784void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
787#ifndef QT_NO_SOUND 785#ifndef QT_NO_SOUND
788 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { 786 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
789 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { 787 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
790 Config cfg ( "qpe" ); 788 Config cfg ( "qpe" );
791 cfg. setGroup ( "Volume" ); 789 cfg. setGroup ( "Volume" );
792 790
793 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 791 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
794 if ( volalarm < 0 ) 792 if ( volalarm < 0 )
795 volalarm = 0; 793 volalarm = 0;
796 else if ( volalarm > 100 ) 794 else if ( volalarm > 100 )
797 volalarm = 100; 795 volalarm = 100;
798 volalarm |= ( volalarm << 8 ); 796 volalarm |= ( volalarm << 8 );
799 797
800 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) 798 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
801 register_qpe_sound_finished(snd, this, SLOT(playingStopped())); 799 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
802 } 800 }
803 d->m_mixer = mixer; 801 d->m_mixer = mixer;
804 } 802 }
805#endif 803#endif
806} 804}
807 805
808} 806}
809} 807}
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 3bd7f6e..e9b163a 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,664 +1,654 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002-2005 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 <opie2/oinputsystem.h> 39#include <opie2/oinputsystem.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60struct z_button z_buttons [] = { 60struct z_button z_buttons [] = {
61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
62 "devicebuttons/z_calendar", 62 "devicebuttons/z_calendar",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
66 "devicebuttons/z_contact", 66 "devicebuttons/z_contact",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
70 "devicebuttons/z_home", 70 "devicebuttons/z_home",
71 "QPE/Launcher", "home()", 71 "QPE/Launcher", "home()",
72 "buttonsettings", "raise()" }, 72 "buttonsettings", "raise()" },
73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
74 "devicebuttons/z_menu", 74 "devicebuttons/z_menu",
75 "QPE/TaskBar", "toggleMenu()", 75 "QPE/TaskBar", "toggleMenu()",
76 "QPE/TaskBar", "toggleStartMenu()" }, 76 "QPE/TaskBar", "toggleStartMenu()" },
77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
78 "devicebuttons/z_mail", 78 "devicebuttons/z_mail",
79 "opiemail", "raise()", 79 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 80 "opiemail", "newMail()" },
81}; 81};
82 82
83struct z_button z_buttons_c700 [] = { 83struct z_button z_buttons_c700 [] = {
84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
85 "devicebuttons/z_calendar", 85 "devicebuttons/z_calendar",
86 "datebook", "nextView()", 86 "datebook", "nextView()",
87 "today", "raise()" }, 87 "today", "raise()" },
88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
89 "devicebuttons/z_contact", 89 "devicebuttons/z_contact",
90 "addressbook", "raise()", 90 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 91 "addressbook", "beamBusinessCard()" },
92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
93 "devicebuttons/z_home", 93 "devicebuttons/z_home",
94 "QPE/Launcher", "home()", 94 "QPE/Launcher", "home()",
95 "buttonsettings", "raise()" }, 95 "buttonsettings", "raise()" },
96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/z_menu", 97 "devicebuttons/z_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
101 "devicebuttons/z_mail", 101 "devicebuttons/z_mail",
102 "opiemail", "raise()", 102 "opiemail", "raise()",
103 "opiemail", "newMail()" }, 103 "opiemail", "newMail()" },
104 104
105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
106 "devicebuttons/z_hinge1", 106 "devicebuttons/z_hinge1",
107 "QPE/Rotation", "rotateDefault()",0}, 107 "QPE/Rotation", "rotateDefault()",0},
108 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 108 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
109 "devicebuttons/z_hinge2", 109 "devicebuttons/z_hinge2",
110 "QPE/Rotation", "rotateDefault()",0}, 110 "QPE/Rotation", "rotateDefault()",0},
111 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 111 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
112 "devicebuttons/z_hinge3", 112 "devicebuttons/z_hinge3",
113 "QPE/Rotation", "rotateDefault()",0}, 113 "QPE/Rotation", "rotateDefault()",0},
114}; 114};
115 115
116// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 116// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
117// class up into individual classes. We need three classes 117// class up into individual classes. We would need three classes
118// 118//
119// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 119// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
120// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 120// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
121// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) 121// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000)
122// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 122// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
123//
124// Only question right now is: Do we really need to do it? Because as soon
125// as the OpenZaurus kernel is ready, there will be a unified interface for all
126// Zaurus models (concerning apm, backlight, buttons, etc.)
127//
128// Comments? - mickeyl.
129 123
130void Zaurus::init(const QString& cpu_info) 124void Zaurus::init(const QString& cpu_info)
131{ 125{
132 // Set the time to wait until the system is realy suspended 126 // Set the time to wait until the system is really suspended
133 // the delta between apm --suspend and sleeping 127 // the delta between apm --suspend and sleeping
134 setAPMTimeOut( 15000 ); 128 setAPMTimeOut( 15000 );
135 129
136 // generic distribution code already scanned /etc/issue at that point - 130 // generic distribution code already scanned /etc/issue at that point -
137 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 131 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
138 if ( d->m_sysverstr.contains( "embedix", false ) ) 132 if ( d->m_sysverstr.contains( "embedix", false ) )
139 { 133 {
140 d->m_vendorstr = "Sharp"; 134 d->m_vendorstr = "Sharp";
141 d->m_vendor = Vendor_Sharp; 135 d->m_vendor = Vendor_Sharp;
142 d->m_systemstr = "Zaurus"; 136 d->m_systemstr = "Zaurus";
143 d->m_system = System_Zaurus; 137 d->m_system = System_Zaurus;
144 m_embedix = true; 138 m_embedix = true;
145 } 139 }
146 else 140 else
147 { 141 {
148 d->m_vendorstr = "OpenZaurus Team"; 142 d->m_vendorstr = "OpenZaurus Team";
149 d->m_systemstr = "OpenZaurus"; 143 d->m_systemstr = "OpenZaurus";
150 d->m_system = System_OpenZaurus; 144 d->m_system = System_OpenZaurus;
151 // sysver already gathered 145 // sysver already gathered
152 146
153 // OpenZaurus sometimes uses the embedix kernel, check if this is one 147 // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one
154 FILE *uname = popen("uname -r", "r"); 148 FILE *uname = popen("uname -r", "r");
155 QFile f; 149 QFile f;
156 QString line; 150 QString line;
157 if ( f.open(IO_ReadOnly, uname) ) { 151 if ( f.open(IO_ReadOnly, uname) ) {
158 QTextStream ts ( &f ); 152 QTextStream ts ( &f );
159 line = ts. readLine(); 153 line = ts.readLine();
160 int loc = line. find ( "embedix" ); 154 m_embedix = line.startsWith( "2.4." );
161 if ( loc != -1 )
162 m_embedix = true;
163 else
164 m_embedix = false;
165 f.close(); 155 f.close();
166 } 156 }
167 pclose(uname); 157 pclose(uname);
168 } 158 }
169 159
170 // check the Zaurus model 160 // check the Zaurus model
171 QString model; 161 QString model;
172 int loc = cpu_info.find( ":" ); 162 int loc = cpu_info.find( ":" );
173 if ( loc != -1 ) 163 if ( loc != -1 )
174 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 164 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
175 else 165 else
176 model = cpu_info; 166 model = cpu_info;
177 167
178 if ( model == "SHARP Corgi" ) { 168 if ( model == "SHARP Corgi" ) {
179 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
180 d->m_modelstr = "Zaurus SL-C700"; 170 d->m_modelstr = "Zaurus SL-C700";
181 } else if ( model == "SHARP Shepherd" ) { 171 } else if ( model == "SHARP Shepherd" ) {
182 d->m_model = Model_Zaurus_SLC7x0; 172 d->m_model = Model_Zaurus_SLC7x0;
183 d->m_modelstr = "Zaurus SL-C750"; 173 d->m_modelstr = "Zaurus SL-C750";
184 } else if ( model == "SHARP Husky" ) { 174 } else if ( model == "SHARP Husky" ) {
185 d->m_model = Model_Zaurus_SLC7x0; 175 d->m_model = Model_Zaurus_SLC7x0;
186 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 176 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
187 } else if ( model == "SHARP Boxer" ) { 177 } else if ( model == "SHARP Boxer" ) {
188 d->m_model = Model_Zaurus_SLC7x0; 178 d->m_model = Model_Zaurus_SLC7x0;
189 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 179 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
190 } else if ( model == "SHARP Poodle" ) { 180 } else if ( model == "SHARP Poodle" ) {
191 d->m_model = Model_Zaurus_SLB600; 181 d->m_model = Model_Zaurus_SLB600;
192 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 182 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
193 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 183 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
194 d->m_model = Model_Zaurus_SL5500; 184 d->m_model = Model_Zaurus_SL5500;
195 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 185 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
196 } else if ( model == "SHARP Tosa" ) { 186 } else if ( model == "SHARP Tosa" ) {
197 d->m_model = Model_Zaurus_SL6000; 187 d->m_model = Model_Zaurus_SL6000;
198 d->m_modelstr = "Zaurus SL-6000"; 188 d->m_modelstr = "Zaurus SL-6000";
199 } else if ( model == "SHARP Spitz" ) { 189 } else if ( model == "SHARP Spitz" ) {
200 d->m_model = Model_Zaurus_SLC3000; 190 d->m_model = Model_Zaurus_SLC3000;
201 d->m_modelstr = "Zaurus SL-C3000"; 191 d->m_modelstr = "Zaurus SL-C3000";
202 } else if ( model == "SHARP Akita" ) { 192 } else if ( model == "SHARP Akita" ) {
203 d->m_model = Model_Zaurus_SLC1000; 193 d->m_model = Model_Zaurus_SLC1000;
204 d->m_modelstr = "Zaurus SL-C1000"; 194 d->m_modelstr = "Zaurus SL-C1000";
205 } else { 195 } else {
206 d->m_model = Model_Zaurus_SL5500; 196 d->m_model = Model_Zaurus_SL5500;
207 d->m_modelstr = "Unknown Zaurus"; 197 d->m_modelstr = "Unknown Zaurus";
208 } 198 }
209 199
210 // set initial rotation 200 // set initial rotation
211 switch( d->m_model ) { 201 switch( d->m_model ) {
212 case Model_Zaurus_SL6000: // fallthrough 202 case Model_Zaurus_SL6000: // fallthrough
213 case Model_Zaurus_SLA300: 203 case Model_Zaurus_SLA300:
214 d->m_rotation = Rot0; 204 d->m_rotation = Rot0;
215 break; 205 break;
216 case Model_Zaurus_SLC3000: // fallthrough 206 case Model_Zaurus_SLC3000: // fallthrough
217 case Model_Zaurus_SLC1000: // fallthrough 207 case Model_Zaurus_SLC1000: // fallthrough
218 case Model_Zaurus_SLC7x0: 208 case Model_Zaurus_SLC7x0:
219 d->m_rotation = rotation(); 209 d->m_rotation = rotation();
220 d->m_direction = direction(); 210 d->m_direction = direction();
221 break; 211 break;
222 case Model_Zaurus_SLB600: // fallthrough 212 case Model_Zaurus_SLB600: // fallthrough
223 case Model_Zaurus_SL5000: // fallthrough 213 case Model_Zaurus_SL5000: // fallthrough
224 case Model_Zaurus_SL5500: // fallthrough 214 case Model_Zaurus_SL5500: // fallthrough
225 default: 215 default:
226 d->m_rotation = Rot270; 216 d->m_rotation = Rot270;
227 break; 217 break;
228 } 218 }
229 m_leds[0] = Led_Off; 219 m_leds[0] = Led_Off;
230 220
231 if ( m_embedix ) 221 if ( m_embedix )
232 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); 222 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr );
233 else 223 else
234 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 224 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
235} 225}
236 226
237void Zaurus::initButtons() 227void Zaurus::initButtons()
238{ 228{
239 if ( d->m_buttons ) 229 if ( d->m_buttons )
240 return; 230 return;
241 231
242 232
243 d->m_buttons = new QValueList <ODeviceButton>; 233 d->m_buttons = new QValueList <ODeviceButton>;
244 234
245 struct z_button * pz_buttons; 235 struct z_button * pz_buttons;
246 int buttoncount; 236 int buttoncount;
247 switch ( d->m_model ) { 237 switch ( d->m_model ) {
248 case Model_Zaurus_SLC3000: // fallthrough 238 case Model_Zaurus_SLC3000: // fallthrough
249 case Model_Zaurus_SLC1000: // fallthrough 239 case Model_Zaurus_SLC1000: // fallthrough
250 case Model_Zaurus_SLC7x0: 240 case Model_Zaurus_SLC7x0:
251 if ( isQWS( ) ) { 241 if ( isQWS( ) ) {
252 addPreHandler(this); // hinge-sensor-handler 242 addPreHandler(this); // hinge-sensor-handler
253 } 243 }
254 pz_buttons = z_buttons_c700; 244 pz_buttons = z_buttons_c700;
255 buttoncount = ARRAY_SIZE(z_buttons_c700); 245 buttoncount = ARRAY_SIZE(z_buttons_c700);
256 break; 246 break;
257 default: 247 default:
258 pz_buttons = z_buttons; 248 pz_buttons = z_buttons;
259 buttoncount = ARRAY_SIZE(z_buttons); 249 buttoncount = ARRAY_SIZE(z_buttons);
260 break; 250 break;
261 } 251 }
262 252
263 for ( int i = 0; i < buttoncount; i++ ) { 253 for ( int i = 0; i < buttoncount; i++ ) {
264 struct z_button *zb = pz_buttons + i; 254 struct z_button *zb = pz_buttons + i;
265 ODeviceButton b; 255 ODeviceButton b;
266 256
267 b.setKeycode( zb->code ); 257 b.setKeycode( zb->code );
268 b.setUserText( QObject::tr( "Button", zb->utext )); 258 b.setUserText( QObject::tr( "Button", zb->utext ));
269 b.setPixmap( Resource::loadPixmap( zb->pix )); 259 b.setPixmap( Resource::loadPixmap( zb->pix ));
270 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 260 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
271 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 261 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
272 d->m_buttons->append( b ); 262 d->m_buttons->append( b );
273 } 263 }
274 264
275 reloadButtonMapping(); 265 reloadButtonMapping();
276} 266}
277 267
278 268
279 269
280typedef struct sharp_led_status { 270typedef struct sharp_led_status {
281 int which; /* select which LED status is wanted. */ 271 int which; /* select which LED status is wanted. */
282 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 272 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
283} sharp_led_status; 273} sharp_led_status;
284 274
285void Zaurus::buzzer( int sound ) 275void Zaurus::buzzer( int sound )
286{ 276{
287#ifndef QT_NO_SOUND 277#ifndef QT_NO_SOUND
288 Sound *snd = 0; 278 Sound *snd = 0;
289 279
290 // All devices except SL5500 have a DSP device 280 // All devices except SL5500 have a DSP device
291 if ( d->m_model != Model_Zaurus_SL5000 281 if ( d->m_model != Model_Zaurus_SL5000
292 && d->m_model != Model_Zaurus_SL5500 ) { 282 && d->m_model != Model_Zaurus_SL5500 ) {
293 283
294 switch ( sound ){ 284 switch ( sound ){
295 case SHARP_BUZ_TOUCHSOUND: { 285 case SHARP_BUZ_TOUCHSOUND: {
296 static Sound touch_sound("touchsound"); 286 static Sound touch_sound("touchsound");
297 snd = &touch_sound; 287 snd = &touch_sound;
298 } 288 }
299 break; 289 break;
300 case SHARP_BUZ_KEYSOUND: { 290 case SHARP_BUZ_KEYSOUND: {
301 static Sound key_sound( "keysound" ); 291 static Sound key_sound( "keysound" );
302 snd = &key_sound; 292 snd = &key_sound;
303 } 293 }
304 break; 294 break;
305 case SHARP_BUZ_SCHEDULE_ALARM: 295 case SHARP_BUZ_SCHEDULE_ALARM:
306 default: { 296 default: {
307 static Sound alarm_sound("alarm"); 297 static Sound alarm_sound("alarm");
308 snd = &alarm_sound; 298 snd = &alarm_sound;
309 } 299 }
310 break; 300 break;
311 } 301 }
312 } 302 }
313 303
314 // If a soundname is defined, we expect that this device has 304 // If a soundname is defined, we expect that this device has
315 // sound capabilities.. Otherwise we expect to have the buzzer 305 // sound capabilities.. Otherwise we expect to have the buzzer
316 // device.. 306 // device..
317 if ( snd && snd->isFinished() ){ 307 if ( snd && snd->isFinished() ){
318 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 308 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
319 snd->play(); 309 snd->play();
320 } else if( !snd ) { 310 } else if( !snd ) {
321 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 311 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
322 312
323 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
324 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 314 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
325 ::close ( fd ); 315 ::close ( fd );
326 } 316 }
327 317
328 } 318 }
329#endif 319#endif
330} 320}
331 321
332 322
333void Zaurus::playAlarmSound() 323void Zaurus::playAlarmSound()
334{ 324{
335 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 325 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
336} 326}
337 327
338void Zaurus::playTouchSound() 328void Zaurus::playTouchSound()
339{ 329{
340 buzzer( SHARP_BUZ_TOUCHSOUND ); 330 buzzer( SHARP_BUZ_TOUCHSOUND );
341} 331}
342 332
343void Zaurus::playKeySound() 333void Zaurus::playKeySound()
344{ 334{
345 buzzer( SHARP_BUZ_KEYSOUND ); 335 buzzer( SHARP_BUZ_KEYSOUND );
346} 336}
347 337
348 338
349QValueList <OLed> Zaurus::ledList() const 339QValueList <OLed> Zaurus::ledList() const
350{ 340{
351 QValueList <OLed> vl; 341 QValueList <OLed> vl;
352 vl << Led_Mail; 342 vl << Led_Mail;
353 return vl; 343 return vl;
354} 344}
355 345
356QValueList <OLedState> Zaurus::ledStateList( OLed l ) const 346QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
357{ 347{
358 QValueList <OLedState> vl; 348 QValueList <OLedState> vl;
359 349
360 if ( l == Led_Mail ) 350 if ( l == Led_Mail )
361 vl << Led_Off << Led_On << Led_BlinkSlow; 351 vl << Led_Off << Led_On << Led_BlinkSlow;
362 return vl; 352 return vl;
363} 353}
364 354
365OLedState Zaurus::ledState( OLed which ) const 355OLedState Zaurus::ledState( OLed which ) const
366{ 356{
367 if ( which == Led_Mail ) 357 if ( which == Led_Mail )
368 return m_leds [0]; 358 return m_leds [0];
369 else 359 else
370 return Led_Off; 360 return Led_Off;
371} 361}
372 362
373bool Zaurus::setLedState( OLed which, OLedState st ) 363bool Zaurus::setLedState( OLed which, OLedState st )
374{ 364{
375 // Currently not supported on non_embedix kernels 365 // Currently not supported on non_embedix kernels
376 if (!m_embedix) 366 if (!m_embedix)
377 { 367 {
378 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 368 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
379 return false; 369 return false;
380 } 370 }
381 371
382 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 372 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
383 373
384 if ( which == Led_Mail ) { 374 if ( which == Led_Mail ) {
385 if ( fd >= 0 ) { 375 if ( fd >= 0 ) {
386 struct sharp_led_status leds; 376 struct sharp_led_status leds;
387 ::memset ( &leds, 0, sizeof( leds )); 377 ::memset ( &leds, 0, sizeof( leds ));
388 leds. which = SHARP_LED_MAIL_EXISTS; 378 leds. which = SHARP_LED_MAIL_EXISTS;
389 bool ok = true; 379 bool ok = true;
390 380
391 switch ( st ) { 381 switch ( st ) {
392 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 382 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
393 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 383 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
394 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 384 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
395 default : ok = false; 385 default : ok = false;
396 } 386 }
397 387
398 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 388 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
399 m_leds [0] = st; 389 m_leds [0] = st;
400 return true; 390 return true;
401 } 391 }
402 } 392 }
403 } 393 }
404 return false; 394 return false;
405} 395}
406 396
407int Zaurus::displayBrightnessResolution() const 397int Zaurus::displayBrightnessResolution() const
408{ 398{
409 int res = 1; 399 int res = 1;
410 if (m_embedix) 400 if (m_embedix)
411 { 401 {
412 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 402 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
413 if ( fd ) 403 if ( fd )
414 { 404 {
415 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 405 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
416 ::close( fd ); 406 ::close( fd );
417 return value ? value : res; 407 return value ? value : res;
418 } 408 }
419 } 409 }
420 else 410 else
421 { 411 {
422 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 412 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
423 if ( fd ) 413 if ( fd )
424 { 414 {
425 char buf[100]; 415 char buf[100];
426 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 416 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
427 ::close( fd ); 417 ::close( fd );
428 } 418 }
429 } 419 }
430 return res; 420 return res;
431} 421}
432 422
433bool Zaurus::setDisplayBrightness( int bright ) 423bool Zaurus::setDisplayBrightness( int bright )
434{ 424{
435 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 425 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
436 bool res = false; 426 bool res = false;
437 427
438 if ( bright > 255 ) bright = 255; 428 if ( bright > 255 ) bright = 255;
439 if ( bright < 0 ) bright = 0; 429 if ( bright < 0 ) bright = 0;
440 430
441 int numberOfSteps = displayBrightnessResolution(); 431 int numberOfSteps = displayBrightnessResolution();
442 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 432 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
443 433
444 if ( m_embedix ) 434 if ( m_embedix )
445 { 435 {
446 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 436 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
447 if ( fd ) 437 if ( fd )
448 { 438 {
449 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 439 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
450 ::close( fd ); 440 ::close( fd );
451 } 441 }
452 } 442 }
453 else 443 else
454 { 444 {
455 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 445 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
456 if ( fd ) 446 if ( fd )
457 { 447 {
458 char buf[100]; 448 char buf[100];
459 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 449 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
460 res = ( ::write( fd, &buf[0], len ) == 0 ); 450 res = ( ::write( fd, &buf[0], len ) == 0 );
461 ::close( fd ); 451 ::close( fd );
462 } 452 }
463 } 453 }
464 return res; 454 return res;
465} 455}
466 456
467bool Zaurus::setDisplayStatus( bool on ) 457bool Zaurus::setDisplayStatus( bool on )
468{ 458{
469 bool res = false; 459 bool res = false;
470 if ( m_embedix ) 460 if ( m_embedix )
471 { 461 {
472 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 462 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
473 if ( fd ) 463 if ( fd )
474 { 464 {
475 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 465 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
476 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 466 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
477 ::close ( fd ); 467 ::close ( fd );
478 } 468 }
479 } 469 }
480 else 470 else
481 { 471 {
482 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 472 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
483 if ( fd ) 473 if ( fd )
484 { 474 {
485 char buf[10]; 475 char buf[10];
486 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 476 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
487 buf[1] = '\0'; 477 buf[1] = '\0';
488 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 478 res = ( ::write( fd, &buf[0], 2 ) == 0 );
489 ::close( fd ); 479 ::close( fd );
490 } 480 }
491 } 481 }
492 return res; 482 return res;
493} 483}
494 484
495Transformation Zaurus::rotation() const 485Transformation Zaurus::rotation() const
496{ 486{
497 qDebug( "Zaurus::rotation()" ); 487 qDebug( "Zaurus::rotation()" );
498 Transformation rot; 488 Transformation rot;
499 489
500 switch ( d->m_model ) { 490 switch ( d->m_model ) {
501 case Model_Zaurus_SLC3000: // fallthrough 491 case Model_Zaurus_SLC3000: // fallthrough
502 case Model_Zaurus_SLC1000: // fallthrough 492 case Model_Zaurus_SLC1000: // fallthrough
503 case Model_Zaurus_SLC7x0: 493 case Model_Zaurus_SLC7x0:
504 { 494 {
505 OHingeStatus hs = readHingeSensor(); 495 OHingeStatus hs = readHingeSensor();
506 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 496 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
507 497
508 if ( m_embedix ) 498 if ( m_embedix )
509 { 499 {
510 if ( hs == CASE_PORTRAIT ) rot = Rot0; 500 if ( hs == CASE_PORTRAIT ) rot = Rot0;
511 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 501 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
512 else rot = Rot270; 502 else rot = Rot270;
513 } 503 }
514 else 504 else
515 { 505 {
516 if ( hs == CASE_PORTRAIT ) rot = Rot90; 506 if ( hs == CASE_PORTRAIT ) rot = Rot90;
517 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 507 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
518 else rot = Rot0; 508 else rot = Rot0;
519 } 509 }
520 } 510 }
521 break; 511 break;
522 case Model_Zaurus_SL6000: 512 case Model_Zaurus_SL6000:
523 case Model_Zaurus_SLB600: 513 case Model_Zaurus_SLB600:
524 case Model_Zaurus_SLA300: 514 case Model_Zaurus_SLA300:
525 case Model_Zaurus_SL5500: 515 case Model_Zaurus_SL5500:
526 case Model_Zaurus_SL5000: 516 case Model_Zaurus_SL5000:
527 default: 517 default:
528 rot = d->m_rotation; 518 rot = d->m_rotation;
529 break; 519 break;
530 } 520 }
531 521
532 return rot; 522 return rot;
533} 523}
534ODirection Zaurus::direction() const 524ODirection Zaurus::direction() const
535{ 525{
536 ODirection dir; 526 ODirection dir;
537 527
538 switch ( d->m_model ) { 528 switch ( d->m_model ) {
539 case Model_Zaurus_SLC3000: // fallthrough 529 case Model_Zaurus_SLC3000: // fallthrough
540 case Model_Zaurus_SLC1000: // fallthrough 530 case Model_Zaurus_SLC1000: // fallthrough
541 case Model_Zaurus_SLC7x0: { 531 case Model_Zaurus_SLC7x0: {
542 OHingeStatus hs = readHingeSensor(); 532 OHingeStatus hs = readHingeSensor();
543 if ( hs == CASE_PORTRAIT ) dir = CCW; 533 if ( hs == CASE_PORTRAIT ) dir = CCW;
544 else if ( hs == CASE_UNKNOWN ) dir = CCW; 534 else if ( hs == CASE_UNKNOWN ) dir = CCW;
545 else dir = CW; 535 else dir = CW;
546 } 536 }
547 break; 537 break;
548 case Model_Zaurus_SL6000: 538 case Model_Zaurus_SL6000:
549 case Model_Zaurus_SLA300: 539 case Model_Zaurus_SLA300:
550 case Model_Zaurus_SLB600: 540 case Model_Zaurus_SLB600:
551 case Model_Zaurus_SL5500: 541 case Model_Zaurus_SL5500:
552 case Model_Zaurus_SL5000: 542 case Model_Zaurus_SL5000:
553 default: dir = d->m_direction; 543 default: dir = d->m_direction;
554 break; 544 break;
555 } 545 }
556 return dir; 546 return dir;
557 547
558} 548}
559 549
560bool Zaurus::hasHingeSensor() const 550bool Zaurus::hasHingeSensor() const
561{ 551{
562 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; 552 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000;
563} 553}
564 554
565OHingeStatus Zaurus::readHingeSensor() const 555OHingeStatus Zaurus::readHingeSensor() const
566{ 556{
567 if (m_embedix) 557 if (m_embedix)
568 { 558 {
569 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 559 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
570 if (handle == -1) 560 if (handle == -1)
571 { 561 {
572 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 562 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
573 return CASE_UNKNOWN; 563 return CASE_UNKNOWN;
574 } 564 }
575 else 565 else
576 { 566 {
577 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 567 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
578 ::close (handle); 568 ::close (handle);
579 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 569 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
580 { 570 {
581 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 571 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
582 return static_cast<OHingeStatus>( retval ); 572 return static_cast<OHingeStatus>( retval );
583 } 573 }
584 else 574 else
585 { 575 {
586 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 576 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
587 return CASE_UNKNOWN; 577 return CASE_UNKNOWN;
588 } 578 }
589 } 579 }
590 } 580 }
591 else 581 else
592 { 582 {
593 // corgi keyboard is event source 0 in OZ kernel 2.6 583 // corgi keyboard is event source 0 in OZ kernel 2.6
594 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); 584 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" );
595 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; 585 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE;
596 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; 586 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT;
597 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; 587 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED;
598 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 588 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
599 return CASE_UNKNOWN; 589 return CASE_UNKNOWN;
600 } 590 }
601} 591}
602 592
603/* 593/*
604 * Take code from iPAQ device. 594 * Take code from iPAQ device.
605 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. 595 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction.
606 * I hope that is ok - Alwin 596 * I hope that is ok - Alwin
607 */ 597 */
608bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 598bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
609{ 599{
610 int newkeycode = keycode; 600 int newkeycode = keycode;
611 601
612 if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false; 602 if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false;
613 603
614 /* map cursor keys depending on the hinge status */ 604 /* map cursor keys depending on the hinge status */
615 switch ( keycode ) { 605 switch ( keycode ) {
616 // Rotate cursor keys 606 // Rotate cursor keys
617 case Key_Left : 607 case Key_Left :
618 case Key_Right: 608 case Key_Right:
619 case Key_Up : 609 case Key_Up :
620 case Key_Down : 610 case Key_Down :
621 { 611 {
622 if (rotation()==Rot90) { 612 if (rotation()==Rot90) {
623 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 613 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
624 } 614 }
625 } 615 }
626 break; 616 break;
627 617
628 } 618 }
629 if (newkeycode!=keycode) { 619 if (newkeycode!=keycode) {
630 if ( newkeycode != Key_unknown ) { 620 if ( newkeycode != Key_unknown ) {
631 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 621 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
632 } 622 }
633 return true; 623 return true;
634 } 624 }
635 return false; 625 return false;
636} 626}
637 627
638bool Zaurus::suspend() { 628bool Zaurus::suspend() {
639 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 629 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
640 return false; 630 return false;
641 631
642 bool res = false; 632 bool res = false;
643 OAbstractMobileDevice::sendSuspendmsg(); 633 OAbstractMobileDevice::sendSuspendmsg();
644 634
645 struct timeval tvs, tvn; 635 struct timeval tvs, tvn;
646 ::gettimeofday ( &tvs, 0 ); 636 ::gettimeofday ( &tvs, 0 );
647 637
648 ::sync(); // flush fs caches 638 ::sync(); // flush fs caches
649 res = ( ::system ( "apm --suspend" ) == 0 ); 639 res = ( ::system ( "apm --suspend" ) == 0 );
650 640
651 // This is needed because some apm implementations are asynchronous and we 641 // This is needed because some apm implementations are asynchronous and we
652 // can not be sure when exactly the device is really suspended 642 // can not be sure when exactly the device is really suspended
653 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 643 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
654 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. 644 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here.
655 645
656 if ( res && m_embedix) { 646 if ( res && m_embedix) {
657 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 647 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
658 ::usleep ( 200 * 1000 ); 648 ::usleep ( 200 * 1000 );
659 ::gettimeofday ( &tvn, 0 ); 649 ::gettimeofday ( &tvn, 0 );
660 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); 650 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut );
661 } 651 }
662 652
663 return res; 653 return res;
664} 654}