summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2004-05-01 18:13:29 (UTC)
committer zecke <zecke>2004-05-01 18:13:29 (UTC)
commit7a2cac7a65be07c1e82508e00c2d3d61e0823dc1 (patch) (unidiff)
tree70381a30c784957b22d9e644272ac96a0fced5a4 /libopie2
parentec6a887d8abddbab085a0a3aecae5760ff85dbe8 (diff)
downloadopie-7a2cac7a65be07c1e82508e00c2d3d61e0823dc1.zip
opie-7a2cac7a65be07c1e82508e00c2d3d61e0823dc1.tar.gz
opie-7a2cac7a65be07c1e82508e00c2d3d61e0823dc1.tar.bz2
Pass on the Hardware line of proc/cpuinfo so we don't need to parse the file again..
only adjusted iPAQ backend to use it Beginning of hh22xx Linux2.6 support
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp6
-rw-r--r--libopie2/opiecore/device/odevice.h7
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp52
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h2
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h2
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.h2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h2
14 files changed, 44 insertions, 43 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 62a2e03..cef7f63 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,345 +1,347 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie::Core; 63using namespace Opie::Core;
64 64
65struct default_button default_buttons [] = { 65struct default_button default_buttons [] = {
66 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 66 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
67 "devicebuttons/z_calendar", 67 "devicebuttons/z_calendar",
68 "datebook", "nextView()", 68 "datebook", "nextView()",
69 "today", "raise()" }, 69 "today", "raise()" },
70 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 70 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
71 "devicebuttons/z_contact", 71 "devicebuttons/z_contact",
72 "addressbook", "raise()", 72 "addressbook", "raise()",
73 "addressbook", "beamBusinessCard()" }, 73 "addressbook", "beamBusinessCard()" },
74 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 74 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
75 "devicebuttons/z_home", 75 "devicebuttons/z_home",
76 "QPE/Launcher", "home()", 76 "QPE/Launcher", "home()",
77 "buttonsettings", "raise()" }, 77 "buttonsettings", "raise()" },
78 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 78 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
79 "devicebuttons/z_menu", 79 "devicebuttons/z_menu",
80 "QPE/TaskBar", "toggleMenu()", 80 "QPE/TaskBar", "toggleMenu()",
81 "QPE/TaskBar", "toggleStartMenu()" }, 81 "QPE/TaskBar", "toggleStartMenu()" },
82 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 82 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
83 "devicebuttons/z_mail", 83 "devicebuttons/z_mail",
84 "opiemail", "raise()", 84 "opiemail", "raise()",
85 "opiemail", "newMail()" }, 85 "opiemail", "newMail()" },
86}; 86};
87 87
88ODevice *ODevice::inst() 88ODevice *ODevice::inst()
89{ 89{
90 static ODevice *dev = 0; 90 static ODevice *dev = 0;
91 91
92 // rewrite this to only use /proc/cpuinfo or so 92 // rewrite this to only use /proc/cpuinfo or so
93 QString cpu_info;
93 94
94 if ( !dev ) 95 if ( !dev )
95 { 96 {
96 QFile f( PATH_PROC_CPUINFO ); 97 QFile f( PATH_PROC_CPUINFO );
97 if ( f.open( IO_ReadOnly ) ) 98 if ( f.open( IO_ReadOnly ) )
98 { 99 {
99 QTextStream s( &f ); 100 QTextStream s( &f );
100 while ( !s.atEnd() ) 101 while ( !s.atEnd() )
101 { 102 {
102 QString line; 103 QString line;
103 line = s.readLine(); 104 line = s.readLine();
104 if ( line.startsWith( "Hardware" ) ) 105 if ( line.startsWith( "Hardware" ) )
105 { 106 {
106 qDebug( "ODevice() - found '%s'", (const char*) line ); 107 qDebug( "ODevice() - found '%s'", (const char*) line );
108 cpu_info = line;
107 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 109 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
108 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 110 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
109 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 111 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
110 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 112 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
111 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 113 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
112 else qWarning( "ODevice() - unknown hardware - using default." ); 114 else qWarning( "ODevice() - unknown hardware - using default." );
113 break; 115 break;
114 } 116 }
115 } 117 }
116 } 118 }
117 else 119 else
118 { 120 {
119 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 121 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
120 } 122 }
121 if ( !dev ) dev = new ODevice(); 123 if ( !dev ) dev = new ODevice();
122 dev->init(); 124 dev->init(cpu_info);
123 } 125 }
124 return dev; 126 return dev;
125} 127}
126 128
127ODevice::ODevice() 129ODevice::ODevice()
128{ 130{
129 d = new ODeviceData; 131 d = new ODeviceData;
130 132
131 d->m_modelstr = "Unknown"; 133 d->m_modelstr = "Unknown";
132 d->m_model = Model_Unknown; 134 d->m_model = Model_Unknown;
133 d->m_vendorstr = "Unknown"; 135 d->m_vendorstr = "Unknown";
134 d->m_vendor = Vendor_Unknown; 136 d->m_vendor = Vendor_Unknown;
135 d->m_systemstr = "Unknown"; 137 d->m_systemstr = "Unknown";
136 d->m_system = System_Unknown; 138 d->m_system = System_Unknown;
137 d->m_sysverstr = "0.0"; 139 d->m_sysverstr = "0.0";
138 d->m_rotation = Rot0; 140 d->m_rotation = Rot0;
139 d->m_direction = CW; 141 d->m_direction = CW;
140 142
141 d->m_holdtime = 1000; // 1000ms 143 d->m_holdtime = 1000; // 1000ms
142 d->m_buttons = 0; 144 d->m_buttons = 0;
143 d->m_cpu_frequencies = new QStrList; 145 d->m_cpu_frequencies = new QStrList;
144} 146}
145 147
146void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 148void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
147{ 149{
148 if ( msg == "deviceButtonMappingChanged()" ) { 150 if ( msg == "deviceButtonMappingChanged()" ) {
149 reloadButtonMapping(); 151 reloadButtonMapping();
150 } 152 }
151} 153}
152 154
153void ODevice::init() 155void ODevice::init(const QString&)
154{ 156{
155} 157}
156 158
157/** 159/**
158* This method initialises the button mapping 160* This method initialises the button mapping
159*/ 161*/
160void ODevice::initButtons() 162void ODevice::initButtons()
161{ 163{
162 if ( d->m_buttons ) 164 if ( d->m_buttons )
163 return; 165 return;
164 166
165 qDebug ( "init Buttons" ); 167 qDebug ( "init Buttons" );
166 d->m_buttons = new QValueList <ODeviceButton>; 168 d->m_buttons = new QValueList <ODeviceButton>;
167 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 169 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
168 default_button *db = default_buttons + i; 170 default_button *db = default_buttons + i;
169 ODeviceButton b; 171 ODeviceButton b;
170 b. setKeycode ( db->code ); 172 b. setKeycode ( db->code );
171 b. setUserText ( QObject::tr ( "Button", db->utext )); 173 b. setUserText ( QObject::tr ( "Button", db->utext ));
172 b. setPixmap ( Resource::loadPixmap ( db->pix )); 174 b. setPixmap ( Resource::loadPixmap ( db->pix ));
173 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 175 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
174 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 176 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
175 d->m_buttons->append ( b ); 177 d->m_buttons->append ( b );
176 } 178 }
177 179
178 reloadButtonMapping(); 180 reloadButtonMapping();
179 181
180 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 182 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
181 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 183 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
182} 184}
183 185
184ODevice::~ODevice() 186ODevice::~ODevice()
185{ 187{
186// we leak m_devicebuttons and m_cpu_frequency 188// we leak m_devicebuttons and m_cpu_frequency
187// but it's a singleton and it is not so importantant 189// but it's a singleton and it is not so importantant
188// -zecke 190// -zecke
189 delete d; 191 delete d;
190} 192}
191 193
192bool ODevice::setSoftSuspend ( bool /*soft*/ ) 194bool ODevice::setSoftSuspend ( bool /*soft*/ )
193{ 195{
194 return false; 196 return false;
195} 197}
196 198
197//#include <linux/apm_bios.h> 199//#include <linux/apm_bios.h>
198 200
199#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 201#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
200 202
201/** 203/**
202* This method will try to suspend the device 204* This method will try to suspend the device
203* It only works if the user is the QWS Server and the apm application 205* It only works if the user is the QWS Server and the apm application
204* is installed. 206* is installed.
205* It tries to suspend and then waits some time cause some distributions 207* It tries to suspend and then waits some time cause some distributions
206* do have asynchronus apm implementations. 208* do have asynchronus apm implementations.
207* This method will either fail and return false or it'll suspend the 209* This method will either fail and return false or it'll suspend the
208* device and return once the device got woken up 210* device and return once the device got woken up
209* 211*
210* @return if the device got suspended 212* @return if the device got suspended
211*/ 213*/
212bool ODevice::suspend() 214bool ODevice::suspend()
213{ 215{
214 qDebug("ODevice::suspend"); 216 qDebug("ODevice::suspend");
215 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 217 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
216 return false; 218 return false;
217 219
218 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 220 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
219 return false; 221 return false;
220 222
221 bool res = false; 223 bool res = false;
222 ODevice::sendSuspendmsg(); 224 ODevice::sendSuspendmsg();
223 225
224 struct timeval tvs, tvn; 226 struct timeval tvs, tvn;
225 ::gettimeofday ( &tvs, 0 ); 227 ::gettimeofday ( &tvs, 0 );
226 228
227 ::sync(); // flush fs caches 229 ::sync(); // flush fs caches
228 res = ( ::system ( "apm --suspend" ) == 0 ); 230 res = ( ::system ( "apm --suspend" ) == 0 );
229 231
230 // This is needed because the iPAQ apm implementation is asynchronous and we 232 // This is needed because the iPAQ apm implementation is asynchronous and we
231 // can not be sure when exactly the device is really suspended 233 // can not be sure when exactly the device is really suspended
232 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 234 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
233 235
234 if ( res ) { 236 if ( res ) {
235 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 237 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
236 ::usleep ( 200 * 1000 ); 238 ::usleep ( 200 * 1000 );
237 ::gettimeofday ( &tvn, 0 ); 239 ::gettimeofday ( &tvn, 0 );
238 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 240 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
239 } 241 }
240 242
241 return res; 243 return res;
242} 244}
243 245
244//#include <linux/fb.h> better not rely on kernel headers in userspace ... 246//#include <linux/fb.h> better not rely on kernel headers in userspace ...
245 247
246#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 248#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
247 249
248/* VESA Blanking Levels */ 250/* VESA Blanking Levels */
249#define VESA_NO_BLANKING 0 251#define VESA_NO_BLANKING 0
250#define VESA_VSYNC_SUSPEND 1 252#define VESA_VSYNC_SUSPEND 1
251#define VESA_HSYNC_SUSPEND 2 253#define VESA_HSYNC_SUSPEND 2
252#define VESA_POWERDOWN 3 254#define VESA_POWERDOWN 3
253 255
254/** 256/**
255* This sets the display on or off 257* This sets the display on or off
256*/ 258*/
257bool ODevice::setDisplayStatus ( bool on ) 259bool ODevice::setDisplayStatus ( bool on )
258{ 260{
259 qDebug("ODevice::setDisplayStatus(%d)", on); 261 qDebug("ODevice::setDisplayStatus(%d)", on);
260 262
261 if ( d->m_model == Model_Unknown ) 263 if ( d->m_model == Model_Unknown )
262 return false; 264 return false;
263 265
264 bool res = false; 266 bool res = false;
265 int fd; 267 int fd;
266 268
267 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 269 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
268 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 270 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
269 ::close ( fd ); 271 ::close ( fd );
270 } 272 }
271 return res; 273 return res;
272} 274}
273 275
274/** 276/**
275* This sets the display brightness 277* This sets the display brightness
276* 278*
277* @param p The brightness to be set on a scale from 0 to 255 279* @param p The brightness to be set on a scale from 0 to 255
278* @return success or failure 280* @return success or failure
279*/ 281*/
280bool ODevice::setDisplayBrightness ( int p) 282bool ODevice::setDisplayBrightness ( int p)
281{ 283{
282 Q_UNUSED( p ) 284 Q_UNUSED( p )
283 return false; 285 return false;
284} 286}
285 287
286/** 288/**
287* @return returns the number of steppings on the brightness slider 289* @return returns the number of steppings on the brightness slider
288* in the Light-'n-Power settings. 290* in the Light-'n-Power settings.
289*/ 291*/
290int ODevice::displayBrightnessResolution() const 292int ODevice::displayBrightnessResolution() const
291{ 293{
292 return 16; 294 return 16;
293} 295}
294 296
295/** 297/**
296* This sets the display contrast 298* This sets the display contrast
297* @param p The contrast to be set on a scale from 0 to 255 299* @param p The contrast to be set on a scale from 0 to 255
298* @return success or failure 300* @return success or failure
299*/ 301*/
300bool ODevice::setDisplayContrast ( int p) 302bool ODevice::setDisplayContrast ( int p)
301{ 303{
302 Q_UNUSED( p ) 304 Q_UNUSED( p )
303 return false; 305 return false;
304} 306}
305 307
306/** 308/**
307* @return return the max value for the brightness settings slider 309* @return return the max value for the brightness settings slider
308* or 0 if the device doesn't support setting of a contrast 310* or 0 if the device doesn't support setting of a contrast
309*/ 311*/
310int ODevice::displayContrastResolution() const 312int ODevice::displayContrastResolution() const
311{ 313{
312 return 0; 314 return 0;
313} 315}
314 316
315/** 317/**
316* This returns the vendor as string 318* This returns the vendor as string
317* @return Vendor as QString 319* @return Vendor as QString
318*/ 320*/
319QString ODevice::vendorString() const 321QString ODevice::vendorString() const
320{ 322{
321 return d->m_vendorstr; 323 return d->m_vendorstr;
322} 324}
323 325
324/** 326/**
325* This returns the vendor as one of the values of OVendor 327* This returns the vendor as one of the values of OVendor
326* @return OVendor 328* @return OVendor
327*/ 329*/
328OVendor ODevice::vendor() const 330OVendor ODevice::vendor() const
329{ 331{
330 return d->m_vendor; 332 return d->m_vendor;
331} 333}
332 334
333/** 335/**
334* This returns the model as a string 336* This returns the model as a string
335* @return A string representing the model 337* @return A string representing the model
336*/ 338*/
337QString ODevice::modelString() const 339QString ODevice::modelString() const
338{ 340{
339 return d->m_modelstr; 341 return d->m_modelstr;
340} 342}
341 343
342/** 344/**
343* This does return the OModel used 345* This does return the OModel used
344*/ 346*/
345OModel ODevice::model() const 347OModel ODevice::model() const
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 0ba58f0..aaebde3 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,350 +1,351 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie{ 43namespace Opie{
44namespace Core{ 44namespace Core{
45 45
46 class ODeviceData; 46 class ODeviceData;
47/** 47/**
48 * The available devices 48 * The available devices
49 */ 49 */
50enum OModel { 50enum OModel {
51 Model_Unknown, // = 0 51 Model_Unknown, // = 0
52 52
53 Model_Series_Mask = 0xff000000, 53 Model_Series_Mask = 0xff000000,
54 54
55 Model_iPAQ = ( 1 << 24 ), 55 Model_iPAQ = ( 1 << 24 ),
56 56
57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
64 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
64 65
65 Model_Jornada = ( 6 << 24 ), 66 Model_Jornada = ( 6 << 24 ),
66 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 67 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
67 68
68 Model_Zaurus = ( 2 << 24 ), 69 Model_Zaurus = ( 2 << 24 ),
69 70
70 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 71 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
71 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 72 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
72 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 73 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
73 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 74 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
74 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 75 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
75 76
76 Model_SIMpad = ( 3 << 24 ), 77 Model_SIMpad = ( 3 << 24 ),
77 78
78 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 79 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
79 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 80 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
80 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 81 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
81 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 82 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
82 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 83 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
83 84
84 Model_Ramses = ( 4 << 24 ), 85 Model_Ramses = ( 4 << 24 ),
85 86
86 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 87 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
87 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 88 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
88 89
89 Model_Yopy = ( 5 << 24 ), 90 Model_Yopy = ( 5 << 24 ),
90 91
91 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 92 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
92 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 93 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
93 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 94 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
94 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 95 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
95 96
96}; 97};
97 98
98/** 99/**
99 * The vendor of the device 100 * The vendor of the device
100 */ 101 */
101enum OVendor { 102enum OVendor {
102 Vendor_Unknown, 103 Vendor_Unknown,
103 104
104 Vendor_HP, 105 Vendor_HP,
105 Vendor_Sharp, 106 Vendor_Sharp,
106 Vendor_SIEMENS, 107 Vendor_SIEMENS,
107 Vendor_MundN, 108 Vendor_MundN,
108 Vendor_GMate, 109 Vendor_GMate,
109}; 110};
110 111
111/** 112/**
112 * The System used 113 * The System used
113 */ 114 */
114enum OSystem { 115enum OSystem {
115 System_Unknown, 116 System_Unknown,
116 117
117 System_Familiar, 118 System_Familiar,
118 System_Zaurus, 119 System_Zaurus,
119 System_OpenZaurus, 120 System_OpenZaurus,
120 System_Linupy, 121 System_Linupy,
121}; 122};
122 123
123enum OLedState { 124enum OLedState {
124 Led_Off, 125 Led_Off,
125 Led_On, 126 Led_On,
126 Led_BlinkSlow, 127 Led_BlinkSlow,
127 Led_BlinkFast 128 Led_BlinkFast
128}; 129};
129 130
130enum OLed { 131enum OLed {
131 Led_Mail, 132 Led_Mail,
132 Led_Power, 133 Led_Power,
133 Led_BlueTooth 134 Led_BlueTooth
134}; 135};
135 136
136enum OHardKey { 137enum OHardKey {
137 HardKey_Datebook = Qt::Key_F9, 138 HardKey_Datebook = Qt::Key_F9,
138 HardKey_Contacts = Qt::Key_F10, 139 HardKey_Contacts = Qt::Key_F10,
139 HardKey_Menu = Qt::Key_F11, 140 HardKey_Menu = Qt::Key_F11,
140 HardKey_Home = Qt::Key_F12, 141 HardKey_Home = Qt::Key_F12,
141 HardKey_Mail = Qt::Key_F13, 142 HardKey_Mail = Qt::Key_F13,
142 HardKey_Record = Qt::Key_F24, 143 HardKey_Record = Qt::Key_F24,
143 HardKey_Suspend = Qt::Key_F34, 144 HardKey_Suspend = Qt::Key_F34,
144 HardKey_Backlight = Qt::Key_F35, 145 HardKey_Backlight = Qt::Key_F35,
145 HardKey_Action = Qt::Key_F10, 146 HardKey_Action = Qt::Key_F10,
146 HardKey_OK = Qt::Key_F11, 147 HardKey_OK = Qt::Key_F11,
147 HardKey_End = Qt::Key_F12, 148 HardKey_End = Qt::Key_F12,
148}; 149};
149 150
150enum ODirection { 151enum ODirection {
151 CW = 0, 152 CW = 0,
152 CCW = 1, 153 CCW = 1,
153 Flip = 2, 154 Flip = 2,
154}; 155};
155 156
156enum OHingeStatus { 157enum OHingeStatus {
157 CASE_CLOSED = 3, 158 CASE_CLOSED = 3,
158 CASE_PORTRAIT = 2, 159 CASE_PORTRAIT = 2,
159 CASE_LANDSCAPE = 0, 160 CASE_LANDSCAPE = 0,
160 CASE_UNKNOWN = 1, 161 CASE_UNKNOWN = 1,
161}; 162};
162 163
163/* default button for qvfb or such 164/* default button for qvfb or such
164 * see odevice.cpp for details. 165 * see odevice.cpp for details.
165 * hint: manage a user defined button for qvfb? 166 * hint: manage a user defined button for qvfb?
166 * alwin 167 * alwin
167 */ 168 */
168struct default_button { 169struct default_button {
169 Qt::Key code; 170 Qt::Key code;
170 char *utext; 171 char *utext;
171 char *pix; 172 char *pix;
172 char *fpressedservice; 173 char *fpressedservice;
173 char *fpressedaction; 174 char *fpressedaction;
174 char *fheldservice; 175 char *fheldservice;
175 char *fheldaction; 176 char *fheldaction;
176}; 177};
177 178
178/** 179/**
179 * A singleton which gives informations about device specefic option 180 * A singleton which gives informations about device specefic option
180 * like the Hardware used, LEDs, the Base Distribution and 181 * like the Hardware used, LEDs, the Base Distribution and
181 * hardware key mappings. 182 * hardware key mappings.
182 * 183 *
183 * @short A small class for device specefic options 184 * @short A small class for device specefic options
184 * @see QObject 185 * @see QObject
185 * @author Robert Griebl 186 * @author Robert Griebl
186 * @version 1.0 187 * @version 1.0
187 */ 188 */
188class ODevice : public QObject 189class ODevice : public QObject
189{ 190{
190 Q_OBJECT 191 Q_OBJECT
191 192
192private: 193private:
193 /* disable copy */ 194 /* disable copy */
194 ODevice ( const ODevice & ); 195 ODevice ( const ODevice & );
195 196
196protected: 197protected:
197 ODevice(); 198 ODevice();
198 virtual void init(); 199 virtual void init(const QString&);
199 virtual void initButtons(); 200 virtual void initButtons();
200 static void sendSuspendmsg(); 201 static void sendSuspendmsg();
201 202
202 ODeviceData *d; 203 ODeviceData *d;
203 204
204public: 205public:
205 // sandman do we want to allow destructions? -zecke? 206 // sandman do we want to allow destructions? -zecke?
206 virtual ~ODevice(); 207 virtual ~ODevice();
207 208
208 static ODevice *inst(); 209 static ODevice *inst();
209 210
210 // information 211 // information
211 212
212 QString modelString() const; 213 QString modelString() const;
213 OModel model() const; 214 OModel model() const;
214 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 215 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
215 216
216 QString vendorString() const; 217 QString vendorString() const;
217 OVendor vendor() const; 218 OVendor vendor() const;
218 219
219 QString systemString() const; 220 QString systemString() const;
220 OSystem system() const; 221 OSystem system() const;
221 222
222 QString systemVersionString() const; 223 QString systemVersionString() const;
223 224
224 virtual Transformation rotation() const; 225 virtual Transformation rotation() const;
225 virtual ODirection direction() const; 226 virtual ODirection direction() const;
226 227
227 // system 228 // system
228 229
229 virtual bool setSoftSuspend ( bool on ); 230 virtual bool setSoftSuspend ( bool on );
230 virtual bool suspend(); 231 virtual bool suspend();
231 232
232 virtual bool setDisplayStatus ( bool on ); 233 virtual bool setDisplayStatus ( bool on );
233 virtual bool setDisplayBrightness ( int brightness ); 234 virtual bool setDisplayBrightness ( int brightness );
234 virtual int displayBrightnessResolution() const; 235 virtual int displayBrightnessResolution() const;
235 virtual bool setDisplayContrast ( int contrast ); 236 virtual bool setDisplayContrast ( int contrast );
236 virtual int displayContrastResolution() const; 237 virtual int displayContrastResolution() const;
237 238
238 // don't add new virtual methods, use this: 239 // don't add new virtual methods, use this:
239 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 240 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
240 // and in your subclass do do overwrite 241 // and in your subclass do do overwrite
241 //protected virtual int virtual_hook(int, void *) 242 //protected virtual int virtual_hook(int, void *)
242 // which is defined below 243 // which is defined below
243 244
244 // input / output 245 // input / output
245 virtual void playAlarmSound(); 246 virtual void playAlarmSound();
246 virtual void playKeySound(); 247 virtual void playKeySound();
247 virtual void playTouchSound(); 248 virtual void playTouchSound();
248 249
249 virtual QValueList <OLed> ledList() const; 250 virtual QValueList <OLed> ledList() const;
250 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 251 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
251 virtual OLedState ledState ( OLed led ) const; 252 virtual OLedState ledState ( OLed led ) const;
252 virtual bool setLedState ( OLed led, OLedState st ); 253 virtual bool setLedState ( OLed led, OLedState st );
253 254
254 virtual bool hasLightSensor() const; 255 virtual bool hasLightSensor() const;
255 virtual int readLightSensor(); 256 virtual int readLightSensor();
256 virtual int lightSensorResolution() const; 257 virtual int lightSensorResolution() const;
257 258
258 virtual bool hasHingeSensor() const; 259 virtual bool hasHingeSensor() const;
259 virtual OHingeStatus readHingeSensor(); 260 virtual OHingeStatus readHingeSensor();
260 261
261 const QStrList &allowedCpuFrequencies() const; 262 const QStrList &allowedCpuFrequencies() const;
262 bool setCurrentCpuFrequency(uint index); 263 bool setCurrentCpuFrequency(uint index);
263 264
264 /** 265 /**
265 * Returns the available buttons on this device. The number and location 266 * Returns the available buttons on this device. The number and location
266 * of buttons will vary depending on the device. Button numbers will be assigned 267 * of buttons will vary depending on the device. Button numbers will be assigned
267 * by the device manufacturer and will be from most preferred button to least preffered 268 * by the device manufacturer and will be from most preferred button to least preffered
268 * button. Note that this list only contains "user mappable" buttons. 269 * button. Note that this list only contains "user mappable" buttons.
269 * 270 *
270 * @todo Make method const and take care of calling initButtons or make that const too 271 * @todo Make method const and take care of calling initButtons or make that const too
271 * 272 *
272 */ 273 */
273 const QValueList<ODeviceButton> &buttons(); 274 const QValueList<ODeviceButton> &buttons();
274 275
275 /** 276 /**
276 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 277 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
277 * returns 0L 278 * returns 0L
278 */ 279 */
279 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 280 const ODeviceButton *buttonForKeycode ( ushort keyCode );
280 281
281 /** 282 /**
282 * Reassigns the pressed action for \a button. To return to the factory 283 * Reassigns the pressed action for \a button. To return to the factory
283 * default pass an empty string as \a qcopMessage. 284 * default pass an empty string as \a qcopMessage.
284 */ 285 */
285 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 286 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
286 287
287 /** 288 /**
288 * Reassigns the held action for \a button. To return to the factory 289 * Reassigns the held action for \a button. To return to the factory
289 * default pass an empty string as \a qcopMessage. 290 * default pass an empty string as \a qcopMessage.
290 */ 291 */
291 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 292 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
292 293
293 /** 294 /**
294 * How long (in ms) you have to press a button for a "hold" action 295 * How long (in ms) you have to press a button for a "hold" action
295 */ 296 */
296 uint buttonHoldTime() const; 297 uint buttonHoldTime() const;
297 298
298signals: 299signals:
299 void buttonMappingChanged(); 300 void buttonMappingChanged();
300 301
301private slots: 302private slots:
302 void systemMessage ( const QCString &, const QByteArray & ); 303 void systemMessage ( const QCString &, const QByteArray & );
303 304
304protected: 305protected:
305 void reloadButtonMapping(); 306 void reloadButtonMapping();
306 /* ugly virtual hook */ 307 /* ugly virtual hook */
307 virtual void virtual_hook( int id, void* data ); 308 virtual void virtual_hook( int id, void* data );
308}; 309};
309 310
310class ODeviceData { 311class ODeviceData {
311 312
312 public: 313 public:
313 QString m_vendorstr; 314 QString m_vendorstr;
314 OVendor m_vendor; 315 OVendor m_vendor;
315 316
316 QString m_modelstr; 317 QString m_modelstr;
317 OModel m_model; 318 OModel m_model;
318 319
319 QString m_systemstr; 320 QString m_systemstr;
320 OSystem m_system; 321 OSystem m_system;
321 322
322 QString m_sysverstr; 323 QString m_sysverstr;
323 324
324 Transformation m_rotation; 325 Transformation m_rotation;
325 ODirection m_direction; 326 ODirection m_direction;
326 327
327 QValueList <ODeviceButton> *m_buttons; 328 QValueList <ODeviceButton> *m_buttons;
328 uint m_holdtime; 329 uint m_holdtime;
329 QStrList *m_cpu_frequencies; 330 QStrList *m_cpu_frequencies;
330}; 331};
331 332
332} 333}
333} 334}
334 335
335static inline bool isQWS() 336static inline bool isQWS()
336{ 337{
337 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 338 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
338} 339}
339 340
340static QCString makeChannel ( const char *str ) 341static QCString makeChannel ( const char *str )
341{ 342{
342 if ( str && !::strchr ( str, '/' )) 343 if ( str && !::strchr ( str, '/' ))
343 return QCString ( "QPE/Application/" ) + str; 344 return QCString ( "QPE/Application/" ) + str;
344 else 345 else
345 return str; 346 return str;
346} 347}
347 348
348 349
349#endif 350#endif
350 351
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 98e2ffa..efe35e7 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,355 +1,353 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60/* KERNEL */ 60/* KERNEL */
61#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 61#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
62 62
63#define OD_IO(type,number) OD_IOC(0,type,number,0) 63#define OD_IO(type,number) OD_IOC(0,type,number,0)
64#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 64#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
65#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 65#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
66#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 66#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
67 67
68typedef struct { 68typedef struct {
69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
70 unsigned char TotalTime; /* Units of 5 seconds */ 70 unsigned char TotalTime; /* Units of 5 seconds */
71 unsigned char OnTime; /* units of 100m/s */ 71 unsigned char OnTime; /* units of 100m/s */
72 unsigned char OffTime; /* units of 100m/s */ 72 unsigned char OffTime; /* units of 100m/s */
73} LED_IN; 73} LED_IN;
74 74
75typedef struct { 75typedef struct {
76 unsigned char mode; 76 unsigned char mode;
77 unsigned char pwr; 77 unsigned char pwr;
78 unsigned char brightness; 78 unsigned char brightness;
79} FLITE_IN; 79} FLITE_IN;
80 80
81#define LED_ON OD_IOW( 'f', 5, LED_IN ) 81#define LED_ON OD_IOW( 'f', 5, LED_IN )
82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
83 83
84struct i_button ipaq_buttons [] = { 84struct i_button ipaq_buttons [] = {
85 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 85 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
87 "devicebuttons/ipaq_calendar", 87 "devicebuttons/ipaq_calendar",
88 "datebook", "nextView()", 88 "datebook", "nextView()",
89 "today", "raise()" }, 89 "today", "raise()" },
90 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 90 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
92 "devicebuttons/ipaq_contact", 92 "devicebuttons/ipaq_contact",
93 "addressbook", "raise()", 93 "addressbook", "raise()",
94 "addressbook", "beamBusinessCard()" }, 94 "addressbook", "beamBusinessCard()" },
95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/ipaq_menu", 97 "devicebuttons/ipaq_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
102 "devicebuttons/ipaq_mail", 102 "devicebuttons/ipaq_mail",
103 "opiemail", "raise()", 103 "opiemail", "raise()",
104 "opiemail", "newMail()" }, 104 "opiemail", "newMail()" },
105 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 105 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
107 "devicebuttons/ipaq_home", 107 "devicebuttons/ipaq_home",
108 "QPE/Launcher", "home()", 108 "QPE/Launcher", "home()",
109 "buttonsettings", "raise()" }, 109 "buttonsettings", "raise()" },
110 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 110 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
111 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 111 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
112 "devicebuttons/ipaq_record", 112 "devicebuttons/ipaq_record",
113 "QPE/VMemo", "toggleRecord()", 113 "QPE/VMemo", "toggleRecord()",
114 "sound", "raise()" }, 114 "sound", "raise()" },
115}; 115};
116 116
117void iPAQ::init() 117void iPAQ::init(const QString& model)
118{ 118{
119 d->m_vendorstr = "HP"; 119 d->m_vendorstr = "HP";
120 d->m_vendor = Vendor_HP; 120 d->m_vendor = Vendor_HP;
121 121
122 QFile f ( "/proc/hal/model" ); 122 d->m_modelstr = model.mid(model.findRev('H'));
123
124 if ( d->m_modelstr == "H3100" )
125 d->m_model = Model_iPAQ_H31xx;
126 else if ( d->m_modelstr == "H3600" )
127 d->m_model = Model_iPAQ_H36xx;
128 else if ( d->m_modelstr == "H3700" )
129 d->m_model = Model_iPAQ_H37xx;
130 else if ( d->m_modelstr == "H3800" )
131 d->m_model = Model_iPAQ_H38xx;
132 else if ( d->m_modelstr == "H3900" )
133 d->m_model = Model_iPAQ_H39xx;
134 else if ( d->m_modelstr == "H5400" )
135 d->m_model = Model_iPAQ_H5xxx;
136 else if ( d->m_modelstr == "H2200" )
137 d->m_model = Model_iPAQ_H22xx;
138 else
139 d->m_model = Model_Unknown;
123 140
124 if ( f. open ( IO_ReadOnly )) {
125 QTextStream ts ( &f );
126 141
127 d->m_modelstr = "H" + ts. readLine();
128
129 if ( d->m_modelstr == "H3100" )
130 d->m_model = Model_iPAQ_H31xx;
131 else if ( d->m_modelstr == "H3600" )
132 d->m_model = Model_iPAQ_H36xx;
133 else if ( d->m_modelstr == "H3700" )
134 d->m_model = Model_iPAQ_H37xx;
135 else if ( d->m_modelstr == "H3800" )
136 d->m_model = Model_iPAQ_H38xx;
137 else if ( d->m_modelstr == "H3900" )
138 d->m_model = Model_iPAQ_H39xx;
139 else if ( d->m_modelstr == "H5400" )
140 d->m_model = Model_iPAQ_H5xxx;
141 else
142 d->m_model = Model_Unknown;
143
144 f. close();
145 }
146 142
147 switch ( d->m_model ) { 143 switch ( d->m_model ) {
148 case Model_iPAQ_H31xx: 144 case Model_iPAQ_H31xx:
149 case Model_iPAQ_H38xx: 145 case Model_iPAQ_H38xx:
150 d->m_rotation = Rot90; 146 d->m_rotation = Rot90;
151 break; 147 break;
148 case Model_iPAQ_H5xxx:
149 case Model_iPAQ_H22xx:
150 d->m_rotation = Rot0;
151 break;
152 case Model_iPAQ_H36xx: 152 case Model_iPAQ_H36xx:
153 case Model_iPAQ_H37xx: 153 case Model_iPAQ_H37xx:
154 case Model_iPAQ_H39xx: 154 case Model_iPAQ_H39xx:
155
156 default: 155 default:
157 d->m_rotation = Rot270; 156 d->m_rotation = Rot270;
158 break; 157 break;
159 case Model_iPAQ_H5xxx: 158
160 d->m_rotation = Rot0;
161 } 159 }
162 160
163 f. setName ( "/etc/familiar-version" ); 161 QFile f( "/etc/familiar-version" );
164 if ( f. open ( IO_ReadOnly )) { 162 if ( f. open ( IO_ReadOnly )) {
165 d->m_systemstr = "Familiar"; 163 d->m_systemstr = "Familiar";
166 d->m_system = System_Familiar; 164 d->m_system = System_Familiar;
167 165
168 QTextStream ts ( &f ); 166 QTextStream ts ( &f );
169 d->m_sysverstr = ts. readLine(). mid ( 10 ); 167 d->m_sysverstr = ts. readLine(). mid ( 10 );
170 168
171 f. close(); 169 f. close();
172 } else { 170 } else {
173 f. setName ( "/etc/oz_version" ); 171 f. setName ( "/etc/oz_version" );
174 172
175 if ( f. open ( IO_ReadOnly )) { 173 if ( f. open ( IO_ReadOnly )) {
176 d->m_systemstr = "OpenEmbedded/iPaq"; 174 d->m_systemstr = "OpenEmbedded/iPaq";
177 d->m_system = System_Familiar; 175 d->m_system = System_Familiar;
178 176
179 QTextStream ts ( &f ); 177 QTextStream ts ( &f );
180 ts.setDevice ( &f ); 178 ts.setDevice ( &f );
181 d->m_sysverstr = ts. readLine(); 179 d->m_sysverstr = ts. readLine();
182 f. close(); 180 f. close();
183 } 181 }
184 } 182 }
185 183
186 m_leds [0] = m_leds [1] = Led_Off; 184 m_leds [0] = m_leds [1] = Led_Off;
187 185
188 m_power_timer = 0; 186 m_power_timer = 0;
189 187
190} 188}
191 189
192void iPAQ::initButtons() 190void iPAQ::initButtons()
193{ 191{
194 if ( d->m_buttons ) 192 if ( d->m_buttons )
195 return; 193 return;
196 194
197 if ( isQWS( ) ) 195 if ( isQWS( ) )
198 QWSServer::setKeyboardFilter ( this ); 196 QWSServer::setKeyboardFilter ( this );
199 197
200 d->m_buttons = new QValueList <ODeviceButton>; 198 d->m_buttons = new QValueList <ODeviceButton>;
201 199
202 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 200 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
203 i_button *ib = ipaq_buttons + i; 201 i_button *ib = ipaq_buttons + i;
204 ODeviceButton b; 202 ODeviceButton b;
205 203
206 if (( ib->model & d->m_model ) == d->m_model ) { 204 if (( ib->model & d->m_model ) == d->m_model ) {
207 b. setKeycode ( ib->code ); 205 b. setKeycode ( ib->code );
208 b. setUserText ( QObject::tr ( "Button", ib->utext )); 206 b. setUserText ( QObject::tr ( "Button", ib->utext ));
209 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 207 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
210 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 208 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
211 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 209 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
212 210
213 d->m_buttons->append ( b ); 211 d->m_buttons->append ( b );
214 } 212 }
215 } 213 }
216 reloadButtonMapping(); 214 reloadButtonMapping();
217 215
218 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 216 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
219 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 217 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
220} 218}
221 219
222QValueList <OLed> iPAQ::ledList() const 220QValueList <OLed> iPAQ::ledList() const
223{ 221{
224 QValueList <OLed> vl; 222 QValueList <OLed> vl;
225 vl << Led_Power; 223 vl << Led_Power;
226 224
227 if ( d->m_model == Model_iPAQ_H38xx ) 225 if ( d->m_model == Model_iPAQ_H38xx )
228 vl << Led_BlueTooth; 226 vl << Led_BlueTooth;
229 return vl; 227 return vl;
230} 228}
231 229
232QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 230QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
233{ 231{
234 QValueList <OLedState> vl; 232 QValueList <OLedState> vl;
235 233
236 if ( l == Led_Power ) 234 if ( l == Led_Power )
237 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 235 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
238 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 236 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
239 vl << Led_Off; // << Led_On << ??? 237 vl << Led_Off; // << Led_On << ???
240 238
241 return vl; 239 return vl;
242} 240}
243 241
244OLedState iPAQ::ledState ( OLed l ) const 242OLedState iPAQ::ledState ( OLed l ) const
245{ 243{
246 switch ( l ) { 244 switch ( l ) {
247 case Led_Power: 245 case Led_Power:
248 return m_leds [0]; 246 return m_leds [0];
249 case Led_BlueTooth: 247 case Led_BlueTooth:
250 return m_leds [1]; 248 return m_leds [1];
251 default: 249 default:
252 return Led_Off; 250 return Led_Off;
253 } 251 }
254} 252}
255 253
256bool iPAQ::setLedState ( OLed l, OLedState st ) 254bool iPAQ::setLedState ( OLed l, OLedState st )
257{ 255{
258 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 256 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
259 257
260 if ( l == Led_Power ) { 258 if ( l == Led_Power ) {
261 if ( fd >= 0 ) { 259 if ( fd >= 0 ) {
262 LED_IN leds; 260 LED_IN leds;
263 ::memset ( &leds, 0, sizeof( leds )); 261 ::memset ( &leds, 0, sizeof( leds ));
264 leds. TotalTime = 0; 262 leds. TotalTime = 0;
265 leds. OnTime = 0; 263 leds. OnTime = 0;
266 leds. OffTime = 1; 264 leds. OffTime = 1;
267 leds. OffOnBlink = 2; 265 leds. OffOnBlink = 2;
268 266
269 switch ( st ) { 267 switch ( st ) {
270 case Led_Off : leds. OffOnBlink = 0; break; 268 case Led_Off : leds. OffOnBlink = 0; break;
271 case Led_On : leds. OffOnBlink = 1; break; 269 case Led_On : leds. OffOnBlink = 1; break;
272 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 270 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
273 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 271 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
274 } 272 }
275 273
276 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 274 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
277 m_leds [0] = st; 275 m_leds [0] = st;
278 return true; 276 return true;
279 } 277 }
280 } 278 }
281 } 279 }
282 return false; 280 return false;
283} 281}
284 282
285 283
286bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 284bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
287{ 285{
288 int newkeycode = keycode; 286 int newkeycode = keycode;
289 287
290 switch ( keycode ) { 288 switch ( keycode ) {
291 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 289 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
292 case HardKey_Menu: { 290 case HardKey_Menu: {
293 if (( d->m_model == Model_iPAQ_H38xx ) || 291 if (( d->m_model == Model_iPAQ_H38xx ) ||
294 ( d->m_model == Model_iPAQ_H39xx ) || 292 ( d->m_model == Model_iPAQ_H39xx ) ||
295 ( d->m_model == Model_iPAQ_H5xxx)) { 293 ( d->m_model == Model_iPAQ_H5xxx)) {
296 newkeycode = HardKey_Mail; 294 newkeycode = HardKey_Mail;
297 } 295 }
298 break; 296 break;
299 } 297 }
300 298
301 // Rotate cursor keys 180° or 270° 299 // Rotate cursor keys 180° or 270°
302 case Key_Left : 300 case Key_Left :
303 case Key_Right: 301 case Key_Right:
304 case Key_Up : 302 case Key_Up :
305 case Key_Down : { 303 case Key_Down : {
306 if (( d->m_model == Model_iPAQ_H31xx ) || 304 if (( d->m_model == Model_iPAQ_H31xx ) ||
307 ( d->m_model == Model_iPAQ_H38xx )) { 305 ( d->m_model == Model_iPAQ_H38xx )) {
308 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 306 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
309 } 307 }
310 // Rotate the cursor keys by 270° 308 // Rotate the cursor keys by 270°
311 // keycode - Key_Left = position of the button starting from left clockwise 309 // keycode - Key_Left = position of the button starting from left clockwise
312 // add the rotation to it and modolo. No we've the original offset 310 // add the rotation to it and modolo. No we've the original offset
313 // add the offset to the Key_Left key 311 // add the offset to the Key_Left key
314 if ( d-> m_model == Model_iPAQ_H5xxx ) 312 if ( d-> m_model == Model_iPAQ_H5xxx )
315 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 313 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
316 break; 314 break;
317 } 315 }
318 316
319 // map Power Button short/long press to F34/F35 317 // map Power Button short/long press to F34/F35
320 case Key_SysReq: { 318 case Key_SysReq: {
321 if ( isPress ) { 319 if ( isPress ) {
322 if ( m_power_timer ) 320 if ( m_power_timer )
323 killTimer ( m_power_timer ); 321 killTimer ( m_power_timer );
324 m_power_timer = startTimer ( 500 ); 322 m_power_timer = startTimer ( 500 );
325 } 323 }
326 else if ( m_power_timer ) { 324 else if ( m_power_timer ) {
327 killTimer ( m_power_timer ); 325 killTimer ( m_power_timer );
328 m_power_timer = 0; 326 m_power_timer = 0;
329 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 327 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
330 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 328 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
331 } 329 }
332 newkeycode = Key_unknown; 330 newkeycode = Key_unknown;
333 break; 331 break;
334 } 332 }
335 } 333 }
336 334
337 if ( newkeycode != keycode ) { 335 if ( newkeycode != keycode ) {
338 if ( newkeycode != Key_unknown ) 336 if ( newkeycode != Key_unknown )
339 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 337 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
340 return true; 338 return true;
341 } 339 }
342 else 340 else
343 return false; 341 return false;
344} 342}
345 343
346void iPAQ::timerEvent ( QTimerEvent * ) 344void iPAQ::timerEvent ( QTimerEvent * )
347{ 345{
348 killTimer ( m_power_timer ); 346 killTimer ( m_power_timer );
349 m_power_timer = 0; 347 m_power_timer = 0;
350 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 348 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
351 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 349 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
352} 350}
353 351
354 352
355void iPAQ::playAlarmSound() 353void iPAQ::playAlarmSound()
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index 968f715..cc0b8ac 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -1,90 +1,90 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_IPAQ 30#ifndef ODEVICE_IPAQ
31#define ODEVICE_IPAQ 31#define ODEVICE_IPAQ
32 32
33#include "odevice.h" 33#include "odevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 44
45 protected: 45 protected:
46 virtual void init(); 46 virtual void init(const QString&);
47 virtual void initButtons(); 47 virtual void initButtons();
48 48
49 public: 49 public:
50 virtual bool setSoftSuspend( bool soft ); 50 virtual bool setSoftSuspend( bool soft );
51 51
52 virtual bool setDisplayBrightness( int b ); 52 virtual bool setDisplayBrightness( int b );
53 virtual int displayBrightnessResolution() const; 53 virtual int displayBrightnessResolution() const;
54 54
55 virtual void playAlarmSound(); 55 virtual void playAlarmSound();
56 56
57 virtual QValueList <OLed> ledList() const; 57 virtual QValueList <OLed> ledList() const;
58 virtual QValueList <OLedState> ledStateList( OLed led ) const; 58 virtual QValueList <OLedState> ledStateList( OLed led ) const;
59 virtual OLedState ledState( OLed led ) const; 59 virtual OLedState ledState( OLed led ) const;
60 virtual bool setLedState( OLed led, OLedState st ); 60 virtual bool setLedState( OLed led, OLedState st );
61 61
62 virtual bool hasLightSensor() const; 62 virtual bool hasLightSensor() const;
63 virtual int readLightSensor(); 63 virtual int readLightSensor();
64 virtual int lightSensorResolution() const; 64 virtual int lightSensorResolution() const;
65 65
66 protected: 66 protected:
67 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 67 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
68 virtual void timerEvent( QTimerEvent *te ); 68 virtual void timerEvent( QTimerEvent *te );
69 69
70 int m_power_timer; 70 int m_power_timer;
71 71
72 OLedState m_leds [2]; 72 OLedState m_leds [2];
73}; 73};
74 74
75struct i_button { 75struct i_button {
76 uint model; 76 uint model;
77 Qt::Key code; 77 Qt::Key code;
78 char *utext; 78 char *utext;
79 char *pix; 79 char *pix;
80 char *fpressedservice; 80 char *fpressedservice;
81 char *fpressedaction; 81 char *fpressedaction;
82 char *fheldservice; 82 char *fheldservice;
83 char *fheldaction; 83 char *fheldaction;
84}; 84};
85 85
86} 86}
87} 87}
88} 88}
89 89
90#endif 90#endif
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index eaa93ca..ad2f830 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -1,150 +1,150 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_jornada.h" 30#include "odevice_jornada.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56/* KERNEL */ 56/* KERNEL */
57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
58 58
59#define OD_IO(type,number) OD_IOC(0,type,number,0) 59#define OD_IO(type,number) OD_IOC(0,type,number,0)
60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
63 63
64typedef struct { 64typedef struct {
65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
66 unsigned char TotalTime; /* Units of 5 seconds */ 66 unsigned char TotalTime; /* Units of 5 seconds */
67 unsigned char OnTime; /* units of 100m/s */ 67 unsigned char OnTime; /* units of 100m/s */
68 unsigned char OffTime; /* units of 100m/s */ 68 unsigned char OffTime; /* units of 100m/s */
69} LED_IN; 69} LED_IN;
70 70
71typedef struct { 71typedef struct {
72 unsigned char mode; 72 unsigned char mode;
73 unsigned char pwr; 73 unsigned char pwr;
74 unsigned char brightness; 74 unsigned char brightness;
75} FLITE_IN; 75} FLITE_IN;
76 76
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 79
80using namespace Opie::Core::Internal; 80using namespace Opie::Core::Internal;
81 81
82void Jornada::init() 82void Jornada::init(const QString&)
83{ 83{
84 d->m_vendorstr = "HP"; 84 d->m_vendorstr = "HP";
85 d->m_vendor = Vendor_HP; 85 d->m_vendor = Vendor_HP;
86 d->m_modelstr = "Jornada 56x"; 86 d->m_modelstr = "Jornada 56x";
87 d->m_model = Model_Jornada_56x; 87 d->m_model = Model_Jornada_56x;
88 d->m_systemstr = "Familiar"; 88 d->m_systemstr = "Familiar";
89 d->m_system = System_Familiar; 89 d->m_system = System_Familiar;
90 d->m_rotation = Rot0; 90 d->m_rotation = Rot0;
91 91
92 QFile f ( "/etc/familiar-version" ); 92 QFile f ( "/etc/familiar-version" );
93 f.setName ( "/etc/familiar-version" ); 93 f.setName ( "/etc/familiar-version" );
94 if ( f.open ( IO_ReadOnly )) { 94 if ( f.open ( IO_ReadOnly )) {
95 95
96 QTextStream ts ( &f ); 96 QTextStream ts ( &f );
97 d->m_sysverstr = ts.readLine().mid( 10 ); 97 d->m_sysverstr = ts.readLine().mid( 10 );
98 98
99 f. close(); 99 f. close();
100 } 100 }
101} 101}
102 102
103 103
104int Jornada::displayBrightnessResolution() const 104int Jornada::displayBrightnessResolution() const
105{ 105{
106 return 0; 106 return 0;
107} 107}
108 108
109 109
110bool Jornada::setDisplayBrightness( int bright ) 110bool Jornada::setDisplayBrightness( int bright )
111{ 111{
112 bool res = false; 112 bool res = false;
113 int fd; 113 int fd;
114 114
115 if ( bright > 255 ) 115 if ( bright > 255 )
116 bright = 255; 116 bright = 255;
117 if ( bright < 0 ) 117 if ( bright < 0 )
118 bright = 0; 118 bright = 0;
119 119
120 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 120 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
121 FLITE_IN bl; 121 FLITE_IN bl;
122 bl. mode = 1; 122 bl. mode = 1;
123 bl. pwr = bright ? 1 : 0; 123 bl. pwr = bright ? 1 : 0;
124 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 124 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
125 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 125 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
126 ::close ( fd ); 126 ::close ( fd );
127 } 127 }
128 return res; 128 return res;
129} 129}
130 130
131 131
132bool Jornada::setSoftSuspend( bool soft ) 132bool Jornada::setSoftSuspend( bool soft )
133{ 133{
134 bool res = false; 134 bool res = false;
135 int fd; 135 int fd;
136 136
137 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 137 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
138 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 138 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
139 res = true; 139 res = true;
140 else 140 else
141 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 141 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
142 142
143 ::close ( fd ); 143 ::close ( fd );
144 } 144 }
145 else 145 else
146 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 146 ::perror ( "/proc/sys/ts/suspend_button_mode" );
147 147
148 return res; 148 return res;
149} 149}
150 150
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
index e2e67af..fddfe34 100644
--- a/libopie2/opiecore/device/odevice_jornada.h
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -1,53 +1,53 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_JORNADA 30#ifndef ODEVICE_JORNADA
31#define ODEVICE_JORNADA 31#define ODEVICE_JORNADA
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Jornada : public ODevice 38class Jornada : public ODevice
39{ 39{
40 40
41 protected: 41 protected:
42 virtual void init(); 42 virtual void init(const QString&);
43 43
44 public: 44 public:
45 virtual bool setSoftSuspend ( bool soft ); 45 virtual bool setSoftSuspend ( bool soft );
46 virtual bool setDisplayBrightness ( int b ); 46 virtual bool setDisplayBrightness ( int b );
47 virtual int displayBrightnessResolution() const; 47 virtual int displayBrightnessResolution() const;
48}; 48};
49} 49}
50} 50}
51} 51}
52#endif 52#endif
53 53
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index 10b7b61..32467f1 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -1,264 +1,264 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ramses.h" 30#include "odevice_ramses.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct r_button ramses_buttons [] = { 59struct r_button ramses_buttons [] = {
60 { Model_Ramses_MNCI, 60 { Model_Ramses_MNCI,
61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
62 "devicebuttons/z_menu", 62 "devicebuttons/z_menu",
63 "QPE/TaskBar", "toggleMenu()", 63 "QPE/TaskBar", "toggleMenu()",
64 "QPE/TaskBar", "toggleStartMenu()" }, 64 "QPE/TaskBar", "toggleStartMenu()" },
65 { Model_Ramses_MNCI, 65 { Model_Ramses_MNCI,
66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
67 "devicebuttons/ipaq_home", 67 "devicebuttons/ipaq_home",
68 "QPE/Launcher", "home()", 68 "QPE/Launcher", "home()",
69 "buttonsettings", "raise()" }, 69 "buttonsettings", "raise()" },
70}; 70};
71 71
72void Ramses::init() 72void Ramses::init(const QString&)
73{ 73{
74 d->m_vendorstr = "M und N"; 74 d->m_vendorstr = "M und N";
75 d->m_vendor = Vendor_MundN; 75 d->m_vendor = Vendor_MundN;
76 76
77 QFile f("/proc/sys/board/ramses"); 77 QFile f("/proc/sys/board/ramses");
78 78
79 d->m_modelstr = "Ramses"; 79 d->m_modelstr = "Ramses";
80 d->m_model = Model_Ramses_MNCI; 80 d->m_model = Model_Ramses_MNCI;
81 81
82 d->m_rotation = Rot0; 82 d->m_rotation = Rot0;
83 d->m_holdtime = 1000; 83 d->m_holdtime = 1000;
84 84
85 f.setName("/etc/oz_version"); 85 f.setName("/etc/oz_version");
86 86
87 if (f.open(IO_ReadOnly)) { 87 if (f.open(IO_ReadOnly)) {
88 d->m_systemstr = "OpenEmbedded/Ramses"; 88 d->m_systemstr = "OpenEmbedded/Ramses";
89 d->m_system = System_OpenZaurus; 89 d->m_system = System_OpenZaurus;
90 90
91 QTextStream ts(&f); 91 QTextStream ts(&f);
92 ts.setDevice(&f); 92 ts.setDevice(&f);
93 d->m_sysverstr = ts.readLine(); 93 d->m_sysverstr = ts.readLine();
94 f.close(); 94 f.close();
95 } 95 }
96 96
97 m_power_timer = 0; 97 m_power_timer = 0;
98 98
99#ifdef QT_QWS_ALLOW_OVERCLOCK 99#ifdef QT_QWS_ALLOW_OVERCLOCK
100#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 100#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
101#define OC(x...) x 101#define OC(x...) x
102#else 102#else
103#define OC(x...) 103#define OC(x...)
104#endif 104#endif
105 105
106 // This table is true for a Intel XScale PXA 255 106 // This table is true for a Intel XScale PXA 255
107 107
108 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 108 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
109OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 109OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
110 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 110 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
111OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 111OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
112 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 112 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
113OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 113OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
114 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 114 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
115 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 115 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
116OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 116OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
117 117
118} 118}
119 119
120bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 120bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
121{ 121{
122 Q_UNUSED( keycode ); 122 Q_UNUSED( keycode );
123 Q_UNUSED( modifiers ); 123 Q_UNUSED( modifiers );
124 Q_UNUSED( isPress ); 124 Q_UNUSED( isPress );
125 Q_UNUSED( autoRepeat ); 125 Q_UNUSED( autoRepeat );
126 return false; 126 return false;
127} 127}
128 128
129void Ramses::timerEvent(QTimerEvent *) 129void Ramses::timerEvent(QTimerEvent *)
130{ 130{
131 killTimer(m_power_timer); 131 killTimer(m_power_timer);
132 m_power_timer = 0; 132 m_power_timer = 0;
133 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 133 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
134 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 134 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
135} 135}
136 136
137 137
138bool Ramses::setSoftSuspend(bool soft) 138bool Ramses::setSoftSuspend(bool soft)
139{ 139{
140 qDebug("Ramses::setSoftSuspend(%d)", soft); 140 qDebug("Ramses::setSoftSuspend(%d)", soft);
141#if 0 141#if 0
142 bool res = false; 142 bool res = false;
143 int fd; 143 int fd;
144 144
145 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || 145 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
146 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { 146 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
147 147
148 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources 148 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
149 149
150 if (sources >= 0) { 150 if (sources >= 0) {
151 if (soft) 151 if (soft)
152 sources &= ~APM_EVT_POWER_BUTTON; 152 sources &= ~APM_EVT_POWER_BUTTON;
153 else 153 else
154 sources |= APM_EVT_POWER_BUTTON; 154 sources |= APM_EVT_POWER_BUTTON;
155 155
156 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources 156 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
157 res = true; 157 res = true;
158 else 158 else
159 perror("APM_IOCGEVTSRC"); 159 perror("APM_IOCGEVTSRC");
160 } 160 }
161 else 161 else
162 perror("APM_IOCGEVTSRC"); 162 perror("APM_IOCGEVTSRC");
163 163
164 ::close(fd); 164 ::close(fd);
165 } 165 }
166 else 166 else
167 perror("/dev/apm_bios or /dev/misc/apm_bios"); 167 perror("/dev/apm_bios or /dev/misc/apm_bios");
168 168
169 return res; 169 return res;
170#else 170#else
171 return true; 171 return true;
172#endif 172#endif
173} 173}
174 174
175bool Ramses::suspend() 175bool Ramses::suspend()
176{ 176{
177 qDebug("Ramses::suspend"); 177 qDebug("Ramses::suspend");
178 return false; 178 return false;
179} 179}
180 180
181/** 181/**
182* This sets the display on or off 182* This sets the display on or off
183*/ 183*/
184bool Ramses::setDisplayStatus(bool on) 184bool Ramses::setDisplayStatus(bool on)
185{ 185{
186 qDebug("Ramses::setDisplayStatus(%d)", on); 186 qDebug("Ramses::setDisplayStatus(%d)", on);
187#if 0 187#if 0
188 bool res = false; 188 bool res = false;
189 int fd; 189 int fd;
190 190
191 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 191 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
192 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 192 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
193 ::close(fd); 193 ::close(fd);
194 } 194 }
195 return res; 195 return res;
196#else 196#else
197 return true; 197 return true;
198#endif 198#endif
199} 199}
200 200
201 201
202/* 202/*
203* We get something between 0..255 into us 203* We get something between 0..255 into us
204*/ 204*/
205bool Ramses::setDisplayBrightness(int bright) 205bool Ramses::setDisplayBrightness(int bright)
206{ 206{
207 qDebug("Ramses::setDisplayBrightness(%d)", bright); 207 qDebug("Ramses::setDisplayBrightness(%d)", bright);
208 bool res = false; 208 bool res = false;
209 int fd; 209 int fd;
210 210
211 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 211 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
212 212
213 if (bright > 255 ) 213 if (bright > 255 )
214 bright = 255; 214 bright = 255;
215 if (bright < 0) 215 if (bright < 0)
216 bright = 0; 216 bright = 0;
217 217
218 // Turn backlight completely off 218 // Turn backlight completely off
219 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 219 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
220 char writeCommand[10]; 220 char writeCommand[10];
221 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 221 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
222 res = (::write(fd, writeCommand, count) != -1); 222 res = (::write(fd, writeCommand, count) != -1);
223 ::close(fd); 223 ::close(fd);
224 } 224 }
225 225
226 // scale backlight brightness to hardware 226 // scale backlight brightness to hardware
227 bright = 500-(bright * 500 / 255); 227 bright = 500-(bright * 500 / 255);
228 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 228 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
229 qDebug(" %d ->pwm1", bright); 229 qDebug(" %d ->pwm1", bright);
230 char writeCommand[100]; 230 char writeCommand[100];
231 const int count = sprintf(writeCommand, "%d\n", bright); 231 const int count = sprintf(writeCommand, "%d\n", bright);
232 res = (::write(fd, writeCommand, count) != -1); 232 res = (::write(fd, writeCommand, count) != -1);
233 ::close(fd); 233 ::close(fd);
234 } 234 }
235 return res; 235 return res;
236} 236}
237 237
238 238
239int Ramses::displayBrightnessResolution() const 239int Ramses::displayBrightnessResolution() const
240{ 240{
241 return 32; 241 return 32;
242} 242}
243 243
244bool Ramses::setDisplayContrast(int contr) 244bool Ramses::setDisplayContrast(int contr)
245{ 245{
246 qDebug("Ramses::setDisplayContrast(%d)", contr); 246 qDebug("Ramses::setDisplayContrast(%d)", contr);
247 bool res = false; 247 bool res = false;
248 int fd; 248 int fd;
249 249
250 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 250 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
251 251
252 if (contr > 255 ) 252 if (contr > 255 )
253 contr = 255; 253 contr = 255;
254 if (contr < 0) 254 if (contr < 0)
255 contr = 0; 255 contr = 0;
256 contr = 90 - (contr * 20 / 255); 256 contr = 90 - (contr * 20 / 255);
257 257
258 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 258 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
259 qDebug(" %d ->pwm0", contr); 259 qDebug(" %d ->pwm0", contr);
260 char writeCommand[100]; 260 char writeCommand[100];
261 const int count = sprintf(writeCommand, "%d\n", contr); 261 const int count = sprintf(writeCommand, "%d\n", contr);
262 res = (::write(fd, writeCommand, count) != -1); 262 res = (::write(fd, writeCommand, count) != -1);
263 res = true; 263 res = true;
264 ::close(fd); 264 ::close(fd);
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
index aea9e2a..3cf5e92 100644
--- a/libopie2/opiecore/device/odevice_ramses.h
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -1,77 +1,77 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_RAMSES 30#ifndef ODEVICE_RAMSES
31#define ODEVICE_RAMSES 31#define ODEVICE_RAMSES
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34/* QT */ 34/* QT */
35#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
36 36
37namespace Opie { 37namespace Opie {
38namespace Core { 38namespace Core {
39namespace Internal { 39namespace Internal {
40 40
41class Ramses : public ODevice, public QWSServer::KeyboardFilter 41class Ramses : public ODevice, public QWSServer::KeyboardFilter
42{ 42{
43 protected: 43 protected:
44 virtual void init(); 44 virtual void init(const QString&);
45 45
46 public: 46 public:
47 virtual bool setSoftSuspend( bool soft ); 47 virtual bool setSoftSuspend( bool soft );
48 virtual bool suspend(); 48 virtual bool suspend();
49 49
50 virtual bool setDisplayStatus( bool on ); 50 virtual bool setDisplayStatus( bool on );
51 virtual bool setDisplayBrightness( int b ); 51 virtual bool setDisplayBrightness( int b );
52 virtual int displayBrightnessResolution() const; 52 virtual int displayBrightnessResolution() const;
53 virtual bool setDisplayContrast( int b ); 53 virtual bool setDisplayContrast( int b );
54 virtual int displayContrastResolution() const; 54 virtual int displayContrastResolution() const;
55 55
56 protected: 56 protected:
57 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 57 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
58 virtual void timerEvent ( QTimerEvent *te ); 58 virtual void timerEvent ( QTimerEvent *te );
59 59
60 int m_power_timer; 60 int m_power_timer;
61}; 61};
62 62
63struct r_button { 63struct r_button {
64 uint model; 64 uint model;
65 Qt::Key code; 65 Qt::Key code;
66 char *utext; 66 char *utext;
67 char *pix; 67 char *pix;
68 char *fpressedservice; 68 char *fpressedservice;
69 char *fpressedaction; 69 char *fpressedaction;
70 char *fheldservice; 70 char *fheldservice;
71 char *fheldaction; 71 char *fheldaction;
72}; 72};
73} 73}
74} 74}
75} 75}
76 76
77#endif 77#endif
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index e9481bb..6630763 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,307 +1,307 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_simpad.h" 30#include "odevice_simpad.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct s_button simpad_buttons [] = { 59struct s_button simpad_buttons [] = {
60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
62 "devicebuttons/simpad_lower_up", 62 "devicebuttons/simpad_lower_up",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
67 "devicebuttons/simpad_lower_down", 67 "devicebuttons/simpad_lower_down",
68 "addressbook", "raise()", 68 "addressbook", "raise()",
69 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
72 "devicebuttons/simpad_lower_right", 72 "devicebuttons/simpad_lower_right",
73 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
74 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
75 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 75 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
77 "devicebuttons/simpad_lower_left", 77 "devicebuttons/simpad_lower_left",
78 "opiemail", "raise()", 78 "opiemail", "raise()",
79 "opiemail", "newMail()" }, 79 "opiemail", "newMail()" },
80 80
81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
83 "devicebuttons/simpad_upper_up", 83 "devicebuttons/simpad_upper_up",
84 "QPE/Launcher", "home()", 84 "QPE/Launcher", "home()",
85 "buttonsettings", "raise()" }, 85 "buttonsettings", "raise()" },
86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
88 "devicebuttons/simpad_upper_down", 88 "devicebuttons/simpad_upper_down",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
93 "devicebuttons/simpad_upper_right", 93 "devicebuttons/simpad_upper_right",
94 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
95 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
98 "devicebuttons/simpad_upper_left", 98 "devicebuttons/simpad_upper_left",
99 "QPE/Rotation", "flip()", 99 "QPE/Rotation", "flip()",
100 "QPE/Rotation", "flip()" }, 100 "QPE/Rotation", "flip()" },
101 /* 101 /*
102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
104 "devicebuttons/simpad_lower_upper", 104 "devicebuttons/simpad_lower_upper",
105 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
106 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
109 "devicebuttons/simpad_upper_lower", 109 "devicebuttons/simpad_upper_lower",
110 "QPE/Launcher", "home()", 110 "QPE/Launcher", "home()",
111 "buttonsettings", "raise()" }, 111 "buttonsettings", "raise()" },
112 */ 112 */
113}; 113};
114 114
115void SIMpad::init() 115void SIMpad::init(const QString&)
116{ 116{
117 d->m_vendorstr = "SIEMENS"; 117 d->m_vendorstr = "SIEMENS";
118 d->m_vendor = Vendor_SIEMENS; 118 d->m_vendor = Vendor_SIEMENS;
119 119
120 QFile f ( "/proc/hal/model" ); 120 QFile f ( "/proc/hal/model" );
121 121
122 //TODO Implement model checking 122 //TODO Implement model checking
123 //FIXME For now we assume an SL4 123 //FIXME For now we assume an SL4
124 124
125 d->m_modelstr = "SL4"; 125 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 126 d->m_model = Model_SIMpad_SL4;
127 127
128 switch ( d->m_model ) { 128 switch ( d->m_model ) {
129 default: 129 default:
130 d->m_rotation = Rot0; 130 d->m_rotation = Rot0;
131 d->m_direction = CCW; 131 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 132 d->m_holdtime = 1000; // 1000ms
133 133
134 break; 134 break;
135 } 135 }
136 136
137 f. setName ( "/etc/familiar-version" ); 137 f. setName ( "/etc/familiar-version" );
138 if ( f. open ( IO_ReadOnly )) { 138 if ( f. open ( IO_ReadOnly )) {
139 d->m_systemstr = "Familiar"; 139 d->m_systemstr = "Familiar";
140 d->m_system = System_Familiar; 140 d->m_system = System_Familiar;
141 141
142 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
143 d->m_sysverstr = ts. readLine(). mid ( 10 ); 143 d->m_sysverstr = ts. readLine(). mid ( 10 );
144 144
145 f. close(); 145 f. close();
146 } else { 146 } else {
147 f. setName ( "/etc/oz_version" ); 147 f. setName ( "/etc/oz_version" );
148 148
149 if ( f. open ( IO_ReadOnly )) { 149 if ( f. open ( IO_ReadOnly )) {
150 d->m_systemstr = "OpenEmbedded/SIMpad"; 150 d->m_systemstr = "OpenEmbedded/SIMpad";
151 d->m_system = System_OpenZaurus; 151 d->m_system = System_OpenZaurus;
152 152
153 QTextStream ts ( &f ); 153 QTextStream ts ( &f );
154 ts.setDevice ( &f ); 154 ts.setDevice ( &f );
155 d->m_sysverstr = ts. readLine(); 155 d->m_sysverstr = ts. readLine();
156 f. close(); 156 f. close();
157 } 157 }
158 } 158 }
159 159
160 m_leds [0] = m_leds [1] = Led_Off; 160 m_leds [0] = m_leds [1] = Led_Off;
161 161
162 m_power_timer = 0; 162 m_power_timer = 0;
163 163
164} 164}
165 165
166void SIMpad::initButtons() 166void SIMpad::initButtons()
167{ 167{
168 if ( d->m_buttons ) 168 if ( d->m_buttons )
169 return; 169 return;
170 170
171 if ( isQWS( ) ) 171 if ( isQWS( ) )
172 QWSServer::setKeyboardFilter ( this ); 172 QWSServer::setKeyboardFilter ( this );
173 173
174 d->m_buttons = new QValueList <ODeviceButton>; 174 d->m_buttons = new QValueList <ODeviceButton>;
175 175
176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
177 s_button *sb = simpad_buttons + i; 177 s_button *sb = simpad_buttons + i;
178 ODeviceButton b; 178 ODeviceButton b;
179 179
180 if (( sb->model & d->m_model ) == d->m_model ) { 180 if (( sb->model & d->m_model ) == d->m_model ) {
181 b. setKeycode ( sb->code ); 181 b. setKeycode ( sb->code );
182 b. setUserText ( QObject::tr ( "Button", sb->utext )); 182 b. setUserText ( QObject::tr ( "Button", sb->utext ));
183 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 183 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
184 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 184 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
185 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 185 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
186 186
187 d->m_buttons->append ( b ); 187 d->m_buttons->append ( b );
188 } 188 }
189 } 189 }
190 reloadButtonMapping(); 190 reloadButtonMapping();
191 191
192 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 192 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
193 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 193 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
194} 194}
195 195
196// SIMpad boardcontrol register CS3 196// SIMpad boardcontrol register CS3
197#define SIMPAD_BOARDCONTROL "/proc/cs3" 197#define SIMPAD_BOARDCONTROL "/proc/cs3"
198#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 198#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
199#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 199#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
200#define SIMPAD_EN1 0x0004 // This is only for EPROM's 200#define SIMPAD_EN1 0x0004 // This is only for EPROM's
201#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 201#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
202#define SIMPAD_DISPLAY_ON 0x0010 202#define SIMPAD_DISPLAY_ON 0x0010
203#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 203#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
204#define SIMPAD_MQ_RESET 0x0040 204#define SIMPAD_MQ_RESET 0x0040
205#define SIMPAD_PCMCIA_RESET 0x0080 205#define SIMPAD_PCMCIA_RESET 0x0080
206#define SIMPAD_DECT_POWER_ON 0x0100 206#define SIMPAD_DECT_POWER_ON 0x0100
207#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 207#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
208#define SIMPAD_RS232_ON 0x0400 208#define SIMPAD_RS232_ON 0x0400
209#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 209#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
210#define SIMPAD_LED2_ON 0x1000 210#define SIMPAD_LED2_ON 0x1000
211#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 211#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
212#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 212#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
213#define SIMPAD_RESET_SIMCARD 0x8000 213#define SIMPAD_RESET_SIMCARD 0x8000
214 214
215//SIMpad touchscreen backlight strength control 215//SIMpad touchscreen backlight strength control
216#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 216#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
217#define SIMPAD_BACKLIGHT_MASK 0x00a10044 217#define SIMPAD_BACKLIGHT_MASK 0x00a10044
218 218
219QValueList <OLed> SIMpad::ledList() const 219QValueList <OLed> SIMpad::ledList() const
220{ 220{
221 QValueList <OLed> vl; 221 QValueList <OLed> vl;
222 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 222 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
223 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 223 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
224 return vl; 224 return vl;
225} 225}
226 226
227QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 227QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
228{ 228{
229 QValueList <OLedState> vl; 229 QValueList <OLedState> vl;
230 230
231 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 231 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
232 vl << Led_Off << Led_On; 232 vl << Led_Off << Led_On;
233 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 233 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
234 //vl << Led_Off; 234 //vl << Led_Off;
235 return vl; 235 return vl;
236} 236}
237 237
238OLedState SIMpad::ledState ( OLed l ) const 238OLedState SIMpad::ledState ( OLed l ) const
239{ 239{
240 switch ( l ) { 240 switch ( l ) {
241 case Led_Power: 241 case Led_Power:
242 return m_leds [0]; 242 return m_leds [0];
243 //case Led_Mail: 243 //case Led_Mail:
244 //return m_leds [1]; 244 //return m_leds [1];
245 default: 245 default:
246 return Led_Off; 246 return Led_Off;
247 } 247 }
248} 248}
249 249
250bool SIMpad::setLedState ( OLed l, OLedState st ) 250bool SIMpad::setLedState ( OLed l, OLedState st )
251{ 251{
252#if 0 252#if 0
253 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 253 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
254 254
255 /*TODO Implement this like that: 255 /*TODO Implement this like that:
256 read from cs3 256 read from cs3
257 && with SIMPAD_LED2_ON 257 && with SIMPAD_LED2_ON
258 write to cs3 */ 258 write to cs3 */
259 m_leds [0] = st; 259 m_leds [0] = st;
260 return true; 260 return true;
261 } 261 }
262 } 262 }
263 } 263 }
264 264
265#endif 265#endif
266 return false; 266 return false;
267} 267}
268 268
269 269
270bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 270bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
271{ 271{
272 //TODO 272 //TODO
273 return false; 273 return false;
274} 274}
275 275
276void SIMpad::timerEvent ( QTimerEvent * ) 276void SIMpad::timerEvent ( QTimerEvent * )
277{ 277{
278 killTimer ( m_power_timer ); 278 killTimer ( m_power_timer );
279 m_power_timer = 0; 279 m_power_timer = 0;
280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
281 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 281 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
282} 282}
283 283
284 284
285void SIMpad::playAlarmSound() 285void SIMpad::playAlarmSound()
286{ 286{
287#ifndef QT_NO_SOUND 287#ifndef QT_NO_SOUND
288 static Sound snd ( "alarm" ); 288 static Sound snd ( "alarm" );
289 int fd; 289 int fd;
290 int vol; 290 int vol;
291 bool vol_reset = false; 291 bool vol_reset = false;
292 292
293 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 293 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
294 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 294 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
295 Config cfg ( "qpe" ); 295 Config cfg ( "qpe" );
296 cfg. setGroup ( "Volume" ); 296 cfg. setGroup ( "Volume" );
297 297
298 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 298 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
299 if ( volalarm < 0 ) 299 if ( volalarm < 0 )
300 volalarm = 0; 300 volalarm = 0;
301 else if ( volalarm > 100 ) 301 else if ( volalarm > 100 )
302 volalarm = 100; 302 volalarm = 100;
303 volalarm |= ( volalarm << 8 ); 303 volalarm |= ( volalarm << 8 );
304 304
305 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 305 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
306 vol_reset = true; 306 vol_reset = true;
307 } 307 }
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index 3d5acb5..0f4e66f 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,87 +1,87 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class SIMpad : public ODevice, public QWSServer::KeyboardFilter 42class SIMpad : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 protected: 44 protected:
45 virtual void init(); 45 virtual void init(const QString&);
46 virtual void initButtons(); 46 virtual void initButtons();
47 47
48 public: 48 public:
49 virtual bool setSoftSuspend( bool soft ); 49 virtual bool setSoftSuspend( bool soft );
50 virtual bool suspend(); 50 virtual bool suspend();
51 51
52 virtual bool setDisplayStatus( bool on ); 52 virtual bool setDisplayStatus( bool on );
53 virtual bool setDisplayBrightness( int b ); 53 virtual bool setDisplayBrightness( int b );
54 virtual int displayBrightnessResolution() const; 54 virtual int displayBrightnessResolution() const;
55 55
56 virtual void playAlarmSound(); 56 virtual void playAlarmSound();
57 57
58 virtual QValueList <OLed> ledList() const; 58 virtual QValueList <OLed> ledList() const;
59 virtual QValueList <OLedState> ledStateList( OLed led ) const; 59 virtual QValueList <OLedState> ledStateList( OLed led ) const;
60 virtual OLedState ledState( OLed led ) const; 60 virtual OLedState ledState( OLed led ) const;
61 virtual bool setLedState( OLed led, OLedState st ); 61 virtual bool setLedState( OLed led, OLedState st );
62 62
63 protected: 63 protected:
64 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 64 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
65 virtual void timerEvent( QTimerEvent *te ); 65 virtual void timerEvent( QTimerEvent *te );
66 66
67 int m_power_timer; 67 int m_power_timer;
68 68
69 OLedState m_leds [1]; 69 OLedState m_leds [1];
70}; 70};
71 71
72struct s_button { 72struct s_button {
73 uint model; 73 uint model;
74 Qt::Key code; 74 Qt::Key code;
75 char *utext; 75 char *utext;
76 char *pix; 76 char *pix;
77 char *fpressedservice; 77 char *fpressedservice;
78 char *fpressedaction; 78 char *fpressedaction;
79 char *fheldservice; 79 char *fheldservice;
80 char *fheldaction; 80 char *fheldaction;
81}; 81};
82 82
83} 83}
84} 84}
85} 85}
86 86
87#endif 87#endif
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index 4e9f227..493ed25 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -1,164 +1,164 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org> 3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6          .>+-= 6          .>+-=
7_;:,     .>    :=|. This program is free software; you can 7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License, 11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version. 12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_. 13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that 14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of 16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21:     =  ...= . :.=- 21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU 22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with 23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB. 24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_yopy.h" 30#include "odevice_yopy.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct yopy_button yopy_buttons [] = { 59struct yopy_button yopy_buttons [] = {
60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), 60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
61 "devicebuttons/yopy_action", 61 "devicebuttons/yopy_action",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), 64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
65 "devicebuttons/yopy_ok", 65 "devicebuttons/yopy_ok",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
69 "devicebuttons/yopy_end", 69 "devicebuttons/yopy_end",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72}; 72};
73 73
74void Yopy::init() 74void Yopy::init(const QString&)
75{ 75{
76 d->m_vendorstr = "G.Mate"; 76 d->m_vendorstr = "G.Mate";
77 d->m_vendor = Vendor_GMate; 77 d->m_vendor = Vendor_GMate;
78 d->m_modelstr = "Yopy3700"; 78 d->m_modelstr = "Yopy3700";
79 d->m_model = Model_Yopy_3700; 79 d->m_model = Model_Yopy_3700;
80 d->m_rotation = Rot0; 80 d->m_rotation = Rot0;
81 81
82 d->m_systemstr = "Linupy"; 82 d->m_systemstr = "Linupy";
83 d->m_system = System_Linupy; 83 d->m_system = System_Linupy;
84 84
85 QFile f ( "/etc/issue" ); 85 QFile f ( "/etc/issue" );
86 if ( f. open ( IO_ReadOnly ) ) 86 if ( f. open ( IO_ReadOnly ) )
87 { 87 {
88 QTextStream ts ( &f ); 88 QTextStream ts ( &f );
89 ts.readLine(); 89 ts.readLine();
90 d->m_sysverstr = ts. readLine(); 90 d->m_sysverstr = ts. readLine();
91 f. close(); 91 f. close();
92 } 92 }
93} 93}
94 94
95 95
96void Yopy::initButtons() 96void Yopy::initButtons()
97{ 97{
98 if ( d->m_buttons ) 98 if ( d->m_buttons )
99 return ; 99 return ;
100 100
101 d->m_buttons = new QValueList <ODeviceButton>; 101 d->m_buttons = new QValueList <ODeviceButton>;
102 102
103 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) 103 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
104 { 104 {
105 105
106 yopy_button *ib = yopy_buttons + i; 106 yopy_button *ib = yopy_buttons + i;
107 107
108 ODeviceButton b; 108 ODeviceButton b;
109 109
110 b. setKeycode ( ib->code ); 110 b. setKeycode ( ib->code );
111 b. setUserText ( QObject::tr ( "Button", ib->utext ) ); 111 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
112 b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); 112 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
113 b. setFactoryPresetPressedAction 113 b. setFactoryPresetPressedAction
114 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); 114 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
115 b. setFactoryPresetHeldAction 115 b. setFactoryPresetHeldAction
116 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); 116 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
117 117
118 d->m_buttons->append ( b ); 118 d->m_buttons->append ( b );
119 } 119 }
120 reloadButtonMapping(); 120 reloadButtonMapping();
121 121
122 QCopChannel *sysch = new QCopChannel( "QPE/System", this ); 122 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
123 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ), 123 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
124 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 124 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
125} 125}
126 126
127 127
128bool Yopy::suspend() 128bool Yopy::suspend()
129{ 129{
130 /* Opie for Yopy does not implement its own power management at the 130 /* Opie for Yopy does not implement its own power management at the
131 moment. The public version runs parallel to X, and relies on the 131 moment. The public version runs parallel to X, and relies on the
132 existing power management features. */ 132 existing power management features. */
133 return false; 133 return false;
134} 134}
135 135
136 136
137bool Yopy::setDisplayBrightness( int bright ) 137bool Yopy::setDisplayBrightness( int bright )
138{ 138{
139 /* The code here works, but is disabled as the current version runs 139 /* The code here works, but is disabled as the current version runs
140 parallel to X, and relies on the existing backlight demon. */ 140 parallel to X, and relies on the existing backlight demon. */
141#if 0 141#if 0
142 if ( QFile::exists( "/proc/sys/pm/light" ) ) 142 if ( QFile::exists( "/proc/sys/pm/light" ) )
143 { 143 {
144 int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); 144 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
145 if ( fd >= 0 ) 145 if ( fd >= 0 )
146 { 146 {
147 if ( bright ) 147 if ( bright )
148 ::write( fd, "1\n", 2 ); 148 ::write( fd, "1\n", 2 );
149 else 149 else
150 ::write( fd, "0\n", 2 ); 150 ::write( fd, "0\n", 2 );
151 ::close( fd ); 151 ::close( fd );
152 return true; 152 return true;
153 } 153 }
154 } 154 }
155#endif 155#endif
156 return false; 156 return false;
157} 157}
158 158
159 159
160int Yopy::displayBrightnessResolution() const 160int Yopy::displayBrightnessResolution() const
161{ 161{
162 return 2; 162 return 2;
163} 163}
164 164
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h
index 6e1db88..f6bf061 100644
--- a/libopie2/opiecore/device/odevice_yopy.h
+++ b/libopie2/opiecore/device/odevice_yopy.h
@@ -1,67 +1,67 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org> 3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6          .>+-= 6          .>+-=
7_;:,     .>    :=|. This program is free software; you can 7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License, 11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version. 12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_. 13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that 14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of 16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21:     =  ...= . :.=- 21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU 22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with 23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB. 24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_YOPY 30#ifndef ODEVICE_YOPY
31#define ODEVICE_YOPY 31#define ODEVICE_YOPY
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Yopy : public ODevice 38class Yopy : public ODevice
39{ 39{
40 protected: 40 protected:
41 41
42 virtual void init(); 42 virtual void init(const QString&);
43 virtual void initButtons(); 43 virtual void initButtons();
44 44
45 public: 45 public:
46 virtual bool suspend(); 46 virtual bool suspend();
47 47
48 virtual bool setDisplayBrightness ( int b ); 48 virtual bool setDisplayBrightness ( int b );
49 virtual int displayBrightnessResolution() const; 49 virtual int displayBrightnessResolution() const;
50}; 50};
51 51
52struct yopy_button 52struct yopy_button
53{ 53{
54 Qt::Key code; 54 Qt::Key code;
55 char *utext; 55 char *utext;
56 char *pix; 56 char *pix;
57 char *fpressedservice; 57 char *fpressedservice;
58 char *fpressedaction; 58 char *fpressedaction;
59 char *fheldservice; 59 char *fheldservice;
60 char *fheldaction; 60 char *fheldaction;
61}; 61};
62 62
63} 63}
64} 64}
65} 65}
66 66
67#endif 67#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 1434e69..e8b813e 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,310 +1,310 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
73 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
77 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
78 "opiemail", "raise()", 78 "opiemail", "raise()",
79 "opiemail", "newMail()" }, 79 "opiemail", "newMail()" },
80}; 80};
81 81
82struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
84 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
85 "datebook", "nextView()", 85 "datebook", "nextView()",
86 "today", "raise()" }, 86 "today", "raise()" },
87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
92 "devicebuttons/z_home", 92 "devicebuttons/z_home",
93 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
103}; 103};
104 104
105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
106// class up into individual classes. We need three classes 106// class up into individual classes. We need three classes
107// 107//
108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
111// 111//
112// Only question right now is: Do we really need to do it? Because as soon 112// Only question right now is: Do we really need to do it? Because as soon
113// as the OpenZaurus kernel is ready, there will be a unified interface for all 113// as the OpenZaurus kernel is ready, there will be a unified interface for all
114// Zaurus models (concerning apm, backlight, buttons, etc.) 114// Zaurus models (concerning apm, backlight, buttons, etc.)
115// 115//
116// Comments? - mickeyl. 116// Comments? - mickeyl.
117 117
118void Zaurus::init() 118void Zaurus::init(const QString&)
119{ 119{
120 d->m_vendorstr = "Sharp"; 120 d->m_vendorstr = "Sharp";
121 d->m_vendor = Vendor_Sharp; 121 d->m_vendor = Vendor_Sharp;
122 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 122 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
123 123
124 // QFile f ( "/proc/filesystems" ); 124 // QFile f ( "/proc/filesystems" );
125 QString model; 125 QString model;
126 126
127 // It isn't a good idea to check the system configuration to 127 // It isn't a good idea to check the system configuration to
128 // detect the distribution ! 128 // detect the distribution !
129 // Otherwise it may happen that any other distribution is detected as openzaurus, just 129 // Otherwise it may happen that any other distribution is detected as openzaurus, just
130 // because it uses a jffs2 filesystem.. 130 // because it uses a jffs2 filesystem..
131 // (eilers) 131 // (eilers)
132 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { 132 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
133 QFile f ("/etc/oz_version"); 133 QFile f ("/etc/oz_version");
134 if ( f.exists() ){ 134 if ( f.exists() ){
135 d->m_vendorstr = "OpenZaurus Team"; 135 d->m_vendorstr = "OpenZaurus Team";
136 d->m_systemstr = "OpenZaurus"; 136 d->m_systemstr = "OpenZaurus";
137 d->m_system = System_OpenZaurus; 137 d->m_system = System_OpenZaurus;
138 138
139 if ( f. open ( IO_ReadOnly )) { 139 if ( f. open ( IO_ReadOnly )) {
140 QTextStream ts ( &f ); 140 QTextStream ts ( &f );
141 d->m_sysverstr = ts. readLine();//. mid ( 10 ); 141 d->m_sysverstr = ts. readLine();//. mid ( 10 );
142 f. close(); 142 f. close();
143 } 143 }
144 144
145 // Openzaurus sometimes uses the embedix kernel! 145 // Openzaurus sometimes uses the embedix kernel!
146 // => Check whether this is an embedix kernel 146 // => Check whether this is an embedix kernel
147 FILE *uname = popen("uname -r", "r"); 147 FILE *uname = popen("uname -r", "r");
148 QString line; 148 QString line;
149 if ( f.open(IO_ReadOnly, uname) ) { 149 if ( f.open(IO_ReadOnly, uname) ) {
150 QTextStream ts ( &f ); 150 QTextStream ts ( &f );
151 line = ts. readLine(); 151 line = ts. readLine();
152 int loc = line. find ( "embedix" ); 152 int loc = line. find ( "embedix" );
153 if ( loc != -1 ) 153 if ( loc != -1 )
154 m_embedix = true; 154 m_embedix = true;
155 else 155 else
156 m_embedix = false; 156 m_embedix = false;
157 f. close(); 157 f. close();
158 } 158 }
159 pclose(uname); 159 pclose(uname);
160 } 160 }
161 else { 161 else {
162 d->m_systemstr = "Zaurus"; 162 d->m_systemstr = "Zaurus";
163 d->m_system = System_Zaurus; 163 d->m_system = System_Zaurus;
164 } 164 }
165 165
166 f. setName ( "/proc/cpuinfo" ); 166 f. setName ( "/proc/cpuinfo" );
167 if ( f. open ( IO_ReadOnly ) ) { 167 if ( f. open ( IO_ReadOnly ) ) {
168 QTextStream ts ( &f ); 168 QTextStream ts ( &f );
169 QString line; 169 QString line;
170 while( line = ts. readLine() ) { 170 while( line = ts. readLine() ) {
171 if ( line. left ( 8 ) == "Hardware" ) 171 if ( line. left ( 8 ) == "Hardware" )
172 break; 172 break;
173 } 173 }
174 int loc = line. find ( ":" ); 174 int loc = line. find ( ":" );
175 if ( loc != -1 ) 175 if ( loc != -1 )
176 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 176 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
177 } 177 }
178 178
179 if ( model == "SHARP Corgi" ) { 179 if ( model == "SHARP Corgi" ) {
180 d->m_model = Model_Zaurus_SLC7x0; 180 d->m_model = Model_Zaurus_SLC7x0;
181 d->m_modelstr = "Zaurus SL-C700"; 181 d->m_modelstr = "Zaurus SL-C700";
182 } else if ( model == "SHARP Shepherd" ) { 182 } else if ( model == "SHARP Shepherd" ) {
183 d->m_model = Model_Zaurus_SLC7x0; 183 d->m_model = Model_Zaurus_SLC7x0;
184 d->m_modelstr = "Zaurus SL-C750"; 184 d->m_modelstr = "Zaurus SL-C750";
185 } else if ( model == "SHARP Husky" ) { 185 } else if ( model == "SHARP Husky" ) {
186 d->m_model = Model_Zaurus_SLC7x0; 186 d->m_model = Model_Zaurus_SLC7x0;
187 d->m_modelstr = "Zaurus SL-C760"; 187 d->m_modelstr = "Zaurus SL-C760";
188 } else if ( model == "SHARP Poodle" ) { 188 } else if ( model == "SHARP Poodle" ) {
189 d->m_model = Model_Zaurus_SLB600; 189 d->m_model = Model_Zaurus_SLB600;
190 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 190 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
191 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 191 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
192 d->m_model = Model_Zaurus_SL5500; 192 d->m_model = Model_Zaurus_SL5500;
193 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 193 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
194 } else { 194 } else {
195 d->m_model = Model_Zaurus_SL5500; 195 d->m_model = Model_Zaurus_SL5500;
196 d->m_modelstr = "Zaurus (Model unknown)"; 196 d->m_modelstr = "Zaurus (Model unknown)";
197 } 197 }
198 198
199 bool flipstate = false; 199 bool flipstate = false;
200 switch ( d->m_model ) { 200 switch ( d->m_model ) {
201 case Model_Zaurus_SLA300: 201 case Model_Zaurus_SLA300:
202 d->m_rotation = Rot0; 202 d->m_rotation = Rot0;
203 break; 203 break;
204 case Model_Zaurus_SLC7x0: 204 case Model_Zaurus_SLC7x0:
205 d->m_rotation = rotation(); 205 d->m_rotation = rotation();
206 d->m_direction = direction(); 206 d->m_direction = direction();
207 break; 207 break;
208 case Model_Zaurus_SLB600: 208 case Model_Zaurus_SLB600:
209 case Model_Zaurus_SL5500: 209 case Model_Zaurus_SL5500:
210 case Model_Zaurus_SL5000: 210 case Model_Zaurus_SL5000:
211 default: 211 default:
212 d->m_rotation = Rot270; 212 d->m_rotation = Rot270;
213 break; 213 break;
214 } 214 }
215 m_leds [0] = Led_Off; 215 m_leds [0] = Led_Off;
216} 216}
217 217
218void Zaurus::initButtons() 218void Zaurus::initButtons()
219{ 219{
220 if ( d->m_buttons ) 220 if ( d->m_buttons )
221 return; 221 return;
222 222
223 d->m_buttons = new QValueList <ODeviceButton>; 223 d->m_buttons = new QValueList <ODeviceButton>;
224 224
225 struct z_button * pz_buttons; 225 struct z_button * pz_buttons;
226 int buttoncount; 226 int buttoncount;
227 switch ( d->m_model ) { 227 switch ( d->m_model ) {
228 case Model_Zaurus_SLC7x0: 228 case Model_Zaurus_SLC7x0:
229 pz_buttons = z_buttons_c700; 229 pz_buttons = z_buttons_c700;
230 buttoncount = ARRAY_SIZE(z_buttons_c700); 230 buttoncount = ARRAY_SIZE(z_buttons_c700);
231 break; 231 break;
232 default: 232 default:
233 pz_buttons = z_buttons; 233 pz_buttons = z_buttons;
234 buttoncount = ARRAY_SIZE(z_buttons); 234 buttoncount = ARRAY_SIZE(z_buttons);
235 break; 235 break;
236 } 236 }
237 237
238 for ( int i = 0; i < buttoncount; i++ ) { 238 for ( int i = 0; i < buttoncount; i++ ) {
239 struct z_button *zb = pz_buttons + i; 239 struct z_button *zb = pz_buttons + i;
240 ODeviceButton b; 240 ODeviceButton b;
241 241
242 b. setKeycode ( zb->code ); 242 b. setKeycode ( zb->code );
243 b. setUserText ( QObject::tr ( "Button", zb->utext )); 243 b. setUserText ( QObject::tr ( "Button", zb->utext ));
244 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 244 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
245 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 245 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
246 zb->fpressedaction )); 246 zb->fpressedaction ));
247 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 247 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
248 zb->fheldaction )); 248 zb->fheldaction ));
249 249
250 d->m_buttons->append ( b ); 250 d->m_buttons->append ( b );
251 } 251 }
252 252
253 reloadButtonMapping(); 253 reloadButtonMapping();
254 254
255 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 255 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
256 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), 256 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
257 this, SLOT( systemMessage(const QCString&,const QByteArray&))); 257 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
258} 258}
259 259
260#include <unistd.h> 260#include <unistd.h>
261#include <fcntl.h> 261#include <fcntl.h>
262#include <sys/ioctl.h> 262#include <sys/ioctl.h>
263 263
264//#include <asm/sharp_char.h> // including kernel headers is evil ... 264//#include <asm/sharp_char.h> // including kernel headers is evil ...
265 265
266#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 266#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
267 267
268 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 268 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
269#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 269#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
270 270
271#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 271#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
272#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 272#define SHARP_BUZ_KEYSOUND 2 /* key sound */
273#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 273#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
274 274
275/* --- for SHARP_BUZZER device --- */ 275/* --- for SHARP_BUZZER device --- */
276 276
277 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 277 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
278//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 278//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
279 279
280#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 280#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
281#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 281#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
282#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 282#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
283#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 283#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
284#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 284#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
285 285
286//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 286//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
287//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 287//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
288 288
289//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 289//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
290//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 290//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
291//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 291//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
292//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 292//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
293//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 293//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
294//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 294//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
295//#define SHARP_PDA_APPSTART 9 /* application start */ 295//#define SHARP_PDA_APPSTART 9 /* application start */
296//#define SHARP_PDA_APPQUIT 10 /* application ends */ 296//#define SHARP_PDA_APPQUIT 10 /* application ends */
297 297
298//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 298//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
299//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 299//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
300//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 300//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
301//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 301//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
302// 302//
303 303
304 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 304 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
305#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 305#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
306 306
307#define SHARP_IOCTL_GET_ROTATION 0x413c 307#define SHARP_IOCTL_GET_ROTATION 0x413c
308 308
309typedef struct sharp_led_status { 309typedef struct sharp_led_status {
310int which; /* select which LED status is wanted. */ 310int which; /* select which LED status is wanted. */
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index a0b1787..76a40d6 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,100 +1,100 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35#ifndef ARRAY_SIZE 35#ifndef ARRAY_SIZE
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37#endif 37#endif
38 38
39// _IO and friends are only defined in kernel headers ... 39// _IO and friends are only defined in kernel headers ...
40 40
41#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 41#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
42 42
43#define OD_IO(type,number) OD_IOC(0,type,number,0) 43#define OD_IO(type,number) OD_IOC(0,type,number,0)
44#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 44#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
45#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 45#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
46#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 46#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
47 47
48 48
49namespace Opie { 49namespace Opie {
50namespace Core { 50namespace Core {
51namespace Internal { 51namespace Internal {
52class Zaurus : public ODevice 52class Zaurus : public ODevice
53{ 53{
54 54
55 protected: 55 protected:
56 virtual void init(); 56 virtual void init(const QString&);
57 virtual void initButtons(); 57 virtual void initButtons();
58 58
59 public: 59 public:
60 virtual bool setSoftSuspend ( bool soft ); 60 virtual bool setSoftSuspend ( bool soft );
61 61
62 virtual bool setDisplayBrightness ( int b ); 62 virtual bool setDisplayBrightness ( int b );
63 virtual int displayBrightnessResolution() const; 63 virtual int displayBrightnessResolution() const;
64 64
65 virtual void playAlarmSound(); 65 virtual void playAlarmSound();
66 virtual void playKeySound(); 66 virtual void playKeySound();
67 virtual void playTouchSound(); 67 virtual void playTouchSound();
68 68
69 virtual QValueList <OLed> ledList() const; 69 virtual QValueList <OLed> ledList() const;
70 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 70 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
71 virtual OLedState ledState( OLed led ) const; 71 virtual OLedState ledState( OLed led ) const;
72 virtual bool setLedState( OLed led, OLedState st ); 72 virtual bool setLedState( OLed led, OLedState st );
73 73
74 virtual bool hasHingeSensor() const; 74 virtual bool hasHingeSensor() const;
75 virtual OHingeStatus readHingeSensor(); 75 virtual OHingeStatus readHingeSensor();
76 76
77 virtual bool suspend(); 77 virtual bool suspend();
78 virtual Transformation rotation() const; 78 virtual Transformation rotation() const;
79 virtual ODirection direction() const; 79 virtual ODirection direction() const;
80 80
81 protected: 81 protected:
82 virtual void buzzer ( int snd ); 82 virtual void buzzer ( int snd );
83 83
84 OLedState m_leds [1]; 84 OLedState m_leds [1];
85 bool m_embedix; 85 bool m_embedix;
86}; 86};
87 87
88struct z_button { 88struct z_button {
89 Qt::Key code; 89 Qt::Key code;
90 char *utext; 90 char *utext;
91 char *pix; 91 char *pix;
92 char *fpressedservice; 92 char *fpressedservice;
93 char *fpressedaction; 93 char *fpressedaction;
94 char *fheldservice; 94 char *fheldservice;
95 char *fheldaction; 95 char *fheldaction;
96}; 96};
97} 97}
98} 98}
99} 99}
100#endif 100#endif