summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 82a0099..35d6cb4 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,1327 +1,1327 @@
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#ifndef QT_NO_SOUND 26#ifndef QT_NO_SOUND
27#include <linux/soundcard.h> 27#include <linux/soundcard.h>
28#endif 28#endif
29#include <math.h> 29#include <math.h>
30 30
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <qfile.h> 33#include <qfile.h>
34#include <qtextstream.h> 34#include <qtextstream.h>
35#include <qpe/sound.h> 35#include <qpe/sound.h>
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39 39
40#include "odevice.h" 40#include "odevice.h"
41 41
42#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
43 43
44#ifndef ARRAY_SIZE 44#ifndef ARRAY_SIZE
45#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 45#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
46#endif 46#endif
47 47
48// _IO and friends are only defined in kernel headers ... 48// _IO and friends are only defined in kernel headers ...
49 49
50#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 50#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
51 51
52#define OD_IO(type,number) OD_IOC(0,type,number,0) 52#define OD_IO(type,number) OD_IOC(0,type,number,0)
53#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 53#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
54#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 54#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
55#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 55#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
56 56
57using namespace Opie; 57using namespace Opie;
58 58
59class ODeviceData { 59class ODeviceData {
60public: 60public:
61 QString m_vendorstr; 61 QString m_vendorstr;
62 OVendor m_vendor; 62 OVendor m_vendor;
63 63
64 QString m_modelstr; 64 QString m_modelstr;
65 OModel m_model; 65 OModel m_model;
66 66
67 QString m_systemstr; 67 QString m_systemstr;
68 OSystem m_system; 68 OSystem m_system;
69 69
70 QString m_sysverstr; 70 QString m_sysverstr;
71 71
72 Transformation m_rotation; 72 Transformation m_rotation;
73 ODirection m_direction; 73 ODirection m_direction;
74 74
75 QValueList <ODeviceButton> *m_buttons; 75 QValueList <ODeviceButton> *m_buttons;
76 uint m_holdtime; 76 uint m_holdtime;
77 QStrList *m_cpu_frequencies; 77 QStrList *m_cpu_frequencies;
78}; 78};
79 79
80class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 80class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
81protected: 81protected:
82 virtual void init ( ); 82 virtual void init ( );
83 virtual void initButtons ( ); 83 virtual void initButtons ( );
84 84
85public: 85public:
86 virtual bool setSoftSuspend ( bool soft ); 86 virtual bool setSoftSuspend ( bool soft );
87 87
88 virtual bool setDisplayBrightness ( int b ); 88 virtual bool setDisplayBrightness ( int b );
89 virtual int displayBrightnessResolution ( ) const; 89 virtual int displayBrightnessResolution ( ) const;
90 90
91 virtual void alarmSound ( ); 91 virtual void alarmSound ( );
92 92
93 virtual QValueList <OLed> ledList ( ) const; 93 virtual QValueList <OLed> ledList ( ) const;
94 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 94 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
95 virtual OLedState ledState ( OLed led ) const; 95 virtual OLedState ledState ( OLed led ) const;
96 virtual bool setLedState ( OLed led, OLedState st ); 96 virtual bool setLedState ( OLed led, OLedState st );
97 97
98 virtual bool hasLightSensor ( ) const; 98 virtual bool hasLightSensor ( ) const;
99 virtual int readLightSensor ( ); 99 virtual int readLightSensor ( );
100 virtual int lightSensorResolution ( ) const; 100 virtual int lightSensorResolution ( ) const;
101 101
102protected: 102protected:
103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
104 virtual void timerEvent ( QTimerEvent *te ); 104 virtual void timerEvent ( QTimerEvent *te );
105 105
106 int m_power_timer; 106 int m_power_timer;
107 107
108 OLedState m_leds [2]; 108 OLedState m_leds [2];
109}; 109};
110 110
111class Jornada : public ODevice { 111class Jornada : public ODevice {
112protected: 112protected:
113 virtual void init ( ); 113 virtual void init ( );
114 //virtual void initButtons ( ); 114 //virtual void initButtons ( );
115public: 115public:
116 virtual bool setSoftSuspend ( bool soft ); 116 virtual bool setSoftSuspend ( bool soft );
117 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
119 static bool isJornada(); 119 static bool isJornada();
120 120
121}; 121};
122 122
123class Zaurus : public ODevice { 123class Zaurus : public ODevice {
124protected: 124protected:
125 virtual void init ( ); 125 virtual void init ( );
126 virtual void initButtons ( ); 126 virtual void initButtons ( );
127 127
128public: 128public:
129 virtual bool setSoftSuspend ( bool soft ); 129 virtual bool setSoftSuspend ( bool soft );
130 130
131 virtual bool setDisplayBrightness ( int b ); 131 virtual bool setDisplayBrightness ( int b );
132 virtual int displayBrightnessResolution ( ) const; 132 virtual int displayBrightnessResolution ( ) const;
133 133
134 virtual void alarmSound ( ); 134 virtual void alarmSound ( );
135 virtual void keySound ( ); 135 virtual void keySound ( );
136 virtual void touchSound ( ); 136 virtual void touchSound ( );
137 137
138 virtual QValueList <OLed> ledList ( ) const; 138 virtual QValueList <OLed> ledList ( ) const;
139 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 139 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
140 virtual OLedState ledState ( OLed led ) const; 140 virtual OLedState ledState ( OLed led ) const;
141 virtual bool setLedState ( OLed led, OLedState st ); 141 virtual bool setLedState ( OLed led, OLedState st );
142 142
143 virtual bool hasHingeSensor() const; 143 virtual bool hasHingeSensor() const;
144 virtual OHingeStatus readHingeSensor(); 144 virtual OHingeStatus readHingeSensor();
145 145
146 static bool isZaurus(); 146 static bool isZaurus();
147 147
148 // Does this break BC? 148 // Does this break BC?
149 virtual bool suspend ( ); 149 virtual bool suspend ( );
150 virtual Transformation rotation ( ) const; 150 virtual Transformation rotation ( ) const;
151 virtual ODirection direction ( ) const; 151 virtual ODirection direction ( ) const;
152 152
153protected: 153protected:
154 virtual void buzzer ( int snd ); 154 virtual void buzzer ( int snd );
155 155
156 OLedState m_leds [1]; 156 OLedState m_leds [1];
157 bool m_embedix; 157 bool m_embedix;
158}; 158};
159 159
160class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 160class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
161protected: 161protected:
162 virtual void init ( ); 162 virtual void init ( );
163 virtual void initButtons ( ); 163 virtual void initButtons ( );
164 164
165public: 165public:
166 virtual bool setSoftSuspend ( bool soft ); 166 virtual bool setSoftSuspend ( bool soft );
167 virtual bool suspend(); 167 virtual bool suspend();
168 168
169 virtual bool setDisplayStatus( bool on ); 169 virtual bool setDisplayStatus( bool on );
170 virtual bool setDisplayBrightness ( int b ); 170 virtual bool setDisplayBrightness ( int b );
171 virtual int displayBrightnessResolution ( ) const; 171 virtual int displayBrightnessResolution ( ) const;
172 172
173 virtual void alarmSound ( ); 173 virtual void alarmSound ( );
174 174
175 virtual QValueList <OLed> ledList ( ) const; 175 virtual QValueList <OLed> ledList ( ) const;
176 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 176 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
177 virtual OLedState ledState ( OLed led ) const; 177 virtual OLedState ledState ( OLed led ) const;
178 virtual bool setLedState ( OLed led, OLedState st ); 178 virtual bool setLedState ( OLed led, OLedState st );
179 179
180protected: 180protected:
181 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 181 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
182 virtual void timerEvent ( QTimerEvent *te ); 182 virtual void timerEvent ( QTimerEvent *te );
183 183
184 int m_power_timer; 184 int m_power_timer;
185 185
186 OLedState m_leds [1]; //FIXME check if really only one 186 OLedState m_leds [1]; //FIXME check if really only one
187}; 187};
188 188
189class Ramses : public ODevice, public QWSServer::KeyboardFilter { 189class Ramses : public ODevice, public QWSServer::KeyboardFilter {
190protected: 190protected:
191 virtual void init ( ); 191 virtual void init ( );
192 192
193public: 193public:
194 virtual bool setSoftSuspend ( bool soft ); 194 virtual bool setSoftSuspend ( bool soft );
195 virtual bool suspend ( ); 195 virtual bool suspend ( );
196 196
197 virtual bool setDisplayStatus( bool on ); 197 virtual bool setDisplayStatus( bool on );
198 virtual bool setDisplayBrightness ( int b ); 198 virtual bool setDisplayBrightness ( int b );
199 virtual int displayBrightnessResolution ( ) const; 199 virtual int displayBrightnessResolution ( ) const;
200 virtual bool setDisplayContrast ( int b ); 200 virtual bool setDisplayContrast ( int b );
201 virtual int displayContrastResolution ( ) const; 201 virtual int displayContrastResolution ( ) const;
202 202
203protected: 203protected:
204 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 204 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
205 virtual void timerEvent ( QTimerEvent *te ); 205 virtual void timerEvent ( QTimerEvent *te );
206 206
207 int m_power_timer; 207 int m_power_timer;
208}; 208};
209 209
210struct i_button { 210struct i_button {
211 uint model; 211 uint model;
212 Qt::Key code; 212 Qt::Key code;
213 char *utext; 213 char *utext;
214 char *pix; 214 char *pix;
215 char *fpressedservice; 215 char *fpressedservice;
216 char *fpressedaction; 216 char *fpressedaction;
217 char *fheldservice; 217 char *fheldservice;
218 char *fheldaction; 218 char *fheldaction;
219} ipaq_buttons [] = { 219} ipaq_buttons [] = {
220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
221 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 221 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
222 "devicebuttons/ipaq_calendar", 222 "devicebuttons/ipaq_calendar",
223 "datebook", "nextView()", 223 "datebook", "nextView()",
224 "today", "raise()" }, 224 "today", "raise()" },
225 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 225 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
226 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 226 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
227 "devicebuttons/ipaq_contact", 227 "devicebuttons/ipaq_contact",
228 "addressbook", "raise()", 228 "addressbook", "raise()",
229 "addressbook", "beamBusinessCard()" }, 229 "addressbook", "beamBusinessCard()" },
230 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 230 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
231 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 231 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
232 "devicebuttons/ipaq_menu", 232 "devicebuttons/ipaq_menu",
233 "QPE/TaskBar", "toggleMenu()", 233 "QPE/TaskBar", "toggleMenu()",
234 "QPE/TaskBar", "toggleStartMenu()" }, 234 "QPE/TaskBar", "toggleStartMenu()" },
235 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 235 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
236 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 236 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
237 "devicebuttons/ipaq_mail", 237 "devicebuttons/ipaq_mail",
238 "mail", "raise()", 238 "mail", "raise()",
239 "mail", "newMail()" }, 239 "mail", "newMail()" },
240 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 240 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
241 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 241 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
242 "devicebuttons/ipaq_home", 242 "devicebuttons/ipaq_home",
243 "QPE/Launcher", "home()", 243 "QPE/Launcher", "home()",
244 "buttonsettings", "raise()" }, 244 "buttonsettings", "raise()" },
245 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 245 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
246 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 246 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
247 "devicebuttons/ipaq_record", 247 "devicebuttons/ipaq_record",
248 "QPE/VMemo", "toggleRecord()", 248 "QPE/VMemo", "toggleRecord()",
249 "sound", "raise()" }, 249 "sound", "raise()" },
250}; 250};
251 251
252struct z_button { 252struct z_button {
253 Qt::Key code; 253 Qt::Key code;
254 char *utext; 254 char *utext;
255 char *pix; 255 char *pix;
256 char *fpressedservice; 256 char *fpressedservice;
257 char *fpressedaction; 257 char *fpressedaction;
258 char *fheldservice; 258 char *fheldservice;
259 char *fheldaction; 259 char *fheldaction;
260} z_buttons [] = { 260} z_buttons [] = {
261 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 261 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
262 "devicebuttons/z_calendar", 262 "devicebuttons/z_calendar",
263 "datebook", "nextView()", 263 "datebook", "nextView()",
264 "today", "raise()" }, 264 "today", "raise()" },
265 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 265 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
266 "devicebuttons/z_contact", 266 "devicebuttons/z_contact",
267 "addressbook", "raise()", 267 "addressbook", "raise()",
268 "addressbook", "beamBusinessCard()" }, 268 "addressbook", "beamBusinessCard()" },
269 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 269 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
270 "devicebuttons/z_home", 270 "devicebuttons/z_home",
271 "QPE/Launcher", "home()", 271 "QPE/Launcher", "home()",
272 "buttonsettings", "raise()" }, 272 "buttonsettings", "raise()" },
273 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 273 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
274 "devicebuttons/z_menu", 274 "devicebuttons/z_menu",
275 "QPE/TaskBar", "toggleMenu()", 275 "QPE/TaskBar", "toggleMenu()",
276 "QPE/TaskBar", "toggleStartMenu()" }, 276 "QPE/TaskBar", "toggleStartMenu()" },
277 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 277 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
278 "devicebuttons/z_mail", 278 "devicebuttons/z_mail",
279 "mail", "raise()", 279 "mail", "raise()",
280 "mail", "newMail()" }, 280 "mail", "newMail()" },
281}; 281};
282 282
283struct z_button z_buttons_c700 [] = { 283struct z_button z_buttons_c700 [] = {
284 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 284 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
285 "devicebuttons/z_calendar", 285 "devicebuttons/z_calendar",
286 "datebook", "nextView()", 286 "datebook", "nextView()",
287 "today", "raise()" }, 287 "today", "raise()" },
288 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 288 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
289 "devicebuttons/z_contact", 289 "devicebuttons/z_contact",
290 "addressbook", "raise()", 290 "addressbook", "raise()",
291 "addressbook", "beamBusinessCard()" }, 291 "addressbook", "beamBusinessCard()" },
292 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 292 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
293 "devicebuttons/z_home", 293 "devicebuttons/z_home",
294 "QPE/Launcher", "home()", 294 "QPE/Launcher", "home()",
295 "buttonsettings", "raise()" }, 295 "buttonsettings", "raise()" },
296 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 296 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
297 "devicebuttons/z_menu", 297 "devicebuttons/z_menu",
298 "QPE/TaskBar", "toggleMenu()", 298 "QPE/TaskBar", "toggleMenu()",
299 "QPE/TaskBar", "toggleStartMenu()" }, 299 "QPE/TaskBar", "toggleStartMenu()" },
300 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 300 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
301 "", 301 "devicebuttons/z_hinge",
302 "QPE/Rotation", "rotateDefault()", 302 "QPE/Rotation", "rotateDefault()",
303 "QPE/Rotation", "rotateDefault()" }, 303 "QPE/Dummy", "doNothing()" },
304}; 304};
305 305
306struct s_button { 306struct s_button {
307 uint model; 307 uint model;
308 Qt::Key code; 308 Qt::Key code;
309 char *utext; 309 char *utext;
310 char *pix; 310 char *pix;
311 char *fpressedservice; 311 char *fpressedservice;
312 char *fpressedaction; 312 char *fpressedaction;
313 char *fheldservice; 313 char *fheldservice;
314 char *fheldaction; 314 char *fheldaction;
315} simpad_buttons [] = { 315} simpad_buttons [] = {
316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
317 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 317 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
318 "devicebuttons/simpad_lower_up", 318 "devicebuttons/simpad_lower_up",
319 "datebook", "nextView()", 319 "datebook", "nextView()",
320 "today", "raise()" }, 320 "today", "raise()" },
321 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 321 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
322 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 322 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
323 "devicebuttons/simpad_lower_down", 323 "devicebuttons/simpad_lower_down",
324 "addressbook", "raise()", 324 "addressbook", "raise()",
325 "addressbook", "beamBusinessCard()" }, 325 "addressbook", "beamBusinessCard()" },
326 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 326 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
327 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 327 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
328 "devicebuttons/simpad_lower_right", 328 "devicebuttons/simpad_lower_right",
329 "QPE/TaskBar", "toggleMenu()", 329 "QPE/TaskBar", "toggleMenu()",
330 "QPE/TaskBar", "toggleStartMenu()" }, 330 "QPE/TaskBar", "toggleStartMenu()" },
331 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 331 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
332 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 332 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
333 "devicebuttons/simpad_lower_left", 333 "devicebuttons/simpad_lower_left",
334 "mail", "raise()", 334 "mail", "raise()",
335 "mail", "newMail()" }, 335 "mail", "newMail()" },
336 336
337 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 337 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
338 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 338 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
339 "devicebuttons/simpad_upper_up", 339 "devicebuttons/simpad_upper_up",
340 "QPE/Launcher", "home()", 340 "QPE/Launcher", "home()",
341 "buttonsettings", "raise()" }, 341 "buttonsettings", "raise()" },
342 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 342 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
343 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 343 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
344 "devicebuttons/simpad_upper_down", 344 "devicebuttons/simpad_upper_down",
345 "addressbook", "raise()", 345 "addressbook", "raise()",
346 "addressbook", "beamBusinessCard()" }, 346 "addressbook", "beamBusinessCard()" },
347 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 347 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
348 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 348 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
349 "devicebuttons/simpad_upper_right", 349 "devicebuttons/simpad_upper_right",
350 "QPE/TaskBar", "toggleMenu()", 350 "QPE/TaskBar", "toggleMenu()",
351 "QPE/TaskBar", "toggleStartMenu()" }, 351 "QPE/TaskBar", "toggleStartMenu()" },
352 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 352 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
353 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 353 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
354 "devicebuttons/simpad_upper_left", 354 "devicebuttons/simpad_upper_left",
355 "QPE/Rotation", "flip()", 355 "QPE/Rotation", "flip()",
356 "QPE/Rotation", "flip()" }, 356 "QPE/Rotation", "flip()" },
357 /* 357 /*
358 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 358 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
359 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 359 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
360 "devicebuttons/simpad_lower_upper", 360 "devicebuttons/simpad_lower_upper",
361 "QPE/Launcher", "home()", 361 "QPE/Launcher", "home()",
362 "buttonsettings", "raise()" }, 362 "buttonsettings", "raise()" },
363 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 363 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
364 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 364 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
365 "devicebuttons/simpad_upper_lower", 365 "devicebuttons/simpad_upper_lower",
366 "QPE/Launcher", "home()", 366 "QPE/Launcher", "home()",
367 "buttonsettings", "raise()" }, 367 "buttonsettings", "raise()" },
368 */ 368 */
369}; 369};
370 370
371struct r_button { 371struct r_button {
372 uint model; 372 uint model;
373 Qt::Key code; 373 Qt::Key code;
374 char *utext; 374 char *utext;
375 char *pix; 375 char *pix;
376 char *fpressedservice; 376 char *fpressedservice;
377 char *fpressedaction; 377 char *fpressedaction;
378 char *fheldservice; 378 char *fheldservice;
379 char *fheldaction; 379 char *fheldaction;
380} ramses_buttons [] = { 380} ramses_buttons [] = {
381 { Model_Ramses_MNCI, 381 { Model_Ramses_MNCI,
382 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 382 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
383 "devicebuttons/z_menu", 383 "devicebuttons/z_menu",
384 "QPE/TaskBar", "toggleMenu()", 384 "QPE/TaskBar", "toggleMenu()",
385 "QPE/TaskBar", "toggleStartMenu()" }, 385 "QPE/TaskBar", "toggleStartMenu()" },
386 { Model_Ramses_MNCI, 386 { Model_Ramses_MNCI,
387 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 387 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
388 "devicebuttons/ipaq_home", 388 "devicebuttons/ipaq_home",
389 "QPE/Launcher", "home()", 389 "QPE/Launcher", "home()",
390 "buttonsettings", "raise()" }, 390 "buttonsettings", "raise()" },
391}; 391};
392 392
393class Yopy : public ODevice { 393class Yopy : public ODevice {
394protected: 394protected:
395 virtual void init ( ); 395 virtual void init ( );
396 virtual void initButtons ( ); 396 virtual void initButtons ( );
397 397
398public: 398public:
399 virtual bool suspend ( ); 399 virtual bool suspend ( );
400 400
401 virtual bool setDisplayBrightness ( int b ); 401 virtual bool setDisplayBrightness ( int b );
402 virtual int displayBrightnessResolution ( ) const; 402 virtual int displayBrightnessResolution ( ) const;
403 403
404 static bool isYopy ( ); 404 static bool isYopy ( );
405}; 405};
406 406
407struct yopy_button { 407struct yopy_button {
408 Qt::Key code; 408 Qt::Key code;
409 char *utext; 409 char *utext;
410 char *pix; 410 char *pix;
411 char *fpressedservice; 411 char *fpressedservice;
412 char *fpressedaction; 412 char *fpressedaction;
413 char *fheldservice; 413 char *fheldservice;
414 char *fheldaction; 414 char *fheldaction;
415} yopy_buttons [] = { 415} yopy_buttons [] = {
416 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 416 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
417 "devicebuttons/yopy_action", 417 "devicebuttons/yopy_action",
418 "datebook", "nextView()", 418 "datebook", "nextView()",
419 "today", "raise()" }, 419 "today", "raise()" },
420 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 420 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
421 "devicebuttons/yopy_ok", 421 "devicebuttons/yopy_ok",
422 "addressbook", "raise()", 422 "addressbook", "raise()",
423 "addressbook", "beamBusinessCard()" }, 423 "addressbook", "beamBusinessCard()" },
424 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 424 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
425 "devicebuttons/yopy_end", 425 "devicebuttons/yopy_end",
426 "QPE/Launcher", "home()", 426 "QPE/Launcher", "home()",
427 "buttonsettings", "raise()" }, 427 "buttonsettings", "raise()" },
428}; 428};
429 429
430static QCString makeChannel ( const char *str ) 430static QCString makeChannel ( const char *str )
431{ 431{
432 if ( str && !::strchr ( str, '/' )) 432 if ( str && !::strchr ( str, '/' ))
433 return QCString ( "QPE/Application/" ) + str; 433 return QCString ( "QPE/Application/" ) + str;
434 else 434 else
435 return str; 435 return str;
436} 436}
437 437
438static inline bool isQWS() 438static inline bool isQWS()
439{ 439{
440 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 440 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
441} 441}
442 442
443ODevice *ODevice::inst ( ) 443ODevice *ODevice::inst ( )
444{ 444{
445 static ODevice *dev = 0; 445 static ODevice *dev = 0;
446 446
447 if ( !dev ) { 447 if ( !dev ) {
448 if ( QFile::exists ( "/proc/hal/model" )) 448 if ( QFile::exists ( "/proc/hal/model" ))
449 dev = new iPAQ ( ); 449 dev = new iPAQ ( );
450 else if ( Zaurus::isZaurus() ) 450 else if ( Zaurus::isZaurus() )
451 dev = new Zaurus ( ); 451 dev = new Zaurus ( );
452 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 452 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
453 dev = new SIMpad ( ); 453 dev = new SIMpad ( );
454 else if ( QFile::exists ( "/proc/sys/board/name" )) 454 else if ( QFile::exists ( "/proc/sys/board/name" ))
455 dev = new Ramses ( ); 455 dev = new Ramses ( );
456 else if ( Yopy::isYopy() ) 456 else if ( Yopy::isYopy() )
457 dev = new Yopy ( ); 457 dev = new Yopy ( );
458 else if ( Jornada::isJornada() ) 458 else if ( Jornada::isJornada() )
459 dev = new Jornada ( ); 459 dev = new Jornada ( );
460 else 460 else
461 dev = new ODevice ( ); 461 dev = new ODevice ( );
462 dev-> init ( ); 462 dev-> init ( );
463 } 463 }
464 return dev; 464 return dev;
465} 465}
466 466
467 467
468/************************************************** 468/**************************************************
469 * 469 *
470 * common 470 * common
471 * 471 *
472 **************************************************/ 472 **************************************************/
473 473
474 474
475ODevice::ODevice ( ) 475ODevice::ODevice ( )
476{ 476{
477 d = new ODeviceData; 477 d = new ODeviceData;
478 478
479 d-> m_modelstr = "Unknown"; 479 d-> m_modelstr = "Unknown";
480 d-> m_model = Model_Unknown; 480 d-> m_model = Model_Unknown;
481 d-> m_vendorstr = "Unknown"; 481 d-> m_vendorstr = "Unknown";
482 d-> m_vendor = Vendor_Unknown; 482 d-> m_vendor = Vendor_Unknown;
483 d-> m_systemstr = "Unknown"; 483 d-> m_systemstr = "Unknown";
484 d-> m_system = System_Unknown; 484 d-> m_system = System_Unknown;
485 d-> m_sysverstr = "0.0"; 485 d-> m_sysverstr = "0.0";
486 d-> m_rotation = Rot0; 486 d-> m_rotation = Rot0;
487 d-> m_direction = CW; 487 d-> m_direction = CW;
488 488
489 d-> m_holdtime = 1000; // 1000ms 489 d-> m_holdtime = 1000; // 1000ms
490 d-> m_buttons = 0; 490 d-> m_buttons = 0;
491 d-> m_cpu_frequencies = new QStrList; 491 d-> m_cpu_frequencies = new QStrList;
492} 492}
493 493
494void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 494void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
495{ 495{
496 if ( msg == "deviceButtonMappingChanged()" ) { 496 if ( msg == "deviceButtonMappingChanged()" ) {
497 reloadButtonMapping ( ); 497 reloadButtonMapping ( );
498 } 498 }
499} 499}
500 500
501void ODevice::init ( ) 501void ODevice::init ( )
502{ 502{
503} 503}
504 504
505/** 505/**
506 * This method initialises the button mapping 506 * This method initialises the button mapping
507 */ 507 */
508void ODevice::initButtons ( ) 508void ODevice::initButtons ( )
509{ 509{
510 if ( d-> m_buttons ) 510 if ( d-> m_buttons )
511 return; 511 return;
512 512
513 // Simulation uses iPAQ 3660 device buttons 513 // Simulation uses iPAQ 3660 device buttons
514 514
515 qDebug ( "init Buttons" ); 515 qDebug ( "init Buttons" );
516 d-> m_buttons = new QValueList <ODeviceButton>; 516 d-> m_buttons = new QValueList <ODeviceButton>;
517 517
518 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 518 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
519 i_button *ib = ipaq_buttons + i; 519 i_button *ib = ipaq_buttons + i;
520 ODeviceButton b; 520 ODeviceButton b;
521 521
522 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 522 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
523 b. setKeycode ( ib-> code ); 523 b. setKeycode ( ib-> code );
524 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 524 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
525 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 525 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
526 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 526 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
527 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 527 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
528 d-> m_buttons-> append ( b ); 528 d-> m_buttons-> append ( b );
529 } 529 }
530 } 530 }
531 reloadButtonMapping ( ); 531 reloadButtonMapping ( );
532 532
533 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 533 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
534 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 534 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
535} 535}
536 536
537ODevice::~ODevice ( ) 537ODevice::~ODevice ( )
538{ 538{
539// we leak m_devicebuttons and m_cpu_frequency 539// we leak m_devicebuttons and m_cpu_frequency
540// but it's a singleton and it is not so importantant 540// but it's a singleton and it is not so importantant
541// -zecke 541// -zecke
542 delete d; 542 delete d;
543} 543}
544 544
545bool ODevice::setSoftSuspend ( bool /*soft*/ ) 545bool ODevice::setSoftSuspend ( bool /*soft*/ )
546{ 546{
547 return false; 547 return false;
548} 548}
549 549
550//#include <linux/apm_bios.h> 550//#include <linux/apm_bios.h>
551 551
552#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 552#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
553 553
554/** 554/**
555 * This method will try to suspend the device 555 * This method will try to suspend the device
556 * It only works if the user is the QWS Server and the apm application 556 * It only works if the user is the QWS Server and the apm application
557 * is installed. 557 * is installed.
558 * It tries to suspend and then waits some time cause some distributions 558 * It tries to suspend and then waits some time cause some distributions
559 * do have asynchronus apm implementations. 559 * do have asynchronus apm implementations.
560 * This method will either fail and return false or it'll suspend the 560 * This method will either fail and return false or it'll suspend the
561 * device and return once the device got woken up 561 * device and return once the device got woken up
562 * 562 *
563 * @return if the device got suspended 563 * @return if the device got suspended
564 */ 564 */
565bool ODevice::suspend ( ) 565bool ODevice::suspend ( )
566{ 566{
567 qDebug("ODevice::suspend"); 567 qDebug("ODevice::suspend");
568 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 568 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
569 return false; 569 return false;
570 570
571 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 571 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
572 return false; 572 return false;
573 573
574 bool res = false; 574 bool res = false;
575 575
576 struct timeval tvs, tvn; 576 struct timeval tvs, tvn;
577 ::gettimeofday ( &tvs, 0 ); 577 ::gettimeofday ( &tvs, 0 );
578 578
579 ::sync ( ); // flush fs caches 579 ::sync ( ); // flush fs caches
580 res = ( ::system ( "apm --suspend" ) == 0 ); 580 res = ( ::system ( "apm --suspend" ) == 0 );
581 581
582 // This is needed because the iPAQ apm implementation is asynchronous and we 582 // This is needed because the iPAQ apm implementation is asynchronous and we
583 // can not be sure when exactly the device is really suspended 583 // can not be sure when exactly the device is really suspended
584 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 584 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
585 585
586 if ( res ) { 586 if ( res ) {
587 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 587 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
588 ::usleep ( 200 * 1000 ); 588 ::usleep ( 200 * 1000 );
589 ::gettimeofday ( &tvn, 0 ); 589 ::gettimeofday ( &tvn, 0 );
590 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 590 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
591 } 591 }
592 592
593 return res; 593 return res;
594} 594}
595 595
596//#include <linux/fb.h> better not rely on kernel headers in userspace ... 596//#include <linux/fb.h> better not rely on kernel headers in userspace ...
597 597
598#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 598#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
599 599
600/* VESA Blanking Levels */ 600/* VESA Blanking Levels */
601#define VESA_NO_BLANKING 0 601#define VESA_NO_BLANKING 0
602#define VESA_VSYNC_SUSPEND 1 602#define VESA_VSYNC_SUSPEND 1
603#define VESA_HSYNC_SUSPEND 2 603#define VESA_HSYNC_SUSPEND 2
604#define VESA_POWERDOWN 3 604#define VESA_POWERDOWN 3
605 605
606/** 606/**
607 * This sets the display on or off 607 * This sets the display on or off
608 */ 608 */
609bool ODevice::setDisplayStatus ( bool on ) 609bool ODevice::setDisplayStatus ( bool on )
610{ 610{
611 qDebug("ODevice::setDisplayStatus(%d)", on); 611 qDebug("ODevice::setDisplayStatus(%d)", on);
612 612
613 if ( d-> m_model == Model_Unknown ) 613 if ( d-> m_model == Model_Unknown )
614 return false; 614 return false;
615 615
616 bool res = false; 616 bool res = false;
617 int fd; 617 int fd;
618 618
619 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 619 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
620 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 620 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
621 ::close ( fd ); 621 ::close ( fd );
622 } 622 }
623 return res; 623 return res;
624} 624}
625 625
626/** 626/**
627 * This sets the display brightness 627 * This sets the display brightness
628 * 628 *
629 * @param p The brightness to be set on a scale from 0 to 255 629 * @param p The brightness to be set on a scale from 0 to 255
630 * @return success or failure 630 * @return success or failure
631 */ 631 */
632bool ODevice::setDisplayBrightness ( int p) 632bool ODevice::setDisplayBrightness ( int p)
633{ 633{
634 Q_UNUSED( p ) 634 Q_UNUSED( p )
635 return false; 635 return false;
636} 636}
637 637
638/** 638/**
639 * @return returns the number of steppings on the brightness slider 639 * @return returns the number of steppings on the brightness slider
640 * in the Light-'n-Power settings. 640 * in the Light-'n-Power settings.
641 */ 641 */
642int ODevice::displayBrightnessResolution ( ) const 642int ODevice::displayBrightnessResolution ( ) const
643{ 643{
644 return 16; 644 return 16;
645} 645}
646 646
647/** 647/**
648 * This sets the display contrast 648 * This sets the display contrast
649 * @param p The contrast to be set on a scale from 0 to 255 649 * @param p The contrast to be set on a scale from 0 to 255
650 * @return success or failure 650 * @return success or failure
651 */ 651 */
652bool ODevice::setDisplayContrast ( int p) 652bool ODevice::setDisplayContrast ( int p)
653{ 653{
654 Q_UNUSED( p ) 654 Q_UNUSED( p )
655 return false; 655 return false;
656} 656}
657 657
658/** 658/**
659 * @return return the max value for the brightness settings slider 659 * @return return the max value for the brightness settings slider
660 * or 0 if the device doesn't support setting of a contrast 660 * or 0 if the device doesn't support setting of a contrast
661 */ 661 */
662int ODevice::displayContrastResolution ( ) const 662int ODevice::displayContrastResolution ( ) const
663{ 663{
664 return 0; 664 return 0;
665} 665}
666 666
667/** 667/**
668 * This returns the vendor as string 668 * This returns the vendor as string
669 * @return Vendor as QString 669 * @return Vendor as QString
670 */ 670 */
671QString ODevice::vendorString ( ) const 671QString ODevice::vendorString ( ) const
672{ 672{
673 return d-> m_vendorstr; 673 return d-> m_vendorstr;
674} 674}
675 675
676/** 676/**
677 * This returns the vendor as one of the values of OVendor 677 * This returns the vendor as one of the values of OVendor
678 * @return OVendor 678 * @return OVendor
679 */ 679 */
680OVendor ODevice::vendor ( ) const 680OVendor ODevice::vendor ( ) const
681{ 681{
682 return d-> m_vendor; 682 return d-> m_vendor;
683} 683}
684 684
685/** 685/**
686 * This returns the model as a string 686 * This returns the model as a string
687 * @return A string representing the model 687 * @return A string representing the model
688 */ 688 */
689QString ODevice::modelString ( ) const 689QString ODevice::modelString ( ) const
690{ 690{
691 return d-> m_modelstr; 691 return d-> m_modelstr;
692} 692}
693 693
694/** 694/**
695 * This does return the OModel used 695 * This does return the OModel used
696 */ 696 */
697OModel ODevice::model ( ) const 697OModel ODevice::model ( ) const
698{ 698{
699 return d-> m_model; 699 return d-> m_model;
700} 700}
701 701
702/** 702/**
703 * This does return the systen name 703 * This does return the systen name
704 */ 704 */
705QString ODevice::systemString ( ) const 705QString ODevice::systemString ( ) const
706{ 706{
707 return d-> m_systemstr; 707 return d-> m_systemstr;
708} 708}
709 709
710/** 710/**
711 * Return System as OSystem value 711 * Return System as OSystem value
712 */ 712 */
713OSystem ODevice::system ( ) const 713OSystem ODevice::system ( ) const
714{ 714{
715 return d-> m_system; 715 return d-> m_system;
716} 716}
717 717
718/** 718/**
719 * @return the version string of the base system 719 * @return the version string of the base system
720 */ 720 */
721QString ODevice::systemVersionString ( ) const 721QString ODevice::systemVersionString ( ) const
722{ 722{
723 return d-> m_sysverstr; 723 return d-> m_sysverstr;
724} 724}
725 725
726/** 726/**
727 * @return the current Transformation 727 * @return the current Transformation
728 */ 728 */
729Transformation ODevice::rotation ( ) const 729Transformation ODevice::rotation ( ) const
730{ 730{
731 return d-> m_rotation; 731 return d-> m_rotation;
732} 732}
733 733
734/** 734/**
735 * @return the current rotation direction 735 * @return the current rotation direction
736 */ 736 */
737ODirection ODevice::direction ( ) const 737ODirection ODevice::direction ( ) const
738{ 738{
739 return d-> m_direction; 739 return d-> m_direction;
740} 740}
741 741
742/** 742/**
743 * This plays an alarmSound 743 * This plays an alarmSound
744 */ 744 */
745void ODevice::alarmSound ( ) 745void ODevice::alarmSound ( )
746{ 746{
747#ifndef QT_NO_SOUND 747#ifndef QT_NO_SOUND
748 static Sound snd ( "alarm" ); 748 static Sound snd ( "alarm" );
749 749
750 if ( snd. isFinished ( )) 750 if ( snd. isFinished ( ))
751 snd. play ( ); 751 snd. play ( );
752#endif 752#endif
753} 753}
754 754
755/** 755/**
756 * This plays a key sound 756 * This plays a key sound
757 */ 757 */
758void ODevice::keySound ( ) 758void ODevice::keySound ( )
759{ 759{
760#ifndef QT_NO_SOUND 760#ifndef QT_NO_SOUND
761 static Sound snd ( "keysound" ); 761 static Sound snd ( "keysound" );
762 762
763 if ( snd. isFinished ( )) 763 if ( snd. isFinished ( ))
764 snd. play ( ); 764 snd. play ( );
765#endif 765#endif
766} 766}
767 767
768/** 768/**
769 * This plays a touch sound 769 * This plays a touch sound
770 */ 770 */
771void ODevice::touchSound ( ) 771void ODevice::touchSound ( )
772{ 772{
773#ifndef QT_NO_SOUND 773#ifndef QT_NO_SOUND
774 static Sound snd ( "touchsound" ); 774 static Sound snd ( "touchsound" );
775 775
776 if ( snd. isFinished ( )) 776 if ( snd. isFinished ( ))
777 snd. play ( ); 777 snd. play ( );
778#endif 778#endif
779} 779}
780 780
781/** 781/**
782 * This method will return a list of leds 782 * This method will return a list of leds
783 * available on this device 783 * available on this device
784 * @return a list of LEDs. 784 * @return a list of LEDs.
785 */ 785 */
786QValueList <OLed> ODevice::ledList ( ) const 786QValueList <OLed> ODevice::ledList ( ) const
787{ 787{
788 return QValueList <OLed> ( ); 788 return QValueList <OLed> ( );
789} 789}
790 790
791/** 791/**
792 * This does return the state of the LEDs 792 * This does return the state of the LEDs
793 */ 793 */
794QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 794QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
795{ 795{
796 return QValueList <OLedState> ( ); 796 return QValueList <OLedState> ( );
797} 797}
798 798
799/** 799/**
800 * @return the state for a given OLed 800 * @return the state for a given OLed
801 */ 801 */
802OLedState ODevice::ledState ( OLed /*which*/ ) const 802OLedState ODevice::ledState ( OLed /*which*/ ) const
803{ 803{
804 return Led_Off; 804 return Led_Off;
805} 805}
806 806
807/** 807/**
808 * Set the state for a LED 808 * Set the state for a LED
809 * @param which Which OLed to use 809 * @param which Which OLed to use
810 * @param st The state to set 810 * @param st The state to set
811 * @return success or failure 811 * @return success or failure
812 */ 812 */
813bool ODevice::setLedState ( OLed which, OLedState st ) 813bool ODevice::setLedState ( OLed which, OLedState st )
814{ 814{
815 Q_UNUSED( which ) 815 Q_UNUSED( which )
816 Q_UNUSED( st ) 816 Q_UNUSED( st )
817 return false; 817 return false;
818} 818}
819 819
820/** 820/**
821 * @return if the device has a light sensor 821 * @return if the device has a light sensor
822 */ 822 */
823bool ODevice::hasLightSensor ( ) const 823bool ODevice::hasLightSensor ( ) const
824{ 824{
825 return false; 825 return false;
826} 826}
827 827
828/** 828/**
829 * @return a value from the light sensor 829 * @return a value from the light sensor
830 */ 830 */
831int ODevice::readLightSensor ( ) 831int ODevice::readLightSensor ( )
832{ 832{
833 return -1; 833 return -1;
834} 834}
835 835
836/** 836/**
837 * @return the light sensor resolution 837 * @return the light sensor resolution
838 */ 838 */
839int ODevice::lightSensorResolution ( ) const 839int ODevice::lightSensorResolution ( ) const
840{ 840{
841 return 0; 841 return 0;
842} 842}
843 843
844/** 844/**
845 * @return if the device has a hinge sensor 845 * @return if the device has a hinge sensor
846 */ 846 */
847bool ODevice::hasHingeSensor ( ) const 847bool ODevice::hasHingeSensor ( ) const
848{ 848{
849 return false; 849 return false;
850} 850}
851 851
852/** 852/**
853 * @return a value from the hinge sensor 853 * @return a value from the hinge sensor
854 */ 854 */
855OHingeStatus ODevice::readHingeSensor ( ) 855OHingeStatus ODevice::readHingeSensor ( )
856{ 856{
857 return CASE_UNKNOWN; 857 return CASE_UNKNOWN;
858} 858}
859 859
860/** 860/**
861 * @return a list with CPU frequencies supported by the hardware 861 * @return a list with CPU frequencies supported by the hardware
862 */ 862 */
863const QStrList &ODevice::allowedCpuFrequencies ( ) const 863const QStrList &ODevice::allowedCpuFrequencies ( ) const
864{ 864{
865 return *d->m_cpu_frequencies; 865 return *d->m_cpu_frequencies;
866} 866}
867 867
868 868
869/** 869/**
870 * Set desired CPU frequency 870 * Set desired CPU frequency
871 * 871 *
872 * @param index index into d->m_cpu_frequencies of the frequency to be set 872 * @param index index into d->m_cpu_frequencies of the frequency to be set
873 */ 873 */
874bool ODevice::setCurrentCpuFrequency(uint index) 874bool ODevice::setCurrentCpuFrequency(uint index)
875{ 875{
876 if (index >= d->m_cpu_frequencies->count()) 876 if (index >= d->m_cpu_frequencies->count())
877 return false; 877 return false;
878 878
879 char *freq = d->m_cpu_frequencies->at(index); 879 char *freq = d->m_cpu_frequencies->at(index);
880 qWarning("set freq to %s", freq); 880 qWarning("set freq to %s", freq);
881 881
882 int fd; 882 int fd;
883 883
884 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 884 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
885 char writeCommand[50]; 885 char writeCommand[50];
886 const int count = sprintf(writeCommand, "%s\n", freq); 886 const int count = sprintf(writeCommand, "%s\n", freq);
887 int res = (::write(fd, writeCommand, count) != -1); 887 int res = (::write(fd, writeCommand, count) != -1);
888 ::close(fd); 888 ::close(fd);
889 return res; 889 return res;
890 } 890 }
891 891
892 return false; 892 return false;
893} 893}
894 894
895 895
896/** 896/**
897 * @return a list of hardware buttons 897 * @return a list of hardware buttons
898 */ 898 */
899const QValueList <ODeviceButton> &ODevice::buttons ( ) 899const QValueList <ODeviceButton> &ODevice::buttons ( )
900{ 900{
901 initButtons ( ); 901 initButtons ( );
902 902
903 return *d-> m_buttons; 903 return *d-> m_buttons;
904} 904}
905 905
906/** 906/**
907 * @return The amount of time that would count as a hold 907 * @return The amount of time that would count as a hold
908 */ 908 */
909uint ODevice::buttonHoldTime ( ) const 909uint ODevice::buttonHoldTime ( ) const
910{ 910{
911 return d-> m_holdtime; 911 return d-> m_holdtime;
912} 912}
913 913
914/** 914/**
915 * This method return a ODeviceButton for a key code 915 * This method return a ODeviceButton for a key code
916 * or 0 if no special hardware button is available for the device 916 * or 0 if no special hardware button is available for the device
917 * 917 *
918 * @return The devicebutton or 0l 918 * @return The devicebutton or 0l
919 * @see ODeviceButton 919 * @see ODeviceButton
920 */ 920 */
921const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 921const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
922{ 922{
923 initButtons ( ); 923 initButtons ( );
924 924
925 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 925 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
926 if ( (*it). keycode ( ) == code ) 926 if ( (*it). keycode ( ) == code )
927 return &(*it); 927 return &(*it);
928 } 928 }
929 return 0; 929 return 0;
930} 930}
931 931
932void ODevice::reloadButtonMapping ( ) 932void ODevice::reloadButtonMapping ( )
933{ 933{
934 initButtons ( ); 934 initButtons ( );
935 935
936 Config cfg ( "ButtonSettings" ); 936 Config cfg ( "ButtonSettings" );
937 937
938 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 938 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
939 ODeviceButton &b = ( *d-> m_buttons ) [i]; 939 ODeviceButton &b = ( *d-> m_buttons ) [i];
940 QString group = "Button" + QString::number ( i ); 940 QString group = "Button" + QString::number ( i );
941 941
942 QCString pch, hch; 942 QCString pch, hch;
943 QCString pm, hm; 943 QCString pm, hm;
944 QByteArray pdata, hdata; 944 QByteArray pdata, hdata;
945 945
946 if ( cfg. hasGroup ( group )) { 946 if ( cfg. hasGroup ( group )) {
947 cfg. setGroup ( group ); 947 cfg. setGroup ( group );
948 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 948 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
949 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 949 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
950 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 950 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
951 951
952 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 952 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
953 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 953 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
954 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 954 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
955 } 955 }
956 956
957 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 957 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
958 958
959 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 959 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
960 } 960 }
961} 961}
962 962
963void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 963void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
964{ 964{
965 initButtons ( ); 965 initButtons ( );
966 966
967 QString mb_chan; 967 QString mb_chan;
968 968
969 if ( button >= (int) d-> m_buttons-> count ( )) 969 if ( button >= (int) d-> m_buttons-> count ( ))
970 return; 970 return;
971 971
972 ODeviceButton &b = ( *d-> m_buttons ) [button]; 972 ODeviceButton &b = ( *d-> m_buttons ) [button];
973 b. setPressedAction ( action ); 973 b. setPressedAction ( action );
974 974
975 mb_chan=b. pressedAction ( ). channel ( ); 975 mb_chan=b. pressedAction ( ). channel ( );
976 976
977 Config buttonFile ( "ButtonSettings" ); 977 Config buttonFile ( "ButtonSettings" );
978 buttonFile. setGroup ( "Button" + QString::number ( button )); 978 buttonFile. setGroup ( "Button" + QString::number ( button ));
979 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 979 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
980 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 980 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
981 981
982 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 982 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
983 983
984 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 984 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
985} 985}
986 986
987void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 987void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
988{ 988{
989 initButtons ( ); 989 initButtons ( );
990 990
991 if ( button >= (int) d-> m_buttons-> count ( )) 991 if ( button >= (int) d-> m_buttons-> count ( ))
992 return; 992 return;
993 993
994 ODeviceButton &b = ( *d-> m_buttons ) [button]; 994 ODeviceButton &b = ( *d-> m_buttons ) [button];
995 b. setHeldAction ( action ); 995 b. setHeldAction ( action );
996 996
997 Config buttonFile ( "ButtonSettings" ); 997 Config buttonFile ( "ButtonSettings" );
998 buttonFile. setGroup ( "Button" + QString::number ( button )); 998 buttonFile. setGroup ( "Button" + QString::number ( button ));
999 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 999 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
1000 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 1000 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
1001 1001
1002 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 1002 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
1003 1003
1004 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 1004 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
1005} 1005}
1006void ODevice::virtual_hook(int, void* ){ 1006void ODevice::virtual_hook(int, void* ){
1007 1007
1008} 1008}
1009 1009
1010/************************************************** 1010/**************************************************
1011 * 1011 *
1012 * Yopy 3500/3700 1012 * Yopy 3500/3700
1013 * 1013 *
1014 **************************************************/ 1014 **************************************************/
1015 1015
1016bool Yopy::isYopy ( ) 1016bool Yopy::isYopy ( )
1017{ 1017{
1018 QFile f( "/proc/cpuinfo" ); 1018 QFile f( "/proc/cpuinfo" );
1019 if ( f. open ( IO_ReadOnly ) ) { 1019 if ( f. open ( IO_ReadOnly ) ) {
1020 QTextStream ts ( &f ); 1020 QTextStream ts ( &f );
1021 QString line; 1021 QString line;
1022 while( line = ts. readLine ( ) ) { 1022 while( line = ts. readLine ( ) ) {
1023 if ( line. left ( 8 ) == "Hardware" ) { 1023 if ( line. left ( 8 ) == "Hardware" ) {
1024 int loc = line. find ( ":" ); 1024 int loc = line. find ( ":" );
1025 if ( loc != -1 ) { 1025 if ( loc != -1 ) {
1026 QString model = 1026 QString model =
1027 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1027 line. mid ( loc + 2 ). simplifyWhiteSpace( );
1028 return ( model == "Yopy" ); 1028 return ( model == "Yopy" );
1029 } 1029 }
1030 } 1030 }
1031 } 1031 }
1032 } 1032 }
1033 return false; 1033 return false;
1034} 1034}
1035 1035
1036void Yopy::init ( ) 1036void Yopy::init ( )
1037{ 1037{
1038 d-> m_vendorstr = "G.Mate"; 1038 d-> m_vendorstr = "G.Mate";
1039 d-> m_vendor = Vendor_GMate; 1039 d-> m_vendor = Vendor_GMate;
1040 d-> m_modelstr = "Yopy3700"; 1040 d-> m_modelstr = "Yopy3700";
1041 d-> m_model = Model_Yopy_3700; 1041 d-> m_model = Model_Yopy_3700;
1042 d-> m_rotation = Rot0; 1042 d-> m_rotation = Rot0;
1043 1043
1044 d-> m_systemstr = "Linupy"; 1044 d-> m_systemstr = "Linupy";
1045 d-> m_system = System_Linupy; 1045 d-> m_system = System_Linupy;
1046 1046
1047 QFile f ( "/etc/issue" ); 1047 QFile f ( "/etc/issue" );
1048 if ( f. open ( IO_ReadOnly )) { 1048 if ( f. open ( IO_ReadOnly )) {
1049 QTextStream ts ( &f ); 1049 QTextStream ts ( &f );
1050 ts.readLine(); 1050 ts.readLine();
1051 d-> m_sysverstr = ts. readLine ( ); 1051 d-> m_sysverstr = ts. readLine ( );
1052 f. close ( ); 1052 f. close ( );
1053 } 1053 }
1054} 1054}
1055 1055
1056void Yopy::initButtons ( ) 1056void Yopy::initButtons ( )
1057{ 1057{
1058 if ( d-> m_buttons ) 1058 if ( d-> m_buttons )
1059 return; 1059 return;
1060 1060
1061 d-> m_buttons = new QValueList <ODeviceButton>; 1061 d-> m_buttons = new QValueList <ODeviceButton>;
1062 1062
1063 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1063 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1064 1064
1065 yopy_button *ib = yopy_buttons + i; 1065 yopy_button *ib = yopy_buttons + i;
1066 1066
1067 ODeviceButton b; 1067 ODeviceButton b;
1068 1068
1069 b. setKeycode ( ib-> code ); 1069 b. setKeycode ( ib-> code );
1070 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1070 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1071 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1071 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1072 b. setFactoryPresetPressedAction 1072 b. setFactoryPresetPressedAction
1073 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1073 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1074 b. setFactoryPresetHeldAction 1074 b. setFactoryPresetHeldAction
1075 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1075 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1076 1076
1077 d-> m_buttons-> append ( b ); 1077 d-> m_buttons-> append ( b );
1078 } 1078 }
1079 reloadButtonMapping ( ); 1079 reloadButtonMapping ( );
1080 1080
1081 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1081 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1082 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1082 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1083 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1083 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1084} 1084}
1085 1085
1086bool Yopy::suspend() 1086bool Yopy::suspend()
1087{ 1087{
1088 /* Opie for Yopy does not implement its own power management at the 1088 /* Opie for Yopy does not implement its own power management at the
1089 moment. The public version runs parallel to X, and relies on the 1089 moment. The public version runs parallel to X, and relies on the
1090 existing power management features. */ 1090 existing power management features. */
1091 return false; 1091 return false;
1092} 1092}
1093 1093
1094bool Yopy::setDisplayBrightness(int bright) 1094bool Yopy::setDisplayBrightness(int bright)
1095{ 1095{
1096 /* The code here works, but is disabled as the current version runs 1096 /* The code here works, but is disabled as the current version runs
1097 parallel to X, and relies on the existing backlight demon. */ 1097 parallel to X, and relies on the existing backlight demon. */
1098#if 0 1098#if 0
1099 if ( QFile::exists("/proc/sys/pm/light") ) { 1099 if ( QFile::exists("/proc/sys/pm/light") ) {
1100 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1100 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1101 if (fd >= 0 ) { 1101 if (fd >= 0 ) {
1102 if (bright) 1102 if (bright)
1103 ::write(fd, "1\n", 2); 1103 ::write(fd, "1\n", 2);
1104 else 1104 else
1105 ::write(fd, "0\n", 2); 1105 ::write(fd, "0\n", 2);
1106 ::close(fd); 1106 ::close(fd);
1107 return true; 1107 return true;
1108 } 1108 }
1109 } 1109 }
1110#endif 1110#endif
1111 return false; 1111 return false;
1112} 1112}
1113 1113
1114int Yopy::displayBrightnessResolution() const 1114int Yopy::displayBrightnessResolution() const
1115{ 1115{
1116 return 2; 1116 return 2;
1117} 1117}
1118 1118
1119/************************************************** 1119/**************************************************
1120 * 1120 *
1121 * iPAQ 1121 * iPAQ
1122 * 1122 *
1123 **************************************************/ 1123 **************************************************/
1124 1124
1125void iPAQ::init ( ) 1125void iPAQ::init ( )
1126{ 1126{
1127 d-> m_vendorstr = "HP"; 1127 d-> m_vendorstr = "HP";
1128 d-> m_vendor = Vendor_HP; 1128 d-> m_vendor = Vendor_HP;
1129 1129
1130 QFile f ( "/proc/hal/model" ); 1130 QFile f ( "/proc/hal/model" );
1131 1131
1132 if ( f. open ( IO_ReadOnly )) { 1132 if ( f. open ( IO_ReadOnly )) {
1133 QTextStream ts ( &f ); 1133 QTextStream ts ( &f );
1134 1134
1135 d-> m_modelstr = "H" + ts. readLine ( ); 1135 d-> m_modelstr = "H" + ts. readLine ( );
1136 1136
1137 if ( d-> m_modelstr == "H3100" ) 1137 if ( d-> m_modelstr == "H3100" )
1138 d-> m_model = Model_iPAQ_H31xx; 1138 d-> m_model = Model_iPAQ_H31xx;
1139 else if ( d-> m_modelstr == "H3600" ) 1139 else if ( d-> m_modelstr == "H3600" )
1140 d-> m_model = Model_iPAQ_H36xx; 1140 d-> m_model = Model_iPAQ_H36xx;
1141 else if ( d-> m_modelstr == "H3700" ) 1141 else if ( d-> m_modelstr == "H3700" )
1142 d-> m_model = Model_iPAQ_H37xx; 1142 d-> m_model = Model_iPAQ_H37xx;
1143 else if ( d-> m_modelstr == "H3800" ) 1143 else if ( d-> m_modelstr == "H3800" )
1144 d-> m_model = Model_iPAQ_H38xx; 1144 d-> m_model = Model_iPAQ_H38xx;
1145 else if ( d-> m_modelstr == "H3900" ) 1145 else if ( d-> m_modelstr == "H3900" )
1146 d-> m_model = Model_iPAQ_H39xx; 1146 d-> m_model = Model_iPAQ_H39xx;
1147 else if ( d-> m_modelstr == "H5400" ) 1147 else if ( d-> m_modelstr == "H5400" )
1148 d-> m_model = Model_iPAQ_H5xxx; 1148 d-> m_model = Model_iPAQ_H5xxx;
1149 else 1149 else
1150 d-> m_model = Model_Unknown; 1150 d-> m_model = Model_Unknown;
1151 1151
1152 f. close ( ); 1152 f. close ( );
1153 } 1153 }
1154 1154
1155 switch ( d-> m_model ) { 1155 switch ( d-> m_model ) {
1156 case Model_iPAQ_H31xx: 1156 case Model_iPAQ_H31xx:
1157 case Model_iPAQ_H38xx: 1157 case Model_iPAQ_H38xx:
1158 d-> m_rotation = Rot90; 1158 d-> m_rotation = Rot90;
1159 break; 1159 break;
1160 case Model_iPAQ_H36xx: 1160 case Model_iPAQ_H36xx:
1161 case Model_iPAQ_H37xx: 1161 case Model_iPAQ_H37xx:
1162 case Model_iPAQ_H39xx: 1162 case Model_iPAQ_H39xx:
1163 1163
1164 default: 1164 default:
1165 d-> m_rotation = Rot270; 1165 d-> m_rotation = Rot270;
1166 break; 1166 break;
1167 case Model_iPAQ_H5xxx: 1167 case Model_iPAQ_H5xxx:
1168 d-> m_rotation = Rot0; 1168 d-> m_rotation = Rot0;
1169 } 1169 }
1170 1170
1171 f. setName ( "/etc/familiar-version" ); 1171 f. setName ( "/etc/familiar-version" );
1172 if ( f. open ( IO_ReadOnly )) { 1172 if ( f. open ( IO_ReadOnly )) {
1173 d-> m_systemstr = "Familiar"; 1173 d-> m_systemstr = "Familiar";
1174 d-> m_system = System_Familiar; 1174 d-> m_system = System_Familiar;
1175 1175
1176 QTextStream ts ( &f ); 1176 QTextStream ts ( &f );
1177 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1177 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1178 1178
1179 f. close ( ); 1179 f. close ( );
1180 } else { 1180 } else {
1181 f. setName ( "/etc/oz_version" ); 1181 f. setName ( "/etc/oz_version" );
1182 1182
1183 if ( f. open ( IO_ReadOnly )) { 1183 if ( f. open ( IO_ReadOnly )) {
1184 d-> m_systemstr = "OpenEmbedded/iPaq"; 1184 d-> m_systemstr = "OpenEmbedded/iPaq";
1185 d-> m_system = System_Familiar; 1185 d-> m_system = System_Familiar;
1186 1186
1187 QTextStream ts ( &f ); 1187 QTextStream ts ( &f );
1188 ts.setDevice ( &f ); 1188 ts.setDevice ( &f );
1189 d-> m_sysverstr = ts. readLine ( ); 1189 d-> m_sysverstr = ts. readLine ( );
1190 f. close ( ); 1190 f. close ( );
1191 } 1191 }
1192 } 1192 }
1193 1193
1194 1194
1195 1195
1196 1196
1197 1197
1198 m_leds [0] = m_leds [1] = Led_Off; 1198 m_leds [0] = m_leds [1] = Led_Off;
1199 1199
1200 m_power_timer = 0; 1200 m_power_timer = 0;
1201 1201
1202} 1202}
1203 1203
1204void iPAQ::initButtons ( ) 1204void iPAQ::initButtons ( )
1205{ 1205{
1206 if ( d-> m_buttons ) 1206 if ( d-> m_buttons )
1207 return; 1207 return;
1208 1208
1209 if ( isQWS( ) ) 1209 if ( isQWS( ) )
1210 QWSServer::setKeyboardFilter ( this ); 1210 QWSServer::setKeyboardFilter ( this );
1211 1211
1212 d-> m_buttons = new QValueList <ODeviceButton>; 1212 d-> m_buttons = new QValueList <ODeviceButton>;
1213 1213
1214 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1214 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1215 i_button *ib = ipaq_buttons + i; 1215 i_button *ib = ipaq_buttons + i;
1216 ODeviceButton b; 1216 ODeviceButton b;
1217 1217
1218 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1218 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1219 b. setKeycode ( ib-> code ); 1219 b. setKeycode ( ib-> code );
1220 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1220 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1221 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1221 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1224 1224
1225 d-> m_buttons-> append ( b ); 1225 d-> m_buttons-> append ( b );
1226 } 1226 }
1227 } 1227 }
1228 reloadButtonMapping ( ); 1228 reloadButtonMapping ( );
1229 1229
1230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1231 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1231 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1232} 1232}
1233 1233
1234 1234
1235//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1235//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1236 1236
1237typedef struct { 1237typedef struct {
1238 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1238 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1239 unsigned char TotalTime; /* Units of 5 seconds */ 1239 unsigned char TotalTime; /* Units of 5 seconds */
1240 unsigned char OnTime; /* units of 100m/s */ 1240 unsigned char OnTime; /* units of 100m/s */
1241 unsigned char OffTime; /* units of 100m/s */ 1241 unsigned char OffTime; /* units of 100m/s */
1242} LED_IN; 1242} LED_IN;
1243 1243
1244typedef struct { 1244typedef struct {
1245 unsigned char mode; 1245 unsigned char mode;
1246 unsigned char pwr; 1246 unsigned char pwr;
1247 unsigned char brightness; 1247 unsigned char brightness;
1248} FLITE_IN; 1248} FLITE_IN;
1249 1249
1250#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1250#define LED_ON OD_IOW( 'f', 5, LED_IN )
1251#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1251#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1252 1252
1253 1253
1254QValueList <OLed> iPAQ::ledList ( ) const 1254QValueList <OLed> iPAQ::ledList ( ) const
1255{ 1255{
1256 QValueList <OLed> vl; 1256 QValueList <OLed> vl;
1257 vl << Led_Power; 1257 vl << Led_Power;
1258 1258
1259 if ( d-> m_model == Model_iPAQ_H38xx ) 1259 if ( d-> m_model == Model_iPAQ_H38xx )
1260 vl << Led_BlueTooth; 1260 vl << Led_BlueTooth;
1261 return vl; 1261 return vl;
1262} 1262}
1263 1263
1264QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1264QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1265{ 1265{
1266 QValueList <OLedState> vl; 1266 QValueList <OLedState> vl;
1267 1267
1268 if ( l == Led_Power ) 1268 if ( l == Led_Power )
1269 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1269 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1270 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1270 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1271 vl << Led_Off; // << Led_On << ??? 1271 vl << Led_Off; // << Led_On << ???
1272 1272
1273 return vl; 1273 return vl;
1274} 1274}
1275 1275
1276OLedState iPAQ::ledState ( OLed l ) const 1276OLedState iPAQ::ledState ( OLed l ) const
1277{ 1277{
1278 switch ( l ) { 1278 switch ( l ) {
1279 case Led_Power: 1279 case Led_Power:
1280 return m_leds [0]; 1280 return m_leds [0];
1281 case Led_BlueTooth: 1281 case Led_BlueTooth:
1282 return m_leds [1]; 1282 return m_leds [1];
1283 default: 1283 default:
1284 return Led_Off; 1284 return Led_Off;
1285 } 1285 }
1286} 1286}
1287 1287
1288bool iPAQ::setLedState ( OLed l, OLedState st ) 1288bool iPAQ::setLedState ( OLed l, OLedState st )
1289{ 1289{
1290 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1290 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1291 1291
1292 if ( l == Led_Power ) { 1292 if ( l == Led_Power ) {
1293 if ( fd >= 0 ) { 1293 if ( fd >= 0 ) {
1294 LED_IN leds; 1294 LED_IN leds;
1295 ::memset ( &leds, 0, sizeof( leds )); 1295 ::memset ( &leds, 0, sizeof( leds ));
1296 leds. TotalTime = 0; 1296 leds. TotalTime = 0;
1297 leds. OnTime = 0; 1297 leds. OnTime = 0;
1298 leds. OffTime = 1; 1298 leds. OffTime = 1;
1299 leds. OffOnBlink = 2; 1299 leds. OffOnBlink = 2;
1300 1300
1301 switch ( st ) { 1301 switch ( st ) {
1302 case Led_Off : leds. OffOnBlink = 0; break; 1302 case Led_Off : leds. OffOnBlink = 0; break;
1303 case Led_On : leds. OffOnBlink = 1; break; 1303 case Led_On : leds. OffOnBlink = 1; break;
1304 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1304 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1305 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1305 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1306 } 1306 }
1307 1307
1308 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1308 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1309 m_leds [0] = st; 1309 m_leds [0] = st;
1310 return true; 1310 return true;
1311 } 1311 }
1312 } 1312 }
1313 } 1313 }
1314 return false; 1314 return false;
1315} 1315}
1316 1316
1317 1317
1318bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1318bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1319{ 1319{
1320 int newkeycode = keycode; 1320 int newkeycode = keycode;
1321 1321
1322 switch ( keycode ) { 1322 switch ( keycode ) {
1323 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1323 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1324 case HardKey_Menu: { 1324 case HardKey_Menu: {
1325 if (( d-> m_model == Model_iPAQ_H38xx ) || 1325 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1326 ( d-> m_model == Model_iPAQ_H39xx ) || 1326 ( d-> m_model == Model_iPAQ_H39xx ) ||
1327 ( d-> m_model == Model_iPAQ_H5xxx)) { 1327 ( d-> m_model == Model_iPAQ_H5xxx)) {