summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp128
1 files changed, 127 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index aadd0bf..8624016 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -13,192 +13,204 @@
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#include <linux/soundcard.h> 26#include <linux/soundcard.h>
27#include <math.h> 27#include <math.h>
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37 37
38#include "odevice.h" 38#include "odevice.h"
39 39
40#include <qwindowsystem_qws.h> 40#include <qwindowsystem_qws.h>
41 41
42#ifndef ARRAY_SIZE 42#ifndef ARRAY_SIZE
43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
44#endif 44#endif
45 45
46// _IO and friends are only defined in kernel headers ... 46// _IO and friends are only defined in kernel headers ...
47 47
48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
49 49
50#define OD_IO(type,number) OD_IOC(0,type,number,0) 50#define OD_IO(type,number) OD_IOC(0,type,number,0)
51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
54 54
55using namespace Opie; 55using namespace Opie;
56 56
57class ODeviceData { 57class ODeviceData {
58public: 58public:
59 QString m_vendorstr; 59 QString m_vendorstr;
60 OVendor m_vendor; 60 OVendor m_vendor;
61 61
62 QString m_modelstr; 62 QString m_modelstr;
63 OModel m_model; 63 OModel m_model;
64 64
65 QString m_systemstr; 65 QString m_systemstr;
66 OSystem m_system; 66 OSystem m_system;
67 67
68 QString m_sysverstr; 68 QString m_sysverstr;
69 69
70 Transformation m_rotation; 70 Transformation m_rotation;
71 ODirection m_direction; 71 ODirection m_direction;
72 72
73 QValueList <ODeviceButton> *m_buttons; 73 QValueList <ODeviceButton> *m_buttons;
74 uint m_holdtime; 74 uint m_holdtime;
75 QStrList *m_cpu_frequencies; 75 QStrList *m_cpu_frequencies;
76}; 76};
77 77
78class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 78class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
79protected: 79protected:
80 virtual void init ( ); 80 virtual void init ( );
81 virtual void initButtons ( ); 81 virtual void initButtons ( );
82 82
83public: 83public:
84 virtual bool setSoftSuspend ( bool soft ); 84 virtual bool setSoftSuspend ( bool soft );
85 85
86 virtual bool setDisplayBrightness ( int b ); 86 virtual bool setDisplayBrightness ( int b );
87 virtual int displayBrightnessResolution ( ) const; 87 virtual int displayBrightnessResolution ( ) const;
88 88
89 virtual void alarmSound ( ); 89 virtual void alarmSound ( );
90 90
91 virtual QValueList <OLed> ledList ( ) const; 91 virtual QValueList <OLed> ledList ( ) const;
92 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 92 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
93 virtual OLedState ledState ( OLed led ) const; 93 virtual OLedState ledState ( OLed led ) const;
94 virtual bool setLedState ( OLed led, OLedState st ); 94 virtual bool setLedState ( OLed led, OLedState st );
95 95
96 virtual bool hasLightSensor ( ) const; 96 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 97 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 98 virtual int lightSensorResolution ( ) const;
99 99
100protected: 100protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 102 virtual void timerEvent ( QTimerEvent *te );
103 103
104 int m_power_timer; 104 int m_power_timer;
105 105
106 OLedState m_leds [2]; 106 OLedState m_leds [2];
107}; 107};
108 108
109class Jornada : public ODevice {
110protected:
111 virtual void init ( );
112 virtual void initButtons ( );
113public:
114 virtual bool setSoftSuspend ( bool soft );
115 virtual bool setDisplayBrightness ( int b );
116 virtual int displayBrightnessResolution ( ) const;
117 static bool isJornada();
118
119};
120
109class Zaurus : public ODevice { 121class Zaurus : public ODevice {
110protected: 122protected:
111 virtual void init ( ); 123 virtual void init ( );
112 virtual void initButtons ( ); 124 virtual void initButtons ( );
113 125
114public: 126public:
115 virtual bool setSoftSuspend ( bool soft ); 127 virtual bool setSoftSuspend ( bool soft );
116 128
117 virtual bool setDisplayBrightness ( int b ); 129 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 130 virtual int displayBrightnessResolution ( ) const;
119 131
120 virtual void alarmSound ( ); 132 virtual void alarmSound ( );
121 virtual void keySound ( ); 133 virtual void keySound ( );
122 virtual void touchSound ( ); 134 virtual void touchSound ( );
123 135
124 virtual QValueList <OLed> ledList ( ) const; 136 virtual QValueList <OLed> ledList ( ) const;
125 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 137 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
126 virtual OLedState ledState ( OLed led ) const; 138 virtual OLedState ledState ( OLed led ) const;
127 virtual bool setLedState ( OLed led, OLedState st ); 139 virtual bool setLedState ( OLed led, OLedState st );
128 140
129 static bool isZaurus(); 141 static bool isZaurus();
130 142
131protected: 143protected:
132 virtual void buzzer ( int snd ); 144 virtual void buzzer ( int snd );
133 145
134 OLedState m_leds [1]; 146 OLedState m_leds [1];
135 bool m_embedix; 147 bool m_embedix;
136}; 148};
137 149
138class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 150class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
139protected: 151protected:
140 virtual void init ( ); 152 virtual void init ( );
141 virtual void initButtons ( ); 153 virtual void initButtons ( );
142 154
143public: 155public:
144 virtual bool setSoftSuspend ( bool soft ); 156 virtual bool setSoftSuspend ( bool soft );
145 virtual bool suspend(); 157 virtual bool suspend();
146 158
147 virtual bool setDisplayStatus( bool on ); 159 virtual bool setDisplayStatus( bool on );
148 virtual bool setDisplayBrightness ( int b ); 160 virtual bool setDisplayBrightness ( int b );
149 virtual int displayBrightnessResolution ( ) const; 161 virtual int displayBrightnessResolution ( ) const;
150 162
151 virtual void alarmSound ( ); 163 virtual void alarmSound ( );
152 164
153 virtual QValueList <OLed> ledList ( ) const; 165 virtual QValueList <OLed> ledList ( ) const;
154 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 166 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
155 virtual OLedState ledState ( OLed led ) const; 167 virtual OLedState ledState ( OLed led ) const;
156 virtual bool setLedState ( OLed led, OLedState st ); 168 virtual bool setLedState ( OLed led, OLedState st );
157 169
158protected: 170protected:
159 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 171 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
160 virtual void timerEvent ( QTimerEvent *te ); 172 virtual void timerEvent ( QTimerEvent *te );
161 173
162 int m_power_timer; 174 int m_power_timer;
163 175
164 OLedState m_leds [1]; //FIXME check if really only one 176 OLedState m_leds [1]; //FIXME check if really only one
165}; 177};
166 178
167class Ramses : public ODevice, public QWSServer::KeyboardFilter { 179class Ramses : public ODevice, public QWSServer::KeyboardFilter {
168protected: 180protected:
169 virtual void init ( ); 181 virtual void init ( );
170 182
171public: 183public:
172 virtual bool setSoftSuspend ( bool soft ); 184 virtual bool setSoftSuspend ( bool soft );
173 virtual bool suspend ( ); 185 virtual bool suspend ( );
174 186
175 virtual bool setDisplayStatus( bool on ); 187 virtual bool setDisplayStatus( bool on );
176 virtual bool setDisplayBrightness ( int b ); 188 virtual bool setDisplayBrightness ( int b );
177 virtual int displayBrightnessResolution ( ) const; 189 virtual int displayBrightnessResolution ( ) const;
178 virtual bool setDisplayContrast ( int b ); 190 virtual bool setDisplayContrast ( int b );
179 virtual int displayContrastResolution ( ) const; 191 virtual int displayContrastResolution ( ) const;
180 192
181protected: 193protected:
182 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 194 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
183 virtual void timerEvent ( QTimerEvent *te ); 195 virtual void timerEvent ( QTimerEvent *te );
184 196
185 int m_power_timer; 197 int m_power_timer;
186}; 198};
187 199
188struct i_button { 200struct i_button {
189 uint model; 201 uint model;
190 Qt::Key code; 202 Qt::Key code;
191 char *utext; 203 char *utext;
192 char *pix; 204 char *pix;
193 char *fpressedservice; 205 char *fpressedservice;
194 char *fpressedaction; 206 char *fpressedaction;
195 char *fheldservice; 207 char *fheldservice;
196 char *fheldaction; 208 char *fheldaction;
197} ipaq_buttons [] = { 209} ipaq_buttons [] = {
198 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 210 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
199 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 211 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
200 "devicebuttons/ipaq_calendar", 212 "devicebuttons/ipaq_calendar",
201 "datebook", "nextView()", 213 "datebook", "nextView()",
202 "today", "raise()" }, 214 "today", "raise()" },
203 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 215 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
204 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 216 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
@@ -340,192 +352,194 @@ struct s_button {
340 "buttonsettings", "raise()" }, 352 "buttonsettings", "raise()" },
341 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
342 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 354 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
343 "devicebuttons/simpad_upper_lower", 355 "devicebuttons/simpad_upper_lower",
344 "QPE/Launcher", "home()", 356 "QPE/Launcher", "home()",
345 "buttonsettings", "raise()" }, 357 "buttonsettings", "raise()" },
346 */ 358 */
347}; 359};
348 360
349struct r_button { 361struct r_button {
350 uint model; 362 uint model;
351 Qt::Key code; 363 Qt::Key code;
352 char *utext; 364 char *utext;
353 char *pix; 365 char *pix;
354 char *fpressedservice; 366 char *fpressedservice;
355 char *fpressedaction; 367 char *fpressedaction;
356 char *fheldservice; 368 char *fheldservice;
357 char *fheldaction; 369 char *fheldaction;
358} ramses_buttons [] = { 370} ramses_buttons [] = {
359 { Model_Ramses_MNCI, 371 { Model_Ramses_MNCI,
360 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 372 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
361 "devicebuttons/z_menu", 373 "devicebuttons/z_menu",
362 "QPE/TaskBar", "toggleMenu()", 374 "QPE/TaskBar", "toggleMenu()",
363 "QPE/TaskBar", "toggleStartMenu()" }, 375 "QPE/TaskBar", "toggleStartMenu()" },
364 { Model_Ramses_MNCI, 376 { Model_Ramses_MNCI,
365 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 377 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
366 "devicebuttons/ipaq_home", 378 "devicebuttons/ipaq_home",
367 "QPE/Launcher", "home()", 379 "QPE/Launcher", "home()",
368 "buttonsettings", "raise()" }, 380 "buttonsettings", "raise()" },
369}; 381};
370 382
371class Yopy : public ODevice { 383class Yopy : public ODevice {
372protected: 384protected:
373 virtual void init ( ); 385 virtual void init ( );
374 virtual void initButtons ( ); 386 virtual void initButtons ( );
375 387
376public: 388public:
377 virtual bool suspend ( ); 389 virtual bool suspend ( );
378 390
379 virtual bool setDisplayBrightness ( int b ); 391 virtual bool setDisplayBrightness ( int b );
380 virtual int displayBrightnessResolution ( ) const; 392 virtual int displayBrightnessResolution ( ) const;
381 393
382 static bool isYopy ( ); 394 static bool isYopy ( );
383}; 395};
384 396
385struct yopy_button { 397struct yopy_button {
386 Qt::Key code; 398 Qt::Key code;
387 char *utext; 399 char *utext;
388 char *pix; 400 char *pix;
389 char *fpressedservice; 401 char *fpressedservice;
390 char *fpressedaction; 402 char *fpressedaction;
391 char *fheldservice; 403 char *fheldservice;
392 char *fheldaction; 404 char *fheldaction;
393} yopy_buttons [] = { 405} yopy_buttons [] = {
394 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 406 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
395 "devicebuttons/yopy_action", 407 "devicebuttons/yopy_action",
396 "datebook", "nextView()", 408 "datebook", "nextView()",
397 "today", "raise()" }, 409 "today", "raise()" },
398 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 410 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
399 "devicebuttons/yopy_ok", 411 "devicebuttons/yopy_ok",
400 "addressbook", "raise()", 412 "addressbook", "raise()",
401 "addressbook", "beamBusinessCard()" }, 413 "addressbook", "beamBusinessCard()" },
402 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 414 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
403 "devicebuttons/yopy_end", 415 "devicebuttons/yopy_end",
404 "QPE/Launcher", "home()", 416 "QPE/Launcher", "home()",
405 "buttonsettings", "raise()" }, 417 "buttonsettings", "raise()" },
406}; 418};
407 419
408static QCString makeChannel ( const char *str ) 420static QCString makeChannel ( const char *str )
409{ 421{
410 if ( str && !::strchr ( str, '/' )) 422 if ( str && !::strchr ( str, '/' ))
411 return QCString ( "QPE/Application/" ) + str; 423 return QCString ( "QPE/Application/" ) + str;
412 else 424 else
413 return str; 425 return str;
414} 426}
415 427
416static inline bool isQWS() 428static inline bool isQWS()
417{ 429{
418 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 430 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
419} 431}
420 432
421ODevice *ODevice::inst ( ) 433ODevice *ODevice::inst ( )
422{ 434{
423 static ODevice *dev = 0; 435 static ODevice *dev = 0;
424 436
425 if ( !dev ) { 437 if ( !dev ) {
426 if ( QFile::exists ( "/proc/hal/model" )) 438 if ( QFile::exists ( "/proc/hal/model" ))
427 dev = new iPAQ ( ); 439 dev = new iPAQ ( );
428 else if ( Zaurus::isZaurus() ) 440 else if ( Zaurus::isZaurus() )
429 dev = new Zaurus ( ); 441 dev = new Zaurus ( );
430 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 442 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
431 dev = new SIMpad ( ); 443 dev = new SIMpad ( );
432 else if ( QFile::exists ( "/proc/sys/board/name" )) 444 else if ( QFile::exists ( "/proc/sys/board/name" ))
433 dev = new Ramses ( ); 445 dev = new Ramses ( );
434 else if ( Yopy::isYopy() ) 446 else if ( Yopy::isYopy() )
435 dev = new Yopy ( ); 447 dev = new Yopy ( );
448 else if ( Jornada::isJornada() )
449 dev = new Jornada ( );
436 else 450 else
437 dev = new ODevice ( ); 451 dev = new ODevice ( );
438 dev-> init ( ); 452 dev-> init ( );
439 } 453 }
440 return dev; 454 return dev;
441} 455}
442 456
443 457
444/************************************************** 458/**************************************************
445 * 459 *
446 * common 460 * common
447 * 461 *
448 **************************************************/ 462 **************************************************/
449 463
450 464
451ODevice::ODevice ( ) 465ODevice::ODevice ( )
452{ 466{
453 d = new ODeviceData; 467 d = new ODeviceData;
454 468
455 d-> m_modelstr = "Unknown"; 469 d-> m_modelstr = "Unknown";
456 d-> m_model = Model_Unknown; 470 d-> m_model = Model_Unknown;
457 d-> m_vendorstr = "Unknown"; 471 d-> m_vendorstr = "Unknown";
458 d-> m_vendor = Vendor_Unknown; 472 d-> m_vendor = Vendor_Unknown;
459 d-> m_systemstr = "Unknown"; 473 d-> m_systemstr = "Unknown";
460 d-> m_system = System_Unknown; 474 d-> m_system = System_Unknown;
461 d-> m_sysverstr = "0.0"; 475 d-> m_sysverstr = "0.0";
462 d-> m_rotation = Rot0; 476 d-> m_rotation = Rot0;
463 d-> m_direction = CW; 477 d-> m_direction = CW;
464 478
465 d-> m_holdtime = 1000; // 1000ms 479 d-> m_holdtime = 1000; // 1000ms
466 d-> m_buttons = 0; 480 d-> m_buttons = 0;
467 d-> m_cpu_frequencies = new QStrList; 481 d-> m_cpu_frequencies = new QStrList;
468} 482}
469 483
470void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 484void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
471{ 485{
472 if ( msg == "deviceButtonMappingChanged()" ) { 486 if ( msg == "deviceButtonMappingChanged()" ) {
473 reloadButtonMapping ( ); 487 reloadButtonMapping ( );
474 } 488 }
475} 489}
476 490
477void ODevice::init ( ) 491void ODevice::init ( )
478{ 492{
479} 493}
480 494
481/** 495/**
482 * This method initialises the button mapping 496 * This method initialises the button mapping
483 */ 497 */
484void ODevice::initButtons ( ) 498void ODevice::initButtons ( )
485{ 499{
486 if ( d-> m_buttons ) 500 if ( d-> m_buttons )
487 return; 501 return;
488 502
489 // Simulation uses iPAQ 3660 device buttons 503 // Simulation uses iPAQ 3660 device buttons
490 504
491 qDebug ( "init Buttons" ); 505 qDebug ( "init Buttons" );
492 d-> m_buttons = new QValueList <ODeviceButton>; 506 d-> m_buttons = new QValueList <ODeviceButton>;
493 507
494 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 508 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
495 i_button *ib = ipaq_buttons + i; 509 i_button *ib = ipaq_buttons + i;
496 ODeviceButton b; 510 ODeviceButton b;
497 511
498 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 512 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
499 b. setKeycode ( ib-> code ); 513 b. setKeycode ( ib-> code );
500 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 514 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
501 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 515 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
502 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 516 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
503 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 517 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
504 d-> m_buttons-> append ( b ); 518 d-> m_buttons-> append ( b );
505 } 519 }
506 } 520 }
507 reloadButtonMapping ( ); 521 reloadButtonMapping ( );
508 522
509 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 523 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
510 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 524 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
511} 525}
512 526
513ODevice::~ODevice ( ) 527ODevice::~ODevice ( )
514{ 528{
515// we leak m_devicebuttons and m_cpu_frequency 529// we leak m_devicebuttons and m_cpu_frequency
516// but it's a singleton and it is not so importantant 530// but it's a singleton and it is not so importantant
517// -zecke 531// -zecke
518 delete d; 532 delete d;
519} 533}
520 534
521bool ODevice::setSoftSuspend ( bool /*soft*/ ) 535bool ODevice::setSoftSuspend ( bool /*soft*/ )
522{ 536{
523 return false; 537 return false;
524} 538}
525 539
526//#include <linux/apm_bios.h> 540//#include <linux/apm_bios.h>
527 541
528#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 542#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
529 543
530/** 544/**
531 * This method will try to suspend the device 545 * This method will try to suspend the device
@@ -890,193 +904,193 @@ const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
890} 904}
891 905
892void ODevice::reloadButtonMapping ( ) 906void ODevice::reloadButtonMapping ( )
893{ 907{
894 initButtons ( ); 908 initButtons ( );
895 909
896 Config cfg ( "ButtonSettings" ); 910 Config cfg ( "ButtonSettings" );
897 911
898 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 912 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
899 ODeviceButton &b = ( *d-> m_buttons ) [i]; 913 ODeviceButton &b = ( *d-> m_buttons ) [i];
900 QString group = "Button" + QString::number ( i ); 914 QString group = "Button" + QString::number ( i );
901 915
902 QCString pch, hch; 916 QCString pch, hch;
903 QCString pm, hm; 917 QCString pm, hm;
904 QByteArray pdata, hdata; 918 QByteArray pdata, hdata;
905 919
906 if ( cfg. hasGroup ( group )) { 920 if ( cfg. hasGroup ( group )) {
907 cfg. setGroup ( group ); 921 cfg. setGroup ( group );
908 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 922 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
909 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 923 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
910 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 924 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
911 925
912 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 926 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
913 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 927 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
914 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 928 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
915 } 929 }
916 930
917 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 931 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
918 932
919 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 933 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
920 } 934 }
921} 935}
922 936
923void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 937void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
924{ 938{
925 initButtons ( ); 939 initButtons ( );
926 940
927 QString mb_chan; 941 QString mb_chan;
928 942
929 if ( button >= (int) d-> m_buttons-> count ( )) 943 if ( button >= (int) d-> m_buttons-> count ( ))
930 return; 944 return;
931 945
932 ODeviceButton &b = ( *d-> m_buttons ) [button]; 946 ODeviceButton &b = ( *d-> m_buttons ) [button];
933 b. setPressedAction ( action ); 947 b. setPressedAction ( action );
934 948
935 mb_chan=b. pressedAction ( ). channel ( ); 949 mb_chan=b. pressedAction ( ). channel ( );
936 950
937 Config buttonFile ( "ButtonSettings" ); 951 Config buttonFile ( "ButtonSettings" );
938 buttonFile. setGroup ( "Button" + QString::number ( button )); 952 buttonFile. setGroup ( "Button" + QString::number ( button ));
939 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 953 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
940 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 954 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
941 955
942 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 956 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
943 957
944 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 958 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
945} 959}
946 960
947void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 961void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
948{ 962{
949 initButtons ( ); 963 initButtons ( );
950 964
951 if ( button >= (int) d-> m_buttons-> count ( )) 965 if ( button >= (int) d-> m_buttons-> count ( ))
952 return; 966 return;
953 967
954 ODeviceButton &b = ( *d-> m_buttons ) [button]; 968 ODeviceButton &b = ( *d-> m_buttons ) [button];
955 b. setHeldAction ( action ); 969 b. setHeldAction ( action );
956 970
957 Config buttonFile ( "ButtonSettings" ); 971 Config buttonFile ( "ButtonSettings" );
958 buttonFile. setGroup ( "Button" + QString::number ( button )); 972 buttonFile. setGroup ( "Button" + QString::number ( button ));
959 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 973 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
960 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 974 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
961 975
962 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 976 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
963 977
964 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 978 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
965} 979}
966void ODevice::virtual_hook(int, void* ){ 980void ODevice::virtual_hook(int, void* ){
967 981
968} 982}
969 983
970/************************************************** 984/**************************************************
971 * 985 *
972 * Yopy 3500/3700 986 * Yopy 3500/3700
973 * 987 *
974 **************************************************/ 988 **************************************************/
975 989
976bool Yopy::isYopy ( ) 990bool Yopy::isYopy ( )
977{ 991{
978 QFile f( "/proc/cpuinfo" ); 992 QFile f( "/proc/cpuinfo" );
979 if ( f. open ( IO_ReadOnly ) ) { 993 if ( f. open ( IO_ReadOnly ) ) {
980 QTextStream ts ( &f ); 994 QTextStream ts ( &f );
981 QString line; 995 QString line;
982 while( line = ts. readLine ( ) ) { 996 while( line = ts. readLine ( ) ) {
983 if ( line. left ( 8 ) == "Hardware" ) { 997 if ( line. left ( 8 ) == "Hardware" ) {
984 int loc = line. find ( ":" ); 998 int loc = line. find ( ":" );
985 if ( loc != -1 ) { 999 if ( loc != -1 ) {
986 QString model = 1000 QString model =
987 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1001 line. mid ( loc + 2 ). simplifyWhiteSpace( );
988 return ( model == "Yopy" ); 1002 return ( model == "Yopy" );
989 } 1003 }
990 } 1004 }
991 } 1005 }
992 } 1006 }
993 return false; 1007 return false;
994} 1008}
995 1009
996void Yopy::init ( ) 1010void Yopy::init ( )
997{ 1011{
998 d-> m_vendorstr = "G.Mate"; 1012 d-> m_vendorstr = "G.Mate";
999 d-> m_vendor = Vendor_GMate; 1013 d-> m_vendor = Vendor_GMate;
1000 d-> m_modelstr = "Yopy3700"; 1014 d-> m_modelstr = "Yopy3700";
1001 d-> m_model = Model_Yopy_3700; 1015 d-> m_model = Model_Yopy_3700;
1002 d-> m_rotation = Rot0; 1016 d-> m_rotation = Rot0;
1003 1017
1004 d-> m_systemstr = "Linupy"; 1018 d-> m_systemstr = "Linupy";
1005 d-> m_system = System_Linupy; 1019 d-> m_system = System_Linupy;
1006 1020
1007 QFile f ( "/etc/issue" ); 1021 QFile f ( "/etc/issue" );
1008 if ( f. open ( IO_ReadOnly )) { 1022 if ( f. open ( IO_ReadOnly )) {
1009 QTextStream ts ( &f ); 1023 QTextStream ts ( &f );
1010 ts.readLine(); 1024 ts.readLine();
1011 d-> m_sysverstr = ts. readLine ( ); 1025 d-> m_sysverstr = ts. readLine ( );
1012 f. close ( ); 1026 f. close ( );
1013 } 1027 }
1014} 1028}
1015 1029
1016void Yopy::initButtons ( ) 1030void Yopy::initButtons ( )
1017{ 1031{
1018 if ( d-> m_buttons ) 1032 if ( d-> m_buttons )
1019 return; 1033 return;
1020 1034
1021 d-> m_buttons = new QValueList <ODeviceButton>; 1035 d-> m_buttons = new QValueList <ODeviceButton>;
1022 1036
1023 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1037 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1024 1038
1025 yopy_button *ib = yopy_buttons + i; 1039 yopy_button *ib = yopy_buttons + i;
1026 1040
1027 ODeviceButton b; 1041 ODeviceButton b;
1028 1042
1029 b. setKeycode ( ib-> code ); 1043 b. setKeycode ( ib-> code );
1030 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1044 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1031 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1045 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1032 b. setFactoryPresetPressedAction 1046 b. setFactoryPresetPressedAction
1033 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1047 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1034 b. setFactoryPresetHeldAction 1048 b. setFactoryPresetHeldAction
1035 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1049 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1036 1050
1037 d-> m_buttons-> append ( b ); 1051 d-> m_buttons-> append ( b );
1038 } 1052 }
1039 reloadButtonMapping ( ); 1053 reloadButtonMapping ( );
1040 1054
1041 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1055 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1042 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1056 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1043 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1057 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1044} 1058}
1045 1059
1046bool Yopy::suspend() 1060bool Yopy::suspend()
1047{ 1061{
1048 /* Opie for Yopy does not implement its own power management at the 1062 /* Opie for Yopy does not implement its own power management at the
1049 moment. The public version runs parallel to X, and relies on the 1063 moment. The public version runs parallel to X, and relies on the
1050 existing power management features. */ 1064 existing power management features. */
1051 return false; 1065 return false;
1052} 1066}
1053 1067
1054bool Yopy::setDisplayBrightness(int bright) 1068bool Yopy::setDisplayBrightness(int bright)
1055{ 1069{
1056 /* The code here works, but is disabled as the current version runs 1070 /* The code here works, but is disabled as the current version runs
1057 parallel to X, and relies on the existing backlight demon. */ 1071 parallel to X, and relies on the existing backlight demon. */
1058#if 0 1072#if 0
1059 if ( QFile::exists("/proc/sys/pm/light") ) { 1073 if ( QFile::exists("/proc/sys/pm/light") ) {
1060 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1074 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1061 if (fd >= 0 ) { 1075 if (fd >= 0 ) {
1062 if (bright) 1076 if (bright)
1063 ::write(fd, "1\n", 2); 1077 ::write(fd, "1\n", 2);
1064 else 1078 else
1065 ::write(fd, "0\n", 2); 1079 ::write(fd, "0\n", 2);
1066 ::close(fd); 1080 ::close(fd);
1067 return true; 1081 return true;
1068 } 1082 }
1069 } 1083 }
1070#endif 1084#endif
1071 return false; 1085 return false;
1072} 1086}
1073 1087
1074int Yopy::displayBrightnessResolution() const 1088int Yopy::displayBrightnessResolution() const
1075{ 1089{
1076 return 2; 1090 return 2;
1077} 1091}
1078 1092
1079/************************************************** 1093/**************************************************
1080 * 1094 *
1081 * iPAQ 1095 * iPAQ
1082 * 1096 *
@@ -2359,96 +2373,208 @@ bool Ramses::suspend ( )
2359 return false; 2373 return false;
2360} 2374}
2361 2375
2362/** 2376/**
2363 * This sets the display on or off 2377 * This sets the display on or off
2364 */ 2378 */
2365bool Ramses::setDisplayStatus(bool on) 2379bool Ramses::setDisplayStatus(bool on)
2366{ 2380{
2367 qDebug("Ramses::setDisplayStatus(%d)", on); 2381 qDebug("Ramses::setDisplayStatus(%d)", on);
2368#if 0 2382#if 0
2369 bool res = false; 2383 bool res = false;
2370 int fd; 2384 int fd;
2371 2385
2372 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 2386 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2373 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 2387 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2374 ::close(fd); 2388 ::close(fd);
2375 } 2389 }
2376 return res; 2390 return res;
2377#else 2391#else
2378 return true; 2392 return true;
2379#endif 2393#endif
2380} 2394}
2381 2395
2382 2396
2383/* 2397/*
2384 * We get something between 0..255 into us 2398 * We get something between 0..255 into us
2385*/ 2399*/
2386bool Ramses::setDisplayBrightness(int bright) 2400bool Ramses::setDisplayBrightness(int bright)
2387{ 2401{
2388 qDebug("Ramses::setDisplayBrightness(%d)", bright); 2402 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2389 bool res = false; 2403 bool res = false;
2390 int fd; 2404 int fd;
2391 2405
2392 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 2406 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2393 2407
2394 if (bright > 255 ) 2408 if (bright > 255 )
2395 bright = 255; 2409 bright = 255;
2396 if (bright < 0) 2410 if (bright < 0)
2397 bright = 0; 2411 bright = 0;
2398 2412
2399 // Turn backlight completely off 2413 // Turn backlight completely off
2400 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 2414 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
2401 char writeCommand[10]; 2415 char writeCommand[10];
2402 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 2416 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
2403 res = (::write(fd, writeCommand, count) != -1); 2417 res = (::write(fd, writeCommand, count) != -1);
2404 ::close(fd); 2418 ::close(fd);
2405 } 2419 }
2406 2420
2407 // scale backlight brightness to hardware 2421 // scale backlight brightness to hardware
2408 bright = 500-(bright * 500 / 255); 2422 bright = 500-(bright * 500 / 255);
2409 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 2423 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2410 qDebug(" %d -> pwm1", bright); 2424 qDebug(" %d -> pwm1", bright);
2411 char writeCommand[100]; 2425 char writeCommand[100];
2412 const int count = sprintf(writeCommand, "%d\n", bright); 2426 const int count = sprintf(writeCommand, "%d\n", bright);
2413 res = (::write(fd, writeCommand, count) != -1); 2427 res = (::write(fd, writeCommand, count) != -1);
2414 ::close(fd); 2428 ::close(fd);
2415 } 2429 }
2416 return res; 2430 return res;
2417} 2431}
2418 2432
2419 2433
2420int Ramses::displayBrightnessResolution() const 2434int Ramses::displayBrightnessResolution() const
2421{ 2435{
2422 return 32; 2436 return 32;
2423} 2437}
2424 2438
2425bool Ramses::setDisplayContrast(int contr) 2439bool Ramses::setDisplayContrast(int contr)
2426{ 2440{
2427 qDebug("Ramses::setDisplayContrast(%d)", contr); 2441 qDebug("Ramses::setDisplayContrast(%d)", contr);
2428 bool res = false; 2442 bool res = false;
2429 int fd; 2443 int fd;
2430 2444
2431 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 2445 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
2432 2446
2433 if (contr > 255 ) 2447 if (contr > 255 )
2434 contr = 255; 2448 contr = 255;
2435 if (contr < 0) 2449 if (contr < 0)
2436 contr = 0; 2450 contr = 0;
2437 contr = 90 - (contr * 20 / 255); 2451 contr = 90 - (contr * 20 / 255);
2438 2452
2439 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 2453 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2440 qDebug(" %d -> pwm0", contr); 2454 qDebug(" %d -> pwm0", contr);
2441 char writeCommand[100]; 2455 char writeCommand[100];
2442 const int count = sprintf(writeCommand, "%d\n", contr); 2456 const int count = sprintf(writeCommand, "%d\n", contr);
2443 res = (::write(fd, writeCommand, count) != -1); 2457 res = (::write(fd, writeCommand, count) != -1);
2444 res = true; 2458 res = true;
2445 ::close(fd); 2459 ::close(fd);
2446 } 2460 }
2447 return res; 2461 return res;
2448} 2462}
2449 2463
2450 2464
2451int Ramses::displayContrastResolution() const 2465int Ramses::displayContrastResolution() const
2452{ 2466{
2453 return 20; 2467 return 20;
2454} 2468}
2469
2470
2471/**************************************************
2472 * *
2473 * Jornada *
2474 * *
2475 **************************************************/
2476
2477
2478bool Jornada::isJornada ( )
2479{
2480 QFile f( "/proc/cpuinfo" );
2481 if ( f. open ( IO_ReadOnly ) ) {
2482 QTextStream ts ( &f );
2483 QString line;
2484 while( line = ts. readLine ( ) ) {
2485 if ( line. left ( 8 ) == "Hardware" ) {
2486 int loc = line. find ( ":" );
2487 if ( loc != -1 ) {
2488 QString model =
2489 line. mid ( loc + 2 ). simplifyWhiteSpace( );
2490 return ( model == "HP Jornada 56x" );
2491 }
2492 }
2493 }
2494 }
2495 return false;
2496}
2497
2498void Jornada::init ( )
2499{
2500 d-> m_vendorstr = "HP";
2501 d-> m_vendor = Vendor_HP;
2502 d-> m_modelstr = "Jornada 56x";
2503 d-> m_model = Model_Jornada_56x;
2504 d-> m_systemstr = "Familiar";
2505 d-> m_system = System_Familiar;
2506 d-> m_rotation = Rot0;
2507}
2508
2509void Jornada::initButtons ( )
2510{
2511 if ( d-> m_buttons )
2512 return;
2513
2514 // Simulation uses iPAQ 3660 device buttons
2515
2516 qDebug ( "init Buttons" );
2517 d-> m_buttons = new QValueList <ODeviceButton>;
2518
2519 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
2520 i_button *ib = ipaq_buttons + i;
2521 ODeviceButton b;
2522
2523 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
2524 b. setKeycode ( ib-> code );
2525 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
2526 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
2527 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
2528 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
2529 d-> m_buttons-> append ( b );
2530 }
2531 }
2532 reloadButtonMapping ( );
2533
2534 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2535 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
2536}
2537
2538int Jornada::displayBrightnessResolution ( ) const
2539{
2540}
2541
2542bool Jornada::setDisplayBrightness ( int bright )
2543{
2544 bool res = false;
2545 int fd;
2546
2547 if ( bright > 255 )
2548 bright = 255;
2549 if ( bright < 0 )
2550 bright = 0;
2551
2552 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
2553 FLITE_IN bl;
2554 bl. mode = 1;
2555 bl. pwr = bright ? 1 : 0;
2556 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
2557 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
2558 ::close ( fd );
2559 }
2560 return res;
2561}
2562
2563bool Jornada::setSoftSuspend ( bool soft )
2564{
2565 bool res = false;
2566 int fd;
2567
2568 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
2569 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
2570 res = true;
2571 else
2572 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
2573
2574 ::close ( fd );
2575 }
2576 else
2577 ::perror ( "/proc/sys/ts/suspend_button_mode" );
2578
2579 return res;
2580}