summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-21 17:15:01 (UTC)
committer kergoth <kergoth>2003-04-21 17:15:01 (UTC)
commitb3ec819dfed40b05b2bea1b1392de774bc1f572d (patch) (unidiff)
treec0e30307ba6623f49cda10ce35e7f3323b4062f8
parenteecb4b6d3c22466f273c3498b6370b1e1c67c726 (diff)
downloadopie-b3ec819dfed40b05b2bea1b1392de774bc1f572d.zip
opie-b3ec819dfed40b05b2bea1b1392de774bc1f572d.tar.gz
opie-b3ec819dfed40b05b2bea1b1392de774bc1f572d.tar.bz2
Final fix for the suspend bug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 501b601..62e3569 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,458 +1,454 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
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 bool m_qwsserver : 1;
60
61 QString m_vendorstr; 59 QString m_vendorstr;
62 OVendor m_vendor; 60 OVendor m_vendor;
63 61
64 QString m_modelstr; 62 QString m_modelstr;
65 OModel m_model; 63 OModel m_model;
66 64
67 QString m_systemstr; 65 QString m_systemstr;
68 OSystem m_system; 66 OSystem m_system;
69 67
70 QString m_sysverstr; 68 QString m_sysverstr;
71 69
72 Transformation m_rotation; 70 Transformation m_rotation;
73 ODirection m_direction; 71 ODirection m_direction;
74 72
75 QValueList <ODeviceButton> *m_buttons; 73 QValueList <ODeviceButton> *m_buttons;
76 uint m_holdtime; 74 uint m_holdtime;
77}; 75};
78 76
79 77
80class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 78class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
81protected: 79protected:
82 virtual void init ( ); 80 virtual void init ( );
83 virtual void initButtons ( ); 81 virtual void initButtons ( );
84 82
85public: 83public:
86 virtual bool setSoftSuspend ( bool soft ); 84 virtual bool setSoftSuspend ( bool soft );
87 85
88 virtual bool setDisplayBrightness ( int b ); 86 virtual bool setDisplayBrightness ( int b );
89 virtual int displayBrightnessResolution ( ) const; 87 virtual int displayBrightnessResolution ( ) const;
90 88
91 virtual void alarmSound ( ); 89 virtual void alarmSound ( );
92 90
93 virtual QValueList <OLed> ledList ( ) const; 91 virtual QValueList <OLed> ledList ( ) const;
94 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 92 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
95 virtual OLedState ledState ( OLed led ) const; 93 virtual OLedState ledState ( OLed led ) const;
96 virtual bool setLedState ( OLed led, OLedState st ); 94 virtual bool setLedState ( OLed led, OLedState st );
97 95
98 virtual bool hasLightSensor ( ) const; 96 virtual bool hasLightSensor ( ) const;
99 virtual int readLightSensor ( ); 97 virtual int readLightSensor ( );
100 virtual int lightSensorResolution ( ) const; 98 virtual int lightSensorResolution ( ) const;
101 99
102protected: 100protected:
103 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 );
104 virtual void timerEvent ( QTimerEvent *te ); 102 virtual void timerEvent ( QTimerEvent *te );
105 103
106 int m_power_timer; 104 int m_power_timer;
107 105
108 OLedState m_leds [2]; 106 OLedState m_leds [2];
109}; 107};
110 108
111class Zaurus : public ODevice { 109class Zaurus : public ODevice {
112protected: 110protected:
113 virtual void init ( ); 111 virtual void init ( );
114 virtual void initButtons ( ); 112 virtual void initButtons ( );
115 113
116public: 114public:
117 virtual bool setSoftSuspend ( bool soft ); 115 virtual bool setSoftSuspend ( bool soft );
118 116
119 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
120 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
121 119
122 virtual void alarmSound ( ); 120 virtual void alarmSound ( );
123 virtual void keySound ( ); 121 virtual void keySound ( );
124 virtual void touchSound ( ); 122 virtual void touchSound ( );
125 123
126 virtual QValueList <OLed> ledList ( ) const; 124 virtual QValueList <OLed> ledList ( ) const;
127 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 125 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
128 virtual OLedState ledState ( OLed led ) const; 126 virtual OLedState ledState ( OLed led ) const;
129 virtual bool setLedState ( OLed led, OLedState st ); 127 virtual bool setLedState ( OLed led, OLedState st );
130 128
131protected: 129protected:
132 virtual void buzzer ( int snd ); 130 virtual void buzzer ( int snd );
133 131
134 OLedState m_leds [1]; 132 OLedState m_leds [1];
135}; 133};
136 134
137 135
138struct i_button { 136struct i_button {
139 uint model; 137 uint model;
140 Qt::Key code; 138 Qt::Key code;
141 char *utext; 139 char *utext;
142 char *pix; 140 char *pix;
143 char *fpressedservice; 141 char *fpressedservice;
144 char *fpressedaction; 142 char *fpressedaction;
145 char *fheldservice; 143 char *fheldservice;
146 char *fheldaction; 144 char *fheldaction;
147} ipaq_buttons [] = { 145} ipaq_buttons [] = {
148 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 146 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
149 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 147 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
150 "devicebuttons/ipaq_calendar", 148 "devicebuttons/ipaq_calendar",
151 "datebook", "nextView()", 149 "datebook", "nextView()",
152 "today", "raise()" }, 150 "today", "raise()" },
153 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 151 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
154 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 152 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
155 "devicebuttons/ipaq_contact", 153 "devicebuttons/ipaq_contact",
156 "addressbook", "raise()", 154 "addressbook", "raise()",
157 "addressbook", "beamBusinessCard()" }, 155 "addressbook", "beamBusinessCard()" },
158 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 156 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
159 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 157 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
160 "devicebuttons/ipaq_menu", 158 "devicebuttons/ipaq_menu",
161 "QPE/TaskBar", "toggleMenu()", 159 "QPE/TaskBar", "toggleMenu()",
162 "QPE/TaskBar", "toggleStartMenu()" }, 160 "QPE/TaskBar", "toggleStartMenu()" },
163 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 161 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
164 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 162 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
165 "devicebuttons/ipaq_mail", 163 "devicebuttons/ipaq_mail",
166 "mail", "raise()", 164 "mail", "raise()",
167 "mail", "newMail()" }, 165 "mail", "newMail()" },
168 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 166 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
169 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 167 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
170 "devicebuttons/ipaq_home", 168 "devicebuttons/ipaq_home",
171 "QPE/Launcher", "home()", 169 "QPE/Launcher", "home()",
172 "buttonsettings", "raise()" }, 170 "buttonsettings", "raise()" },
173 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 171 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
174 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 172 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
175 "devicebuttons/ipaq_record", 173 "devicebuttons/ipaq_record",
176 "QPE/VMemo", "toggleRecord()", 174 "QPE/VMemo", "toggleRecord()",
177 "sound", "raise()" }, 175 "sound", "raise()" },
178}; 176};
179 177
180struct z_button { 178struct z_button {
181 Qt::Key code; 179 Qt::Key code;
182 char *utext; 180 char *utext;
183 char *pix; 181 char *pix;
184 char *fpressedservice; 182 char *fpressedservice;
185 char *fpressedaction; 183 char *fpressedaction;
186 char *fheldservice; 184 char *fheldservice;
187 char *fheldaction; 185 char *fheldaction;
188} z_buttons [] = { 186} z_buttons [] = {
189 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 187 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
190 "devicebuttons/z_calendar", 188 "devicebuttons/z_calendar",
191 "datebook", "nextView()", 189 "datebook", "nextView()",
192 "today", "raise()" }, 190 "today", "raise()" },
193 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 191 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
194 "devicebuttons/z_contact", 192 "devicebuttons/z_contact",
195 "addressbook", "raise()", 193 "addressbook", "raise()",
196 "addressbook", "beamBusinessCard()" }, 194 "addressbook", "beamBusinessCard()" },
197 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 195 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
198 "devicebuttons/z_home", 196 "devicebuttons/z_home",
199 "QPE/Launcher", "home()", 197 "QPE/Launcher", "home()",
200 "buttonsettings", "raise()" }, 198 "buttonsettings", "raise()" },
201 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 199 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
202 "devicebuttons/z_menu", 200 "devicebuttons/z_menu",
203 "QPE/TaskBar", "toggleMenu()", 201 "QPE/TaskBar", "toggleMenu()",
204 "QPE/TaskBar", "toggleStartMenu()" }, 202 "QPE/TaskBar", "toggleStartMenu()" },
205 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 203 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
206 "devicebuttons/z_mail", 204 "devicebuttons/z_mail",
207 "mail", "raise()", 205 "mail", "raise()",
208 "mail", "newMail()" }, 206 "mail", "newMail()" },
209}; 207};
210 208
211struct z_button z_buttons_c700 [] = { 209struct z_button z_buttons_c700 [] = {
212 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 210 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
213 "devicebuttons/z_calendar", 211 "devicebuttons/z_calendar",
214 "datebook", "nextView()", 212 "datebook", "nextView()",
215 "today", "raise()" }, 213 "today", "raise()" },
216 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 214 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
217 "devicebuttons/z_contact", 215 "devicebuttons/z_contact",
218 "addressbook", "raise()", 216 "addressbook", "raise()",
219 "addressbook", "beamBusinessCard()" }, 217 "addressbook", "beamBusinessCard()" },
220 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 218 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
221 "devicebuttons/z_home", 219 "devicebuttons/z_home",
222 "QPE/Launcher", "home()", 220 "QPE/Launcher", "home()",
223 "buttonsettings", "raise()" }, 221 "buttonsettings", "raise()" },
224 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 222 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
225 "devicebuttons/z_menu", 223 "devicebuttons/z_menu",
226 "QPE/TaskBar", "toggleMenu()", 224 "QPE/TaskBar", "toggleMenu()",
227 "QPE/TaskBar", "toggleStartMenu()" }, 225 "QPE/TaskBar", "toggleStartMenu()" },
228 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 226 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
229 "", 227 "",
230 "QPE/Rotation", "flip()", 228 "QPE/Rotation", "flip()",
231 "QPE/Rotation", "flip()" }, 229 "QPE/Rotation", "flip()" },
232}; 230};
233 231
234static QCString makeChannel ( const char *str ) 232static QCString makeChannel ( const char *str )
235{ 233{
236 if ( str && !::strchr ( str, '/' )) 234 if ( str && !::strchr ( str, '/' ))
237 return QCString ( "QPE/Application/" ) + str; 235 return QCString ( "QPE/Application/" ) + str;
238 else 236 else
239 return str; 237 return str;
240} 238}
241 239
242 240static inline bool isQWS()
243 241{
242 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
243}
244 244
245ODevice *ODevice::inst ( ) 245ODevice *ODevice::inst ( )
246{ 246{
247 static ODevice *dev = 0; 247 static ODevice *dev = 0;
248 248
249 if ( !dev ) { 249 if ( !dev ) {
250 if ( QFile::exists ( "/proc/hal/model" )) 250 if ( QFile::exists ( "/proc/hal/model" ))
251 dev = new iPAQ ( ); 251 dev = new iPAQ ( );
252 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 252 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
253 dev = new Zaurus ( ); 253 dev = new Zaurus ( );
254 else 254 else
255 dev = new ODevice ( ); 255 dev = new ODevice ( );
256 256
257 dev-> init ( ); 257 dev-> init ( );
258 } 258 }
259 return dev; 259 return dev;
260} 260}
261 261
262 262
263/************************************************** 263/**************************************************
264 * 264 *
265 * common 265 * common
266 * 266 *
267 **************************************************/ 267 **************************************************/
268 268
269 269
270ODevice::ODevice ( ) 270ODevice::ODevice ( )
271{ 271{
272 d = new ODeviceData; 272 d = new ODeviceData;
273 273
274 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
275
276 d-> m_modelstr = "Unknown"; 274 d-> m_modelstr = "Unknown";
277 d-> m_model = Model_Unknown; 275 d-> m_model = Model_Unknown;
278 d-> m_vendorstr = "Unknown"; 276 d-> m_vendorstr = "Unknown";
279 d-> m_vendor = Vendor_Unknown; 277 d-> m_vendor = Vendor_Unknown;
280 d-> m_systemstr = "Unknown"; 278 d-> m_systemstr = "Unknown";
281 d-> m_system = System_Unknown; 279 d-> m_system = System_Unknown;
282 d-> m_sysverstr = "0.0"; 280 d-> m_sysverstr = "0.0";
283 d-> m_rotation = Rot0; 281 d-> m_rotation = Rot0;
284 d-> m_direction = CW; 282 d-> m_direction = CW;
285 283
286 d-> m_holdtime = 1000; // 1000ms 284 d-> m_holdtime = 1000; // 1000ms
287 d-> m_buttons = 0; 285 d-> m_buttons = 0;
288} 286}
289 287
290void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 288void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
291{ 289{
292 if ( msg == "deviceButtonMappingChanged()" ) { 290 if ( msg == "deviceButtonMappingChanged()" ) {
293 reloadButtonMapping ( ); 291 reloadButtonMapping ( );
294 } 292 }
295} 293}
296 294
297void ODevice::init ( ) 295void ODevice::init ( )
298{ 296{
299} 297}
300 298
301/** 299/**
302 * This method initialises the button mapping 300 * This method initialises the button mapping
303 */ 301 */
304void ODevice::initButtons ( ) 302void ODevice::initButtons ( )
305{ 303{
306 if ( d-> m_buttons ) 304 if ( d-> m_buttons )
307 return; 305 return;
308 306
309 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
310
311 // Simulation uses iPAQ 3660 device buttons 307 // Simulation uses iPAQ 3660 device buttons
312 308
313 qDebug ( "init Buttons" ); 309 qDebug ( "init Buttons" );
314 d-> m_buttons = new QValueList <ODeviceButton>; 310 d-> m_buttons = new QValueList <ODeviceButton>;
315 311
316 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 312 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
317 i_button *ib = ipaq_buttons + i; 313 i_button *ib = ipaq_buttons + i;
318 ODeviceButton b; 314 ODeviceButton b;
319 315
320 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 316 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
321 b. setKeycode ( ib-> code ); 317 b. setKeycode ( ib-> code );
322 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 318 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
323 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 319 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
324 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 320 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
325 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 321 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
326 d-> m_buttons-> append ( b ); 322 d-> m_buttons-> append ( b );
327 } 323 }
328 } 324 }
329 reloadButtonMapping ( ); 325 reloadButtonMapping ( );
330 326
331 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 327 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
332 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 328 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
333} 329}
334 330
335ODevice::~ODevice ( ) 331ODevice::~ODevice ( )
336{ 332{
337 delete d; 333 delete d;
338} 334}
339 335
340bool ODevice::setSoftSuspend ( bool /*soft*/ ) 336bool ODevice::setSoftSuspend ( bool /*soft*/ )
341{ 337{
342 return false; 338 return false;
343} 339}
344 340
345//#include <linux/apm_bios.h> 341//#include <linux/apm_bios.h>
346 342
347#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 343#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
348 344
349/** 345/**
350 * This method will try to suspend the device 346 * This method will try to suspend the device
351 * It only works if the user is the QWS Server and the apm application 347 * It only works if the user is the QWS Server and the apm application
352 * is installed. 348 * is installed.
353 * It tries to suspend and then waits some time cause some distributions 349 * It tries to suspend and then waits some time cause some distributions
354 * do have asynchronus apm implementations. 350 * do have asynchronus apm implementations.
355 * This method will either fail and return false or it'll suspend the 351 * This method will either fail and return false or it'll suspend the
356 * device and return once the device got woken up 352 * device and return once the device got woken up
357 * 353 *
358 * @return if the device got suspended 354 * @return if the device got suspended
359 */ 355 */
360bool ODevice::suspend ( ) 356bool ODevice::suspend ( )
361{ 357{
362 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 358 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
363 return false; 359 return false;
364 360
365 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 361 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
366 return false; 362 return false;
367 363
368 bool res = false; 364 bool res = false;
369 365
370 struct timeval tvs, tvn; 366 struct timeval tvs, tvn;
371 ::gettimeofday ( &tvs, 0 ); 367 ::gettimeofday ( &tvs, 0 );
372 368
373 ::sync ( ); // flush fs caches 369 ::sync ( ); // flush fs caches
374 res = ( ::system ( "apm --suspend" ) == 0 ); 370 res = ( ::system ( "apm --suspend" ) == 0 );
375 371
376 // This is needed because the iPAQ apm implementation is asynchronous and we 372 // This is needed because the iPAQ apm implementation is asynchronous and we
377 // can not be sure when exactly the device is really suspended 373 // can not be sure when exactly the device is really suspended
378 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 374 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
379 375
380 if ( res ) { 376 if ( res ) {
381 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 377 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
382 ::usleep ( 200 * 1000 ); 378 ::usleep ( 200 * 1000 );
383 ::gettimeofday ( &tvn, 0 ); 379 ::gettimeofday ( &tvn, 0 );
384 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 380 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
385 } 381 }
386 382
387 return res; 383 return res;
388} 384}
389 385
390//#include <linux/fb.h> better not rely on kernel headers in userspace ... 386//#include <linux/fb.h> better not rely on kernel headers in userspace ...
391 387
392#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 388#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
393 389
394/* VESA Blanking Levels */ 390/* VESA Blanking Levels */
395#define VESA_NO_BLANKING 0 391#define VESA_NO_BLANKING 0
396#define VESA_VSYNC_SUSPEND 1 392#define VESA_VSYNC_SUSPEND 1
397#define VESA_HSYNC_SUSPEND 2 393#define VESA_HSYNC_SUSPEND 2
398#define VESA_POWERDOWN 3 394#define VESA_POWERDOWN 3
399 395
400/** 396/**
401 * This sets the display on or off 397 * This sets the display on or off
402 */ 398 */
403bool ODevice::setDisplayStatus ( bool on ) 399bool ODevice::setDisplayStatus ( bool on )
404{ 400{
405 if ( d-> m_model == Model_Unknown ) 401 if ( d-> m_model == Model_Unknown )
406 return false; 402 return false;
407 403
408 bool res = false; 404 bool res = false;
409 int fd; 405 int fd;
410 406
411 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 407 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
412 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 408 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
413 ::close ( fd ); 409 ::close ( fd );
414 } 410 }
415 return res; 411 return res;
416} 412}
417 413
418/** 414/**
419 * This sets the display brightness 415 * This sets the display brightness
420 * @return success or failure 416 * @return success or failure
421 */ 417 */
422bool ODevice::setDisplayBrightness ( int p) 418bool ODevice::setDisplayBrightness ( int p)
423{ 419{
424 Q_UNUSED( p ) 420 Q_UNUSED( p )
425 return false; 421 return false;
426} 422}
427 423
428int ODevice::displayBrightnessResolution ( ) const 424int ODevice::displayBrightnessResolution ( ) const
429{ 425{
430 return 16; 426 return 16;
431} 427}
432 428
433/** 429/**
434 * This returns the vendor as string 430 * This returns the vendor as string
435 * @return Vendor as QString 431 * @return Vendor as QString
436 */ 432 */
437QString ODevice::vendorString ( ) const 433QString ODevice::vendorString ( ) const
438{ 434{
439 return d-> m_vendorstr; 435 return d-> m_vendorstr;
440} 436}
441 437
442/** 438/**
443 * This returns the vendor as one of the values of OVendor 439 * This returns the vendor as one of the values of OVendor
444 * @return OVendor 440 * @return OVendor
445 */ 441 */
446OVendor ODevice::vendor ( ) const 442OVendor ODevice::vendor ( ) const
447{ 443{
448 return d-> m_vendor; 444 return d-> m_vendor;
449} 445}
450 446
451/** 447/**
452 * This returns the model as a string 448 * This returns the model as a string
453 * @return A string representing the model 449 * @return A string representing the model
454 */ 450 */
455QString ODevice::modelString ( ) const 451QString ODevice::modelString ( ) const
456{ 452{
457 return d-> m_modelstr; 453 return d-> m_modelstr;
458} 454}
@@ -714,195 +710,193 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
714 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 710 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
715 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 711 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
716 712
717 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 713 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
718 714
719 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 715 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
720} 716}
721 717
722 718
723 719
724 720
725/************************************************** 721/**************************************************
726 * 722 *
727 * iPAQ 723 * iPAQ
728 * 724 *
729 **************************************************/ 725 **************************************************/
730 726
731void iPAQ::init ( ) 727void iPAQ::init ( )
732{ 728{
733 d-> m_vendorstr = "HP"; 729 d-> m_vendorstr = "HP";
734 d-> m_vendor = Vendor_HP; 730 d-> m_vendor = Vendor_HP;
735 731
736 QFile f ( "/proc/hal/model" ); 732 QFile f ( "/proc/hal/model" );
737 733
738 if ( f. open ( IO_ReadOnly )) { 734 if ( f. open ( IO_ReadOnly )) {
739 QTextStream ts ( &f ); 735 QTextStream ts ( &f );
740 736
741 d-> m_modelstr = "H" + ts. readLine ( ); 737 d-> m_modelstr = "H" + ts. readLine ( );
742 738
743 if ( d-> m_modelstr == "H3100" ) 739 if ( d-> m_modelstr == "H3100" )
744 d-> m_model = Model_iPAQ_H31xx; 740 d-> m_model = Model_iPAQ_H31xx;
745 else if ( d-> m_modelstr == "H3600" ) 741 else if ( d-> m_modelstr == "H3600" )
746 d-> m_model = Model_iPAQ_H36xx; 742 d-> m_model = Model_iPAQ_H36xx;
747 else if ( d-> m_modelstr == "H3700" ) 743 else if ( d-> m_modelstr == "H3700" )
748 d-> m_model = Model_iPAQ_H37xx; 744 d-> m_model = Model_iPAQ_H37xx;
749 else if ( d-> m_modelstr == "H3800" ) 745 else if ( d-> m_modelstr == "H3800" )
750 d-> m_model = Model_iPAQ_H38xx; 746 d-> m_model = Model_iPAQ_H38xx;
751 else if ( d-> m_modelstr == "H3900" ) 747 else if ( d-> m_modelstr == "H3900" )
752 d-> m_model = Model_iPAQ_H39xx; 748 d-> m_model = Model_iPAQ_H39xx;
753 else 749 else
754 d-> m_model = Model_Unknown; 750 d-> m_model = Model_Unknown;
755 751
756 f. close ( ); 752 f. close ( );
757 } 753 }
758 754
759 switch ( d-> m_model ) { 755 switch ( d-> m_model ) {
760 case Model_iPAQ_H31xx: 756 case Model_iPAQ_H31xx:
761 case Model_iPAQ_H38xx: 757 case Model_iPAQ_H38xx:
762 d-> m_rotation = Rot90; 758 d-> m_rotation = Rot90;
763 break; 759 break;
764 case Model_iPAQ_H36xx: 760 case Model_iPAQ_H36xx:
765 case Model_iPAQ_H37xx: 761 case Model_iPAQ_H37xx:
766 case Model_iPAQ_H39xx: 762 case Model_iPAQ_H39xx:
767 default: 763 default:
768 d-> m_rotation = Rot270; 764 d-> m_rotation = Rot270;
769 break; 765 break;
770 } 766 }
771 767
772 f. setName ( "/etc/familiar-version" ); 768 f. setName ( "/etc/familiar-version" );
773 if ( f. open ( IO_ReadOnly )) { 769 if ( f. open ( IO_ReadOnly )) {
774 d-> m_systemstr = "Familiar"; 770 d-> m_systemstr = "Familiar";
775 d-> m_system = System_Familiar; 771 d-> m_system = System_Familiar;
776 772
777 QTextStream ts ( &f ); 773 QTextStream ts ( &f );
778 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 774 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
779 775
780 f. close ( ); 776 f. close ( );
781 } else { 777 } else {
782 f. setName ( "/etc/oz_version" ); 778 f. setName ( "/etc/oz_version" );
783 779
784 if ( f. open ( IO_ReadOnly )) { 780 if ( f. open ( IO_ReadOnly )) {
785 d-> m_systemstr = "OpenEmbedded/iPaq"; 781 d-> m_systemstr = "OpenEmbedded/iPaq";
786 d-> m_system = System_Familiar; 782 d-> m_system = System_Familiar;
787 783
788 QTextStream ts ( &f ); 784 QTextStream ts ( &f );
789 ts.setDevice ( &f ); 785 ts.setDevice ( &f );
790 d-> m_sysverstr = ts. readLine ( ); 786 d-> m_sysverstr = ts. readLine ( );
791 f. close ( ); 787 f. close ( );
792 } 788 }
793 } 789 }
794 790
795 791
796 792
797 793
798 794
799 m_leds [0] = m_leds [1] = Led_Off; 795 m_leds [0] = m_leds [1] = Led_Off;
800 796
801 m_power_timer = 0; 797 m_power_timer = 0;
802 798
803} 799}
804 800
805void iPAQ::initButtons ( ) 801void iPAQ::initButtons ( )
806{ 802{
807 if ( d-> m_buttons ) 803 if ( d-> m_buttons )
808 return; 804 return;
809 805
810 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 806 if ( isQWS( ) )
811
812 if ( d-> m_qwsserver )
813 QWSServer::setKeyboardFilter ( this ); 807 QWSServer::setKeyboardFilter ( this );
814 808
815 d-> m_buttons = new QValueList <ODeviceButton>; 809 d-> m_buttons = new QValueList <ODeviceButton>;
816 810
817 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 811 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
818 i_button *ib = ipaq_buttons + i; 812 i_button *ib = ipaq_buttons + i;
819 ODeviceButton b; 813 ODeviceButton b;
820 814
821 if (( ib-> model & d-> m_model ) == d-> m_model ) { 815 if (( ib-> model & d-> m_model ) == d-> m_model ) {
822 b. setKeycode ( ib-> code ); 816 b. setKeycode ( ib-> code );
823 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 817 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
824 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 818 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
825 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 819 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
826 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 820 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
827 821
828 d-> m_buttons-> append ( b ); 822 d-> m_buttons-> append ( b );
829 } 823 }
830 } 824 }
831 reloadButtonMapping ( ); 825 reloadButtonMapping ( );
832 826
833 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 827 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
834 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 828 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
835} 829}
836 830
837 831
838//#include <linux/h3600_ts.h> // including kernel headers is evil ... 832//#include <linux/h3600_ts.h> // including kernel headers is evil ...
839 833
840typedef struct { 834typedef struct {
841 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 835 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
842 unsigned char TotalTime; /* Units of 5 seconds */ 836 unsigned char TotalTime; /* Units of 5 seconds */
843 unsigned char OnTime; /* units of 100m/s */ 837 unsigned char OnTime; /* units of 100m/s */
844 unsigned char OffTime; /* units of 100m/s */ 838 unsigned char OffTime; /* units of 100m/s */
845} LED_IN; 839} LED_IN;
846 840
847typedef struct { 841typedef struct {
848 unsigned char mode; 842 unsigned char mode;
849 unsigned char pwr; 843 unsigned char pwr;
850 unsigned char brightness; 844 unsigned char brightness;
851} FLITE_IN; 845} FLITE_IN;
852 846
853#define LED_ON OD_IOW( 'f', 5, LED_IN ) 847#define LED_ON OD_IOW( 'f', 5, LED_IN )
854#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 848#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
855 849
856 850
857QValueList <OLed> iPAQ::ledList ( ) const 851QValueList <OLed> iPAQ::ledList ( ) const
858{ 852{
859 QValueList <OLed> vl; 853 QValueList <OLed> vl;
860 vl << Led_Power; 854 vl << Led_Power;
861 855
862 if ( d-> m_model == Model_iPAQ_H38xx ) 856 if ( d-> m_model == Model_iPAQ_H38xx )
863 vl << Led_BlueTooth; 857 vl << Led_BlueTooth;
864 return vl; 858 return vl;
865} 859}
866 860
867QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 861QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
868{ 862{
869 QValueList <OLedState> vl; 863 QValueList <OLedState> vl;
870 864
871 if ( l == Led_Power ) 865 if ( l == Led_Power )
872 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 866 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
873 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 867 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
874 vl << Led_Off; // << Led_On << ??? 868 vl << Led_Off; // << Led_On << ???
875 869
876 return vl; 870 return vl;
877} 871}
878 872
879OLedState iPAQ::ledState ( OLed l ) const 873OLedState iPAQ::ledState ( OLed l ) const
880{ 874{
881 switch ( l ) { 875 switch ( l ) {
882 case Led_Power: 876 case Led_Power:
883 return m_leds [0]; 877 return m_leds [0];
884 case Led_BlueTooth: 878 case Led_BlueTooth:
885 return m_leds [1]; 879 return m_leds [1];
886 default: 880 default:
887 return Led_Off; 881 return Led_Off;
888 } 882 }
889} 883}
890 884
891bool iPAQ::setLedState ( OLed l, OLedState st ) 885bool iPAQ::setLedState ( OLed l, OLedState st )
892{ 886{
893 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 887 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
894 888
895 if ( l == Led_Power ) { 889 if ( l == Led_Power ) {
896 if ( fd >= 0 ) { 890 if ( fd >= 0 ) {
897 LED_IN leds; 891 LED_IN leds;
898 ::memset ( &leds, 0, sizeof( leds )); 892 ::memset ( &leds, 0, sizeof( leds ));
899 leds. TotalTime = 0; 893 leds. TotalTime = 0;
900 leds. OnTime = 0; 894 leds. OnTime = 0;
901 leds. OffTime = 1; 895 leds. OffTime = 1;
902 leds. OffOnBlink = 2; 896 leds. OffOnBlink = 2;
903 897
904 switch ( st ) { 898 switch ( st ) {
905 case Led_Off : leds. OffOnBlink = 0; break; 899 case Led_Off : leds. OffOnBlink = 0; break;
906 case Led_On : leds. OffOnBlink = 1; break; 900 case Led_On : leds. OffOnBlink = 1; break;
907 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 901 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
908 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 902 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
@@ -1114,194 +1108,192 @@ int iPAQ::lightSensorResolution ( ) const
1114 * 1108 *
1115 * Zaurus 1109 * Zaurus
1116 * 1110 *
1117 **************************************************/ 1111 **************************************************/
1118 1112
1119 1113
1120 1114
1121void Zaurus::init ( ) 1115void Zaurus::init ( )
1122{ 1116{
1123 d-> m_vendorstr = "Sharp"; 1117 d-> m_vendorstr = "Sharp";
1124 d-> m_vendor = Vendor_Sharp; 1118 d-> m_vendor = Vendor_Sharp;
1125 1119
1126 QFile f ( "/proc/filesystems" ); 1120 QFile f ( "/proc/filesystems" );
1127 QString model; 1121 QString model;
1128 1122
1129 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1123 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1130 d-> m_vendorstr = "OpenZaurus Team"; 1124 d-> m_vendorstr = "OpenZaurus Team";
1131 d-> m_systemstr = "OpenZaurus"; 1125 d-> m_systemstr = "OpenZaurus";
1132 d-> m_system = System_OpenZaurus; 1126 d-> m_system = System_OpenZaurus;
1133 1127
1134 f. close ( ); 1128 f. close ( );
1135 1129
1136 f. setName ( "/etc/oz_version" ); 1130 f. setName ( "/etc/oz_version" );
1137 if ( f. open ( IO_ReadOnly )) { 1131 if ( f. open ( IO_ReadOnly )) {
1138 QTextStream ts ( &f ); 1132 QTextStream ts ( &f );
1139 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1133 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1140 f. close ( ); 1134 f. close ( );
1141 } 1135 }
1142 } 1136 }
1143 else { 1137 else {
1144 d-> m_systemstr = "Zaurus"; 1138 d-> m_systemstr = "Zaurus";
1145 d-> m_system = System_Zaurus; 1139 d-> m_system = System_Zaurus;
1146 } 1140 }
1147 1141
1148 f. setName ( "/proc/cpuinfo" ); 1142 f. setName ( "/proc/cpuinfo" );
1149 if ( f. open ( IO_ReadOnly ) ) { 1143 if ( f. open ( IO_ReadOnly ) ) {
1150 QTextStream ts ( &f ); 1144 QTextStream ts ( &f );
1151 QString line; 1145 QString line;
1152 while( line = ts. readLine ( ) ) { 1146 while( line = ts. readLine ( ) ) {
1153 if ( line. left ( 8 ) == "Hardware" ) 1147 if ( line. left ( 8 ) == "Hardware" )
1154 break; 1148 break;
1155 } 1149 }
1156 int loc = line. find ( ":" ); 1150 int loc = line. find ( ":" );
1157 if ( loc != -1 ) 1151 if ( loc != -1 )
1158 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1152 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1159 } 1153 }
1160 1154
1161 if ( model == "SHARP Corgi" ) { 1155 if ( model == "SHARP Corgi" ) {
1162 d-> m_model = Model_Zaurus_SLC700; 1156 d-> m_model = Model_Zaurus_SLC700;
1163 d-> m_modelstr = "Zaurus SL-C700"; 1157 d-> m_modelstr = "Zaurus SL-C700";
1164 } else if ( model == "SHARP Poodle" ) { 1158 } else if ( model == "SHARP Poodle" ) {
1165 d-> m_model = Model_Zaurus_SLB600; 1159 d-> m_model = Model_Zaurus_SLB600;
1166 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1160 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1167 } else if ( model = "Sharp-Collie" ) { 1161 } else if ( model = "Sharp-Collie" ) {
1168 d-> m_model = Model_Zaurus_SL5500; 1162 d-> m_model = Model_Zaurus_SL5500;
1169 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1163 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1170 } else { 1164 } else {
1171 d-> m_model = Model_Zaurus_SL5500; 1165 d-> m_model = Model_Zaurus_SL5500;
1172 d-> m_modelstr = "Zaurus (Model unknown)"; 1166 d-> m_modelstr = "Zaurus (Model unknown)";
1173 } 1167 }
1174 1168
1175 bool flipstate = false; 1169 bool flipstate = false;
1176 switch ( d-> m_model ) { 1170 switch ( d-> m_model ) {
1177 case Model_Zaurus_SLA300: 1171 case Model_Zaurus_SLA300:
1178 d-> m_rotation = Rot0; 1172 d-> m_rotation = Rot0;
1179 break; 1173 break;
1180 case Model_Zaurus_SLC700: 1174 case Model_Zaurus_SLC700:
1181 // Note: need to 1) set flipstate based on physical screen orientation 1175 // Note: need to 1) set flipstate based on physical screen orientation
1182 // and 2) check to see if the user overrode the rotation direction 1176 // and 2) check to see if the user overrode the rotation direction
1183 // using appearance, and if so, remove that item from the Config to 1177 // using appearance, and if so, remove that item from the Config to
1184 // ensure the rotate applet flips us back to the previous state. 1178 // ensure the rotate applet flips us back to the previous state.
1185 if ( flipstate ) { 1179 if ( flipstate ) {
1186 // 480x640 1180 // 480x640
1187 d-> m_rotation = Rot0; 1181 d-> m_rotation = Rot0;
1188 d-> m_direction = CW; 1182 d-> m_direction = CW;
1189 } else { 1183 } else {
1190 // 640x480 1184 // 640x480
1191 d-> m_rotation = Rot270; 1185 d-> m_rotation = Rot270;
1192 d-> m_direction = CCW; 1186 d-> m_direction = CCW;
1193 } 1187 }
1194 break; 1188 break;
1195 case Model_Zaurus_SLB600: 1189 case Model_Zaurus_SLB600:
1196 case Model_Zaurus_SL5500: 1190 case Model_Zaurus_SL5500:
1197 case Model_Zaurus_SL5000: 1191 case Model_Zaurus_SL5000:
1198 default: 1192 default:
1199 d-> m_rotation = Rot270; 1193 d-> m_rotation = Rot270;
1200 break; 1194 break;
1201 } 1195 }
1202 m_leds [0] = Led_Off; 1196 m_leds [0] = Led_Off;
1203} 1197}
1204 1198
1205void Zaurus::initButtons ( ) 1199void Zaurus::initButtons ( )
1206{ 1200{
1207 if ( d-> m_buttons ) 1201 if ( d-> m_buttons )
1208 return; 1202 return;
1209 1203
1210 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
1211
1212 d-> m_buttons = new QValueList <ODeviceButton>; 1204 d-> m_buttons = new QValueList <ODeviceButton>;
1213 1205
1214 struct z_button * pz_buttons; 1206 struct z_button * pz_buttons;
1215 int buttoncount; 1207 int buttoncount;
1216 switch ( d-> m_model ) { 1208 switch ( d-> m_model ) {
1217 case Model_Zaurus_SLC700: 1209 case Model_Zaurus_SLC700:
1218 pz_buttons = z_buttons_c700; 1210 pz_buttons = z_buttons_c700;
1219 buttoncount = ARRAY_SIZE(z_buttons_c700); 1211 buttoncount = ARRAY_SIZE(z_buttons_c700);
1220 break; 1212 break;
1221 default: 1213 default:
1222 pz_buttons = z_buttons; 1214 pz_buttons = z_buttons;
1223 buttoncount = ARRAY_SIZE(z_buttons); 1215 buttoncount = ARRAY_SIZE(z_buttons);
1224 break; 1216 break;
1225 } 1217 }
1226 1218
1227 for ( int i = 0; i < buttoncount; i++ ) { 1219 for ( int i = 0; i < buttoncount; i++ ) {
1228 struct z_button *zb = pz_buttons + i; 1220 struct z_button *zb = pz_buttons + i;
1229 ODeviceButton b; 1221 ODeviceButton b;
1230 1222
1231 b. setKeycode ( zb-> code ); 1223 b. setKeycode ( zb-> code );
1232 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1224 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1233 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1225 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1234 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1226 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1235 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1227 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1236 1228
1237 d-> m_buttons-> append ( b ); 1229 d-> m_buttons-> append ( b );
1238 } 1230 }
1239 1231
1240 reloadButtonMapping ( ); 1232 reloadButtonMapping ( );
1241 1233
1242 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1234 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1243 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1235 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1244} 1236}
1245 1237
1246#include <unistd.h> 1238#include <unistd.h>
1247#include <fcntl.h> 1239#include <fcntl.h>
1248#include <sys/ioctl.h> 1240#include <sys/ioctl.h>
1249 1241
1250//#include <asm/sharp_char.h> // including kernel headers is evil ... 1242//#include <asm/sharp_char.h> // including kernel headers is evil ...
1251 1243
1252#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1244#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1253 1245
1254 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1246 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1255#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1247#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1256 1248
1257#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1249#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1258#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1250#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1259#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1251#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1260 1252
1261/* --- for SHARP_BUZZER device --- */ 1253/* --- for SHARP_BUZZER device --- */
1262 1254
1263 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1255 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1264//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1256//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1265 1257
1266#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1258#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1267#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1259#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1268#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1260#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1269#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1261#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1270#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1262#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1271 1263
1272//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1264//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1273//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1265//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1274 1266
1275//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1267//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1276//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1268//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1277//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1269//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1278//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1270//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1279//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1271//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1280//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1272//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1281//#define SHARP_PDA_APPSTART 9 /* application start */ 1273//#define SHARP_PDA_APPSTART 9 /* application start */
1282//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1274//#define SHARP_PDA_APPQUIT 10 /* application ends */
1283 1275
1284//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1276//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1285//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1277//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1286//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1278//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1287//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1279//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1288// 1280//
1289 1281
1290 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1282 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1291#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1283#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1292 1284
1293typedef struct sharp_led_status { 1285typedef struct sharp_led_status {
1294 int which; /* select which LED status is wanted. */ 1286 int which; /* select which LED status is wanted. */
1295 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1287 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1296} sharp_led_status; 1288} sharp_led_status;
1297 1289
1298#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1290#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1299 1291
1300#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1292#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1301#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1293#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1302#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1294#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1303 1295
1304// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1296// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1305 1297
1306#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1298#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1307#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1299#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )