summaryrefslogtreecommitdiff
authorzecke <zecke>2004-08-25 21:51:13 (UTC)
committer zecke <zecke>2004-08-25 21:51:13 (UTC)
commitdf3e4c8b13c16aeb96e70dbaa2d409f83eed988e (patch) (unidiff)
tree59b12028c6e8a53b99f1686278b6e9fdc57ab18e
parente4811064703ad34f42f15c3044cd8f63c0e7583c (diff)
downloadopie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.zip
opie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.tar.gz
opie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.tar.bz2
-Have a common implementation for reading the config value
and setting the Mixer. The mixer, sound and path is configurable -Restore the Opie HEADER (who is guilty? probably me) -Fix warnings -Port Zaurus,Simpad,Ipaq to configure the mixer
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp57
-rw-r--r--libopie2/opiecore/device/odevice.h55
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp71
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp47
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp99
7 files changed, 158 insertions, 175 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index b58f9eb..26c6dca 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,269 +1,274 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48#include <qpe/sound.h>
48#include <opie2/okeyfilter.h> 49#include <opie2/okeyfilter.h>
49 50
50/* STD */ 51/* STD */
51#include <fcntl.h> 52#include <fcntl.h>
52#include <math.h> 53#include <math.h>
53#include <stdlib.h> 54#include <stdlib.h>
54#include <signal.h> 55#include <signal.h>
55#include <sys/ioctl.h> 56#include <sys/ioctl.h>
56#include <sys/time.h> 57#include <sys/time.h>
57#include <unistd.h> 58#include <unistd.h>
58#ifndef QT_NO_SOUND 59#ifndef QT_NO_SOUND
59#include <linux/soundcard.h> 60#include <linux/soundcard.h>
60#endif 61#endif
61 62
62namespace Opie { 63namespace Opie {
63namespace Core { 64namespace Core {
64 65
65static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 66static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
66 67
67 68
68/* STATIC and common implementation */ 69/* STATIC and common implementation */
69/* EXPORT */ ODistribution distributions[] = { 70/* EXPORT */ ODistribution distributions[] = {
70 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 71 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
71 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 72 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
72 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 73 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
73 { System_Unknown, "Linux", "/etc/issue" }, 74 { System_Unknown, "Linux", "/etc/issue" },
74}; 75};
75 76
76 77
77/* EXPORT */ bool isQWS(){ 78/* EXPORT */ bool isQWS(){
78 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 79 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
79} 80}
80 81
81/* EXPORT */ QCString makeChannel ( const char *str ){ 82/* EXPORT */ QCString makeChannel ( const char *str ){
82 if ( str && !::strchr ( str, '/' )) 83 if ( str && !::strchr ( str, '/' ))
83 return QCString ( "QPE/Application/" ) + str; 84 return QCString ( "QPE/Application/" ) + str;
84 else 85 else
85 return str; 86 return str;
86} 87}
87 88
88 89
89 90
90/* Now the default implementation of ODevice */ 91/* Now the default implementation of ODevice */
91 92
92struct default_button default_buttons [] = { 93struct default_button default_buttons [] = {
93 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 94 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
94 "devicebuttons/z_calendar", 95 "devicebuttons/z_calendar",
95 "datebook", "nextView()", 96 "datebook", "nextView()",
96 "today", "raise()" }, 97 "today", "raise()" },
97 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 98 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
98 "devicebuttons/z_contact", 99 "devicebuttons/z_contact",
99 "addressbook", "raise()", 100 "addressbook", "raise()",
100 "addressbook", "beamBusinessCard()" }, 101 "addressbook", "beamBusinessCard()" },
101 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 102 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
102 "devicebuttons/z_home", 103 "devicebuttons/z_home",
103 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
104 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
105 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 106 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
106 "devicebuttons/z_menu", 107 "devicebuttons/z_menu",
107 "QPE/TaskBar", "toggleMenu()", 108 "QPE/TaskBar", "toggleMenu()",
108 "QPE/TaskBar", "toggleStartMenu()" }, 109 "QPE/TaskBar", "toggleStartMenu()" },
109 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 110 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
110 "devicebuttons/z_mail", 111 "devicebuttons/z_mail",
111 "opiemail", "raise()", 112 "opiemail", "raise()",
112 "opiemail", "newMail()" }, 113 "opiemail", "newMail()" },
113}; 114};
114 115
115ODevice *ODevice::inst() 116ODevice *ODevice::inst()
116{ 117{
117 static ODevice *dev = 0; 118 static ODevice *dev = 0;
118 119
119 // rewrite this to only use /proc/cpuinfo or so 120 // rewrite this to only use /proc/cpuinfo or so
120 QString cpu_info; 121 QString cpu_info;
121 122
122 if ( !dev ) 123 if ( !dev )
123 { 124 {
124 QFile f( PATH_PROC_CPUINFO ); 125 QFile f( PATH_PROC_CPUINFO );
125 if ( f.open( IO_ReadOnly ) ) 126 if ( f.open( IO_ReadOnly ) )
126 { 127 {
127 QTextStream s( &f ); 128 QTextStream s( &f );
128 while ( !s.atEnd() ) 129 while ( !s.atEnd() )
129 { 130 {
130 QString line; 131 QString line;
131 line = s.readLine(); 132 line = s.readLine();
132 if ( line.startsWith( "Hardware" ) ) 133 if ( line.startsWith( "Hardware" ) )
133 { 134 {
134 qDebug( "ODevice() - found '%s'", (const char*) line ); 135 qDebug( "ODevice() - found '%s'", (const char*) line );
135 cpu_info = line; 136 cpu_info = line;
136 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
137 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
138 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
139 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
140 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
141 else qWarning( "ODevice() - unknown hardware - using default." ); 142 else qWarning( "ODevice() - unknown hardware - using default." );
142 break; 143 break;
143 } 144 }
144 } 145 }
145 } 146 }
146 else 147 else
147 { 148 {
148 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 149 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
149 } 150 }
150 if ( !dev ) dev = new ODevice(); 151 if ( !dev ) dev = new ODevice();
151 dev->init(cpu_info); 152 dev->init(cpu_info);
152 } 153 }
153 return dev; 154 return dev;
154} 155}
155 156
156ODevice::ODevice() 157ODevice::ODevice()
157{ 158{
158 d = new ODeviceData; 159 d = new ODeviceData;
159 160
160 d->m_modelstr = "Unknown"; 161 d->m_modelstr = "Unknown";
161 d->m_model = Model_Unknown; 162 d->m_model = Model_Unknown;
162 d->m_vendorstr = "Unknown"; 163 d->m_vendorstr = "Unknown";
163 d->m_vendor = Vendor_Unknown; 164 d->m_vendor = Vendor_Unknown;
164 d->m_systemstr = "Unknown"; 165 d->m_systemstr = "Unknown";
165 d->m_system = System_Unknown; 166 d->m_system = System_Unknown;
166 d->m_sysverstr = "0.0"; 167 d->m_sysverstr = "0.0";
167 d->m_rotation = Rot0; 168 d->m_rotation = Rot0;
168 d->m_direction = CW; 169 d->m_direction = CW;
169 170
170 d->m_holdtime = 1000; // 1000ms 171 d->m_holdtime = 1000; // 1000ms
171 d->m_buttons = 0; 172 d->m_buttons = 0;
172 d->m_cpu_frequencies = new QStrList; 173 d->m_cpu_frequencies = new QStrList;
173 174
175
176 /* mixer */
177 d->m_sound = d->m_vol = d->m_mixer = -1;
178
174 // New distribution detection code first checks for legacy distributions, 179 // New distribution detection code first checks for legacy distributions,
175 // identified by /etc/familiar-version or /etc/oz_version. 180 // identified by /etc/familiar-version or /etc/oz_version.
176 // Then check for OpenEmbedded and lastly, read /etc/issue 181 // Then check for OpenEmbedded and lastly, read /etc/issue
177 182
178 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 183 for ( unsigned int i = 0; i < sizeof distributions; ++i )
179 { 184 {
180 if ( QFile::exists( distributions[i].sysvfile ) ) 185 if ( QFile::exists( distributions[i].sysvfile ) )
181 { 186 {
182 d->m_systemstr = distributions[i].sysstr; 187 d->m_systemstr = distributions[i].sysstr;
183 d->m_system = distributions[i].system; 188 d->m_system = distributions[i].system;
184 d->m_sysverstr = "<Unknown>"; 189 d->m_sysverstr = "<Unknown>";
185 QFile f( distributions[i].sysvfile ); 190 QFile f( distributions[i].sysvfile );
186 if ( f.open( IO_ReadOnly ) ) 191 if ( f.open( IO_ReadOnly ) )
187 { 192 {
188 QTextStream ts( &f ); 193 QTextStream ts( &f );
189 d->m_sysverstr = ts.readLine(); 194 d->m_sysverstr = ts.readLine();
190 } 195 }
191 break; 196 break;
192 } 197 }
193 } 198 }
194} 199}
195 200
196void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 201void ODevice::systemMessage( const QCString &msg, const QByteArray & )
197{ 202{
198 if ( msg == "deviceButtonMappingChanged()" ) { 203 if ( msg == "deviceButtonMappingChanged()" ) {
199 reloadButtonMapping(); 204 reloadButtonMapping();
200 } 205 }
201} 206}
202 207
203void ODevice::init(const QString&) 208void ODevice::init(const QString&)
204{ 209{
205} 210}
206 211
207/** 212/**
208* This method initialises the button mapping 213* This method initialises the button mapping
209*/ 214*/
210void ODevice::initButtons() 215void ODevice::initButtons()
211{ 216{
212 if ( d->m_buttons ) 217 if ( d->m_buttons )
213 return; 218 return;
214 219
215 qDebug ( "init Buttons" ); 220 qDebug ( "init Buttons" );
216 d->m_buttons = new QValueList <ODeviceButton>; 221 d->m_buttons = new QValueList <ODeviceButton>;
217 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 222 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
218 default_button *db = default_buttons + i; 223 default_button *db = default_buttons + i;
219 ODeviceButton b; 224 ODeviceButton b;
220 b. setKeycode ( db->code ); 225 b. setKeycode ( db->code );
221 b. setUserText ( QObject::tr ( "Button", db->utext )); 226 b. setUserText ( QObject::tr ( "Button", db->utext ));
222 b. setPixmap ( Resource::loadPixmap ( db->pix )); 227 b. setPixmap ( Resource::loadPixmap ( db->pix ));
223 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 228 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
224 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 229 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
225 d->m_buttons->append ( b ); 230 d->m_buttons->append ( b );
226 } 231 }
227 232
228 reloadButtonMapping(); 233 reloadButtonMapping();
229 234
230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 235 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
231 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 236 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
232} 237}
233 238
234ODevice::~ODevice() 239ODevice::~ODevice()
235{ 240{
236// we leak m_devicebuttons and m_cpu_frequency 241// we leak m_devicebuttons and m_cpu_frequency
237// but it's a singleton and it is not so importantant 242// but it's a singleton and it is not so importantant
238// -zecke 243// -zecke
239 delete d; 244 delete d;
240} 245}
241 246
242bool ODevice::setSoftSuspend ( bool /*soft*/ ) 247bool ODevice::setSoftSuspend ( bool /*soft*/ )
243{ 248{
244 return false; 249 return false;
245} 250}
246 251
247//#include <linux/apm_bios.h> 252//#include <linux/apm_bios.h>
248 253
249#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 254#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
250 255
251/** 256/**
252* This method will try to suspend the device 257* This method will try to suspend the device
253* It only works if the user is the QWS Server and the apm application 258* It only works if the user is the QWS Server and the apm application
254* is installed. 259* is installed.
255* It tries to suspend and then waits some time cause some distributions 260* It tries to suspend and then waits some time cause some distributions
256* do have asynchronus apm implementations. 261* do have asynchronus apm implementations.
257* This method will either fail and return false or it'll suspend the 262* This method will either fail and return false or it'll suspend the
258* device and return once the device got woken up 263* device and return once the device got woken up
259* 264*
260* @return if the device got suspended 265* @return if the device got suspended
261*/ 266*/
262bool ODevice::suspend() 267bool ODevice::suspend()
263{ 268{
264 qDebug("ODevice::suspend"); 269 qDebug("ODevice::suspend");
265 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 270 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
266 return false; 271 return false;
267 272
268 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 273 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
269 return false; 274 return false;
@@ -612,117 +617,169 @@ uint ODevice::buttonHoldTime() const
612/** 617/**
613* This method return a ODeviceButton for a key code 618* This method return a ODeviceButton for a key code
614* or 0 if no special hardware button is available for the device 619* or 0 if no special hardware button is available for the device
615* 620*
616* @return The devicebutton or 0l 621* @return The devicebutton or 0l
617* @see ODeviceButton 622* @see ODeviceButton
618*/ 623*/
619const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 624const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
620{ 625{
621 initButtons(); 626 initButtons();
622 627
623 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 628 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
624 if ( (*it). keycode() == code ) 629 if ( (*it). keycode() == code )
625 return &(*it); 630 return &(*it);
626 } 631 }
627 return 0; 632 return 0;
628} 633}
629 634
630void ODevice::reloadButtonMapping() 635void ODevice::reloadButtonMapping()
631{ 636{
632 initButtons(); 637 initButtons();
633 638
634 Config cfg ( "ButtonSettings" ); 639 Config cfg ( "ButtonSettings" );
635 640
636 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 641 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
637 ODeviceButton &b = ( *d->m_buttons ) [i]; 642 ODeviceButton &b = ( *d->m_buttons ) [i];
638 QString group = "Button" + QString::number ( i ); 643 QString group = "Button" + QString::number ( i );
639 644
640 QCString pch, hch; 645 QCString pch, hch;
641 QCString pm, hm; 646 QCString pm, hm;
642 QByteArray pdata, hdata; 647 QByteArray pdata, hdata;
643 648
644 if ( cfg. hasGroup ( group )) { 649 if ( cfg. hasGroup ( group )) {
645 cfg. setGroup ( group ); 650 cfg. setGroup ( group );
646 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 651 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
647 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 652 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
648 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 653 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
649 654
650 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 655 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
651 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 656 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
652 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 657 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
653 } 658 }
654 659
655 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 660 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
656 661
657 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 662 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
658 } 663 }
659} 664}
660 665
661void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 666void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
662{ 667{
663 initButtons(); 668 initButtons();
664 669
665 QString mb_chan; 670 QString mb_chan;
666 671
667 if ( button >= (int) d->m_buttons->count()) 672 if ( button >= (int) d->m_buttons->count())
668 return; 673 return;
669 674
670 ODeviceButton &b = ( *d->m_buttons ) [button]; 675 ODeviceButton &b = ( *d->m_buttons ) [button];
671 b. setPressedAction ( action ); 676 b. setPressedAction ( action );
672 677
673 mb_chan=b. pressedAction(). channel(); 678 mb_chan=b. pressedAction(). channel();
674 679
675 Config buttonFile ( "ButtonSettings" ); 680 Config buttonFile ( "ButtonSettings" );
676 buttonFile. setGroup ( "Button" + QString::number ( button )); 681 buttonFile. setGroup ( "Button" + QString::number ( button ));
677 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 682 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
678 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 683 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
679 684
680// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 685// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
681 686
682 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 687 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
683} 688}
684 689
685void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 690void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
686{ 691{
687 initButtons(); 692 initButtons();
688 693
689 if ( button >= (int) d->m_buttons->count()) 694 if ( button >= (int) d->m_buttons->count())
690 return; 695 return;
691 696
692 ODeviceButton &b = ( *d->m_buttons ) [button]; 697 ODeviceButton &b = ( *d->m_buttons ) [button];
693 b. setHeldAction ( action ); 698 b. setHeldAction ( action );
694 699
695 Config buttonFile ( "ButtonSettings" ); 700 Config buttonFile ( "ButtonSettings" );
696 buttonFile. setGroup ( "Button" + QString::number ( button )); 701 buttonFile. setGroup ( "Button" + QString::number ( button ));
697 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 702 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
698 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 703 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
699 704
700// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 705// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
701 706
702 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 707 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
703} 708}
704void ODevice::virtual_hook(int, void* ){ 709void ODevice::virtual_hook(int, void* ){
705 710
706} 711}
707 712
713/**
714 * Sends a QCOP message to channel QPE/System
715 * with the message "aboutToSuspend()" if this
716 * is the windowing server
717 */
708void ODevice::sendSuspendmsg() 718void ODevice::sendSuspendmsg()
709{ 719{
710 if ( isQWS() ) 720 if ( isQWS() )
711 return; 721 return;
712 722
713 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 723 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
714} 724}
715 725
726/**
727 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
728 *
729 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
730 * Filters. This function is the only way to prepend a KeyFilter.
731 *
732 * @param aFilter The KeyFilter to be prepended to the list of filters
733 *
734 * @see Opie::Core::OKeyFilter
735 * @see Opie::Core::OKeyFilter::inst()
736 */
716void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 737void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
717{ 738{
718 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 739 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
719} 740}
720 741
742/**
743 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
744 *
745 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
746 * of Keyfilters. Call this when you delete the KeyFilter!
747 *
748 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
749 * @see Opie::Core::ODevice::addPreHandler
750 */
721void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 751void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
722{ 752{
723 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 753 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
724} 754}
725 755
756void ODevice::playingStopped() {
757 const_cast<QObject*>(sender())->disconnect( this );
758 if ( d->m_sound >= 0 ) {
759 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
760 ::close ( d->m_sound );
761 }
762}
763
764void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
765 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
766 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
767 Config cfg ( "qpe" );
768 cfg. setGroup ( "Volume" );
769
770 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
771 if ( volalarm < 0 )
772 volalarm = 0;
773 else if ( volalarm > 100 )
774 volalarm = 100;
775 volalarm |= ( volalarm << 8 );
776
777 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
778 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
779 }
780 d->m_mixer = mixer;
781 }
782}
726 783
727} 784}
728} 785}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index cb7a83f..f4b3e0e 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,143 +1,148 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++= -. .` .: details. 20++=   -.     .`     .: details.
21: = ...= . :.=- 21 :     =  ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41
42
41#include <qstrlist.h> 43#include <qstrlist.h>
42#include <qwindowsystem_qws.h> 44#include <qwindowsystem_qws.h>
43 45
46
47class Sound;
48
44namespace Opie{ 49namespace Opie{
45namespace Core{ 50namespace Core{
46 51
47 class ODeviceData; 52class ODeviceData;
48/** 53/**
49 * The available devices 54 * The available devices
50 */ 55 */
51enum OModel { 56enum OModel {
52 Model_Unknown, // = 0 57 Model_Unknown, // = 0
53 58
54 Model_Series_Mask = 0xff000000, 59 Model_Series_Mask = 0xff000000,
55 60
56 Model_iPAQ = ( 1 << 24 ), 61 Model_iPAQ = ( 1 << 24 ),
57 62
58 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 63 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
59 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
60 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
61 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
62 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
63 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
64 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), 69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
65 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
66 71
67 Model_Jornada = ( 6 << 24 ), 72 Model_Jornada = ( 6 << 24 ),
68 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 73 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
69 74
70 Model_Zaurus = ( 2 << 24 ), 75 Model_Zaurus = ( 2 << 24 ),
71 76
72 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
73 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
74 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
75 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
76 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
77 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), 82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ),
78 83
79 Model_SIMpad = ( 3 << 24 ), 84 Model_SIMpad = ( 3 << 24 ),
80 85
81 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 86 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
82 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 87 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
83 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 88 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
84 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 89 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
85 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 90 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
86 91
87 Model_Ramses = ( 4 << 24 ), 92 Model_Ramses = ( 4 << 24 ),
88 93
89 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 94 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
90 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 95 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
91 96
92 Model_Yopy = ( 5 << 24 ), 97 Model_Yopy = ( 5 << 24 ),
93 98
94 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 99 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
95 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 100 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
96 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 101 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
97 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 102 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
98 103
99 Model_Beagle = ( 6 << 24 ), 104 Model_Beagle = ( 6 << 24 ),
100 105
101 Model_Beagle_All = ( Model_Beagle | 0xffffff ), 106 Model_Beagle_All = ( Model_Beagle | 0xffffff ),
102 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), 107 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ),
103 108
104}; 109};
105 110
106/** 111/**
107 * The vendor of the device 112 * The vendor of the device
108 */ 113 */
109enum OVendor { 114enum OVendor {
110 Vendor_Unknown, 115 Vendor_Unknown,
111 116
112 Vendor_HP, 117 Vendor_HP,
113 Vendor_Sharp, 118 Vendor_Sharp,
114 Vendor_SIEMENS, 119 Vendor_SIEMENS,
115 Vendor_MundN, 120 Vendor_MundN,
116 Vendor_GMate, 121 Vendor_GMate,
117 Vendor_MasterIA, 122 Vendor_MasterIA,
118}; 123};
119 124
120/** 125/**
121 * The System used 126 * The System used
122 */ 127 */
123enum OSystem { 128enum OSystem {
124 System_Unknown, 129 System_Unknown,
125 130
126 System_Familiar, 131 System_Familiar,
127 System_Zaurus, 132 System_Zaurus,
128 System_OpenZaurus, 133 System_OpenZaurus,
129 System_Linupy, 134 System_Linupy,
130 System_OpenEmbedded, 135 System_OpenEmbedded,
131}; 136};
132 137
133typedef struct { 138typedef struct {
134 OSystem system; 139 OSystem system;
135 char* sysstr; 140 char* sysstr;
136 char* sysvfile; 141 char* sysvfile;
137} ODistribution; 142} ODistribution;
138 143
139extern ODistribution distributions[]; 144extern ODistribution distributions[];
140 145
141 146
142enum OLedState { 147enum OLedState {
143 Led_Off, 148 Led_Off,
@@ -226,137 +231,143 @@ public:
226 231
227 static ODevice *inst(); 232 static ODevice *inst();
228 233
229 // information 234 // information
230 235
231 QString modelString() const; 236 QString modelString() const;
232 OModel model() const; 237 OModel model() const;
233 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 238 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
234 239
235 QString vendorString() const; 240 QString vendorString() const;
236 OVendor vendor() const; 241 OVendor vendor() const;
237 242
238 QString systemString() const; 243 QString systemString() const;
239 OSystem system() const; 244 OSystem system() const;
240 245
241 QString systemVersionString() const; 246 QString systemVersionString() const;
242 247
243 virtual Transformation rotation() const; 248 virtual Transformation rotation() const;
244 virtual ODirection direction() const; 249 virtual ODirection direction() const;
245 250
246 // system 251 // system
247 252
248 virtual bool setSoftSuspend ( bool on ); 253 virtual bool setSoftSuspend ( bool on );
249 virtual bool suspend(); 254 virtual bool suspend();
250 255
251 virtual bool setDisplayStatus ( bool on ); 256 virtual bool setDisplayStatus ( bool on );
252 virtual bool setDisplayBrightness ( int brightness ); 257 virtual bool setDisplayBrightness ( int brightness );
253 virtual int displayBrightnessResolution() const; 258 virtual int displayBrightnessResolution() const;
254 virtual bool setDisplayContrast ( int contrast ); 259 virtual bool setDisplayContrast ( int contrast );
255 virtual int displayContrastResolution() const; 260 virtual int displayContrastResolution() const;
256 261
257 // don't add new virtual methods, use this: 262 // don't add new virtual methods, use this:
258 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 263 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
259 // and in your subclass do do overwrite 264 // and in your subclass do do overwrite
260 // protected virtual int virtual_hook(int, void *) 265 // protected virtual int virtual_hook(int, void *)
261 // which is defined below 266 // which is defined below
262 267
263 // input / output 268 // input / output
264 virtual void playAlarmSound(); 269 virtual void playAlarmSound();
265 virtual void playKeySound(); 270 virtual void playKeySound();
266 virtual void playTouchSound(); 271 virtual void playTouchSound();
267 272
268 virtual QValueList <OLed> ledList() const; 273 virtual QValueList <OLed> ledList() const;
269 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 274 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
270 virtual OLedState ledState ( OLed led ) const; 275 virtual OLedState ledState ( OLed led ) const;
271 virtual bool setLedState ( OLed led, OLedState st ); 276 virtual bool setLedState ( OLed led, OLedState st );
272 277
273 virtual bool hasLightSensor() const; 278 virtual bool hasLightSensor() const;
274 virtual int readLightSensor(); 279 virtual int readLightSensor();
275 virtual int lightSensorResolution() const; 280 virtual int lightSensorResolution() const;
276 281
277 virtual bool hasHingeSensor() const; 282 virtual bool hasHingeSensor() const;
278 virtual OHingeStatus readHingeSensor(); 283 virtual OHingeStatus readHingeSensor();
279 284
280 const QStrList &allowedCpuFrequencies() const; 285 const QStrList &allowedCpuFrequencies() const;
281 bool setCurrentCpuFrequency(uint index); 286 bool setCurrentCpuFrequency(uint index);
282 287
283 /** 288 /**
284 * Returns the available buttons on this device. The number and location 289 * Returns the available buttons on this device. The number and location
285 * of buttons will vary depending on the device. Button numbers will be assigned 290 * of buttons will vary depending on the device. Button numbers will be assigned
286 * by the device manufacturer and will be from most preferred button to least preffered 291 * by the device manufacturer and will be from most preferred button to least preffered
287 * button. Note that this list only contains "user mappable" buttons. 292 * button. Note that this list only contains "user mappable" buttons.
288 * 293 *
289 * @todo Make method const and take care of calling initButtons or make that const too 294 * @todo Make method const and take care of calling initButtons or make that const too
290 * 295 *
291 */ 296 */
292 const QValueList<ODeviceButton> &buttons(); 297 const QValueList<ODeviceButton> &buttons();
293 298
294 /** 299 /**
295 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 300 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
296 * returns 0L 301 * returns 0L
297 */ 302 */
298 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 303 const ODeviceButton *buttonForKeycode ( ushort keyCode );
299 304
300 /** 305 /**
301 * Reassigns the pressed action for \a button. To return to the factory 306 * Reassigns the pressed action for \a button. To return to the factory
302 * default pass an empty string as \a qcopMessage. 307 * default pass an empty string as \a qcopMessage.
303 */ 308 */
304 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 309 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
305 310
306 /** 311 /**
307 * Reassigns the held action for \a button. To return to the factory 312 * Reassigns the held action for \a button. To return to the factory
308 * default pass an empty string as \a qcopMessage. 313 * default pass an empty string as \a qcopMessage.
309 */ 314 */
310 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 315 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
311 316
312 /** 317 /**
313 * How long (in ms) you have to press a button for a "hold" action 318 * How long (in ms) you have to press a button for a "hold" action
314 */ 319 */
315 uint buttonHoldTime() const; 320 uint buttonHoldTime() const;
316 321
317signals: 322signals:
318 void buttonMappingChanged(); 323 void buttonMappingChanged();
319 324
320private slots: 325private slots:
321 void systemMessage ( const QCString &, const QByteArray & ); 326 void systemMessage ( const QCString &, const QByteArray & );
327 void playingStopped();
322 328
323protected: 329protected:
324 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 330 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
325 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 331 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
326 void reloadButtonMapping(); 332 void reloadButtonMapping();
333 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
334
327 /* ugly virtual hook */ 335 /* ugly virtual hook */
328 virtual void virtual_hook( int id, void* data ); 336 virtual void virtual_hook( int id, void* data );
329}; 337};
330 338
331class ODeviceData { 339class ODeviceData {
332 340
333 public: 341 public:
334 QString m_vendorstr; 342 QString m_vendorstr;
335 OVendor m_vendor; 343 OVendor m_vendor;
336 344
337 QString m_modelstr; 345 QString m_modelstr;
338 OModel m_model; 346 OModel m_model;
339 347
340 QString m_systemstr; 348 QString m_systemstr;
341 OSystem m_system; 349 OSystem m_system;
342 350
343 QString m_sysverstr; 351 QString m_sysverstr;
344 352
345 Transformation m_rotation; 353 Transformation m_rotation;
346 ODirection m_direction; 354 ODirection m_direction;
347 355
348 QValueList <ODeviceButton> *m_buttons; 356 QValueList <ODeviceButton> *m_buttons;
349 uint m_holdtime; 357 uint m_holdtime;
350 QStrList *m_cpu_frequencies; 358 QStrList *m_cpu_frequencies;
359
360 /* values for changeMixerForAlarm */
361 int m_sound, m_vol, m_mixer;
351}; 362};
352 363
353extern bool isQWS(); 364extern bool isQWS();
354extern QCString makeChannel ( const char *str ); 365extern QCString makeChannel ( const char *str );
355} 366}
356} 367}
357 368
358 369
359 370
360 371
361#endif 372#endif
362 373
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 21fed99..7f5aa7b 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,120 +1,120 @@
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) 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";
@@ -238,222 +238,195 @@ bool iPAQ::setLedState ( OLed l, OLedState st )
238 ::memset ( &leds, 0, sizeof( leds )); 238 ::memset ( &leds, 0, sizeof( leds ));
239 leds. TotalTime = 0; 239 leds. TotalTime = 0;
240 leds. OnTime = 0; 240 leds. OnTime = 0;
241 leds. OffTime = 1; 241 leds. OffTime = 1;
242 leds. OffOnBlink = 2; 242 leds. OffOnBlink = 2;
243 243
244 switch ( st ) { 244 switch ( st ) {
245 case Led_Off : leds. OffOnBlink = 0; break; 245 case Led_Off : leds. OffOnBlink = 0; break;
246 case Led_On : leds. OffOnBlink = 1; break; 246 case Led_On : leds. OffOnBlink = 1; break;
247 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 247 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
248 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 248 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
249 } 249 }
250 250
251 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 251 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
252 m_leds [0] = st; 252 m_leds [0] = st;
253 return true; 253 return true;
254 } 254 }
255 } 255 }
256 } 256 }
257 return false; 257 return false;
258} 258}
259 259
260 260
261bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 261bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
262{ 262{
263 int newkeycode = keycode; 263 int newkeycode = keycode;
264 264
265 switch ( keycode ) { 265 switch ( keycode ) {
266 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 266 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
267 case HardKey_Menu: { 267 case HardKey_Menu: {
268 if (( d->m_model == Model_iPAQ_H38xx ) || 268 if (( d->m_model == Model_iPAQ_H38xx ) ||
269 ( d->m_model == Model_iPAQ_H39xx ) || 269 ( d->m_model == Model_iPAQ_H39xx ) ||
270 ( d->m_model == Model_iPAQ_H5xxx)) { 270 ( d->m_model == Model_iPAQ_H5xxx)) {
271 newkeycode = HardKey_Mail; 271 newkeycode = HardKey_Mail;
272 } 272 }
273 break; 273 break;
274 } 274 }
275 275
276 // Rotate cursor keys 180 or 270 276 // Rotate cursor keys 180 or 270
277 case Key_Left : 277 case Key_Left :
278 case Key_Right: 278 case Key_Right:
279 case Key_Up : 279 case Key_Up :
280 case Key_Down : { 280 case Key_Down : {
281 if (( d->m_model == Model_iPAQ_H31xx ) || 281 if (( d->m_model == Model_iPAQ_H31xx ) ||
282 ( d->m_model == Model_iPAQ_H38xx )) { 282 ( d->m_model == Model_iPAQ_H38xx )) {
283 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 283 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
284 } 284 }
285 // Rotate the cursor keys by 270 285 // Rotate the cursor keys by 270
286 // keycode - Key_Left = position of the button starting from left clockwise 286 // 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 287 // add the rotation to it and modolo. No we've the original offset
288 // add the offset to the Key_Left key 288 // add the offset to the Key_Left key
289 if ( d-> m_model == Model_iPAQ_H5xxx ) 289 if ( d-> m_model == Model_iPAQ_H5xxx )
290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
291 break; 291 break;
292 } 292 }
293 293
294 // map Power Button short/long press to F34/F35 294 // map Power Button short/long press to F34/F35
295 case Key_SysReq: { 295 case Key_SysReq: {
296 if ( isPress ) { 296 if ( isPress ) {
297 if ( m_power_timer ) 297 if ( m_power_timer )
298 killTimer ( m_power_timer ); 298 killTimer ( m_power_timer );
299 m_power_timer = startTimer ( 500 ); 299 m_power_timer = startTimer ( 500 );
300 } 300 }
301 else if ( m_power_timer ) { 301 else if ( m_power_timer ) {
302 killTimer ( m_power_timer ); 302 killTimer ( m_power_timer );
303 m_power_timer = 0; 303 m_power_timer = 0;
304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
306 } 306 }
307 newkeycode = Key_unknown; 307 newkeycode = Key_unknown;
308 break; 308 break;
309 } 309 }
310 } 310 }
311 311
312 if ( newkeycode != keycode ) { 312 if ( newkeycode != keycode ) {
313 if ( newkeycode != Key_unknown ) 313 if ( newkeycode != Key_unknown )
314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
315 return true; 315 return true;
316 } 316 }
317 else 317 else
318 return false; 318 return false;
319} 319}
320 320
321void iPAQ::timerEvent ( QTimerEvent * ) 321void iPAQ::timerEvent ( QTimerEvent * )
322{ 322{
323 killTimer ( m_power_timer ); 323 killTimer ( m_power_timer );
324 m_power_timer = 0; 324 m_power_timer = 0;
325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
327} 327}
328 328
329 329
330void iPAQ::playAlarmSound() 330void iPAQ::playAlarmSound()
331{ 331{
332#ifndef QT_NO_SOUND 332#ifndef QT_NO_SOUND
333 static Sound snd ( "alarm" ); 333 static Sound snd ( "alarm" );
334 int fd;
335 int vol;
336 bool vol_reset = false;
337
338 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
339 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
340 Config cfg ( "qpe" );
341 cfg. setGroup ( "Volume" );
342
343 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
344 if ( volalarm < 0 )
345 volalarm = 0;
346 else if ( volalarm > 100 )
347 volalarm = 100;
348 volalarm |= ( volalarm << 8 );
349
350 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
351 vol_reset = true;
352 }
353 }
354 334
335 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
355 snd. play(); 336 snd. play();
356 while ( !snd. isFinished())
357 qApp->processEvents();
358
359 if ( fd >= 0 ) {
360 if ( vol_reset )
361 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
362 ::close ( fd );
363 }
364#endif 337#endif
365} 338}
366 339
367 340
368bool iPAQ::setSoftSuspend ( bool soft ) 341bool iPAQ::setSoftSuspend ( bool soft )
369{ 342{
370 bool res = false; 343 bool res = false;
371 int fd; 344 int fd;
372 345
373 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 346 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
374 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 347 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
375 res = true; 348 res = true;
376 else 349 else
377 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 350 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
378 351
379 ::close ( fd ); 352 ::close ( fd );
380 } 353 }
381 else 354 else
382 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 355 ::perror ( "/proc/sys/ts/suspend_button_mode" );
383 356
384 return res; 357 return res;
385} 358}
386 359
387 360
388bool iPAQ::setDisplayBrightness ( int bright ) 361bool iPAQ::setDisplayBrightness ( int bright )
389{ 362{
390 bool res = false; 363 bool res = false;
391 int fd; 364 int fd;
392 365
393 if ( bright > 255 ) 366 if ( bright > 255 )
394 bright = 255; 367 bright = 255;
395 if ( bright < 0 ) 368 if ( bright < 0 )
396 bright = 0; 369 bright = 0;
397 370
398 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 371 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
399 FLITE_IN bl; 372 FLITE_IN bl;
400 bl. mode = 1; 373 bl. mode = 1;
401 bl. pwr = bright ? 1 : 0; 374 bl. pwr = bright ? 1 : 0;
402 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 375 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
403 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 376 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
404 ::close ( fd ); 377 ::close ( fd );
405 } 378 }
406 return res; 379 return res;
407} 380}
408 381
409int iPAQ::displayBrightnessResolution() const 382int iPAQ::displayBrightnessResolution() const
410{ 383{
411 switch ( model()) { 384 switch ( model()) {
412 case Model_iPAQ_H31xx: 385 case Model_iPAQ_H31xx:
413 case Model_iPAQ_H36xx: 386 case Model_iPAQ_H36xx:
414 case Model_iPAQ_H37xx: 387 case Model_iPAQ_H37xx:
415 return 128; // really 256, but >128 could damage the LCD 388 return 128; // really 256, but >128 could damage the LCD
416 389
417 case Model_iPAQ_H38xx: 390 case Model_iPAQ_H38xx:
418 case Model_iPAQ_H39xx: 391 case Model_iPAQ_H39xx:
419 return 64; 392 return 64;
420 case Model_iPAQ_H5xxx: 393 case Model_iPAQ_H5xxx:
421 return 255; 394 return 255;
422 395
423 default: 396 default:
424 return 2; 397 return 2;
425 } 398 }
426} 399}
427 400
428 401
429bool iPAQ::hasLightSensor() const 402bool iPAQ::hasLightSensor() const
430{ 403{
431 return true; 404 return true;
432} 405}
433 406
434int iPAQ::readLightSensor() 407int iPAQ::readLightSensor()
435{ 408{
436 int fd; 409 int fd;
437 int val = -1; 410 int val = -1;
438 411
439 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 412 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
440 char buffer [8]; 413 char buffer [8];
441 414
442 if ( ::read ( fd, buffer, 5 ) == 5 ) { 415 if ( ::read ( fd, buffer, 5 ) == 5 ) {
443 char *endptr; 416 char *endptr;
444 417
445 buffer [4] = 0; 418 buffer [4] = 0;
446 val = ::strtol ( buffer + 2, &endptr, 16 ); 419 val = ::strtol ( buffer + 2, &endptr, 16 );
447 420
448 if ( *endptr != 0 ) 421 if ( *endptr != 0 )
449 val = -1; 422 val = -1;
450 } 423 }
451 ::close ( fd ); 424 ::close ( fd );
452 } 425 }
453 426
454 return val; 427 return val;
455} 428}
456 429
457int iPAQ::lightSensorResolution() const 430int iPAQ::lightSensorResolution() const
458{ 431{
459 return 256; 432 return 256;
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index c6de614..2d0160d 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -145,234 +145,205 @@ void SIMpad::initButtons()
145{ 145{
146 if ( d->m_buttons ) 146 if ( d->m_buttons )
147 return; 147 return;
148 148
149 if ( isQWS( ) ) { 149 if ( isQWS( ) ) {
150 addPreHandler(this); 150 addPreHandler(this);
151 } 151 }
152 152
153 153
154 d->m_buttons = new QValueList <ODeviceButton>; 154 d->m_buttons = new QValueList <ODeviceButton>;
155 155
156 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 156 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
157 s_button *sb = simpad_buttons + i; 157 s_button *sb = simpad_buttons + i;
158 ODeviceButton b; 158 ODeviceButton b;
159 159
160 if (( sb->model & d->m_model ) == d->m_model ) { 160 if (( sb->model & d->m_model ) == d->m_model ) {
161 b. setKeycode ( sb->code ); 161 b. setKeycode ( sb->code );
162 b. setUserText ( QObject::tr ( "Button", sb->utext )); 162 b. setUserText ( QObject::tr ( "Button", sb->utext ));
163 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 163 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
164 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 164 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
165 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 165 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
166 166
167 d->m_buttons->append ( b ); 167 d->m_buttons->append ( b );
168 } 168 }
169 } 169 }
170 reloadButtonMapping(); 170 reloadButtonMapping();
171 171
172 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 172 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
173 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 173 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
174} 174}
175 175
176// SIMpad boardcontrol register CS3 176// SIMpad boardcontrol register CS3
177#define SIMPAD_BOARDCONTROL "/proc/cs3" 177#define SIMPAD_BOARDCONTROL "/proc/cs3"
178#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 178#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
179#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 179#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
180#define SIMPAD_EN1 0x0004 // This is only for EPROM's 180#define SIMPAD_EN1 0x0004 // This is only for EPROM's
181#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 181#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
182#define SIMPAD_DISPLAY_ON 0x0010 182#define SIMPAD_DISPLAY_ON 0x0010
183#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 183#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
184#define SIMPAD_MQ_RESET 0x0040 184#define SIMPAD_MQ_RESET 0x0040
185#define SIMPAD_PCMCIA_RESET 0x0080 185#define SIMPAD_PCMCIA_RESET 0x0080
186#define SIMPAD_DECT_POWER_ON 0x0100 186#define SIMPAD_DECT_POWER_ON 0x0100
187#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 187#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
188#define SIMPAD_RS232_ON 0x0400 188#define SIMPAD_RS232_ON 0x0400
189#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 189#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
190#define SIMPAD_LED2_ON 0x1000 190#define SIMPAD_LED2_ON 0x1000
191#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 191#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
192#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 192#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
193#define SIMPAD_RESET_SIMCARD 0x8000 193#define SIMPAD_RESET_SIMCARD 0x8000
194 194
195//SIMpad touchscreen backlight strength control 195//SIMpad touchscreen backlight strength control
196#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 196#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
197#define SIMPAD_BACKLIGHT_MASK 0x00a10044 197#define SIMPAD_BACKLIGHT_MASK 0x00a10044
198 198
199QValueList <OLed> SIMpad::ledList() const 199QValueList <OLed> SIMpad::ledList() const
200{ 200{
201 QValueList <OLed> vl; 201 QValueList <OLed> vl;
202 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 202 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
203 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 203 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
204 return vl; 204 return vl;
205} 205}
206 206
207QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 207QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
208{ 208{
209 QValueList <OLedState> vl; 209 QValueList <OLedState> vl;
210 210
211 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 211 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
212 vl << Led_Off << Led_On; 212 vl << Led_Off << Led_On;
213 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 213 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
214 //vl << Led_Off; 214 //vl << Led_Off;
215 return vl; 215 return vl;
216} 216}
217 217
218OLedState SIMpad::ledState ( OLed l ) const 218OLedState SIMpad::ledState ( OLed l ) const
219{ 219{
220 switch ( l ) { 220 switch ( l ) {
221 case Led_Power: 221 case Led_Power:
222 return m_leds [0]; 222 return m_leds [0];
223 //case Led_Mail: 223 //case Led_Mail:
224 // return m_leds [1]; 224 // return m_leds [1];
225 default: 225 default:
226 return Led_Off; 226 return Led_Off;
227 } 227 }
228} 228}
229 229
230bool SIMpad::setLedState ( OLed l, OLedState st ) 230bool SIMpad::setLedState ( OLed l, OLedState st )
231{ 231{
232#if 0 232#if 0
233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
234 234
235 /*TODO Implement this like that: 235 /*TODO Implement this like that:
236 read from cs3 236 read from cs3
237 && with SIMPAD_LED2_ON 237 && with SIMPAD_LED2_ON
238 write to cs3 */ 238 write to cs3 */
239 m_leds [0] = st; 239 m_leds [0] = st;
240 return true; 240 return true;
241 } 241 // }
242 } 242// }
243 } 243#else
244 244 Q_UNUSED( l )
245 Q_UNUSED( st )
245#endif 246#endif
246 return false; 247 return false;
247} 248}
248 249
249 250
250bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 251bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ )
251{ 252{
252 //TODO 253 //TODO
253 return false; 254 return false;
254} 255}
255 256
256void SIMpad::timerEvent ( QTimerEvent * ) 257void SIMpad::timerEvent ( QTimerEvent * )
257{ 258{
258 killTimer ( m_power_timer ); 259 killTimer ( m_power_timer );
259 m_power_timer = 0; 260 m_power_timer = 0;
260 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 262 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
262} 263}
263 264
264 265
265void SIMpad::playAlarmSound() 266void SIMpad::playAlarmSound()
266{ 267{
267#ifndef QT_NO_SOUND 268#ifndef QT_NO_SOUND
268 static Sound snd ( "alarm" ); 269 static Sound snd ( "alarm" );
269 int fd;
270 int vol;
271 bool vol_reset = false;
272
273 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
274 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
275 Config cfg ( "qpe" );
276 cfg. setGroup ( "Volume" );
277
278 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
279 if ( volalarm < 0 )
280 volalarm = 0;
281 else if ( volalarm > 100 )
282 volalarm = 100;
283 volalarm |= ( volalarm << 8 );
284
285 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
286 vol_reset = true;
287 }
288 }
289 270
271 /* save as the Sound is static! */
272 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
290 snd. play(); 273 snd. play();
291 while ( !snd. isFinished())
292 qApp->processEvents();
293
294 if ( fd >= 0 ) {
295 if ( vol_reset )
296 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
297 ::close ( fd );
298 }
299#endif 274#endif
300} 275}
301 276
302 277
303bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 278bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
304{ 279{
305 qDebug( "ODevice for SIMpad: suspend()" ); 280 qDebug( "ODevice for SIMpad: suspend()" );
306 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 281 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
307 return false; 282 return false;
308 283
309 /* 284 /*
310 * we need to save the screen content 285 * we need to save the screen content
311 * then go to suspend using ODevice::suspend 286 * then go to suspend using ODevice::suspend
312 * and finally restore the screen content 287 * and finally restore the screen content
313 */ 288 */
314 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); 289 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" );
315 bool res = ODevice::suspend(); 290 bool res = ODevice::suspend();
316 291
317 /* 292 /*
318 * restore 293 * restore
319 */ 294 */
320 if ( res ) 295 if ( res )
321 ::system( "cat /tmp/.buffer > /dev/fb/0" ); 296 ::system( "cat /tmp/.buffer > /dev/fb/0" );
322 297
323 return res; 298 return res;
324} 299}
325 300
326 301
327bool SIMpad::setSoftSuspend ( bool soft ) 302bool SIMpad::setSoftSuspend ( bool soft )
328{ 303{
329 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 304 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
330 return false; 305 return false;
331} 306}
332 307
333 308
334bool SIMpad::setDisplayStatus ( bool on ) 309bool SIMpad::setDisplayStatus ( bool on )
335{ 310{
336 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 311 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
337 312
338 bool res = false;
339 int fd;
340 313
341 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 314 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
342 315
343 res = ( ::system( (const char*) cmdline ) == 0 ); 316 return ( ::system( (const char*) cmdline ) == 0 );
344
345 return res;
346} 317}
347 318
348 319
349bool SIMpad::setDisplayBrightness ( int bright ) 320bool SIMpad::setDisplayBrightness ( int bright )
350{ 321{
351 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 322 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
352 bool res = false; 323 bool res = false;
353 int fd; 324 int fd;
354 325
355 if ( bright > 255 ) 326 if ( bright > 255 )
356 bright = 255; 327 bright = 255;
357 if ( bright < 1 ) 328 if ( bright < 1 )
358 bright = 0; 329 bright = 0;
359 330
360 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 331 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
361 int value = 255 - bright; 332 int value = 255 - bright;
362 const int mask = SIMPAD_BACKLIGHT_MASK; 333 const int mask = SIMPAD_BACKLIGHT_MASK;
363 value = value << 8; 334 value = value << 8;
364 value += mask; 335 value += mask;
365 char writeCommand[100]; 336 char writeCommand[100];
366 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); 337 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value );
367 res = ( ::write ( fd, writeCommand, count ) != -1 ); 338 res = ( ::write ( fd, writeCommand, count ) != -1 );
368 ::close ( fd ); 339 ::close ( fd );
369 } 340 }
370 return res; 341 return res;
371} 342}
372 343
373 344
374int SIMpad::displayBrightnessResolution() const 345int SIMpad::displayBrightnessResolution() const
375{ 346{
376 return 255; // All SIMpad models share the same display 347 return 255; // All SIMpad models share the same display
377} 348}
378 349
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index d9ae5a5..6c42be7 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,87 +1,87 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 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#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class SIMpad : public ODevice, public QWSServer::KeyboardFilter 42class SIMpad : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 protected: 44 protected:
45 virtual void init(const QString&); 45 virtual void init(const QString&);
46 virtual void initButtons(); 46 virtual void initButtons();
47 47
48 public: 48 public:
49 virtual bool setSoftSuspend( bool soft ); 49 virtual bool setSoftSuspend( bool soft );
50 virtual bool suspend(); 50 virtual bool suspend();
51 51
52 virtual bool setDisplayStatus( bool on ); 52 virtual bool setDisplayStatus( bool on );
53 virtual bool setDisplayBrightness( int b ); 53 virtual bool setDisplayBrightness( int b );
54 virtual int displayBrightnessResolution() const; 54 virtual int displayBrightnessResolution() const;
55 55
56 virtual void playAlarmSound(); 56 virtual void playAlarmSound();
57 57
58 virtual QValueList <OLed> ledList() const; 58 virtual QValueList <OLed> ledList() const;
59 virtual QValueList <OLedState> ledStateList( OLed led ) const; 59 virtual QValueList <OLedState> ledStateList( OLed led ) const;
60 virtual OLedState ledState( OLed led ) const; 60 virtual OLedState ledState( OLed led ) const;
61 virtual bool setLedState( OLed led, OLedState st ); 61 virtual bool setLedState( OLed led, OLedState st );
62 62
63 protected: 63 protected:
64 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 64 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
65 virtual void timerEvent( QTimerEvent *te ); 65 virtual void timerEvent( QTimerEvent *te );
66 66
67 int m_power_timer; 67 int m_power_timer;
68 68
69 OLedState m_leds [2]; 69 OLedState m_leds [2];
70}; 70};
71 71
72struct s_button { 72struct s_button {
73 uint model; 73 uint model;
74 Qt::Key code; 74 Qt::Key code;
75 char *utext; 75 char *utext;
76 char *pix; 76 char *pix;
77 char *fpressedservice; 77 char *fpressedservice;
78 char *fpressedaction; 78 char *fpressedaction;
79 char *fheldservice; 79 char *fheldservice;
80 char *fheldaction; 80 char *fheldaction;
81}; 81};
82 82
83} 83}
84} 84}
85} 85}
86 86
87#endif 87#endif
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index 223aa76..a06d7ec 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -50,106 +50,108 @@ _;:,     .>    :=|. This program is free software; you can
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 112
113 QCopChannel *sysch = new QCopChannel( "QPE/System", this ); 113 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
114 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ), 114 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
115 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 115 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
116} 116}
117 117
118 118
119bool Yopy::suspend() 119bool Yopy::suspend()
120{ 120{
121 /* Opie for Yopy does not implement its own power management at the 121 /* 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 122 moment. The public version runs parallel to X, and relies on the
123 existing power management features. */ 123 existing power management features. */
124 return false; 124 return false;
125} 125}
126 126
127 127
128bool Yopy::setDisplayBrightness( int bright ) 128bool Yopy::setDisplayBrightness( int bright )
129{ 129{
130 /* The code here works, but is disabled as the current version runs 130 /* The code here works, but is disabled as the current version runs
131 parallel to X, and relies on the existing backlight demon. */ 131 parallel to X, and relies on the existing backlight demon. */
132#if 0 132#if 0
133 if ( QFile::exists( "/proc/sys/pm/light" ) ) 133 if ( QFile::exists( "/proc/sys/pm/light" ) )
134 { 134 {
135 int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); 135 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
136 if ( fd >= 0 ) 136 if ( fd >= 0 )
137 { 137 {
138 if ( bright ) 138 if ( bright )
139 ::write( fd, "1\n", 2 ); 139 ::write( fd, "1\n", 2 );
140 else 140 else
141 ::write( fd, "0\n", 2 ); 141 ::write( fd, "0\n", 2 );
142 ::close( fd ); 142 ::close( fd );
143 return true; 143 return true;
144 } 144 }
145 } 145 }
146#else
147 Q_UNUSED( bright )
146#endif 148#endif
147 return false; 149 return false;
148} 150}
149 151
150 152
151int Yopy::displayBrightnessResolution() const 153int Yopy::displayBrightnessResolution() const
152{ 154{
153 return 2; 155 return 2;
154} 156}
155 157
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 47682bb..127fee9 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,613 +1,582 @@
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
187 bool flipstate = false;
188 switch ( d->m_model ) { 186 switch ( d->m_model ) {
189 case Model_Zaurus_SL6000: 187 case Model_Zaurus_SL6000:
190 case Model_Zaurus_SLA300: 188 case Model_Zaurus_SLA300:
191 d->m_rotation = Rot0; 189 d->m_rotation = Rot0;
192 break; 190 break;
193 case Model_Zaurus_SLC7x0: 191 case Model_Zaurus_SLC7x0:
194 d->m_rotation = rotation(); 192 d->m_rotation = rotation();
195 d->m_direction = direction(); 193 d->m_direction = direction();
196 break; 194 break;
197 case Model_Zaurus_SLB600: 195 case Model_Zaurus_SLB600:
198 case Model_Zaurus_SL5500: 196 case Model_Zaurus_SL5500:
199 case Model_Zaurus_SL5000: 197 case Model_Zaurus_SL5000:
200 default: 198 default:
201 d->m_rotation = Rot270; 199 d->m_rotation = Rot270;
202 break; 200 break;
203 } 201 }
204 m_leds [0] = Led_Off; 202 m_leds [0] = Led_Off;
205} 203}
206 204
207void Zaurus::initButtons() 205void Zaurus::initButtons()
208{ 206{
209 if ( d->m_buttons ) 207 if ( d->m_buttons )
210 return; 208 return;
211 209
212 d->m_buttons = new QValueList <ODeviceButton>; 210 d->m_buttons = new QValueList <ODeviceButton>;
213 211
214 struct z_button * pz_buttons; 212 struct z_button * pz_buttons;
215 int buttoncount; 213 int buttoncount;
216 switch ( d->m_model ) { 214 switch ( d->m_model ) {
217 case Model_Zaurus_SLC7x0: 215 case Model_Zaurus_SLC7x0:
218 pz_buttons = z_buttons_c700; 216 pz_buttons = z_buttons_c700;
219 buttoncount = ARRAY_SIZE(z_buttons_c700); 217 buttoncount = ARRAY_SIZE(z_buttons_c700);
220 break; 218 break;
221 default: 219 default:
222 pz_buttons = z_buttons; 220 pz_buttons = z_buttons;
223 buttoncount = ARRAY_SIZE(z_buttons); 221 buttoncount = ARRAY_SIZE(z_buttons);
224 break; 222 break;
225 } 223 }
226 224
227 for ( int i = 0; i < buttoncount; i++ ) { 225 for ( int i = 0; i < buttoncount; i++ ) {
228 struct z_button *zb = pz_buttons + i; 226 struct z_button *zb = pz_buttons + i;
229 ODeviceButton b; 227 ODeviceButton b;
230 228
231 b. setKeycode ( zb->code ); 229 b. setKeycode ( zb->code );
232 b. setUserText ( QObject::tr ( "Button", zb->utext )); 230 b. setUserText ( QObject::tr ( "Button", zb->utext ));
233 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 231 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
234 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
235 zb->fpressedaction )); 233 zb->fpressedaction ));
236 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
237 zb->fheldaction )); 235 zb->fheldaction ));
238 236
239 d->m_buttons->append ( b ); 237 d->m_buttons->append ( b );
240 } 238 }
241 239
242 reloadButtonMapping(); 240 reloadButtonMapping();
243 241
244 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 242 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
245 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), 243 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
246 this, SLOT( systemMessage(const QCString&,const QByteArray&))); 244 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
247} 245}
248 246
249#include <unistd.h> 247#include <unistd.h>
250#include <fcntl.h> 248#include <fcntl.h>
251#include <sys/ioctl.h> 249#include <sys/ioctl.h>
252 250
253//#include <asm/sharp_char.h> // including kernel headers is evil ... 251//#include <asm/sharp_char.h> // including kernel headers is evil ...
254 252
255#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 253#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
256 254
257 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 255 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
258#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 256#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
259 257
260#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 258#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
261#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 259#define SHARP_BUZ_KEYSOUND 2 /* key sound */
262#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 260#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
263 261
264/* --- for SHARP_BUZZER device --- */ 262/* --- for SHARP_BUZZER device --- */
265 263
266 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 264 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
267//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 265//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
268 266
269#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 267#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
270#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 268#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
271#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 269#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
272#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 270#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
273#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 271#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
274 272
275//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 273//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
276//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 274//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
277 275
278//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 276//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
279//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 277//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
280//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 278//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
281//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 279//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
282//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 280//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
283//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 281//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
284//#define SHARP_PDA_APPSTART 9 /* application start */ 282//#define SHARP_PDA_APPSTART 9 /* application start */
285//#define SHARP_PDA_APPQUIT 10 /* application ends */ 283//#define SHARP_PDA_APPQUIT 10 /* application ends */
286 284
287//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 285//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
288//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 286//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
289//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 287//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
290//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 288//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
291// 289//
292 290
293 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 291 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
294#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 292#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
295 293
296#define SHARP_IOCTL_GET_ROTATION 0x413c 294#define SHARP_IOCTL_GET_ROTATION 0x413c
297 295
298typedef struct sharp_led_status { 296typedef struct sharp_led_status {
299int which; /* select which LED status is wanted. */ 297int which; /* select which LED status is wanted. */
300int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 298int status; /* set new led status if you call SHARP_LED_SETSTATUS */
301} sharp_led_status; 299} sharp_led_status;
302 300
303#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 301#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
304 302
305#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 303#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
306#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 304#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
307#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 305#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
308 306
309// #include <asm/sharp_apm.h> // including kernel headers is evil ... 307// #include <asm/sharp_apm.h> // including kernel headers is evil ...
310 308
311#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 309#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
312#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 310#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
313#define APM_EVT_POWER_BUTTON (1 << 0) 311#define APM_EVT_POWER_BUTTON (1 << 0)
314 312
315#define FL_IOCTL_STEP_CONTRAST 100 313#define FL_IOCTL_STEP_CONTRAST 100
316 314
317 315
318void Zaurus::buzzer ( int sound ) 316void Zaurus::buzzer ( int sound )
319{ 317{
320#ifndef QT_NO_SOUND 318#ifndef QT_NO_SOUND
321 QString soundname; 319 Sound *snd = 0;
322 320
323 // Not all devices have real sound 321 // Not all devices have real sound
324 if ( d->m_model == Model_Zaurus_SLC7x0 322 if ( d->m_model == Model_Zaurus_SLC7x0
325 || d->m_model == Model_Zaurus_SLB600 ){ 323 || d->m_model == Model_Zaurus_SLB600 ){
326 324
327 switch ( sound ){ 325 switch ( sound ){
328 case SHARP_BUZ_SCHEDULE_ALARM:
329 soundname = "alarm";
330 break;
331 case SHARP_BUZ_TOUCHSOUND: 326 case SHARP_BUZ_TOUCHSOUND:
332 soundname = "touchsound"; 327 static Sound touch_sound("touchsound");
328 snd = &touch_sound;
333 break; 329 break;
334 case SHARP_BUZ_KEYSOUND: 330 case SHARP_BUZ_KEYSOUND:
335 soundname = "keysound"; 331 static Sound key_sound( "keysound" );
332 snd = &key_sound;
336 break; 333 break;
334 case SHARP_BUZ_SCHEDULE_ALARM:
337 default: 335 default:
338 soundname = "alarm"; 336 static Sound alarm_sound("alarm");
339 337 snd = &alarm_sound;
338 break;
340 } 339 }
341 } 340 }
342 341
343 // If a soundname is defined, we expect that this device has 342 // If a soundname is defined, we expect that this device has
344 // sound capabilities.. Otherwise we expect to have the buzzer 343 // sound capabilities.. Otherwise we expect to have the buzzer
345 // device.. 344 // device..
346 if ( !soundname.isEmpty() ){ 345 if ( snd ){
347 int fd; 346 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
348 int vol; 347 snd-> play();
349 bool vol_reset = false;
350
351 Sound snd ( soundname );
352
353 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
354 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
355 Config cfg ( "qpe" );
356 cfg. setGroup ( "Volume" );
357
358 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
359 if ( volalarm < 0 )
360 volalarm = 0;
361 else if ( volalarm > 100 )
362 volalarm = 100;
363 volalarm |= ( volalarm << 8 );
364
365 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
366 vol_reset = true;
367 }
368 }
369
370 snd. play();
371 while ( !snd. isFinished())
372 qApp->processEvents();
373
374 if ( fd >= 0 ) {
375 if ( vol_reset )
376 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
377 ::close ( fd );
378 }
379 } else { 348 } else {
380 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 349 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
381 350
382 if ( fd >= 0 ) { 351 if ( fd >= 0 ) {
383 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 352 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
384 ::close ( fd ); 353 ::close ( fd );
385 } 354 }
386 355
387 } 356 }
388#endif 357#endif
389} 358}
390 359
391 360
392void Zaurus::playAlarmSound() 361void Zaurus::playAlarmSound()
393{ 362{
394 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 363 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
395} 364}
396 365
397void Zaurus::playTouchSound() 366void Zaurus::playTouchSound()
398{ 367{
399 buzzer ( SHARP_BUZ_TOUCHSOUND ); 368 buzzer ( SHARP_BUZ_TOUCHSOUND );
400} 369}
401 370
402void Zaurus::playKeySound() 371void Zaurus::playKeySound()
403{ 372{
404 buzzer ( SHARP_BUZ_KEYSOUND ); 373 buzzer ( SHARP_BUZ_KEYSOUND );
405} 374}
406 375
407 376
408QValueList <OLed> Zaurus::ledList() const 377QValueList <OLed> Zaurus::ledList() const
409{ 378{
410 QValueList <OLed> vl; 379 QValueList <OLed> vl;
411 vl << Led_Mail; 380 vl << Led_Mail;
412 return vl; 381 return vl;
413} 382}
414 383
415QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 384QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
416{ 385{
417 QValueList <OLedState> vl; 386 QValueList <OLedState> vl;
418 387
419 if ( l == Led_Mail ) 388 if ( l == Led_Mail )
420 vl << Led_Off << Led_On << Led_BlinkSlow; 389 vl << Led_Off << Led_On << Led_BlinkSlow;
421 return vl; 390 return vl;
422} 391}
423 392
424OLedState Zaurus::ledState ( OLed which ) const 393OLedState Zaurus::ledState ( OLed which ) const
425{ 394{
426 if ( which == Led_Mail ) 395 if ( which == Led_Mail )
427 return m_leds [0]; 396 return m_leds [0];
428 else 397 else
429 return Led_Off; 398 return Led_Off;
430} 399}
431 400
432bool Zaurus::setLedState ( OLed which, OLedState st ) 401bool Zaurus::setLedState ( OLed which, OLedState st )
433{ 402{
434 if (!m_embedix) // Currently not supported on non_embedix kernels 403 if (!m_embedix) // Currently not supported on non_embedix kernels
435 return false; 404 return false;
436 405
437 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 406 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
438 407
439 if ( which == Led_Mail ) { 408 if ( which == Led_Mail ) {
440 if ( fd >= 0 ) { 409 if ( fd >= 0 ) {
441 struct sharp_led_status leds; 410 struct sharp_led_status leds;
442 ::memset ( &leds, 0, sizeof( leds )); 411 ::memset ( &leds, 0, sizeof( leds ));
443 leds. which = SHARP_LED_MAIL_EXISTS; 412 leds. which = SHARP_LED_MAIL_EXISTS;
444 bool ok = true; 413 bool ok = true;
445 414
446 switch ( st ) { 415 switch ( st ) {
447 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 416 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
448 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 417 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
449 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 418 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
450 default : ok = false; 419 default : ok = false;
451 } 420 }
452 421
453 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 422 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
454 m_leds [0] = st; 423 m_leds [0] = st;
455 return true; 424 return true;
456 } 425 }
457 } 426 }
458 } 427 }
459 return false; 428 return false;
460} 429}
461 430
462bool Zaurus::setSoftSuspend ( bool soft ) 431bool Zaurus::setSoftSuspend ( bool soft )
463{ 432{
464 if (!m_embedix) { 433 if (!m_embedix) {
465 /* non-Embedix kernels dont have kernel autosuspend */ 434 /* non-Embedix kernels dont have kernel autosuspend */
466 return ODevice::setSoftSuspend( soft ); 435 return ODevice::setSoftSuspend( soft );
467 } 436 }
468 437
469 bool res = false; 438 bool res = false;
470 int fd; 439 int fd;
471 440
472 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 441 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
473 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 442 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
474 443
475 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 444 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
476 445
477 if ( sources >= 0 ) { 446 if ( sources >= 0 ) {
478 if ( soft ) 447 if ( soft )
479 sources &= ~APM_EVT_POWER_BUTTON; 448 sources &= ~APM_EVT_POWER_BUTTON;
480 else 449 else
481 sources |= APM_EVT_POWER_BUTTON; 450 sources |= APM_EVT_POWER_BUTTON;
482 451
483 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 452 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
484 res = true; 453 res = true;
485 else 454 else
486 perror ( "APM_IOCGEVTSRC" ); 455 perror ( "APM_IOCGEVTSRC" );
487 } 456 }
488 else 457 else
489 perror ( "APM_IOCGEVTSRC" ); 458 perror ( "APM_IOCGEVTSRC" );
490 459
491 ::close ( fd ); 460 ::close ( fd );
492 } 461 }
493 else 462 else
494 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 463 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
495 464
496 return res; 465 return res;
497} 466}
498 467
499 468
500bool Zaurus::setDisplayBrightness ( int bright ) 469bool Zaurus::setDisplayBrightness ( int bright )
501{ 470{
502 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 471 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
503 bool res = false; 472 bool res = false;
504 int fd; 473 int fd;
505 474
506 if ( bright > 255 ) bright = 255; 475 if ( bright > 255 ) bright = 255;
507 if ( bright < 0 ) bright = 0; 476 if ( bright < 0 ) bright = 0;
508 477
509 if ( m_embedix ) 478 if ( m_embedix )
510 { 479 {
511 if ( d->m_model == Model_Zaurus_SLC7x0 ) 480 if ( d->m_model == Model_Zaurus_SLC7x0 )
512 { 481 {
513 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 482 //qDebug( "using special treatment for devices with the corgi backlight interface" );
514 // special treatment for devices with the corgi backlight interface 483 // special treatment for devices with the corgi backlight interface
515 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 484 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
516 { 485 {
517 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 486 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
518 char writeCommand[100]; 487 char writeCommand[100];
519 const int count = sprintf( writeCommand, "0x%x\n", value ); 488 const int count = sprintf( writeCommand, "0x%x\n", value );
520 res = ( ::write ( fd, writeCommand, count ) != -1 ); 489 res = ( ::write ( fd, writeCommand, count ) != -1 );
521 ::close ( fd ); 490 ::close ( fd );
522 } 491 }
523 return res; 492 return res;
524 } 493 }
525 else 494 else
526 { 495 {
527 // standard treatment for devices with the dumb embedix frontlight interface 496 // standard treatment for devices with the dumb embedix frontlight interface
528 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 497 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
529 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 498 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
530 if ( bright && !bl ) 499 if ( bright && !bl )
531 bl = 1; 500 bl = 1;
532 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 501 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
533 ::close ( fd ); 502 ::close ( fd );
534 } 503 }
535 } 504 }
536 } 505 }
537 else 506 else
538 { 507 {
539 // special treatment for the OpenZaurus unified interface 508 // special treatment for the OpenZaurus unified interface
540 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 509 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
541 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 510 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
542 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 511 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
543 ::close ( fd ); 512 ::close ( fd );
544 } 513 }
545 } 514 }
546 return res; 515 return res;
547} 516}
548 517
549bool Zaurus::suspend() 518bool Zaurus::suspend()
550{ 519{
551 qDebug("ODevice::suspend"); 520 qDebug("ODevice::suspend");
552 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 521 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
553 return false; 522 return false;
554 523
555 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 524 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
556 return false; 525 return false;
557 526
558 bool res = false; 527 bool res = false;
559 ODevice::sendSuspendmsg(); 528 ODevice::sendSuspendmsg();
560 529
561 struct timeval tvs, tvn; 530 struct timeval tvs, tvn;
562 ::gettimeofday ( &tvs, 0 ); 531 ::gettimeofday ( &tvs, 0 );
563 532
564 ::sync(); // flush fs caches 533 ::sync(); // flush fs caches
565 res = ( ::system ( "apm --suspend" ) == 0 ); 534 res = ( ::system ( "apm --suspend" ) == 0 );
566 535
567 // This is needed because the iPAQ apm implementation is asynchronous and we 536 // This is needed because the iPAQ apm implementation is asynchronous and we
568 // can not be sure when exactly the device is really suspended 537 // can not be sure when exactly the device is really suspended
569 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 538 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
570 539
571 if ( res ) { 540 if ( res ) {
572 do { // Yes, wait 15 seconds. This APM bug sucks big time. 541 do { // Yes, wait 15 seconds. This APM bug sucks big time.
573 ::usleep ( 200 * 1000 ); 542 ::usleep ( 200 * 1000 );
574 ::gettimeofday ( &tvn, 0 ); 543 ::gettimeofday ( &tvn, 0 );
575 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 544 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
576 } 545 }
577 546
578 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 547 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
579 return res; 548 return res;
580} 549}
581 550
582 551
583Transformation Zaurus::rotation() const 552Transformation Zaurus::rotation() const
584{ 553{
585 Transformation rot; 554 Transformation rot;
586 int handle = 0; 555 int handle = 0;
587 int retval = 0; 556 int retval = 0;
588 557
589 switch ( d->m_model ) { 558 switch ( d->m_model ) {
590 case Model_Zaurus_SLC7x0: 559 case Model_Zaurus_SLC7x0:
591 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 560 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
592 if (handle == -1) { 561 if (handle == -1) {
593 return Rot270; 562 return Rot270;
594 } else { 563 } else {
595 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 564 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
596 ::close (handle); 565 ::close (handle);
597 566
598 if (retval == 2 ) 567 if (retval == 2 )
599 rot = Rot0; 568 rot = Rot0;
600 else 569 else
601 rot = Rot270; 570 rot = Rot270;
602 } 571 }
603 break; 572 break;
604 case Model_Zaurus_SLA300: 573 case Model_Zaurus_SLA300:
605 case Model_Zaurus_SLB600: 574 case Model_Zaurus_SLB600:
606 case Model_Zaurus_SL5500: 575 case Model_Zaurus_SL5500:
607 case Model_Zaurus_SL5000: 576 case Model_Zaurus_SL5000:
608 default: 577 default:
609 rot = d->m_rotation; 578 rot = d->m_rotation;
610 break; 579 break;
611 } 580 }
612 581
613 return rot; 582 return rot;