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