summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp13
-rw-r--r--libopie2/opiecore/device/odevice.h1
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp4
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp4
6 files changed, 11 insertions, 17 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 8b64c41..67cae1c 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,852 +1,859 @@
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_beagle.h" 30#include "odevice_beagle.h"
31#include "odevice_ipaq.h" 31#include "odevice_ipaq.h"
32#include "odevice_jornada.h" 32#include "odevice_jornada.h"
33#include "odevice_ramses.h" 33#include "odevice_ramses.h"
34#include "odevice_simpad.h" 34#include "odevice_simpad.h"
35#include "odevice_yopy.h" 35#include "odevice_yopy.h"
36#include "odevice_zaurus.h" 36#include "odevice_zaurus.h"
37 37
38/* QT */ 38/* QT */
39#include <qapplication.h> 39#include <qapplication.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
43 43
44/* OPIE */ 44/* OPIE */
45#include <qpe/config.h> 45#include <qpe/config.h>
46#include <qpe/resource.h> 46#include <qpe/resource.h>
47#include <qpe/sound.h> 47#include <qpe/sound.h>
48#include <qpe/qcopenvelope_qws.h> 48#include <qpe/qcopenvelope_qws.h>
49#include <qpe/sound.h> 49#include <qpe/sound.h>
50#include <opie2/okeyfilter.h> 50#include <opie2/okeyfilter.h>
51 51
52/* STD */ 52/* STD */
53#include <fcntl.h> 53#include <fcntl.h>
54#include <math.h> 54#include <math.h>
55#include <stdlib.h> 55#include <stdlib.h>
56#include <signal.h> 56#include <signal.h>
57#include <sys/ioctl.h> 57#include <sys/ioctl.h>
58#include <sys/time.h> 58#include <sys/time.h>
59#include <unistd.h> 59#include <unistd.h>
60#ifndef QT_NO_SOUND 60#ifndef QT_NO_SOUND
61#include <linux/soundcard.h> 61#include <linux/soundcard.h>
62#endif 62#endif
63 63
64namespace Opie { 64namespace Opie {
65namespace Core { 65namespace Core {
66 66
67static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 67static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
68 68
69 69
70/* STATIC and common implementation */ 70/* STATIC and common implementation */
71/* EXPORT */ ODistribution distributions[] = { 71/* EXPORT */ ODistribution distributions[] = {
72 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 72 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
73 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 73 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
74 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 74 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
75 { System_Unknown, "Linux", "/etc/issue" }, 75 { System_Unknown, "Linux", "/etc/issue" },
76}; 76};
77 77
78 78
79/* EXPORT */ bool isQWS(){ 79/* EXPORT */ bool isQWS(){
80 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 80 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
81} 81}
82 82
83/* EXPORT */ QCString makeChannel ( const char *str ){ 83/* EXPORT */ QCString makeChannel ( const char *str ){
84 if ( str && !::strchr ( str, '/' )) 84 if ( str && !::strchr ( str, '/' ))
85 return QCString ( "QPE/Application/" ) + str; 85 return QCString ( "QPE/Application/" ) + str;
86 else 86 else
87 return str; 87 return str;
88} 88}
89 89
90 90
91 91
92/* Now the default implementation of ODevice */ 92/* Now the default implementation of ODevice */
93 93
94struct default_button default_buttons [] = { 94struct default_button default_buttons [] = {
95 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 95 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
96 "devicebuttons/z_calendar", 96 "devicebuttons/z_calendar",
97 "datebook", "nextView()", 97 "datebook", "nextView()",
98 "today", "raise()" }, 98 "today", "raise()" },
99 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 99 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
100 "devicebuttons/z_contact", 100 "devicebuttons/z_contact",
101 "addressbook", "raise()", 101 "addressbook", "raise()",
102 "addressbook", "beamBusinessCard()" }, 102 "addressbook", "beamBusinessCard()" },
103 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 103 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
104 "devicebuttons/z_home", 104 "devicebuttons/z_home",
105 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
106 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
107 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 107 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
108 "devicebuttons/z_menu", 108 "devicebuttons/z_menu",
109 "QPE/TaskBar", "toggleMenu()", 109 "QPE/TaskBar", "toggleMenu()",
110 "QPE/TaskBar", "toggleStartMenu()" }, 110 "QPE/TaskBar", "toggleStartMenu()" },
111 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 111 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
112 "devicebuttons/z_mail", 112 "devicebuttons/z_mail",
113 "opiemail", "raise()", 113 "opiemail", "raise()",
114 "opiemail", "newMail()" }, 114 "opiemail", "newMail()" },
115}; 115};
116 116
117ODevice *ODevice::inst() 117ODevice *ODevice::inst()
118{ 118{
119 static ODevice *dev = 0; 119 static ODevice *dev = 0;
120 120
121 // rewrite this to only use /proc/cpuinfo or so 121 // rewrite this to only use /proc/cpuinfo or so
122 QString cpu_info; 122 QString cpu_info;
123 123
124 if ( !dev ) 124 if ( !dev )
125 { 125 {
126 QFile f( PATH_PROC_CPUINFO ); 126 QFile f( PATH_PROC_CPUINFO );
127 if ( f.open( IO_ReadOnly ) ) 127 if ( f.open( IO_ReadOnly ) )
128 { 128 {
129 QTextStream s( &f ); 129 QTextStream s( &f );
130 while ( !s.atEnd() ) 130 while ( !s.atEnd() )
131 { 131 {
132 QString line; 132 QString line;
133 line = s.readLine(); 133 line = s.readLine();
134 if ( line.startsWith( "Hardware" ) ) 134 if ( line.startsWith( "Hardware" ) )
135 { 135 {
136 qDebug( "ODevice() - found '%s'", (const char*) line ); 136 qDebug( "ODevice() - found '%s'", (const char*) line );
137 cpu_info = line; 137 cpu_info = line;
138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
144 else qWarning( "ODevice() - unknown hardware - using default." ); 144 else qWarning( "ODevice() - unknown hardware - using default." );
145 break; 145 break;
146 } 146 }
147 } 147 }
148 } 148 }
149 else 149 else
150 { 150 {
151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
152 } 152 }
153 if ( !dev ) dev = new ODevice(); 153 if ( !dev ) dev = new ODevice();
154 dev->init(cpu_info); 154 dev->init(cpu_info);
155 } 155 }
156 return dev; 156 return dev;
157} 157}
158 158
159ODevice::ODevice() 159ODevice::ODevice()
160{ 160{
161 d = new ODeviceData; 161 d = new ODeviceData;
162 162
163 d->m_modelstr = "Unknown"; 163 d->m_modelstr = "Unknown";
164 d->m_model = Model_Unknown; 164 d->m_model = Model_Unknown;
165 d->m_vendorstr = "Unknown"; 165 d->m_vendorstr = "Unknown";
166 d->m_vendor = Vendor_Unknown; 166 d->m_vendor = Vendor_Unknown;
167 d->m_systemstr = "Unknown"; 167 d->m_systemstr = "Unknown";
168 d->m_system = System_Unknown; 168 d->m_system = System_Unknown;
169 d->m_sysverstr = "0.0"; 169 d->m_sysverstr = "0.0";
170 d->m_rotation = Rot0; 170 d->m_rotation = Rot0;
171 d->m_direction = CW; 171 d->m_direction = CW;
172 172
173 d->m_holdtime = 1000; // 1000ms 173 d->m_holdtime = 1000; // 1000ms
174 d->m_buttons = 0; 174 d->m_buttons = 0;
175 d->m_cpu_frequencies = new QStrList; 175 d->m_cpu_frequencies = new QStrList;
176 176
177 177
178 /* mixer */ 178 /* mixer */
179 d->m_sound = d->m_vol = d->m_mixer = -1; 179 d->m_sound = d->m_vol = d->m_mixer = -1;
180
181 /* System QCopChannel created */
182 d->m_initializedButtonQcop = false;
180 183
181 // New distribution detection code first checks for legacy distributions, 184 // New distribution detection code first checks for legacy distributions,
182 // identified by /etc/familiar-version or /etc/oz_version. 185 // identified by /etc/familiar-version or /etc/oz_version.
183 // Then check for OpenEmbedded and lastly, read /etc/issue 186 // Then check for OpenEmbedded and lastly, read /etc/issue
184 187
185 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 188 for ( unsigned int i = 0; i < sizeof distributions; ++i )
186 { 189 {
187 if ( QFile::exists( distributions[i].sysvfile ) ) 190 if ( QFile::exists( distributions[i].sysvfile ) )
188 { 191 {
189 d->m_systemstr = distributions[i].sysstr; 192 d->m_systemstr = distributions[i].sysstr;
190 d->m_system = distributions[i].system; 193 d->m_system = distributions[i].system;
191 d->m_sysverstr = "<Unknown>"; 194 d->m_sysverstr = "<Unknown>";
192 QFile f( distributions[i].sysvfile ); 195 QFile f( distributions[i].sysvfile );
193 if ( f.open( IO_ReadOnly ) ) 196 if ( f.open( IO_ReadOnly ) )
194 { 197 {
195 QTextStream ts( &f ); 198 QTextStream ts( &f );
196 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 199 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
197 } 200 }
198 break; 201 break;
199 } 202 }
200 } 203 }
201} 204}
202 205
203void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 206void ODevice::systemMessage( const QCString &msg, const QByteArray & )
204{ 207{
205 if ( msg == "deviceButtonMappingChanged()" ) { 208 if ( msg == "deviceButtonMappingChanged()" ) {
206 reloadButtonMapping(); 209 reloadButtonMapping();
207 } 210 }
208} 211}
209 212
210void ODevice::init(const QString&) 213void ODevice::init(const QString&)
211{ 214{
212} 215}
213 216
214/** 217/**
215* This method initialises the button mapping 218* This method initialises the button mapping
216*/ 219*/
217void ODevice::initButtons() 220void ODevice::initButtons()
218{ 221{
219 if ( d->m_buttons ) 222 if ( d->m_buttons )
220 return; 223 return;
221 224
222 qDebug ( "init Buttons" ); 225 qDebug ( "init Buttons" );
223 d->m_buttons = new QValueList <ODeviceButton>; 226 d->m_buttons = new QValueList <ODeviceButton>;
224 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 227 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
225 default_button *db = default_buttons + i; 228 default_button *db = default_buttons + i;
226 ODeviceButton b; 229 ODeviceButton b;
227 b. setKeycode ( db->code ); 230 b. setKeycode ( db->code );
228 b. setUserText ( QObject::tr ( "Button", db->utext )); 231 b. setUserText ( QObject::tr ( "Button", db->utext ));
229 b. setPixmap ( Resource::loadPixmap ( db->pix )); 232 b. setPixmap ( Resource::loadPixmap ( db->pix ));
230 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 233 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
231 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
232 d->m_buttons->append ( b ); 235 d->m_buttons->append ( b );
233 } 236 }
234 237
235 reloadButtonMapping(); 238 reloadButtonMapping();
236
237 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
238 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
239} 239}
240 240
241ODevice::~ODevice() 241ODevice::~ODevice()
242{ 242{
243// we leak m_devicebuttons and m_cpu_frequency 243// we leak m_devicebuttons and m_cpu_frequency
244// but it's a singleton and it is not so importantant 244// but it's a singleton and it is not so importantant
245// -zecke 245// -zecke
246 delete d; 246 delete d;
247} 247}
248 248
249bool ODevice::setSoftSuspend ( bool /*soft*/ ) 249bool ODevice::setSoftSuspend ( bool /*soft*/ )
250{ 250{
251 return false; 251 return false;
252} 252}
253 253
254//#include <linux/apm_bios.h> 254//#include <linux/apm_bios.h>
255 255
256#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 256#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
257 257
258/** 258/**
259* This method will try to suspend the device 259* This method will try to suspend the device
260* It only works if the user is the QWS Server and the apm application 260* It only works if the user is the QWS Server and the apm application
261* is installed. 261* is installed.
262* It tries to suspend and then waits some time cause some distributions 262* It tries to suspend and then waits some time cause some distributions
263* do have asynchronus apm implementations. 263* do have asynchronus apm implementations.
264* This method will either fail and return false or it'll suspend the 264* This method will either fail and return false or it'll suspend the
265* device and return once the device got woken up 265* device and return once the device got woken up
266* 266*
267* @return if the device got suspended 267* @return if the device got suspended
268*/ 268*/
269bool ODevice::suspend() 269bool ODevice::suspend()
270{ 270{
271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
272 return false; 272 return false;
273 273
274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
275 return false; 275 return false;
276 276
277 bool res = false; 277 bool res = false;
278 ODevice::sendSuspendmsg(); 278 ODevice::sendSuspendmsg();
279 279
280 struct timeval tvs, tvn; 280 struct timeval tvs, tvn;
281 ::gettimeofday ( &tvs, 0 ); 281 ::gettimeofday ( &tvs, 0 );
282 282
283 ::sync(); // flush fs caches 283 ::sync(); // flush fs caches
284 res = ( ::system ( "apm --suspend" ) == 0 ); 284 res = ( ::system ( "apm --suspend" ) == 0 );
285 285
286 // This is needed because the iPAQ apm implementation is asynchronous and we 286 // This is needed because the iPAQ apm implementation is asynchronous and we
287 // can not be sure when exactly the device is really suspended 287 // can not be sure when exactly the device is really suspended
288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
289 289
290 if ( res ) { 290 if ( res ) {
291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
292 ::usleep ( 200 * 1000 ); 292 ::usleep ( 200 * 1000 );
293 ::gettimeofday ( &tvn, 0 ); 293 ::gettimeofday ( &tvn, 0 );
294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
295 } 295 }
296 296
297 return res; 297 return res;
298} 298}
299 299
300//#include <linux/fb.h> better not rely on kernel headers in userspace ... 300//#include <linux/fb.h> better not rely on kernel headers in userspace ...
301 301
302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
303 303
304/* VESA Blanking Levels */ 304/* VESA Blanking Levels */
305#define VESA_NO_BLANKING 0 305#define VESA_NO_BLANKING 0
306#define VESA_VSYNC_SUSPEND 1 306#define VESA_VSYNC_SUSPEND 1
307#define VESA_HSYNC_SUSPEND 2 307#define VESA_HSYNC_SUSPEND 2
308#define VESA_POWERDOWN 3 308#define VESA_POWERDOWN 3
309 309
310/** 310/**
311* This sets the display on or off 311* This sets the display on or off
312*/ 312*/
313bool ODevice::setDisplayStatus ( bool on ) 313bool ODevice::setDisplayStatus ( bool on )
314{ 314{
315 qDebug("ODevice::setDisplayStatus(%d)", on); 315 qDebug("ODevice::setDisplayStatus(%d)", on);
316 316
317 if ( d->m_model == Model_Unknown ) 317 if ( d->m_model == Model_Unknown )
318 return false; 318 return false;
319 319
320 bool res = false; 320 bool res = false;
321 int fd; 321 int fd;
322 322
323#ifdef QT_QWS_DEVFS 323#ifdef QT_QWS_DEVFS
324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { 324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
325#else 325#else
326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
327#endif 327#endif
328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
329 ::close ( fd ); 329 ::close ( fd );
330 } 330 }
331 return res; 331 return res;
332} 332}
333 333
334/** 334/**
335* This sets the display brightness 335* This sets the display brightness
336* 336*
337* @param b The brightness to be set on a scale from 0 to 255 337* @param b The brightness to be set on a scale from 0 to 255
338* @return success or failure 338* @return success or failure
339*/ 339*/
340bool ODevice::setDisplayBrightness ( int b) 340bool ODevice::setDisplayBrightness ( int b)
341{ 341{
342 Q_UNUSED( b ) 342 Q_UNUSED( b )
343 return false; 343 return false;
344} 344}
345 345
346/** 346/**
347 * 347 *
348 * @return Returns the number of steppings on the brightness slider 348 * @return Returns the number of steppings on the brightness slider
349 * in the Light-'n-Power settings. Values smaller zero and bigger 349 * in the Light-'n-Power settings. Values smaller zero and bigger
350 * than 255 do not make sense. 350 * than 255 do not make sense.
351 * 351 *
352 * \sa QSlider::setLineStep 352 * \sa QSlider::setLineStep
353 * \sa QSlider::setPageStep 353 * \sa QSlider::setPageStep
354 */ 354 */
355int ODevice::displayBrightnessResolution() const 355int ODevice::displayBrightnessResolution() const
356{ 356{
357 return 16; 357 return 16;
358} 358}
359 359
360/** 360/**
361* This sets the display contrast 361* This sets the display contrast
362* @param p The contrast to be set on a scale from 0 to 255 362* @param p The contrast to be set on a scale from 0 to 255
363* @return success or failure 363* @return success or failure
364*/ 364*/
365bool ODevice::setDisplayContrast ( int p) 365bool ODevice::setDisplayContrast ( int p)
366{ 366{
367 Q_UNUSED( p ) 367 Q_UNUSED( p )
368 return false; 368 return false;
369} 369}
370 370
371/** 371/**
372* @return return the max value for the brightness settings slider 372* @return return the max value for the brightness settings slider
373* or 0 if the device doesn't support setting of a contrast 373* or 0 if the device doesn't support setting of a contrast
374*/ 374*/
375int ODevice::displayContrastResolution() const 375int ODevice::displayContrastResolution() const
376{ 376{
377 return 0; 377 return 0;
378} 378}
379 379
380/** 380/**
381* This returns the vendor as string 381* This returns the vendor as string
382* @return Vendor as QString 382* @return Vendor as QString
383*/ 383*/
384QString ODevice::vendorString() const 384QString ODevice::vendorString() const
385{ 385{
386 return d->m_vendorstr; 386 return d->m_vendorstr;
387} 387}
388 388
389/** 389/**
390* This returns the vendor as one of the values of OVendor 390* This returns the vendor as one of the values of OVendor
391* @return OVendor 391* @return OVendor
392*/ 392*/
393OVendor ODevice::vendor() const 393OVendor ODevice::vendor() const
394{ 394{
395 return d->m_vendor; 395 return d->m_vendor;
396} 396}
397 397
398/** 398/**
399* This returns the model as a string 399* This returns the model as a string
400* @return A string representing the model 400* @return A string representing the model
401*/ 401*/
402QString ODevice::modelString() const 402QString ODevice::modelString() const
403{ 403{
404 return d->m_modelstr; 404 return d->m_modelstr;
405} 405}
406 406
407/** 407/**
408* This does return the OModel used 408* This does return the OModel used
409*/ 409*/
410OModel ODevice::model() const 410OModel ODevice::model() const
411{ 411{
412 return d->m_model; 412 return d->m_model;
413} 413}
414 414
415/** 415/**
416* This does return the systen name 416* This does return the systen name
417*/ 417*/
418QString ODevice::systemString() const 418QString ODevice::systemString() const
419{ 419{
420 return d->m_systemstr; 420 return d->m_systemstr;
421} 421}
422 422
423/** 423/**
424* Return System as OSystem value 424* Return System as OSystem value
425*/ 425*/
426OSystem ODevice::system() const 426OSystem ODevice::system() const
427{ 427{
428 return d->m_system; 428 return d->m_system;
429} 429}
430 430
431/** 431/**
432* @return the version string of the base system 432* @return the version string of the base system
433*/ 433*/
434QString ODevice::systemVersionString() const 434QString ODevice::systemVersionString() const
435{ 435{
436 return d->m_sysverstr; 436 return d->m_sysverstr;
437} 437}
438 438
439/** 439/**
440* @return the current Transformation 440* @return the current Transformation
441*/ 441*/
442Transformation ODevice::rotation() const 442Transformation ODevice::rotation() const
443{ 443{
444 return d->m_rotation; 444 return d->m_rotation;
445} 445}
446 446
447/** 447/**
448* @return the current rotation direction 448* @return the current rotation direction
449*/ 449*/
450ODirection ODevice::direction() const 450ODirection ODevice::direction() const
451{ 451{
452 return d->m_direction; 452 return d->m_direction;
453} 453}
454 454
455/** 455/**
456* This plays an alarm sound 456* This plays an alarm sound
457*/ 457*/
458void ODevice::playAlarmSound() 458void ODevice::playAlarmSound()
459{ 459{
460#ifndef QT_NO_SOUND 460#ifndef QT_NO_SOUND
461 static Sound snd ( "alarm" ); 461 static Sound snd ( "alarm" );
462 462
463 if ( snd. isFinished()) 463 if ( snd. isFinished())
464 snd. play(); 464 snd. play();
465#endif 465#endif
466} 466}
467 467
468/** 468/**
469* This plays a key sound 469* This plays a key sound
470*/ 470*/
471void ODevice::playKeySound() 471void ODevice::playKeySound()
472{ 472{
473#ifndef QT_NO_SOUND 473#ifndef QT_NO_SOUND
474 static Sound snd ( "keysound" ); 474 static Sound snd ( "keysound" );
475 475
476 if ( snd. isFinished()) 476 if ( snd. isFinished())
477 snd. play(); 477 snd. play();
478#endif 478#endif
479} 479}
480 480
481/** 481/**
482* This plays a touch sound 482* This plays a touch sound
483*/ 483*/
484void ODevice::playTouchSound() 484void ODevice::playTouchSound()
485{ 485{
486#ifndef QT_NO_SOUND 486#ifndef QT_NO_SOUND
487 static Sound snd ( "touchsound" ); 487 static Sound snd ( "touchsound" );
488 488
489 if ( snd. isFinished()) 489 if ( snd. isFinished())
490 snd. play(); 490 snd. play();
491#endif 491#endif
492} 492}
493 493
494/** 494/**
495* This method will return a list of leds 495* This method will return a list of leds
496* available on this device 496* available on this device
497* @return a list of LEDs. 497* @return a list of LEDs.
498*/ 498*/
499QValueList <OLed> ODevice::ledList() const 499QValueList <OLed> ODevice::ledList() const
500{ 500{
501 return QValueList <OLed>(); 501 return QValueList <OLed>();
502} 502}
503 503
504/** 504/**
505* This does return the state of the LEDs 505* This does return the state of the LEDs
506*/ 506*/
507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
508{ 508{
509 return QValueList <OLedState>(); 509 return QValueList <OLedState>();
510} 510}
511 511
512/** 512/**
513* @return the state for a given OLed 513* @return the state for a given OLed
514*/ 514*/
515OLedState ODevice::ledState ( OLed /*which*/ ) const 515OLedState ODevice::ledState ( OLed /*which*/ ) const
516{ 516{
517 return Led_Off; 517 return Led_Off;
518} 518}
519 519
520/** 520/**
521* Set the state for a LED 521* Set the state for a LED
522* @param which Which OLed to use 522* @param which Which OLed to use
523* @param st The state to set 523* @param st The state to set
524* @return success or failure 524* @return success or failure
525*/ 525*/
526bool ODevice::setLedState ( OLed which, OLedState st ) 526bool ODevice::setLedState ( OLed which, OLedState st )
527{ 527{
528 Q_UNUSED( which ) 528 Q_UNUSED( which )
529 Q_UNUSED( st ) 529 Q_UNUSED( st )
530 return false; 530 return false;
531} 531}
532 532
533/** 533/**
534* @return if the device has a light sensor 534* @return if the device has a light sensor
535*/ 535*/
536bool ODevice::hasLightSensor() const 536bool ODevice::hasLightSensor() const
537{ 537{
538 return false; 538 return false;
539} 539}
540 540
541/** 541/**
542* @return a value from the light sensor 542* @return a value from the light sensor
543*/ 543*/
544int ODevice::readLightSensor() 544int ODevice::readLightSensor()
545{ 545{
546 return -1; 546 return -1;
547} 547}
548 548
549/** 549/**
550* @return the light sensor resolution 550* @return the light sensor resolution
551*/ 551*/
552int ODevice::lightSensorResolution() const 552int ODevice::lightSensorResolution() const
553{ 553{
554 return 0; 554 return 0;
555} 555}
556 556
557/** 557/**
558* @return if the device has a hinge sensor 558* @return if the device has a hinge sensor
559*/ 559*/
560bool ODevice::hasHingeSensor() const 560bool ODevice::hasHingeSensor() const
561{ 561{
562 return false; 562 return false;
563} 563}
564 564
565/** 565/**
566* @return a value from the hinge sensor 566* @return a value from the hinge sensor
567*/ 567*/
568OHingeStatus ODevice::readHingeSensor() 568OHingeStatus ODevice::readHingeSensor()
569{ 569{
570 return CASE_UNKNOWN; 570 return CASE_UNKNOWN;
571} 571}
572 572
573/** 573/**
574* @return a list with CPU frequencies supported by the hardware 574* @return a list with CPU frequencies supported by the hardware
575*/ 575*/
576const QStrList &ODevice::allowedCpuFrequencies() const 576const QStrList &ODevice::allowedCpuFrequencies() const
577{ 577{
578 return *d->m_cpu_frequencies; 578 return *d->m_cpu_frequencies;
579} 579}
580 580
581 581
582/** 582/**
583* Set desired CPU frequency 583* Set desired CPU frequency
584* 584*
585* @param index index into d->m_cpu_frequencies of the frequency to be set 585* @param index index into d->m_cpu_frequencies of the frequency to be set
586*/ 586*/
587bool ODevice::setCurrentCpuFrequency(uint index) 587bool ODevice::setCurrentCpuFrequency(uint index)
588{ 588{
589 if (index >= d->m_cpu_frequencies->count()) 589 if (index >= d->m_cpu_frequencies->count())
590 return false; 590 return false;
591 591
592 char *freq = d->m_cpu_frequencies->at(index); 592 char *freq = d->m_cpu_frequencies->at(index);
593 qWarning("set freq to %s", freq); 593 qWarning("set freq to %s", freq);
594 594
595 int fd; 595 int fd;
596 596
597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
598 char writeCommand[50]; 598 char writeCommand[50];
599 const int count = sprintf(writeCommand, "%s\n", freq); 599 const int count = sprintf(writeCommand, "%s\n", freq);
600 int res = (::write(fd, writeCommand, count) != -1); 600 int res = (::write(fd, writeCommand, count) != -1);
601 ::close(fd); 601 ::close(fd);
602 return res; 602 return res;
603 } 603 }
604 604
605 return false; 605 return false;
606} 606}
607 607
608 608
609/** 609/**
610* @return a list of hardware buttons 610* @return a list of hardware buttons
611*/ 611*/
612const QValueList <ODeviceButton> &ODevice::buttons() 612const QValueList <ODeviceButton> &ODevice::buttons()
613{ 613{
614 initButtons(); 614 initButtons();
615 615
616 return *d->m_buttons; 616 return *d->m_buttons;
617} 617}
618 618
619/** 619/**
620* @return The amount of time that would count as a hold 620* @return The amount of time that would count as a hold
621*/ 621*/
622uint ODevice::buttonHoldTime() const 622uint ODevice::buttonHoldTime() const
623{ 623{
624 return d->m_holdtime; 624 return d->m_holdtime;
625} 625}
626 626
627/** 627/**
628* This method return a ODeviceButton for a key code 628* This method return a ODeviceButton for a key code
629* or 0 if no special hardware button is available for the device 629* or 0 if no special hardware button is available for the device
630* 630*
631* @return The devicebutton or 0l 631* @return The devicebutton or 0l
632* @see ODeviceButton 632* @see ODeviceButton
633*/ 633*/
634const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 634const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
635{ 635{
636 initButtons(); 636 initButtons();
637 637
638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
639 if ( (*it). keycode() == code ) 639 if ( (*it). keycode() == code )
640 return &(*it); 640 return &(*it);
641 } 641 }
642 return 0; 642 return 0;
643} 643}
644 644
645void ODevice::reloadButtonMapping() 645void ODevice::reloadButtonMapping()
646{ 646{
647 initButtons(); 647 initButtons();
648
649 if(!d->m_initializedButtonQcop) {
650 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel");
651 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)),
652 this,SLOT(systemMessage(const QCString&,const QByteArray&)));
653 d->m_initializedButtonQcop = true;
654 }
648 655
649 Config cfg ( "ButtonSettings" ); 656 Config cfg ( "ButtonSettings" );
650 657
651 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 658 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
652 ODeviceButton &b = ( *d->m_buttons ) [i]; 659 ODeviceButton &b = ( *d->m_buttons ) [i];
653 QString group = "Button" + QString::number ( i ); 660 QString group = "Button" + QString::number ( i );
654 661
655 QCString pch, hch; 662 QCString pch, hch;
656 QCString pm, hm; 663 QCString pm, hm;
657 QByteArray pdata, hdata; 664 QByteArray pdata, hdata;
658 665
659 if ( cfg. hasGroup ( group )) { 666 if ( cfg. hasGroup ( group )) {
660 cfg. setGroup ( group ); 667 cfg. setGroup ( group );
661 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 668 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
662 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 669 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
663 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 670 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
664 671
665 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 672 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
666 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 673 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
667 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 674 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
668 } 675 }
669 676
670 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 677 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
671 678
672 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 679 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
673 } 680 }
674} 681}
675 682
676void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 683void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
677{ 684{
678 initButtons(); 685 initButtons();
679 686
680 QString mb_chan; 687 QString mb_chan;
681 688
682 if ( button >= (int) d->m_buttons->count()) 689 if ( button >= (int) d->m_buttons->count())
683 return; 690 return;
684 691
685 ODeviceButton &b = ( *d->m_buttons ) [button]; 692 ODeviceButton &b = ( *d->m_buttons ) [button];
686 b. setPressedAction ( action ); 693 b. setPressedAction ( action );
687 694
688 mb_chan=b. pressedAction(). channel(); 695 mb_chan=b. pressedAction(). channel();
689 696
690 Config buttonFile ( "ButtonSettings" ); 697 Config buttonFile ( "ButtonSettings" );
691 buttonFile. setGroup ( "Button" + QString::number ( button )); 698 buttonFile. setGroup ( "Button" + QString::number ( button ));
692 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 699 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
693 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 700 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
694 701
695// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 702// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
696 703
697 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 704 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
698} 705}
699 706
700void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 707void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
701{ 708{
702 initButtons(); 709 initButtons();
703 710
704 if ( button >= (int) d->m_buttons->count()) 711 if ( button >= (int) d->m_buttons->count())
705 return; 712 return;
706 713
707 ODeviceButton &b = ( *d->m_buttons ) [button]; 714 ODeviceButton &b = ( *d->m_buttons ) [button];
708 b. setHeldAction ( action ); 715 b. setHeldAction ( action );
709 716
710 Config buttonFile ( "ButtonSettings" ); 717 Config buttonFile ( "ButtonSettings" );
711 buttonFile. setGroup ( "Button" + QString::number ( button )); 718 buttonFile. setGroup ( "Button" + QString::number ( button ));
712 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 719 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
713 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 720 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
714 721
715// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 722// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
716 723
717 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 724 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
718} 725}
719 726
720/** 727/**
721 * @internal 728 * @internal
722 */ 729 */
723void ODevice::virtual_hook(int, void* ){ 730void ODevice::virtual_hook(int, void* ){
724 731
725} 732}
726 733
727/** 734/**
728 * \brief Send a QCOP Message before suspending 735 * \brief Send a QCOP Message before suspending
729 * 736 *
730 * Sends a QCOP message to channel QPE/System 737 * Sends a QCOP message to channel QPE/System
731 * with the message "aboutToSuspend()" if this 738 * with the message "aboutToSuspend()" if this
732 * is the windowing server. 739 * is the windowing server.
733 * 740 *
734 * Call this in your custom \sa suspend() Method 741 * Call this in your custom \sa suspend() Method
735 * before going to suspend. 742 * before going to suspend.
736 * 743 *
737 */ 744 */
738void ODevice::sendSuspendmsg() 745void ODevice::sendSuspendmsg()
739{ 746{
740 if ( isQWS() ) 747 if ( isQWS() )
741 return; 748 return;
742 749
743 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 750 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
744} 751}
745 752
746/** 753/**
747 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters 754 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
748 * 755 *
749 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard 756 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
750 * Filters. This function is the only way to prepend a KeyFilter. 757 * Filters. This function is the only way to prepend a KeyFilter.
751 * 758 *
752 * @param aFilter The KeyFilter to be prepended to the list of filters 759 * @param aFilter The KeyFilter to be prepended to the list of filters
753 * 760 *
754 * @see Opie::Core::OKeyFilter 761 * @see Opie::Core::OKeyFilter
755 * @see Opie::Core::OKeyFilter::inst() 762 * @see Opie::Core::OKeyFilter::inst()
756 */ 763 */
757void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 764void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
758{ 765{
759 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 766 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
760} 767}
761 768
762/** 769/**
763 * \brief Remove the QWSServer::KeyboardFilter in the param from the list 770 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
764 * 771 *
765 * Remove the QWSServer::KeyboardFilter \par aFilter from the List 772 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
766 * of Keyfilters. Call this when you delete the KeyFilter! 773 * of Keyfilters. Call this when you delete the KeyFilter!
767 * 774 *
768 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter 775 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
769 * @see Opie::Core::ODevice::addPreHandler 776 * @see Opie::Core::ODevice::addPreHandler
770 */ 777 */
771void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 778void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
772{ 779{
773 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 780 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
774} 781}
775 782
776 783
777/** 784/**
778 * @internal 785 * @internal
779 * 786 *
780 * @see changeMixerForAlarm 787 * @see changeMixerForAlarm
781 */ 788 */
782void ODevice::playingStopped() { 789void ODevice::playingStopped() {
783 if ( sender() ) 790 if ( sender() )
784 const_cast<QObject*>(sender())->disconnect( this ); 791 const_cast<QObject*>(sender())->disconnect( this );
785 792
786#ifndef QT_NO_SOUND 793#ifndef QT_NO_SOUND
787 if ( d->m_sound >= 0 ) { 794 if ( d->m_sound >= 0 ) {
788 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); 795 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
789 ::close ( d->m_sound ); 796 ::close ( d->m_sound );
790 } 797 }
791#endif 798#endif
792} 799}
793 800
794 801
795/** 802/**
796 * \brief Change the Volume for the Alarm and set it back after playing is finished 803 * \brief Change the Volume for the Alarm and set it back after playing is finished
797 * 804 *
798 * If you play an Alarm Sound you might want to change the Mixer to 805 * If you play an Alarm Sound you might want to change the Mixer to
799 * full volume and ignore the user setting. After it \sa Sound::isFinished 806 * full volume and ignore the user setting. After it \sa Sound::isFinished
800 * you would turn the volume back to the user preference. 807 * you would turn the volume back to the user preference.
801 * The problem is that we used to enter the event loop while waiting 808 * The problem is that we used to enter the event loop while waiting
802 * for the sound to be finished triggering all kind of reentrance 809 * for the sound to be finished triggering all kind of reentrance
803 * problems what a library shouldn't introduce. 810 * problems what a library shouldn't introduce.
804 * Instead of manually waiting for the sound to be finished use 811 * Instead of manually waiting for the sound to be finished use
805 * this Method and it will automatically restore the Mixer to 812 * this Method and it will automatically restore the Mixer to
806 * the user configuration after the sound finished playing. 813 * the user configuration after the sound finished playing.
807 * 814 *
808 * Note: The onwership of \param snd is not transfered and playing 815 * Note: The onwership of \param snd is not transfered and playing
809 * is not started in this method. If 'snd' gets deleted before 816 * is not started in this method. If 'snd' gets deleted before
810 * playing is finished the volume doesn't get set back to 817 * playing is finished the volume doesn't get set back to
811 * the user preference! 818 * the user preference!
812 * 819 *
813 * \code 820 * \code
814 * static Sound snd("alarm"); 821 * static Sound snd("alarm");
815 * if(!snd.isFinished()) 822 * if(!snd.isFinished())
816 * return; 823 * return;
817 * 824 *
818 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); 825 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd );
819 * snd.play() 826 * snd.play()
820 * \endcode 827 * \endcode
821 * 828 *
822 * 829 *
823 * 830 *
824 * @param mixer The mixer number/channel to use 831 * @param mixer The mixer number/channel to use
825 * @param file The file name. If you convert from QString use QFile::encodeName 832 * @param file The file name. If you convert from QString use QFile::encodeName
826 * @param snd The sound to wait for finishing 833 * @param snd The sound to wait for finishing
827 * 834 *
828 */ 835 */
829void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { 836void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
830#ifndef QT_NO_SOUND 837#ifndef QT_NO_SOUND
831 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { 838 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
832 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { 839 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
833 Config cfg ( "qpe" ); 840 Config cfg ( "qpe" );
834 cfg. setGroup ( "Volume" ); 841 cfg. setGroup ( "Volume" );
835 842
836 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 843 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
837 if ( volalarm < 0 ) 844 if ( volalarm < 0 )
838 volalarm = 0; 845 volalarm = 0;
839 else if ( volalarm > 100 ) 846 else if ( volalarm > 100 )
840 volalarm = 100; 847 volalarm = 100;
841 volalarm |= ( volalarm << 8 ); 848 volalarm |= ( volalarm << 8 );
842 849
843 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) 850 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
844 register_qpe_sound_finished(snd, this, SLOT(playingStopped())); 851 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
845 } 852 }
846 d->m_mixer = mixer; 853 d->m_mixer = mixer;
847 } 854 }
848#endif 855#endif
849} 856}
850 857
851} 858}
852} 859}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 6f0d036..21fcc3f 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -104,271 +104,272 @@ enum OModel {
104 104
105 Model_Beagle = ( 6 << 24 ), 105 Model_Beagle = ( 6 << 24 ),
106 106
107 Model_Beagle_All = ( Model_Beagle | 0xffffff ), 107 Model_Beagle_All = ( Model_Beagle | 0xffffff ),
108 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), 108 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ),
109 109
110}; 110};
111 111
112/** 112/**
113 * The vendor of the device 113 * The vendor of the device
114 */ 114 */
115enum OVendor { 115enum OVendor {
116 Vendor_Unknown, 116 Vendor_Unknown,
117 117
118 Vendor_HP, 118 Vendor_HP,
119 Vendor_Sharp, 119 Vendor_Sharp,
120 Vendor_SIEMENS, 120 Vendor_SIEMENS,
121 Vendor_MundN, 121 Vendor_MundN,
122 Vendor_GMate, 122 Vendor_GMate,
123 Vendor_MasterIA, 123 Vendor_MasterIA,
124}; 124};
125 125
126/** 126/**
127 * The System used 127 * The System used
128 */ 128 */
129enum OSystem { 129enum OSystem {
130 System_Unknown, 130 System_Unknown,
131 131
132 System_Familiar, 132 System_Familiar,
133 System_Zaurus, 133 System_Zaurus,
134 System_OpenZaurus, 134 System_OpenZaurus,
135 System_Linupy, 135 System_Linupy,
136 System_OpenEmbedded, 136 System_OpenEmbedded,
137}; 137};
138 138
139typedef struct { 139typedef struct {
140 OSystem system; 140 OSystem system;
141 char* sysstr; 141 char* sysstr;
142 char* sysvfile; 142 char* sysvfile;
143} ODistribution; 143} ODistribution;
144 144
145extern ODistribution distributions[]; 145extern ODistribution distributions[];
146 146
147 147
148enum OLedState { 148enum OLedState {
149 Led_Off, 149 Led_Off,
150 Led_On, 150 Led_On,
151 Led_BlinkSlow, 151 Led_BlinkSlow,
152 Led_BlinkFast 152 Led_BlinkFast
153}; 153};
154 154
155enum OLed { 155enum OLed {
156 Led_Mail, 156 Led_Mail,
157 Led_Power, 157 Led_Power,
158 Led_BlueTooth 158 Led_BlueTooth
159}; 159};
160 160
161enum OHardKey { 161enum OHardKey {
162 HardKey_Datebook = Qt::Key_F9, 162 HardKey_Datebook = Qt::Key_F9,
163 HardKey_Contacts = Qt::Key_F10, 163 HardKey_Contacts = Qt::Key_F10,
164 HardKey_Menu = Qt::Key_F11, 164 HardKey_Menu = Qt::Key_F11,
165 HardKey_Home = Qt::Key_F12, 165 HardKey_Home = Qt::Key_F12,
166 HardKey_Mail = Qt::Key_F13, 166 HardKey_Mail = Qt::Key_F13,
167 HardKey_Record = Qt::Key_F24, 167 HardKey_Record = Qt::Key_F24,
168 HardKey_Suspend = Qt::Key_F34, 168 HardKey_Suspend = Qt::Key_F34,
169 HardKey_Backlight = Qt::Key_F35, 169 HardKey_Backlight = Qt::Key_F35,
170 HardKey_Action = Qt::Key_F10, 170 HardKey_Action = Qt::Key_F10,
171 HardKey_OK = Qt::Key_F11, 171 HardKey_OK = Qt::Key_F11,
172 HardKey_End = Qt::Key_F12, 172 HardKey_End = Qt::Key_F12,
173}; 173};
174 174
175enum ODirection { 175enum ODirection {
176 CW = 0, 176 CW = 0,
177 CCW = 1, 177 CCW = 1,
178 Flip = 2, 178 Flip = 2,
179}; 179};
180 180
181enum OHingeStatus { 181enum OHingeStatus {
182 CASE_CLOSED = 3, 182 CASE_CLOSED = 3,
183 CASE_PORTRAIT = 2, 183 CASE_PORTRAIT = 2,
184 CASE_LANDSCAPE = 0, 184 CASE_LANDSCAPE = 0,
185 CASE_UNKNOWN = 1, 185 CASE_UNKNOWN = 1,
186}; 186};
187 187
188/* default button for qvfb or such 188/* default button for qvfb or such
189 * see odevice.cpp for details. 189 * see odevice.cpp for details.
190 * hint: manage a user defined button for qvfb? 190 * hint: manage a user defined button for qvfb?
191 * alwin 191 * alwin
192 */ 192 */
193struct default_button { 193struct default_button {
194 Qt::Key code; 194 Qt::Key code;
195 char *utext; 195 char *utext;
196 char *pix; 196 char *pix;
197 char *fpressedservice; 197 char *fpressedservice;
198 char *fpressedaction; 198 char *fpressedaction;
199 char *fheldservice; 199 char *fheldservice;
200 char *fheldaction; 200 char *fheldaction;
201}; 201};
202 202
203/** 203/**
204 * A singleton which gives informations about device specefic option 204 * A singleton which gives informations about device specefic option
205 * like the Hardware used, LEDs, the Base Distribution and 205 * like the Hardware used, LEDs, the Base Distribution and
206 * hardware key mappings. 206 * hardware key mappings.
207 * 207 *
208 * @short A small class for device specefic options 208 * @short A small class for device specefic options
209 * @see QObject 209 * @see QObject
210 * @author Robert Griebl 210 * @author Robert Griebl
211 * @version 1.0 211 * @version 1.0
212 */ 212 */
213class ODevice : public QObject 213class ODevice : public QObject
214{ 214{
215 Q_OBJECT 215 Q_OBJECT
216 216
217private: 217private:
218 /* disable copy */ 218 /* disable copy */
219 ODevice ( const ODevice & ); 219 ODevice ( const ODevice & );
220 220
221protected: 221protected:
222 ODevice(); 222 ODevice();
223 virtual void init(const QString&); 223 virtual void init(const QString&);
224 virtual void initButtons(); 224 virtual void initButtons();
225 static void sendSuspendmsg(); 225 static void sendSuspendmsg();
226 226
227 ODeviceData *d; 227 ODeviceData *d;
228 228
229public: 229public:
230 // sandman do we want to allow destructions? -zecke? 230 // sandman do we want to allow destructions? -zecke?
231 virtual ~ODevice(); 231 virtual ~ODevice();
232 232
233 static ODevice *inst(); 233 static ODevice *inst();
234 234
235 // information 235 // information
236 236
237 QString modelString() const; 237 QString modelString() const;
238 OModel model() const; 238 OModel model() const;
239 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 239 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
240 240
241 QString vendorString() const; 241 QString vendorString() const;
242 OVendor vendor() const; 242 OVendor vendor() const;
243 243
244 QString systemString() const; 244 QString systemString() const;
245 OSystem system() const; 245 OSystem system() const;
246 246
247 QString systemVersionString() const; 247 QString systemVersionString() const;
248 248
249 virtual Transformation rotation() const; 249 virtual Transformation rotation() const;
250 virtual ODirection direction() const; 250 virtual ODirection direction() const;
251 251
252 // system 252 // system
253 253
254 virtual bool setSoftSuspend ( bool on ); 254 virtual bool setSoftSuspend ( bool on );
255 virtual bool suspend(); 255 virtual bool suspend();
256 256
257 virtual bool setDisplayStatus ( bool on ); 257 virtual bool setDisplayStatus ( bool on );
258 virtual bool setDisplayBrightness ( int brightness ); 258 virtual bool setDisplayBrightness ( int brightness );
259 virtual int displayBrightnessResolution() const; 259 virtual int displayBrightnessResolution() const;
260 virtual bool setDisplayContrast ( int contrast ); 260 virtual bool setDisplayContrast ( int contrast );
261 virtual int displayContrastResolution() const; 261 virtual int displayContrastResolution() const;
262 262
263 // don't add new virtual methods, use this: 263 // don't add new virtual methods, use this:
264 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 264 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
265 // and in your subclass do overwrite 265 // and in your subclass do overwrite
266 // protected virtual int virtual_hook(int, void *) 266 // protected virtual int virtual_hook(int, void *)
267 // which is defined below 267 // which is defined below
268 268
269 // input / output 269 // input / output
270 virtual void playAlarmSound(); 270 virtual void playAlarmSound();
271 virtual void playKeySound(); 271 virtual void playKeySound();
272 virtual void playTouchSound(); 272 virtual void playTouchSound();
273 273
274 virtual QValueList <OLed> ledList() const; 274 virtual QValueList <OLed> ledList() const;
275 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 275 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
276 virtual OLedState ledState ( OLed led ) const; 276 virtual OLedState ledState ( OLed led ) const;
277 virtual bool setLedState ( OLed led, OLedState st ); 277 virtual bool setLedState ( OLed led, OLedState st );
278 278
279 virtual bool hasLightSensor() const; 279 virtual bool hasLightSensor() const;
280 virtual int readLightSensor(); 280 virtual int readLightSensor();
281 virtual int lightSensorResolution() const; 281 virtual int lightSensorResolution() const;
282 282
283 virtual bool hasHingeSensor() const; 283 virtual bool hasHingeSensor() const;
284 virtual OHingeStatus readHingeSensor(); 284 virtual OHingeStatus readHingeSensor();
285 285
286 const QStrList &allowedCpuFrequencies() const; 286 const QStrList &allowedCpuFrequencies() const;
287 bool setCurrentCpuFrequency(uint index); 287 bool setCurrentCpuFrequency(uint index);
288 288
289 /** 289 /**
290 * Returns the available buttons on this device. The number and location 290 * Returns the available buttons on this device. The number and location
291 * of buttons will vary depending on the device. Button numbers will be assigned 291 * of buttons will vary depending on the device. Button numbers will be assigned
292 * by the device manufacturer and will be from most preferred button to least preffered 292 * by the device manufacturer and will be from most preferred button to least preffered
293 * button. Note that this list only contains "user mappable" buttons. 293 * button. Note that this list only contains "user mappable" buttons.
294 * 294 *
295 * @todo Make method const and take care of calling initButtons or make that const too 295 * @todo Make method const and take care of calling initButtons or make that const too
296 * 296 *
297 */ 297 */
298 const QValueList<ODeviceButton> &buttons(); 298 const QValueList<ODeviceButton> &buttons();
299 299
300 /** 300 /**
301 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 301 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
302 * returns 0L 302 * returns 0L
303 */ 303 */
304 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 304 const ODeviceButton *buttonForKeycode ( ushort keyCode );
305 305
306 /** 306 /**
307 * Reassigns the pressed action for \a button. To return to the factory 307 * Reassigns the pressed action for \a button. To return to the factory
308 * default pass an empty string as \a qcopMessage. 308 * default pass an empty string as \a qcopMessage.
309 */ 309 */
310 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 310 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
311 311
312 /** 312 /**
313 * Reassigns the held action for \a button. To return to the factory 313 * Reassigns the held action for \a button. To return to the factory
314 * default pass an empty string as \a qcopMessage. 314 * default pass an empty string as \a qcopMessage.
315 */ 315 */
316 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 316 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
317 317
318 /** 318 /**
319 * How long (in ms) you have to press a button for a "hold" action 319 * How long (in ms) you have to press a button for a "hold" action
320 */ 320 */
321 uint buttonHoldTime() const; 321 uint buttonHoldTime() const;
322 322
323signals: 323signals:
324 void buttonMappingChanged(); 324 void buttonMappingChanged();
325 325
326private slots: 326private slots:
327 void systemMessage ( const QCString &, const QByteArray & ); 327 void systemMessage ( const QCString &, const QByteArray & );
328 void playingStopped(); 328 void playingStopped();
329 329
330protected: 330protected:
331 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 331 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
332 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 332 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
333 void reloadButtonMapping(); 333 void reloadButtonMapping();
334 void changeMixerForAlarm( int mixer, const char* file, Sound *snd); 334 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
335 335
336 /* ugly virtual hook */ 336 /* ugly virtual hook */
337 virtual void virtual_hook( int id, void* data ); 337 virtual void virtual_hook( int id, void* data );
338}; 338};
339 339
340class ODeviceData { 340class ODeviceData {
341 341
342 public: 342 public:
343 QString m_vendorstr; 343 QString m_vendorstr;
344 OVendor m_vendor; 344 OVendor m_vendor;
345 345
346 QString m_modelstr; 346 QString m_modelstr;
347 OModel m_model; 347 OModel m_model;
348 348
349 QString m_systemstr; 349 QString m_systemstr;
350 OSystem m_system; 350 OSystem m_system;
351 351
352 QString m_sysverstr; 352 QString m_sysverstr;
353 353
354 Transformation m_rotation; 354 Transformation m_rotation;
355 ODirection m_direction; 355 ODirection m_direction;
356 356
357 QValueList <ODeviceButton> *m_buttons; 357 QValueList <ODeviceButton> *m_buttons;
358 uint m_holdtime; 358 uint m_holdtime;
359 QStrList *m_cpu_frequencies; 359 QStrList *m_cpu_frequencies;
360 boolm_initializedButtonQcop : 1;
360 361
361 /* values for changeMixerForAlarm */ 362 /* values for changeMixerForAlarm */
362 int m_sound, m_vol, m_mixer; 363 int m_sound, m_vol, m_mixer;
363}; 364};
364 365
365extern bool isQWS(); 366extern bool isQWS();
366extern QCString makeChannel ( const char *str ); 367extern QCString makeChannel ( const char *str );
367} 368}
368} 369}
369 370
370 371
371 372
372 373
373#endif 374#endif
374 375
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 6193ddc..9e01a0c 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,435 +1,432 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002,2003,2004 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#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57 57
58using namespace Opie::Core; 58using namespace Opie::Core;
59using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
60 60
61/* KERNEL */ 61/* KERNEL */
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63 63
64#define OD_IO(type,number) OD_IOC(0,type,number,0) 64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68 68
69typedef struct { 69typedef struct {
70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
71 unsigned char TotalTime; /* Units of 5 seconds */ 71 unsigned char TotalTime; /* Units of 5 seconds */
72 unsigned char OnTime; /* units of 100m/s */ 72 unsigned char OnTime; /* units of 100m/s */
73 unsigned char OffTime; /* units of 100m/s */ 73 unsigned char OffTime; /* units of 100m/s */
74} LED_IN; 74} LED_IN;
75 75
76typedef struct { 76typedef struct {
77 unsigned char mode; 77 unsigned char mode;
78 unsigned char pwr; 78 unsigned char pwr;
79 unsigned char brightness; 79 unsigned char brightness;
80} FLITE_IN; 80} FLITE_IN;
81 81
82#define LED_ON OD_IOW( 'f', 5, LED_IN ) 82#define LED_ON OD_IOW( 'f', 5, LED_IN )
83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
84 84
85struct i_button ipaq_buttons [] = { 85struct i_button ipaq_buttons [] = {
86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
87 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 87 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
88 "devicebuttons/ipaq_calendar", 88 "devicebuttons/ipaq_calendar",
89 "datebook", "nextView()", 89 "datebook", "nextView()",
90 "today", "raise()" }, 90 "today", "raise()" },
91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
92 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 92 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
93 "devicebuttons/ipaq_contact", 93 "devicebuttons/ipaq_contact",
94 "addressbook", "raise()", 94 "addressbook", "raise()",
95 "addressbook", "beamBusinessCard()" }, 95 "addressbook", "beamBusinessCard()" },
96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
98 "devicebuttons/ipaq_menu", 98 "devicebuttons/ipaq_menu",
99 "QPE/TaskBar", "toggleMenu()", 99 "QPE/TaskBar", "toggleMenu()",
100 "QPE/TaskBar", "toggleStartMenu()" }, 100 "QPE/TaskBar", "toggleStartMenu()" },
101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
103 "devicebuttons/ipaq_mail", 103 "devicebuttons/ipaq_mail",
104 "opiemail", "raise()", 104 "opiemail", "raise()",
105 "opiemail", "newMail()" }, 105 "opiemail", "newMail()" },
106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
108 "devicebuttons/ipaq_home", 108 "devicebuttons/ipaq_home",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
113 "devicebuttons/ipaq_record", 113 "devicebuttons/ipaq_record",
114 "QPE/VMemo", "toggleRecord()", 114 "QPE/VMemo", "toggleRecord()",
115 "sound", "raise()" }, 115 "sound", "raise()" },
116}; 116};
117 117
118void iPAQ::init(const QString& model) 118void iPAQ::init(const QString& model)
119{ 119{
120 d->m_vendorstr = "HP"; 120 d->m_vendorstr = "HP";
121 d->m_vendor = Vendor_HP; 121 d->m_vendor = Vendor_HP;
122 122
123 d->m_modelstr = model.mid(model.findRev('H')); 123 d->m_modelstr = model.mid(model.findRev('H'));
124 124
125 if ( d->m_modelstr == "H3100" ) 125 if ( d->m_modelstr == "H3100" )
126 d->m_model = Model_iPAQ_H31xx; 126 d->m_model = Model_iPAQ_H31xx;
127 else if ( d->m_modelstr == "H3600" ) 127 else if ( d->m_modelstr == "H3600" )
128 d->m_model = Model_iPAQ_H36xx; 128 d->m_model = Model_iPAQ_H36xx;
129 else if ( d->m_modelstr == "H3700" ) 129 else if ( d->m_modelstr == "H3700" )
130 d->m_model = Model_iPAQ_H37xx; 130 d->m_model = Model_iPAQ_H37xx;
131 else if ( d->m_modelstr == "H3800" ) 131 else if ( d->m_modelstr == "H3800" )
132 d->m_model = Model_iPAQ_H38xx; 132 d->m_model = Model_iPAQ_H38xx;
133 else if ( d->m_modelstr == "H3900" ) 133 else if ( d->m_modelstr == "H3900" )
134 d->m_model = Model_iPAQ_H39xx; 134 d->m_model = Model_iPAQ_H39xx;
135 else if ( d->m_modelstr == "H5400" ) 135 else if ( d->m_modelstr == "H5400" )
136 d->m_model = Model_iPAQ_H5xxx; 136 d->m_model = Model_iPAQ_H5xxx;
137 else if ( d->m_modelstr == "H2200" ) 137 else if ( d->m_modelstr == "H2200" )
138 d->m_model = Model_iPAQ_H22xx; 138 d->m_model = Model_iPAQ_H22xx;
139 else 139 else
140 d->m_model = Model_Unknown; 140 d->m_model = Model_Unknown;
141 141
142 switch ( d->m_model ) { 142 switch ( d->m_model ) {
143 case Model_iPAQ_H31xx: 143 case Model_iPAQ_H31xx:
144 case Model_iPAQ_H38xx: 144 case Model_iPAQ_H38xx:
145 d->m_rotation = Rot90; 145 d->m_rotation = Rot90;
146 break; 146 break;
147 case Model_iPAQ_H5xxx: 147 case Model_iPAQ_H5xxx:
148 case Model_iPAQ_H22xx: 148 case Model_iPAQ_H22xx:
149 d->m_rotation = Rot0; 149 d->m_rotation = Rot0;
150 break; 150 break;
151 case Model_iPAQ_H36xx: 151 case Model_iPAQ_H36xx:
152 case Model_iPAQ_H37xx: 152 case Model_iPAQ_H37xx:
153 case Model_iPAQ_H39xx: 153 case Model_iPAQ_H39xx:
154 default: 154 default:
155 d->m_rotation = Rot270; 155 d->m_rotation = Rot270;
156 break; 156 break;
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 iPAQ::initButtons() 166void iPAQ::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 addPreHandler(this); 172 addPreHandler(this);
173 } 173 }
174 174
175 d->m_buttons = new QValueList <ODeviceButton>; 175 d->m_buttons = new QValueList <ODeviceButton>;
176 176
177 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 177 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
178 i_button *ib = ipaq_buttons + i; 178 i_button *ib = ipaq_buttons + i;
179 ODeviceButton b; 179 ODeviceButton b;
180 180
181 if (( ib->model & d->m_model ) == d->m_model ) { 181 if (( ib->model & d->m_model ) == d->m_model ) {
182 b. setKeycode ( ib->code ); 182 b. setKeycode ( ib->code );
183 b. setUserText ( QObject::tr ( "Button", ib->utext )); 183 b. setUserText ( QObject::tr ( "Button", ib->utext ));
184 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 184 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
187 187
188 d->m_buttons->append ( b ); 188 d->m_buttons->append ( b );
189 } 189 }
190 } 190 }
191 reloadButtonMapping(); 191 reloadButtonMapping();
192
193 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
194 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
195} 192}
196 193
197QValueList <OLed> iPAQ::ledList() const 194QValueList <OLed> iPAQ::ledList() const
198{ 195{
199 QValueList <OLed> vl; 196 QValueList <OLed> vl;
200 vl << Led_Power; 197 vl << Led_Power;
201 198
202 if ( d->m_model == Model_iPAQ_H38xx ) 199 if ( d->m_model == Model_iPAQ_H38xx )
203 vl << Led_BlueTooth; 200 vl << Led_BlueTooth;
204 return vl; 201 return vl;
205} 202}
206 203
207QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 204QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
208{ 205{
209 QValueList <OLedState> vl; 206 QValueList <OLedState> vl;
210 207
211 if ( l == Led_Power ) 208 if ( l == Led_Power )
212 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 209 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
213 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 210 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
214 vl << Led_Off; // << Led_On << ??? 211 vl << Led_Off; // << Led_On << ???
215 212
216 return vl; 213 return vl;
217} 214}
218 215
219OLedState iPAQ::ledState ( OLed l ) const 216OLedState iPAQ::ledState ( OLed l ) const
220{ 217{
221 switch ( l ) { 218 switch ( l ) {
222 case Led_Power: 219 case Led_Power:
223 return m_leds [0]; 220 return m_leds [0];
224 case Led_BlueTooth: 221 case Led_BlueTooth:
225 return m_leds [1]; 222 return m_leds [1];
226 default: 223 default:
227 return Led_Off; 224 return Led_Off;
228 } 225 }
229} 226}
230 227
231bool iPAQ::setLedState ( OLed l, OLedState st ) 228bool iPAQ::setLedState ( OLed l, OLedState st )
232{ 229{
233 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 230 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
234 231
235 if ( l == Led_Power ) { 232 if ( l == Led_Power ) {
236 if ( fd >= 0 ) { 233 if ( fd >= 0 ) {
237 LED_IN leds; 234 LED_IN leds;
238 ::memset ( &leds, 0, sizeof( leds )); 235 ::memset ( &leds, 0, sizeof( leds ));
239 leds. TotalTime = 0; 236 leds. TotalTime = 0;
240 leds. OnTime = 0; 237 leds. OnTime = 0;
241 leds. OffTime = 1; 238 leds. OffTime = 1;
242 leds. OffOnBlink = 2; 239 leds. OffOnBlink = 2;
243 240
244 switch ( st ) { 241 switch ( st ) {
245 case Led_Off : leds. OffOnBlink = 0; break; 242 case Led_Off : leds. OffOnBlink = 0; break;
246 case Led_On : leds. OffOnBlink = 1; break; 243 case Led_On : leds. OffOnBlink = 1; break;
247 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 244 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
248 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 245 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
249 } 246 }
250 247
251 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 248 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
252 m_leds [0] = st; 249 m_leds [0] = st;
253 return true; 250 return true;
254 } 251 }
255 } 252 }
256 } 253 }
257 return false; 254 return false;
258} 255}
259 256
260 257
261bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 258bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
262{ 259{
263 int newkeycode = keycode; 260 int newkeycode = keycode;
264 261
265 switch ( keycode ) { 262 switch ( keycode ) {
266 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 263 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
267 case HardKey_Menu: { 264 case HardKey_Menu: {
268 if (( d->m_model == Model_iPAQ_H38xx ) || 265 if (( d->m_model == Model_iPAQ_H38xx ) ||
269 ( d->m_model == Model_iPAQ_H39xx ) || 266 ( d->m_model == Model_iPAQ_H39xx ) ||
270 ( d->m_model == Model_iPAQ_H5xxx)) { 267 ( d->m_model == Model_iPAQ_H5xxx)) {
271 newkeycode = HardKey_Mail; 268 newkeycode = HardKey_Mail;
272 } 269 }
273 break; 270 break;
274 } 271 }
275 272
276 // Rotate cursor keys 180 or 270 273 // Rotate cursor keys 180 or 270
277 case Key_Left : 274 case Key_Left :
278 case Key_Right: 275 case Key_Right:
279 case Key_Up : 276 case Key_Up :
280 case Key_Down : { 277 case Key_Down : {
281 if (( d->m_model == Model_iPAQ_H31xx ) || 278 if (( d->m_model == Model_iPAQ_H31xx ) ||
282 ( d->m_model == Model_iPAQ_H38xx )) { 279 ( d->m_model == Model_iPAQ_H38xx )) {
283 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 280 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
284 } 281 }
285 // Rotate the cursor keys by 270 282 // Rotate the cursor keys by 270
286 // keycode - Key_Left = position of the button starting from left clockwise 283 // keycode - Key_Left = position of the button starting from left clockwise
287 // add the rotation to it and modolo. No we've the original offset 284 // add the rotation to it and modolo. No we've the original offset
288 // add the offset to the Key_Left key 285 // add the offset to the Key_Left key
289 if ( d-> m_model == Model_iPAQ_H5xxx ) 286 if ( d-> m_model == Model_iPAQ_H5xxx )
290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 287 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
291 break; 288 break;
292 } 289 }
293 290
294 // map Power Button short/long press to F34/F35 291 // map Power Button short/long press to F34/F35
295 case Key_SysReq: { 292 case Key_SysReq: {
296 if ( isPress ) { 293 if ( isPress ) {
297 if ( m_power_timer ) 294 if ( m_power_timer )
298 killTimer ( m_power_timer ); 295 killTimer ( m_power_timer );
299 m_power_timer = startTimer ( 500 ); 296 m_power_timer = startTimer ( 500 );
300 } 297 }
301 else if ( m_power_timer ) { 298 else if ( m_power_timer ) {
302 killTimer ( m_power_timer ); 299 killTimer ( m_power_timer );
303 m_power_timer = 0; 300 m_power_timer = 0;
304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 301 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 302 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
306 } 303 }
307 newkeycode = Key_unknown; 304 newkeycode = Key_unknown;
308 break; 305 break;
309 } 306 }
310 } 307 }
311 308
312 if ( newkeycode != keycode ) { 309 if ( newkeycode != keycode ) {
313 if ( newkeycode != Key_unknown ) 310 if ( newkeycode != Key_unknown )
314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 311 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
315 return true; 312 return true;
316 } 313 }
317 else 314 else
318 return false; 315 return false;
319} 316}
320 317
321void iPAQ::timerEvent ( QTimerEvent * ) 318void iPAQ::timerEvent ( QTimerEvent * )
322{ 319{
323 killTimer ( m_power_timer ); 320 killTimer ( m_power_timer );
324 m_power_timer = 0; 321 m_power_timer = 0;
325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 322 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 323 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
327} 324}
328 325
329 326
330void iPAQ::playAlarmSound() 327void iPAQ::playAlarmSound()
331{ 328{
332#ifndef QT_NO_SOUND 329#ifndef QT_NO_SOUND
333 static Sound snd ( "alarm" ); 330 static Sound snd ( "alarm" );
334 if(!snd.isFinished()) 331 if(!snd.isFinished())
335 return; 332 return;
336 333
337 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 334 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
338 snd. play(); 335 snd. play();
339#endif 336#endif
340} 337}
341 338
342 339
343bool iPAQ::setSoftSuspend ( bool soft ) 340bool iPAQ::setSoftSuspend ( bool soft )
344{ 341{
345 bool res = false; 342 bool res = false;
346 int fd; 343 int fd;
347 344
348 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 345 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
349 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 346 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
350 res = true; 347 res = true;
351 else 348 else
352 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 349 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
353 350
354 ::close ( fd ); 351 ::close ( fd );
355 } 352 }
356 else 353 else
357 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 354 ::perror ( "/proc/sys/ts/suspend_button_mode" );
358 355
359 return res; 356 return res;
360} 357}
361 358
362 359
363bool iPAQ::setDisplayBrightness ( int bright ) 360bool iPAQ::setDisplayBrightness ( int bright )
364{ 361{
365 bool res = false; 362 bool res = false;
366 int fd; 363 int fd;
367 364
368 if ( bright > 255 ) 365 if ( bright > 255 )
369 bright = 255; 366 bright = 255;
370 if ( bright < 0 ) 367 if ( bright < 0 )
371 bright = 0; 368 bright = 0;
372 369
373 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 370 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
374 FLITE_IN bl; 371 FLITE_IN bl;
375 bl. mode = 1; 372 bl. mode = 1;
376 bl. pwr = bright ? 1 : 0; 373 bl. pwr = bright ? 1 : 0;
377 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 374 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
378 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 375 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
379 ::close ( fd ); 376 ::close ( fd );
380 } 377 }
381 return res; 378 return res;
382} 379}
383 380
384int iPAQ::displayBrightnessResolution() const 381int iPAQ::displayBrightnessResolution() const
385{ 382{
386 switch ( model()) { 383 switch ( model()) {
387 case Model_iPAQ_H31xx: 384 case Model_iPAQ_H31xx:
388 case Model_iPAQ_H36xx: 385 case Model_iPAQ_H36xx:
389 case Model_iPAQ_H37xx: 386 case Model_iPAQ_H37xx:
390 return 128; // really 256, but >128 could damage the LCD 387 return 128; // really 256, but >128 could damage the LCD
391 388
392 case Model_iPAQ_H38xx: 389 case Model_iPAQ_H38xx:
393 case Model_iPAQ_H39xx: 390 case Model_iPAQ_H39xx:
394 return 64; 391 return 64;
395 case Model_iPAQ_H5xxx: 392 case Model_iPAQ_H5xxx:
396 return 255; 393 return 255;
397 394
398 default: 395 default:
399 return 2; 396 return 2;
400 } 397 }
401} 398}
402 399
403 400
404bool iPAQ::hasLightSensor() const 401bool iPAQ::hasLightSensor() const
405{ 402{
406 return true; 403 return true;
407} 404}
408 405
409int iPAQ::readLightSensor() 406int iPAQ::readLightSensor()
410{ 407{
411 int fd; 408 int fd;
412 int val = -1; 409 int val = -1;
413 410
414 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 411 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
415 char buffer [8]; 412 char buffer [8];
416 413
417 if ( ::read ( fd, buffer, 5 ) == 5 ) { 414 if ( ::read ( fd, buffer, 5 ) == 5 ) {
418 char *endptr; 415 char *endptr;
419 416
420 buffer [4] = 0; 417 buffer [4] = 0;
421 val = ::strtol ( buffer + 2, &endptr, 16 ); 418 val = ::strtol ( buffer + 2, &endptr, 16 );
422 419
423 if ( *endptr != 0 ) 420 if ( *endptr != 0 )
424 val = -1; 421 val = -1;
425 } 422 }
426 ::close ( fd ); 423 ::close ( fd );
427 } 424 }
428 425
429 return val; 426 return val;
430} 427}
431 428
432int iPAQ::lightSensorResolution() const 429int iPAQ::lightSensorResolution() const
433{ 430{
434 return 256; 431 return 256;
435} 432}
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 2cab0c8..8141f1c 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -1,207 +1,204 @@
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; 80using namespace Opie::Core;
81using namespace Opie::Core::Internal; 81using namespace Opie::Core::Internal;
82 82
83struct j_button jornada56x_buttons [] = { 83struct j_button jornada56x_buttons [] = {
84 { Model_Jornada_56x, 84 { Model_Jornada_56x,
85 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 85 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
86 "devicebuttons/jornada56x_calendar", 86 "devicebuttons/jornada56x_calendar",
87 "datebook", "nextView()", 87 "datebook", "nextView()",
88 "today", "raise()" }, 88 "today", "raise()" },
89 { Model_Jornada_56x, 89 { Model_Jornada_56x,
90 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 90 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
91 "devicebuttons/jornada56x_contact", 91 "devicebuttons/jornada56x_contact",
92 "addressbook", "raise()", 92 "addressbook", "raise()",
93 "addressbook", "beamBusinessCard()" }, 93 "addressbook", "beamBusinessCard()" },
94 { Model_Jornada_56x, 94 { Model_Jornada_56x,
95 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), 95 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"),
96 "devicebuttons/jornada56x_todo", 96 "devicebuttons/jornada56x_todo",
97 "todolist", "raise()", 97 "todolist", "raise()",
98 "todolist", "create()" }, 98 "todolist", "create()" },
99 { Model_Jornada_56x, 99 { Model_Jornada_56x,
100 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), 100 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"),
101 "devicebuttons/jornada56x_home", 101 "devicebuttons/jornada56x_home",
102 "QPE/Launcher", "home()", 102 "QPE/Launcher", "home()",
103 "buttonsettings", "raise()" }, 103 "buttonsettings", "raise()" },
104 { Model_Jornada_56x, 104 { Model_Jornada_56x,
105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), 105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"),
106 "devicebuttons/jornada56x_record", 106 "devicebuttons/jornada56x_record",
107 "QPE/VMemo", "toggleRecord()", 107 "QPE/VMemo", "toggleRecord()",
108 "sound", "raise()" }, 108 "sound", "raise()" },
109}; 109};
110 110
111void Jornada::init(const QString&) 111void Jornada::init(const QString&)
112{ 112{
113 d->m_vendorstr = "HP"; 113 d->m_vendorstr = "HP";
114 d->m_vendor = Vendor_HP; 114 d->m_vendor = Vendor_HP;
115 d->m_modelstr = "Jornada 56x"; 115 d->m_modelstr = "Jornada 56x";
116 d->m_model = Model_Jornada_56x; 116 d->m_model = Model_Jornada_56x;
117 d->m_rotation = Rot0; 117 d->m_rotation = Rot0;
118 //Distribution detecting code is now in base class 118 //Distribution detecting code is now in base class
119} 119}
120 120
121void Jornada::initButtons() 121void Jornada::initButtons()
122{ 122{
123 if ( d->m_buttons ) 123 if ( d->m_buttons )
124 return; 124 return;
125 125
126 d->m_buttons = new QValueList <ODeviceButton>; 126 d->m_buttons = new QValueList <ODeviceButton>;
127 127
128 for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { 128 for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) {
129 j_button *ib = jornada56x_buttons + i; 129 j_button *ib = jornada56x_buttons + i;
130 ODeviceButton b; 130 ODeviceButton b;
131 131
132 if (( ib->model & d->m_model ) == d->m_model ) { 132 if (( ib->model & d->m_model ) == d->m_model ) {
133 b. setKeycode ( ib->code ); 133 b. setKeycode ( ib->code );
134 b. setUserText ( QObject::tr ( "Button", ib->utext )); 134 b. setUserText ( QObject::tr ( "Button", ib->utext ));
135 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 135 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
136 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 136 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
137 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 137 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
138 138
139 d->m_buttons->append ( b ); 139 d->m_buttons->append ( b );
140 } 140 }
141 } 141 }
142 reloadButtonMapping(); 142 reloadButtonMapping();
143
144 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
145 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
146} 143}
147 144
148int Jornada::displayBrightnessResolution() const 145int Jornada::displayBrightnessResolution() const
149{ 146{
150 return 255; 147 return 255;
151} 148}
152 149
153 150
154bool Jornada::setDisplayBrightness( int bright ) 151bool Jornada::setDisplayBrightness( int bright )
155{ 152{
156 bool res = false; 153 bool res = false;
157 154
158 if ( bright > 255 ) 155 if ( bright > 255 )
159 bright = 255; 156 bright = 255;
160 if ( bright < 0 ) 157 if ( bright < 0 )
161 bright = 0; 158 bright = 0;
162 159
163 QString cmdline; 160 QString cmdline;
164 161
165 if ( !bright ) 162 if ( !bright )
166 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); 163 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power");
167 else 164 else
168 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright ); 165 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright );
169 166
170 res = ( ::system( (const char*) cmdline ) == 0 ); 167 res = ( ::system( (const char*) cmdline ) == 0 );
171 168
172 return res; 169 return res;
173} 170}
174 171
175 172
176bool Jornada::suspend( ) 173bool Jornada::suspend( )
177{ 174{
178 qDebug("ODevice::suspend"); 175 qDebug("ODevice::suspend");
179 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 176 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
180 return false; 177 return false;
181 178
182 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 179 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
183 return false; 180 return false;
184 181
185 bool res = false; 182 bool res = false;
186 ODevice::sendSuspendmsg(); 183 ODevice::sendSuspendmsg();
187 184
188 struct timeval tvs; 185 struct timeval tvs;
189 ::gettimeofday ( &tvs, 0 ); 186 ::gettimeofday ( &tvs, 0 );
190 187
191 ::sync(); // flush fs caches 188 ::sync(); // flush fs caches
192 res = ( ::system ( "apm --suspend" ) == 0 ); 189 res = ( ::system ( "apm --suspend" ) == 0 );
193 190
194 return res; 191 return res;
195} 192}
196 193
197bool Jornada::setDisplayStatus ( bool on ) 194bool Jornada::setDisplayStatus ( bool on )
198{ 195{
199 bool res = false; 196 bool res = false;
200 197
201 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 198 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
202 199
203 res = ( ::system( (const char*) cmdline ) == 0 ); 200 res = ( ::system( (const char*) cmdline ) == 0 );
204 201
205 return res; 202 return res;
206} 203}
207 204
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index a06d7ec..8f22514 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -1,157 +1,153 @@
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(const QString&) 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 d->m_systemstr = "Linupy"; 81 d->m_systemstr = "Linupy";
82 d->m_system = System_Linupy; 82 d->m_system = System_Linupy;
83 // Distribution detection code now in the base class 83 // Distribution detection code now in the base class
84} 84}
85 85
86 86
87void Yopy::initButtons() 87void Yopy::initButtons()
88{ 88{
89 if ( d->m_buttons ) 89 if ( d->m_buttons )
90 return ; 90 return ;
91 91
92 d->m_buttons = new QValueList <ODeviceButton>; 92 d->m_buttons = new QValueList <ODeviceButton>;
93 93
94 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) 94 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
95 { 95 {
96 96
97 yopy_button *ib = yopy_buttons + i; 97 yopy_button *ib = yopy_buttons + i;
98 98
99 ODeviceButton b; 99 ODeviceButton b;
100 100
101 b. setKeycode ( ib->code ); 101 b. setKeycode ( ib->code );
102 b. setUserText ( QObject::tr ( "Button", ib->utext ) ); 102 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
103 b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); 103 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
104 b. setFactoryPresetPressedAction 104 b. setFactoryPresetPressedAction
105 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); 105 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
106 b. setFactoryPresetHeldAction 106 b. setFactoryPresetHeldAction
107 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); 107 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
108 108
109 d->m_buttons->append ( b ); 109 d->m_buttons->append ( b );
110 } 110 }
111 reloadButtonMapping(); 111 reloadButtonMapping();
112
113 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
114 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
115 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
116} 112}
117 113
118 114
119bool Yopy::suspend() 115bool Yopy::suspend()
120{ 116{
121 /* Opie for Yopy does not implement its own power management at the 117 /* Opie for Yopy does not implement its own power management at the
122 moment. The public version runs parallel to X, and relies on the 118 moment. The public version runs parallel to X, and relies on the
123 existing power management features. */ 119 existing power management features. */
124 return false; 120 return false;
125} 121}
126 122
127 123
128bool Yopy::setDisplayBrightness( int bright ) 124bool Yopy::setDisplayBrightness( int bright )
129{ 125{
130 /* The code here works, but is disabled as the current version runs 126 /* The code here works, but is disabled as the current version runs
131 parallel to X, and relies on the existing backlight demon. */ 127 parallel to X, and relies on the existing backlight demon. */
132#if 0 128#if 0
133 if ( QFile::exists( "/proc/sys/pm/light" ) ) 129 if ( QFile::exists( "/proc/sys/pm/light" ) )
134 { 130 {
135 int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); 131 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
136 if ( fd >= 0 ) 132 if ( fd >= 0 )
137 { 133 {
138 if ( bright ) 134 if ( bright )
139 ::write( fd, "1\n", 2 ); 135 ::write( fd, "1\n", 2 );
140 else 136 else
141 ::write( fd, "0\n", 2 ); 137 ::write( fd, "0\n", 2 );
142 ::close( fd ); 138 ::close( fd );
143 return true; 139 return true;
144 } 140 }
145 } 141 }
146#else 142#else
147 Q_UNUSED( bright ) 143 Q_UNUSED( bright )
148#endif 144#endif
149 return false; 145 return false;
150} 146}
151 147
152 148
153int Yopy::displayBrightnessResolution() const 149int Yopy::displayBrightnessResolution() const
154{ 150{
155 return 2; 151 return 2;
156} 152}
157 153
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 733479e..ebe1949 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,500 +1,496 @@
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(const QString& cpu_info) 118void Zaurus::init(const QString& cpu_info)
119{ 119{
120 // generic distribution code already scanned /etc/issue at that point - 120 // generic distribution code already scanned /etc/issue at that point -
121 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 121 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
122 if ( d->m_sysverstr.contains( "embedix", false ) ) 122 if ( d->m_sysverstr.contains( "embedix", false ) )
123 { 123 {
124 d->m_vendorstr = "Sharp"; 124 d->m_vendorstr = "Sharp";
125 d->m_vendor = Vendor_Sharp; 125 d->m_vendor = Vendor_Sharp;
126 d->m_systemstr = "Zaurus"; 126 d->m_systemstr = "Zaurus";
127 d->m_system = System_Zaurus; 127 d->m_system = System_Zaurus;
128 m_embedix = true; 128 m_embedix = true;
129 } 129 }
130 else 130 else
131 { 131 {
132 d->m_vendorstr = "OpenZaurus Team"; 132 d->m_vendorstr = "OpenZaurus Team";
133 d->m_systemstr = "OpenZaurus"; 133 d->m_systemstr = "OpenZaurus";
134 d->m_system = System_OpenZaurus; 134 d->m_system = System_OpenZaurus;
135 // sysver already gathered 135 // sysver already gathered
136 136
137 // Openzaurus sometimes uses the embedix kernel, check if this is one 137 // Openzaurus sometimes uses the embedix kernel, check if this is one
138 FILE *uname = popen("uname -r", "r"); 138 FILE *uname = popen("uname -r", "r");
139 QFile f; 139 QFile f;
140 QString line; 140 QString line;
141 if ( f.open(IO_ReadOnly, uname) ) { 141 if ( f.open(IO_ReadOnly, uname) ) {
142 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
143 line = ts. readLine(); 143 line = ts. readLine();
144 int loc = line. find ( "embedix" ); 144 int loc = line. find ( "embedix" );
145 if ( loc != -1 ) 145 if ( loc != -1 )
146 m_embedix = true; 146 m_embedix = true;
147 else 147 else
148 m_embedix = false; 148 m_embedix = false;
149 f.close(); 149 f.close();
150 } 150 }
151 pclose(uname); 151 pclose(uname);
152 } 152 }
153 153
154 // check the Zaurus model 154 // check the Zaurus model
155 QString model; 155 QString model;
156 int loc = cpu_info.find( ":" ); 156 int loc = cpu_info.find( ":" );
157 if ( loc != -1 ) 157 if ( loc != -1 )
158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
159 else 159 else
160 model = cpu_info; 160 model = cpu_info;
161 161
162 if ( model == "SHARP Corgi" ) { 162 if ( model == "SHARP Corgi" ) {
163 d->m_model = Model_Zaurus_SLC7x0; 163 d->m_model = Model_Zaurus_SLC7x0;
164 d->m_modelstr = "Zaurus SL-C700"; 164 d->m_modelstr = "Zaurus SL-C700";
165 } else if ( model == "SHARP Shepherd" ) { 165 } else if ( model == "SHARP Shepherd" ) {
166 d->m_model = Model_Zaurus_SLC7x0; 166 d->m_model = Model_Zaurus_SLC7x0;
167 d->m_modelstr = "Zaurus SL-C750"; 167 d->m_modelstr = "Zaurus SL-C750";
168 } else if ( model == "SHARP Husky" ) { 168 } else if ( model == "SHARP Husky" ) {
169 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
170 d->m_modelstr = "Zaurus SL-C760"; 170 d->m_modelstr = "Zaurus SL-C760";
171 } else if ( model == "SHARP Poodle" ) { 171 } else if ( model == "SHARP Poodle" ) {
172 d->m_model = Model_Zaurus_SLB600; 172 d->m_model = Model_Zaurus_SLB600;
173 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 173 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
174 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 174 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
175 d->m_model = Model_Zaurus_SL5500; 175 d->m_model = Model_Zaurus_SL5500;
176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
177 } else if ( model == "SHARP Tosa" ) { 177 } else if ( model == "SHARP Tosa" ) {
178 d->m_model = Model_Zaurus_SL6000; 178 d->m_model = Model_Zaurus_SL6000;
179 d->m_modelstr = "Zaurus SL-6000"; 179 d->m_modelstr = "Zaurus SL-6000";
180 } else { 180 } else {
181 d->m_model = Model_Zaurus_SL5500; 181 d->m_model = Model_Zaurus_SL5500;
182 d->m_modelstr = "Unkown Zaurus"; 182 d->m_modelstr = "Unkown Zaurus";
183 } 183 }
184 184
185 // set initial rotation 185 // set initial rotation
186 switch ( d->m_model ) { 186 switch ( d->m_model ) {
187 case Model_Zaurus_SL6000: 187 case Model_Zaurus_SL6000:
188 case Model_Zaurus_SLA300: 188 case Model_Zaurus_SLA300:
189 d->m_rotation = Rot0; 189 d->m_rotation = Rot0;
190 break; 190 break;
191 case Model_Zaurus_SLC7x0: 191 case Model_Zaurus_SLC7x0:
192 d->m_rotation = rotation(); 192 d->m_rotation = rotation();
193 d->m_direction = direction(); 193 d->m_direction = direction();
194 break; 194 break;
195 case Model_Zaurus_SLB600: 195 case Model_Zaurus_SLB600:
196 case Model_Zaurus_SL5500: 196 case Model_Zaurus_SL5500:
197 case Model_Zaurus_SL5000: 197 case Model_Zaurus_SL5000:
198 default: 198 default:
199 d->m_rotation = Rot270; 199 d->m_rotation = Rot270;
200 break; 200 break;
201 } 201 }
202 m_leds [0] = Led_Off; 202 m_leds [0] = Led_Off;
203} 203}
204 204
205void Zaurus::initButtons() 205void Zaurus::initButtons()
206{ 206{
207 if ( d->m_buttons ) 207 if ( d->m_buttons )
208 return; 208 return;
209 209
210 d->m_buttons = new QValueList <ODeviceButton>; 210 d->m_buttons = new QValueList <ODeviceButton>;
211 211
212 struct z_button * pz_buttons; 212 struct z_button * pz_buttons;
213 int buttoncount; 213 int buttoncount;
214 switch ( d->m_model ) { 214 switch ( d->m_model ) {
215 case Model_Zaurus_SLC7x0: 215 case Model_Zaurus_SLC7x0:
216 pz_buttons = z_buttons_c700; 216 pz_buttons = z_buttons_c700;
217 buttoncount = ARRAY_SIZE(z_buttons_c700); 217 buttoncount = ARRAY_SIZE(z_buttons_c700);
218 break; 218 break;
219 default: 219 default:
220 pz_buttons = z_buttons; 220 pz_buttons = z_buttons;
221 buttoncount = ARRAY_SIZE(z_buttons); 221 buttoncount = ARRAY_SIZE(z_buttons);
222 break; 222 break;
223 } 223 }
224 224
225 for ( int i = 0; i < buttoncount; i++ ) { 225 for ( int i = 0; i < buttoncount; i++ ) {
226 struct z_button *zb = pz_buttons + i; 226 struct z_button *zb = pz_buttons + i;
227 ODeviceButton b; 227 ODeviceButton b;
228 228
229 b. setKeycode ( zb->code ); 229 b. setKeycode ( zb->code );
230 b. setUserText ( QObject::tr ( "Button", zb->utext )); 230 b. setUserText ( QObject::tr ( "Button", zb->utext ));
231 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 231 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
233 zb->fpressedaction )); 233 zb->fpressedaction ));
234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
235 zb->fheldaction )); 235 zb->fheldaction ));
236 236
237 d->m_buttons->append ( b ); 237 d->m_buttons->append ( b );
238 } 238 }
239 239
240 reloadButtonMapping(); 240 reloadButtonMapping();
241
242 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
243 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
244 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
245} 241}
246 242
247#include <unistd.h> 243#include <unistd.h>
248#include <fcntl.h> 244#include <fcntl.h>
249#include <sys/ioctl.h> 245#include <sys/ioctl.h>
250 246
251//#include <asm/sharp_char.h> // including kernel headers is evil ... 247//#include <asm/sharp_char.h> // including kernel headers is evil ...
252 248
253#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 249#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
254 250
255 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 251 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
256#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 252#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
257 253
258#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 254#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
259#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 255#define SHARP_BUZ_KEYSOUND 2 /* key sound */
260#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 256#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
261 257
262/* --- for SHARP_BUZZER device --- */ 258/* --- for SHARP_BUZZER device --- */
263 259
264 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 260 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
265//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 261//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
266 262
267#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 263#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
268#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 264#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
269#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 265#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
270#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 266#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
271#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 267#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
272 268
273//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 269//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
274//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 270//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
275 271
276//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 272//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
277//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 273//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
278//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 274//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
279//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 275//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
280//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 276//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
281//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 277//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
282//#define SHARP_PDA_APPSTART 9 /* application start */ 278//#define SHARP_PDA_APPSTART 9 /* application start */
283//#define SHARP_PDA_APPQUIT 10 /* application ends */ 279//#define SHARP_PDA_APPQUIT 10 /* application ends */
284 280
285//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 281//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
286//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 282//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
287//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 283//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
288//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 284//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
289// 285//
290 286
291 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 287 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
292#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 288#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
293 289
294#define SHARP_IOCTL_GET_ROTATION 0x413c 290#define SHARP_IOCTL_GET_ROTATION 0x413c
295 291
296typedef struct sharp_led_status { 292typedef struct sharp_led_status {
297int which; /* select which LED status is wanted. */ 293int which; /* select which LED status is wanted. */
298int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 294int status; /* set new led status if you call SHARP_LED_SETSTATUS */
299} sharp_led_status; 295} sharp_led_status;
300 296
301#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 297#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
302 298
303#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 299#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
304#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 300#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
305#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 301#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
306 302
307// #include <asm/sharp_apm.h> // including kernel headers is evil ... 303// #include <asm/sharp_apm.h> // including kernel headers is evil ...
308 304
309#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 305#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
310#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 306#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
311#define APM_EVT_POWER_BUTTON (1 << 0) 307#define APM_EVT_POWER_BUTTON (1 << 0)
312 308
313#define FL_IOCTL_STEP_CONTRAST 100 309#define FL_IOCTL_STEP_CONTRAST 100
314 310
315 311
316void Zaurus::buzzer ( int sound ) 312void Zaurus::buzzer ( int sound )
317{ 313{
318#ifndef QT_NO_SOUND 314#ifndef QT_NO_SOUND
319 Sound *snd = 0; 315 Sound *snd = 0;
320 316
321 // Not all devices have real sound 317 // Not all devices have real sound
322 if ( d->m_model == Model_Zaurus_SLC7x0 318 if ( d->m_model == Model_Zaurus_SLC7x0
323 || d->m_model == Model_Zaurus_SLB600 ){ 319 || d->m_model == Model_Zaurus_SLB600 ){
324 320
325 switch ( sound ){ 321 switch ( sound ){
326 case SHARP_BUZ_TOUCHSOUND: { 322 case SHARP_BUZ_TOUCHSOUND: {
327 static Sound touch_sound("touchsound"); 323 static Sound touch_sound("touchsound");
328 snd = &touch_sound; 324 snd = &touch_sound;
329 } 325 }
330 break; 326 break;
331 case SHARP_BUZ_KEYSOUND: { 327 case SHARP_BUZ_KEYSOUND: {
332 static Sound key_sound( "keysound" ); 328 static Sound key_sound( "keysound" );
333 snd = &key_sound; 329 snd = &key_sound;
334 } 330 }
335 break; 331 break;
336 case SHARP_BUZ_SCHEDULE_ALARM: 332 case SHARP_BUZ_SCHEDULE_ALARM:
337 default: { 333 default: {
338 static Sound alarm_sound("alarm"); 334 static Sound alarm_sound("alarm");
339 snd = &alarm_sound; 335 snd = &alarm_sound;
340 } 336 }
341 break; 337 break;
342 } 338 }
343 } 339 }
344 340
345 // If a soundname is defined, we expect that this device has 341 // If a soundname is defined, we expect that this device has
346 // sound capabilities.. Otherwise we expect to have the buzzer 342 // sound capabilities.. Otherwise we expect to have the buzzer
347 // device.. 343 // device..
348 if ( snd && snd->isFinished() ){ 344 if ( snd && snd->isFinished() ){
349 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 345 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
350 snd-> play(); 346 snd-> play();
351 } else if( !snd ) { 347 } else if( !snd ) {
352 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 348 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
353 349
354 if ( fd >= 0 ) { 350 if ( fd >= 0 ) {
355 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 351 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
356 ::close ( fd ); 352 ::close ( fd );
357 } 353 }
358 354
359 } 355 }
360#endif 356#endif
361} 357}
362 358
363 359
364void Zaurus::playAlarmSound() 360void Zaurus::playAlarmSound()
365{ 361{
366 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 362 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
367} 363}
368 364
369void Zaurus::playTouchSound() 365void Zaurus::playTouchSound()
370{ 366{
371 buzzer ( SHARP_BUZ_TOUCHSOUND ); 367 buzzer ( SHARP_BUZ_TOUCHSOUND );
372} 368}
373 369
374void Zaurus::playKeySound() 370void Zaurus::playKeySound()
375{ 371{
376 buzzer ( SHARP_BUZ_KEYSOUND ); 372 buzzer ( SHARP_BUZ_KEYSOUND );
377} 373}
378 374
379 375
380QValueList <OLed> Zaurus::ledList() const 376QValueList <OLed> Zaurus::ledList() const
381{ 377{
382 QValueList <OLed> vl; 378 QValueList <OLed> vl;
383 vl << Led_Mail; 379 vl << Led_Mail;
384 return vl; 380 return vl;
385} 381}
386 382
387QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 383QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
388{ 384{
389 QValueList <OLedState> vl; 385 QValueList <OLedState> vl;
390 386
391 if ( l == Led_Mail ) 387 if ( l == Led_Mail )
392 vl << Led_Off << Led_On << Led_BlinkSlow; 388 vl << Led_Off << Led_On << Led_BlinkSlow;
393 return vl; 389 return vl;
394} 390}
395 391
396OLedState Zaurus::ledState ( OLed which ) const 392OLedState Zaurus::ledState ( OLed which ) const
397{ 393{
398 if ( which == Led_Mail ) 394 if ( which == Led_Mail )
399 return m_leds [0]; 395 return m_leds [0];
400 else 396 else
401 return Led_Off; 397 return Led_Off;
402} 398}
403 399
404bool Zaurus::setLedState ( OLed which, OLedState st ) 400bool Zaurus::setLedState ( OLed which, OLedState st )
405{ 401{
406 if (!m_embedix) // Currently not supported on non_embedix kernels 402 if (!m_embedix) // Currently not supported on non_embedix kernels
407 return false; 403 return false;
408 404
409 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 405 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
410 406
411 if ( which == Led_Mail ) { 407 if ( which == Led_Mail ) {
412 if ( fd >= 0 ) { 408 if ( fd >= 0 ) {
413 struct sharp_led_status leds; 409 struct sharp_led_status leds;
414 ::memset ( &leds, 0, sizeof( leds )); 410 ::memset ( &leds, 0, sizeof( leds ));
415 leds. which = SHARP_LED_MAIL_EXISTS; 411 leds. which = SHARP_LED_MAIL_EXISTS;
416 bool ok = true; 412 bool ok = true;
417 413
418 switch ( st ) { 414 switch ( st ) {
419 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 415 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
420 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 416 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
421 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 417 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
422 default : ok = false; 418 default : ok = false;
423 } 419 }
424 420
425 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 421 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
426 m_leds [0] = st; 422 m_leds [0] = st;
427 return true; 423 return true;
428 } 424 }
429 } 425 }
430 } 426 }
431 return false; 427 return false;
432} 428}
433 429
434bool Zaurus::setSoftSuspend ( bool soft ) 430bool Zaurus::setSoftSuspend ( bool soft )
435{ 431{
436 if (!m_embedix) { 432 if (!m_embedix) {
437 /* non-Embedix kernels dont have kernel autosuspend */ 433 /* non-Embedix kernels dont have kernel autosuspend */
438 return ODevice::setSoftSuspend( soft ); 434 return ODevice::setSoftSuspend( soft );
439 } 435 }
440 436
441 bool res = false; 437 bool res = false;
442 int fd; 438 int fd;
443 439
444 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 440 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
445 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 441 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
446 442
447 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 443 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
448 444
449 if ( sources >= 0 ) { 445 if ( sources >= 0 ) {
450 if ( soft ) 446 if ( soft )
451 sources &= ~APM_EVT_POWER_BUTTON; 447 sources &= ~APM_EVT_POWER_BUTTON;
452 else 448 else
453 sources |= APM_EVT_POWER_BUTTON; 449 sources |= APM_EVT_POWER_BUTTON;
454 450
455 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 451 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
456 res = true; 452 res = true;
457 else 453 else
458 perror ( "APM_IOCGEVTSRC" ); 454 perror ( "APM_IOCGEVTSRC" );
459 } 455 }
460 else 456 else
461 perror ( "APM_IOCGEVTSRC" ); 457 perror ( "APM_IOCGEVTSRC" );
462 458
463 ::close ( fd ); 459 ::close ( fd );
464 } 460 }
465 else 461 else
466 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 462 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
467 463
468 return res; 464 return res;
469} 465}
470 466
471 467
472bool Zaurus::setDisplayBrightness ( int bright ) 468bool Zaurus::setDisplayBrightness ( int bright )
473{ 469{
474 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 470 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
475 bool res = false; 471 bool res = false;
476 int fd; 472 int fd;
477 473
478 if ( bright > 255 ) bright = 255; 474 if ( bright > 255 ) bright = 255;
479 if ( bright < 0 ) bright = 0; 475 if ( bright < 0 ) bright = 0;
480 476
481 if ( m_embedix ) 477 if ( m_embedix )
482 { 478 {
483 if ( d->m_model == Model_Zaurus_SLC7x0 ) 479 if ( d->m_model == Model_Zaurus_SLC7x0 )
484 { 480 {
485 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 481 //qDebug( "using special treatment for devices with the corgi backlight interface" );
486 // special treatment for devices with the corgi backlight interface 482 // special treatment for devices with the corgi backlight interface
487 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 483 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
488 { 484 {
489 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); 485 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
490 char writeCommand[100]; 486 char writeCommand[100];
491 const int count = sprintf( writeCommand, "0x%x\n", value ); 487 const int count = sprintf( writeCommand, "0x%x\n", value );
492 res = ( ::write ( fd, writeCommand, count ) != -1 ); 488 res = ( ::write ( fd, writeCommand, count ) != -1 );
493 ::close ( fd ); 489 ::close ( fd );
494 } 490 }
495 return res; 491 return res;
496 } 492 }
497 else 493 else
498 { 494 {
499 // standard treatment for devices with the dumb embedix frontlight interface 495 // standard treatment for devices with the dumb embedix frontlight interface
500 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 496 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {