summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/main.cpp7
-rw-r--r--core/opie-login/main.cpp7
-rw-r--r--libopie2/opiecore/device/odevice.cpp5
-rw-r--r--libopie2/opiecore/device/odevice.h2
-rw-r--r--libopie2/opiecore/device/odevice_genuineintel.cpp6
-rw-r--r--libopie2/opiecore/device/odevice_genuineintel.h2
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp21
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp44
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h2
10 files changed, 3 insertions, 95 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 734d072..5bbed59 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,262 +1,255 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2003-2005 The Opie Team <opie-devel@handhelds.org> 3** Copyright (C) 2003-2005 The Opie Team <opie-devel@handhelds.org>
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**********************************************************************/ 12**********************************************************************/
13 13
14#ifndef QTOPIA_INTERNAL_FILEOPERATIONS 14#ifndef QTOPIA_INTERNAL_FILEOPERATIONS
15#define QTOPIA_INTERNAL_FILEOPERATIONS 15#define QTOPIA_INTERNAL_FILEOPERATIONS
16#endif 16#endif
17#ifdef QT_QWS_LOGIN 17#ifdef QT_QWS_LOGIN
18#include "../login/qdmdialogimpl.h" 18#include "../login/qdmdialogimpl.h"
19#endif 19#endif
20#include "calibrate.h" 20#include "calibrate.h"
21#include "server.h" 21#include "server.h"
22#include "serverapp.h" 22#include "serverapp.h"
23#include "stabmon.h" 23#include "stabmon.h"
24#include "firstuse.h" 24#include "firstuse.h"
25 25
26/* OPIE */ 26/* OPIE */
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <opie2/odevice.h> 28#include <opie2/odevice.h>
29#include <opie2/oglobal.h> 29#include <opie2/oglobal.h>
30#include <qtopia/network.h> 30#include <qtopia/network.h>
31#include <qtopia/alarmserver.h> 31#include <qtopia/alarmserver.h>
32using namespace Opie::Core; 32using namespace Opie::Core;
33 33
34/* QT */ 34/* QT */
35#include <qdir.h> 35#include <qdir.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#ifdef QWS 37#ifdef QWS
38#include <qwindowsystem_qws.h> 38#include <qwindowsystem_qws.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#endif 40#endif
41#ifdef Q_WS_QWS 41#ifdef Q_WS_QWS
42#include <qkeyboard_qws.h> 42#include <qkeyboard_qws.h>
43#endif 43#endif
44 44
45/* STD */ 45/* STD */
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48#include <signal.h> 48#include <signal.h>
49#include <unistd.h> 49#include <unistd.h>
50#include <errno.h> 50#include <errno.h>
51#include <string.h> 51#include <string.h>
52 52
53void create_pidfile(); 53void create_pidfile();
54void remove_pidfile(); 54void remove_pidfile();
55 55
56static void cleanup() 56static void cleanup()
57{ 57{
58 QDir dir( "/tmp", "qcop-msg-*" ); 58 QDir dir( "/tmp", "qcop-msg-*" );
59 59
60 QStringList stale = dir.entryList(); 60 QStringList stale = dir.entryList();
61 QStringList::Iterator it; 61 QStringList::Iterator it;
62 for ( it = stale.begin(); it != stale.end(); ++it ) { 62 for ( it = stale.begin(); it != stale.end(); ++it ) {
63 dir.remove( *it ); 63 dir.remove( *it );
64 } 64 }
65} 65}
66 66
67void initEnvironment() 67void initEnvironment()
68{ 68{
69 Config config("locale"); 69 Config config("locale");
70 config.setGroup( "Location" ); 70 config.setGroup( "Location" );
71 QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); 71 QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace();
72 72
73 // timezone 73 // timezone
74 if (tz.isNull() || tz.isEmpty()) tz = "America/New_York"; 74 if (tz.isNull() || tz.isEmpty()) tz = "America/New_York";
75 setenv( "TZ", tz, 1 ); 75 setenv( "TZ", tz, 1 );
76 config.writeEntry( "Timezone", tz); 76 config.writeEntry( "Timezone", tz);
77 77
78 // language 78 // language
79 config.setGroup( "Language" ); 79 config.setGroup( "Language" );
80 QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); 80 QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace();
81 if( lang.isNull() || lang.isEmpty()) lang = "en_US"; 81 if( lang.isNull() || lang.isEmpty()) lang = "en_US";
82 setenv( "LANG", lang, 1 ); 82 setenv( "LANG", lang, 1 );
83 config.writeEntry("Language", lang); 83 config.writeEntry("Language", lang);
84 config.write(); 84 config.write();
85 85
86 // rotation 86 // rotation
87 int t = ODevice::inst()->rotation(); 87 int t = ODevice::inst()->rotation();
88 odebug << "ODevice reports transformation to be " << t << oendl; 88 odebug << "ODevice reports transformation to be " << t << oendl;
89 89
90 QString env( getenv("QWS_DISPLAY") ); 90 QString env( getenv("QWS_DISPLAY") );
91 if ( env.isEmpty() ) 91 if ( env.isEmpty() )
92 { 92 {
93 int rot = ODevice::inst()->rotation() * 90; 93 int rot = ODevice::inst()->rotation() * 90;
94 QString qws_display = QString("Transformed:Rot%1:0").arg(rot); 94 QString qws_display = QString("Transformed:Rot%1:0").arg(rot);
95 odebug << "setting QWS_DISPLAY to '" << qws_display << "'" << oendl; 95 odebug << "setting QWS_DISPLAY to '" << qws_display << "'" << oendl;
96 setenv("QWS_DISPLAY", (const char*) qws_display, 1); 96 setenv("QWS_DISPLAY", (const char*) qws_display, 1);
97 } 97 }
98 else 98 else
99 odebug << "QWS_DISPLAY already set as '" << env << "' - overriding ODevice transformation" << oendl; 99 odebug << "QWS_DISPLAY already set as '" << env << "' - overriding ODevice transformation" << oendl;
100 100
101 QPEApplication::defaultRotation(); /* to ensure deforient matches reality */ 101 QPEApplication::defaultRotation(); /* to ensure deforient matches reality */
102} 102}
103 103
104static void initKeyboard() 104static void initKeyboard()
105{ 105{
106 Config config("qpe"); 106 Config config("qpe");
107 107
108 config.setGroup( "Keyboard" ); 108 config.setGroup( "Keyboard" );
109 109
110 int ard = config.readNumEntry( "RepeatDelay" ); 110 int ard = config.readNumEntry( "RepeatDelay" );
111 int arp = config.readNumEntry( "RepeatPeriod" ); 111 int arp = config.readNumEntry( "RepeatPeriod" );
112 if ( ard > 0 && arp > 0 ) 112 if ( ard > 0 && arp > 0 )
113 qwsSetKeyboardAutoRepeat( ard, arp ); 113 qwsSetKeyboardAutoRepeat( ard, arp );
114 114
115 QString layout = config.readEntry( "Layout", "us101" ); 115 QString layout = config.readEntry( "Layout", "us101" );
116 Server::setKeyboardLayout( layout ); 116 Server::setKeyboardLayout( layout );
117} 117}
118 118
119static bool firstUse() 119static bool firstUse()
120{ 120{
121 bool needFirstUse = FALSE; 121 bool needFirstUse = FALSE;
122 if ( QWSServer::mouseHandler() && 122 if ( QWSServer::mouseHandler() &&
123 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 123 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
124 if ( !QFile::exists( "/etc/pointercal" ) ) 124 if ( !QFile::exists( "/etc/pointercal" ) )
125 needFirstUse = TRUE; 125 needFirstUse = TRUE;
126 } 126 }
127 127
128 { 128 {
129 Config config( "qpe" ); 129 Config config( "qpe" );
130 config.setGroup( "Startup" ); 130 config.setGroup( "Startup" );
131 needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); 131 needFirstUse |= config.readBoolEntry( "FirstUse", TRUE );
132 } 132 }
133 133
134 if ( !needFirstUse ) 134 if ( !needFirstUse )
135 return FALSE; 135 return FALSE;
136 136
137 FirstUse *fu = new FirstUse(); 137 FirstUse *fu = new FirstUse();
138 fu->exec(); 138 fu->exec();
139 bool rs = fu->restartNeeded(); 139 bool rs = fu->restartNeeded();
140 delete fu; 140 delete fu;
141 return rs; 141 return rs;
142} 142}
143 143
144int initApplication( int argc, char ** argv ) 144int initApplication( int argc, char ** argv )
145{ 145{
146 cleanup(); 146 cleanup();
147 initEnvironment(); 147 initEnvironment();
148 148
149#ifdef QWS 149#ifdef QWS
150 QWSServer::setDesktopBackground( QImage() ); 150 QWSServer::setDesktopBackground( QImage() );
151#endif 151#endif
152 ServerApplication a( argc, argv, QApplication::GuiServer ); 152 ServerApplication a( argc, argv, QApplication::GuiServer );
153 initKeyboard(); 153 initKeyboard();
154 154
155 if ( firstUse() ) 155 if ( firstUse() )
156 { 156 {
157 a.restart(); 157 a.restart();
158 return 0; 158 return 0;
159 } 159 }
160 160
161#ifndef Q_OS_MACX
162 ODevice::inst()->setSoftSuspend( true );
163#endif
164 { 161 {
165 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 162 QCopEnvelope e("QPE/System", "setBacklight(int)" );
166 e << -3; // Forced on 163 e << -3; // Forced on
167 } 164 }
168 165
169 AlarmServer::initialize(); 166 AlarmServer::initialize();
170 Server *s = new Server(); 167 Server *s = new Server();
171 new SysFileMonitor(s); 168 new SysFileMonitor(s);
172#ifdef QWS 169#ifdef QWS
173 Network::createServer(s); 170 Network::createServer(s);
174#endif 171#endif
175 s->show(); 172 s->show();
176 173
177#if 0 174#if 0
178 if ( QDate::currentDate().year() < 2005 ) 175 if ( QDate::currentDate().year() < 2005 )
179 { 176 {
180 if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), 177 if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ),
181 ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ) 178 ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" )
182 .arg( TimeString::dateString( QDate::currentDate())), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 179 .arg( TimeString::dateString( QDate::currentDate())), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
183 { 180 {
184 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); 181 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" );
185 e << QString ( ); 182 e << QString ( );
186 } 183 }
187 } 184 }
188#endif 185#endif
189 186
190 create_pidfile(); 187 create_pidfile();
191 odebug << "--> mainloop in" << oendl; 188 odebug << "--> mainloop in" << oendl;
192 int rv = a.exec(); 189 int rv = a.exec();
193 odebug << "<-- mainloop out" << oendl; 190 odebug << "<-- mainloop out" << oendl;
194 remove_pidfile(); 191 remove_pidfile();
195 odebug << "removing server object..." << oendl; 192 odebug << "removing server object..." << oendl;
196 delete s; 193 delete s;
197 194
198#ifndef Q_OS_MACX
199 ODevice::inst()->setSoftSuspend( false );
200#endif
201
202 odebug << "returning from qpe/initapplication..." << oendl; 195 odebug << "returning from qpe/initapplication..." << oendl;
203 return rv; 196 return rv;
204} 197}
205 198
206static const char *pidfile_path = "/var/run/opie.pid"; 199static const char *pidfile_path = "/var/run/opie.pid";
207 200
208void create_pidfile() 201void create_pidfile()
209{ 202{
210 FILE *f; 203 FILE *f;
211 204
212 if (( f = ::fopen( pidfile_path, "w" ))) { 205 if (( f = ::fopen( pidfile_path, "w" ))) {
213 ::fprintf( f, "%d", getpid ( )); 206 ::fprintf( f, "%d", getpid ( ));
214 ::fclose( f ); 207 ::fclose( f );
215 } 208 }
216 else 209 else
217 { 210 {
218 odebug << "couldn't create pidfile: " << strerror( errno ) << oendl; 211 odebug << "couldn't create pidfile: " << strerror( errno ) << oendl;
219 } 212 }
220} 213}
221 214
222void remove_pidfile() 215void remove_pidfile()
223{ 216{
224 ::unlink( pidfile_path ); 217 ::unlink( pidfile_path );
225} 218}
226 219
227void handle_sigterm( int sig ) 220void handle_sigterm( int sig )
228{ 221{
229 qDebug( "D'oh! QPE Server process got SIGNAL %d. Trying to exit gracefully...", sig ); 222 qDebug( "D'oh! QPE Server process got SIGNAL %d. Trying to exit gracefully...", sig );
230 ::signal( SIGCHLD, SIG_IGN ); 223 ::signal( SIGCHLD, SIG_IGN );
231 ::signal( SIGSEGV, SIG_IGN ); 224 ::signal( SIGSEGV, SIG_IGN );
232 ::signal( SIGBUS, SIG_IGN ); 225 ::signal( SIGBUS, SIG_IGN );
233 ::signal( SIGILL, SIG_IGN ); 226 ::signal( SIGILL, SIG_IGN );
234 ::signal( SIGTERM, SIG_IGN ); 227 ::signal( SIGTERM, SIG_IGN );
235 ::signal ( SIGINT, SIG_IGN ); 228 ::signal ( SIGINT, SIG_IGN );
236 if ( qApp ) qApp->quit(); 229 if ( qApp ) qApp->quit();
237} 230}
238 231
239int main( int argc, char ** argv ) 232int main( int argc, char ** argv )
240{ 233{
241 ::signal( SIGCHLD, SIG_IGN ); 234 ::signal( SIGCHLD, SIG_IGN );
242 ::signal( SIGSEGV, handle_sigterm ); 235 ::signal( SIGSEGV, handle_sigterm );
243 ::signal( SIGBUS, handle_sigterm ); 236 ::signal( SIGBUS, handle_sigterm );
244 ::signal( SIGILL, handle_sigterm ); 237 ::signal( SIGILL, handle_sigterm );
245 ::signal( SIGTERM, handle_sigterm ); 238 ::signal( SIGTERM, handle_sigterm );
246 ::signal ( SIGINT, handle_sigterm ); 239 ::signal ( SIGINT, handle_sigterm );
247 ::setsid(); 240 ::setsid();
248 ::setpgid( 0, 0 ); 241 ::setpgid( 0, 0 );
249 242
250 ::atexit( remove_pidfile ); 243 ::atexit( remove_pidfile );
251 244
252 int retVal = initApplication( argc, argv ); 245 int retVal = initApplication( argc, argv );
253 246
254 // Have we been asked to restart? 247 // Have we been asked to restart?
255 if ( ServerApplication::doRestart ) 248 if ( ServerApplication::doRestart )
256 { 249 {
257 for ( int fd = 3; fd < 100; fd++ ) close( fd ); 250 for ( int fd = 3; fd < 100; fd++ ) close( fd );
258 execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 ); 251 execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 );
259 } 252 }
260 253
261 return retVal; 254 return retVal;
262} 255}
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 0699d0a..2de0180 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -1,383 +1,378 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#include "loginapplication.h" 28#include "loginapplication.h"
29#include "loginwindowimpl.h" 29#include "loginwindowimpl.h"
30#include "calibrate.h" 30#include "calibrate.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34#include <qpe/qpestyle.h> 34#include <qpe/qpestyle.h>
35#include <qpe/power.h> 35#include <qpe/power.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38/* QT */ 38/* QT */
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#include <qmessagebox.h> 40#include <qmessagebox.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qfile.h> 43#include <qfile.h>
44 44
45/* STD */ 45/* STD */
46#include <sys/types.h> 46#include <sys/types.h>
47#include <time.h> 47#include <time.h>
48#include <sys/time.h> 48#include <sys/time.h>
49#include <sys/resource.h> 49#include <sys/resource.h>
50#include <unistd.h> 50#include <unistd.h>
51#include <syslog.h> 51#include <syslog.h>
52#include <sys/wait.h> 52#include <sys/wait.h>
53#include <stdio.h> 53#include <stdio.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <signal.h> 55#include <signal.h>
56#include <getopt.h> 56#include <getopt.h>
57#include <string.h> 57#include <string.h>
58 58
59using namespace Opie::Core; 59using namespace Opie::Core;
60 60
61int login_main ( int argc, char **argv, pid_t ppid ); 61int login_main ( int argc, char **argv, pid_t ppid );
62void sigterm ( int sig ); 62void sigterm ( int sig );
63void sigint ( int sig ); 63void sigint ( int sig );
64void exit_closelog ( ); 64void exit_closelog ( );
65 65
66static struct option long_options [] = { 66static struct option long_options [] = {
67 { "autologin", 1, 0, 'a' }, 67 { "autologin", 1, 0, 'a' },
68 { 0, 0, 0, 0 } 68 { 0, 0, 0, 0 }
69}; 69};
70 70
71 71
72int main ( int argc, char **argv ) 72int main ( int argc, char **argv )
73{ 73{
74 int userExited = 0; 74 int userExited = 0;
75 pid_t ppid = ::getpid ( ); 75 pid_t ppid = ::getpid ( );
76 76
77 if ( ::geteuid ( ) != 0 ) { 77 if ( ::geteuid ( ) != 0 ) {
78 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); 78 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
79 return 1; 79 return 1;
80 } 80 }
81 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and 81 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and
82 ::setuid ( 0 ); // messes up things like config files 82 ::setuid ( 0 ); // messes up things like config files
83 83
84 char *autolog = 0; 84 char *autolog = 0;
85 int c; 85 int c;
86 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { 86 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) {
87 switch ( c ) { 87 switch ( c ) {
88 case 'a': 88 case 'a':
89 autolog = optarg; 89 autolog = optarg;
90 break; 90 break;
91 default: 91 default:
92 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); 92 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] );
93 return 2; 93 return 2;
94 } 94 }
95 } 95 }
96 96
97 //struct rlimit rl; 97 //struct rlimit rl;
98 //::getrlimit ( RLIMIT_NOFILE, &rl ); 98 //::getrlimit ( RLIMIT_NOFILE, &rl );
99 99
100 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) 100 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ )
101 // ::close ( i ); 101 // ::close ( i );
102 102
103 ::setpgid ( 0, 0 ); 103 ::setpgid ( 0, 0 );
104 ::setsid ( ); 104 ::setsid ( );
105 105
106 ::signal ( SIGTERM, sigterm ); 106 ::signal ( SIGTERM, sigterm );
107 ::signal ( SIGINT, sigterm ); 107 ::signal ( SIGINT, sigterm );
108 108
109 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); 109 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV );
110 ::atexit ( exit_closelog ); 110 ::atexit ( exit_closelog );
111 111
112 while ( true ) { 112 while ( true ) {
113 pid_t child = ::fork ( ); 113 pid_t child = ::fork ( );
114 114
115 if ( child < 0 ) { 115 if ( child < 0 ) {
116 ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); 116 ::syslog ( LOG_ERR, "Could not fork GUI process\n" );
117 break; 117 break;
118 } 118 }
119 else if ( child > 0 ) { 119 else if ( child > 0 ) {
120 int status = 0; 120 int status = 0;
121 time_t started = ::time ( 0 ); 121 time_t started = ::time ( 0 );
122 122
123 while ( ::waitpid ( child, &status, 0 ) < 0 ) { } 123 while ( ::waitpid ( child, &status, 0 ) < 0 ) { }
124 124
125 LoginApplication::logout ( ); 125 LoginApplication::logout ( );
126 126
127 if (( ::time ( 0 ) - started ) < 3 ) { 127 if (( ::time ( 0 ) - started ) < 3 ) {
128 if ( autolog ) { 128 if ( autolog ) {
129 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); 129 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" );
130 autolog = 0; 130 autolog = 0;
131 } 131 }
132 else { 132 else {
133 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); 133 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" );
134 break; 134 break;
135 } 135 }
136 } 136 }
137 int killedbysig = 0; 137 int killedbysig = 0;
138 userExited=0; 138 userExited=0;
139 if (WIFEXITED(status)!=0 ) { 139 if (WIFEXITED(status)!=0 ) {
140 if (WEXITSTATUS(status)==137) { 140 if (WEXITSTATUS(status)==137) {
141 userExited=1; 141 userExited=1;
142 } 142 }
143 } 143 }
144 144
145 if ( WIFSIGNALED( status )) { 145 if ( WIFSIGNALED( status )) {
146 switch ( WTERMSIG( status )) { 146 switch ( WTERMSIG( status )) {
147 case SIGTERM: 147 case SIGTERM:
148 case SIGINT : 148 case SIGINT :
149 case SIGKILL: 149 case SIGKILL:
150 break; 150 break;
151 151
152 default : 152 default :
153 killedbysig = WTERMSIG( status ); 153 killedbysig = WTERMSIG( status );
154 break; 154 break;
155 } 155 }
156 } 156 }
157 if ( killedbysig ) { // qpe was killed by an uncaught signal 157 if ( killedbysig ) { // qpe was killed by an uncaught signal
158 qApp = 0; 158 qApp = 0;
159 159
160 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); 160 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig );
161 161
162 QWSServer::setDesktopBackground ( QImage ( )); 162 QWSServer::setDesktopBackground ( QImage ( ));
163 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); 163 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer );
164 app-> setFont ( QFont ( "Helvetica", 10 )); 164 app-> setFont ( QFont ( "Helvetica", 10 ));
165 app-> setStyle ( new QPEStyle ( )); 165 app-> setStyle ( new QPEStyle ( ));
166 166
167 // const char *sig = ::strsignal ( killedbysig ); 167 // const char *sig = ::strsignal ( killedbysig );
168 const char *sig = ::sys_siglist[killedbysig]; 168 const char *sig = ::sys_siglist[killedbysig];
169 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); 169 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool );
170 l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); 170 l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig ));
171 l-> setAlignment ( Qt::AlignCenter ); 171 l-> setAlignment ( Qt::AlignCenter );
172 l-> move ( 0, 0 ); 172 l-> move ( 0, 0 );
173 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 173 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
174 l-> show ( ); 174 l-> show ( );
175 QTimer::singleShot ( 3000, app, SLOT( quit())); 175 QTimer::singleShot ( 3000, app, SLOT( quit()));
176 app-> exec ( ); 176 app-> exec ( );
177 delete app; 177 delete app;
178 qApp = 0; 178 qApp = 0;
179 } 179 }
180 } 180 }
181 else { 181 else {
182 if ( !autolog ) { 182 if ( !autolog ) {
183 QString confFile=QPEApplication::qpeDir() + "etc/opie-login.conf"; 183 QString confFile=QPEApplication::qpeDir() + "etc/opie-login.conf";
184 Config cfg ( confFile, Config::File ); 184 Config cfg ( confFile, Config::File );
185 cfg. setGroup ( "General" ); 185 cfg. setGroup ( "General" );
186 QString user = cfg. readEntry ( "AutoLogin" ); 186 QString user = cfg. readEntry ( "AutoLogin" );
187 187
188 if ( !user. isEmpty ( )) 188 if ( !user. isEmpty ( ))
189 autolog = ::strdup ( user. latin1 ( )); 189 autolog = ::strdup ( user. latin1 ( ));
190 } 190 }
191 191
192 if ( autolog && !userExited ) { 192 if ( autolog && !userExited ) {
193 193
194 QWSServer::setDesktopBackground( QImage() ); 194 QWSServer::setDesktopBackground( QImage() );
195 ODevice::inst ( )-> setDisplayStatus ( true ); 195 ODevice::inst()->setDisplayStatus( true );
196 ODevice::inst ( )-> setSoftSuspend ( false );
197 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 196 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
198 LoginApplication::setLoginAs ( autolog ); 197 LoginApplication::setLoginAs ( autolog );
199 198
200 199
201 if ( LoginApplication::changeIdentity ( )) 200 if ( LoginApplication::changeIdentity ( ))
202 ::exit ( LoginApplication::login ( )); 201 ::exit ( LoginApplication::login ( ));
203 else 202 else
204 ::exit ( 0 ); 203 ::exit ( 0 );
205 } 204 }
206 else { 205 else {
207 ::exit ( login_main ( argc, argv, ppid )); 206 ::exit ( login_main ( argc, argv, ppid ));
208 } 207 }
209 } 208 }
210 } 209 }
211 return 0; 210 return 0;
212} 211}
213 212
214void sigterm ( int /*sig*/ ) 213void sigterm ( int /*sig*/ )
215{ 214{
216 ::exit ( 0 ); 215 ::exit ( 0 );
217} 216}
218 217
219 218
220void exit_closelog ( ) 219void exit_closelog ( )
221{ 220{
222 ::closelog ( ); 221 ::closelog ( );
223} 222}
224 223
225 224
226class LoginScreenSaver : public QWSScreenSaver 225class LoginScreenSaver : public QWSScreenSaver
227{ 226{
228public: 227public:
229 LoginScreenSaver ( ) 228 LoginScreenSaver ( )
230 { 229 {
231 m_lcd_status = true; 230 m_lcd_status = true;
232 231
233 m_backlight_bright = -1; 232 m_backlight_bright = -1;
234 m_backlight_forcedoff = false; 233 m_backlight_forcedoff = false;
235 234
236 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 235 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
237 ODevice::inst ( )-> setDisplayStatus ( true ); 236 ODevice::inst ( )-> setDisplayStatus ( true );
238 } 237 }
239 void restore() 238 void restore()
240 { 239 {
241 if ( !m_lcd_status ) // We must have turned it off 240 if ( !m_lcd_status ) // We must have turned it off
242 ODevice::inst ( ) -> setDisplayStatus ( true ); 241 ODevice::inst ( ) -> setDisplayStatus ( true );
243 242
244 setBacklight ( -3 ); 243 setBacklight ( -3 );
245 } 244 }
246 bool save( int level ) 245 bool save( int level )
247 { 246 {
248 switch ( level ) { 247 switch ( level ) {
249 case 0: 248 case 0:
250 if ( backlight() > 1 ) 249 if ( backlight() > 1 )
251 setBacklight( 1 ); // lowest non-off 250 setBacklight( 1 ); // lowest non-off
252 return true; 251 return true;
253 break; 252 break;
254 case 1: 253 case 1:
255 setBacklight( 0 ); // off 254 setBacklight( 0 ); // off
256 return true; 255 return true;
257 break; 256 break;
258 case 2: 257 case 2:
259 // We're going to suspend the whole machine 258 // We're going to suspend the whole machine
260 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 259 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
261 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 260 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
262 return true; 261 return true;
263 } 262 }
264 break; 263 break;
265 } 264 }
266 return false; 265 return false;
267 } 266 }
268 267
269private: 268private:
270public: 269public:
271 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) 270 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 )
272 { 271 {
273 int v [4]; 272 int v [4];
274 273
275 v [ 0 ] = QMAX( 1000 * i1, 100 ); 274 v [ 0 ] = QMAX( 1000 * i1, 100 );
276 v [ 1 ] = QMAX( 1000 * i2, 100 ); 275 v [ 1 ] = QMAX( 1000 * i2, 100 );
277 v [ 2 ] = QMAX( 1000 * i3, 100 ); 276 v [ 2 ] = QMAX( 1000 * i3, 100 );
278 v [ 3 ] = 0; 277 v [ 3 ] = 0;
279 278
280 if ( !i1 && !i2 && !i3 ) 279 if ( !i1 && !i2 && !i3 )
281 QWSServer::setScreenSaverInterval ( 0 ); 280 QWSServer::setScreenSaverInterval ( 0 );
282 else 281 else
283 QWSServer::setScreenSaverIntervals ( v ); 282 QWSServer::setScreenSaverIntervals ( v );
284 } 283 }
285 284
286 int backlight ( ) 285 int backlight ( )
287 { 286 {
288 if ( m_backlight_bright == -1 ) 287 if ( m_backlight_bright == -1 )
289 m_backlight_bright = 255; 288 m_backlight_bright = 255;
290 289
291 return m_backlight_bright; 290 return m_backlight_bright;
292 } 291 }
293 292
294 void setBacklight ( int bright ) 293 void setBacklight ( int bright )
295 { 294 {
296 if ( bright == -3 ) { 295 if ( bright == -3 ) {
297 // Forced on 296 // Forced on
298 m_backlight_forcedoff = false; 297 m_backlight_forcedoff = false;
299 bright = -1; 298 bright = -1;
300 } 299 }
301 if ( m_backlight_forcedoff && bright != -2 ) 300 if ( m_backlight_forcedoff && bright != -2 )
302 return ; 301 return ;
303 if ( bright == -2 ) { 302 if ( bright == -2 ) {
304 // Toggle between off and on 303 // Toggle between off and on
305 bright = m_backlight_bright ? 0 : -1; 304 bright = m_backlight_bright ? 0 : -1;
306 m_backlight_forcedoff = !bright; 305 m_backlight_forcedoff = !bright;
307 } 306 }
308 307
309 m_backlight_bright = bright; 308 m_backlight_bright = bright;
310 309
311 bright = backlight ( ); 310 bright = backlight ( );
312 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 311 ODevice::inst ( ) -> setDisplayBrightness ( bright );
313 312
314 m_backlight_bright = bright; 313 m_backlight_bright = bright;
315 } 314 }
316 315
317private: 316private:
318 bool m_lcd_status; 317 bool m_lcd_status;
319 318
320 int m_backlight_bright; 319 int m_backlight_bright;
321 bool m_backlight_forcedoff; 320 bool m_backlight_forcedoff;
322}; 321};
323 322
324 323
325namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting 324namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting
326 325
327 326
328int login_main ( int argc, char **argv, pid_t ppid ) 327int login_main ( int argc, char **argv, pid_t ppid )
329{ 328{
330 QWSServer::setDesktopBackground( QImage() ); 329 QWSServer::setDesktopBackground( QImage() );
331 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 330 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
332 331
333 Opie::force_appearance = 0; 332 Opie::force_appearance = 0;
334 333
335 app-> setFont ( QFont ( "Helvetica", 10 )); 334 app-> setFont ( QFont ( "Helvetica", 10 ));
336 app-> setStyle ( new QPEStyle ( )); 335 app-> setStyle ( new QPEStyle ( ));
337 336
338 ODevice::inst ( )-> setSoftSuspend ( true );
339
340 if ( QWSServer::mouseHandler() && 337 if ( QWSServer::mouseHandler() &&
341 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 338 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
342 if ( !QFile::exists ( "/etc/pointercal" )) { 339 if ( !QFile::exists ( "/etc/pointercal" )) {
343 // Make sure calibration widget starts on top. 340 // Make sure calibration widget starts on top.
344 Calibrate *cal = new Calibrate; 341 Calibrate *cal = new Calibrate;
345 cal-> exec ( ); 342 cal-> exec ( );
346 delete cal; 343 delete cal;
347 } 344 }
348 } 345 }
349 346
350 LoginScreenSaver *saver = new LoginScreenSaver; 347 LoginScreenSaver *saver = new LoginScreenSaver;
351 348
352 saver-> setIntervals ( ); 349 saver-> setIntervals ( );
353 QWSServer::setScreenSaver ( saver ); 350 QWSServer::setScreenSaver ( saver );
354 saver-> restore ( ); 351 saver-> restore ( );
355 352
356 353
357 LoginWindowImpl *lw = new LoginWindowImpl ( ); 354 LoginWindowImpl *lw = new LoginWindowImpl ( );
358 app-> setMainWidget ( lw ); 355 app-> setMainWidget ( lw );
359 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 356 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
360 lw-> show ( ); 357 lw-> show ( );
361 358
362 int rc = app-> exec ( ); 359 int rc = app-> exec ( );
363 360
364 ODevice::inst ( )-> setSoftSuspend ( false );
365
366 if ( app-> loginAs ( )) { 361 if ( app-> loginAs ( )) {
367 if ( app-> changeIdentity ( )) { 362 if ( app-> changeIdentity ( )) {
368 app-> login ( ); 363 app-> login ( );
369 364
370 // if login succeeds, it never comes back 365 // if login succeeds, it never comes back
371 366
372 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." )); 367 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." ));
373 rc = 1; 368 rc = 1;
374 } 369 }
375 else { 370 else {
376 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 371 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" ));
377 rc = 2; 372 rc = 2;
378 } 373 }
379 374
380 } 375 }
381 return rc; 376 return rc;
382} 377}
383 378
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index a824392..3d69614 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,517 +1,512 @@
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_beagle.h" 30#include "odevice_beagle.h"
31#include "odevice_ipaq.h" 31#include "odevice_ipaq.h"
32#include "odevice_jornada.h" 32#include "odevice_jornada.h"
33#include "odevice_ramses.h" 33#include "odevice_ramses.h"
34#include "odevice_simpad.h" 34#include "odevice_simpad.h"
35#include "odevice_yopy.h" 35#include "odevice_yopy.h"
36#include "odevice_zaurus.h" 36#include "odevice_zaurus.h"
37#include "odevice_genuineintel.h" 37#include "odevice_genuineintel.h"
38 38
39/* QT */ 39/* QT */
40#include <qapplication.h> 40#include <qapplication.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qwindowsystem_qws.h> 43#include <qwindowsystem_qws.h>
44 44
45/* OPIE */ 45/* OPIE */
46#include <qpe/config.h> 46#include <qpe/config.h>
47#include <qpe/resource.h> 47#include <qpe/resource.h>
48#include <qpe/sound.h> 48#include <qpe/sound.h>
49#include <qpe/qcopenvelope_qws.h> 49#include <qpe/qcopenvelope_qws.h>
50#include <qpe/sound.h> 50#include <qpe/sound.h>
51#include <opie2/okeyfilter.h> 51#include <opie2/okeyfilter.h>
52 52
53/* STD */ 53/* STD */
54#include <fcntl.h> 54#include <fcntl.h>
55#include <math.h> 55#include <math.h>
56#include <stdlib.h> 56#include <stdlib.h>
57#include <signal.h> 57#include <signal.h>
58#include <sys/ioctl.h> 58#include <sys/ioctl.h>
59#include <sys/time.h> 59#include <sys/time.h>
60#include <unistd.h> 60#include <unistd.h>
61#ifndef QT_NO_SOUND 61#ifndef QT_NO_SOUND
62#include <linux/soundcard.h> 62#include <linux/soundcard.h>
63#endif 63#endif
64 64
65namespace Opie { 65namespace Opie {
66namespace Core { 66namespace Core {
67 67
68static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 68static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
69 69
70 70
71/* STATIC and common implementation */ 71/* STATIC and common implementation */
72/* EXPORT */ ODistribution distributions[] = { 72/* EXPORT */ ODistribution distributions[] = {
73 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 73 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
74 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 74 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
75 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 75 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
76 { System_Unknown, "Linux", "/etc/issue" }, 76 { System_Unknown, "Linux", "/etc/issue" },
77}; 77};
78 78
79 79
80/* EXPORT */ bool isQWS(){ 80/* EXPORT */ bool isQWS(){
81 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 81 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
82} 82}
83 83
84/* EXPORT */ QCString makeChannel ( const char *str ){ 84/* EXPORT */ QCString makeChannel ( const char *str ){
85 if ( str && !::strchr ( str, '/' )) 85 if ( str && !::strchr ( str, '/' ))
86 return QCString ( "QPE/Application/" ) + str; 86 return QCString ( "QPE/Application/" ) + str;
87 else 87 else
88 return str; 88 return str;
89} 89}
90 90
91 91
92 92
93/* Now the default implementation of ODevice */ 93/* Now the default implementation of ODevice */
94 94
95struct default_button default_buttons [] = { 95struct default_button default_buttons [] = {
96 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 96 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
97 "devicebuttons/z_calendar", 97 "devicebuttons/z_calendar",
98 "datebook", "nextView()", 98 "datebook", "nextView()",
99 "today", "raise()" }, 99 "today", "raise()" },
100 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 100 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
101 "devicebuttons/z_contact", 101 "devicebuttons/z_contact",
102 "addressbook", "raise()", 102 "addressbook", "raise()",
103 "addressbook", "beamBusinessCard()" }, 103 "addressbook", "beamBusinessCard()" },
104 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 104 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
105 "devicebuttons/z_home", 105 "devicebuttons/z_home",
106 "QPE/Launcher", "home()", 106 "QPE/Launcher", "home()",
107 "buttonsettings", "raise()" }, 107 "buttonsettings", "raise()" },
108 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 108 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
109 "devicebuttons/z_menu", 109 "devicebuttons/z_menu",
110 "QPE/TaskBar", "toggleMenu()", 110 "QPE/TaskBar", "toggleMenu()",
111 "QPE/TaskBar", "toggleStartMenu()" }, 111 "QPE/TaskBar", "toggleStartMenu()" },
112 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 112 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
113 "devicebuttons/z_mail", 113 "devicebuttons/z_mail",
114 "opiemail", "raise()", 114 "opiemail", "raise()",
115 "opiemail", "newMail()" }, 115 "opiemail", "newMail()" },
116}; 116};
117 117
118ODevice *ODevice::inst() 118ODevice *ODevice::inst()
119{ 119{
120 static ODevice *dev = 0; 120 static ODevice *dev = 0;
121 121
122 // rewrite this to only use /proc/cpuinfo or so 122 // rewrite this to only use /proc/cpuinfo or so
123 QString cpu_info; 123 QString cpu_info;
124 124
125 if ( !dev ) 125 if ( !dev )
126 { 126 {
127 QFile f( PATH_PROC_CPUINFO ); 127 QFile f( PATH_PROC_CPUINFO );
128 if ( f.open( IO_ReadOnly ) ) 128 if ( f.open( IO_ReadOnly ) )
129 { 129 {
130 QTextStream s( &f ); 130 QTextStream s( &f );
131 while ( !s.atEnd() ) 131 while ( !s.atEnd() )
132 { 132 {
133 QString line; 133 QString line;
134 line = s.readLine(); 134 line = s.readLine();
135 if ( line.startsWith( "Hardware" ) ) 135 if ( line.startsWith( "Hardware" ) )
136 { 136 {
137 qDebug( "ODevice() - found '%s'", (const char*) line ); 137 qDebug( "ODevice() - found '%s'", (const char*) line );
138 cpu_info = line; 138 cpu_info = line;
139 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 139 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
140 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 140 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
141 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 141 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
142 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 142 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
143 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 143 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
144 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 144 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
145 else qWarning( "ODevice() - unknown hardware - using default." ); 145 else qWarning( "ODevice() - unknown hardware - using default." );
146 break; 146 break;
147 } else if ( line.startsWith( "vendor_id" ) ) { 147 } else if ( line.startsWith( "vendor_id" ) ) {
148 qDebug( "ODevice() - found '%s'", (const char*) line ); 148 qDebug( "ODevice() - found '%s'", (const char*) line );
149 cpu_info = line; 149 cpu_info = line;
150 if( line.contains( "genuineintel", false ) ) { 150 if( line.contains( "genuineintel", false ) ) {
151 dev = new Internal::GenuineIntel(); 151 dev = new Internal::GenuineIntel();
152 break; 152 break;
153 } 153 }
154 } 154 }
155 } 155 }
156 } 156 }
157 else 157 else
158 { 158 {
159 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 159 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
160 } 160 }
161 if ( !dev ) dev = new ODevice(); 161 if ( !dev ) dev = new ODevice();
162 dev->init(cpu_info); 162 dev->init(cpu_info);
163 } 163 }
164 return dev; 164 return dev;
165} 165}
166 166
167ODevice::ODevice() 167ODevice::ODevice()
168{ 168{
169 d = new ODeviceData; 169 d = new ODeviceData;
170 170
171 d->m_modelstr = "Unknown"; 171 d->m_modelstr = "Unknown";
172 d->m_model = Model_Unknown; 172 d->m_model = Model_Unknown;
173 d->m_vendorstr = "Unknown"; 173 d->m_vendorstr = "Unknown";
174 d->m_vendor = Vendor_Unknown; 174 d->m_vendor = Vendor_Unknown;
175 d->m_systemstr = "Unknown"; 175 d->m_systemstr = "Unknown";
176 d->m_system = System_Unknown; 176 d->m_system = System_Unknown;
177 d->m_sysverstr = "0.0"; 177 d->m_sysverstr = "0.0";
178 d->m_rotation = Rot0; 178 d->m_rotation = Rot0;
179 d->m_direction = CW; 179 d->m_direction = CW;
180 180
181 d->m_holdtime = 1000; // 1000ms 181 d->m_holdtime = 1000; // 1000ms
182 d->m_buttons = 0; 182 d->m_buttons = 0;
183 d->m_cpu_frequencies = new QStrList; 183 d->m_cpu_frequencies = new QStrList;
184 184
185 185
186 /* mixer */ 186 /* mixer */
187 d->m_sound = d->m_vol = d->m_mixer = -1; 187 d->m_sound = d->m_vol = d->m_mixer = -1;
188 188
189 /* System QCopChannel created */ 189 /* System QCopChannel created */
190 d->m_initializedButtonQcop = false; 190 d->m_initializedButtonQcop = false;
191 191
192 // New distribution detection code first checks for legacy distributions, 192 // New distribution detection code first checks for legacy distributions,
193 // identified by /etc/familiar-version or /etc/oz_version. 193 // identified by /etc/familiar-version or /etc/oz_version.
194 // Then check for OpenEmbedded and lastly, read /etc/issue 194 // Then check for OpenEmbedded and lastly, read /etc/issue
195 195
196 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 196 for ( unsigned int i = 0; i < sizeof distributions; ++i )
197 { 197 {
198 if ( QFile::exists( distributions[i].sysvfile ) ) 198 if ( QFile::exists( distributions[i].sysvfile ) )
199 { 199 {
200 d->m_systemstr = distributions[i].sysstr; 200 d->m_systemstr = distributions[i].sysstr;
201 d->m_system = distributions[i].system; 201 d->m_system = distributions[i].system;
202 d->m_sysverstr = "<Unknown>"; 202 d->m_sysverstr = "<Unknown>";
203 QFile f( distributions[i].sysvfile ); 203 QFile f( distributions[i].sysvfile );
204 if ( f.open( IO_ReadOnly ) ) 204 if ( f.open( IO_ReadOnly ) )
205 { 205 {
206 QTextStream ts( &f ); 206 QTextStream ts( &f );
207 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 207 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
208 } 208 }
209 break; 209 break;
210 } 210 }
211 } 211 }
212} 212}
213 213
214void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 214void ODevice::systemMessage( const QCString &msg, const QByteArray & )
215{ 215{
216 if ( msg == "deviceButtonMappingChanged()" ) { 216 if ( msg == "deviceButtonMappingChanged()" ) {
217 reloadButtonMapping(); 217 reloadButtonMapping();
218 } 218 }
219} 219}
220 220
221void ODevice::init(const QString&) 221void ODevice::init(const QString&)
222{ 222{
223} 223}
224 224
225/** 225/**
226* This method initialises the button mapping 226* This method initialises the button mapping
227*/ 227*/
228void ODevice::initButtons() 228void ODevice::initButtons()
229{ 229{
230 if ( d->m_buttons ) 230 if ( d->m_buttons )
231 return; 231 return;
232 232
233 qDebug ( "init Buttons" ); 233 qDebug ( "init Buttons" );
234 d->m_buttons = new QValueList <ODeviceButton>; 234 d->m_buttons = new QValueList <ODeviceButton>;
235 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 235 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
236 default_button *db = default_buttons + i; 236 default_button *db = default_buttons + i;
237 ODeviceButton b; 237 ODeviceButton b;
238 b. setKeycode ( db->code ); 238 b. setKeycode ( db->code );
239 b. setUserText ( QObject::tr ( "Button", db->utext )); 239 b. setUserText ( QObject::tr ( "Button", db->utext ));
240 b. setPixmap ( Resource::loadPixmap ( db->pix )); 240 b. setPixmap ( Resource::loadPixmap ( db->pix ));
241 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 241 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
242 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 242 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
243 d->m_buttons->append ( b ); 243 d->m_buttons->append ( b );
244 } 244 }
245 245
246 reloadButtonMapping(); 246 reloadButtonMapping();
247} 247}
248 248
249ODevice::~ODevice() 249ODevice::~ODevice()
250{ 250{
251// we leak m_devicebuttons and m_cpu_frequency 251// we leak m_devicebuttons and m_cpu_frequency
252// but it's a singleton and it is not so importantant 252// but it's a singleton and it is not so importantant
253// -zecke 253// -zecke
254 delete d; 254 delete d;
255} 255}
256 256
257bool ODevice::setSoftSuspend ( bool /*soft*/ )
258{
259 return false;
260}
261
262//#include <linux/apm_bios.h> 257//#include <linux/apm_bios.h>
263 258
264#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 259#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
265 260
266/** 261/**
267* This method will try to suspend the device 262* This method will try to suspend the device
268* It only works if the user is the QWS Server and the apm application 263* It only works if the user is the QWS Server and the apm application
269* is installed. 264* is installed.
270* It tries to suspend and then waits some time cause some distributions 265* It tries to suspend and then waits some time cause some distributions
271* do have asynchronus apm implementations. 266* do have asynchronus apm implementations.
272* This method will either fail and return false or it'll suspend the 267* This method will either fail and return false or it'll suspend the
273* device and return once the device got woken up 268* device and return once the device got woken up
274* 269*
275* @return if the device got suspended 270* @return if the device got suspended
276*/ 271*/
277bool ODevice::suspend() 272bool ODevice::suspend()
278{ 273{
279 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 274 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
280 return false; 275 return false;
281 276
282 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 277 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
283 return false; 278 return false;
284 279
285 bool res = false; 280 bool res = false;
286 ODevice::sendSuspendmsg(); 281 ODevice::sendSuspendmsg();
287 282
288 struct timeval tvs, tvn; 283 struct timeval tvs, tvn;
289 ::gettimeofday ( &tvs, 0 ); 284 ::gettimeofday ( &tvs, 0 );
290 285
291 ::sync(); // flush fs caches 286 ::sync(); // flush fs caches
292 res = ( ::system ( "apm --suspend" ) == 0 ); 287 res = ( ::system ( "apm --suspend" ) == 0 );
293 288
294 // This is needed because the iPAQ apm implementation is asynchronous and we 289 // This is needed because the iPAQ apm implementation is asynchronous and we
295 // can not be sure when exactly the device is really suspended 290 // can not be sure when exactly the device is really suspended
296 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 291 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
297 292
298 if ( res ) { 293 if ( res ) {
299 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 294 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
300 ::usleep ( 200 * 1000 ); 295 ::usleep ( 200 * 1000 );
301 ::gettimeofday ( &tvn, 0 ); 296 ::gettimeofday ( &tvn, 0 );
302 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 297 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
303 } 298 }
304 299
305 return res; 300 return res;
306} 301}
307 302
308//#include <linux/fb.h> better not rely on kernel headers in userspace ... 303//#include <linux/fb.h> better not rely on kernel headers in userspace ...
309 304
310#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 305#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
311 306
312/* VESA Blanking Levels */ 307/* VESA Blanking Levels */
313#define VESA_NO_BLANKING 0 308#define VESA_NO_BLANKING 0
314#define VESA_VSYNC_SUSPEND 1 309#define VESA_VSYNC_SUSPEND 1
315#define VESA_HSYNC_SUSPEND 2 310#define VESA_HSYNC_SUSPEND 2
316#define VESA_POWERDOWN 3 311#define VESA_POWERDOWN 3
317 312
318/** 313/**
319* This sets the display on or off 314* This sets the display on or off
320*/ 315*/
321bool ODevice::setDisplayStatus ( bool on ) 316bool ODevice::setDisplayStatus ( bool on )
322{ 317{
323 qDebug("ODevice::setDisplayStatus(%d)", on); 318 qDebug("ODevice::setDisplayStatus(%d)", on);
324 319
325 if ( d->m_model == Model_Unknown ) 320 if ( d->m_model == Model_Unknown )
326 return false; 321 return false;
327 322
328 bool res = false; 323 bool res = false;
329 int fd; 324 int fd;
330 325
331#ifdef QT_QWS_DEVFS 326#ifdef QT_QWS_DEVFS
332 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { 327 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
333#else 328#else
334 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 329 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
335#endif 330#endif
336 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 331 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
337 ::close ( fd ); 332 ::close ( fd );
338 } 333 }
339 return res; 334 return res;
340} 335}
341 336
342/** 337/**
343* This sets the display brightness 338* This sets the display brightness
344* 339*
345* @param b The brightness to be set on a scale from 0 to 255 340* @param b The brightness to be set on a scale from 0 to 255
346* @return success or failure 341* @return success or failure
347*/ 342*/
348bool ODevice::setDisplayBrightness ( int b) 343bool ODevice::setDisplayBrightness ( int b)
349{ 344{
350 Q_UNUSED( b ) 345 Q_UNUSED( b )
351 return false; 346 return false;
352} 347}
353 348
354/** 349/**
355 * 350 *
356 * @return Returns the number of steppings on the brightness slider 351 * @return Returns the number of steppings on the brightness slider
357 * in the Light-'n-Power settings. Values smaller zero and bigger 352 * in the Light-'n-Power settings. Values smaller zero and bigger
358 * than 255 do not make sense. 353 * than 255 do not make sense.
359 * 354 *
360 * \sa QSlider::setLineStep 355 * \sa QSlider::setLineStep
361 * \sa QSlider::setPageStep 356 * \sa QSlider::setPageStep
362 */ 357 */
363int ODevice::displayBrightnessResolution() const 358int ODevice::displayBrightnessResolution() const
364{ 359{
365 return 16; 360 return 16;
366} 361}
367 362
368/** 363/**
369* This sets the display contrast 364* This sets the display contrast
370* @param p The contrast to be set on a scale from 0 to 255 365* @param p The contrast to be set on a scale from 0 to 255
371* @return success or failure 366* @return success or failure
372*/ 367*/
373bool ODevice::setDisplayContrast ( int p) 368bool ODevice::setDisplayContrast ( int p)
374{ 369{
375 Q_UNUSED( p ) 370 Q_UNUSED( p )
376 return false; 371 return false;
377} 372}
378 373
379/** 374/**
380* @return return the max value for the brightness settings slider 375* @return return the max value for the brightness settings slider
381* or 0 if the device doesn't support setting of a contrast 376* or 0 if the device doesn't support setting of a contrast
382*/ 377*/
383int ODevice::displayContrastResolution() const 378int ODevice::displayContrastResolution() const
384{ 379{
385 return 0; 380 return 0;
386} 381}
387 382
388/** 383/**
389* This returns the vendor as string 384* This returns the vendor as string
390* @return Vendor as QString 385* @return Vendor as QString
391*/ 386*/
392QString ODevice::vendorString() const 387QString ODevice::vendorString() const
393{ 388{
394 return d->m_vendorstr; 389 return d->m_vendorstr;
395} 390}
396 391
397/** 392/**
398* This returns the vendor as one of the values of OVendor 393* This returns the vendor as one of the values of OVendor
399* @return OVendor 394* @return OVendor
400*/ 395*/
401OVendor ODevice::vendor() const 396OVendor ODevice::vendor() const
402{ 397{
403 return d->m_vendor; 398 return d->m_vendor;
404} 399}
405 400
406/** 401/**
407* This returns the model as a string 402* This returns the model as a string
408* @return A string representing the model 403* @return A string representing the model
409*/ 404*/
410QString ODevice::modelString() const 405QString ODevice::modelString() const
411{ 406{
412 return d->m_modelstr; 407 return d->m_modelstr;
413} 408}
414 409
415/** 410/**
416* This does return the OModel used 411* This does return the OModel used
417*/ 412*/
418OModel ODevice::model() const 413OModel ODevice::model() const
419{ 414{
420 return d->m_model; 415 return d->m_model;
421} 416}
422 417
423/** 418/**
424* This does return the systen name 419* This does return the systen name
425*/ 420*/
426QString ODevice::systemString() const 421QString ODevice::systemString() const
427{ 422{
428 return d->m_systemstr; 423 return d->m_systemstr;
429} 424}
430 425
431/** 426/**
432* Return System as OSystem value 427* Return System as OSystem value
433*/ 428*/
434OSystem ODevice::system() const 429OSystem ODevice::system() const
435{ 430{
436 return d->m_system; 431 return d->m_system;
437} 432}
438 433
439/** 434/**
440* @return the version string of the base system 435* @return the version string of the base system
441*/ 436*/
442QString ODevice::systemVersionString() const 437QString ODevice::systemVersionString() const
443{ 438{
444 return d->m_sysverstr; 439 return d->m_sysverstr;
445} 440}
446 441
447/** 442/**
448* @return the current Transformation 443* @return the current Transformation
449*/ 444*/
450Transformation ODevice::rotation() const 445Transformation ODevice::rotation() const
451{ 446{
452 return d->m_rotation; 447 return d->m_rotation;
453} 448}
454 449
455/** 450/**
456* @return the current rotation direction 451* @return the current rotation direction
457*/ 452*/
458ODirection ODevice::direction() const 453ODirection ODevice::direction() const
459{ 454{
460 return d->m_direction; 455 return d->m_direction;
461} 456}
462 457
463/** 458/**
464* This plays an alarm sound 459* This plays an alarm sound
465*/ 460*/
466void ODevice::playAlarmSound() 461void ODevice::playAlarmSound()
467{ 462{
468#ifndef QT_NO_SOUND 463#ifndef QT_NO_SOUND
469 static Sound snd ( "alarm" ); 464 static Sound snd ( "alarm" );
470 465
471 if ( snd. isFinished()) 466 if ( snd. isFinished())
472 snd. play(); 467 snd. play();
473#endif 468#endif
474} 469}
475 470
476/** 471/**
477* This plays a key sound 472* This plays a key sound
478*/ 473*/
479void ODevice::playKeySound() 474void ODevice::playKeySound()
480{ 475{
481#ifndef QT_NO_SOUND 476#ifndef QT_NO_SOUND
482 static Sound snd ( "keysound" ); 477 static Sound snd ( "keysound" );
483 478
484 if ( snd. isFinished()) 479 if ( snd. isFinished())
485 snd. play(); 480 snd. play();
486#endif 481#endif
487} 482}
488 483
489/** 484/**
490* This plays a touch sound 485* This plays a touch sound
491*/ 486*/
492void ODevice::playTouchSound() 487void ODevice::playTouchSound()
493{ 488{
494#ifndef QT_NO_SOUND 489#ifndef QT_NO_SOUND
495 static Sound snd ( "touchsound" ); 490 static Sound snd ( "touchsound" );
496 491
497 if ( snd. isFinished()) 492 if ( snd. isFinished())
498 snd. play(); 493 snd. play();
499#endif 494#endif
500} 495}
501 496
502/** 497/**
503* This method will return a list of leds 498* This method will return a list of leds
504* available on this device 499* available on this device
505* @return a list of LEDs. 500* @return a list of LEDs.
506*/ 501*/
507QValueList <OLed> ODevice::ledList() const 502QValueList <OLed> ODevice::ledList() const
508{ 503{
509 return QValueList <OLed>(); 504 return QValueList <OLed>();
510} 505}
511 506
512/** 507/**
513* This does return the state of the LEDs 508* This does return the state of the LEDs
514*/ 509*/
515QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 510QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
516{ 511{
517 return QValueList <OLedState>(); 512 return QValueList <OLedState>();
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index bbc32fa..96a41fc 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -2,379 +2,377 @@
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 41
42 42
43#include <qstrlist.h> 43#include <qstrlist.h>
44#include <qwindowsystem_qws.h> 44#include <qwindowsystem_qws.h>
45 45
46 46
47class Sound; 47class Sound;
48 48
49namespace Opie{ 49namespace Opie{
50namespace Core{ 50namespace Core{
51 51
52class ODeviceData; 52class ODeviceData;
53/** 53/**
54 * The available devices 54 * The available devices
55 */ 55 */
56enum OModel { 56enum OModel {
57 Model_Unknown, // = 0 57 Model_Unknown, // = 0
58 58
59 Model_Series_Mask = 0xff000000, 59 Model_Series_Mask = 0xff000000,
60 60
61 Model_iPAQ = ( 1 << 24 ), 61 Model_iPAQ = ( 1 << 24 ),
62 62
63 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 63 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), 69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
71 71
72 Model_Jornada = ( 6 << 24 ), 72 Model_Jornada = ( 6 << 24 ),
73 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 73 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
74 74
75 Model_Zaurus = ( 2 << 24 ), 75 Model_Zaurus = ( 2 << 24 ),
76 76
77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), 82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ),
83 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ), 83 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ),
84 84
85 Model_SIMpad = ( 3 << 24 ), 85 Model_SIMpad = ( 3 << 24 ),
86 86
87 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 87 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
88 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 88 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
89 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 89 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
90 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 90 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
91 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 91 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
92 92
93 Model_Ramses = ( 4 << 24 ), 93 Model_Ramses = ( 4 << 24 ),
94 94
95 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 95 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
96 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 96 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
97 Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), 97 Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ),
98 98
99 Model_Yopy = ( 5 << 24 ), 99 Model_Yopy = ( 5 << 24 ),
100 100
101 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 101 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
102 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 102 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
103 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 103 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
104 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 104 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
105 105
106 Model_Beagle = ( 6 << 24 ), 106 Model_Beagle = ( 6 << 24 ),
107 107
108 Model_Beagle_All = ( Model_Beagle | 0xffffff ), 108 Model_Beagle_All = ( Model_Beagle | 0xffffff ),
109 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), 109 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ),
110 110
111 Model_GenuineIntel = ( 7 << 24 ) 111 Model_GenuineIntel = ( 7 << 24 )
112 112
113}; 113};
114 114
115/** 115/**
116 * The vendor of the device 116 * The vendor of the device
117 */ 117 */
118enum OVendor { 118enum OVendor {
119 Vendor_Unknown, 119 Vendor_Unknown,
120 120
121 Vendor_HP, 121 Vendor_HP,
122 Vendor_Sharp, 122 Vendor_Sharp,
123 Vendor_SIEMENS, 123 Vendor_SIEMENS,
124 Vendor_MundN, 124 Vendor_MundN,
125 Vendor_GMate, 125 Vendor_GMate,
126 Vendor_MasterIA, 126 Vendor_MasterIA,
127 Vendor_GenuineIntel 127 Vendor_GenuineIntel
128}; 128};
129 129
130/** 130/**
131 * The System used 131 * The System used
132 */ 132 */
133enum OSystem { 133enum OSystem {
134 System_Unknown, 134 System_Unknown,
135 135
136 System_Familiar, 136 System_Familiar,
137 System_Zaurus, 137 System_Zaurus,
138 System_OpenZaurus, 138 System_OpenZaurus,
139 System_Linupy, 139 System_Linupy,
140 System_OpenEmbedded, 140 System_OpenEmbedded,
141 System_PC 141 System_PC
142}; 142};
143 143
144typedef struct { 144typedef struct {
145 OSystem system; 145 OSystem system;
146 char* sysstr; 146 char* sysstr;
147 char* sysvfile; 147 char* sysvfile;
148} ODistribution; 148} ODistribution;
149 149
150extern ODistribution distributions[]; 150extern ODistribution distributions[];
151 151
152 152
153enum OLedState { 153enum OLedState {
154 Led_Off, 154 Led_Off,
155 Led_On, 155 Led_On,
156 Led_BlinkSlow, 156 Led_BlinkSlow,
157 Led_BlinkFast 157 Led_BlinkFast
158}; 158};
159 159
160enum OLed { 160enum OLed {
161 Led_Mail, 161 Led_Mail,
162 Led_Power, 162 Led_Power,
163 Led_BlueTooth 163 Led_BlueTooth
164}; 164};
165 165
166enum OHardKey { 166enum OHardKey {
167 HardKey_Datebook = Qt::Key_F9, 167 HardKey_Datebook = Qt::Key_F9,
168 HardKey_Contacts = Qt::Key_F10, 168 HardKey_Contacts = Qt::Key_F10,
169 HardKey_Menu = Qt::Key_F11, 169 HardKey_Menu = Qt::Key_F11,
170 HardKey_Home = Qt::Key_F12, 170 HardKey_Home = Qt::Key_F12,
171 HardKey_Mail = Qt::Key_F13, 171 HardKey_Mail = Qt::Key_F13,
172 HardKey_Record = Qt::Key_F24, 172 HardKey_Record = Qt::Key_F24,
173 HardKey_Suspend = Qt::Key_F34, 173 HardKey_Suspend = Qt::Key_F34,
174 HardKey_Backlight = Qt::Key_F35, 174 HardKey_Backlight = Qt::Key_F35,
175 HardKey_Action = Qt::Key_F10, 175 HardKey_Action = Qt::Key_F10,
176 HardKey_OK = Qt::Key_F11, 176 HardKey_OK = Qt::Key_F11,
177 HardKey_End = Qt::Key_F12, 177 HardKey_End = Qt::Key_F12,
178}; 178};
179 179
180enum ODirection { 180enum ODirection {
181 CW = 0, 181 CW = 0,
182 CCW = 1, 182 CCW = 1,
183 Flip = 2, 183 Flip = 2,
184}; 184};
185 185
186enum OHingeStatus { 186enum OHingeStatus {
187 CASE_CLOSED = 3, 187 CASE_CLOSED = 3,
188 CASE_PORTRAIT = 2, 188 CASE_PORTRAIT = 2,
189 CASE_LANDSCAPE = 0, 189 CASE_LANDSCAPE = 0,
190 CASE_UNKNOWN = 1, 190 CASE_UNKNOWN = 1,
191}; 191};
192 192
193/* default button for qvfb or such 193/* default button for qvfb or such
194 * see odevice.cpp for details. 194 * see odevice.cpp for details.
195 * hint: manage a user defined button for qvfb? 195 * hint: manage a user defined button for qvfb?
196 * alwin 196 * alwin
197 */ 197 */
198struct default_button { 198struct default_button {
199 Qt::Key code; 199 Qt::Key code;
200 char *utext; 200 char *utext;
201 char *pix; 201 char *pix;
202 char *fpressedservice; 202 char *fpressedservice;
203 char *fpressedaction; 203 char *fpressedaction;
204 char *fheldservice; 204 char *fheldservice;
205 char *fheldaction; 205 char *fheldaction;
206}; 206};
207 207
208/** 208/**
209 * A singleton which gives informations about device specefic option 209 * A singleton which gives informations about device specefic option
210 * like the Hardware used, LEDs, the Base Distribution and 210 * like the Hardware used, LEDs, the Base Distribution and
211 * hardware key mappings. 211 * hardware key mappings.
212 * 212 *
213 * @short A small class for device specefic options 213 * @short A small class for device specefic options
214 * @see QObject 214 * @see QObject
215 * @author Robert Griebl 215 * @author Robert Griebl
216 * @version 1.0 216 * @version 1.0
217 */ 217 */
218class ODevice : public QObject 218class ODevice : public QObject
219{ 219{
220 Q_OBJECT 220 Q_OBJECT
221 221
222private: 222private:
223 /* disable copy */ 223 /* disable copy */
224 ODevice ( const ODevice & ); 224 ODevice ( const ODevice & );
225 225
226protected: 226protected:
227 ODevice(); 227 ODevice();
228 virtual void init(const QString&); 228 virtual void init(const QString&);
229 virtual void initButtons(); 229 virtual void initButtons();
230 static void sendSuspendmsg(); 230 static void sendSuspendmsg();
231 231
232 ODeviceData *d; 232 ODeviceData *d;
233 233
234public: 234public:
235 // sandman do we want to allow destructions? -zecke? 235 // sandman do we want to allow destructions? -zecke?
236 virtual ~ODevice(); 236 virtual ~ODevice();
237 237
238 static ODevice *inst(); 238 static ODevice *inst();
239 239
240 // information 240 // information
241 241
242 QString modelString() const; 242 QString modelString() const;
243 OModel model() const; 243 OModel model() const;
244 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 244 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
245 245
246 QString vendorString() const; 246 QString vendorString() const;
247 OVendor vendor() const; 247 OVendor vendor() const;
248 248
249 QString systemString() const; 249 QString systemString() const;
250 OSystem system() const; 250 OSystem system() const;
251 251
252 QString systemVersionString() const; 252 QString systemVersionString() const;
253 253
254 virtual Transformation rotation() const; 254 virtual Transformation rotation() const;
255 virtual ODirection direction() const; 255 virtual ODirection direction() const;
256 256
257 // system 257 // system
258
259 virtual bool setSoftSuspend ( bool on );
260 virtual bool suspend(); 258 virtual bool suspend();
261 259
262 virtual bool setDisplayStatus ( bool on ); 260 virtual bool setDisplayStatus ( bool on );
263 virtual bool setDisplayBrightness ( int brightness ); 261 virtual bool setDisplayBrightness ( int brightness );
264 virtual int displayBrightnessResolution() const; 262 virtual int displayBrightnessResolution() const;
265 virtual bool setDisplayContrast ( int contrast ); 263 virtual bool setDisplayContrast ( int contrast );
266 virtual int displayContrastResolution() const; 264 virtual int displayContrastResolution() const;
267 265
268 // don't add new virtual methods, use this: 266 // don't add new virtual methods, use this:
269 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 267 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
270 // and in your subclass do overwrite 268 // and in your subclass do overwrite
271 // protected virtual int virtual_hook(int, void *) 269 // protected virtual int virtual_hook(int, void *)
272 // which is defined below 270 // which is defined below
273 271
274 // input / output 272 // input / output
275 virtual void playAlarmSound(); 273 virtual void playAlarmSound();
276 virtual void playKeySound(); 274 virtual void playKeySound();
277 virtual void playTouchSound(); 275 virtual void playTouchSound();
278 276
279 virtual QValueList <OLed> ledList() const; 277 virtual QValueList <OLed> ledList() const;
280 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 278 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
281 virtual OLedState ledState ( OLed led ) const; 279 virtual OLedState ledState ( OLed led ) const;
282 virtual bool setLedState ( OLed led, OLedState st ); 280 virtual bool setLedState ( OLed led, OLedState st );
283 281
284 virtual bool hasLightSensor() const; 282 virtual bool hasLightSensor() const;
285 virtual int readLightSensor(); 283 virtual int readLightSensor();
286 virtual int lightSensorResolution() const; 284 virtual int lightSensorResolution() const;
287 285
288 virtual bool hasHingeSensor() const; 286 virtual bool hasHingeSensor() const;
289 virtual OHingeStatus readHingeSensor(); 287 virtual OHingeStatus readHingeSensor();
290 288
291 const QStrList &allowedCpuFrequencies() const; 289 const QStrList &allowedCpuFrequencies() const;
292 bool setCurrentCpuFrequency(uint index); 290 bool setCurrentCpuFrequency(uint index);
293 291
294 /** 292 /**
295 * Returns the available buttons on this device. The number and location 293 * Returns the available buttons on this device. The number and location
296 * of buttons will vary depending on the device. Button numbers will be assigned 294 * of buttons will vary depending on the device. Button numbers will be assigned
297 * by the device manufacturer and will be from most preferred button to least preffered 295 * by the device manufacturer and will be from most preferred button to least preffered
298 * button. Note that this list only contains "user mappable" buttons. 296 * button. Note that this list only contains "user mappable" buttons.
299 * 297 *
300 * @todo Make method const and take care of calling initButtons or make that const too 298 * @todo Make method const and take care of calling initButtons or make that const too
301 * 299 *
302 */ 300 */
303 const QValueList<ODeviceButton> &buttons(); 301 const QValueList<ODeviceButton> &buttons();
304 302
305 /** 303 /**
306 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 304 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
307 * returns 0L 305 * returns 0L
308 */ 306 */
309 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 307 const ODeviceButton *buttonForKeycode ( ushort keyCode );
310 308
311 /** 309 /**
312 * Reassigns the pressed action for \a button. To return to the factory 310 * Reassigns the pressed action for \a button. To return to the factory
313 * default pass an empty string as \a qcopMessage. 311 * default pass an empty string as \a qcopMessage.
314 */ 312 */
315 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 313 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
316 314
317 /** 315 /**
318 * Reassigns the held action for \a button. To return to the factory 316 * Reassigns the held action for \a button. To return to the factory
319 * default pass an empty string as \a qcopMessage. 317 * default pass an empty string as \a qcopMessage.
320 */ 318 */
321 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 319 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
322 320
323 /** 321 /**
324 * How long (in ms) you have to press a button for a "hold" action 322 * How long (in ms) you have to press a button for a "hold" action
325 */ 323 */
326 uint buttonHoldTime() const; 324 uint buttonHoldTime() const;
327 325
328signals: 326signals:
329 void buttonMappingChanged(); 327 void buttonMappingChanged();
330 328
331private slots: 329private slots:
332 void systemMessage ( const QCString &, const QByteArray & ); 330 void systemMessage ( const QCString &, const QByteArray & );
333 void playingStopped(); 331 void playingStopped();
334 332
335protected: 333protected:
336 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 334 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
337 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 335 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
338 void reloadButtonMapping(); 336 void reloadButtonMapping();
339 void changeMixerForAlarm( int mixer, const char* file, Sound *snd); 337 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
340 338
341 /* ugly virtual hook */ 339 /* ugly virtual hook */
342 virtual void virtual_hook( int id, void* data ); 340 virtual void virtual_hook( int id, void* data );
343}; 341};
344 342
345class ODeviceData { 343class ODeviceData {
346 344
347 public: 345 public:
348 QString m_vendorstr; 346 QString m_vendorstr;
349 OVendor m_vendor; 347 OVendor m_vendor;
350 348
351 QString m_modelstr; 349 QString m_modelstr;
352 OModel m_model; 350 OModel m_model;
353 351
354 QString m_systemstr; 352 QString m_systemstr;
355 OSystem m_system; 353 OSystem m_system;
356 354
357 QString m_sysverstr; 355 QString m_sysverstr;
358 356
359 Transformation m_rotation; 357 Transformation m_rotation;
360 ODirection m_direction; 358 ODirection m_direction;
361 359
362 QValueList <ODeviceButton> *m_buttons; 360 QValueList <ODeviceButton> *m_buttons;
363 uint m_holdtime; 361 uint m_holdtime;
364 QStrList *m_cpu_frequencies; 362 QStrList *m_cpu_frequencies;
365 bool m_initializedButtonQcop : 1; 363 bool m_initializedButtonQcop : 1;
366 364
367 /* values for changeMixerForAlarm */ 365 /* values for changeMixerForAlarm */
368 int m_sound, m_vol, m_mixer; 366 int m_sound, m_vol, m_mixer;
369}; 367};
370 368
371extern bool isQWS(); 369extern bool isQWS();
372extern QCString makeChannel ( const char *str ); 370extern QCString makeChannel ( const char *str );
373} 371}
374} 372}
375 373
376 374
377 375
378 376
379#endif 377#endif
380 378
diff --git a/libopie2/opiecore/device/odevice_genuineintel.cpp b/libopie2/opiecore/device/odevice_genuineintel.cpp
index 61ba052..1584249 100644
--- a/libopie2/opiecore/device/odevice_genuineintel.cpp
+++ b/libopie2/opiecore/device/odevice_genuineintel.cpp
@@ -1,193 +1,187 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002,2003,2004 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_genuineintel.h" 30#include "odevice_genuineintel.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#ifndef QT_NO_SOUND 45#ifndef QT_NO_SOUND
46#include <linux/soundcard.h> 46#include <linux/soundcard.h>
47#endif 47#endif
48 48
49using namespace Opie::Core; 49using namespace Opie::Core;
50using namespace Opie::Core::Internal; 50using namespace Opie::Core::Internal;
51 51
52struct gi_button genuineintel_buttons [] = { 52struct gi_button genuineintel_buttons [] = {
53 { 53 {
54 Qt::Key_F1, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 54 Qt::Key_F1, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
55 "devicebuttons/ipaq_calendar", 55 "devicebuttons/ipaq_calendar",
56 "datebook", "nextView()", 56 "datebook", "nextView()",
57 "today", "raise()" }, 57 "today", "raise()" },
58 { 58 {
59 Qt::Key_F2, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 59 Qt::Key_F2, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
60 "devicebuttons/ipaq_contact", 60 "devicebuttons/ipaq_contact",
61 "addressbook", "raise()", 61 "addressbook", "raise()",
62 "addressbook", "beamBusinessCard()" }, 62 "addressbook", "beamBusinessCard()" },
63 { 63 {
64 Qt::Key_F3, QT_TRANSLATE_NOOP("Button", "Menu Button"), 64 Qt::Key_F3, QT_TRANSLATE_NOOP("Button", "Menu Button"),
65 "devicebuttons/ipaq_menu", 65 "devicebuttons/ipaq_menu",
66 "QPE/TaskBar", "toggleMenu()", 66 "QPE/TaskBar", "toggleMenu()",
67 "QPE/TaskBar", "toggleStartMenu()" }, 67 "QPE/TaskBar", "toggleStartMenu()" },
68 { 68 {
69 Qt::Key_F4, QT_TRANSLATE_NOOP("Button", "Mail Button"), 69 Qt::Key_F4, QT_TRANSLATE_NOOP("Button", "Mail Button"),
70 "devicebuttons/ipaq_mail", 70 "devicebuttons/ipaq_mail",
71 "opiemail", "raise()", 71 "opiemail", "raise()",
72 "opiemail", "newMail()" }, 72 "opiemail", "newMail()" },
73 { 73 {
74 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Home Button"), 74 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Home Button"),
75 "devicebuttons/ipaq_home", 75 "devicebuttons/ipaq_home",
76 "QPE/Launcher", "home()", 76 "QPE/Launcher", "home()",
77 "buttonsettings", "raise()" }, 77 "buttonsettings", "raise()" },
78 { 78 {
79 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Record Button"), 79 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Record Button"),
80 "devicebuttons/ipaq_record", 80 "devicebuttons/ipaq_record",
81 "QPE/VMemo", "toggleRecord()", 81 "QPE/VMemo", "toggleRecord()",
82 "sound", "raise()" }, 82 "sound", "raise()" },
83}; 83};
84 84
85void GenuineIntel::init(const QString& model) 85void GenuineIntel::init(const QString& model)
86{ 86{
87 d->m_vendorstr = "Intel"; 87 d->m_vendorstr = "Intel";
88 d->m_vendor = Vendor_GenuineIntel; 88 d->m_vendor = Vendor_GenuineIntel;
89 89
90 QStringList SL = QStringList::split( " ", model ); 90 QStringList SL = QStringList::split( " ", model );
91 91
92 d->m_model = Model_GenuineIntel; 92 d->m_model = Model_GenuineIntel;
93 d->m_rotation = Rot0; 93 d->m_rotation = Rot0;
94} 94}
95 95
96void GenuineIntel::initButtons() 96void GenuineIntel::initButtons()
97{ 97{
98 if ( d->m_buttons ) 98 if ( d->m_buttons )
99 return; 99 return;
100 100
101 if ( isQWS( ) ) { 101 if ( isQWS( ) ) {
102 addPreHandler(this); 102 addPreHandler(this);
103 } 103 }
104 104
105 d->m_buttons = new QValueList <ODeviceButton>; 105 d->m_buttons = new QValueList <ODeviceButton>;
106 106
107 for ( uint i = 0; i < ( sizeof( genuineintel_buttons ) / sizeof( gi_button )); i++ ) { 107 for ( uint i = 0; i < ( sizeof( genuineintel_buttons ) / sizeof( gi_button )); i++ ) {
108 gi_button *ib = genuineintel_buttons + i; 108 gi_button *ib = genuineintel_buttons + i;
109 ODeviceButton b; 109 ODeviceButton b;
110 110
111 b. setKeycode ( ib->code ); 111 b. setKeycode ( ib->code );
112 b. setUserText ( QObject::tr ( "Button", ib->utext )); 112 b. setUserText ( QObject::tr ( "Button", ib->utext ));
113 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 113 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
114 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 114 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
115 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 115 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
116 116
117 d->m_buttons->append ( b ); 117 d->m_buttons->append ( b );
118 } 118 }
119 reloadButtonMapping(); 119 reloadButtonMapping();
120} 120}
121 121
122QValueList <OLed> GenuineIntel::ledList() const 122QValueList <OLed> GenuineIntel::ledList() const
123{ 123{
124 QValueList <OLed> vl; 124 QValueList <OLed> vl;
125 return vl; //none 125 return vl; //none
126} 126}
127 127
128QValueList <OLedState> GenuineIntel::ledStateList ( OLed ) const 128QValueList <OLedState> GenuineIntel::ledStateList ( OLed ) const
129{ 129{
130 QValueList <OLedState> vl; 130 QValueList <OLedState> vl;
131 return vl; // none 131 return vl; // none
132} 132}
133 133
134OLedState GenuineIntel::ledState ( OLed ) const 134OLedState GenuineIntel::ledState ( OLed ) const
135{ 135{
136 return Led_Off; 136 return Led_Off;
137} 137}
138 138
139bool GenuineIntel::setLedState ( OLed , OLedState ) 139bool GenuineIntel::setLedState ( OLed , OLedState )
140{ 140{
141 return false; 141 return false;
142} 142}
143 143
144 144
145bool GenuineIntel::filter ( int /*unicode*/, int , int , bool , bool ) 145bool GenuineIntel::filter ( int /*unicode*/, int , int , bool , bool )
146{ 146{
147 return false; 147 return false;
148} 148}
149 149
150void GenuineIntel::playAlarmSound() 150void GenuineIntel::playAlarmSound()
151{ 151{
152#ifndef QT_NO_SOUND 152#ifndef QT_NO_SOUND
153 static Sound snd ( "alarm" ); 153 static Sound snd ( "alarm" );
154 if(!snd.isFinished()) 154 if(!snd.isFinished())
155 return; 155 return;
156 156
157 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 157 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
158 snd. play(); 158 snd. play();
159#endif 159#endif
160} 160}
161 161
162 162
163bool GenuineIntel::setSoftSuspend ( bool )
164{
165 return false;
166}
167
168
169bool GenuineIntel::setDisplayBrightness ( int ) 163bool GenuineIntel::setDisplayBrightness ( int )
170{ 164{
171 return false; 165 return false;
172} 166}
173 167
174int GenuineIntel::displayBrightnessResolution() const 168int GenuineIntel::displayBrightnessResolution() const
175{ 169{
176 return 1; // perhaps to avoid division by zero 170 return 1; // perhaps to avoid division by zero
177} 171}
178 172
179 173
180bool GenuineIntel::hasLightSensor() const 174bool GenuineIntel::hasLightSensor() const
181{ 175{
182 return false; 176 return false;
183} 177}
184 178
185int GenuineIntel::readLightSensor() 179int GenuineIntel::readLightSensor()
186{ 180{
187 return 0; 181 return 0;
188} 182}
189 183
190int GenuineIntel::lightSensorResolution() const 184int GenuineIntel::lightSensorResolution() const
191{ 185{
192 return 1; // see above 186 return 1; // see above
193} 187}
diff --git a/libopie2/opiecore/device/odevice_genuineintel.h b/libopie2/opiecore/device/odevice_genuineintel.h
index 52c5fc6..69316af 100644
--- a/libopie2/opiecore/device/odevice_genuineintel.h
+++ b/libopie2/opiecore/device/odevice_genuineintel.h
@@ -1,84 +1,82 @@
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_GENUINEINTEL 30#ifndef ODEVICE_GENUINEINTEL
31#define ODEVICE_GENUINEINTEL 31#define ODEVICE_GENUINEINTEL
32 32
33#include "odevice.h" 33#include "odevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class GenuineIntel : public ODevice, public QWSServer::KeyboardFilter 42class GenuineIntel : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 44
45 protected: 45 protected:
46 virtual void init(const QString&); 46 virtual void init(const QString&);
47 virtual void initButtons(); 47 virtual void initButtons();
48 48
49 public: 49 public:
50 virtual bool setSoftSuspend( bool soft );
51
52 virtual bool setDisplayBrightness( int b ); 50 virtual bool setDisplayBrightness( int b );
53 virtual int displayBrightnessResolution() const; 51 virtual int displayBrightnessResolution() const;
54 52
55 virtual void playAlarmSound(); 53 virtual void playAlarmSound();
56 54
57 virtual QValueList <OLed> ledList() const; 55 virtual QValueList <OLed> ledList() const;
58 virtual QValueList <OLedState> ledStateList( OLed led ) const; 56 virtual QValueList <OLedState> ledStateList( OLed led ) const;
59 virtual OLedState ledState( OLed led ) const; 57 virtual OLedState ledState( OLed led ) const;
60 virtual bool setLedState( OLed led, OLedState st ); 58 virtual bool setLedState( OLed led, OLedState st );
61 59
62 virtual bool hasLightSensor() const; 60 virtual bool hasLightSensor() const;
63 virtual int readLightSensor(); 61 virtual int readLightSensor();
64 virtual int lightSensorResolution() const; 62 virtual int lightSensorResolution() const;
65 protected: 63 protected:
66 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 64 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
67 65
68}; 66};
69 67
70struct gi_button { 68struct gi_button {
71 Qt::Key code; 69 Qt::Key code;
72 char *utext; 70 char *utext;
73 char *pix; 71 char *pix;
74 char *fpressedservice; 72 char *fpressedservice;
75 char *fpressedaction; 73 char *fpressedaction;
76 char *fheldservice; 74 char *fheldservice;
77 char *fheldaction; 75 char *fheldaction;
78}; 76};
79 77
80} 78}
81} 79}
82} 80}
83 81
84#endif 82#endif
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 9e01a0c..2ce38a9 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -83,350 +83,329 @@ typedef struct {
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 addPreHandler(this); 172 addPreHandler(this);
173 } 173 }
174 174
175 d->m_buttons = new QValueList <ODeviceButton>; 175 d->m_buttons = new QValueList <ODeviceButton>;
176 176
177 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++ ) {
178 i_button *ib = ipaq_buttons + i; 178 i_button *ib = ipaq_buttons + i;
179 ODeviceButton b; 179 ODeviceButton b;
180 180
181 if (( ib->model & d->m_model ) == d->m_model ) { 181 if (( ib->model & d->m_model ) == d->m_model ) {
182 b. setKeycode ( ib->code ); 182 b. setKeycode ( ib->code );
183 b. setUserText ( QObject::tr ( "Button", ib->utext )); 183 b. setUserText ( QObject::tr ( "Button", ib->utext ));
184 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 184 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
187 187
188 d->m_buttons->append ( b ); 188 d->m_buttons->append ( b );
189 } 189 }
190 } 190 }
191 reloadButtonMapping(); 191 reloadButtonMapping();
192} 192}
193 193
194QValueList <OLed> iPAQ::ledList() const 194QValueList <OLed> iPAQ::ledList() const
195{ 195{
196 QValueList <OLed> vl; 196 QValueList <OLed> vl;
197 vl << Led_Power; 197 vl << Led_Power;
198 198
199 if ( d->m_model == Model_iPAQ_H38xx ) 199 if ( d->m_model == Model_iPAQ_H38xx )
200 vl << Led_BlueTooth; 200 vl << Led_BlueTooth;
201 return vl; 201 return vl;
202} 202}
203 203
204QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 204QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
205{ 205{
206 QValueList <OLedState> vl; 206 QValueList <OLedState> vl;
207 207
208 if ( l == Led_Power ) 208 if ( l == Led_Power )
209 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 209 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
210 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 210 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
211 vl << Led_Off; // << Led_On << ??? 211 vl << Led_Off; // << Led_On << ???
212 212
213 return vl; 213 return vl;
214} 214}
215 215
216OLedState iPAQ::ledState ( OLed l ) const 216OLedState iPAQ::ledState ( OLed l ) const
217{ 217{
218 switch ( l ) { 218 switch ( l ) {
219 case Led_Power: 219 case Led_Power:
220 return m_leds [0]; 220 return m_leds [0];
221 case Led_BlueTooth: 221 case Led_BlueTooth:
222 return m_leds [1]; 222 return m_leds [1];
223 default: 223 default:
224 return Led_Off; 224 return Led_Off;
225 } 225 }
226} 226}
227 227
228bool iPAQ::setLedState ( OLed l, OLedState st ) 228bool iPAQ::setLedState ( OLed l, OLedState st )
229{ 229{
230 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 230 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
231 231
232 if ( l == Led_Power ) { 232 if ( l == Led_Power ) {
233 if ( fd >= 0 ) { 233 if ( fd >= 0 ) {
234 LED_IN leds; 234 LED_IN leds;
235 ::memset ( &leds, 0, sizeof( leds )); 235 ::memset ( &leds, 0, sizeof( leds ));
236 leds. TotalTime = 0; 236 leds. TotalTime = 0;
237 leds. OnTime = 0; 237 leds. OnTime = 0;
238 leds. OffTime = 1; 238 leds. OffTime = 1;
239 leds. OffOnBlink = 2; 239 leds. OffOnBlink = 2;
240 240
241 switch ( st ) { 241 switch ( st ) {
242 case Led_Off : leds. OffOnBlink = 0; break; 242 case Led_Off : leds. OffOnBlink = 0; break;
243 case Led_On : leds. OffOnBlink = 1; break; 243 case Led_On : leds. OffOnBlink = 1; break;
244 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 244 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
245 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 245 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
246 } 246 }
247 247
248 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 248 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
249 m_leds [0] = st; 249 m_leds [0] = st;
250 return true; 250 return true;
251 } 251 }
252 } 252 }
253 } 253 }
254 return false; 254 return false;
255} 255}
256 256
257 257
258bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 258bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
259{ 259{
260 int newkeycode = keycode; 260 int newkeycode = keycode;
261 261
262 switch ( keycode ) { 262 switch ( keycode ) {
263 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 263 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
264 case HardKey_Menu: { 264 case HardKey_Menu: {
265 if (( d->m_model == Model_iPAQ_H38xx ) || 265 if (( d->m_model == Model_iPAQ_H38xx ) ||
266 ( d->m_model == Model_iPAQ_H39xx ) || 266 ( d->m_model == Model_iPAQ_H39xx ) ||
267 ( d->m_model == Model_iPAQ_H5xxx)) { 267 ( d->m_model == Model_iPAQ_H5xxx)) {
268 newkeycode = HardKey_Mail; 268 newkeycode = HardKey_Mail;
269 } 269 }
270 break; 270 break;
271 } 271 }
272 272
273 // Rotate cursor keys 180 or 270 273 // Rotate cursor keys 180 or 270
274 case Key_Left : 274 case Key_Left :
275 case Key_Right: 275 case Key_Right:
276 case Key_Up : 276 case Key_Up :
277 case Key_Down : { 277 case Key_Down : {
278 if (( d->m_model == Model_iPAQ_H31xx ) || 278 if (( d->m_model == Model_iPAQ_H31xx ) ||
279 ( d->m_model == Model_iPAQ_H38xx )) { 279 ( d->m_model == Model_iPAQ_H38xx )) {
280 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 280 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
281 } 281 }
282 // Rotate the cursor keys by 270 282 // Rotate the cursor keys by 270
283 // keycode - Key_Left = position of the button starting from left clockwise 283 // keycode - Key_Left = position of the button starting from left clockwise
284 // add the rotation to it and modolo. No we've the original offset 284 // add the rotation to it and modolo. No we've the original offset
285 // add the offset to the Key_Left key 285 // add the offset to the Key_Left key
286 if ( d-> m_model == Model_iPAQ_H5xxx ) 286 if ( d-> m_model == Model_iPAQ_H5xxx )
287 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 287 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
288 break; 288 break;
289 } 289 }
290 290
291 // map Power Button short/long press to F34/F35 291 // map Power Button short/long press to F34/F35
292 case Key_SysReq: { 292 case Key_SysReq: {
293 if ( isPress ) { 293 if ( isPress ) {
294 if ( m_power_timer ) 294 if ( m_power_timer )
295 killTimer ( m_power_timer ); 295 killTimer ( m_power_timer );
296 m_power_timer = startTimer ( 500 ); 296 m_power_timer = startTimer ( 500 );
297 } 297 }
298 else if ( m_power_timer ) { 298 else if ( m_power_timer ) {
299 killTimer ( m_power_timer ); 299 killTimer ( m_power_timer );
300 m_power_timer = 0; 300 m_power_timer = 0;
301 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 301 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
302 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 302 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
303 } 303 }
304 newkeycode = Key_unknown; 304 newkeycode = Key_unknown;
305 break; 305 break;
306 } 306 }
307 } 307 }
308 308
309 if ( newkeycode != keycode ) { 309 if ( newkeycode != keycode ) {
310 if ( newkeycode != Key_unknown ) 310 if ( newkeycode != Key_unknown )
311 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 311 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
312 return true; 312 return true;
313 } 313 }
314 else 314 else
315 return false; 315 return false;
316} 316}
317 317
318void iPAQ::timerEvent ( QTimerEvent * ) 318void iPAQ::timerEvent ( QTimerEvent * )
319{ 319{
320 killTimer ( m_power_timer ); 320 killTimer ( m_power_timer );
321 m_power_timer = 0; 321 m_power_timer = 0;
322 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 322 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
323 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 323 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
324} 324}
325 325
326 326
327void iPAQ::playAlarmSound() 327void iPAQ::playAlarmSound()
328{ 328{
329#ifndef QT_NO_SOUND 329#ifndef QT_NO_SOUND
330 static Sound snd ( "alarm" ); 330 static Sound snd ( "alarm" );
331 if(!snd.isFinished()) 331 if(!snd.isFinished())
332 return; 332 return;
333 333
334 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 334 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
335 snd. play(); 335 snd. play();
336#endif 336#endif
337} 337}
338 338
339
340bool iPAQ::setSoftSuspend ( bool soft )
341{
342 bool res = false;
343 int fd;
344
345 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
346 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
347 res = true;
348 else
349 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
350
351 ::close ( fd );
352 }
353 else
354 ::perror ( "/proc/sys/ts/suspend_button_mode" );
355
356 return res;
357}
358
359
360bool iPAQ::setDisplayBrightness ( int bright ) 339bool iPAQ::setDisplayBrightness ( int bright )
361{ 340{
362 bool res = false; 341 bool res = false;
363 int fd; 342 int fd;
364 343
365 if ( bright > 255 ) 344 if ( bright > 255 )
366 bright = 255; 345 bright = 255;
367 if ( bright < 0 ) 346 if ( bright < 0 )
368 bright = 0; 347 bright = 0;
369 348
370 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 349 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
371 FLITE_IN bl; 350 FLITE_IN bl;
372 bl. mode = 1; 351 bl. mode = 1;
373 bl. pwr = bright ? 1 : 0; 352 bl. pwr = bright ? 1 : 0;
374 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 353 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
375 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 354 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
376 ::close ( fd ); 355 ::close ( fd );
377 } 356 }
378 return res; 357 return res;
379} 358}
380 359
381int iPAQ::displayBrightnessResolution() const 360int iPAQ::displayBrightnessResolution() const
382{ 361{
383 switch ( model()) { 362 switch ( model()) {
384 case Model_iPAQ_H31xx: 363 case Model_iPAQ_H31xx:
385 case Model_iPAQ_H36xx: 364 case Model_iPAQ_H36xx:
386 case Model_iPAQ_H37xx: 365 case Model_iPAQ_H37xx:
387 return 128; // really 256, but >128 could damage the LCD 366 return 128; // really 256, but >128 could damage the LCD
388 367
389 case Model_iPAQ_H38xx: 368 case Model_iPAQ_H38xx:
390 case Model_iPAQ_H39xx: 369 case Model_iPAQ_H39xx:
391 return 64; 370 return 64;
392 case Model_iPAQ_H5xxx: 371 case Model_iPAQ_H5xxx:
393 return 255; 372 return 255;
394 373
395 default: 374 default:
396 return 2; 375 return 2;
397 } 376 }
398} 377}
399 378
400 379
401bool iPAQ::hasLightSensor() const 380bool iPAQ::hasLightSensor() const
402{ 381{
403 return true; 382 return true;
404} 383}
405 384
406int iPAQ::readLightSensor() 385int iPAQ::readLightSensor()
407{ 386{
408 int fd; 387 int fd;
409 int val = -1; 388 int val = -1;
410 389
411 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 390 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
412 char buffer [8]; 391 char buffer [8];
413 392
414 if ( ::read ( fd, buffer, 5 ) == 5 ) { 393 if ( ::read ( fd, buffer, 5 ) == 5 ) {
415 char *endptr; 394 char *endptr;
416 395
417 buffer [4] = 0; 396 buffer [4] = 0;
418 val = ::strtol ( buffer + 2, &endptr, 16 ); 397 val = ::strtol ( buffer + 2, &endptr, 16 );
419 398
420 if ( *endptr != 0 ) 399 if ( *endptr != 0 )
421 val = -1; 400 val = -1;
422 } 401 }
423 ::close ( fd ); 402 ::close ( fd );
424 } 403 }
425 404
426 return val; 405 return val;
427} 406}
428 407
429int iPAQ::lightSensorResolution() const 408int iPAQ::lightSensorResolution() const
430{ 409{
431 return 256; 410 return 256;
432} 411}
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index cc0b8ac..b1dac74 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -1,90 +1,88 @@
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_IPAQ 30#ifndef ODEVICE_IPAQ
31#define ODEVICE_IPAQ 31#define ODEVICE_IPAQ
32 32
33#include "odevice.h" 33#include "odevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 44
45 protected: 45 protected:
46 virtual void init(const QString&); 46 virtual void init(const QString&);
47 virtual void initButtons(); 47 virtual void initButtons();
48 48
49 public: 49 public:
50 virtual bool setSoftSuspend( bool soft );
51
52 virtual bool setDisplayBrightness( int b ); 50 virtual bool setDisplayBrightness( int b );
53 virtual int displayBrightnessResolution() const; 51 virtual int displayBrightnessResolution() const;
54 52
55 virtual void playAlarmSound(); 53 virtual void playAlarmSound();
56 54
57 virtual QValueList <OLed> ledList() const; 55 virtual QValueList <OLed> ledList() const;
58 virtual QValueList <OLedState> ledStateList( OLed led ) const; 56 virtual QValueList <OLedState> ledStateList( OLed led ) const;
59 virtual OLedState ledState( OLed led ) const; 57 virtual OLedState ledState( OLed led ) const;
60 virtual bool setLedState( OLed led, OLedState st ); 58 virtual bool setLedState( OLed led, OLedState st );
61 59
62 virtual bool hasLightSensor() const; 60 virtual bool hasLightSensor() const;
63 virtual int readLightSensor(); 61 virtual int readLightSensor();
64 virtual int lightSensorResolution() const; 62 virtual int lightSensorResolution() const;
65 63
66 protected: 64 protected:
67 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 65 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
68 virtual void timerEvent( QTimerEvent *te ); 66 virtual void timerEvent( QTimerEvent *te );
69 67
70 int m_power_timer; 68 int m_power_timer;
71 69
72 OLedState m_leds [2]; 70 OLedState m_leds [2];
73}; 71};
74 72
75struct i_button { 73struct i_button {
76 uint model; 74 uint model;
77 Qt::Key code; 75 Qt::Key code;
78 char *utext; 76 char *utext;
79 char *pix; 77 char *pix;
80 char *fpressedservice; 78 char *fpressedservice;
81 char *fpressedaction; 79 char *fpressedaction;
82 char *fheldservice; 80 char *fheldservice;
83 char *fheldaction; 81 char *fheldaction;
84}; 82};
85 83
86} 84}
87} 85}
88} 86}
89 87
90#endif 88#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index b22ee70..cbc7a24 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -127,501 +127,461 @@ void Zaurus::init(const QString& cpu_info)
127 d->m_systemstr = "Zaurus"; 127 d->m_systemstr = "Zaurus";
128 d->m_system = System_Zaurus; 128 d->m_system = System_Zaurus;
129 m_embedix = true; 129 m_embedix = true;
130 } 130 }
131 else 131 else
132 { 132 {
133 d->m_vendorstr = "OpenZaurus Team"; 133 d->m_vendorstr = "OpenZaurus Team";
134 d->m_systemstr = "OpenZaurus"; 134 d->m_systemstr = "OpenZaurus";
135 d->m_system = System_OpenZaurus; 135 d->m_system = System_OpenZaurus;
136 // sysver already gathered 136 // sysver already gathered
137 137
138 // OpenZaurus sometimes uses the embedix kernel, check if this is one 138 // OpenZaurus sometimes uses the embedix kernel, check if this is one
139 FILE *uname = popen("uname -r", "r"); 139 FILE *uname = popen("uname -r", "r");
140 QFile f; 140 QFile f;
141 QString line; 141 QString line;
142 if ( f.open(IO_ReadOnly, uname) ) { 142 if ( f.open(IO_ReadOnly, uname) ) {
143 QTextStream ts ( &f ); 143 QTextStream ts ( &f );
144 line = ts. readLine(); 144 line = ts. readLine();
145 int loc = line. find ( "embedix" ); 145 int loc = line. find ( "embedix" );
146 if ( loc != -1 ) 146 if ( loc != -1 )
147 m_embedix = true; 147 m_embedix = true;
148 else 148 else
149 m_embedix = false; 149 m_embedix = false;
150 f.close(); 150 f.close();
151 } 151 }
152 pclose(uname); 152 pclose(uname);
153 } 153 }
154 154
155 // check the Zaurus model 155 // check the Zaurus model
156 QString model; 156 QString model;
157 int loc = cpu_info.find( ":" ); 157 int loc = cpu_info.find( ":" );
158 if ( loc != -1 ) 158 if ( loc != -1 )
159 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 159 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
160 else 160 else
161 model = cpu_info; 161 model = cpu_info;
162 162
163 if ( model == "SHARP Corgi" ) { 163 if ( model == "SHARP Corgi" ) {
164 d->m_model = Model_Zaurus_SLC7x0; 164 d->m_model = Model_Zaurus_SLC7x0;
165 d->m_modelstr = "Zaurus SL-C700"; 165 d->m_modelstr = "Zaurus SL-C700";
166 } else if ( model == "SHARP Shepherd" ) { 166 } else if ( model == "SHARP Shepherd" ) {
167 d->m_model = Model_Zaurus_SLC7x0; 167 d->m_model = Model_Zaurus_SLC7x0;
168 d->m_modelstr = "Zaurus SL-C750"; 168 d->m_modelstr = "Zaurus SL-C750";
169 } else if ( model == "SHARP Husky" ) { 169 } else if ( model == "SHARP Husky" ) {
170 d->m_model = Model_Zaurus_SLC7x0; 170 d->m_model = Model_Zaurus_SLC7x0;
171 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 171 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
172 } else if ( model == "SHARP Boxer" ) { 172 } else if ( model == "SHARP Boxer" ) {
173 d->m_model = Model_Zaurus_SLC7x0; 173 d->m_model = Model_Zaurus_SLC7x0;
174 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 174 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
175 } else if ( model == "SHARP Poodle" ) { 175 } else if ( model == "SHARP Poodle" ) {
176 d->m_model = Model_Zaurus_SLB600; 176 d->m_model = Model_Zaurus_SLB600;
177 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 177 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
178 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 178 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
179 d->m_model = Model_Zaurus_SL5500; 179 d->m_model = Model_Zaurus_SL5500;
180 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 180 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
181 } else if ( model == "SHARP Tosa" ) { 181 } else if ( model == "SHARP Tosa" ) {
182 d->m_model = Model_Zaurus_SL6000; 182 d->m_model = Model_Zaurus_SL6000;
183 d->m_modelstr = "Zaurus SL-6000"; 183 d->m_modelstr = "Zaurus SL-6000";
184 } else if ( model == "SHARP Spitz" ) { 184 } else if ( model == "SHARP Spitz" ) {
185 d->m_model = Model_Zaurus_SLC3000; 185 d->m_model = Model_Zaurus_SLC3000;
186 d->m_modelstr = "Zaurus SL-C3000"; 186 d->m_modelstr = "Zaurus SL-C3000";
187 } else { 187 } else {
188 d->m_model = Model_Zaurus_SL5500; 188 d->m_model = Model_Zaurus_SL5500;
189 d->m_modelstr = "Unknown Zaurus"; 189 d->m_modelstr = "Unknown Zaurus";
190 } 190 }
191 191
192 // set initial rotation 192 // set initial rotation
193 switch( d->m_model ) { 193 switch( d->m_model ) {
194 case Model_Zaurus_SL6000: // fallthrough 194 case Model_Zaurus_SL6000: // fallthrough
195 case Model_Zaurus_SLA300: 195 case Model_Zaurus_SLA300:
196 d->m_rotation = Rot0; 196 d->m_rotation = Rot0;
197 break; 197 break;
198 case Model_Zaurus_SLC3000: // fallthrough 198 case Model_Zaurus_SLC3000: // fallthrough
199 case Model_Zaurus_SLC7x0: 199 case Model_Zaurus_SLC7x0:
200 d->m_rotation = rotation(); 200 d->m_rotation = rotation();
201 d->m_direction = direction(); 201 d->m_direction = direction();
202 break; 202 break;
203 case Model_Zaurus_SLB600: // fallthrough 203 case Model_Zaurus_SLB600: // fallthrough
204 case Model_Zaurus_SL5000: // fallthrough 204 case Model_Zaurus_SL5000: // fallthrough
205 case Model_Zaurus_SL5500: // fallthrough 205 case Model_Zaurus_SL5500: // fallthrough
206 default: 206 default:
207 d->m_rotation = Rot270; 207 d->m_rotation = Rot270;
208 break; 208 break;
209 } 209 }
210 m_leds[0] = Led_Off; 210 m_leds[0] = Led_Off;
211 211
212 if ( m_embedix ) 212 if ( m_embedix )
213 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); 213 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr );
214 else 214 else
215 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 215 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
216} 216}
217 217
218void Zaurus::initButtons() 218void Zaurus::initButtons()
219{ 219{
220 if ( d->m_buttons ) 220 if ( d->m_buttons )
221 return; 221 return;
222 222
223 d->m_buttons = new QValueList <ODeviceButton>; 223 d->m_buttons = new QValueList <ODeviceButton>;
224 224
225 struct z_button * pz_buttons; 225 struct z_button * pz_buttons;
226 int buttoncount; 226 int buttoncount;
227 switch ( d->m_model ) { 227 switch ( d->m_model ) {
228 case Model_Zaurus_SLC3000: // fallthrough 228 case Model_Zaurus_SLC3000: // fallthrough
229 case Model_Zaurus_SLC7x0: 229 case Model_Zaurus_SLC7x0:
230 pz_buttons = z_buttons_c700; 230 pz_buttons = z_buttons_c700;
231 buttoncount = ARRAY_SIZE(z_buttons_c700); 231 buttoncount = ARRAY_SIZE(z_buttons_c700);
232 break; 232 break;
233 default: 233 default:
234 pz_buttons = z_buttons; 234 pz_buttons = z_buttons;
235 buttoncount = ARRAY_SIZE(z_buttons); 235 buttoncount = ARRAY_SIZE(z_buttons);
236 break; 236 break;
237 } 237 }
238 238
239 for ( int i = 0; i < buttoncount; i++ ) { 239 for ( int i = 0; i < buttoncount; i++ ) {
240 struct z_button *zb = pz_buttons + i; 240 struct z_button *zb = pz_buttons + i;
241 ODeviceButton b; 241 ODeviceButton b;
242 242
243 b.setKeycode( zb->code ); 243 b.setKeycode( zb->code );
244 b.setUserText( QObject::tr( "Button", zb->utext )); 244 b.setUserText( QObject::tr( "Button", zb->utext ));
245 b.setPixmap( Resource::loadPixmap( zb->pix )); 245 b.setPixmap( Resource::loadPixmap( zb->pix ));
246 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 246 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
247 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 247 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
248 d->m_buttons->append( b ); 248 d->m_buttons->append( b );
249 } 249 }
250 250
251 reloadButtonMapping(); 251 reloadButtonMapping();
252} 252}
253 253
254 254
255 255
256typedef struct sharp_led_status { 256typedef struct sharp_led_status {
257 int which; /* select which LED status is wanted. */ 257 int which; /* select which LED status is wanted. */
258 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 258 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
259} sharp_led_status; 259} sharp_led_status;
260 260
261void Zaurus::buzzer( int sound ) 261void Zaurus::buzzer( int sound )
262{ 262{
263#ifndef QT_NO_SOUND 263#ifndef QT_NO_SOUND
264 Sound *snd = 0; 264 Sound *snd = 0;
265 265
266 // All devices except SL5500 have a DSP device 266 // All devices except SL5500 have a DSP device
267 if ( d->m_model != Model_Zaurus_SL5000 267 if ( d->m_model != Model_Zaurus_SL5000
268 && d->m_model != Model_Zaurus_SL5500 ) { 268 && d->m_model != Model_Zaurus_SL5500 ) {
269 269
270 switch ( sound ){ 270 switch ( sound ){
271 case SHARP_BUZ_TOUCHSOUND: { 271 case SHARP_BUZ_TOUCHSOUND: {
272 static Sound touch_sound("touchsound"); 272 static Sound touch_sound("touchsound");
273 snd = &touch_sound; 273 snd = &touch_sound;
274 } 274 }
275 break; 275 break;
276 case SHARP_BUZ_KEYSOUND: { 276 case SHARP_BUZ_KEYSOUND: {
277 static Sound key_sound( "keysound" ); 277 static Sound key_sound( "keysound" );
278 snd = &key_sound; 278 snd = &key_sound;
279 } 279 }
280 break; 280 break;
281 case SHARP_BUZ_SCHEDULE_ALARM: 281 case SHARP_BUZ_SCHEDULE_ALARM:
282 default: { 282 default: {
283 static Sound alarm_sound("alarm"); 283 static Sound alarm_sound("alarm");
284 snd = &alarm_sound; 284 snd = &alarm_sound;
285 } 285 }
286 break; 286 break;
287 } 287 }
288 } 288 }
289 289
290 // If a soundname is defined, we expect that this device has 290 // If a soundname is defined, we expect that this device has
291 // sound capabilities.. Otherwise we expect to have the buzzer 291 // sound capabilities.. Otherwise we expect to have the buzzer
292 // device.. 292 // device..
293 if ( snd && snd->isFinished() ){ 293 if ( snd && snd->isFinished() ){
294 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 294 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
295 snd->play(); 295 snd->play();
296 } else if( !snd ) { 296 } else if( !snd ) {
297 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 297 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
298 298
299 if ( fd >= 0 ) { 299 if ( fd >= 0 ) {
300 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 300 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
301 ::close ( fd ); 301 ::close ( fd );
302 } 302 }
303 303
304 } 304 }
305#endif 305#endif
306} 306}
307 307
308 308
309void Zaurus::playAlarmSound() 309void Zaurus::playAlarmSound()
310{ 310{
311 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 311 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
312} 312}
313 313
314void Zaurus::playTouchSound() 314void Zaurus::playTouchSound()
315{ 315{
316 buzzer( SHARP_BUZ_TOUCHSOUND ); 316 buzzer( SHARP_BUZ_TOUCHSOUND );
317} 317}
318 318
319void Zaurus::playKeySound() 319void Zaurus::playKeySound()
320{ 320{
321 buzzer( SHARP_BUZ_KEYSOUND ); 321 buzzer( SHARP_BUZ_KEYSOUND );
322} 322}
323 323
324 324
325QValueList <OLed> Zaurus::ledList() const 325QValueList <OLed> Zaurus::ledList() const
326{ 326{
327 QValueList <OLed> vl; 327 QValueList <OLed> vl;
328 vl << Led_Mail; 328 vl << Led_Mail;
329 return vl; 329 return vl;
330} 330}
331 331
332QValueList <OLedState> Zaurus::ledStateList( OLed l ) const 332QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
333{ 333{
334 QValueList <OLedState> vl; 334 QValueList <OLedState> vl;
335 335
336 if ( l == Led_Mail ) 336 if ( l == Led_Mail )
337 vl << Led_Off << Led_On << Led_BlinkSlow; 337 vl << Led_Off << Led_On << Led_BlinkSlow;
338 return vl; 338 return vl;
339} 339}
340 340
341OLedState Zaurus::ledState( OLed which ) const 341OLedState Zaurus::ledState( OLed which ) const
342{ 342{
343 if ( which == Led_Mail ) 343 if ( which == Led_Mail )
344 return m_leds [0]; 344 return m_leds [0];
345 else 345 else
346 return Led_Off; 346 return Led_Off;
347} 347}
348 348
349bool Zaurus::setLedState( OLed which, OLedState st ) 349bool Zaurus::setLedState( OLed which, OLedState st )
350{ 350{
351 // Currently not supported on non_embedix kernels 351 // Currently not supported on non_embedix kernels
352 if (!m_embedix) 352 if (!m_embedix)
353 { 353 {
354 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 354 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
355 return false; 355 return false;
356 } 356 }
357 357
358 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 358 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
359 359
360 if ( which == Led_Mail ) { 360 if ( which == Led_Mail ) {
361 if ( fd >= 0 ) { 361 if ( fd >= 0 ) {
362 struct sharp_led_status leds; 362 struct sharp_led_status leds;
363 ::memset ( &leds, 0, sizeof( leds )); 363 ::memset ( &leds, 0, sizeof( leds ));
364 leds. which = SHARP_LED_MAIL_EXISTS; 364 leds. which = SHARP_LED_MAIL_EXISTS;
365 bool ok = true; 365 bool ok = true;
366 366
367 switch ( st ) { 367 switch ( st ) {
368 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 368 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
369 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 369 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
370 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 370 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
371 default : ok = false; 371 default : ok = false;
372 } 372 }
373 373
374 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 374 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
375 m_leds [0] = st; 375 m_leds [0] = st;
376 return true; 376 return true;
377 } 377 }
378 } 378 }
379 } 379 }
380 return false; 380 return false;
381} 381}
382 382
383bool Zaurus::setSoftSuspend ( bool soft )
384{
385 if (!m_embedix) {
386 /* non-Embedix kernels dont have kernel autosuspend */
387 return ODevice::setSoftSuspend( soft );
388 }
389
390 bool res = false;
391 int fd;
392
393 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
394 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
395
396 int sources = ::ioctl( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
397
398 if ( sources >= 0 ) {
399 if ( soft )
400 sources &= ~APM_EVT_POWER_BUTTON;
401 else
402 sources |= APM_EVT_POWER_BUTTON;
403
404 if ( ::ioctl( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
405 res = true;
406 else
407 perror ( "APM_IOCGEVTSRC" );
408 }
409 else
410 perror ( "APM_IOCGEVTSRC" );
411
412 ::close( fd );
413 }
414 else
415 perror( "/dev/apm_bios or /dev/misc/apm_bios" );
416
417 return res;
418}
419
420int Zaurus::displayBrightnessResolution() const 383int Zaurus::displayBrightnessResolution() const
421{ 384{
422 int res = 1; 385 int res = 1;
423 if (m_embedix) 386 if (m_embedix)
424 { 387 {
425 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 388 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
426 if ( fd ) 389 if ( fd )
427 { 390 {
428 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 391 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
429 ::close( fd ); 392 ::close( fd );
430 return value ? value : res; 393 return value ? value : res;
431 } 394 }
432 } 395 }
433 else 396 else
434 { 397 {
435 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 398 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
436 if ( fd ) 399 if ( fd )
437 { 400 {
438 char buf[100]; 401 char buf[100];
439 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 402 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
440 ::close( fd ); 403 ::close( fd );
441 } 404 }
442 } 405 }
443 return res; 406 return res;
444} 407}
445 408
446bool Zaurus::setDisplayBrightness( int bright ) 409bool Zaurus::setDisplayBrightness( int bright )
447{ 410{
448 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 411 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
449 bool res = false; 412 bool res = false;
450 413
451 if ( bright > 255 ) bright = 255; 414 if ( bright > 255 ) bright = 255;
452 if ( bright < 0 ) bright = 0; 415 if ( bright < 0 ) bright = 0;
453 416
454 int numberOfSteps = displayBrightnessResolution(); 417 int numberOfSteps = displayBrightnessResolution();
455 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 418 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
456 419
457 if ( m_embedix ) 420 if ( m_embedix )
458 { 421 {
459 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 422 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
460 if ( fd ) 423 if ( fd )
461 { 424 {
462 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 425 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
463 ::close( fd ); 426 ::close( fd );
464 } 427 }
465 } 428 }
466 else 429 else
467 { 430 {
468 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 431 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
469 if ( fd ) 432 if ( fd )
470 { 433 {
471 char buf[100]; 434 char buf[100];
472 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 435 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
473 res = ( ::write( fd, &buf[0], len ) == 0 ); 436 res = ( ::write( fd, &buf[0], len ) == 0 );
474 ::close( fd ); 437 ::close( fd );
475 } 438 }
476 } 439 }
477 return res; 440 return res;
478} 441}
479 442
480bool Zaurus::setDisplayStatus( bool on ) 443bool Zaurus::setDisplayStatus( bool on )
481{ 444{
482 bool res = false; 445 bool res = false;
483 if ( m_embedix ) 446 if ( m_embedix )
484 { 447 {
485 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 448 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
486 if ( fd ) 449 if ( fd )
487 { 450 {
488 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 451 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
489 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 452 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
490 ::close ( fd ); 453 ::close ( fd );
491 } 454 }
492 } 455 }
493 else 456 else
494 { 457 {
495 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 458 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
496 if ( fd ) 459 if ( fd )
497 { 460 {
498 char buf[10]; 461 char buf[10];
499 buf[0] = on ? '1' : '0'; 462 buf[0] = on ? '1' : '0';
500 buf[1] = '\0'; 463 buf[1] = '\0';
501 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 464 res = ( ::write( fd, &buf[0], 2 ) == 0 );
502 ::close( fd ); 465 ::close( fd );
503 } 466 }
504 } 467 }
505 return res; 468 return res;
506} 469}
507 470
508bool Zaurus::suspend() 471bool Zaurus::suspend()
509{ 472{
510 qDebug("ODevice::suspend"); 473 qDebug("ODevice::suspend");
511 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 474 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
512 return false; 475 return false;
513 476
514 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 477 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
515 return false; 478 return false;
516 479
517 bool res = false; 480 bool res = false;
518 ODevice::sendSuspendmsg(); 481 ODevice::sendSuspendmsg();
519 482
520 struct timeval tvs, tvn; 483 struct timeval tvs, tvn;
521 ::gettimeofday ( &tvs, 0 ); 484 ::gettimeofday ( &tvs, 0 );
522 485
523 ::sync(); // flush fs caches 486 ::sync(); // flush fs caches
524 res = ( ::system ( "apm --suspend" ) == 0 ); 487 res = ( ::system ( "apm --suspend" ) == 0 );
525 488
526 // This is needed because the apm implementation is asynchronous and we 489 // This is needed because the apm implementation is asynchronous and we
527 // can not be sure when exactly the device is really suspended 490 // can not be sure when exactly the device is really suspended
528 if ( res ) { 491 if ( res ) {
529 do { // Yes, wait 15 seconds. This APM sucks big time. 492 do { // Yes, wait 15 seconds. This APM sucks big time.
530 ::usleep ( 200 * 1000 ); 493 ::usleep ( 200 * 1000 );
531 ::gettimeofday ( &tvn, 0 ); 494 ::gettimeofday ( &tvn, 0 );
532 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 495 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
533 } 496 }
534 497
535 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 498 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
536 return res; 499 return res;
537} 500}
538 501
539 502
540Transformation Zaurus::rotation() const 503Transformation Zaurus::rotation() const
541{ 504{
542 Transformation rot; 505 Transformation rot;
543 int handle = 0; 506
544 int retval = 0;
545
546 switch ( d->m_model ) { 507 switch ( d->m_model ) {
547 case Model_Zaurus_SLC3000: // fallthrough 508 case Model_Zaurus_SLC3000: // fallthrough
548 case Model_Zaurus_SLC7x0: 509 case Model_Zaurus_SLC7x0:
549 OHingeStatus hs = readHingeSensor(); 510 OHingeStatus hs = readHingeSensor();
550 if ( hs == CASE_PORTRAIT ) rot = Rot0; 511 if ( hs == CASE_PORTRAIT ) rot = Rot0;
551 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 512 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
552 else rot = Rot270; 513 else rot = Rot270;
553 break; 514 break;
554 case Model_Zaurus_SL6000: 515 case Model_Zaurus_SL6000:
555 case Model_Zaurus_SLB600: 516 case Model_Zaurus_SLB600:
556 case Model_Zaurus_SLA300: 517 case Model_Zaurus_SLA300:
557 case Model_Zaurus_SL5500: 518 case Model_Zaurus_SL5500:
558 case Model_Zaurus_SL5000: 519 case Model_Zaurus_SL5000:
559 default: 520 default:
560 rot = d->m_rotation; 521 rot = d->m_rotation;
561 break; 522 break;
562 } 523 }
563 524
564 return rot; 525 return rot;
565} 526}
566ODirection Zaurus::direction() const 527ODirection Zaurus::direction() const
567{ 528{
568 ODirection dir; 529 ODirection dir;
569 int handle = 0; 530
570 int retval = 0;
571 switch ( d->m_model ) { 531 switch ( d->m_model ) {
572 case Model_Zaurus_SLC3000: // fallthrough 532 case Model_Zaurus_SLC3000: // fallthrough
573 case Model_Zaurus_SLC7x0: 533 case Model_Zaurus_SLC7x0:
574 OHingeStatus hs = readHingeSensor(); 534 OHingeStatus hs = readHingeSensor();
575 if ( hs == CASE_PORTRAIT ) dir = CCW; 535 if ( hs == CASE_PORTRAIT ) dir = CCW;
576 else if ( hs == CASE_UNKNOWN ) dir = CCW; 536 else if ( hs == CASE_UNKNOWN ) dir = CCW;
577 else dir = CW; 537 else dir = CW;
578 break; 538 break;
579 case Model_Zaurus_SL6000: 539 case Model_Zaurus_SL6000:
580 case Model_Zaurus_SLA300: 540 case Model_Zaurus_SLA300:
581 case Model_Zaurus_SLB600: 541 case Model_Zaurus_SLB600:
582 case Model_Zaurus_SL5500: 542 case Model_Zaurus_SL5500:
583 case Model_Zaurus_SL5000: 543 case Model_Zaurus_SL5000:
584 default: dir = d->m_direction; 544 default: dir = d->m_direction;
585 break; 545 break;
586 } 546 }
587 return dir; 547 return dir;
588 548
589} 549}
590 550
591bool Zaurus::hasHingeSensor() const 551bool Zaurus::hasHingeSensor() const
592{ 552{
593 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; 553 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
594} 554}
595 555
596OHingeStatus Zaurus::readHingeSensor() const 556OHingeStatus Zaurus::readHingeSensor() const
597{ 557{
598 if (m_embedix) 558 if (m_embedix)
599 { 559 {
600 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 560 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
601 if (handle == -1) 561 if (handle == -1)
602 { 562 {
603 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 563 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
604 return CASE_UNKNOWN; 564 return CASE_UNKNOWN;
605 } 565 }
606 else 566 else
607 { 567 {
608 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 568 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
609 ::close (handle); 569 ::close (handle);
610 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 570 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
611 { 571 {
612 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 572 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
613 return static_cast<OHingeStatus>( retval ); 573 return static_cast<OHingeStatus>( retval );
614 } 574 }
615 else 575 else
616 { 576 {
617 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 577 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
618 return CASE_UNKNOWN; 578 return CASE_UNKNOWN;
619 } 579 }
620 } 580 }
621 } 581 }
622 else 582 else
623 { 583 {
624 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); 584 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" );
625 return CASE_UNKNOWN; 585 return CASE_UNKNOWN;
626 } 586 }
627} 587}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index c763798..04e73c4 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,138 +1,136 @@
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 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
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_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35#ifndef ARRAY_SIZE 35#ifndef ARRAY_SIZE
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37#endif 37#endif
38 38
39// _IO and friends are only defined in kernel headers ... 39// _IO and friends are only defined in kernel headers ...
40#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 40#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
41#define OD_IO(type,number) OD_IOC(0,type,number,0) 41#define OD_IO(type,number) OD_IOC(0,type,number,0)
42#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 42#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
43#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 43#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
44#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 44#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
45 45
46// Audio 46// Audio
47#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 47#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
48 48
49#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 49#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
50#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 50#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
51 51
52#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 52#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
53#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 53#define SHARP_BUZ_KEYSOUND 2 /* key sound */
54#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 54#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
55 55
56#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 56#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
57#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 57#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
58#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 58#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
59#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 59#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
60#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 60#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
61 61
62// LED 62// LED
63#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 63#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
64#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 64#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
65#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 65#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
66 66
67#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 67#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
68#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 68#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
69#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 69#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
70 70
71// Rotation and Power Management 71// Rotation and Power Management
72#define SHARP_IOCTL_GET_ROTATION 0x413c 72#define SHARP_IOCTL_GET_ROTATION 0x413c
73 73
74#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 74#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
75#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 75#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
76#define APM_EVT_POWER_BUTTON (1 << 0) 76#define APM_EVT_POWER_BUTTON (1 << 0)
77 77
78// Brightness 78// Brightness
79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" 79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
80#define SHARP_FL_IOCTL_ON 1 80#define SHARP_FL_IOCTL_ON 1
81#define SHARP_FL_IOCTL_OFF 2 81#define SHARP_FL_IOCTL_OFF 2
82#define SHARP_FL_IOCTL_STEP_CONTRAST 100 82#define SHARP_FL_IOCTL_STEP_CONTRAST 100
83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
84#define SHARP_FL_IOCTL_GET_STEP 102 84#define SHARP_FL_IOCTL_GET_STEP 102
85 85
86namespace Opie { 86namespace Opie {
87namespace Core { 87namespace Core {
88namespace Internal { 88namespace Internal {
89 89
90class Zaurus : public ODevice 90class Zaurus : public ODevice
91{ 91{
92 protected: 92 protected:
93 virtual void init(const QString&); 93 virtual void init(const QString&);
94 virtual void initButtons(); 94 virtual void initButtons();
95 95
96 public: 96 public:
97 virtual bool setSoftSuspend( bool soft );
98
99 virtual bool setDisplayBrightness( int b ); 97 virtual bool setDisplayBrightness( int b );
100 virtual bool setDisplayStatus( bool on ); 98 virtual bool setDisplayStatus( bool on );
101 virtual int displayBrightnessResolution() const; 99 virtual int displayBrightnessResolution() const;
102 100
103 virtual void playAlarmSound(); 101 virtual void playAlarmSound();
104 virtual void playKeySound(); 102 virtual void playKeySound();
105 virtual void playTouchSound(); 103 virtual void playTouchSound();
106 104
107 virtual QValueList <OLed> ledList() const; 105 virtual QValueList <OLed> ledList() const;
108 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 106 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
109 virtual OLedState ledState( OLed led ) const; 107 virtual OLedState ledState( OLed led ) const;
110 virtual bool setLedState( OLed led, OLedState st ); 108 virtual bool setLedState( OLed led, OLedState st );
111 109
112 virtual bool hasHingeSensor() const; 110 virtual bool hasHingeSensor() const;
113 virtual OHingeStatus readHingeSensor() const; 111 virtual OHingeStatus readHingeSensor() const;
114 112
115 virtual bool suspend(); 113 virtual bool suspend();
116 virtual Transformation rotation() const; 114 virtual Transformation rotation() const;
117 virtual ODirection direction() const; 115 virtual ODirection direction() const;
118 116
119 protected: 117 protected:
120 virtual void buzzer( int snd ); 118 virtual void buzzer( int snd );
121 119
122 OLedState m_leds[1]; 120 OLedState m_leds[1];
123 bool m_embedix; 121 bool m_embedix;
124}; 122};
125 123
126struct z_button { 124struct z_button {
127 Qt::Key code; 125 Qt::Key code;
128 char *utext; 126 char *utext;
129 char *pix; 127 char *pix;
130 char *fpressedservice; 128 char *fpressedservice;
131 char *fpressedaction; 129 char *fpressedaction;
132 char *fheldservice; 130 char *fheldservice;
133 char *fheldaction; 131 char *fheldaction;
134}; 132};
135} 133}
136} 134}
137} 135}
138#endif 136#endif