summaryrefslogtreecommitdiff
authoralwin <alwin>2004-08-01 19:54:59 (UTC)
committer alwin <alwin>2004-08-01 19:54:59 (UTC)
commit9084969d2d4fa39d4d2c185695f0c88739a0f95c (patch) (unidiff)
tree4c76ee5bf61e9f0a883381d2ac68291075cfd541
parent3d67a6ef781f59f9db936442a5b44329a0d5c70b (diff)
downloadopie-9084969d2d4fa39d4d2c185695f0c88739a0f95c.zip
opie-9084969d2d4fa39d4d2c185695f0c88739a0f95c.tar.gz
opie-9084969d2d4fa39d4d2c185695f0c88739a0f95c.tar.bz2
cleanup - odevice is now and for future the one and only friend class
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp57
-rw-r--r--libopie2/opiecore/device/odevice.h49
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp3
-rw-r--r--libopie2/opiecore/okeyfilter.h7
5 files changed, 63 insertions, 56 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 0068d88..cd3a84c 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,239 +1,240 @@
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 49
49/* STD */ 50/* STD */
50#include <fcntl.h> 51#include <fcntl.h>
51#include <math.h> 52#include <math.h>
52#include <stdlib.h> 53#include <stdlib.h>
53#include <signal.h> 54#include <signal.h>
54#include <sys/ioctl.h> 55#include <sys/ioctl.h>
55#include <sys/time.h> 56#include <sys/time.h>
56#include <unistd.h> 57#include <unistd.h>
57#ifndef QT_NO_SOUND 58#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 59#include <linux/soundcard.h>
59#endif 60#endif
60 61
61namespace Opie { 62namespace Opie {
62namespace Core { 63namespace Core {
63 64
64static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 65static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
65 66
66 67
67/* STATIC and common implementation */ 68/* STATIC and common implementation */
68/* EXPORT */ ODistribution distributions[] = { 69/* EXPORT */ ODistribution distributions[] = {
69 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 70 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
70 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 71 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
71 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 72 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
72 { System_Unknown, "Linux", "/etc/issue" }, 73 { System_Unknown, "Linux", "/etc/issue" },
73}; 74};
74 75
75 76
76/* EXPORT */ bool isQWS(){ 77/* EXPORT */ bool isQWS(){
77 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 78 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
78} 79}
79 80
80/* EXPORT */ QCString makeChannel ( const char *str ){ 81/* EXPORT */ QCString makeChannel ( const char *str ){
81 if ( str && !::strchr ( str, '/' )) 82 if ( str && !::strchr ( str, '/' ))
82 return QCString ( "QPE/Application/" ) + str; 83 return QCString ( "QPE/Application/" ) + str;
83 else 84 else
84 return str; 85 return str;
85} 86}
86 87
87 88
88 89
89/* Now the default implementation of ODevice */ 90/* Now the default implementation of ODevice */
90 91
91struct default_button default_buttons [] = { 92struct default_button default_buttons [] = {
92 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 93 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
93 "devicebuttons/z_calendar", 94 "devicebuttons/z_calendar",
94 "datebook", "nextView()", 95 "datebook", "nextView()",
95 "today", "raise()" }, 96 "today", "raise()" },
96 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 97 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
97 "devicebuttons/z_contact", 98 "devicebuttons/z_contact",
98 "addressbook", "raise()", 99 "addressbook", "raise()",
99 "addressbook", "beamBusinessCard()" }, 100 "addressbook", "beamBusinessCard()" },
100 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 101 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
101 "devicebuttons/z_home", 102 "devicebuttons/z_home",
102 "QPE/Launcher", "home()", 103 "QPE/Launcher", "home()",
103 "buttonsettings", "raise()" }, 104 "buttonsettings", "raise()" },
104 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 105 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
105 "devicebuttons/z_menu", 106 "devicebuttons/z_menu",
106 "QPE/TaskBar", "toggleMenu()", 107 "QPE/TaskBar", "toggleMenu()",
107 "QPE/TaskBar", "toggleStartMenu()" }, 108 "QPE/TaskBar", "toggleStartMenu()" },
108 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 109 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
109 "devicebuttons/z_mail", 110 "devicebuttons/z_mail",
110 "opiemail", "raise()", 111 "opiemail", "raise()",
111 "opiemail", "newMail()" }, 112 "opiemail", "newMail()" },
112}; 113};
113 114
114ODevice *ODevice::inst() 115ODevice *ODevice::inst()
115{ 116{
116 static ODevice *dev = 0; 117 static ODevice *dev = 0;
117 118
118 // rewrite this to only use /proc/cpuinfo or so 119 // rewrite this to only use /proc/cpuinfo or so
119 QString cpu_info; 120 QString cpu_info;
120 121
121 if ( !dev ) 122 if ( !dev )
122 { 123 {
123 QFile f( PATH_PROC_CPUINFO ); 124 QFile f( PATH_PROC_CPUINFO );
124 if ( f.open( IO_ReadOnly ) ) 125 if ( f.open( IO_ReadOnly ) )
125 { 126 {
126 QTextStream s( &f ); 127 QTextStream s( &f );
127 while ( !s.atEnd() ) 128 while ( !s.atEnd() )
128 { 129 {
129 QString line; 130 QString line;
130 line = s.readLine(); 131 line = s.readLine();
131 if ( line.startsWith( "Hardware" ) ) 132 if ( line.startsWith( "Hardware" ) )
132 { 133 {
133 qDebug( "ODevice() - found '%s'", (const char*) line ); 134 qDebug( "ODevice() - found '%s'", (const char*) line );
134 cpu_info = line; 135 cpu_info = line;
135 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 136 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
136 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 137 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
137 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 138 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
138 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 139 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
139 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 140 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
140 else qWarning( "ODevice() - unknown hardware - using default." ); 141 else qWarning( "ODevice() - unknown hardware - using default." );
141 break; 142 break;
142 } 143 }
143 } 144 }
144 } 145 }
145 else 146 else
146 { 147 {
147 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 );
148 } 149 }
149 if ( !dev ) dev = new ODevice(); 150 if ( !dev ) dev = new ODevice();
150 dev->init(cpu_info); 151 dev->init(cpu_info);
151 } 152 }
152 return dev; 153 return dev;
153} 154}
154 155
155ODevice::ODevice() 156ODevice::ODevice()
156{ 157{
157 d = new ODeviceData; 158 d = new ODeviceData;
158 159
159 d->m_modelstr = "Unknown"; 160 d->m_modelstr = "Unknown";
160 d->m_model = Model_Unknown; 161 d->m_model = Model_Unknown;
161 d->m_vendorstr = "Unknown"; 162 d->m_vendorstr = "Unknown";
162 d->m_vendor = Vendor_Unknown; 163 d->m_vendor = Vendor_Unknown;
163 d->m_systemstr = "Unknown"; 164 d->m_systemstr = "Unknown";
164 d->m_system = System_Unknown; 165 d->m_system = System_Unknown;
165 d->m_sysverstr = "0.0"; 166 d->m_sysverstr = "0.0";
166 d->m_rotation = Rot0; 167 d->m_rotation = Rot0;
167 d->m_direction = CW; 168 d->m_direction = CW;
168 169
169 d->m_holdtime = 1000; // 1000ms 170 d->m_holdtime = 1000; // 1000ms
170 d->m_buttons = 0; 171 d->m_buttons = 0;
171 d->m_cpu_frequencies = new QStrList; 172 d->m_cpu_frequencies = new QStrList;
172 173
173 // New distribution detection code first checks for legacy distributions, 174 // New distribution detection code first checks for legacy distributions,
174 // identified by /etc/familiar-version or /etc/oz_version. 175 // identified by /etc/familiar-version or /etc/oz_version.
175 // Then check for OpenEmbedded and lastly, read /etc/issue 176 // Then check for OpenEmbedded and lastly, read /etc/issue
176 177
177 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 178 for ( unsigned int i = 0; i < sizeof distributions; ++i )
178 { 179 {
179 if ( QFile::exists( distributions[i].sysvfile ) ) 180 if ( QFile::exists( distributions[i].sysvfile ) )
180 { 181 {
181 d->m_systemstr = distributions[i].sysstr; 182 d->m_systemstr = distributions[i].sysstr;
182 d->m_system = distributions[i].system; 183 d->m_system = distributions[i].system;
183 d->m_sysverstr = "<Unknown>"; 184 d->m_sysverstr = "<Unknown>";
184 QFile f( distributions[i].sysvfile ); 185 QFile f( distributions[i].sysvfile );
185 if ( f.open( IO_ReadOnly ) ) 186 if ( f.open( IO_ReadOnly ) )
186 { 187 {
187 QTextStream ts( &f ); 188 QTextStream ts( &f );
188 d->m_sysverstr = ts.readLine(); 189 d->m_sysverstr = ts.readLine();
189 } 190 }
190 break; 191 break;
191 } 192 }
192 } 193 }
193} 194}
194 195
195void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 196void ODevice::systemMessage( const QCString &msg, const QByteArray & )
196{ 197{
197 if ( msg == "deviceButtonMappingChanged()" ) { 198 if ( msg == "deviceButtonMappingChanged()" ) {
198 reloadButtonMapping(); 199 reloadButtonMapping();
199 } 200 }
200} 201}
201 202
202void ODevice::init(const QString&) 203void ODevice::init(const QString&)
203{ 204{
204} 205}
205 206
206/** 207/**
207* This method initialises the button mapping 208* This method initialises the button mapping
208*/ 209*/
209void ODevice::initButtons() 210void ODevice::initButtons()
210{ 211{
211 if ( d->m_buttons ) 212 if ( d->m_buttons )
212 return; 213 return;
213 214
214 qDebug ( "init Buttons" ); 215 qDebug ( "init Buttons" );
215 d->m_buttons = new QValueList <ODeviceButton>; 216 d->m_buttons = new QValueList <ODeviceButton>;
216 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++ ) {
217 default_button *db = default_buttons + i; 218 default_button *db = default_buttons + i;
218 ODeviceButton b; 219 ODeviceButton b;
219 b. setKeycode ( db->code ); 220 b. setKeycode ( db->code );
220 b. setUserText ( QObject::tr ( "Button", db->utext )); 221 b. setUserText ( QObject::tr ( "Button", db->utext ));
221 b. setPixmap ( Resource::loadPixmap ( db->pix )); 222 b. setPixmap ( Resource::loadPixmap ( db->pix ));
222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 223 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 224 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
224 d->m_buttons->append ( b ); 225 d->m_buttons->append ( b );
225 } 226 }
226 227
227 reloadButtonMapping(); 228 reloadButtonMapping();
228 229
229 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
230 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&)));
231} 232}
232 233
233ODevice::~ODevice() 234ODevice::~ODevice()
234{ 235{
235// we leak m_devicebuttons and m_cpu_frequency 236// we leak m_devicebuttons and m_cpu_frequency
236// but it's a singleton and it is not so importantant 237// but it's a singleton and it is not so importantant
237// -zecke 238// -zecke
238 delete d; 239 delete d;
239} 240}
@@ -487,231 +488,241 @@ QValueList <OLed> ODevice::ledList() const
487 488
488/** 489/**
489* This does return the state of the LEDs 490* This does return the state of the LEDs
490*/ 491*/
491QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 492QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
492{ 493{
493 return QValueList <OLedState>(); 494 return QValueList <OLedState>();
494} 495}
495 496
496/** 497/**
497* @return the state for a given OLed 498* @return the state for a given OLed
498*/ 499*/
499OLedState ODevice::ledState ( OLed /*which*/ ) const 500OLedState ODevice::ledState ( OLed /*which*/ ) const
500{ 501{
501 return Led_Off; 502 return Led_Off;
502} 503}
503 504
504/** 505/**
505* Set the state for a LED 506* Set the state for a LED
506* @param which Which OLed to use 507* @param which Which OLed to use
507* @param st The state to set 508* @param st The state to set
508* @return success or failure 509* @return success or failure
509*/ 510*/
510bool ODevice::setLedState ( OLed which, OLedState st ) 511bool ODevice::setLedState ( OLed which, OLedState st )
511{ 512{
512 Q_UNUSED( which ) 513 Q_UNUSED( which )
513 Q_UNUSED( st ) 514 Q_UNUSED( st )
514 return false; 515 return false;
515} 516}
516 517
517/** 518/**
518* @return if the device has a light sensor 519* @return if the device has a light sensor
519*/ 520*/
520bool ODevice::hasLightSensor() const 521bool ODevice::hasLightSensor() const
521{ 522{
522 return false; 523 return false;
523} 524}
524 525
525/** 526/**
526* @return a value from the light sensor 527* @return a value from the light sensor
527*/ 528*/
528int ODevice::readLightSensor() 529int ODevice::readLightSensor()
529{ 530{
530 return -1; 531 return -1;
531} 532}
532 533
533/** 534/**
534* @return the light sensor resolution 535* @return the light sensor resolution
535*/ 536*/
536int ODevice::lightSensorResolution() const 537int ODevice::lightSensorResolution() const
537{ 538{
538 return 0; 539 return 0;
539} 540}
540 541
541/** 542/**
542* @return if the device has a hinge sensor 543* @return if the device has a hinge sensor
543*/ 544*/
544bool ODevice::hasHingeSensor() const 545bool ODevice::hasHingeSensor() const
545{ 546{
546 return false; 547 return false;
547} 548}
548 549
549/** 550/**
550* @return a value from the hinge sensor 551* @return a value from the hinge sensor
551*/ 552*/
552OHingeStatus ODevice::readHingeSensor() 553OHingeStatus ODevice::readHingeSensor()
553{ 554{
554 return CASE_UNKNOWN; 555 return CASE_UNKNOWN;
555} 556}
556 557
557/** 558/**
558* @return a list with CPU frequencies supported by the hardware 559* @return a list with CPU frequencies supported by the hardware
559*/ 560*/
560const QStrList &ODevice::allowedCpuFrequencies() const 561const QStrList &ODevice::allowedCpuFrequencies() const
561{ 562{
562 return *d->m_cpu_frequencies; 563 return *d->m_cpu_frequencies;
563} 564}
564 565
565 566
566/** 567/**
567* Set desired CPU frequency 568* Set desired CPU frequency
568* 569*
569* @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
570*/ 571*/
571bool ODevice::setCurrentCpuFrequency(uint index) 572bool ODevice::setCurrentCpuFrequency(uint index)
572{ 573{
573 if (index >= d->m_cpu_frequencies->count()) 574 if (index >= d->m_cpu_frequencies->count())
574 return false; 575 return false;
575 576
576 char *freq = d->m_cpu_frequencies->at(index); 577 char *freq = d->m_cpu_frequencies->at(index);
577 qWarning("set freq to %s", freq); 578 qWarning("set freq to %s", freq);
578 579
579 int fd; 580 int fd;
580 581
581 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 582 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
582 char writeCommand[50]; 583 char writeCommand[50];
583 const int count = sprintf(writeCommand, "%s\n", freq); 584 const int count = sprintf(writeCommand, "%s\n", freq);
584 int res = (::write(fd, writeCommand, count) != -1); 585 int res = (::write(fd, writeCommand, count) != -1);
585 ::close(fd); 586 ::close(fd);
586 return res; 587 return res;
587 } 588 }
588 589
589 return false; 590 return false;
590} 591}
591 592
592 593
593/** 594/**
594* @return a list of hardware buttons 595* @return a list of hardware buttons
595*/ 596*/
596const QValueList <ODeviceButton> &ODevice::buttons() 597const QValueList <ODeviceButton> &ODevice::buttons()
597{ 598{
598 initButtons(); 599 initButtons();
599 600
600 return *d->m_buttons; 601 return *d->m_buttons;
601} 602}
602 603
603/** 604/**
604* @return The amount of time that would count as a hold 605* @return The amount of time that would count as a hold
605*/ 606*/
606uint ODevice::buttonHoldTime() const 607uint ODevice::buttonHoldTime() const
607{ 608{
608 return d->m_holdtime; 609 return d->m_holdtime;
609} 610}
610 611
611/** 612/**
612* This method return a ODeviceButton for a key code 613* This method return a ODeviceButton for a key code
613* 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
614* 615*
615* @return The devicebutton or 0l 616* @return The devicebutton or 0l
616* @see ODeviceButton 617* @see ODeviceButton
617*/ 618*/
618const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 619const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
619{ 620{
620 initButtons(); 621 initButtons();
621 622
622 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 ) {
623 if ( (*it). keycode() == code ) 624 if ( (*it). keycode() == code )
624 return &(*it); 625 return &(*it);
625 } 626 }
626 return 0; 627 return 0;
627} 628}
628 629
629void ODevice::reloadButtonMapping() 630void ODevice::reloadButtonMapping()
630{ 631{
631 initButtons(); 632 initButtons();
632 633
633 Config cfg ( "ButtonSettings" ); 634 Config cfg ( "ButtonSettings" );
634 635
635 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 636 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
636 ODeviceButton &b = ( *d->m_buttons ) [i]; 637 ODeviceButton &b = ( *d->m_buttons ) [i];
637 QString group = "Button" + QString::number ( i ); 638 QString group = "Button" + QString::number ( i );
638 639
639 QCString pch, hch; 640 QCString pch, hch;
640 QCString pm, hm; 641 QCString pm, hm;
641 QByteArray pdata, hdata; 642 QByteArray pdata, hdata;
642 643
643 if ( cfg. hasGroup ( group )) { 644 if ( cfg. hasGroup ( group )) {
644 cfg. setGroup ( group ); 645 cfg. setGroup ( group );
645 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 646 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
646 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 647 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
647 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 648 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
648 649
649 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 650 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
650 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 651 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
651 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 652 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
652 } 653 }
653 654
654 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 655 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
655 656
656 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 657 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
657 } 658 }
658} 659}
659 660
660void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 661void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
661{ 662{
662 initButtons(); 663 initButtons();
663 664
664 QString mb_chan; 665 QString mb_chan;
665 666
666 if ( button >= (int) d->m_buttons->count()) 667 if ( button >= (int) d->m_buttons->count())
667 return; 668 return;
668 669
669 ODeviceButton &b = ( *d->m_buttons ) [button]; 670 ODeviceButton &b = ( *d->m_buttons ) [button];
670 b. setPressedAction ( action ); 671 b. setPressedAction ( action );
671 672
672 mb_chan=b. pressedAction(). channel(); 673 mb_chan=b. pressedAction(). channel();
673 674
674 Config buttonFile ( "ButtonSettings" ); 675 Config buttonFile ( "ButtonSettings" );
675 buttonFile. setGroup ( "Button" + QString::number ( button )); 676 buttonFile. setGroup ( "Button" + QString::number ( button ));
676 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 677 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
677 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 678 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
678 679
679 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 680// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
680 681
681 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 682 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
682} 683}
683 684
684void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 685void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
685{ 686{
686 initButtons(); 687 initButtons();
687 688
688 if ( button >= (int) d->m_buttons->count()) 689 if ( button >= (int) d->m_buttons->count())
689 return; 690 return;
690 691
691 ODeviceButton &b = ( *d->m_buttons ) [button]; 692 ODeviceButton &b = ( *d->m_buttons ) [button];
692 b. setHeldAction ( action ); 693 b. setHeldAction ( action );
693 694
694 Config buttonFile ( "ButtonSettings" ); 695 Config buttonFile ( "ButtonSettings" );
695 buttonFile. setGroup ( "Button" + QString::number ( button )); 696 buttonFile. setGroup ( "Button" + QString::number ( button ));
696 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 697 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
697 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 698 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
698 699
699 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 700// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
700 701
701 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 702 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
702} 703}
703void ODevice::virtual_hook(int, void* ){ 704void ODevice::virtual_hook(int, void* ){
704 705
705} 706}
706 707
707void ODevice::sendSuspendmsg() 708void ODevice::sendSuspendmsg()
708{ 709{
709 if ( isQWS() ) 710 if ( isQWS() )
710 return; 711 return;
711 712
712 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 713 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
713} 714}
714 715
716void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
717{
718 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
719}
720
721void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
722{
723 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
724}
725
715 726
716} 727}
717} 728}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 0465d7e..762d3f1 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,358 +1,361 @@
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#include <qwindowsystem_qws.h>
42 43
43namespace Opie{ 44namespace Opie{
44namespace Core{ 45namespace Core{
45 46
46 class ODeviceData; 47 class ODeviceData;
47/** 48/**
48 * The available devices 49 * The available devices
49 */ 50 */
50enum OModel { 51enum OModel {
51 Model_Unknown, // = 0 52 Model_Unknown, // = 0
52 53
53 Model_Series_Mask = 0xff000000, 54 Model_Series_Mask = 0xff000000,
54 55
55 Model_iPAQ = ( 1 << 24 ), 56 Model_iPAQ = ( 1 << 24 ),
56 57
57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 58 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 59 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 60 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 61 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 62 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 63 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), 64 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
64 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 65 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
65 66
66 Model_Jornada = ( 6 << 24 ), 67 Model_Jornada = ( 6 << 24 ),
67 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 68 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
68 69
69 Model_Zaurus = ( 2 << 24 ), 70 Model_Zaurus = ( 2 << 24 ),
70 71
71 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 72 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
72 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 73 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
73 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 74 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
74 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 75 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
75 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 76 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
76 77
77 Model_SIMpad = ( 3 << 24 ), 78 Model_SIMpad = ( 3 << 24 ),
78 79
79 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 80 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
80 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 81 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
81 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 82 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
82 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 83 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
83 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 84 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
84 85
85 Model_Ramses = ( 4 << 24 ), 86 Model_Ramses = ( 4 << 24 ),
86 87
87 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 88 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
88 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 89 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
89 90
90 Model_Yopy = ( 5 << 24 ), 91 Model_Yopy = ( 5 << 24 ),
91 92
92 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 93 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
93 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 94 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
94 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 95 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
95 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 96 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
96 97
97 Model_Beagle = ( 6 << 24 ), 98 Model_Beagle = ( 6 << 24 ),
98 99
99 Model_Beagle_All = ( Model_Beagle | 0xffffff ), 100 Model_Beagle_All = ( Model_Beagle | 0xffffff ),
100 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), 101 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ),
101 102
102}; 103};
103 104
104/** 105/**
105 * The vendor of the device 106 * The vendor of the device
106 */ 107 */
107enum OVendor { 108enum OVendor {
108 Vendor_Unknown, 109 Vendor_Unknown,
109 110
110 Vendor_HP, 111 Vendor_HP,
111 Vendor_Sharp, 112 Vendor_Sharp,
112 Vendor_SIEMENS, 113 Vendor_SIEMENS,
113 Vendor_MundN, 114 Vendor_MundN,
114 Vendor_GMate, 115 Vendor_GMate,
115 Vendor_MasterIA, 116 Vendor_MasterIA,
116}; 117};
117 118
118/** 119/**
119 * The System used 120 * The System used
120 */ 121 */
121enum OSystem { 122enum OSystem {
122 System_Unknown, 123 System_Unknown,
123 124
124 System_Familiar, 125 System_Familiar,
125 System_Zaurus, 126 System_Zaurus,
126 System_OpenZaurus, 127 System_OpenZaurus,
127 System_Linupy, 128 System_Linupy,
128 System_OpenEmbedded, 129 System_OpenEmbedded,
129}; 130};
130 131
131typedef struct { 132typedef struct {
132 OSystem system; 133 OSystem system;
133 char* sysstr; 134 char* sysstr;
134 char* sysvfile; 135 char* sysvfile;
135} ODistribution; 136} ODistribution;
136 137
137extern ODistribution distributions[]; 138extern ODistribution distributions[];
138 139
139 140
140enum OLedState { 141enum OLedState {
141 Led_Off, 142 Led_Off,
142 Led_On, 143 Led_On,
143 Led_BlinkSlow, 144 Led_BlinkSlow,
144 Led_BlinkFast 145 Led_BlinkFast
145}; 146};
146 147
147enum OLed { 148enum OLed {
148 Led_Mail, 149 Led_Mail,
149 Led_Power, 150 Led_Power,
150 Led_BlueTooth 151 Led_BlueTooth
151}; 152};
152 153
153enum OHardKey { 154enum OHardKey {
154 HardKey_Datebook = Qt::Key_F9, 155 HardKey_Datebook = Qt::Key_F9,
155 HardKey_Contacts = Qt::Key_F10, 156 HardKey_Contacts = Qt::Key_F10,
156 HardKey_Menu = Qt::Key_F11, 157 HardKey_Menu = Qt::Key_F11,
157 HardKey_Home = Qt::Key_F12, 158 HardKey_Home = Qt::Key_F12,
158 HardKey_Mail = Qt::Key_F13, 159 HardKey_Mail = Qt::Key_F13,
159 HardKey_Record = Qt::Key_F24, 160 HardKey_Record = Qt::Key_F24,
160 HardKey_Suspend = Qt::Key_F34, 161 HardKey_Suspend = Qt::Key_F34,
161 HardKey_Backlight = Qt::Key_F35, 162 HardKey_Backlight = Qt::Key_F35,
162 HardKey_Action = Qt::Key_F10, 163 HardKey_Action = Qt::Key_F10,
163 HardKey_OK = Qt::Key_F11, 164 HardKey_OK = Qt::Key_F11,
164 HardKey_End = Qt::Key_F12, 165 HardKey_End = Qt::Key_F12,
165}; 166};
166 167
167enum ODirection { 168enum ODirection {
168 CW = 0, 169 CW = 0,
169 CCW = 1, 170 CCW = 1,
170 Flip = 2, 171 Flip = 2,
171}; 172};
172 173
173enum OHingeStatus { 174enum OHingeStatus {
174 CASE_CLOSED = 3, 175 CASE_CLOSED = 3,
175 CASE_PORTRAIT = 2, 176 CASE_PORTRAIT = 2,
176 CASE_LANDSCAPE = 0, 177 CASE_LANDSCAPE = 0,
177 CASE_UNKNOWN = 1, 178 CASE_UNKNOWN = 1,
178}; 179};
179 180
180/* default button for qvfb or such 181/* default button for qvfb or such
181 * see odevice.cpp for details. 182 * see odevice.cpp for details.
182 * hint: manage a user defined button for qvfb? 183 * hint: manage a user defined button for qvfb?
183 * alwin 184 * alwin
184 */ 185 */
185struct default_button { 186struct default_button {
186 Qt::Key code; 187 Qt::Key code;
187 char *utext; 188 char *utext;
188 char *pix; 189 char *pix;
189 char *fpressedservice; 190 char *fpressedservice;
190 char *fpressedaction; 191 char *fpressedaction;
191 char *fheldservice; 192 char *fheldservice;
192 char *fheldaction; 193 char *fheldaction;
193}; 194};
194 195
195/** 196/**
196 * A singleton which gives informations about device specefic option 197 * A singleton which gives informations about device specefic option
197 * like the Hardware used, LEDs, the Base Distribution and 198 * like the Hardware used, LEDs, the Base Distribution and
198 * hardware key mappings. 199 * hardware key mappings.
199 * 200 *
200 * @short A small class for device specefic options 201 * @short A small class for device specefic options
201 * @see QObject 202 * @see QObject
202 * @author Robert Griebl 203 * @author Robert Griebl
203 * @version 1.0 204 * @version 1.0
204 */ 205 */
205class ODevice : public QObject 206class ODevice : public QObject
206{ 207{
207 Q_OBJECT 208 Q_OBJECT
208 209
209private: 210private:
210 /* disable copy */ 211 /* disable copy */
211 ODevice ( const ODevice & ); 212 ODevice ( const ODevice & );
212 213
213protected: 214protected:
214 ODevice(); 215 ODevice();
215 virtual void init(const QString&); 216 virtual void init(const QString&);
216 virtual void initButtons(); 217 virtual void initButtons();
217 static void sendSuspendmsg(); 218 static void sendSuspendmsg();
218 219
219 ODeviceData *d; 220 ODeviceData *d;
220 221
221public: 222public:
222 // sandman do we want to allow destructions? -zecke? 223 // sandman do we want to allow destructions? -zecke?
223 virtual ~ODevice(); 224 virtual ~ODevice();
224 225
225 static ODevice *inst(); 226 static ODevice *inst();
226 227
227 // information 228 // information
228 229
229 QString modelString() const; 230 QString modelString() const;
230 OModel model() const; 231 OModel model() const;
231 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 232 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
232 233
233 QString vendorString() const; 234 QString vendorString() const;
234 OVendor vendor() const; 235 OVendor vendor() const;
235 236
236 QString systemString() const; 237 QString systemString() const;
237 OSystem system() const; 238 OSystem system() const;
238 239
239 QString systemVersionString() const; 240 QString systemVersionString() const;
240 241
241 virtual Transformation rotation() const; 242 virtual Transformation rotation() const;
242 virtual ODirection direction() const; 243 virtual ODirection direction() const;
243 244
244 // system 245 // system
245 246
246 virtual bool setSoftSuspend ( bool on ); 247 virtual bool setSoftSuspend ( bool on );
247 virtual bool suspend(); 248 virtual bool suspend();
248 249
249 virtual bool setDisplayStatus ( bool on ); 250 virtual bool setDisplayStatus ( bool on );
250 virtual bool setDisplayBrightness ( int brightness ); 251 virtual bool setDisplayBrightness ( int brightness );
251 virtual int displayBrightnessResolution() const; 252 virtual int displayBrightnessResolution() const;
252 virtual bool setDisplayContrast ( int contrast ); 253 virtual bool setDisplayContrast ( int contrast );
253 virtual int displayContrastResolution() const; 254 virtual int displayContrastResolution() const;
254 255
255 // don't add new virtual methods, use this: 256 // don't add new virtual methods, use this:
256 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 257 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
257 // and in your subclass do do overwrite 258 // and in your subclass do do overwrite
258 //protected virtual int virtual_hook(int, void *) 259 // protected virtual int virtual_hook(int, void *)
259 // which is defined below 260 // which is defined below
260 261
261 // input / output 262 // input / output
262 virtual void playAlarmSound(); 263 virtual void playAlarmSound();
263 virtual void playKeySound(); 264 virtual void playKeySound();
264 virtual void playTouchSound(); 265 virtual void playTouchSound();
265 266
266 virtual QValueList <OLed> ledList() const; 267 virtual QValueList <OLed> ledList() const;
267 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 268 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
268 virtual OLedState ledState ( OLed led ) const; 269 virtual OLedState ledState ( OLed led ) const;
269 virtual bool setLedState ( OLed led, OLedState st ); 270 virtual bool setLedState ( OLed led, OLedState st );
270 271
271 virtual bool hasLightSensor() const; 272 virtual bool hasLightSensor() const;
272 virtual int readLightSensor(); 273 virtual int readLightSensor();
273 virtual int lightSensorResolution() const; 274 virtual int lightSensorResolution() const;
274 275
275 virtual bool hasHingeSensor() const; 276 virtual bool hasHingeSensor() const;
276 virtual OHingeStatus readHingeSensor(); 277 virtual OHingeStatus readHingeSensor();
277 278
278 const QStrList &allowedCpuFrequencies() const; 279 const QStrList &allowedCpuFrequencies() const;
279 bool setCurrentCpuFrequency(uint index); 280 bool setCurrentCpuFrequency(uint index);
280 281
281 /** 282 /**
282 * Returns the available buttons on this device. The number and location 283 * Returns the available buttons on this device. The number and location
283 * of buttons will vary depending on the device. Button numbers will be assigned 284 * of buttons will vary depending on the device. Button numbers will be assigned
284 * by the device manufacturer and will be from most preferred button to least preffered 285 * by the device manufacturer and will be from most preferred button to least preffered
285 * button. Note that this list only contains "user mappable" buttons. 286 * button. Note that this list only contains "user mappable" buttons.
286 * 287 *
287 * @todo Make method const and take care of calling initButtons or make that const too 288 * @todo Make method const and take care of calling initButtons or make that const too
288 * 289 *
289 */ 290 */
290 const QValueList<ODeviceButton> &buttons(); 291 const QValueList<ODeviceButton> &buttons();
291 292
292 /** 293 /**
293 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 294 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
294 * returns 0L 295 * returns 0L
295 */ 296 */
296 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 297 const ODeviceButton *buttonForKeycode ( ushort keyCode );
297 298
298 /** 299 /**
299 * Reassigns the pressed action for \a button. To return to the factory 300 * Reassigns the pressed action for \a button. To return to the factory
300 * default pass an empty string as \a qcopMessage. 301 * default pass an empty string as \a qcopMessage.
301 */ 302 */
302 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 303 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
303 304
304 /** 305 /**
305 * Reassigns the held action for \a button. To return to the factory 306 * Reassigns the held action for \a button. To return to the factory
306 * default pass an empty string as \a qcopMessage. 307 * default pass an empty string as \a qcopMessage.
307 */ 308 */
308 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 309 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
309 310
310 /** 311 /**
311 * How long (in ms) you have to press a button for a "hold" action 312 * How long (in ms) you have to press a button for a "hold" action
312 */ 313 */
313 uint buttonHoldTime() const; 314 uint buttonHoldTime() const;
314 315
315signals: 316signals:
316 void buttonMappingChanged(); 317 void buttonMappingChanged();
317 318
318private slots: 319private slots:
319 void systemMessage ( const QCString &, const QByteArray & ); 320 void systemMessage ( const QCString &, const QByteArray & );
320 321
321protected: 322protected:
323 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
324 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
322 void reloadButtonMapping(); 325 void reloadButtonMapping();
323 /* ugly virtual hook */ 326 /* ugly virtual hook */
324 virtual void virtual_hook( int id, void* data ); 327 virtual void virtual_hook( int id, void* data );
325}; 328};
326 329
327class ODeviceData { 330class ODeviceData {
328 331
329 public: 332 public:
330 QString m_vendorstr; 333 QString m_vendorstr;
331 OVendor m_vendor; 334 OVendor m_vendor;
332 335
333 QString m_modelstr; 336 QString m_modelstr;
334 OModel m_model; 337 OModel m_model;
335 338
336 QString m_systemstr; 339 QString m_systemstr;
337 OSystem m_system; 340 OSystem m_system;
338 341
339 QString m_sysverstr; 342 QString m_sysverstr;
340 343
341 Transformation m_rotation; 344 Transformation m_rotation;
342 ODirection m_direction; 345 ODirection m_direction;
343 346
344 QValueList <ODeviceButton> *m_buttons; 347 QValueList <ODeviceButton> *m_buttons;
345 uint m_holdtime; 348 uint m_holdtime;
346 QStrList *m_cpu_frequencies; 349 QStrList *m_cpu_frequencies;
347}; 350};
348 351
349extern bool isQWS(); 352extern bool isQWS();
350extern QCString makeChannel ( const char *str ); 353extern QCString makeChannel ( const char *str );
351} 354}
352} 355}
353 356
354 357
355 358
356 359
357#endif 360#endif
358 361
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 791e409..21fed99 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,365 +1,364 @@
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 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57 57
58using namespace Opie::Core; 58using namespace Opie::Core;
59using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
60 60
61/* KERNEL */ 61/* KERNEL */
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63 63
64#define OD_IO(type,number) OD_IOC(0,type,number,0) 64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68 68
69typedef struct { 69typedef struct {
70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
71 unsigned char TotalTime; /* Units of 5 seconds */ 71 unsigned char TotalTime; /* Units of 5 seconds */
72 unsigned char OnTime; /* units of 100m/s */ 72 unsigned char OnTime; /* units of 100m/s */
73 unsigned char OffTime; /* units of 100m/s */ 73 unsigned char OffTime; /* units of 100m/s */
74} LED_IN; 74} LED_IN;
75 75
76typedef struct { 76typedef struct {
77 unsigned char mode; 77 unsigned char mode;
78 unsigned char pwr; 78 unsigned char pwr;
79 unsigned char brightness; 79 unsigned char brightness;
80} FLITE_IN; 80} FLITE_IN;
81 81
82#define LED_ON OD_IOW( 'f', 5, LED_IN ) 82#define LED_ON OD_IOW( 'f', 5, LED_IN )
83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
84 84
85struct i_button ipaq_buttons [] = { 85struct i_button ipaq_buttons [] = {
86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
87 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 87 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
88 "devicebuttons/ipaq_calendar", 88 "devicebuttons/ipaq_calendar",
89 "datebook", "nextView()", 89 "datebook", "nextView()",
90 "today", "raise()" }, 90 "today", "raise()" },
91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
92 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 92 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
93 "devicebuttons/ipaq_contact", 93 "devicebuttons/ipaq_contact",
94 "addressbook", "raise()", 94 "addressbook", "raise()",
95 "addressbook", "beamBusinessCard()" }, 95 "addressbook", "beamBusinessCard()" },
96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
98 "devicebuttons/ipaq_menu", 98 "devicebuttons/ipaq_menu",
99 "QPE/TaskBar", "toggleMenu()", 99 "QPE/TaskBar", "toggleMenu()",
100 "QPE/TaskBar", "toggleStartMenu()" }, 100 "QPE/TaskBar", "toggleStartMenu()" },
101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
103 "devicebuttons/ipaq_mail", 103 "devicebuttons/ipaq_mail",
104 "opiemail", "raise()", 104 "opiemail", "raise()",
105 "opiemail", "newMail()" }, 105 "opiemail", "newMail()" },
106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
108 "devicebuttons/ipaq_home", 108 "devicebuttons/ipaq_home",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
113 "devicebuttons/ipaq_record", 113 "devicebuttons/ipaq_record",
114 "QPE/VMemo", "toggleRecord()", 114 "QPE/VMemo", "toggleRecord()",
115 "sound", "raise()" }, 115 "sound", "raise()" },
116}; 116};
117 117
118void iPAQ::init(const QString& model) 118void iPAQ::init(const QString& model)
119{ 119{
120 d->m_vendorstr = "HP"; 120 d->m_vendorstr = "HP";
121 d->m_vendor = Vendor_HP; 121 d->m_vendor = Vendor_HP;
122 122
123 d->m_modelstr = model.mid(model.findRev('H')); 123 d->m_modelstr = model.mid(model.findRev('H'));
124 124
125 if ( d->m_modelstr == "H3100" ) 125 if ( d->m_modelstr == "H3100" )
126 d->m_model = Model_iPAQ_H31xx; 126 d->m_model = Model_iPAQ_H31xx;
127 else if ( d->m_modelstr == "H3600" ) 127 else if ( d->m_modelstr == "H3600" )
128 d->m_model = Model_iPAQ_H36xx; 128 d->m_model = Model_iPAQ_H36xx;
129 else if ( d->m_modelstr == "H3700" ) 129 else if ( d->m_modelstr == "H3700" )
130 d->m_model = Model_iPAQ_H37xx; 130 d->m_model = Model_iPAQ_H37xx;
131 else if ( d->m_modelstr == "H3800" ) 131 else if ( d->m_modelstr == "H3800" )
132 d->m_model = Model_iPAQ_H38xx; 132 d->m_model = Model_iPAQ_H38xx;
133 else if ( d->m_modelstr == "H3900" ) 133 else if ( d->m_modelstr == "H3900" )
134 d->m_model = Model_iPAQ_H39xx; 134 d->m_model = Model_iPAQ_H39xx;
135 else if ( d->m_modelstr == "H5400" ) 135 else if ( d->m_modelstr == "H5400" )
136 d->m_model = Model_iPAQ_H5xxx; 136 d->m_model = Model_iPAQ_H5xxx;
137 else if ( d->m_modelstr == "H2200" ) 137 else if ( d->m_modelstr == "H2200" )
138 d->m_model = Model_iPAQ_H22xx; 138 d->m_model = Model_iPAQ_H22xx;
139 else 139 else
140 d->m_model = Model_Unknown; 140 d->m_model = Model_Unknown;
141 141
142 switch ( d->m_model ) { 142 switch ( d->m_model ) {
143 case Model_iPAQ_H31xx: 143 case Model_iPAQ_H31xx:
144 case Model_iPAQ_H38xx: 144 case Model_iPAQ_H38xx:
145 d->m_rotation = Rot90; 145 d->m_rotation = Rot90;
146 break; 146 break;
147 case Model_iPAQ_H5xxx: 147 case Model_iPAQ_H5xxx:
148 case Model_iPAQ_H22xx: 148 case Model_iPAQ_H22xx:
149 d->m_rotation = Rot0; 149 d->m_rotation = Rot0;
150 break; 150 break;
151 case Model_iPAQ_H36xx: 151 case Model_iPAQ_H36xx:
152 case Model_iPAQ_H37xx: 152 case Model_iPAQ_H37xx:
153 case Model_iPAQ_H39xx: 153 case Model_iPAQ_H39xx:
154 default: 154 default:
155 d->m_rotation = Rot270; 155 d->m_rotation = Rot270;
156 break; 156 break;
157 157
158 } 158 }
159 159
160 m_leds [0] = m_leds [1] = Led_Off; 160 m_leds [0] = m_leds [1] = Led_Off;
161 161
162 m_power_timer = 0; 162 m_power_timer = 0;
163 163
164} 164}
165 165
166void iPAQ::initButtons() 166void iPAQ::initButtons()
167{ 167{
168 if ( d->m_buttons ) 168 if ( d->m_buttons )
169 return; 169 return;
170 170
171 if ( isQWS( ) ) { 171 if ( isQWS( ) ) {
172 Opie::Core::OKeyFilter::inst()->addPreHandler(this); 172 addPreHandler(this);
173 //QWSServer::setKeyboardFilter ( this );
174 } 173 }
175 174
176 d->m_buttons = new QValueList <ODeviceButton>; 175 d->m_buttons = new QValueList <ODeviceButton>;
177 176
178 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 177 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
179 i_button *ib = ipaq_buttons + i; 178 i_button *ib = ipaq_buttons + i;
180 ODeviceButton b; 179 ODeviceButton b;
181 180
182 if (( ib->model & d->m_model ) == d->m_model ) { 181 if (( ib->model & d->m_model ) == d->m_model ) {
183 b. setKeycode ( ib->code ); 182 b. setKeycode ( ib->code );
184 b. setUserText ( QObject::tr ( "Button", ib->utext )); 183 b. setUserText ( QObject::tr ( "Button", ib->utext ));
185 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 184 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
186 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
187 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
188 187
189 d->m_buttons->append ( b ); 188 d->m_buttons->append ( b );
190 } 189 }
191 } 190 }
192 reloadButtonMapping(); 191 reloadButtonMapping();
193 192
194 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 193 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
195 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 194 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
196} 195}
197 196
198QValueList <OLed> iPAQ::ledList() const 197QValueList <OLed> iPAQ::ledList() const
199{ 198{
200 QValueList <OLed> vl; 199 QValueList <OLed> vl;
201 vl << Led_Power; 200 vl << Led_Power;
202 201
203 if ( d->m_model == Model_iPAQ_H38xx ) 202 if ( d->m_model == Model_iPAQ_H38xx )
204 vl << Led_BlueTooth; 203 vl << Led_BlueTooth;
205 return vl; 204 return vl;
206} 205}
207 206
208QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 207QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
209{ 208{
210 QValueList <OLedState> vl; 209 QValueList <OLedState> vl;
211 210
212 if ( l == Led_Power ) 211 if ( l == Led_Power )
213 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 212 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
214 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 213 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
215 vl << Led_Off; // << Led_On << ??? 214 vl << Led_Off; // << Led_On << ???
216 215
217 return vl; 216 return vl;
218} 217}
219 218
220OLedState iPAQ::ledState ( OLed l ) const 219OLedState iPAQ::ledState ( OLed l ) const
221{ 220{
222 switch ( l ) { 221 switch ( l ) {
223 case Led_Power: 222 case Led_Power:
224 return m_leds [0]; 223 return m_leds [0];
225 case Led_BlueTooth: 224 case Led_BlueTooth:
226 return m_leds [1]; 225 return m_leds [1];
227 default: 226 default:
228 return Led_Off; 227 return Led_Off;
229 } 228 }
230} 229}
231 230
232bool iPAQ::setLedState ( OLed l, OLedState st ) 231bool iPAQ::setLedState ( OLed l, OLedState st )
233{ 232{
234 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 233 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
235 234
236 if ( l == Led_Power ) { 235 if ( l == Led_Power ) {
237 if ( fd >= 0 ) { 236 if ( fd >= 0 ) {
238 LED_IN leds; 237 LED_IN leds;
239 ::memset ( &leds, 0, sizeof( leds )); 238 ::memset ( &leds, 0, sizeof( leds ));
240 leds. TotalTime = 0; 239 leds. TotalTime = 0;
241 leds. OnTime = 0; 240 leds. OnTime = 0;
242 leds. OffTime = 1; 241 leds. OffTime = 1;
243 leds. OffOnBlink = 2; 242 leds. OffOnBlink = 2;
244 243
245 switch ( st ) { 244 switch ( st ) {
246 case Led_Off : leds. OffOnBlink = 0; break; 245 case Led_Off : leds. OffOnBlink = 0; break;
247 case Led_On : leds. OffOnBlink = 1; break; 246 case Led_On : leds. OffOnBlink = 1; break;
248 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 247 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
249 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 248 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
250 } 249 }
251 250
252 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 251 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
253 m_leds [0] = st; 252 m_leds [0] = st;
254 return true; 253 return true;
255 } 254 }
256 } 255 }
257 } 256 }
258 return false; 257 return false;
259} 258}
260 259
261 260
262bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 261bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
263{ 262{
264 int newkeycode = keycode; 263 int newkeycode = keycode;
265 264
266 switch ( keycode ) { 265 switch ( keycode ) {
267 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 266 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
268 case HardKey_Menu: { 267 case HardKey_Menu: {
269 if (( d->m_model == Model_iPAQ_H38xx ) || 268 if (( d->m_model == Model_iPAQ_H38xx ) ||
270 ( d->m_model == Model_iPAQ_H39xx ) || 269 ( d->m_model == Model_iPAQ_H39xx ) ||
271 ( d->m_model == Model_iPAQ_H5xxx)) { 270 ( d->m_model == Model_iPAQ_H5xxx)) {
272 newkeycode = HardKey_Mail; 271 newkeycode = HardKey_Mail;
273 } 272 }
274 break; 273 break;
275 } 274 }
276 275
277 // Rotate cursor keys 180 or 270 276 // Rotate cursor keys 180 or 270
278 case Key_Left : 277 case Key_Left :
279 case Key_Right: 278 case Key_Right:
280 case Key_Up : 279 case Key_Up :
281 case Key_Down : { 280 case Key_Down : {
282 if (( d->m_model == Model_iPAQ_H31xx ) || 281 if (( d->m_model == Model_iPAQ_H31xx ) ||
283 ( d->m_model == Model_iPAQ_H38xx )) { 282 ( d->m_model == Model_iPAQ_H38xx )) {
284 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 283 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
285 } 284 }
286 // Rotate the cursor keys by 270 285 // Rotate the cursor keys by 270
287 // keycode - Key_Left = position of the button starting from left clockwise 286 // keycode - Key_Left = position of the button starting from left clockwise
288 // add the rotation to it and modolo. No we've the original offset 287 // add the rotation to it and modolo. No we've the original offset
289 // add the offset to the Key_Left key 288 // add the offset to the Key_Left key
290 if ( d-> m_model == Model_iPAQ_H5xxx ) 289 if ( d-> m_model == Model_iPAQ_H5xxx )
291 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
292 break; 291 break;
293 } 292 }
294 293
295 // map Power Button short/long press to F34/F35 294 // map Power Button short/long press to F34/F35
296 case Key_SysReq: { 295 case Key_SysReq: {
297 if ( isPress ) { 296 if ( isPress ) {
298 if ( m_power_timer ) 297 if ( m_power_timer )
299 killTimer ( m_power_timer ); 298 killTimer ( m_power_timer );
300 m_power_timer = startTimer ( 500 ); 299 m_power_timer = startTimer ( 500 );
301 } 300 }
302 else if ( m_power_timer ) { 301 else if ( m_power_timer ) {
303 killTimer ( m_power_timer ); 302 killTimer ( m_power_timer );
304 m_power_timer = 0; 303 m_power_timer = 0;
305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
306 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
307 } 306 }
308 newkeycode = Key_unknown; 307 newkeycode = Key_unknown;
309 break; 308 break;
310 } 309 }
311 } 310 }
312 311
313 if ( newkeycode != keycode ) { 312 if ( newkeycode != keycode ) {
314 if ( newkeycode != Key_unknown ) 313 if ( newkeycode != Key_unknown )
315 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
316 return true; 315 return true;
317 } 316 }
318 else 317 else
319 return false; 318 return false;
320} 319}
321 320
322void iPAQ::timerEvent ( QTimerEvent * ) 321void iPAQ::timerEvent ( QTimerEvent * )
323{ 322{
324 killTimer ( m_power_timer ); 323 killTimer ( m_power_timer );
325 m_power_timer = 0; 324 m_power_timer = 0;
326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
327 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
328} 327}
329 328
330 329
331void iPAQ::playAlarmSound() 330void iPAQ::playAlarmSound()
332{ 331{
333#ifndef QT_NO_SOUND 332#ifndef QT_NO_SOUND
334 static Sound snd ( "alarm" ); 333 static Sound snd ( "alarm" );
335 int fd; 334 int fd;
336 int vol; 335 int vol;
337 bool vol_reset = false; 336 bool vol_reset = false;
338 337
339 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 338 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
340 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 339 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
341 Config cfg ( "qpe" ); 340 Config cfg ( "qpe" );
342 cfg. setGroup ( "Volume" ); 341 cfg. setGroup ( "Volume" );
343 342
344 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 343 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
345 if ( volalarm < 0 ) 344 if ( volalarm < 0 )
346 volalarm = 0; 345 volalarm = 0;
347 else if ( volalarm > 100 ) 346 else if ( volalarm > 100 )
348 volalarm = 100; 347 volalarm = 100;
349 volalarm |= ( volalarm << 8 ); 348 volalarm |= ( volalarm << 8 );
350 349
351 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 350 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
352 vol_reset = true; 351 vol_reset = true;
353 } 352 }
354 } 353 }
355 354
356 snd. play(); 355 snd. play();
357 while ( !snd. isFinished()) 356 while ( !snd. isFinished())
358 qApp->processEvents(); 357 qApp->processEvents();
359 358
360 if ( fd >= 0 ) { 359 if ( fd >= 0 ) {
361 if ( vol_reset ) 360 if ( vol_reset )
362 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 361 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
363 ::close ( fd ); 362 ::close ( fd );
364 } 363 }
365#endif 364#endif
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 6c3253c..bf46e43 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,343 +1,342 @@
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_simpad.h" 30#include "odevice_simpad.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60struct s_button simpad_buttons [] = { 60struct s_button simpad_buttons [] = {
61 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 61 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
62 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 62 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
63 "devicebuttons/simpad_lower_up", 63 "devicebuttons/simpad_lower_up",
64 "datebook", "nextView()", 64 "datebook", "nextView()",
65 "today", "raise()" }, 65 "today", "raise()" },
66 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 66 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
67 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 67 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
68 "devicebuttons/simpad_lower_down", 68 "devicebuttons/simpad_lower_down",
69 "addressbook", "raise()", 69 "addressbook", "raise()",
70 "addressbook", "beamBusinessCard()" }, 70 "addressbook", "beamBusinessCard()" },
71 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 71 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
72 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 72 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
73 "devicebuttons/simpad_lower_right", 73 "devicebuttons/simpad_lower_right",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
77 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 77 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
78 "devicebuttons/simpad_lower_left", 78 "devicebuttons/simpad_lower_left",
79 "opiemail", "raise()", 79 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 80 "opiemail", "newMail()" },
81 81
82 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 82 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
83 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 83 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
84 "devicebuttons/simpad_upper_up", 84 "devicebuttons/simpad_upper_up",
85 "QPE/Launcher", "home()", 85 "QPE/Launcher", "home()",
86 "buttonsettings", "raise()" }, 86 "buttonsettings", "raise()" },
87 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 87 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
88 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 88 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
89 "devicebuttons/simpad_upper_down", 89 "devicebuttons/simpad_upper_down",
90 "addressbook", "raise()", 90 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 91 "addressbook", "beamBusinessCard()" },
92 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 92 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
93 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 93 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
94 "devicebuttons/simpad_upper_right", 94 "devicebuttons/simpad_upper_right",
95 "QPE/TaskBar", "toggleMenu()", 95 "QPE/TaskBar", "toggleMenu()",
96 "QPE/TaskBar", "toggleStartMenu()" }, 96 "QPE/TaskBar", "toggleStartMenu()" },
97 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 97 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
98 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 98 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
99 "devicebuttons/simpad_upper_left", 99 "devicebuttons/simpad_upper_left",
100 "QPE/Rotation", "flip()", 100 "QPE/Rotation", "flip()",
101 "QPE/Rotation", "flip()" }, 101 "QPE/Rotation", "flip()" },
102 /* 102 /*
103 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 103 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
104 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 104 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
105 "devicebuttons/simpad_lower_upper", 105 "devicebuttons/simpad_lower_upper",
106 "QPE/Launcher", "home()", 106 "QPE/Launcher", "home()",
107 "buttonsettings", "raise()" }, 107 "buttonsettings", "raise()" },
108 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 108 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
110 "devicebuttons/simpad_upper_lower", 110 "devicebuttons/simpad_upper_lower",
111 "QPE/Launcher", "home()", 111 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 112 "buttonsettings", "raise()" },
113 */ 113 */
114}; 114};
115 115
116void SIMpad::init(const QString&) 116void SIMpad::init(const QString&)
117{ 117{
118 d->m_vendorstr = "SIEMENS"; 118 d->m_vendorstr = "SIEMENS";
119 d->m_vendor = Vendor_SIEMENS; 119 d->m_vendor = Vendor_SIEMENS;
120 120
121 121
122 //TODO Implement model checking 122 //TODO Implement model checking
123 //FIXME For now we assume an SL4 123 //FIXME For now we assume an SL4
124 124
125 d->m_modelstr = "SL4"; 125 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 126 d->m_model = Model_SIMpad_SL4;
127 127
128 switch ( d->m_model ) { 128 switch ( d->m_model ) {
129 default: 129 default:
130 d->m_rotation = Rot0; 130 d->m_rotation = Rot0;
131 d->m_direction = CCW; 131 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 132 d->m_holdtime = 1000; // 1000ms
133 133
134 break; 134 break;
135 } 135 }
136 136
137 //Distribution detecting code is now in base class 137 //Distribution detecting code is now in base class
138 m_leds [0] = m_leds [1] = Led_Off; 138 m_leds [0] = m_leds [1] = Led_Off;
139 139
140 m_power_timer = 0; 140 m_power_timer = 0;
141 141
142} 142}
143 143
144void SIMpad::initButtons() 144void SIMpad::initButtons()
145{ 145{
146 if ( d->m_buttons ) 146 if ( d->m_buttons )
147 return; 147 return;
148 148
149 if ( isQWS( ) ) { 149 if ( isQWS( ) ) {
150 Opie::Core::OKeyFilter::inst()->addPreHandler(this); 150 addPreHandler(this);
151// QWSServer::setKeyboardFilter ( this );
152 } 151 }
153 152
154 153
155 d->m_buttons = new QValueList <ODeviceButton>; 154 d->m_buttons = new QValueList <ODeviceButton>;
156 155
157 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 156 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
158 s_button *sb = simpad_buttons + i; 157 s_button *sb = simpad_buttons + i;
159 ODeviceButton b; 158 ODeviceButton b;
160 159
161 if (( sb->model & d->m_model ) == d->m_model ) { 160 if (( sb->model & d->m_model ) == d->m_model ) {
162 b. setKeycode ( sb->code ); 161 b. setKeycode ( sb->code );
163 b. setUserText ( QObject::tr ( "Button", sb->utext )); 162 b. setUserText ( QObject::tr ( "Button", sb->utext ));
164 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 163 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
165 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 164 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
166 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 165 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
167 166
168 d->m_buttons->append ( b ); 167 d->m_buttons->append ( b );
169 } 168 }
170 } 169 }
171 reloadButtonMapping(); 170 reloadButtonMapping();
172 171
173 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 172 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
174 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 173 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
175} 174}
176 175
177// SIMpad boardcontrol register CS3 176// SIMpad boardcontrol register CS3
178#define SIMPAD_BOARDCONTROL "/proc/cs3" 177#define SIMPAD_BOARDCONTROL "/proc/cs3"
179#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 178#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
180#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 179#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
181#define SIMPAD_EN1 0x0004 // This is only for EPROM's 180#define SIMPAD_EN1 0x0004 // This is only for EPROM's
182#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 181#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
183#define SIMPAD_DISPLAY_ON 0x0010 182#define SIMPAD_DISPLAY_ON 0x0010
184#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 183#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
185#define SIMPAD_MQ_RESET 0x0040 184#define SIMPAD_MQ_RESET 0x0040
186#define SIMPAD_PCMCIA_RESET 0x0080 185#define SIMPAD_PCMCIA_RESET 0x0080
187#define SIMPAD_DECT_POWER_ON 0x0100 186#define SIMPAD_DECT_POWER_ON 0x0100
188#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 187#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
189#define SIMPAD_RS232_ON 0x0400 188#define SIMPAD_RS232_ON 0x0400
190#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 189#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
191#define SIMPAD_LED2_ON 0x1000 190#define SIMPAD_LED2_ON 0x1000
192#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 191#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
193#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 192#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
194#define SIMPAD_RESET_SIMCARD 0x8000 193#define SIMPAD_RESET_SIMCARD 0x8000
195 194
196//SIMpad touchscreen backlight strength control 195//SIMpad touchscreen backlight strength control
197#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 196#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
198#define SIMPAD_BACKLIGHT_MASK 0x00a10044 197#define SIMPAD_BACKLIGHT_MASK 0x00a10044
199 198
200QValueList <OLed> SIMpad::ledList() const 199QValueList <OLed> SIMpad::ledList() const
201{ 200{
202 QValueList <OLed> vl; 201 QValueList <OLed> vl;
203 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 202 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
204 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 203 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
205 return vl; 204 return vl;
206} 205}
207 206
208QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 207QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
209{ 208{
210 QValueList <OLedState> vl; 209 QValueList <OLedState> vl;
211 210
212 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 211 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
213 vl << Led_Off << Led_On; 212 vl << Led_Off << Led_On;
214 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 213 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
215 //vl << Led_Off; 214 //vl << Led_Off;
216 return vl; 215 return vl;
217} 216}
218 217
219OLedState SIMpad::ledState ( OLed l ) const 218OLedState SIMpad::ledState ( OLed l ) const
220{ 219{
221 switch ( l ) { 220 switch ( l ) {
222 case Led_Power: 221 case Led_Power:
223 return m_leds [0]; 222 return m_leds [0];
224 //case Led_Mail: 223 //case Led_Mail:
225 // return m_leds [1]; 224 // return m_leds [1];
226 default: 225 default:
227 return Led_Off; 226 return Led_Off;
228 } 227 }
229} 228}
230 229
231bool SIMpad::setLedState ( OLed l, OLedState st ) 230bool SIMpad::setLedState ( OLed l, OLedState st )
232{ 231{
233#if 0 232#if 0
234 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
235 234
236 /*TODO Implement this like that: 235 /*TODO Implement this like that:
237 read from cs3 236 read from cs3
238 && with SIMPAD_LED2_ON 237 && with SIMPAD_LED2_ON
239 write to cs3 */ 238 write to cs3 */
240 m_leds [0] = st; 239 m_leds [0] = st;
241 return true; 240 return true;
242 } 241 }
243 } 242 }
244 } 243 }
245 244
246#endif 245#endif
247 return false; 246 return false;
248} 247}
249 248
250 249
251bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 250bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
252{ 251{
253 //TODO 252 //TODO
254 return false; 253 return false;
255} 254}
256 255
257void SIMpad::timerEvent ( QTimerEvent * ) 256void SIMpad::timerEvent ( QTimerEvent * )
258{ 257{
259 killTimer ( m_power_timer ); 258 killTimer ( m_power_timer );
260 m_power_timer = 0; 259 m_power_timer = 0;
261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 260 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
262 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
263} 262}
264 263
265 264
266void SIMpad::playAlarmSound() 265void SIMpad::playAlarmSound()
267{ 266{
268#ifndef QT_NO_SOUND 267#ifndef QT_NO_SOUND
269 static Sound snd ( "alarm" ); 268 static Sound snd ( "alarm" );
270 int fd; 269 int fd;
271 int vol; 270 int vol;
272 bool vol_reset = false; 271 bool vol_reset = false;
273 272
274 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 273 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
275 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 274 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
276 Config cfg ( "qpe" ); 275 Config cfg ( "qpe" );
277 cfg. setGroup ( "Volume" ); 276 cfg. setGroup ( "Volume" );
278 277
279 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 278 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
280 if ( volalarm < 0 ) 279 if ( volalarm < 0 )
281 volalarm = 0; 280 volalarm = 0;
282 else if ( volalarm > 100 ) 281 else if ( volalarm > 100 )
283 volalarm = 100; 282 volalarm = 100;
284 volalarm |= ( volalarm << 8 ); 283 volalarm |= ( volalarm << 8 );
285 284
286 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 285 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
287 vol_reset = true; 286 vol_reset = true;
288 } 287 }
289 } 288 }
290 289
291 snd. play(); 290 snd. play();
292 while ( !snd. isFinished()) 291 while ( !snd. isFinished())
293 qApp->processEvents(); 292 qApp->processEvents();
294 293
295 if ( fd >= 0 ) { 294 if ( fd >= 0 ) {
296 if ( vol_reset ) 295 if ( vol_reset )
297 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 296 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
298 ::close ( fd ); 297 ::close ( fd );
299 } 298 }
300#endif 299#endif
301} 300}
302 301
303 302
304bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 303bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
305{ 304{
306 qDebug( "ODevice for SIMpad: suspend()" ); 305 qDebug( "ODevice for SIMpad: suspend()" );
307 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 306 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
308 return false; 307 return false;
309 308
310 bool res = false; 309 bool res = false;
311 ODevice::sendSuspendmsg(); 310 ODevice::sendSuspendmsg();
312 311
313 struct timeval tvs, tvn; 312 struct timeval tvs, tvn;
314 ::gettimeofday ( &tvs, 0 ); 313 ::gettimeofday ( &tvs, 0 );
315 314
316 ::sync(); // flush fs caches 315 ::sync(); // flush fs caches
317 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 316 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
318 317
319 return res; 318 return res;
320} 319}
321 320
322 321
323bool SIMpad::setSoftSuspend ( bool soft ) 322bool SIMpad::setSoftSuspend ( bool soft )
324{ 323{
325 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 324 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
326 return false; 325 return false;
327} 326}
328 327
329 328
330bool SIMpad::setDisplayStatus ( bool on ) 329bool SIMpad::setDisplayStatus ( bool on )
331{ 330{
332 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 331 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
333 332
334 bool res = false; 333 bool res = false;
335 int fd; 334 int fd;
336 335
337 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 336 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
338 337
339 res = ( ::system( (const char*) cmdline ) == 0 ); 338 res = ( ::system( (const char*) cmdline ) == 0 );
340 339
341 return res; 340 return res;
342} 341}
343 342
diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h
index a65bc48..d183641 100644
--- a/libopie2/opiecore/okeyfilter.h
+++ b/libopie2/opiecore/okeyfilter.h
@@ -1,105 +1,100 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> 3 =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org>
4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .>+-= 5 .>+-=
6_;:, .> :=|. This program is free software; you can 6_;:, .> :=|. This program is free software; you can
7.> <`_, > . <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 8:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
9.="- .-=="i, .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10- . .-<_> .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11 ._= =} : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12 .%`+i> _;_. 12 .%`+i> _;_.
13 .i_,=:_. -<s. This program is distributed in the hope that 13 .i_,=:_. -<s. This program is distributed in the hope that
14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15 : .. .:, . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.= = ; Library General Public License for more 18..}^=.= = ; Library General Public License for more
19++= -. .` .: details. 19++= -. .` .: details.
20: = ...= . :.=- 20: = ...= . :.=-
21-. .:....=;==+<; You should have received a copy of the GNU 21-. .:....=;==+<; You should have received a copy of the GNU
22 -_. . . )=. = Library General Public License along with 22 -_. . . )=. = Library General Public License along with
23 -- :-=` this library; see the file COPYING.LIB. 23 -- :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29/* QT */ 29/* QT */
30#include <qwindowsystem_qws.h> 30#include <qwindowsystem_qws.h>
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32 32
33namespace Opie { 33namespace Opie {
34namespace Core { 34namespace Core {
35 class ODevice; 35 class ODevice;
36namespace Internal { 36
37 class iPAQ;
38 class SIMpad;
39}
40 37
41/** 38/**
42 * A singleton which will manage all possible keyboard filters inside opie. 39 * A singleton which will manage all possible keyboard filters inside opie.
43 * It makes sure that key handlers of odevice are checked first than the 40 * It makes sure that key handlers of odevice are checked first than the
44 * keyfilters of software. 41 * keyfilters of software.
45 * @short a keyfilter proxy 42 * @short a keyfilter proxy
46 * @see QWSServer::KeyboardFilter 43 * @see QWSServer::KeyboardFilter
47 * @author Rajko Albrecht 44 * @author Rajko Albrecht
48 * @version 1.0 45 * @version 1.0
49 */ 46 */
50class OKeyFilter 47class OKeyFilter
51{ 48{
52 friend class Opie::Core::ODevice; 49 friend class Opie::Core::ODevice;
53 friend class Opie::Core::Internal::iPAQ;
54 friend class Opie::Core::Internal::SIMpad;
55 50
56protected: 51protected:
57 /** 52 /**
58 * Protected constructor - generate class via inst() 53 * Protected constructor - generate class via inst()
59 * @see inst() 54 * @see inst()
60 */ 55 */
61 OKeyFilter(); 56 OKeyFilter();
62 /** 57 /**
63 * Protected constructor - generate class via inst() 58 * Protected constructor - generate class via inst()
64 * @see inst() 59 * @see inst()
65 */ 60 */
66 OKeyFilter(const OKeyFilter&){}; 61 OKeyFilter(const OKeyFilter&){};
67 /** 62 /**
68 * Append filter to the primary list. 63 * Append filter to the primary list.
69 * This is only allowed for friend classes from odevice 64 * This is only allowed for friend classes from odevice
70 * @param aFilter a filter to append 65 * @param aFilter a filter to append
71 * @see addHandler 66 * @see addHandler
72 */ 67 */
73 virtual void addPreHandler(QWSServer::KeyboardFilter*aFilter)=0; 68 virtual void addPreHandler(QWSServer::KeyboardFilter*aFilter)=0;
74 /** 69 /**
75 * Remove the specified filter from list and give back ownership. 70 * Remove the specified filter from list and give back ownership.
76 * This is only allowed for friend classes from odevice 71 * This is only allowed for friend classes from odevice
77 * @param aFilter a filter to remove 72 * @param aFilter a filter to remove
78 * @see remHandler 73 * @see remHandler
79 */ 74 */
80 virtual void remPreHandler(QWSServer::KeyboardFilter*aFilter)=0; 75 virtual void remPreHandler(QWSServer::KeyboardFilter*aFilter)=0;
81 76
82public: 77public:
83 virtual ~OKeyFilter(); 78 virtual ~OKeyFilter();
84 /** 79 /**
85 * Append filter to the secondary list. 80 * Append filter to the secondary list.
86 * @param aFilter a filter to append 81 * @param aFilter a filter to append
87 * @see addPreHandler 82 * @see addPreHandler
88 */ 83 */
89 virtual void addHandler(QWSServer::KeyboardFilter*)=0; 84 virtual void addHandler(QWSServer::KeyboardFilter*)=0;
90 /** 85 /**
91 * Remove the specified filter from list and give back ownership. 86 * Remove the specified filter from list and give back ownership.
92 * @param aFilter a filter to remove 87 * @param aFilter a filter to remove
93 * @see remPreHandler 88 * @see remPreHandler
94 */ 89 */
95 virtual void remHandler(QWSServer::KeyboardFilter*)=0; 90 virtual void remHandler(QWSServer::KeyboardFilter*)=0;
96 91
97 /** 92 /**
98 * Returns a handler to an instance of OKeyFilter 93 * Returns a handler to an instance of OKeyFilter
99 * @return a pointer to a working OKeyFilter 94 * @return a pointer to a working OKeyFilter
100 */ 95 */
101 static OKeyFilter*inst(); 96 static OKeyFilter*inst();
102}; 97};
103 98
104} 99}
105} 100}