summaryrefslogtreecommitdiff
authorerik <erik>2007-02-08 21:46:07 (UTC)
committer erik <erik>2007-02-08 21:46:07 (UTC)
commit497621fb3ba39ea511842a30cddfcdbda090e7ba (patch) (unidiff)
tree13e70fb1840b7cc1c7b3a16ff9b6e71925b76b57
parent63f64a9733d5504bb04d5f06cdf52b42a4b8006c (diff)
downloadopie-497621fb3ba39ea511842a30cddfcdbda090e7ba.zip
opie-497621fb3ba39ea511842a30cddfcdbda090e7ba.tar.gz
opie-497621fb3ba39ea511842a30cddfcdbda090e7ba.tar.bz2
This commit provides the necessary changes and new files for Opie to
have partial support for the Palm LD, TX and Z72 handheld computers. This commit is based on a patch submitted by Cristiano to the opie-devel list. The patch itself comprises work done by Alex Osborne, Cristiano, Sergey Lapin, Jan Herman and Aaron. Thanks goes to them for sticking with the patch and expanding the number of devices Opie works on.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/device.pro6
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
-rw-r--r--libopie2/opiecore/device/odevice.h7
-rw-r--r--libopie2/opiecore/device/odevice_palm.cpp282
-rw-r--r--libopie2/opiecore/device/odevice_palm.h72
5 files changed, 367 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro
index b517032..2fd5ded 100644
--- a/libopie2/opiecore/device/device.pro
+++ b/libopie2/opiecore/device/device.pro
@@ -1,30 +1,32 @@
1HEADERS += device/odevice.h \ 1HEADERS += device/odevice.h \
2 device/odevicebutton.h \ 2 device/odevicebutton.h \
3 device/odevice_abstractmobiledevice.h \ 3 device/odevice_abstractmobiledevice.h \
4 device/odevice_beagle.h \ 4 device/odevice_beagle.h \
5 device/odevice_ipaq.h \ 5 device/odevice_ipaq.h \
6 device/odevice_jornada.h \ 6 device/odevice_jornada.h \
7 device/odevice_ramses.h \ 7 device/odevice_ramses.h \
8 device/odevice_simpad.h \ 8 device/odevice_simpad.h \
9 device/odevice_zaurus.h \ 9 device/odevice_zaurus.h \
10 device/odevice_genuineintel.h \ 10 device/odevice_genuineintel.h \
11 device/odevice_yopy.h \ 11 device/odevice_yopy.h \
12 device/odevice_mypal.h \ 12 device/odevice_mypal.h \
13 device/odevice_htc.h \ 13 device/odevice_htc.h \
14 device/odevice_motorola_ezx.h 14 device/odevice_motorola_ezx.h \
15 device/odevice_palm.h
15 16
16SOURCES += device/odevice.cpp \ 17SOURCES += device/odevice.cpp \
17 device/odevicebutton.cpp \ 18 device/odevicebutton.cpp \
18 device/odevice_abstractmobiledevice.cpp \ 19 device/odevice_abstractmobiledevice.cpp \
19 device/odevice_beagle.cpp \ 20 device/odevice_beagle.cpp \
20 device/odevice_ipaq.cpp \ 21 device/odevice_ipaq.cpp \
21 device/odevice_jornada.cpp\ 22 device/odevice_jornada.cpp\
22 device/odevice_ramses.cpp \ 23 device/odevice_ramses.cpp \
23 device/odevice_simpad.cpp \ 24 device/odevice_simpad.cpp \
24 device/odevice_zaurus.cpp \ 25 device/odevice_zaurus.cpp \
25 device/odevice_genuineintel.cpp \ 26 device/odevice_genuineintel.cpp \
26 device/odevice_yopy.cpp \ 27 device/odevice_yopy.cpp \
27 device/odevice_mypal.cpp \ 28 device/odevice_mypal.cpp \
28 device/odevice_htc.cpp \ 29 device/odevice_htc.cpp \
29 device/odevice_motorola_ezx.cpp 30 device/odevice_motorola_ezx.cpp \
31 device/odevice_palm.cpp
30 32
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 8f5be8b..e4233eb 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,822 +1,824 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2002-2006 The Opie Team <opie-devel@handhelds.org> 3 =. (C) 2002-2006 The Opie Team <opie-devel@handhelds.org>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30 30
31#include "odevice_beagle.h" 31#include "odevice_beagle.h"
32#include "odevice_ipaq.h" 32#include "odevice_ipaq.h"
33#include "odevice_mypal.h" 33#include "odevice_mypal.h"
34#include "odevice_jornada.h" 34#include "odevice_jornada.h"
35#include "odevice_ramses.h" 35#include "odevice_ramses.h"
36#include "odevice_simpad.h" 36#include "odevice_simpad.h"
37#include "odevice_yopy.h" 37#include "odevice_yopy.h"
38#include "odevice_zaurus.h" 38#include "odevice_zaurus.h"
39#include "odevice_genuineintel.h" 39#include "odevice_genuineintel.h"
40#include "odevice_htc.h" 40#include "odevice_htc.h"
41#include "odevice_motorola_ezx.h" 41#include "odevice_motorola_ezx.h"
42#include "odevice_palm.h"
42 43
43/* QT */ 44/* QT */
44#include <qapplication.h> 45#include <qapplication.h>
45#include <qfile.h> 46#include <qfile.h>
46#include <qtextstream.h> 47#include <qtextstream.h>
47#include <qwindowsystem_qws.h> 48#include <qwindowsystem_qws.h>
48 49
49/* OPIE */ 50/* OPIE */
50#include <qpe/config.h> 51#include <qpe/config.h>
51#include <qpe/sound.h> 52#include <qpe/sound.h>
52#include <qpe/qcopenvelope_qws.h> 53#include <qpe/qcopenvelope_qws.h>
53#include <qpe/sound.h> 54#include <qpe/sound.h>
54 55
55#include <opie2/okeyfilter.h> 56#include <opie2/okeyfilter.h>
56#include <opie2/oresource.h> 57#include <opie2/oresource.h>
57 58
58/* STD */ 59/* STD */
59#include <fcntl.h> 60#include <fcntl.h>
60#include <math.h> 61#include <math.h>
61#include <stdlib.h> 62#include <stdlib.h>
62#include <signal.h> 63#include <signal.h>
63#include <sys/ioctl.h> 64#include <sys/ioctl.h>
64#include <sys/time.h> 65#include <sys/time.h>
65#include <unistd.h> 66#include <unistd.h>
66#ifndef QT_NO_SOUND 67#ifndef QT_NO_SOUND
67#include <linux/soundcard.h> 68#include <linux/soundcard.h>
68#endif 69#endif
69 70
70namespace Opie { 71namespace Opie {
71namespace Core { 72namespace Core {
72 73
73static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 74static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
74 75
75 76
76/* STATIC and common implementation */ 77/* STATIC and common implementation */
77/* EXPORT */ ODistribution distributions[] = { 78/* EXPORT */ ODistribution distributions[] = {
78 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 79 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
79 { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, 80 { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" },
80 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 81 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
81 { System_Unknown, "Linux", "/etc/issue" }, 82 { System_Unknown, "Linux", "/etc/issue" },
82}; 83};
83 84
84 85
85/* EXPORT */ bool isQWS(){ 86/* EXPORT */ bool isQWS(){
86 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 87 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
87} 88}
88 89
89/* EXPORT */ QCString makeChannel ( const char *str ){ 90/* EXPORT */ QCString makeChannel ( const char *str ){
90 if ( str && !::strchr ( str, '/' )) 91 if ( str && !::strchr ( str, '/' ))
91 return QCString ( "QPE/Application/" ) + str; 92 return QCString ( "QPE/Application/" ) + str;
92 else 93 else
93 return str; 94 return str;
94} 95}
95 96
96 97
97 98
98/* Now the default implementation of ODevice */ 99/* Now the default implementation of ODevice */
99 100
100struct default_button default_buttons [] = { 101struct default_button default_buttons [] = {
101 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 102 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
102 "devicebuttons/z_calendar", 103 "devicebuttons/z_calendar",
103 "datebook", "nextView()", 104 "datebook", "nextView()",
104 "today", "raise()" }, 105 "today", "raise()" },
105 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 106 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
106 "devicebuttons/z_contact", 107 "devicebuttons/z_contact",
107 "addressbook", "raise()", 108 "addressbook", "raise()",
108 "addressbook", "beamBusinessCard()" }, 109 "addressbook", "beamBusinessCard()" },
109 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 110 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
110 "devicebuttons/z_home", 111 "devicebuttons/z_home",
111 "QPE/Launcher", "home()", 112 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 113 "buttonsettings", "raise()" },
113 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 114 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
114 "devicebuttons/z_menu", 115 "devicebuttons/z_menu",
115 "QPE/TaskBar", "toggleMenu()", 116 "QPE/TaskBar", "toggleMenu()",
116 "QPE/TaskBar", "toggleStartMenu()" }, 117 "QPE/TaskBar", "toggleStartMenu()" },
117 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 118 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
118 "devicebuttons/z_mail", 119 "devicebuttons/z_mail",
119 "opiemail", "raise()", 120 "opiemail", "raise()",
120 "opiemail", "newMail()" }, 121 "opiemail", "newMail()" },
121}; 122};
122 123
123ODevice *ODevice::inst() 124ODevice *ODevice::inst()
124{ 125{
125 static ODevice *dev = 0; 126 static ODevice *dev = 0;
126 QString cpu_info; 127 QString cpu_info;
127 128
128 if ( !dev ) 129 if ( !dev )
129 { 130 {
130 QFile f( PATH_PROC_CPUINFO ); 131 QFile f( PATH_PROC_CPUINFO );
131 if ( f.open( IO_ReadOnly ) ) 132 if ( f.open( IO_ReadOnly ) )
132 { 133 {
133 QTextStream s( &f ); 134 QTextStream s( &f );
134 while ( !s.atEnd() ) 135 while ( !s.atEnd() )
135 { 136 {
136 QString line; 137 QString line;
137 line = s.readLine(); 138 line = s.readLine();
138 if ( line.startsWith( "Hardware" ) ) 139 if ( line.startsWith( "Hardware" ) )
139 { 140 {
140 qDebug( "ODevice() - found '%s'", (const char*) line ); 141 qDebug( "ODevice() - found '%s'", (const char*) line );
141 cpu_info = line; 142 cpu_info = line;
142 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 143 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
143 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 144 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
144 else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal(); 145 else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal();
145 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 146 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
146 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 147 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
147 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 148 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
148 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 149 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
149 else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC(); 150 else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC();
150 else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX(); 151 else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX();
152 else if ( line.contains( "Palm", false ) ) dev = new Internal::Palm();
151 153
152 else qWarning( "ODevice() - unknown hardware - using default." ); 154 else qWarning( "ODevice() - unknown hardware - using default." );
153 break; 155 break;
154 } else if ( line.startsWith( "vendor_id" ) ) { 156 } else if ( line.startsWith( "vendor_id" ) ) {
155 qDebug( "ODevice() - found '%s'", (const char*) line ); 157 qDebug( "ODevice() - found '%s'", (const char*) line );
156 cpu_info = line; 158 cpu_info = line;
157 if( line.contains( "genuineintel", false ) ) { 159 if( line.contains( "genuineintel", false ) ) {
158 dev = new Internal::GenuineIntel(); 160 dev = new Internal::GenuineIntel();
159 break; 161 break;
160 } 162 }
161 } 163 }
162 } 164 }
163 } 165 }
164 else 166 else
165 { 167 {
166 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 168 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
167 } 169 }
168 if ( !dev ) dev = new ODevice(); 170 if ( !dev ) dev = new ODevice();
169 dev->init(cpu_info); 171 dev->init(cpu_info);
170 } 172 }
171 return dev; 173 return dev;
172} 174}
173 175
174ODevice::ODevice() 176ODevice::ODevice()
175{ 177{
176 d = new ODeviceData; 178 d = new ODeviceData;
177 179
178 d->m_modelstr = "Unknown"; 180 d->m_modelstr = "Unknown";
179 d->m_model = Model_Unknown; 181 d->m_model = Model_Unknown;
180 d->m_vendorstr = "Unknown"; 182 d->m_vendorstr = "Unknown";
181 d->m_vendor = Vendor_Unknown; 183 d->m_vendor = Vendor_Unknown;
182 d->m_systemstr = "Unknown"; 184 d->m_systemstr = "Unknown";
183 d->m_system = System_Unknown; 185 d->m_system = System_Unknown;
184 d->m_sysverstr = "0.0"; 186 d->m_sysverstr = "0.0";
185 d->m_rotation = Rot0; 187 d->m_rotation = Rot0;
186 d->m_direction = CW; 188 d->m_direction = CW;
187 d->m_qteDriver = "Transformed"; 189 d->m_qteDriver = "Transformed";
188 190
189 d->m_holdtime = 1000; // 1000ms 191 d->m_holdtime = 1000; // 1000ms
190 d->m_buttons = 0; 192 d->m_buttons = 0;
191 d->m_cpu_frequencies = new QStrList; 193 d->m_cpu_frequencies = new QStrList;
192 194
193 195
194 /* mixer */ 196 /* mixer */
195 d->m_sound = d->m_vol = d->m_mixer = -1; 197 d->m_sound = d->m_vol = d->m_mixer = -1;
196 198
197 /* System QCopChannel created */ 199 /* System QCopChannel created */
198 d->m_initializedButtonQcop = false; 200 d->m_initializedButtonQcop = false;
199 201
200 // New distribution detection code first checks for legacy distributions, 202 // New distribution detection code first checks for legacy distributions,
201 // identified by /etc/familiar-version or /etc/oz_version. 203 // identified by /etc/familiar-version or /etc/oz_version.
202 // Then check for OpenEmbedded and lastly, read /etc/issue 204 // Then check for OpenEmbedded and lastly, read /etc/issue
203 205
204 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) 206 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i )
205 { 207 {
206 if ( QFile::exists( distributions[i].sysvfile ) ) 208 if ( QFile::exists( distributions[i].sysvfile ) )
207 { 209 {
208 d->m_systemstr = distributions[i].sysstr; 210 d->m_systemstr = distributions[i].sysstr;
209 d->m_system = distributions[i].system; 211 d->m_system = distributions[i].system;
210 d->m_sysverstr = "<Unknown>"; 212 d->m_sysverstr = "<Unknown>";
211 QFile f( distributions[i].sysvfile ); 213 QFile f( distributions[i].sysvfile );
212 if ( f.open( IO_ReadOnly ) ) 214 if ( f.open( IO_ReadOnly ) )
213 { 215 {
214 QTextStream ts( &f ); 216 QTextStream ts( &f );
215 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 217 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
216 } 218 }
217 break; 219 break;
218 } 220 }
219 } 221 }
220} 222}
221 223
222void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 224void ODevice::systemMessage( const QCString &msg, const QByteArray & )
223{ 225{
224 if ( msg == "deviceButtonMappingChanged()" ) { 226 if ( msg == "deviceButtonMappingChanged()" ) {
225 reloadButtonMapping(); 227 reloadButtonMapping();
226 } 228 }
227} 229}
228 230
229void ODevice::init(const QString&) 231void ODevice::init(const QString&)
230{ 232{
231} 233}
232 234
233/** 235/**
234* This method initialises the button mapping 236* This method initialises the button mapping
235*/ 237*/
236void ODevice::initButtons() 238void ODevice::initButtons()
237{ 239{
238 if ( d->m_buttons ) 240 if ( d->m_buttons )
239 return; 241 return;
240 242
241 qDebug ( "init Buttons" ); 243 qDebug ( "init Buttons" );
242 d->m_buttons = new QValueList <ODeviceButton>; 244 d->m_buttons = new QValueList <ODeviceButton>;
243 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 245 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
244 default_button *db = default_buttons + i; 246 default_button *db = default_buttons + i;
245 ODeviceButton b; 247 ODeviceButton b;
246 b. setKeycode ( db->code ); 248 b. setKeycode ( db->code );
247 b. setUserText ( QObject::tr ( "Button", db->utext )); 249 b. setUserText ( QObject::tr ( "Button", db->utext ));
248 b. setPixmap ( OResource::loadPixmap ( db->pix )); 250 b. setPixmap ( OResource::loadPixmap ( db->pix ));
249 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 251 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
250 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 252 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
251 d->m_buttons->append ( b ); 253 d->m_buttons->append ( b );
252 } 254 }
253 255
254 reloadButtonMapping(); 256 reloadButtonMapping();
255} 257}
256 258
257ODevice::~ODevice() 259ODevice::~ODevice()
258{ 260{
259// we leak m_devicebuttons and m_cpu_frequency 261// we leak m_devicebuttons and m_cpu_frequency
260// but it's a singleton and it is not so importantant 262// but it's a singleton and it is not so importantant
261// -zecke 263// -zecke
262 delete d; 264 delete d;
263} 265}
264 266
265/** 267/**
266* This method will try to suspend the device 268* This method will try to suspend the device
267* It only works if the user is the QWS Server and the apm application 269* It only works if the user is the QWS Server and the apm application
268* is installed. 270* is installed.
269* It tries to suspend and then waits some time cause some distributions 271* It tries to suspend and then waits some time cause some distributions
270* do have asynchronus apm implementations. 272* do have asynchronus apm implementations.
271* This method will either fail and return false or it'll suspend the 273* This method will either fail and return false or it'll suspend the
272* device and return once the device got woken up 274* device and return once the device got woken up
273* 275*
274* @return if the device got suspended 276* @return if the device got suspended
275*/ 277*/
276bool ODevice::suspend() 278bool ODevice::suspend()
277{ 279{
278 return false; // default implementation == unknown device or qvfb 280 return false; // default implementation == unknown device or qvfb
279} 281}
280 282
281/** 283/**
282* This sets the display on or off 284* This sets the display on or off
283*/ 285*/
284bool ODevice::setDisplayStatus( bool on ) 286bool ODevice::setDisplayStatus( bool on )
285{ 287{
286 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); 288 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on );
287 return false; // don't do anything for unknown models 289 return false; // don't do anything for unknown models
288} 290}
289 291
290/** 292/**
291* This sets the display brightness 293* This sets the display brightness
292* 294*
293* @param b The brightness to be set on a scale from 0 to 255 295* @param b The brightness to be set on a scale from 0 to 255
294* @return success or failure 296* @return success or failure
295*/ 297*/
296bool ODevice::setDisplayBrightness( int b ) 298bool ODevice::setDisplayBrightness( int b )
297{ 299{
298 qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); 300 qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b );
299 return false; 301 return false;
300} 302}
301 303
302/** 304/**
303 * 305 *
304 * @returns the number of steppings on the brightness slider 306 * @returns the number of steppings on the brightness slider
305 * in the Light-'n-Power settings. Values smaller than zero and bigger 307 * in the Light-'n-Power settings. Values smaller than zero and bigger
306 * than 255 do not make sense. 308 * than 255 do not make sense.
307 * 309 *
308 * \sa QSlider::setLineStep 310 * \sa QSlider::setLineStep
309 * \sa QSlider::setPageStep 311 * \sa QSlider::setPageStep
310 */ 312 */
311int ODevice::displayBrightnessResolution() const 313int ODevice::displayBrightnessResolution() const
312{ 314{
313 qDebug( "ODevice::displayBrightnessResolution() - please override me." ); 315 qDebug( "ODevice::displayBrightnessResolution() - please override me." );
314 return 16; 316 return 16;
315} 317}
316 318
317/** 319/**
318* This sets the display contrast 320* This sets the display contrast
319* @param p The contrast to be set on a scale from 0 to 255 321* @param p The contrast to be set on a scale from 0 to 255
320* @returns success or failure 322* @returns success or failure
321*/ 323*/
322bool ODevice::setDisplayContrast( int p ) 324bool ODevice::setDisplayContrast( int p )
323{ 325{
324 qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); 326 qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p );
325 return false; 327 return false;
326} 328}
327 329
328/** 330/**
329* @returns the maximum value for the contrast settings slider 331* @returns the maximum value for the contrast settings slider
330* or 0 if the device doesn't support setting of a contrast 332* or 0 if the device doesn't support setting of a contrast
331*/ 333*/
332int ODevice::displayContrastResolution() const 334int ODevice::displayContrastResolution() const
333{ 335{
334 qDebug( "ODevice::displayBrightnessResolution() - please override me." ); 336 qDebug( "ODevice::displayBrightnessResolution() - please override me." );
335 return 0; 337 return 0;
336} 338}
337 339
338/** 340/**
339* This returns the vendor as string 341* This returns the vendor as string
340* @return Vendor as QString 342* @return Vendor as QString
341*/ 343*/
342QString ODevice::vendorString() const 344QString ODevice::vendorString() const
343{ 345{
344 return d->m_vendorstr; 346 return d->m_vendorstr;
345} 347}
346 348
347/** 349/**
348* This returns the vendor as one of the values of OVendor 350* This returns the vendor as one of the values of OVendor
349* @return OVendor 351* @return OVendor
350*/ 352*/
351OVendor ODevice::vendor() const 353OVendor ODevice::vendor() const
352{ 354{
353 return d->m_vendor; 355 return d->m_vendor;
354} 356}
355 357
356/** 358/**
357* This returns the model as a string 359* This returns the model as a string
358* @return A string representing the model 360* @return A string representing the model
359*/ 361*/
360QString ODevice::modelString() const 362QString ODevice::modelString() const
361{ 363{
362 return d->m_modelstr; 364 return d->m_modelstr;
363} 365}
364 366
365/** 367/**
366* This does return the OModel used 368* This does return the OModel used
367*/ 369*/
368OModel ODevice::model() const 370OModel ODevice::model() const
369{ 371{
370 return d->m_model; 372 return d->m_model;
371} 373}
372 374
373/** 375/**
374* This does return the systen name 376* This does return the systen name
375*/ 377*/
376QString ODevice::systemString() const 378QString ODevice::systemString() const
377{ 379{
378 return d->m_systemstr; 380 return d->m_systemstr;
379} 381}
380 382
381/** 383/**
382* Return System as OSystem value 384* Return System as OSystem value
383*/ 385*/
384OSystem ODevice::system() const 386OSystem ODevice::system() const
385{ 387{
386 return d->m_system; 388 return d->m_system;
387} 389}
388 390
389/** 391/**
390* @return the version string of the base system 392* @return the version string of the base system
391*/ 393*/
392QString ODevice::systemVersionString() const 394QString ODevice::systemVersionString() const
393{ 395{
394 return d->m_sysverstr; 396 return d->m_sysverstr;
395} 397}
396 398
397/** 399/**
398* @return the current Transformation 400* @return the current Transformation
399*/ 401*/
400Transformation ODevice::rotation() const 402Transformation ODevice::rotation() const
401{ 403{
402 return d->m_rotation; 404 return d->m_rotation;
403} 405}
404 406
405/** 407/**
406* @return the current rotation direction 408* @return the current rotation direction
407*/ 409*/
408ODirection ODevice::direction() const 410ODirection ODevice::direction() const
409{ 411{
410 return d->m_direction; 412 return d->m_direction;
411} 413}
412 414
413QString ODevice::qteDriver() const 415QString ODevice::qteDriver() const
414{ 416{
415 return d->m_qteDriver; 417 return d->m_qteDriver;
416} 418}
417 419
418/** 420/**
419* This plays an alarm sound 421* This plays an alarm sound
420*/ 422*/
421void ODevice::playAlarmSound() 423void ODevice::playAlarmSound()
422{ 424{
423#ifndef QT_NO_SOUND 425#ifndef QT_NO_SOUND
424 static Sound snd ( "alarm" ); 426 static Sound snd ( "alarm" );
425 427
426 if ( snd. isFinished()) 428 if ( snd. isFinished())
427 snd. play(); 429 snd. play();
428#endif 430#endif
429} 431}
430 432
431/** 433/**
432* This plays a key sound 434* This plays a key sound
433*/ 435*/
434void ODevice::playKeySound() 436void ODevice::playKeySound()
435{ 437{
436#ifndef QT_NO_SOUND 438#ifndef QT_NO_SOUND
437 static Sound snd ( "keysound" ); 439 static Sound snd ( "keysound" );
438 440
439 if ( snd. isFinished()) 441 if ( snd. isFinished())
440 snd. play(); 442 snd. play();
441#endif 443#endif
442} 444}
443 445
444/** 446/**
445* This plays a touch sound 447* This plays a touch sound
446*/ 448*/
447void ODevice::playTouchSound() 449void ODevice::playTouchSound()
448{ 450{
449#ifndef QT_NO_SOUND 451#ifndef QT_NO_SOUND
450 static Sound snd ( "touchsound" ); 452 static Sound snd ( "touchsound" );
451 453
452 if ( snd. isFinished()) 454 if ( snd. isFinished())
453 snd. play(); 455 snd. play();
454#endif 456#endif
455} 457}
456 458
457/** 459/**
458* This method will return a list of leds 460* This method will return a list of leds
459* available on this device 461* available on this device
460* @return a list of LEDs. 462* @return a list of LEDs.
461*/ 463*/
462QValueList <OLed> ODevice::ledList() const 464QValueList <OLed> ODevice::ledList() const
463{ 465{
464 return QValueList <OLed>(); 466 return QValueList <OLed>();
465} 467}
466 468
467/** 469/**
468* This does return the state of the LEDs 470* This does return the state of the LEDs
469*/ 471*/
470QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 472QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
471{ 473{
472 return QValueList <OLedState>(); 474 return QValueList <OLedState>();
473} 475}
474 476
475/** 477/**
476* @return the state for a given OLed 478* @return the state for a given OLed
477*/ 479*/
478OLedState ODevice::ledState ( OLed /*which*/ ) const 480OLedState ODevice::ledState ( OLed /*which*/ ) const
479{ 481{
480 return Led_Off; 482 return Led_Off;
481} 483}
482 484
483/** 485/**
484* Set the state for a LED 486* Set the state for a LED
485* @param which Which OLed to use 487* @param which Which OLed to use
486* @param st The state to set 488* @param st The state to set
487* @return success or failure 489* @return success or failure
488*/ 490*/
489bool ODevice::setLedState ( OLed which, OLedState st ) 491bool ODevice::setLedState ( OLed which, OLedState st )
490{ 492{
491 Q_UNUSED( which ) 493 Q_UNUSED( which )
492 Q_UNUSED( st ) 494 Q_UNUSED( st )
493 return false; 495 return false;
494} 496}
495 497
496/** 498/**
497* @return if the device has a light sensor 499* @return if the device has a light sensor
498*/ 500*/
499bool ODevice::hasLightSensor() const 501bool ODevice::hasLightSensor() const
500{ 502{
501 return false; 503 return false;
502} 504}
503 505
504/** 506/**
505* @return a value from the light sensor 507* @return a value from the light sensor
506*/ 508*/
507int ODevice::readLightSensor() 509int ODevice::readLightSensor()
508{ 510{
509 return -1; 511 return -1;
510} 512}
511 513
512/** 514/**
513* @return the light sensor resolution 515* @return the light sensor resolution
514*/ 516*/
515int ODevice::lightSensorResolution() const 517int ODevice::lightSensorResolution() const
516{ 518{
517 return 0; 519 return 0;
518} 520}
519 521
520/** 522/**
521* @return if the device has a hinge sensor 523* @return if the device has a hinge sensor
522*/ 524*/
523bool ODevice::hasHingeSensor() const 525bool ODevice::hasHingeSensor() const
524{ 526{
525 return false; 527 return false;
526} 528}
527 529
528/** 530/**
529* @return a value from the hinge sensor 531* @return a value from the hinge sensor
530*/ 532*/
531OHingeStatus ODevice::readHingeSensor()const 533OHingeStatus ODevice::readHingeSensor()const
532{ 534{
533 return CASE_UNKNOWN; 535 return CASE_UNKNOWN;
534} 536}
535 537
536/** 538/**
537* @return a list with CPU frequencies supported by the hardware 539* @return a list with CPU frequencies supported by the hardware
538*/ 540*/
539const QStrList &ODevice::allowedCpuFrequencies() const 541const QStrList &ODevice::allowedCpuFrequencies() const
540{ 542{
541 return *d->m_cpu_frequencies; 543 return *d->m_cpu_frequencies;
542} 544}
543 545
544 546
545/** 547/**
546* Set desired CPU frequency 548* Set desired CPU frequency
547* 549*
548* @param index index into d->m_cpu_frequencies of the frequency to be set 550* @param index index into d->m_cpu_frequencies of the frequency to be set
549*/ 551*/
550bool ODevice::setCurrentCpuFrequency(uint index) 552bool ODevice::setCurrentCpuFrequency(uint index)
551{ 553{
552 if (index >= d->m_cpu_frequencies->count()) 554 if (index >= d->m_cpu_frequencies->count())
553 return false; 555 return false;
554 556
555 char *freq = d->m_cpu_frequencies->at(index); 557 char *freq = d->m_cpu_frequencies->at(index);
556 qWarning("set freq to %s", freq); 558 qWarning("set freq to %s", freq);
557 559
558 int fd; 560 int fd;
559 561
560 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 562 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
561 char writeCommand[50]; 563 char writeCommand[50];
562 const int count = sprintf(writeCommand, "%s\n", freq); 564 const int count = sprintf(writeCommand, "%s\n", freq);
563 int res = (::write(fd, writeCommand, count) != -1); 565 int res = (::write(fd, writeCommand, count) != -1);
564 ::close(fd); 566 ::close(fd);
565 return res; 567 return res;
566 } 568 }
567 569
568 return false; 570 return false;
569} 571}
570 572
571 573
572/** 574/**
573* @return a list of hardware buttons 575* @return a list of hardware buttons
574*/ 576*/
575const QValueList <ODeviceButton> &ODevice::buttons() 577const QValueList <ODeviceButton> &ODevice::buttons()
576{ 578{
577 initButtons(); 579 initButtons();
578 580
579 return *d->m_buttons; 581 return *d->m_buttons;
580} 582}
581 583
582/** 584/**
583* @return The amount of time that would count as a hold 585* @return The amount of time that would count as a hold
584*/ 586*/
585uint ODevice::buttonHoldTime() const 587uint ODevice::buttonHoldTime() const
586{ 588{
587 return d->m_holdtime; 589 return d->m_holdtime;
588} 590}
589 591
590/** 592/**
591* This method return a ODeviceButton for a key code 593* This method return a ODeviceButton for a key code
592* or 0 if no special hardware button is available for the device 594* or 0 if no special hardware button is available for the device
593* 595*
594* @return The devicebutton or 0l 596* @return The devicebutton or 0l
595* @see ODeviceButton 597* @see ODeviceButton
596*/ 598*/
597const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 599const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
598{ 600{
599 initButtons(); 601 initButtons();
600 602
601 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 603 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
602 if ( (*it).keycode() == code ) 604 if ( (*it).keycode() == code )
603 return &(*it); 605 return &(*it);
604 } 606 }
605 return 0; 607 return 0;
606} 608}
607 609
608void ODevice::reloadButtonMapping() 610void ODevice::reloadButtonMapping()
609{ 611{
610 if(!d->m_buttons) 612 if(!d->m_buttons)
611 initButtons(); 613 initButtons();
612 614
613 if(!d->m_initializedButtonQcop) { 615 if(!d->m_initializedButtonQcop) {
614 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); 616 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel");
615 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), 617 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)),
616 this,SLOT(systemMessage(const QCString&,const QByteArray&))); 618 this,SLOT(systemMessage(const QCString&,const QByteArray&)));
617 d->m_initializedButtonQcop = true; 619 d->m_initializedButtonQcop = true;
618 } 620 }
619 621
620 Config cfg ( "ButtonSettings" ); 622 Config cfg ( "ButtonSettings" );
621 623
622 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 624 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
623 ODeviceButton &b = ( *d->m_buttons ) [i]; 625 ODeviceButton &b = ( *d->m_buttons ) [i];
624 QString group = "Button" + QString::number ( i ); 626 QString group = "Button" + QString::number ( i );
625 627
626 QCString pch, hch; 628 QCString pch, hch;
627 QCString pm, hm; 629 QCString pm, hm;
628 QByteArray pdata, hdata; 630 QByteArray pdata, hdata;
629 631
630 if ( cfg. hasGroup ( group )) { 632 if ( cfg. hasGroup ( group )) {
631 cfg. setGroup ( group ); 633 cfg. setGroup ( group );
632 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 634 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
633 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 635 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
634 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 636 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
635 637
636 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 638 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
637 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 639 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
638 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 640 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
639 } 641 }
640 642
641 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 643 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
642 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 644 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
643 } 645 }
644} 646}
645 647
646void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 648void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
647{ 649{
648 initButtons(); 650 initButtons();
649 651
650 QString mb_chan; 652 QString mb_chan;
651 653
652 if ( button >= (int) d->m_buttons->count()) 654 if ( button >= (int) d->m_buttons->count())
653 return; 655 return;
654 656
655 ODeviceButton &b = ( *d->m_buttons ) [button]; 657 ODeviceButton &b = ( *d->m_buttons ) [button];
656 b. setPressedAction ( action ); 658 b. setPressedAction ( action );
657 659
658 mb_chan=b. pressedAction(). channel(); 660 mb_chan=b. pressedAction(). channel();
659 661
660 Config buttonFile ( "ButtonSettings" ); 662 Config buttonFile ( "ButtonSettings" );
661 buttonFile. setGroup ( "Button" + QString::number ( button )); 663 buttonFile. setGroup ( "Button" + QString::number ( button ));
662 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 664 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
663 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 665 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
664 666
665// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 667// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
666 668
667 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 669 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
668} 670}
669 671
670void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 672void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
671{ 673{
672 initButtons(); 674 initButtons();
673 675
674 if ( button >= (int) d->m_buttons->count()) 676 if ( button >= (int) d->m_buttons->count())
675 return; 677 return;
676 678
677 ODeviceButton &b = ( *d->m_buttons ) [button]; 679 ODeviceButton &b = ( *d->m_buttons ) [button];
678 b. setHeldAction ( action ); 680 b. setHeldAction ( action );
679 681
680 Config buttonFile ( "ButtonSettings" ); 682 Config buttonFile ( "ButtonSettings" );
681 buttonFile. setGroup ( "Button" + QString::number ( button )); 683 buttonFile. setGroup ( "Button" + QString::number ( button ));
682 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 684 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
683 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 685 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
684 686
685// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 687// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
686 688
687 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 689 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
688} 690}
689 691
690/** 692/**
691 * @internal 693 * @internal
692 */ 694 */
693void ODevice::virtual_hook(int, void* ){ 695void ODevice::virtual_hook(int, void* ){
694 696
695} 697}
696 698
697/** 699/**
698 * \brief Send a QCOP Message before suspending 700 * \brief Send a QCOP Message before suspending
699 * 701 *
700 * Sends a QCOP message to channel QPE/System 702 * Sends a QCOP message to channel QPE/System
701 * with the message "aboutToSuspend()" if this 703 * with the message "aboutToSuspend()" if this
702 * is the windowing server. 704 * is the windowing server.
703 * 705 *
704 * Call this in your custom \sa suspend() Method 706 * Call this in your custom \sa suspend() Method
705 * before going to suspend. 707 * before going to suspend.
706 * 708 *
707 */ 709 */
708void ODevice::sendSuspendmsg() 710void ODevice::sendSuspendmsg()
709{ 711{
710 if ( !isQWS() ) 712 if ( !isQWS() )
711 return; 713 return;
712 714
713 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 715 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
714} 716}
715 717
716/** 718/**
717 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters 719 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
718 * 720 *
719 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard 721 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
720 * Filters. This function is the only way to prepend a KeyFilter. 722 * Filters. This function is the only way to prepend a KeyFilter.
721 * 723 *
722 * @param aFilter The KeyFilter to be prepended to the list of filters 724 * @param aFilter The KeyFilter to be prepended to the list of filters
723 * 725 *
724 * @see Opie::Core::OKeyFilter 726 * @see Opie::Core::OKeyFilter
725 * @see Opie::Core::OKeyFilter::inst() 727 * @see Opie::Core::OKeyFilter::inst()
726 */ 728 */
727void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 729void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
728{ 730{
729 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 731 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
730} 732}
731 733
732/** 734/**
733 * \brief Remove the QWSServer::KeyboardFilter in the param from the list 735 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
734 * 736 *
735 * Remove the QWSServer::KeyboardFilter \par aFilter from the List 737 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
736 * of Keyfilters. Call this when you delete the KeyFilter! 738 * of Keyfilters. Call this when you delete the KeyFilter!
737 * 739 *
738 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter 740 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
739 * @see Opie::Core::ODevice::addPreHandler 741 * @see Opie::Core::ODevice::addPreHandler
740 */ 742 */
741void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 743void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
742{ 744{
743 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 745 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
744} 746}
745 747
746 748
747/** 749/**
748 * @internal 750 * @internal
749 * 751 *
750 * @see changeMixerForAlarm 752 * @see changeMixerForAlarm
751 */ 753 */
752void ODevice::playingStopped() { 754void ODevice::playingStopped() {
753 if ( sender() ) 755 if ( sender() )
754 const_cast<QObject*>(sender())->disconnect( this ); 756 const_cast<QObject*>(sender())->disconnect( this );
755 757
756#ifndef QT_NO_SOUND 758#ifndef QT_NO_SOUND
757 if ( d->m_sound >= 0 ) { 759 if ( d->m_sound >= 0 ) {
758 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); 760 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
759 ::close ( d->m_sound ); 761 ::close ( d->m_sound );
760 } 762 }
761#endif 763#endif
762} 764}
763 765
764 766
765/** 767/**
766 * \brief Change the Volume for the Alarm and set it back after playing is finished 768 * \brief Change the Volume for the Alarm and set it back after playing is finished
767 * 769 *
768 * If you play an Alarm Sound you might want to change the Mixer to 770 * If you play an Alarm Sound you might want to change the Mixer to
769 * full volume and ignore the user setting. After it \sa Sound::isFinished 771 * full volume and ignore the user setting. After it \sa Sound::isFinished
770 * you would turn the volume back to the user preference. 772 * you would turn the volume back to the user preference.
771 * The problem is that we used to enter the event loop while waiting 773 * The problem is that we used to enter the event loop while waiting
772 * for the sound to be finished triggering all kind of reentrance 774 * for the sound to be finished triggering all kind of reentrance
773 * problems what a library shouldn't introduce. 775 * problems what a library shouldn't introduce.
774 * Instead of manually waiting for the sound to be finished use 776 * Instead of manually waiting for the sound to be finished use
775 * this Method and it will automatically restore the Mixer to 777 * this Method and it will automatically restore the Mixer to
776 * the user configuration after the sound finished playing. 778 * the user configuration after the sound finished playing.
777 * 779 *
778 * Note: The onwership of \param snd is not transfered and playing 780 * Note: The onwership of \param snd is not transfered and playing
779 * is not started in this method. If 'snd' gets deleted before 781 * is not started in this method. If 'snd' gets deleted before
780 * playing is finished the volume doesn't get set back to 782 * playing is finished the volume doesn't get set back to
781 * the user preference! 783 * the user preference!
782 * 784 *
783 * \code 785 * \code
784 * static Sound snd("alarm"); 786 * static Sound snd("alarm");
785 * if(!snd.isFinished()) 787 * if(!snd.isFinished())
786 * return; 788 * return;
787 * 789 *
788 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); 790 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd );
789 * snd.play() 791 * snd.play()
790 * \endcode 792 * \endcode
791 * 793 *
792 * 794 *
793 * 795 *
794 * @param mixer The mixer number/channel to use 796 * @param mixer The mixer number/channel to use
795 * @param file The file name. If you convert from QString use QFile::encodeName 797 * @param file The file name. If you convert from QString use QFile::encodeName
796 * @param snd The sound to wait for finishing 798 * @param snd The sound to wait for finishing
797 * 799 *
798 */ 800 */
799void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { 801void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
800#ifndef QT_NO_SOUND 802#ifndef QT_NO_SOUND
801 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { 803 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
802 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { 804 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
803 Config cfg ( "qpe" ); 805 Config cfg ( "qpe" );
804 cfg. setGroup ( "Volume" ); 806 cfg. setGroup ( "Volume" );
805 807
806 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 808 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
807 if ( volalarm < 0 ) 809 if ( volalarm < 0 )
808 volalarm = 0; 810 volalarm = 0;
809 else if ( volalarm > 100 ) 811 else if ( volalarm > 100 )
810 volalarm = 100; 812 volalarm = 100;
811 volalarm |= ( volalarm << 8 ); 813 volalarm |= ( volalarm << 8 );
812 814
813 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) 815 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
814 register_qpe_sound_finished(snd, this, SLOT(playingStopped())); 816 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
815 } 817 }
816 d->m_mixer = mixer; 818 d->m_mixer = mixer;
817 } 819 }
818#endif 820#endif
819} 821}
820 822
821} 823}
822} 824}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index a8362cd..1eb5959 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,409 +1,416 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2002-2006 The Opie Team <opie-devel@handhelds.org> 3              (C) 2002-2006 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; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
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 41
42 42
43#include <qstrlist.h> 43#include <qstrlist.h>
44#include <qwindowsystem_qws.h> 44#include <qwindowsystem_qws.h>
45 45
46 46
47class Sound; 47class Sound;
48 48
49namespace Opie{ 49namespace Opie{
50namespace Core{ 50namespace Core{
51 51
52class ODeviceData; 52class ODeviceData;
53/** 53/**
54 * The available devices 54 * The available devices
55 */ 55 */
56enum OModel { 56enum OModel {
57 Model_Unknown, // = 0 57 Model_Unknown, // = 0
58 58
59 Model_Series_Mask = 0xffff0000, 59 Model_Series_Mask = 0xffff0000,
60 60
61 Model_iPAQ = ( 1 << 16 ), 61 Model_iPAQ = ( 1 << 16 ),
62 62
63 Model_iPAQ_All = ( Model_iPAQ | 0xffff ), 63 Model_iPAQ_All = ( Model_iPAQ | 0xffff ),
64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ), 64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ),
65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ), 65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ),
66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ), 66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ),
67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ), 67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ),
68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ), 68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ),
69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ), 69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ),
70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ), 70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ),
71 Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ), 71 Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ),
72 Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ), 72 Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ),
73 Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ), 73 Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ),
74 Model_iPAQ_H4xxx = ( Model_iPAQ | 0x000b ), 74 Model_iPAQ_H4xxx = ( Model_iPAQ | 0x000b ),
75 Model_Jornada = ( 6 << 16 ), 75 Model_Jornada = ( 6 << 16 ),
76 Model_Jornada_56x = ( Model_Jornada | 0x0001 ), 76 Model_Jornada_56x = ( Model_Jornada | 0x0001 ),
77 Model_Jornada_720 = ( Model_Jornada | 0x0002 ), 77 Model_Jornada_720 = ( Model_Jornada | 0x0002 ),
78 Model_Jornada_820 = ( Model_Jornada | 0x0003 ), 78 Model_Jornada_820 = ( Model_Jornada | 0x0003 ),
79 79
80 Model_Zaurus = ( 2 << 16 ), 80 Model_Zaurus = ( 2 << 16 ),
81 81
82 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), 82 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ),
83 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), 83 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ),
84 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), 84 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ),
85 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), 85 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ),
86 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), 86 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ),
87 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ), 87 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ),
88 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ), 88 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ),
89 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ), 89 Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ),
90 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ), 90 Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ),
91 91
92 Model_SIMpad = ( 3 << 16 ), 92 Model_SIMpad = ( 3 << 16 ),
93 93
94 Model_SIMpad_All = ( Model_SIMpad | 0xffff ), 94 Model_SIMpad_All = ( Model_SIMpad | 0xffff ),
95 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ), 95 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ),
96 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ), 96 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ),
97 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ), 97 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ),
98 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ), 98 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ),
99 99
100 Model_Ramses = ( 4 << 16 ), 100 Model_Ramses = ( 4 << 16 ),
101 101
102 Model_Ramses_All = ( Model_Ramses | 0xffff ), 102 Model_Ramses_All = ( Model_Ramses | 0xffff ),
103 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), 103 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ),
104 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), 104 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ),
105 105
106 Model_Yopy = ( 5 << 16 ), 106 Model_Yopy = ( 5 << 16 ),
107 107
108 Model_Yopy_All = ( Model_Yopy | 0xffff ), 108 Model_Yopy_All = ( Model_Yopy | 0xffff ),
109 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), 109 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ),
110 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), 110 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ),
111 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), 111 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ),
112 112
113 Model_Beagle = ( 6 << 16 ), 113 Model_Beagle = ( 6 << 16 ),
114 114
115 Model_Beagle_All = ( Model_Beagle | 0xffff ), 115 Model_Beagle_All = ( Model_Beagle | 0xffff ),
116 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), 116 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ),
117 117
118 Model_GenuineIntel = ( 7 << 16 ), 118 Model_GenuineIntel = ( 7 << 16 ),
119 119
120 Model_MyPal = ( 8 << 16 ), 120 Model_MyPal = ( 8 << 16 ),
121 121
122 Model_MyPal_All = ( Model_MyPal | 0xffff ), 122 Model_MyPal_All = ( Model_MyPal | 0xffff ),
123 Model_MyPal_620 = ( Model_MyPal | 0x0001 ), 123 Model_MyPal_620 = ( Model_MyPal | 0x0001 ),
124 Model_MyPal_716 = ( Model_MyPal | 0x0002 ), 124 Model_MyPal_716 = ( Model_MyPal | 0x0002 ),
125 Model_MyPal_730 = ( Model_MyPal | 0x0003 ), 125 Model_MyPal_730 = ( Model_MyPal | 0x0003 ),
126 126
127 Model_HTC = ( 9 << 16 ), 127 Model_HTC = ( 9 << 16 ),
128 Model_HTC_All = ( Model_HTC | 0xffff ), 128 Model_HTC_All = ( Model_HTC | 0xffff ),
129 Model_HTC_Universal = ( Model_HTC | 0x0001 ), 129 Model_HTC_Universal = ( Model_HTC | 0x0001 ),
130 Model_HTC_Alpine = ( Model_HTC | 0x0002 ), 130 Model_HTC_Alpine = ( Model_HTC | 0x0002 ),
131 Model_HTC_Apache = ( Model_HTC | 0x0003 ), 131 Model_HTC_Apache = ( Model_HTC | 0x0003 ),
132 Model_HTC_Beetles = ( Model_HTC | 0x0004 ), 132 Model_HTC_Beetles = ( Model_HTC | 0x0004 ),
133 Model_HTC_Blueangel = ( Model_HTC | 0x0005 ), 133 Model_HTC_Blueangel = ( Model_HTC | 0x0005 ),
134 Model_HTC_Himalaya = ( Model_HTC | 0x0006 ), 134 Model_HTC_Himalaya = ( Model_HTC | 0x0006 ),
135 Model_HTC_Magician = ( Model_HTC | 0x0007 ), 135 Model_HTC_Magician = ( Model_HTC | 0x0007 ),
136 136
137 Model_Motorola = ( 9 << 17 ), 137 Model_Motorola = ( 9 << 17 ),
138 Model_Motorola_All = ( Model_Motorola | 0xffff ), 138 Model_Motorola_All = ( Model_Motorola | 0xffff ),
139 Model_Motorola_EZX = ( Model_Motorola | 0x0001 ), 139 Model_Motorola_EZX = ( Model_Motorola | 0x0001 ),
140 140
141 Model_Palm = ( 10 << 16),
142 Model_Palm_All = ( Model_Palm | 0xffff ),
143 Model_Palm_LD = ( Model_Palm | 0x0001 ),
144 Model_Palm_TX = ( Model_Palm | 0x0002 ),
145 Model_Palm_Z72 = ( Model_Palm | 0x0003 ),
146
141}; 147};
142 148
143/** 149/**
144 * The vendor of the device 150 * The vendor of the device
145 */ 151 */
146enum OVendor { 152enum OVendor {
147 Vendor_Unknown, 153 Vendor_Unknown,
148 154
149 Vendor_HP, 155 Vendor_HP,
150 Vendor_Sharp, 156 Vendor_Sharp,
151 Vendor_SIEMENS, 157 Vendor_SIEMENS,
152 Vendor_MundN, 158 Vendor_MundN,
153 Vendor_GMate, 159 Vendor_GMate,
154 Vendor_MasterIA, 160 Vendor_MasterIA,
155 Vendor_GenuineIntel, 161 Vendor_GenuineIntel,
156 Vendor_Asus, 162 Vendor_Asus,
157 Vendor_HTC, 163 Vendor_HTC,
158 Vendor_Motorola, 164 Vendor_Motorola,
165 Vendor_Palm,
159}; 166};
160 167
161/** 168/**
162 * The System used 169 * The System used
163 */ 170 */
164enum OSystem { 171enum OSystem {
165 System_Unknown, 172 System_Unknown,
166 173
167 System_Familiar, 174 System_Familiar,
168 System_Zaurus, 175 System_Zaurus,
169 System_OpenZaurus, 176 System_OpenZaurus,
170 System_Linupy, 177 System_Linupy,
171 System_OpenEmbedded, 178 System_OpenEmbedded,
172 System_PC, 179 System_PC,
173 System_OpenEZX, 180 System_OpenEZX,
174 System_Angstrom, 181 System_Angstrom,
175}; 182};
176 183
177typedef struct { 184typedef struct {
178 OSystem system; 185 OSystem system;
179 char* sysstr; 186 char* sysstr;
180 char* sysvfile; 187 char* sysvfile;
181} ODistribution; 188} ODistribution;
182 189
183extern ODistribution distributions[]; 190extern ODistribution distributions[];
184 191
185 192
186enum OLedState { 193enum OLedState {
187 Led_Off, 194 Led_Off,
188 Led_On, 195 Led_On,
189 Led_BlinkSlow, 196 Led_BlinkSlow,
190 Led_BlinkFast 197 Led_BlinkFast
191}; 198};
192 199
193enum OLed { 200enum OLed {
194 Led_Mail, 201 Led_Mail,
195 Led_Power, 202 Led_Power,
196 Led_BlueTooth 203 Led_BlueTooth
197}; 204};
198 205
199enum OHardKey { 206enum OHardKey {
200 HardKey_Datebook = Qt::Key_F9, 207 HardKey_Datebook = Qt::Key_F9,
201 HardKey_Contacts = Qt::Key_F10, 208 HardKey_Contacts = Qt::Key_F10,
202 HardKey_Menu = Qt::Key_F11, 209 HardKey_Menu = Qt::Key_F11,
203 HardKey_Home = Qt::Key_F12, 210 HardKey_Home = Qt::Key_F12,
204 HardKey_Mail = Qt::Key_F13, 211 HardKey_Mail = Qt::Key_F13,
205 HardKey_Record = Qt::Key_F24, 212 HardKey_Record = Qt::Key_F24,
206 HardKey_Suspend = Qt::Key_F34, 213 HardKey_Suspend = Qt::Key_F34,
207 HardKey_Backlight = Qt::Key_F35, 214 HardKey_Backlight = Qt::Key_F35,
208 HardKey_Action = Qt::Key_F10, 215 HardKey_Action = Qt::Key_F10,
209 HardKey_OK = Qt::Key_F11, 216 HardKey_OK = Qt::Key_F11,
210 HardKey_End = Qt::Key_F12, 217 HardKey_End = Qt::Key_F12,
211}; 218};
212 219
213enum ODirection { 220enum ODirection {
214 CW = 0, 221 CW = 0,
215 CCW = 1, 222 CCW = 1,
216 Flip = 2, 223 Flip = 2,
217}; 224};
218 225
219enum OHingeStatus { 226enum OHingeStatus {
220 CASE_CLOSED = 3, 227 CASE_CLOSED = 3,
221 CASE_PORTRAIT = 2, 228 CASE_PORTRAIT = 2,
222 CASE_LANDSCAPE = 0, 229 CASE_LANDSCAPE = 0,
223 CASE_UNKNOWN = 1, 230 CASE_UNKNOWN = 1,
224}; 231};
225 232
226/* default button for qvfb or such 233/* default button for qvfb or such
227 * see odevice.cpp for details. 234 * see odevice.cpp for details.
228 * hint: manage a user defined button for qvfb? 235 * hint: manage a user defined button for qvfb?
229 * alwin 236 * alwin
230 */ 237 */
231struct default_button { 238struct default_button {
232 Qt::Key code; 239 Qt::Key code;
233 char *utext; 240 char *utext;
234 char *pix; 241 char *pix;
235 char *fpressedservice; 242 char *fpressedservice;
236 char *fpressedaction; 243 char *fpressedaction;
237 char *fheldservice; 244 char *fheldservice;
238 char *fheldaction; 245 char *fheldaction;
239}; 246};
240 247
241/** 248/**
242 * A singleton which gives informations about device specefic option 249 * A singleton which gives informations about device specefic option
243 * like the Hardware used, LEDs, the Base Distribution and 250 * like the Hardware used, LEDs, the Base Distribution and
244 * hardware key mappings. 251 * hardware key mappings.
245 * 252 *
246 * @short A small class for device specific options 253 * @short A small class for device specific options
247 * @see QObject 254 * @see QObject
248 * @author Robert Griebl 255 * @author Robert Griebl
249 * @version 1.0 256 * @version 1.0
250 */ 257 */
251class ODevice : public QObject 258class ODevice : public QObject
252{ 259{
253 Q_OBJECT 260 Q_OBJECT
254 261
255private: 262private:
256 /* disable copy */ 263 /* disable copy */
257 ODevice ( const ODevice & ); 264 ODevice ( const ODevice & );
258 265
259protected: 266protected:
260 ODevice(); 267 ODevice();
261 virtual void init(const QString&); 268 virtual void init(const QString&);
262 virtual void initButtons(); 269 virtual void initButtons();
263 static void sendSuspendmsg(); 270 static void sendSuspendmsg();
264 271
265 ODeviceData *d; 272 ODeviceData *d;
266 273
267public: 274public:
268 // sandman do we want to allow destructions? -zecke? 275 // sandman do we want to allow destructions? -zecke?
269 virtual ~ODevice(); 276 virtual ~ODevice();
270 static ODevice *inst(); 277 static ODevice *inst();
271 278
272 // information 279 // information
273 QString modelString() const; 280 QString modelString() const;
274 OModel model() const; 281 OModel model() const;
275 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 282 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
276 283
277 QString vendorString() const; 284 QString vendorString() const;
278 OVendor vendor() const; 285 OVendor vendor() const;
279 286
280 QString systemString() const; 287 QString systemString() const;
281 OSystem system() const; 288 OSystem system() const;
282 289
283 QString systemVersionString() const; 290 QString systemVersionString() const;
284 291
285 virtual Transformation rotation() const; 292 virtual Transformation rotation() const;
286 virtual ODirection direction() const; 293 virtual ODirection direction() const;
287 294
288 QString qteDriver() const; 295 QString qteDriver() const;
289 296
290 // system 297 // system
291 virtual bool suspend(); 298 virtual bool suspend();
292 299
293 virtual bool setDisplayStatus ( bool on ); 300 virtual bool setDisplayStatus ( bool on );
294 virtual bool setDisplayBrightness ( int brightness ); 301 virtual bool setDisplayBrightness ( int brightness );
295 virtual int displayBrightnessResolution() const; 302 virtual int displayBrightnessResolution() const;
296 virtual bool setDisplayContrast ( int contrast ); 303 virtual bool setDisplayContrast ( int contrast );
297 virtual int displayContrastResolution() const; 304 virtual int displayContrastResolution() const;
298 305
299 // don't add new virtual methods, use this: 306 // don't add new virtual methods, use this:
300 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 307 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
301 // and in your subclass do overwrite 308 // and in your subclass do overwrite
302 // protected virtual int virtual_hook(int, void *) 309 // protected virtual int virtual_hook(int, void *)
303 // which is defined below 310 // which is defined below
304 311
305 // input / output 312 // input / output
306 virtual void playAlarmSound(); 313 virtual void playAlarmSound();
307 virtual void playKeySound(); 314 virtual void playKeySound();
308 virtual void playTouchSound(); 315 virtual void playTouchSound();
309 316
310 virtual QValueList <OLed> ledList() const; 317 virtual QValueList <OLed> ledList() const;
311 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 318 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
312 virtual OLedState ledState ( OLed led ) const; 319 virtual OLedState ledState ( OLed led ) const;
313 virtual bool setLedState ( OLed led, OLedState st ); 320 virtual bool setLedState ( OLed led, OLedState st );
314 321
315 virtual bool hasLightSensor() const; 322 virtual bool hasLightSensor() const;
316 virtual int readLightSensor(); 323 virtual int readLightSensor();
317 virtual int lightSensorResolution() const; 324 virtual int lightSensorResolution() const;
318 325
319 virtual bool hasHingeSensor() const; 326 virtual bool hasHingeSensor() const;
320 virtual OHingeStatus readHingeSensor()const; 327 virtual OHingeStatus readHingeSensor()const;
321 328
322 const QStrList &allowedCpuFrequencies() const; 329 const QStrList &allowedCpuFrequencies() const;
323 bool setCurrentCpuFrequency(uint index); 330 bool setCurrentCpuFrequency(uint index);
324 331
325 /** 332 /**
326 * Returns the available buttons on this device. The number and location 333 * Returns the available buttons on this device. The number and location
327 * of buttons will vary depending on the device. Button numbers will be assigned 334 * of buttons will vary depending on the device. Button numbers will be assigned
328 * by the device manufacturer and will be from most preferred button to least preffered 335 * by the device manufacturer and will be from most preferred button to least preffered
329 * button. Note that this list only contains "user mappable" buttons. 336 * button. Note that this list only contains "user mappable" buttons.
330 * 337 *
331 * @todo Make method const and take care of calling initButtons or make that const too 338 * @todo Make method const and take care of calling initButtons or make that const too
332 * 339 *
333 */ 340 */
334 const QValueList<ODeviceButton> &buttons(); 341 const QValueList<ODeviceButton> &buttons();
335 342
336 /** 343 /**
337 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 344 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
338 * returns 0L 345 * returns 0L
339 */ 346 */
340 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 347 const ODeviceButton *buttonForKeycode ( ushort keyCode );
341 348
342 /** 349 /**
343 * Reassigns the pressed action for \a button. To return to the factory 350 * Reassigns the pressed action for \a button. To return to the factory
344 * default pass an empty string as \a qcopMessage. 351 * default pass an empty string as \a qcopMessage.
345 */ 352 */
346 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 353 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
347 354
348 /** 355 /**
349 * Reassigns the held action for \a button. To return to the factory 356 * Reassigns the held action for \a button. To return to the factory
350 * default pass an empty string as \a qcopMessage. 357 * default pass an empty string as \a qcopMessage.
351 */ 358 */
352 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 359 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
353 360
354 /** 361 /**
355 * How long (in ms) you have to press a button for a "hold" action 362 * How long (in ms) you have to press a button for a "hold" action
356 */ 363 */
357 uint buttonHoldTime() const; 364 uint buttonHoldTime() const;
358 365
359signals: 366signals:
360 void buttonMappingChanged(); 367 void buttonMappingChanged();
361 368
362private slots: 369private slots:
363 void systemMessage ( const QCString &, const QByteArray & ); 370 void systemMessage ( const QCString &, const QByteArray & );
364 void playingStopped(); 371 void playingStopped();
365 372
366protected: 373protected:
367 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 374 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
368 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 375 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
369 void reloadButtonMapping(); 376 void reloadButtonMapping();
370 void changeMixerForAlarm( int mixer, const char* file, Sound *snd); 377 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
371 378
372 /* ugly virtual hook */ 379 /* ugly virtual hook */
373 virtual void virtual_hook( int id, void* data ); 380 virtual void virtual_hook( int id, void* data );
374}; 381};
375 382
376class ODeviceData { 383class ODeviceData {
377 384
378 public: 385 public:
379 QString m_vendorstr; 386 QString m_vendorstr;
380 OVendor m_vendor; 387 OVendor m_vendor;
381 388
382 QString m_modelstr; 389 QString m_modelstr;
383 OModel m_model; 390 OModel m_model;
384 391
385 QString m_systemstr; 392 QString m_systemstr;
386 OSystem m_system; 393 OSystem m_system;
387 394
388 QString m_sysverstr; 395 QString m_sysverstr;
389 396
390 Transformation m_rotation; 397 Transformation m_rotation;
391 ODirection m_direction; 398 ODirection m_direction;
392 399
393 QString m_qteDriver; 400 QString m_qteDriver;
394 401
395 QValueList <ODeviceButton> *m_buttons; 402 QValueList <ODeviceButton> *m_buttons;
396 uint m_holdtime; 403 uint m_holdtime;
397 QStrList *m_cpu_frequencies; 404 QStrList *m_cpu_frequencies;
398 bool m_initializedButtonQcop : 1; 405 bool m_initializedButtonQcop : 1;
399 406
400 /* values for changeMixerForAlarm */ 407 /* values for changeMixerForAlarm */
401 int m_sound, m_vol, m_mixer; 408 int m_sound, m_vol, m_mixer;
402}; 409};
403 410
404extern bool isQWS(); 411extern bool isQWS();
405extern QCString makeChannel ( const char *str ); 412extern QCString makeChannel ( const char *str );
406} 413}
407} 414}
408 415
409#endif 416#endif
diff --git a/libopie2/opiecore/device/odevice_palm.cpp b/libopie2/opiecore/device/odevice_palm.cpp
new file mode 100644
index 0000000..76399f8
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_palm.cpp
@@ -0,0 +1,282 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
31#include "odevice_palm.h"
32
33/* QT */
34#include <qapplication.h>
35#include <qfile.h>
36#include <qtextstream.h>
37#include <qwindowsystem_qws.h>
38#include <qgfx_qws.h>
39
40/* OPIE */
41#include <qpe/config.h>
42#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h>
44
45#include <opie2/okeyfilter.h>
46#include <opie2/oresource.h>
47
48/* STD */
49#include <fcntl.h>
50#include <math.h>
51#include <stdlib.h>
52#include <signal.h>
53#include <sys/ioctl.h>
54#include <sys/time.h>
55#include <unistd.h>
56#ifndef QT_NO_SOUND
57#include <linux/soundcard.h>
58#endif
59
60using namespace Opie::Core;
61using namespace Opie::Core::Internal;
62
63struct palm_button palm_buttons [] = {
64 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
65 Qt::Key_F9, QT_TRANSLATE_NOOP( "Button", "Home Button" ),
66 "devicebuttons/palm_home",
67 "QPE/Launcher", "home()",
68 "buttonsettings", "raise()" },
69 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
70 Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Calendar Button" ),
71 "devicebuttons/palm_calendar",
72 "datebook", "nextView()",
73 "today", "raise()" },
74 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
75 Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "Todo Button" ),
76 "devicebuttons/palm_todo",
77 "todolist", "raise()",
78 "todolist", "create()" },
79 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
80 Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "Mail Button" ),
81 "devicebuttons/palm_mail",
82 "opiemail", "raise()",
83 "opiemail", "newmail()" },
84 { Model_Palm_LD,
85 Qt::Key_F7, QT_TRANSLATE_NOOP( "Button", "Voice Memo Button" ),
86 "devicebuttons/palm_voice_memo",
87 "QPE/TaskBar", "toggleMenu()",
88 "QPE/TaskBar", "toggleStartMenu()" },
89 { Model_Palm_LD,
90 Qt::Key_F8, QT_TRANSLATE_NOOP( "Button", "Rotate Button" ),
91 "devicebuttons/palm_rotate",
92 "QPE/Rotation", "flip()",0},
93};
94
95void Palm::init(const QString& cpu_info)
96{
97 d->m_vendorstr = "Palm";
98 d->m_vendor = Vendor_Palm;
99
100 QString model = "unknown";
101
102 int loc = cpu_info.find( ":" );
103 if ( loc != -1 )
104 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
105 else
106 model = cpu_info;
107
108 if ( model == "Palm LifeDrive" ) {
109 d->m_modelstr = "Palm LifeDrive";
110 d->m_model = Model_Palm_LD;
111 }
112 else if ( model == "Palm TX" ) {
113 d->m_modelstr = "Palm TX";
114 d->m_model = Model_Palm_TX;
115 }
116 else if ( model == "Palm Zire 72" ) {
117 d->m_modelstr = "Palm Zire 72";
118 d->m_model = Model_Palm_Z72;
119 }
120 else
121 d->m_model = Model_Unknown;
122
123 switch ( d->m_model )
124 {
125 case Model_Palm_LD:
126 case Model_Palm_TX:
127 case Model_Palm_Z72:
128 m_backlightdev = "/sys/class/backlight/pxapwm-bl/";
129 d->m_rotation = Rot0;
130 d->m_direction = CCW;
131 d->m_qteDriver = "Transformed";
132 break;
133 default:
134 m_backlightdev = "";
135 }
136
137}
138
139
140void Palm::initButtons()
141{
142
143 if ( d->m_buttons )
144 return ;
145
146 if ( isQWS( ) ) {
147 addPreHandler(this);
148 }
149
150 d->m_buttons = new QValueList <ODeviceButton>;
151
152 for ( uint i = 0; i < ( sizeof( palm_buttons ) / sizeof( palm_button ) ); i++ )
153 {
154 palm_button *ib = palm_buttons + i;
155 ODeviceButton b;
156
157 if (( ib->model & d->m_model ) == d->m_model ) {
158 b. setKeycode ( ib->code );
159 b. setUserText ( QObject::tr ( "Button", ib->utext ));
160 b. setPixmap ( OResource::loadPixmap ( ib->pix ));
161 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
162 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
163
164 d->m_buttons->append ( b );
165 }
166 }
167 reloadButtonMapping();
168}
169
170
171bool Palm::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
172{
173 int newkeycode = keycode;
174
175 if (qt_screen->transformOrientation() != Rot0){
176
177 switch ( keycode ) {
178 case Key_Left :
179 case Key_Right:
180 case Key_Up :
181 case Key_Down :
182 newkeycode = Key_Left + ( keycode - Key_Left + (int) qt_screen->transformOrientation() ) % 4;
183 default:
184 break;
185 }
186
187 if (newkeycode!=keycode) {
188 if ( newkeycode != Key_unknown ) {
189 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
190 }
191 return true;
192 }
193
194 }
195
196 return false;
197}
198
199
200bool Palm::suspend()
201{
202 // some Palms do not implement their own power management at the moment.
203
204 bool res = false;
205
206 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
207 return false;
208
209 switch ( d->m_model ) {
210 case Model_Palm_LD:
211 case Model_Palm_Z72:
212 {
213 QCopChannel::send( "QPE/System", "aboutToSuspend()" );
214
215 ::sync(); // flush fs caches
216 res = ( ::system ( "apm --suspend" ) == 0 );
217
218 QCopChannel::send( "QPE/System", "returnFromSuspend()" );
219 }
220 break;
221 }
222
223 return res;
224}
225
226
227int Palm::displayBrightnessResolution() const
228{
229 int res = 1;
230
231 switch ( d->m_model )
232 {
233 case Model_Palm_LD:
234 case Model_Palm_TX:
235 case Model_Palm_Z72:
236 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
237 if ( fd )
238 {
239 char buf[100];
240 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
241 ::close( fd );
242 }
243 break;
244
245 default:
246 res = 1;
247 }
248
249 return res;
250}
251
252
253bool Palm::setDisplayBrightness( int bright )
254{
255 bool res = false;
256
257 if ( bright > 255 ) bright = 255;
258 if ( bright < 0 ) bright = 0;
259
260 int numberOfSteps = displayBrightnessResolution();
261 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
262
263 switch ( d->m_model )
264 {
265
266 case Model_Palm_LD:
267 case Model_Palm_TX:
268 case Model_Palm_Z72:
269 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
270 if ( fd )
271 {
272 char buf[100];
273 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
274 res = ( ::write( fd, &buf[0], len ) == 0 );
275 ::close( fd );
276 }
277 break;
278
279 default: res = false;
280 }
281 return res;
282}
diff --git a/libopie2/opiecore/device/odevice_palm.h b/libopie2/opiecore/device/odevice_palm.h
new file mode 100644
index 0000000..3ce786c
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_palm.h
@@ -0,0 +1,72 @@
1/*
2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6          .>+-=
7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_PALM
31#define ODEVICE_PALM
32
33#include "odevice_abstractmobiledevice.h"
34
35namespace Opie {
36namespace Core {
37namespace Internal {
38class Palm : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
39{
40 protected:
41
42 virtual void init(const QString&);
43 virtual void initButtons();
44 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
45
46 QString m_backlightdev;
47
48 public:
49 virtual bool suspend();
50
51 virtual bool setDisplayBrightness ( int b );
52 virtual int displayBrightnessResolution() const;
53
54};
55
56struct palm_button
57{
58 uint model;
59 Qt::Key code;
60 char *utext;
61 char *pix;
62 char *fpressedservice;
63 char *fpressedaction;
64 char *fheldservice;
65 char *fheldaction;
66};
67
68}
69}
70}
71
72#endif