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