summaryrefslogtreecommitdiff
authoreilers <eilers>2004-03-31 15:11:38 (UTC)
committer eilers <eilers>2004-03-31 15:11:38 (UTC)
commit10ed731c865d41955bf2aeb721cad592cd56b545 (patch) (unidiff)
tree2c05853293b3e0a1020a51bb84a804e0074e2c2b
parent0a56adea03683be6066622bbbbae1f0b8c73db12 (diff)
downloadopie-10ed731c865d41955bf2aeb721cad592cd56b545.zip
opie-10ed731c865d41955bf2aeb721cad592cd56b545.tar.gz
opie-10ed731c865d41955bf2aeb721cad592cd56b545.tar.bz2
Fixed small bug, causes some crashes at startup: qDebug("... %s"); is bad.. ;)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index f3e2cfb..1ad0327 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,631 +1,631 @@
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::Core; 63using namespace Opie::Core;
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 Private::Zaurus(); 84 if ( line.contains( "sharp", false ) ) dev = new Private::Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ(); 85 else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad(); 86 else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada(); 87 else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Private::Ramses(); 88 else if ( line.contains( "ramses", false ) ) dev = new Private::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.", PATH_PROC_CPUINFO );
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 ODevice::sendSuspendmsg(); 189 ODevice::sendSuspendmsg();
190 190
191 struct timeval tvs, tvn; 191 struct timeval tvs, tvn;
192 ::gettimeofday ( &tvs, 0 ); 192 ::gettimeofday ( &tvs, 0 );
193 193
194 ::sync(); // flush fs caches 194 ::sync(); // flush fs caches
195 res = ( ::system ( "apm --suspend" ) == 0 ); 195 res = ( ::system ( "apm --suspend" ) == 0 );
196 196
197 // 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
198 // can not be sure when exactly the device is really suspended 198 // can not be sure when exactly the device is really suspended
199 // 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.
200 200
201 if ( res ) { 201 if ( res ) {
202 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
203 ::usleep ( 200 * 1000 ); 203 ::usleep ( 200 * 1000 );
204 ::gettimeofday ( &tvn, 0 ); 204 ::gettimeofday ( &tvn, 0 );
205 } 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 );
206 } 206 }
207 207
208 return res; 208 return res;
209} 209}
210 210
211//#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 ...
212 212
213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
214 214
215/* VESA Blanking Levels */ 215/* VESA Blanking Levels */
216#define VESA_NO_BLANKING 0 216#define VESA_NO_BLANKING 0
217#define VESA_VSYNC_SUSPEND 1 217#define VESA_VSYNC_SUSPEND 1
218#define VESA_HSYNC_SUSPEND 2 218#define VESA_HSYNC_SUSPEND 2
219#define VESA_POWERDOWN 3 219#define VESA_POWERDOWN 3
220 220
221/** 221/**
222* This sets the display on or off 222* This sets the display on or off
223*/ 223*/
224bool ODevice::setDisplayStatus ( bool on ) 224bool ODevice::setDisplayStatus ( bool on )
225{ 225{
226 qDebug("ODevice::setDisplayStatus(%d)", on); 226 qDebug("ODevice::setDisplayStatus(%d)", on);
227 227
228 if ( d->m_model == Model_Unknown ) 228 if ( d->m_model == Model_Unknown )
229 return false; 229 return false;
230 230
231 bool res = false; 231 bool res = false;
232 int fd; 232 int fd;
233 233
234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
236 ::close ( fd ); 236 ::close ( fd );
237 } 237 }
238 return res; 238 return res;
239} 239}
240 240
241/** 241/**
242* This sets the display brightness 242* This sets the display brightness
243* 243*
244* @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
245* @return success or failure 245* @return success or failure
246*/ 246*/
247bool ODevice::setDisplayBrightness ( int p) 247bool ODevice::setDisplayBrightness ( int p)
248{ 248{
249 Q_UNUSED( p ) 249 Q_UNUSED( p )
250 return false; 250 return false;
251} 251}
252 252
253/** 253/**
254* @return returns the number of steppings on the brightness slider 254* @return returns the number of steppings on the brightness slider
255* in the Light-'n-Power settings. 255* in the Light-'n-Power settings.
256*/ 256*/
257int ODevice::displayBrightnessResolution() const 257int ODevice::displayBrightnessResolution() const
258{ 258{
259 return 16; 259 return 16;
260} 260}
261 261
262/** 262/**
263* This sets the display contrast 263* This sets the display contrast
264* @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
265* @return success or failure 265* @return success or failure
266*/ 266*/
267bool ODevice::setDisplayContrast ( int p) 267bool ODevice::setDisplayContrast ( int p)
268{ 268{
269 Q_UNUSED( p ) 269 Q_UNUSED( p )
270 return false; 270 return false;
271} 271}
272 272
273/** 273/**
274* @return return the max value for the brightness settings slider 274* @return return the max value for the brightness settings slider
275* 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
276*/ 276*/
277int ODevice::displayContrastResolution() const 277int ODevice::displayContrastResolution() const
278{ 278{
279 return 0; 279 return 0;
280} 280}
281 281
282/** 282/**
283* This returns the vendor as string 283* This returns the vendor as string
284* @return Vendor as QString 284* @return Vendor as QString
285*/ 285*/
286QString ODevice::vendorString() const 286QString ODevice::vendorString() const
287{ 287{
288 return d->m_vendorstr; 288 return d->m_vendorstr;
289} 289}
290 290
291/** 291/**
292* This returns the vendor as one of the values of OVendor 292* This returns the vendor as one of the values of OVendor
293* @return OVendor 293* @return OVendor
294*/ 294*/
295OVendor ODevice::vendor() const 295OVendor ODevice::vendor() const
296{ 296{
297 return d->m_vendor; 297 return d->m_vendor;
298} 298}
299 299
300/** 300/**
301* This returns the model as a string 301* This returns the model as a string
302* @return A string representing the model 302* @return A string representing the model
303*/ 303*/
304QString ODevice::modelString() const 304QString ODevice::modelString() const
305{ 305{
306 return d->m_modelstr; 306 return d->m_modelstr;
307} 307}
308 308
309/** 309/**
310* This does return the OModel used 310* This does return the OModel used
311*/ 311*/
312OModel ODevice::model() const 312OModel ODevice::model() const
313{ 313{
314 return d->m_model; 314 return d->m_model;
315} 315}
316 316
317/** 317/**
318* This does return the systen name 318* This does return the systen name
319*/ 319*/
320QString ODevice::systemString() const 320QString ODevice::systemString() const
321{ 321{
322 return d->m_systemstr; 322 return d->m_systemstr;
323} 323}
324 324
325/** 325/**
326* Return System as OSystem value 326* Return System as OSystem value
327*/ 327*/
328OSystem ODevice::system() const 328OSystem ODevice::system() const
329{ 329{
330 return d->m_system; 330 return d->m_system;
331} 331}
332 332
333/** 333/**
334* @return the version string of the base system 334* @return the version string of the base system
335*/ 335*/
336QString ODevice::systemVersionString() const 336QString ODevice::systemVersionString() const
337{ 337{
338 return d->m_sysverstr; 338 return d->m_sysverstr;
339} 339}
340 340
341/** 341/**
342* @return the current Transformation 342* @return the current Transformation
343*/ 343*/
344Transformation ODevice::rotation() const 344Transformation ODevice::rotation() const
345{ 345{
346 return d->m_rotation; 346 return d->m_rotation;
347} 347}
348 348
349/** 349/**
350* @return the current rotation direction 350* @return the current rotation direction
351*/ 351*/
352ODirection ODevice::direction() const 352ODirection ODevice::direction() const
353{ 353{
354 return d->m_direction; 354 return d->m_direction;
355} 355}
356 356
357/** 357/**
358* This plays an alarm sound 358* This plays an alarm sound
359*/ 359*/
360void ODevice::playAlarmSound() 360void ODevice::playAlarmSound()
361{ 361{
362#ifndef QT_NO_SOUND 362#ifndef QT_NO_SOUND
363 static Sound snd ( "alarm" ); 363 static Sound snd ( "alarm" );
364 364
365 if ( snd. isFinished()) 365 if ( snd. isFinished())
366 snd. play(); 366 snd. play();
367#endif 367#endif
368} 368}
369 369
370/** 370/**
371* This plays a key sound 371* This plays a key sound
372*/ 372*/
373void ODevice::playKeySound() 373void ODevice::playKeySound()
374{ 374{
375#ifndef QT_NO_SOUND 375#ifndef QT_NO_SOUND
376 static Sound snd ( "keysound" ); 376 static Sound snd ( "keysound" );
377 377
378 if ( snd. isFinished()) 378 if ( snd. isFinished())
379 snd. play(); 379 snd. play();
380#endif 380#endif
381} 381}
382 382
383/** 383/**
384* This plays a touch sound 384* This plays a touch sound
385*/ 385*/
386void ODevice::playTouchSound() 386void ODevice::playTouchSound()
387{ 387{
388#ifndef QT_NO_SOUND 388#ifndef QT_NO_SOUND
389 static Sound snd ( "touchsound" ); 389 static Sound snd ( "touchsound" );
390 390
391 if ( snd. isFinished()) 391 if ( snd. isFinished())
392 snd. play(); 392 snd. play();
393#endif 393#endif
394} 394}
395 395
396/** 396/**
397* This method will return a list of leds 397* This method will return a list of leds
398* available on this device 398* available on this device
399* @return a list of LEDs. 399* @return a list of LEDs.
400*/ 400*/
401QValueList <OLed> ODevice::ledList() const 401QValueList <OLed> ODevice::ledList() const
402{ 402{
403 return QValueList <OLed>(); 403 return QValueList <OLed>();
404} 404}
405 405
406/** 406/**
407* This does return the state of the LEDs 407* This does return the state of the LEDs
408*/ 408*/
409QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 409QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
410{ 410{
411 return QValueList <OLedState>(); 411 return QValueList <OLedState>();
412} 412}
413 413
414/** 414/**
415* @return the state for a given OLed 415* @return the state for a given OLed
416*/ 416*/
417OLedState ODevice::ledState ( OLed /*which*/ ) const 417OLedState ODevice::ledState ( OLed /*which*/ ) const
418{ 418{
419 return Led_Off; 419 return Led_Off;
420} 420}
421 421
422/** 422/**
423* Set the state for a LED 423* Set the state for a LED
424* @param which Which OLed to use 424* @param which Which OLed to use
425* @param st The state to set 425* @param st The state to set
426* @return success or failure 426* @return success or failure
427*/ 427*/
428bool ODevice::setLedState ( OLed which, OLedState st ) 428bool ODevice::setLedState ( OLed which, OLedState st )
429{ 429{
430 Q_UNUSED( which ) 430 Q_UNUSED( which )
431 Q_UNUSED( st ) 431 Q_UNUSED( st )
432 return false; 432 return false;
433} 433}
434 434
435/** 435/**
436* @return if the device has a light sensor 436* @return if the device has a light sensor
437*/ 437*/
438bool ODevice::hasLightSensor() const 438bool ODevice::hasLightSensor() const
439{ 439{
440 return false; 440 return false;
441} 441}
442 442
443/** 443/**
444* @return a value from the light sensor 444* @return a value from the light sensor
445*/ 445*/
446int ODevice::readLightSensor() 446int ODevice::readLightSensor()
447{ 447{
448 return -1; 448 return -1;
449} 449}
450 450
451/** 451/**
452* @return the light sensor resolution 452* @return the light sensor resolution
453*/ 453*/
454int ODevice::lightSensorResolution() const 454int ODevice::lightSensorResolution() const
455{ 455{
456 return 0; 456 return 0;
457} 457}
458 458
459/** 459/**
460* @return if the device has a hinge sensor 460* @return if the device has a hinge sensor
461*/ 461*/
462bool ODevice::hasHingeSensor() const 462bool ODevice::hasHingeSensor() const
463{ 463{
464 return false; 464 return false;
465} 465}
466 466
467/** 467/**
468* @return a value from the hinge sensor 468* @return a value from the hinge sensor
469*/ 469*/
470OHingeStatus ODevice::readHingeSensor() 470OHingeStatus ODevice::readHingeSensor()
471{ 471{
472 return CASE_UNKNOWN; 472 return CASE_UNKNOWN;
473} 473}
474 474
475/** 475/**
476* @return a list with CPU frequencies supported by the hardware 476* @return a list with CPU frequencies supported by the hardware
477*/ 477*/
478const QStrList &ODevice::allowedCpuFrequencies() const 478const QStrList &ODevice::allowedCpuFrequencies() const
479{ 479{
480 return *d->m_cpu_frequencies; 480 return *d->m_cpu_frequencies;
481} 481}
482 482
483 483
484/** 484/**
485* Set desired CPU frequency 485* Set desired CPU frequency
486* 486*
487* @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
488*/ 488*/
489bool ODevice::setCurrentCpuFrequency(uint index) 489bool ODevice::setCurrentCpuFrequency(uint index)
490{ 490{
491 if (index >= d->m_cpu_frequencies->count()) 491 if (index >= d->m_cpu_frequencies->count())
492 return false; 492 return false;
493 493
494 char *freq = d->m_cpu_frequencies->at(index); 494 char *freq = d->m_cpu_frequencies->at(index);
495 qWarning("set freq to %s", freq); 495 qWarning("set freq to %s", freq);
496 496
497 int fd; 497 int fd;
498 498
499 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 499 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
500 char writeCommand[50]; 500 char writeCommand[50];
501 const int count = sprintf(writeCommand, "%s\n", freq); 501 const int count = sprintf(writeCommand, "%s\n", freq);
502 int res = (::write(fd, writeCommand, count) != -1); 502 int res = (::write(fd, writeCommand, count) != -1);
503 ::close(fd); 503 ::close(fd);
504 return res; 504 return res;
505 } 505 }
506 506
507 return false; 507 return false;
508} 508}
509 509
510 510
511/** 511/**
512* @return a list of hardware buttons 512* @return a list of hardware buttons
513*/ 513*/
514const QValueList <ODeviceButton> &ODevice::buttons() 514const QValueList <ODeviceButton> &ODevice::buttons()
515{ 515{
516 initButtons(); 516 initButtons();
517 517
518 return *d->m_buttons; 518 return *d->m_buttons;
519} 519}
520 520
521/** 521/**
522* @return The amount of time that would count as a hold 522* @return The amount of time that would count as a hold
523*/ 523*/
524uint ODevice::buttonHoldTime() const 524uint ODevice::buttonHoldTime() const
525{ 525{
526 return d->m_holdtime; 526 return d->m_holdtime;
527} 527}
528 528
529/** 529/**
530* This method return a ODeviceButton for a key code 530* This method return a ODeviceButton for a key code
531* 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
532* 532*
533* @return The devicebutton or 0l 533* @return The devicebutton or 0l
534* @see ODeviceButton 534* @see ODeviceButton
535*/ 535*/
536const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 536const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
537{ 537{
538 initButtons(); 538 initButtons();
539 539
540 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 ) {
541 if ( (*it). keycode() == code ) 541 if ( (*it). keycode() == code )
542 return &(*it); 542 return &(*it);
543 } 543 }
544 return 0; 544 return 0;
545} 545}
546 546
547void ODevice::reloadButtonMapping() 547void ODevice::reloadButtonMapping()
548{ 548{
549 initButtons(); 549 initButtons();
550 550
551 Config cfg ( "ButtonSettings" ); 551 Config cfg ( "ButtonSettings" );
552 552
553 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 553 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
554 ODeviceButton &b = ( *d->m_buttons ) [i]; 554 ODeviceButton &b = ( *d->m_buttons ) [i];
555 QString group = "Button" + QString::number ( i ); 555 QString group = "Button" + QString::number ( i );
556 556
557 QCString pch, hch; 557 QCString pch, hch;
558 QCString pm, hm; 558 QCString pm, hm;
559 QByteArray pdata, hdata; 559 QByteArray pdata, hdata;
560 560
561 if ( cfg. hasGroup ( group )) { 561 if ( cfg. hasGroup ( group )) {
562 cfg. setGroup ( group ); 562 cfg. setGroup ( group );
563 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 563 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
564 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 564 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
565 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 565 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
566 566
567 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 567 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
568 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 568 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
569 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 569 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
570 } 570 }
571 571
572 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 572 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
573 573
574 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 574 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
575 } 575 }
576} 576}
577 577
578void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 578void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
579{ 579{
580 initButtons(); 580 initButtons();
581 581
582 QString mb_chan; 582 QString mb_chan;
583 583
584 if ( button >= (int) d->m_buttons->count()) 584 if ( button >= (int) d->m_buttons->count())
585 return; 585 return;
586 586
587 ODeviceButton &b = ( *d->m_buttons ) [button]; 587 ODeviceButton &b = ( *d->m_buttons ) [button];
588 b. setPressedAction ( action ); 588 b. setPressedAction ( action );
589 589
590 mb_chan=b. pressedAction(). channel(); 590 mb_chan=b. pressedAction(). channel();
591 591
592 Config buttonFile ( "ButtonSettings" ); 592 Config buttonFile ( "ButtonSettings" );
593 buttonFile. setGroup ( "Button" + QString::number ( button )); 593 buttonFile. setGroup ( "Button" + QString::number ( button ));
594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
596 596
597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
598 598
599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
600} 600}
601 601
602void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 602void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
603{ 603{
604 initButtons(); 604 initButtons();
605 605
606 if ( button >= (int) d->m_buttons->count()) 606 if ( button >= (int) d->m_buttons->count())
607 return; 607 return;
608 608
609 ODeviceButton &b = ( *d->m_buttons ) [button]; 609 ODeviceButton &b = ( *d->m_buttons ) [button];
610 b. setHeldAction ( action ); 610 b. setHeldAction ( action );
611 611
612 Config buttonFile ( "ButtonSettings" ); 612 Config buttonFile ( "ButtonSettings" );
613 buttonFile. setGroup ( "Button" + QString::number ( button )); 613 buttonFile. setGroup ( "Button" + QString::number ( button ));
614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
616 616
617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
618 618
619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
620} 620}
621void ODevice::virtual_hook(int, void* ){ 621void ODevice::virtual_hook(int, void* ){
622 622
623} 623}
624 624
625void ODevice::sendSuspendmsg() 625void ODevice::sendSuspendmsg()
626{ 626{
627 if ( isQWS() ) 627 if ( isQWS() )
628 return; 628 return;
629 629
630 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 630 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
631} 631}