summaryrefslogtreecommitdiff
authorzecke <zecke>2004-07-13 14:01:44 (UTC)
committer zecke <zecke>2004-07-13 14:01:44 (UTC)
commit03930fa4871365efb6438b74b3a68f8f06aa7e4f (patch) (unidiff)
tree86c83a95b37fbde6e467b852393b66527383492e
parent74f19a502a513258f88a75e057a5998393e3c7f6 (diff)
downloadopie-03930fa4871365efb6438b74b3a68f8f06aa7e4f.zip
opie-03930fa4871365efb6438b74b3a68f8f06aa7e4f.tar.gz
opie-03930fa4871365efb6438b74b3a68f8f06aa7e4f.tar.bz2
Fix compiler warnings coming from static methods which are unused most of the
time in headers. Move isQWS and makeChannel to Opie::Core. Maybe we will move them to internal later
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp34
-rw-r--r--libopie2/opiecore/device/odevice.h21
2 files changed, 35 insertions, 20 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 5b73e59..0068d88 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,687 +1,717 @@
1/* 1/*
2 � � � � � � � � This file is part of the Opie Project 2 � � � � � � � � This file is part of the Opie Project
3� � � � � � � Copyright (C) The Opie Team <opie-devel@handhelds.org> 3� � � � � � � Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6� � � � � �.>+-= 6� � � � � �.>+-=
7�_;:, � � .> � �:=|. This program is free software; you can 7�_;:, � � .> � �:=|. This program is free software; you can
8.> <`_, � > �. � <= redistribute it and/or modify it under 8.> <`_, � > �. � <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- � : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- � : the terms of the GNU Library General Public
10.="- .-=="i, � � .._ License as published by the Free Software 10.="- .-=="i, � � .._ License as published by the Free Software
11�- . � .-<_> � � .<> Foundation; either version 2 of the License, 11�- . � .-<_> � � .<> Foundation; either version 2 of the License,
12� � �._= =} � � � : or (at your option) any later version. 12� � �._= =} � � � : or (at your option) any later version.
13� � .%`+i> � � � _;_. 13� � .%`+i> � � � _;_.
14� � .i_,=:_. � � �-<s. This program is distributed in the hope that 14� � .i_,=:_. � � �-<s. This program is distributed in the hope that
15� � �+ �. �-:. � � � = it will be useful, but WITHOUT ANY WARRANTY; 15� � �+ �. �-:. � � � = it will be useful, but WITHOUT ANY WARRANTY;
16� � : .. � �.:, � � . . . without even the implied warranty of 16� � : .. � �.:, � � . . . without even the implied warranty of
17� � =_ � � � �+ � � =;=|` MERCHANTABILITY or FITNESS FOR A 17� � =_ � � � �+ � � =;=|` MERCHANTABILITY or FITNESS FOR A
18� _.=:. � � � : � �:=>`: PARTICULAR PURPOSE. See the GNU 18� _.=:. � � � : � �:=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= � � � = � � � ; Library General Public License for more 19..}^=.= � � � = � � � ; Library General Public License for more
20++= � -. � � .` � � .: details. 20++= � -. � � .` � � .: details.
21�: � � = �...= . :.=- 21�: � � = �...= . :.=-
22�-. � .:....=;==+<; You should have received a copy of the GNU 22�-. � .:....=;==+<; You should have received a copy of the GNU
23� -_. . . � )=. �= Library General Public License along with 23� -_. . . � )=. �= Library General Public License along with
24� � -- � � � �:-=` this library; see the file COPYING.LIB. 24� � -- � � � �:-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61namespace Opie {
62namespace Core {
62 63
63using namespace Opie::Core; 64static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
65
66
67/* STATIC and common implementation */
68/* EXPORT */ ODistribution distributions[] = {
69 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
70 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
71 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
72 { System_Unknown, "Linux", "/etc/issue" },
73};
74
75
76/* EXPORT */ bool isQWS(){
77 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
78}
79
80/* EXPORT */ QCString makeChannel ( const char *str ){
81 if ( str && !::strchr ( str, '/' ))
82 return QCString ( "QPE/Application/" ) + str;
83 else
84 return str;
85}
86
87
88
89/* Now the default implementation of ODevice */
64 90
65struct default_button default_buttons [] = { 91struct default_button default_buttons [] = {
66 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 92 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
67 "devicebuttons/z_calendar", 93 "devicebuttons/z_calendar",
68 "datebook", "nextView()", 94 "datebook", "nextView()",
69 "today", "raise()" }, 95 "today", "raise()" },
70 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 96 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
71 "devicebuttons/z_contact", 97 "devicebuttons/z_contact",
72 "addressbook", "raise()", 98 "addressbook", "raise()",
73 "addressbook", "beamBusinessCard()" }, 99 "addressbook", "beamBusinessCard()" },
74 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 100 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
75 "devicebuttons/z_home", 101 "devicebuttons/z_home",
76 "QPE/Launcher", "home()", 102 "QPE/Launcher", "home()",
77 "buttonsettings", "raise()" }, 103 "buttonsettings", "raise()" },
78 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 104 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
79 "devicebuttons/z_menu", 105 "devicebuttons/z_menu",
80 "QPE/TaskBar", "toggleMenu()", 106 "QPE/TaskBar", "toggleMenu()",
81 "QPE/TaskBar", "toggleStartMenu()" }, 107 "QPE/TaskBar", "toggleStartMenu()" },
82 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 108 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
83 "devicebuttons/z_mail", 109 "devicebuttons/z_mail",
84 "opiemail", "raise()", 110 "opiemail", "raise()",
85 "opiemail", "newMail()" }, 111 "opiemail", "newMail()" },
86}; 112};
87 113
88ODevice *ODevice::inst() 114ODevice *ODevice::inst()
89{ 115{
90 static ODevice *dev = 0; 116 static ODevice *dev = 0;
91 117
92 // rewrite this to only use /proc/cpuinfo or so 118 // rewrite this to only use /proc/cpuinfo or so
93 QString cpu_info; 119 QString cpu_info;
94 120
95 if ( !dev ) 121 if ( !dev )
96 { 122 {
97 QFile f( PATH_PROC_CPUINFO ); 123 QFile f( PATH_PROC_CPUINFO );
98 if ( f.open( IO_ReadOnly ) ) 124 if ( f.open( IO_ReadOnly ) )
99 { 125 {
100 QTextStream s( &f ); 126 QTextStream s( &f );
101 while ( !s.atEnd() ) 127 while ( !s.atEnd() )
102 { 128 {
103 QString line; 129 QString line;
104 line = s.readLine(); 130 line = s.readLine();
105 if ( line.startsWith( "Hardware" ) ) 131 if ( line.startsWith( "Hardware" ) )
106 { 132 {
107 qDebug( "ODevice() - found '%s'", (const char*) line ); 133 qDebug( "ODevice() - found '%s'", (const char*) line );
108 cpu_info = line; 134 cpu_info = line;
109 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 135 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
110 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 136 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
111 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 137 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
112 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 138 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
113 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 139 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
114 else qWarning( "ODevice() - unknown hardware - using default." ); 140 else qWarning( "ODevice() - unknown hardware - using default." );
115 break; 141 break;
116 } 142 }
117 } 143 }
118 } 144 }
119 else 145 else
120 { 146 {
121 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 147 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
122 } 148 }
123 if ( !dev ) dev = new ODevice(); 149 if ( !dev ) dev = new ODevice();
124 dev->init(cpu_info); 150 dev->init(cpu_info);
125 } 151 }
126 return dev; 152 return dev;
127} 153}
128 154
129ODevice::ODevice() 155ODevice::ODevice()
130{ 156{
131 d = new ODeviceData; 157 d = new ODeviceData;
132 158
133 d->m_modelstr = "Unknown"; 159 d->m_modelstr = "Unknown";
134 d->m_model = Model_Unknown; 160 d->m_model = Model_Unknown;
135 d->m_vendorstr = "Unknown"; 161 d->m_vendorstr = "Unknown";
136 d->m_vendor = Vendor_Unknown; 162 d->m_vendor = Vendor_Unknown;
137 d->m_systemstr = "Unknown"; 163 d->m_systemstr = "Unknown";
138 d->m_system = System_Unknown; 164 d->m_system = System_Unknown;
139 d->m_sysverstr = "0.0"; 165 d->m_sysverstr = "0.0";
140 d->m_rotation = Rot0; 166 d->m_rotation = Rot0;
141 d->m_direction = CW; 167 d->m_direction = CW;
142 168
143 d->m_holdtime = 1000; // 1000ms 169 d->m_holdtime = 1000; // 1000ms
144 d->m_buttons = 0; 170 d->m_buttons = 0;
145 d->m_cpu_frequencies = new QStrList; 171 d->m_cpu_frequencies = new QStrList;
146 172
147 // New distribution detection code first checks for legacy distributions, 173 // New distribution detection code first checks for legacy distributions,
148 // identified by /etc/familiar-version or /etc/oz_version. 174 // identified by /etc/familiar-version or /etc/oz_version.
149 // Then check for OpenEmbedded and lastly, read /etc/issue 175 // Then check for OpenEmbedded and lastly, read /etc/issue
150 176
151 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 177 for ( unsigned int i = 0; i < sizeof distributions; ++i )
152 { 178 {
153 if ( QFile::exists( distributions[i].sysvfile ) ) 179 if ( QFile::exists( distributions[i].sysvfile ) )
154 { 180 {
155 d->m_systemstr = distributions[i].sysstr; 181 d->m_systemstr = distributions[i].sysstr;
156 d->m_system = distributions[i].system; 182 d->m_system = distributions[i].system;
157 d->m_sysverstr = "<Unknown>"; 183 d->m_sysverstr = "<Unknown>";
158 QFile f( distributions[i].sysvfile ); 184 QFile f( distributions[i].sysvfile );
159 if ( f.open( IO_ReadOnly ) ) 185 if ( f.open( IO_ReadOnly ) )
160 { 186 {
161 QTextStream ts( &f ); 187 QTextStream ts( &f );
162 d->m_sysverstr = ts.readLine(); 188 d->m_sysverstr = ts.readLine();
163 } 189 }
164 break; 190 break;
165 } 191 }
166 } 192 }
167} 193}
168 194
169void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 195void ODevice::systemMessage( const QCString &msg, const QByteArray & )
170{ 196{
171 if ( msg == "deviceButtonMappingChanged()" ) { 197 if ( msg == "deviceButtonMappingChanged()" ) {
172 reloadButtonMapping(); 198 reloadButtonMapping();
173 } 199 }
174} 200}
175 201
176void ODevice::init(const QString&) 202void ODevice::init(const QString&)
177{ 203{
178} 204}
179 205
180/** 206/**
181* This method initialises the button mapping 207* This method initialises the button mapping
182*/ 208*/
183void ODevice::initButtons() 209void ODevice::initButtons()
184{ 210{
185 if ( d->m_buttons ) 211 if ( d->m_buttons )
186 return; 212 return;
187 213
188 qDebug ( "init Buttons" ); 214 qDebug ( "init Buttons" );
189 d->m_buttons = new QValueList <ODeviceButton>; 215 d->m_buttons = new QValueList <ODeviceButton>;
190 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 216 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
191 default_button *db = default_buttons + i; 217 default_button *db = default_buttons + i;
192 ODeviceButton b; 218 ODeviceButton b;
193 b. setKeycode ( db->code ); 219 b. setKeycode ( db->code );
194 b. setUserText ( QObject::tr ( "Button", db->utext )); 220 b. setUserText ( QObject::tr ( "Button", db->utext ));
195 b. setPixmap ( Resource::loadPixmap ( db->pix )); 221 b. setPixmap ( Resource::loadPixmap ( db->pix ));
196 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
197 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
198 d->m_buttons->append ( b ); 224 d->m_buttons->append ( b );
199 } 225 }
200 226
201 reloadButtonMapping(); 227 reloadButtonMapping();
202 228
203 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 229 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
204 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 230 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
205} 231}
206 232
207ODevice::~ODevice() 233ODevice::~ODevice()
208{ 234{
209// we leak m_devicebuttons and m_cpu_frequency 235// we leak m_devicebuttons and m_cpu_frequency
210// but it's a singleton and it is not so importantant 236// but it's a singleton and it is not so importantant
211// -zecke 237// -zecke
212 delete d; 238 delete d;
213} 239}
214 240
215bool ODevice::setSoftSuspend ( bool /*soft*/ ) 241bool ODevice::setSoftSuspend ( bool /*soft*/ )
216{ 242{
217 return false; 243 return false;
218} 244}
219 245
220//#include <linux/apm_bios.h> 246//#include <linux/apm_bios.h>
221 247
222#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 248#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
223 249
224/** 250/**
225* This method will try to suspend the device 251* This method will try to suspend the device
226* It only works if the user is the QWS Server and the apm application 252* It only works if the user is the QWS Server and the apm application
227* is installed. 253* is installed.
228* It tries to suspend and then waits some time cause some distributions 254* It tries to suspend and then waits some time cause some distributions
229* do have asynchronus apm implementations. 255* do have asynchronus apm implementations.
230* This method will either fail and return false or it'll suspend the 256* This method will either fail and return false or it'll suspend the
231* device and return once the device got woken up 257* device and return once the device got woken up
232* 258*
233* @return if the device got suspended 259* @return if the device got suspended
234*/ 260*/
235bool ODevice::suspend() 261bool ODevice::suspend()
236{ 262{
237 qDebug("ODevice::suspend"); 263 qDebug("ODevice::suspend");
238 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 264 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
239 return false; 265 return false;
240 266
241 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 267 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
242 return false; 268 return false;
243 269
244 bool res = false; 270 bool res = false;
245 ODevice::sendSuspendmsg(); 271 ODevice::sendSuspendmsg();
246 272
247 struct timeval tvs, tvn; 273 struct timeval tvs, tvn;
248 ::gettimeofday ( &tvs, 0 ); 274 ::gettimeofday ( &tvs, 0 );
249 275
250 ::sync(); // flush fs caches 276 ::sync(); // flush fs caches
251 res = ( ::system ( "apm --suspend" ) == 0 ); 277 res = ( ::system ( "apm --suspend" ) == 0 );
252 278
253 // This is needed because the iPAQ apm implementation is asynchronous and we 279 // This is needed because the iPAQ apm implementation is asynchronous and we
254 // can not be sure when exactly the device is really suspended 280 // can not be sure when exactly the device is really suspended
255 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 281 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
256 282
257 if ( res ) { 283 if ( res ) {
258 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 284 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
259 ::usleep ( 200 * 1000 ); 285 ::usleep ( 200 * 1000 );
260 ::gettimeofday ( &tvn, 0 ); 286 ::gettimeofday ( &tvn, 0 );
261 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 287 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
262 } 288 }
263 289
264 return res; 290 return res;
265} 291}
266 292
267//#include <linux/fb.h> better not rely on kernel headers in userspace ... 293//#include <linux/fb.h> better not rely on kernel headers in userspace ...
268 294
269#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 295#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
270 296
271/* VESA Blanking Levels */ 297/* VESA Blanking Levels */
272#define VESA_NO_BLANKING 0 298#define VESA_NO_BLANKING 0
273#define VESA_VSYNC_SUSPEND 1 299#define VESA_VSYNC_SUSPEND 1
274#define VESA_HSYNC_SUSPEND 2 300#define VESA_HSYNC_SUSPEND 2
275#define VESA_POWERDOWN 3 301#define VESA_POWERDOWN 3
276 302
277/** 303/**
278* This sets the display on or off 304* This sets the display on or off
279*/ 305*/
280bool ODevice::setDisplayStatus ( bool on ) 306bool ODevice::setDisplayStatus ( bool on )
281{ 307{
282 qDebug("ODevice::setDisplayStatus(%d)", on); 308 qDebug("ODevice::setDisplayStatus(%d)", on);
283 309
284 if ( d->m_model == Model_Unknown ) 310 if ( d->m_model == Model_Unknown )
285 return false; 311 return false;
286 312
287 bool res = false; 313 bool res = false;
288 int fd; 314 int fd;
289 315
290 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 316 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
291 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 317 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
292 ::close ( fd ); 318 ::close ( fd );
293 } 319 }
294 return res; 320 return res;
295} 321}
296 322
297/** 323/**
298* This sets the display brightness 324* This sets the display brightness
299* 325*
300* @param p The brightness to be set on a scale from 0 to 255 326* @param p The brightness to be set on a scale from 0 to 255
301* @return success or failure 327* @return success or failure
302*/ 328*/
303bool ODevice::setDisplayBrightness ( int p) 329bool ODevice::setDisplayBrightness ( int p)
304{ 330{
305 Q_UNUSED( p ) 331 Q_UNUSED( p )
306 return false; 332 return false;
307} 333}
308 334
309/** 335/**
310* @return returns the number of steppings on the brightness slider 336* @return returns the number of steppings on the brightness slider
311* in the Light-'n-Power settings. 337* in the Light-'n-Power settings.
312*/ 338*/
313int ODevice::displayBrightnessResolution() const 339int ODevice::displayBrightnessResolution() const
314{ 340{
315 return 16; 341 return 16;
316} 342}
317 343
318/** 344/**
319* This sets the display contrast 345* This sets the display contrast
320* @param p The contrast to be set on a scale from 0 to 255 346* @param p The contrast to be set on a scale from 0 to 255
321* @return success or failure 347* @return success or failure
322*/ 348*/
323bool ODevice::setDisplayContrast ( int p) 349bool ODevice::setDisplayContrast ( int p)
324{ 350{
325 Q_UNUSED( p ) 351 Q_UNUSED( p )
326 return false; 352 return false;
327} 353}
328 354
329/** 355/**
330* @return return the max value for the brightness settings slider 356* @return return the max value for the brightness settings slider
331* or 0 if the device doesn't support setting of a contrast 357* or 0 if the device doesn't support setting of a contrast
332*/ 358*/
333int ODevice::displayContrastResolution() const 359int ODevice::displayContrastResolution() const
334{ 360{
335 return 0; 361 return 0;
336} 362}
337 363
338/** 364/**
339* This returns the vendor as string 365* This returns the vendor as string
340* @return Vendor as QString 366* @return Vendor as QString
341*/ 367*/
342QString ODevice::vendorString() const 368QString ODevice::vendorString() const
343{ 369{
344 return d->m_vendorstr; 370 return d->m_vendorstr;
345} 371}
346 372
347/** 373/**
348* This returns the vendor as one of the values of OVendor 374* This returns the vendor as one of the values of OVendor
349* @return OVendor 375* @return OVendor
350*/ 376*/
351OVendor ODevice::vendor() const 377OVendor ODevice::vendor() const
352{ 378{
353 return d->m_vendor; 379 return d->m_vendor;
354} 380}
355 381
356/** 382/**
357* This returns the model as a string 383* This returns the model as a string
358* @return A string representing the model 384* @return A string representing the model
359*/ 385*/
360QString ODevice::modelString() const 386QString ODevice::modelString() const
361{ 387{
362 return d->m_modelstr; 388 return d->m_modelstr;
363} 389}
364 390
365/** 391/**
366* This does return the OModel used 392* This does return the OModel used
367*/ 393*/
368OModel ODevice::model() const 394OModel ODevice::model() const
369{ 395{
370 return d->m_model; 396 return d->m_model;
371} 397}
372 398
373/** 399/**
374* This does return the systen name 400* This does return the systen name
375*/ 401*/
376QString ODevice::systemString() const 402QString ODevice::systemString() const
377{ 403{
378 return d->m_systemstr; 404 return d->m_systemstr;
379} 405}
380 406
381/** 407/**
382* Return System as OSystem value 408* Return System as OSystem value
383*/ 409*/
384OSystem ODevice::system() const 410OSystem ODevice::system() const
385{ 411{
386 return d->m_system; 412 return d->m_system;
387} 413}
388 414
389/** 415/**
390* @return the version string of the base system 416* @return the version string of the base system
391*/ 417*/
392QString ODevice::systemVersionString() const 418QString ODevice::systemVersionString() const
393{ 419{
394 return d->m_sysverstr; 420 return d->m_sysverstr;
395} 421}
396 422
397/** 423/**
398* @return the current Transformation 424* @return the current Transformation
399*/ 425*/
400Transformation ODevice::rotation() const 426Transformation ODevice::rotation() const
401{ 427{
402 return d->m_rotation; 428 return d->m_rotation;
403} 429}
404 430
405/** 431/**
406* @return the current rotation direction 432* @return the current rotation direction
407*/ 433*/
408ODirection ODevice::direction() const 434ODirection ODevice::direction() const
409{ 435{
410 return d->m_direction; 436 return d->m_direction;
411} 437}
412 438
413/** 439/**
414* This plays an alarm sound 440* This plays an alarm sound
415*/ 441*/
416void ODevice::playAlarmSound() 442void ODevice::playAlarmSound()
417{ 443{
418#ifndef QT_NO_SOUND 444#ifndef QT_NO_SOUND
419 static Sound snd ( "alarm" ); 445 static Sound snd ( "alarm" );
420 446
421 if ( snd. isFinished()) 447 if ( snd. isFinished())
422 snd. play(); 448 snd. play();
423#endif 449#endif
424} 450}
425 451
426/** 452/**
427* This plays a key sound 453* This plays a key sound
428*/ 454*/
429void ODevice::playKeySound() 455void ODevice::playKeySound()
430{ 456{
431#ifndef QT_NO_SOUND 457#ifndef QT_NO_SOUND
432 static Sound snd ( "keysound" ); 458 static Sound snd ( "keysound" );
433 459
434 if ( snd. isFinished()) 460 if ( snd. isFinished())
435 snd. play(); 461 snd. play();
436#endif 462#endif
437} 463}
438 464
439/** 465/**
440* This plays a touch sound 466* This plays a touch sound
441*/ 467*/
442void ODevice::playTouchSound() 468void ODevice::playTouchSound()
443{ 469{
444#ifndef QT_NO_SOUND 470#ifndef QT_NO_SOUND
445 static Sound snd ( "touchsound" ); 471 static Sound snd ( "touchsound" );
446 472
447 if ( snd. isFinished()) 473 if ( snd. isFinished())
448 snd. play(); 474 snd. play();
449#endif 475#endif
450} 476}
451 477
452/** 478/**
453* This method will return a list of leds 479* This method will return a list of leds
454* available on this device 480* available on this device
455* @return a list of LEDs. 481* @return a list of LEDs.
456*/ 482*/
457QValueList <OLed> ODevice::ledList() const 483QValueList <OLed> ODevice::ledList() const
458{ 484{
459 return QValueList <OLed>(); 485 return QValueList <OLed>();
460} 486}
461 487
462/** 488/**
463* This does return the state of the LEDs 489* This does return the state of the LEDs
464*/ 490*/
465QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 491QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
466{ 492{
467 return QValueList <OLedState>(); 493 return QValueList <OLedState>();
468} 494}
469 495
470/** 496/**
471* @return the state for a given OLed 497* @return the state for a given OLed
472*/ 498*/
473OLedState ODevice::ledState ( OLed /*which*/ ) const 499OLedState ODevice::ledState ( OLed /*which*/ ) const
474{ 500{
475 return Led_Off; 501 return Led_Off;
476} 502}
477 503
478/** 504/**
479* Set the state for a LED 505* Set the state for a LED
480* @param which Which OLed to use 506* @param which Which OLed to use
481* @param st The state to set 507* @param st The state to set
482* @return success or failure 508* @return success or failure
483*/ 509*/
484bool ODevice::setLedState ( OLed which, OLedState st ) 510bool ODevice::setLedState ( OLed which, OLedState st )
485{ 511{
486 Q_UNUSED( which ) 512 Q_UNUSED( which )
487 Q_UNUSED( st ) 513 Q_UNUSED( st )
488 return false; 514 return false;
489} 515}
490 516
491/** 517/**
492* @return if the device has a light sensor 518* @return if the device has a light sensor
493*/ 519*/
494bool ODevice::hasLightSensor() const 520bool ODevice::hasLightSensor() const
495{ 521{
496 return false; 522 return false;
497} 523}
498 524
499/** 525/**
500* @return a value from the light sensor 526* @return a value from the light sensor
501*/ 527*/
502int ODevice::readLightSensor() 528int ODevice::readLightSensor()
503{ 529{
504 return -1; 530 return -1;
505} 531}
506 532
507/** 533/**
508* @return the light sensor resolution 534* @return the light sensor resolution
509*/ 535*/
510int ODevice::lightSensorResolution() const 536int ODevice::lightSensorResolution() const
511{ 537{
512 return 0; 538 return 0;
513} 539}
514 540
515/** 541/**
516* @return if the device has a hinge sensor 542* @return if the device has a hinge sensor
517*/ 543*/
518bool ODevice::hasHingeSensor() const 544bool ODevice::hasHingeSensor() const
519{ 545{
520 return false; 546 return false;
521} 547}
522 548
523/** 549/**
524* @return a value from the hinge sensor 550* @return a value from the hinge sensor
525*/ 551*/
526OHingeStatus ODevice::readHingeSensor() 552OHingeStatus ODevice::readHingeSensor()
527{ 553{
528 return CASE_UNKNOWN; 554 return CASE_UNKNOWN;
529} 555}
530 556
531/** 557/**
532* @return a list with CPU frequencies supported by the hardware 558* @return a list with CPU frequencies supported by the hardware
533*/ 559*/
534const QStrList &ODevice::allowedCpuFrequencies() const 560const QStrList &ODevice::allowedCpuFrequencies() const
535{ 561{
536 return *d->m_cpu_frequencies; 562 return *d->m_cpu_frequencies;
537} 563}
538 564
539 565
540/** 566/**
541* Set desired CPU frequency 567* Set desired CPU frequency
542* 568*
543* @param index index into d->m_cpu_frequencies of the frequency to be set 569* @param index index into d->m_cpu_frequencies of the frequency to be set
544*/ 570*/
545bool ODevice::setCurrentCpuFrequency(uint index) 571bool ODevice::setCurrentCpuFrequency(uint index)
546{ 572{
547 if (index >= d->m_cpu_frequencies->count()) 573 if (index >= d->m_cpu_frequencies->count())
548 return false; 574 return false;
549 575
550 char *freq = d->m_cpu_frequencies->at(index); 576 char *freq = d->m_cpu_frequencies->at(index);
551 qWarning("set freq to %s", freq); 577 qWarning("set freq to %s", freq);
552 578
553 int fd; 579 int fd;
554 580
555 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 581 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
556 char writeCommand[50]; 582 char writeCommand[50];
557 const int count = sprintf(writeCommand, "%s\n", freq); 583 const int count = sprintf(writeCommand, "%s\n", freq);
558 int res = (::write(fd, writeCommand, count) != -1); 584 int res = (::write(fd, writeCommand, count) != -1);
559 ::close(fd); 585 ::close(fd);
560 return res; 586 return res;
561 } 587 }
562 588
563 return false; 589 return false;
564} 590}
565 591
566 592
567/** 593/**
568* @return a list of hardware buttons 594* @return a list of hardware buttons
569*/ 595*/
570const QValueList <ODeviceButton> &ODevice::buttons() 596const QValueList <ODeviceButton> &ODevice::buttons()
571{ 597{
572 initButtons(); 598 initButtons();
573 599
574 return *d->m_buttons; 600 return *d->m_buttons;
575} 601}
576 602
577/** 603/**
578* @return The amount of time that would count as a hold 604* @return The amount of time that would count as a hold
579*/ 605*/
580uint ODevice::buttonHoldTime() const 606uint ODevice::buttonHoldTime() const
581{ 607{
582 return d->m_holdtime; 608 return d->m_holdtime;
583} 609}
584 610
585/** 611/**
586* This method return a ODeviceButton for a key code 612* This method return a ODeviceButton for a key code
587* or 0 if no special hardware button is available for the device 613* or 0 if no special hardware button is available for the device
588* 614*
589* @return The devicebutton or 0l 615* @return The devicebutton or 0l
590* @see ODeviceButton 616* @see ODeviceButton
591*/ 617*/
592const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 618const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
593{ 619{
594 initButtons(); 620 initButtons();
595 621
596 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 622 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
597 if ( (*it). keycode() == code ) 623 if ( (*it). keycode() == code )
598 return &(*it); 624 return &(*it);
599 } 625 }
600 return 0; 626 return 0;
601} 627}
602 628
603void ODevice::reloadButtonMapping() 629void ODevice::reloadButtonMapping()
604{ 630{
605 initButtons(); 631 initButtons();
606 632
607 Config cfg ( "ButtonSettings" ); 633 Config cfg ( "ButtonSettings" );
608 634
609 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 635 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
610 ODeviceButton &b = ( *d->m_buttons ) [i]; 636 ODeviceButton &b = ( *d->m_buttons ) [i];
611 QString group = "Button" + QString::number ( i ); 637 QString group = "Button" + QString::number ( i );
612 638
613 QCString pch, hch; 639 QCString pch, hch;
614 QCString pm, hm; 640 QCString pm, hm;
615 QByteArray pdata, hdata; 641 QByteArray pdata, hdata;
616 642
617 if ( cfg. hasGroup ( group )) { 643 if ( cfg. hasGroup ( group )) {
618 cfg. setGroup ( group ); 644 cfg. setGroup ( group );
619 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 645 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
620 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 646 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
621 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 647 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
622 648
623 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 649 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
624 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 650 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
625 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 651 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
626 } 652 }
627 653
628 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 654 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
629 655
630 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 656 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
631 } 657 }
632} 658}
633 659
634void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 660void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
635{ 661{
636 initButtons(); 662 initButtons();
637 663
638 QString mb_chan; 664 QString mb_chan;
639 665
640 if ( button >= (int) d->m_buttons->count()) 666 if ( button >= (int) d->m_buttons->count())
641 return; 667 return;
642 668
643 ODeviceButton &b = ( *d->m_buttons ) [button]; 669 ODeviceButton &b = ( *d->m_buttons ) [button];
644 b. setPressedAction ( action ); 670 b. setPressedAction ( action );
645 671
646 mb_chan=b. pressedAction(). channel(); 672 mb_chan=b. pressedAction(). channel();
647 673
648 Config buttonFile ( "ButtonSettings" ); 674 Config buttonFile ( "ButtonSettings" );
649 buttonFile. setGroup ( "Button" + QString::number ( button )); 675 buttonFile. setGroup ( "Button" + QString::number ( button ));
650 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 676 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
651 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 677 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
652 678
653 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 679 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
654 680
655 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 681 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
656} 682}
657 683
658void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 684void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
659{ 685{
660 initButtons(); 686 initButtons();
661 687
662 if ( button >= (int) d->m_buttons->count()) 688 if ( button >= (int) d->m_buttons->count())
663 return; 689 return;
664 690
665 ODeviceButton &b = ( *d->m_buttons ) [button]; 691 ODeviceButton &b = ( *d->m_buttons ) [button];
666 b. setHeldAction ( action ); 692 b. setHeldAction ( action );
667 693
668 Config buttonFile ( "ButtonSettings" ); 694 Config buttonFile ( "ButtonSettings" );
669 buttonFile. setGroup ( "Button" + QString::number ( button )); 695 buttonFile. setGroup ( "Button" + QString::number ( button ));
670 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 696 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
671 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 697 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
672 698
673 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 699 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
674 700
675 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 701 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
676} 702}
677void ODevice::virtual_hook(int, void* ){ 703void ODevice::virtual_hook(int, void* ){
678 704
679} 705}
680 706
681void ODevice::sendSuspendmsg() 707void ODevice::sendSuspendmsg()
682{ 708{
683 if ( isQWS() ) 709 if ( isQWS() )
684 return; 710 return;
685 711
686 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 712 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
687} 713}
714
715
716}
717}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 474d792..0465d7e 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,373 +1,358 @@
1/* 1/*
2 � � � � � � � � This file is part of the Opie Project 2 � � � � � � � � This file is part of the Opie Project
3� � � � � � � Copyright (C) The Opie Team <opie-devel@handhelds.org> 3� � � � � � � Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6� � � � � �.>+-= 6� � � � � �.>+-=
7�_;:, � � .> � �:=|. This program is free software; you can 7�_;:, � � .> � �:=|. This program is free software; you can
8.> <`_, � > �. � <= redistribute it and/or modify it under 8.> <`_, � > �. � <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- � : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- � : the terms of the GNU Library General Public
10.="- .-=="i, � � .._ License as published by the Free Software 10.="- .-=="i, � � .._ License as published by the Free Software
11�- . � .-<_> � � .<> Foundation; either version 2 of the License, 11�- . � .-<_> � � .<> Foundation; either version 2 of the License,
12� � �._= =} � � � : or (at your option) any later version. 12� � �._= =} � � � : or (at your option) any later version.
13� � .%`+i> � � � _;_. 13� � .%`+i> � � � _;_.
14� � .i_,=:_. � � �-<s. This program is distributed in the hope that 14� � .i_,=:_. � � �-<s. This program is distributed in the hope that
15� � �+ �. �-:. � � � = it will be useful, but WITHOUT ANY WARRANTY; 15� � �+ �. �-:. � � � = it will be useful, but WITHOUT ANY WARRANTY;
16� � : .. � �.:, � � . . . without even the implied warranty of 16� � : .. � �.:, � � . . . without even the implied warranty of
17� � =_ � � � �+ � � =;=|` MERCHANTABILITY or FITNESS FOR A 17� � =_ � � � �+ � � =;=|` MERCHANTABILITY or FITNESS FOR A
18� _.=:. � � � : � �:=>`: PARTICULAR PURPOSE. See the GNU 18� _.=:. � � � : � �:=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= � � � = � � � ; Library General Public License for more 19..}^=.= � � � = � � � ; Library General Public License for more
20++= � -. � � .` � � .: details. 20++= � -. � � .` � � .: details.
21�: � � = �...= . :.=- 21�: � � = �...= . :.=-
22�-. � .:....=;==+<; You should have received a copy of the GNU 22�-. � .:....=;==+<; You should have received a copy of the GNU
23� -_. . . � )=. �= Library General Public License along with 23� -_. . . � )=. �= Library General Public License along with
24� � -- � � � �:-=` this library; see the file COPYING.LIB. 24� � -- � � � �:-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie{ 43namespace Opie{
44namespace Core{ 44namespace Core{
45 45
46 class ODeviceData; 46 class ODeviceData;
47/** 47/**
48 * The available devices 48 * The available devices
49 */ 49 */
50enum OModel { 50enum OModel {
51 Model_Unknown, // = 0 51 Model_Unknown, // = 0
52 52
53 Model_Series_Mask = 0xff000000, 53 Model_Series_Mask = 0xff000000,
54 54
55 Model_iPAQ = ( 1 << 24 ), 55 Model_iPAQ = ( 1 << 24 ),
56 56
57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), 63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
64 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 64 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
65 65
66 Model_Jornada = ( 6 << 24 ), 66 Model_Jornada = ( 6 << 24 ),
67 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 67 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
68 68
69 Model_Zaurus = ( 2 << 24 ), 69 Model_Zaurus = ( 2 << 24 ),
70 70
71 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 71 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
72 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 72 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
73 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 73 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
74 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 74 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
75 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 75 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
76 76
77 Model_SIMpad = ( 3 << 24 ), 77 Model_SIMpad = ( 3 << 24 ),
78 78
79 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 79 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
80 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 80 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
81 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 81 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
82 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 82 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
83 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 83 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
84 84
85 Model_Ramses = ( 4 << 24 ), 85 Model_Ramses = ( 4 << 24 ),
86 86
87 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 87 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
88 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 88 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
89 89
90 Model_Yopy = ( 5 << 24 ), 90 Model_Yopy = ( 5 << 24 ),
91 91
92 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 92 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
93 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 93 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
94 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 94 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
95 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 95 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
96 96
97 Model_Beagle = ( 6 << 24 ), 97 Model_Beagle = ( 6 << 24 ),
98 98
99 Model_Beagle_All = ( Model_Beagle | 0xffffff ), 99 Model_Beagle_All = ( Model_Beagle | 0xffffff ),
100 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), 100 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ),
101 101
102}; 102};
103 103
104/** 104/**
105 * The vendor of the device 105 * The vendor of the device
106 */ 106 */
107enum OVendor { 107enum OVendor {
108 Vendor_Unknown, 108 Vendor_Unknown,
109 109
110 Vendor_HP, 110 Vendor_HP,
111 Vendor_Sharp, 111 Vendor_Sharp,
112 Vendor_SIEMENS, 112 Vendor_SIEMENS,
113 Vendor_MundN, 113 Vendor_MundN,
114 Vendor_GMate, 114 Vendor_GMate,
115 Vendor_MasterIA, 115 Vendor_MasterIA,
116}; 116};
117 117
118/** 118/**
119 * The System used 119 * The System used
120 */ 120 */
121enum OSystem { 121enum OSystem {
122 System_Unknown, 122 System_Unknown,
123 123
124 System_Familiar, 124 System_Familiar,
125 System_Zaurus, 125 System_Zaurus,
126 System_OpenZaurus, 126 System_OpenZaurus,
127 System_Linupy, 127 System_Linupy,
128 System_OpenEmbedded, 128 System_OpenEmbedded,
129}; 129};
130 130
131typedef struct { 131typedef struct {
132 OSystem system; 132 OSystem system;
133 char* sysstr; 133 char* sysstr;
134 char* sysvfile; 134 char* sysvfile;
135} ODistribution; 135} ODistribution;
136 136
137static ODistribution distributions[] = 137extern ODistribution distributions[];
138{
139 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
140 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
141 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
142 { System_Unknown, "Linux", "/etc/issue" },
143 138
144};
145 139
146enum OLedState { 140enum OLedState {
147 Led_Off, 141 Led_Off,
148 Led_On, 142 Led_On,
149 Led_BlinkSlow, 143 Led_BlinkSlow,
150 Led_BlinkFast 144 Led_BlinkFast
151}; 145};
152 146
153enum OLed { 147enum OLed {
154 Led_Mail, 148 Led_Mail,
155 Led_Power, 149 Led_Power,
156 Led_BlueTooth 150 Led_BlueTooth
157}; 151};
158 152
159enum OHardKey { 153enum OHardKey {
160 HardKey_Datebook = Qt::Key_F9, 154 HardKey_Datebook = Qt::Key_F9,
161 HardKey_Contacts = Qt::Key_F10, 155 HardKey_Contacts = Qt::Key_F10,
162 HardKey_Menu = Qt::Key_F11, 156 HardKey_Menu = Qt::Key_F11,
163 HardKey_Home = Qt::Key_F12, 157 HardKey_Home = Qt::Key_F12,
164 HardKey_Mail = Qt::Key_F13, 158 HardKey_Mail = Qt::Key_F13,
165 HardKey_Record = Qt::Key_F24, 159 HardKey_Record = Qt::Key_F24,
166 HardKey_Suspend = Qt::Key_F34, 160 HardKey_Suspend = Qt::Key_F34,
167 HardKey_Backlight = Qt::Key_F35, 161 HardKey_Backlight = Qt::Key_F35,
168 HardKey_Action = Qt::Key_F10, 162 HardKey_Action = Qt::Key_F10,
169 HardKey_OK = Qt::Key_F11, 163 HardKey_OK = Qt::Key_F11,
170 HardKey_End = Qt::Key_F12, 164 HardKey_End = Qt::Key_F12,
171}; 165};
172 166
173enum ODirection { 167enum ODirection {
174 CW = 0, 168 CW = 0,
175 CCW = 1, 169 CCW = 1,
176 Flip = 2, 170 Flip = 2,
177}; 171};
178 172
179enum OHingeStatus { 173enum OHingeStatus {
180 CASE_CLOSED = 3, 174 CASE_CLOSED = 3,
181 CASE_PORTRAIT = 2, 175 CASE_PORTRAIT = 2,
182 CASE_LANDSCAPE = 0, 176 CASE_LANDSCAPE = 0,
183 CASE_UNKNOWN = 1, 177 CASE_UNKNOWN = 1,
184}; 178};
185 179
186/* default button for qvfb or such 180/* default button for qvfb or such
187 * see odevice.cpp for details. 181 * see odevice.cpp for details.
188 * hint: manage a user defined button for qvfb? 182 * hint: manage a user defined button for qvfb?
189 * alwin 183 * alwin
190 */ 184 */
191struct default_button { 185struct default_button {
192 Qt::Key code; 186 Qt::Key code;
193 char *utext; 187 char *utext;
194 char *pix; 188 char *pix;
195 char *fpressedservice; 189 char *fpressedservice;
196 char *fpressedaction; 190 char *fpressedaction;
197 char *fheldservice; 191 char *fheldservice;
198 char *fheldaction; 192 char *fheldaction;
199}; 193};
200 194
201/** 195/**
202 * A singleton which gives informations about device specefic option 196 * A singleton which gives informations about device specefic option
203 * like the Hardware used, LEDs, the Base Distribution and 197 * like the Hardware used, LEDs, the Base Distribution and
204 * hardware key mappings. 198 * hardware key mappings.
205 * 199 *
206 * @short A small class for device specefic options 200 * @short A small class for device specefic options
207 * @see QObject 201 * @see QObject
208 * @author Robert Griebl 202 * @author Robert Griebl
209 * @version 1.0 203 * @version 1.0
210 */ 204 */
211class ODevice : public QObject 205class ODevice : public QObject
212{ 206{
213 Q_OBJECT 207 Q_OBJECT
214 208
215private: 209private:
216 /* disable copy */ 210 /* disable copy */
217 ODevice ( const ODevice & ); 211 ODevice ( const ODevice & );
218 212
219protected: 213protected:
220 ODevice(); 214 ODevice();
221 virtual void init(const QString&); 215 virtual void init(const QString&);
222 virtual void initButtons(); 216 virtual void initButtons();
223 static void sendSuspendmsg(); 217 static void sendSuspendmsg();
224 218
225 ODeviceData *d; 219 ODeviceData *d;
226 220
227public: 221public:
228 // sandman do we want to allow destructions? -zecke? 222 // sandman do we want to allow destructions? -zecke?
229 virtual ~ODevice(); 223 virtual ~ODevice();
230 224
231 static ODevice *inst(); 225 static ODevice *inst();
232 226
233 // information 227 // information
234 228
235 QString modelString() const; 229 QString modelString() const;
236 OModel model() const; 230 OModel model() const;
237 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 231 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
238 232
239 QString vendorString() const; 233 QString vendorString() const;
240 OVendor vendor() const; 234 OVendor vendor() const;
241 235
242 QString systemString() const; 236 QString systemString() const;
243 OSystem system() const; 237 OSystem system() const;
244 238
245 QString systemVersionString() const; 239 QString systemVersionString() const;
246 240
247 virtual Transformation rotation() const; 241 virtual Transformation rotation() const;
248 virtual ODirection direction() const; 242 virtual ODirection direction() const;
249 243
250 // system 244 // system
251 245
252 virtual bool setSoftSuspend ( bool on ); 246 virtual bool setSoftSuspend ( bool on );
253 virtual bool suspend(); 247 virtual bool suspend();
254 248
255 virtual bool setDisplayStatus ( bool on ); 249 virtual bool setDisplayStatus ( bool on );
256 virtual bool setDisplayBrightness ( int brightness ); 250 virtual bool setDisplayBrightness ( int brightness );
257 virtual int displayBrightnessResolution() const; 251 virtual int displayBrightnessResolution() const;
258 virtual bool setDisplayContrast ( int contrast ); 252 virtual bool setDisplayContrast ( int contrast );
259 virtual int displayContrastResolution() const; 253 virtual int displayContrastResolution() const;
260 254
261 // don't add new virtual methods, use this: 255 // don't add new virtual methods, use this:
262 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 256 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
263 // and in your subclass do do overwrite 257 // and in your subclass do do overwrite
264 //protected virtual int virtual_hook(int, void *) 258 //protected virtual int virtual_hook(int, void *)
265 // which is defined below 259 // which is defined below
266 260
267 // input / output 261 // input / output
268 virtual void playAlarmSound(); 262 virtual void playAlarmSound();
269 virtual void playKeySound(); 263 virtual void playKeySound();
270 virtual void playTouchSound(); 264 virtual void playTouchSound();
271 265
272 virtual QValueList <OLed> ledList() const; 266 virtual QValueList <OLed> ledList() const;
273 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 267 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
274 virtual OLedState ledState ( OLed led ) const; 268 virtual OLedState ledState ( OLed led ) const;
275 virtual bool setLedState ( OLed led, OLedState st ); 269 virtual bool setLedState ( OLed led, OLedState st );
276 270
277 virtual bool hasLightSensor() const; 271 virtual bool hasLightSensor() const;
278 virtual int readLightSensor(); 272 virtual int readLightSensor();
279 virtual int lightSensorResolution() const; 273 virtual int lightSensorResolution() const;
280 274
281 virtual bool hasHingeSensor() const; 275 virtual bool hasHingeSensor() const;
282 virtual OHingeStatus readHingeSensor(); 276 virtual OHingeStatus readHingeSensor();
283 277
284 const QStrList &allowedCpuFrequencies() const; 278 const QStrList &allowedCpuFrequencies() const;
285 bool setCurrentCpuFrequency(uint index); 279 bool setCurrentCpuFrequency(uint index);
286 280
287 /** 281 /**
288 * Returns the available buttons on this device. The number and location 282 * Returns the available buttons on this device. The number and location
289 * of buttons will vary depending on the device. Button numbers will be assigned 283 * of buttons will vary depending on the device. Button numbers will be assigned
290 * by the device manufacturer and will be from most preferred button to least preffered 284 * by the device manufacturer and will be from most preferred button to least preffered
291 * button. Note that this list only contains "user mappable" buttons. 285 * button. Note that this list only contains "user mappable" buttons.
292 * 286 *
293 * @todo Make method const and take care of calling initButtons or make that const too 287 * @todo Make method const and take care of calling initButtons or make that const too
294 * 288 *
295 */ 289 */
296 const QValueList<ODeviceButton> &buttons(); 290 const QValueList<ODeviceButton> &buttons();
297 291
298 /** 292 /**
299 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 293 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
300 * returns 0L 294 * returns 0L
301 */ 295 */
302 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 296 const ODeviceButton *buttonForKeycode ( ushort keyCode );
303 297
304 /** 298 /**
305 * Reassigns the pressed action for \a button. To return to the factory 299 * Reassigns the pressed action for \a button. To return to the factory
306 * default pass an empty string as \a qcopMessage. 300 * default pass an empty string as \a qcopMessage.
307 */ 301 */
308 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 302 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
309 303
310 /** 304 /**
311 * Reassigns the held action for \a button. To return to the factory 305 * Reassigns the held action for \a button. To return to the factory
312 * default pass an empty string as \a qcopMessage. 306 * default pass an empty string as \a qcopMessage.
313 */ 307 */
314 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 308 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
315 309
316 /** 310 /**
317 * How long (in ms) you have to press a button for a "hold" action 311 * How long (in ms) you have to press a button for a "hold" action
318 */ 312 */
319 uint buttonHoldTime() const; 313 uint buttonHoldTime() const;
320 314
321signals: 315signals:
322 void buttonMappingChanged(); 316 void buttonMappingChanged();
323 317
324private slots: 318private slots:
325 void systemMessage ( const QCString &, const QByteArray & ); 319 void systemMessage ( const QCString &, const QByteArray & );
326 320
327protected: 321protected:
328 void reloadButtonMapping(); 322 void reloadButtonMapping();
329 /* ugly virtual hook */ 323 /* ugly virtual hook */
330 virtual void virtual_hook( int id, void* data ); 324 virtual void virtual_hook( int id, void* data );
331}; 325};
332 326
333class ODeviceData { 327class ODeviceData {
334 328
335 public: 329 public:
336 QString m_vendorstr; 330 QString m_vendorstr;
337 OVendor m_vendor; 331 OVendor m_vendor;
338 332
339 QString m_modelstr; 333 QString m_modelstr;
340 OModel m_model; 334 OModel m_model;
341 335
342 QString m_systemstr; 336 QString m_systemstr;
343 OSystem m_system; 337 OSystem m_system;
344 338
345 QString m_sysverstr; 339 QString m_sysverstr;
346 340
347 Transformation m_rotation; 341 Transformation m_rotation;
348 ODirection m_direction; 342 ODirection m_direction;
349 343
350 QValueList <ODeviceButton> *m_buttons; 344 QValueList <ODeviceButton> *m_buttons;
351 uint m_holdtime; 345 uint m_holdtime;
352 QStrList *m_cpu_frequencies; 346 QStrList *m_cpu_frequencies;
353}; 347};
354 348
349extern bool isQWS();
350extern QCString makeChannel ( const char *str );
355} 351}
356} 352}
357 353
358static inline bool isQWS()
359{
360 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
361}
362 354
363static QCString makeChannel ( const char *str )
364{
365 if ( str && !::strchr ( str, '/' ))
366 return QCString ( "QPE/Application/" ) + str;
367 else
368 return str;
369}
370 355
371 356
372#endif 357#endif
373 358