summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp44
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp61
2 files changed, 55 insertions, 50 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index cd3a84c..835586e 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,246 +1,246 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++= -. .` .: details. 20++=   -.     .`     .: details.
21: = ...= . :.=- 21 :     =  ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48#include <opie2/okeyfilter.h> 48#include <opie2/okeyfilter.h>
49 49
50/* STD */ 50/* STD */
51#include <fcntl.h> 51#include <fcntl.h>
52#include <math.h> 52#include <math.h>
53#include <stdlib.h> 53#include <stdlib.h>
54#include <signal.h> 54#include <signal.h>
55#include <sys/ioctl.h> 55#include <sys/ioctl.h>
56#include <sys/time.h> 56#include <sys/time.h>
57#include <unistd.h> 57#include <unistd.h>
58#ifndef QT_NO_SOUND 58#ifndef QT_NO_SOUND
59#include <linux/soundcard.h> 59#include <linux/soundcard.h>
60#endif 60#endif
61 61
62namespace Opie { 62namespace Opie {
63namespace Core { 63namespace Core {
64 64
65static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 65static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
66 66
67 67
68/* STATIC and common implementation */ 68/* STATIC and common implementation */
69/* EXPORT */ ODistribution distributions[] = { 69/* EXPORT */ ODistribution distributions[] = {
70 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 70 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
71 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 71 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
72 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 72 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
73 { System_Unknown, "Linux", "/etc/issue" }, 73 { System_Unknown, "Linux", "/etc/issue" },
74}; 74};
75 75
76 76
77/* EXPORT */ bool isQWS(){ 77/* EXPORT */ bool isQWS(){
78 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 78 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
79} 79}
80 80
81/* EXPORT */ QCString makeChannel ( const char *str ){ 81/* EXPORT */ QCString makeChannel ( const char *str ){
82 if ( str && !::strchr ( str, '/' )) 82 if ( str && !::strchr ( str, '/' ))
83 return QCString ( "QPE/Application/" ) + str; 83 return QCString ( "QPE/Application/" ) + str;
84 else 84 else
85 return str; 85 return str;
86} 86}
87 87
88 88
89 89
90/* Now the default implementation of ODevice */ 90/* Now the default implementation of ODevice */
91 91
92struct default_button default_buttons [] = { 92struct default_button default_buttons [] = {
93 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 93 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
94 "devicebuttons/z_calendar", 94 "devicebuttons/z_calendar",
95 "datebook", "nextView()", 95 "datebook", "nextView()",
96 "today", "raise()" }, 96 "today", "raise()" },
97 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 97 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
98 "devicebuttons/z_contact", 98 "devicebuttons/z_contact",
99 "addressbook", "raise()", 99 "addressbook", "raise()",
100 "addressbook", "beamBusinessCard()" }, 100 "addressbook", "beamBusinessCard()" },
101 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 101 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
102 "devicebuttons/z_home", 102 "devicebuttons/z_home",
103 "QPE/Launcher", "home()", 103 "QPE/Launcher", "home()",
104 "buttonsettings", "raise()" }, 104 "buttonsettings", "raise()" },
105 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 105 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
106 "devicebuttons/z_menu", 106 "devicebuttons/z_menu",
107 "QPE/TaskBar", "toggleMenu()", 107 "QPE/TaskBar", "toggleMenu()",
108 "QPE/TaskBar", "toggleStartMenu()" }, 108 "QPE/TaskBar", "toggleStartMenu()" },
109 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 109 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
110 "devicebuttons/z_mail", 110 "devicebuttons/z_mail",
111 "opiemail", "raise()", 111 "opiemail", "raise()",
112 "opiemail", "newMail()" }, 112 "opiemail", "newMail()" },
113}; 113};
114 114
115ODevice *ODevice::inst() 115ODevice *ODevice::inst()
116{ 116{
117 static ODevice *dev = 0; 117 static ODevice *dev = 0;
118 118
119 // rewrite this to only use /proc/cpuinfo or so 119 // rewrite this to only use /proc/cpuinfo or so
120 QString cpu_info; 120 QString cpu_info;
121 121
122 if ( !dev ) 122 if ( !dev )
123 { 123 {
124 QFile f( PATH_PROC_CPUINFO ); 124 QFile f( PATH_PROC_CPUINFO );
125 if ( f.open( IO_ReadOnly ) ) 125 if ( f.open( IO_ReadOnly ) )
126 { 126 {
127 QTextStream s( &f ); 127 QTextStream s( &f );
128 while ( !s.atEnd() ) 128 while ( !s.atEnd() )
129 { 129 {
130 QString line; 130 QString line;
131 line = s.readLine(); 131 line = s.readLine();
132 if ( line.startsWith( "Hardware" ) ) 132 if ( line.startsWith( "Hardware" ) )
133 { 133 {
134 qDebug( "ODevice() - found '%s'", (const char*) line ); 134 qDebug( "ODevice() - found '%s'", (const char*) line );
135 cpu_info = line; 135 cpu_info = line;
136 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 136 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
137 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 137 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
138 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 138 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
139 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 139 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
140 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 140 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
141 else qWarning( "ODevice() - unknown hardware - using default." ); 141 else qWarning( "ODevice() - unknown hardware - using default." );
142 break; 142 break;
143 } 143 }
144 } 144 }
145 } 145 }
146 else 146 else
147 { 147 {
148 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 148 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
149 } 149 }
150 if ( !dev ) dev = new ODevice(); 150 if ( !dev ) dev = new Internal::Zaurus();
151 dev->init(cpu_info); 151 dev->init(cpu_info);
152 } 152 }
153 return dev; 153 return dev;
154} 154}
155 155
156ODevice::ODevice() 156ODevice::ODevice()
157{ 157{
158 d = new ODeviceData; 158 d = new ODeviceData;
159 159
160 d->m_modelstr = "Unknown"; 160 d->m_modelstr = "Unknown";
161 d->m_model = Model_Unknown; 161 d->m_model = Model_Unknown;
162 d->m_vendorstr = "Unknown"; 162 d->m_vendorstr = "Unknown";
163 d->m_vendor = Vendor_Unknown; 163 d->m_vendor = Vendor_Unknown;
164 d->m_systemstr = "Unknown"; 164 d->m_systemstr = "Unknown";
165 d->m_system = System_Unknown; 165 d->m_system = System_Unknown;
166 d->m_sysverstr = "0.0"; 166 d->m_sysverstr = "0.0";
167 d->m_rotation = Rot0; 167 d->m_rotation = Rot0;
168 d->m_direction = CW; 168 d->m_direction = CW;
169 169
170 d->m_holdtime = 1000; // 1000ms 170 d->m_holdtime = 1000; // 1000ms
171 d->m_buttons = 0; 171 d->m_buttons = 0;
172 d->m_cpu_frequencies = new QStrList; 172 d->m_cpu_frequencies = new QStrList;
173 173
174 // New distribution detection code first checks for legacy distributions, 174 // New distribution detection code first checks for legacy distributions,
175 // identified by /etc/familiar-version or /etc/oz_version. 175 // identified by /etc/familiar-version or /etc/oz_version.
176 // Then check for OpenEmbedded and lastly, read /etc/issue 176 // Then check for OpenEmbedded and lastly, read /etc/issue
177 177
178 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 178 for ( unsigned int i = 0; i < sizeof distributions; ++i )
179 { 179 {
180 if ( QFile::exists( distributions[i].sysvfile ) ) 180 if ( QFile::exists( distributions[i].sysvfile ) )
181 { 181 {
182 d->m_systemstr = distributions[i].sysstr; 182 d->m_systemstr = distributions[i].sysstr;
183 d->m_system = distributions[i].system; 183 d->m_system = distributions[i].system;
184 d->m_sysverstr = "<Unknown>"; 184 d->m_sysverstr = "<Unknown>";
185 QFile f( distributions[i].sysvfile ); 185 QFile f( distributions[i].sysvfile );
186 if ( f.open( IO_ReadOnly ) ) 186 if ( f.open( IO_ReadOnly ) )
187 { 187 {
188 QTextStream ts( &f ); 188 QTextStream ts( &f );
189 d->m_sysverstr = ts.readLine(); 189 d->m_sysverstr = ts.readLine();
190 } 190 }
191 break; 191 break;
192 } 192 }
193 } 193 }
194} 194}
195 195
196void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 196void ODevice::systemMessage( const QCString &msg, const QByteArray & )
197{ 197{
198 if ( msg == "deviceButtonMappingChanged()" ) { 198 if ( msg == "deviceButtonMappingChanged()" ) {
199 reloadButtonMapping(); 199 reloadButtonMapping();
200 } 200 }
201} 201}
202 202
203void ODevice::init(const QString&) 203void ODevice::init(const QString&)
204{ 204{
205} 205}
206 206
207/** 207/**
208* This method initialises the button mapping 208* This method initialises the button mapping
209*/ 209*/
210void ODevice::initButtons() 210void ODevice::initButtons()
211{ 211{
212 if ( d->m_buttons ) 212 if ( d->m_buttons )
213 return; 213 return;
214 214
215 qDebug ( "init Buttons" ); 215 qDebug ( "init Buttons" );
216 d->m_buttons = new QValueList <ODeviceButton>; 216 d->m_buttons = new QValueList <ODeviceButton>;
217 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 217 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
218 default_button *db = default_buttons + i; 218 default_button *db = default_buttons + i;
219 ODeviceButton b; 219 ODeviceButton b;
220 b. setKeycode ( db->code ); 220 b. setKeycode ( db->code );
221 b. setUserText ( QObject::tr ( "Button", db->utext )); 221 b. setUserText ( QObject::tr ( "Button", db->utext ));
222 b. setPixmap ( Resource::loadPixmap ( db->pix )); 222 b. setPixmap ( Resource::loadPixmap ( db->pix ));
223 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 223 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
224 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 224 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
225 d->m_buttons->append ( b ); 225 d->m_buttons->append ( b );
226 } 226 }
227 227
228 reloadButtonMapping(); 228 reloadButtonMapping();
229 229
230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
231 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 231 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
232} 232}
233 233
234ODevice::~ODevice() 234ODevice::~ODevice()
235{ 235{
236// we leak m_devicebuttons and m_cpu_frequency 236// we leak m_devicebuttons and m_cpu_frequency
237// but it's a singleton and it is not so importantant 237// but it's a singleton and it is not so importantant
238// -zecke 238// -zecke
239 delete d; 239 delete d;
240} 240}
241 241
242bool ODevice::setSoftSuspend ( bool /*soft*/ ) 242bool ODevice::setSoftSuspend ( bool /*soft*/ )
243{ 243{
244 return false; 244 return false;
245} 245}
246 246
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index bf46e43..c6de614 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,120 +1,120 @@
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
@@ -213,161 +213,166 @@ QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
213 //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
214 //vl << Led_Off; 214 //vl << Led_Off;
215 return vl; 215 return vl;
216} 216}
217 217
218OLedState SIMpad::ledState ( OLed l ) const 218OLedState SIMpad::ledState ( OLed l ) const
219{ 219{
220 switch ( l ) { 220 switch ( l ) {
221 case Led_Power: 221 case Led_Power:
222 return m_leds [0]; 222 return m_leds [0];
223 //case Led_Mail: 223 //case Led_Mail:
224 // return m_leds [1]; 224 // return m_leds [1];
225 default: 225 default:
226 return Led_Off; 226 return Led_Off;
227 } 227 }
228} 228}
229 229
230bool SIMpad::setLedState ( OLed l, OLedState st ) 230bool SIMpad::setLedState ( OLed l, OLedState st )
231{ 231{
232#if 0 232#if 0
233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
234 234
235 /*TODO Implement this like that: 235 /*TODO Implement this like that:
236 read from cs3 236 read from cs3
237 && with SIMPAD_LED2_ON 237 && with SIMPAD_LED2_ON
238 write to cs3 */ 238 write to cs3 */
239 m_leds [0] = st; 239 m_leds [0] = st;
240 return true; 240 return true;
241 } 241 }
242 } 242 }
243 } 243 }
244 244
245#endif 245#endif
246 return false; 246 return false;
247} 247}
248 248
249 249
250bool 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 )
251{ 251{
252 //TODO 252 //TODO
253 return false; 253 return false;
254} 254}
255 255
256void SIMpad::timerEvent ( QTimerEvent * ) 256void SIMpad::timerEvent ( QTimerEvent * )
257{ 257{
258 killTimer ( m_power_timer ); 258 killTimer ( m_power_timer );
259 m_power_timer = 0; 259 m_power_timer = 0;
260 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 260 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
262} 262}
263 263
264 264
265void SIMpad::playAlarmSound() 265void SIMpad::playAlarmSound()
266{ 266{
267#ifndef QT_NO_SOUND 267#ifndef QT_NO_SOUND
268 static Sound snd ( "alarm" ); 268 static Sound snd ( "alarm" );
269 int fd; 269 int fd;
270 int vol; 270 int vol;
271 bool vol_reset = false; 271 bool vol_reset = false;
272 272
273 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 273 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
274 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 274 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
275 Config cfg ( "qpe" ); 275 Config cfg ( "qpe" );
276 cfg. setGroup ( "Volume" ); 276 cfg. setGroup ( "Volume" );
277 277
278 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 278 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
279 if ( volalarm < 0 ) 279 if ( volalarm < 0 )
280 volalarm = 0; 280 volalarm = 0;
281 else if ( volalarm > 100 ) 281 else if ( volalarm > 100 )
282 volalarm = 100; 282 volalarm = 100;
283 volalarm |= ( volalarm << 8 ); 283 volalarm |= ( volalarm << 8 );
284 284
285 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 285 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
286 vol_reset = true; 286 vol_reset = true;
287 } 287 }
288 } 288 }
289 289
290 snd. play(); 290 snd. play();
291 while ( !snd. isFinished()) 291 while ( !snd. isFinished())
292 qApp->processEvents(); 292 qApp->processEvents();
293 293
294 if ( fd >= 0 ) { 294 if ( fd >= 0 ) {
295 if ( vol_reset ) 295 if ( vol_reset )
296 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 296 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
297 ::close ( fd ); 297 ::close ( fd );
298 } 298 }
299#endif 299#endif
300} 300}
301 301
302 302
303bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 303bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
304{ 304{
305 qDebug( "ODevice for SIMpad: suspend()" ); 305 qDebug( "ODevice for SIMpad: suspend()" );
306 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 306 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
307 return false; 307 return false;
308 308
309 bool res = false; 309 /*
310 ODevice::sendSuspendmsg(); 310 * we need to save the screen content
311 311 * then go to suspend using ODevice::suspend
312 struct timeval tvs, tvn; 312 * and finally restore the screen content
313 ::gettimeofday ( &tvs, 0 ); 313 */
314 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" );
315 bool res = ODevice::suspend();
314 316
315 ::sync(); // flush fs caches 317 /*
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 * restore
319 */
320 if ( res )
321 ::system( "cat /tmp/.buffer > /dev/fb/0" );
317 322
318 return res; 323 return res;
319} 324}
320 325
321 326
322bool SIMpad::setSoftSuspend ( bool soft ) 327bool SIMpad::setSoftSuspend ( bool soft )
323{ 328{
324 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 329 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
325 return false; 330 return false;
326} 331}
327 332
328 333
329bool SIMpad::setDisplayStatus ( bool on ) 334bool SIMpad::setDisplayStatus ( bool on )
330{ 335{
331 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 336 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
332 337
333 bool res = false; 338 bool res = false;
334 int fd; 339 int fd;
335 340
336 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 341 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
337 342
338 res = ( ::system( (const char*) cmdline ) == 0 ); 343 res = ( ::system( (const char*) cmdline ) == 0 );
339 344
340 return res; 345 return res;
341} 346}
342 347
343 348
344bool SIMpad::setDisplayBrightness ( int bright ) 349bool SIMpad::setDisplayBrightness ( int bright )
345{ 350{
346 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 351 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
347 bool res = false; 352 bool res = false;
348 int fd; 353 int fd;
349 354
350 if ( bright > 255 ) 355 if ( bright > 255 )
351 bright = 255; 356 bright = 255;
352 if ( bright < 1 ) 357 if ( bright < 1 )
353 bright = 0; 358 bright = 0;
354 359
355 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 360 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
356 int value = 255 - bright; 361 int value = 255 - bright;
357 const int mask = SIMPAD_BACKLIGHT_MASK; 362 const int mask = SIMPAD_BACKLIGHT_MASK;
358 value = value << 8; 363 value = value << 8;
359 value += mask; 364 value += mask;
360 char writeCommand[100]; 365 char writeCommand[100];
361 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); 366 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value );
362 res = ( ::write ( fd, writeCommand, count ) != -1 ); 367 res = ( ::write ( fd, writeCommand, count ) != -1 );
363 ::close ( fd ); 368 ::close ( fd );
364 } 369 }
365 return res; 370 return res;
366} 371}
367 372
368 373
369int SIMpad::displayBrightnessResolution() const 374int SIMpad::displayBrightnessResolution() const
370{ 375{
371 return 255; // All SIMpad models share the same display 376 return 255; // All SIMpad models share the same display
372} 377}
373 378