summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index fcdbf45..dd1e2f3 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,99 +1,101 @@
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
4 Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
4 =. 5 =.
5 .=l. 6 .=l.
6           .>+-= 7           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 14    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 17 : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 21++=   -.     .`     .: details.
21 :     =  ...= . :.=- 22:     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
28*/ 29*/
29 30
30#include "odevice_beagle.h" 31#include "odevice_beagle.h"
31#include "odevice_ipaq.h" 32#include "odevice_ipaq.h"
32#include "odevice_jornada.h" 33#include "odevice_jornada.h"
33#include "odevice_ramses.h" 34#include "odevice_ramses.h"
34#include "odevice_simpad.h" 35#include "odevice_simpad.h"
35#include "odevice_yopy.h" 36#include "odevice_yopy.h"
36#include "odevice_zaurus.h" 37#include "odevice_zaurus.h"
37#include "odevice_genuineintel.h" 38#include "odevice_genuineintel.h"
38 39
39/* QT */ 40/* QT */
40#include <qapplication.h> 41#include <qapplication.h>
41#include <qfile.h> 42#include <qfile.h>
42#include <qtextstream.h> 43#include <qtextstream.h>
43#include <qwindowsystem_qws.h> 44#include <qwindowsystem_qws.h>
44 45
45/* OPIE */ 46/* OPIE */
46#include <qpe/config.h> 47#include <qpe/config.h>
47#include <qpe/resource.h>
48#include <qpe/sound.h> 48#include <qpe/sound.h>
49#include <qpe/qcopenvelope_qws.h> 49#include <qpe/qcopenvelope_qws.h>
50#include <qpe/sound.h> 50#include <qpe/sound.h>
51
51#include <opie2/okeyfilter.h> 52#include <opie2/okeyfilter.h>
53#include <opie2/oresource.h>
52 54
53/* STD */ 55/* STD */
54#include <fcntl.h> 56#include <fcntl.h>
55#include <math.h> 57#include <math.h>
56#include <stdlib.h> 58#include <stdlib.h>
57#include <signal.h> 59#include <signal.h>
58#include <sys/ioctl.h> 60#include <sys/ioctl.h>
59#include <sys/time.h> 61#include <sys/time.h>
60#include <unistd.h> 62#include <unistd.h>
61#ifndef QT_NO_SOUND 63#ifndef QT_NO_SOUND
62#include <linux/soundcard.h> 64#include <linux/soundcard.h>
63#endif 65#endif
64 66
65namespace Opie { 67namespace Opie {
66namespace Core { 68namespace Core {
67 69
68static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 70static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
69 71
70 72
71/* STATIC and common implementation */ 73/* STATIC and common implementation */
72/* EXPORT */ ODistribution distributions[] = { 74/* EXPORT */ ODistribution distributions[] = {
73 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 75 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
74 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 76 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
75 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 77 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
76 { System_Unknown, "Linux", "/etc/issue" }, 78 { System_Unknown, "Linux", "/etc/issue" },
77}; 79};
78 80
79 81
80/* EXPORT */ bool isQWS(){ 82/* EXPORT */ bool isQWS(){
81 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 83 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
82} 84}
83 85
84/* EXPORT */ QCString makeChannel ( const char *str ){ 86/* EXPORT */ QCString makeChannel ( const char *str ){
85 if ( str && !::strchr ( str, '/' )) 87 if ( str && !::strchr ( str, '/' ))
86 return QCString ( "QPE/Application/" ) + str; 88 return QCString ( "QPE/Application/" ) + str;
87 else 89 else
88 return str; 90 return str;
89} 91}
90 92
91 93
92 94
93/* Now the default implementation of ODevice */ 95/* Now the default implementation of ODevice */
94 96
95struct default_button default_buttons [] = { 97struct default_button default_buttons [] = {
96 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 98 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
97 "devicebuttons/z_calendar", 99 "devicebuttons/z_calendar",
98 "datebook", "nextView()", 100 "datebook", "nextView()",
99 "today", "raise()" }, 101 "today", "raise()" },
@@ -190,97 +192,97 @@ ODevice::ODevice()
190 // New distribution detection code first checks for legacy distributions, 192 // New distribution detection code first checks for legacy distributions,
191 // identified by /etc/familiar-version or /etc/oz_version. 193 // identified by /etc/familiar-version or /etc/oz_version.
192 // Then check for OpenEmbedded and lastly, read /etc/issue 194 // Then check for OpenEmbedded and lastly, read /etc/issue
193 195
194 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) 196 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i )
195 { 197 {
196 if ( QFile::exists( distributions[i].sysvfile ) ) 198 if ( QFile::exists( distributions[i].sysvfile ) )
197 { 199 {
198 d->m_systemstr = distributions[i].sysstr; 200 d->m_systemstr = distributions[i].sysstr;
199 d->m_system = distributions[i].system; 201 d->m_system = distributions[i].system;
200 d->m_sysverstr = "<Unknown>"; 202 d->m_sysverstr = "<Unknown>";
201 QFile f( distributions[i].sysvfile ); 203 QFile f( distributions[i].sysvfile );
202 if ( f.open( IO_ReadOnly ) ) 204 if ( f.open( IO_ReadOnly ) )
203 { 205 {
204 QTextStream ts( &f ); 206 QTextStream ts( &f );
205 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 207 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
206 } 208 }
207 break; 209 break;
208 } 210 }
209 } 211 }
210} 212}
211 213
212void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 214void ODevice::systemMessage( const QCString &msg, const QByteArray & )
213{ 215{
214 if ( msg == "deviceButtonMappingChanged()" ) { 216 if ( msg == "deviceButtonMappingChanged()" ) {
215 reloadButtonMapping(); 217 reloadButtonMapping();
216 } 218 }
217} 219}
218 220
219void ODevice::init(const QString&) 221void ODevice::init(const QString&)
220{ 222{
221} 223}
222 224
223/** 225/**
224* This method initialises the button mapping 226* This method initialises the button mapping
225*/ 227*/
226void ODevice::initButtons() 228void ODevice::initButtons()
227{ 229{
228 if ( d->m_buttons ) 230 if ( d->m_buttons )
229 return; 231 return;
230 232
231 qDebug ( "init Buttons" ); 233 qDebug ( "init Buttons" );
232 d->m_buttons = new QValueList <ODeviceButton>; 234 d->m_buttons = new QValueList <ODeviceButton>;
233 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 235 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
234 default_button *db = default_buttons + i; 236 default_button *db = default_buttons + i;
235 ODeviceButton b; 237 ODeviceButton b;
236 b. setKeycode ( db->code ); 238 b. setKeycode ( db->code );
237 b. setUserText ( QObject::tr ( "Button", db->utext )); 239 b. setUserText ( QObject::tr ( "Button", db->utext ));
238 b. setPixmap ( Resource::loadPixmap ( db->pix )); 240 b. setPixmap ( OResource::loadPixmap ( db->pix ));
239 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 241 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
240 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 242 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
241 d->m_buttons->append ( b ); 243 d->m_buttons->append ( b );
242 } 244 }
243 245
244 reloadButtonMapping(); 246 reloadButtonMapping();
245} 247}
246 248
247ODevice::~ODevice() 249ODevice::~ODevice()
248{ 250{
249// we leak m_devicebuttons and m_cpu_frequency 251// we leak m_devicebuttons and m_cpu_frequency
250// but it's a singleton and it is not so importantant 252// but it's a singleton and it is not so importantant
251// -zecke 253// -zecke
252 delete d; 254 delete d;
253} 255}
254 256
255/** 257/**
256* This method will try to suspend the device 258* This method will try to suspend the device
257* It only works if the user is the QWS Server and the apm application 259* It only works if the user is the QWS Server and the apm application
258* is installed. 260* is installed.
259* It tries to suspend and then waits some time cause some distributions 261* It tries to suspend and then waits some time cause some distributions
260* do have asynchronus apm implementations. 262* do have asynchronus apm implementations.
261* This method will either fail and return false or it'll suspend the 263* This method will either fail and return false or it'll suspend the
262* device and return once the device got woken up 264* device and return once the device got woken up
263* 265*
264* @return if the device got suspended 266* @return if the device got suspended
265*/ 267*/
266bool ODevice::suspend() 268bool ODevice::suspend()
267{ 269{
268 return false; // default implementation == unknown device or qvfb 270 return false; // default implementation == unknown device or qvfb
269} 271}
270 272
271/** 273/**
272* This sets the display on or off 274* This sets the display on or off
273*/ 275*/
274bool ODevice::setDisplayStatus( bool on ) 276bool ODevice::setDisplayStatus( bool on )
275{ 277{
276 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); 278 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on );
277 return false; // don't do anything for unknown models 279 return false; // don't do anything for unknown models
278} 280}
279 281
280/** 282/**
281* This sets the display brightness 283* This sets the display brightness
282* 284*
283* @param b The brightness to be set on a scale from 0 to 255 285* @param b The brightness to be set on a scale from 0 to 255
284* @return success or failure 286* @return success or failure
285*/ 287*/
286bool ODevice::setDisplayBrightness( int b ) 288bool ODevice::setDisplayBrightness( int b )