summaryrefslogtreecommitdiff
authorgroucho <groucho>2003-03-19 11:36:34 (UTC)
committer groucho <groucho>2003-03-19 11:36:34 (UTC)
commit28be0fcc9bda71175c3ee17e79fce2ac24340ff2 (patch) (unidiff)
treef09c80460e4f0219eb308d612a2e67df57f2c254
parent18c6c51705de3b1897f671e54b25929e74d11f23 (diff)
downloadopie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.zip
opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.gz
opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.bz2
Fixed bug #744 where non mapped buttons in buttonsettings were not saved by introducing the "
ignore" statement. Also removed unsed debug code
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp25
-rw-r--r--core/launcher/desktop.h2
-rw-r--r--core/settings/button/buttonsettings.cpp3
-rw-r--r--core/settings/button/buttonutils.cpp3
-rw-r--r--core/settings/button/remapdlg.cpp26
-rw-r--r--libopie/odevice.cpp15
-rw-r--r--libopie/odevicebutton.cpp3
7 files changed, 55 insertions, 22 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 59f2aea..fbcce7c 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,849 +1,858 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <syslog.h> 21#include <syslog.h>
22 22
23#include "desktop.h" 23#include "desktop.h"
24#include "info.h" 24#include "info.h"
25#include "launcher.h" 25#include "launcher.h"
26#include "qcopbridge.h" 26#include "qcopbridge.h"
27#include "shutdownimpl.h" 27#include "shutdownimpl.h"
28#include "startmenu.h" 28#include "startmenu.h"
29#include "taskbar.h" 29#include "taskbar.h"
30#include "transferserver.h" 30#include "transferserver.h"
31#include "irserver.h" 31#include "irserver.h"
32#include "packageslave.h" 32#include "packageslave.h"
33#include "screensaver.h" 33#include "screensaver.h"
34 34
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qpe/mimetype.h> 36#include <qpe/mimetype.h>
37#include <qpe/password.h> 37#include <qpe/password.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qpe/power.h> 39#include <qpe/power.h>
40#include <qpe/timeconversion.h> 40#include <qpe/timeconversion.h>
41#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
42#include <qpe/network.h> 42#include <qpe/network.h>
43#include <qpe/global.h> 43#include <qpe/global.h>
44 44
45#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ ) 45#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ )
46#include <qpe/custom.h> 46#include <qpe/custom.h>
47#endif 47#endif
48 48
49#include <opie/odevice.h> 49#include <opie/odevice.h>
50 50
51#include <qgfx_qws.h> 51#include <qgfx_qws.h>
52#include <qmainwindow.h> 52#include <qmainwindow.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qtimer.h> 54#include <qtimer.h>
55#include <qwindowsystem_qws.h> 55#include <qwindowsystem_qws.h>
56 56
57#include <qvaluelist.h> 57#include <qvaluelist.h>
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60#include <unistd.h> 60#include <unistd.h>
61#include <fcntl.h> 61#include <fcntl.h>
62 62
63 63
64using namespace Opie; 64using namespace Opie;
65 65
66class QCopKeyRegister 66class QCopKeyRegister
67{ 67{
68public: 68public:
69 QCopKeyRegister() : keyCode( 0 ) 69 QCopKeyRegister() : keyCode( 0 )
70 { } 70 { }
71 QCopKeyRegister( int k, const QCString &c, const QCString &m ) 71 QCopKeyRegister( int k, const QCString &c, const QCString &m )
72 : keyCode( k ), channel( c ), message( m ) 72 : keyCode( k ), channel( c ), message( m )
73 { } 73 { }
74 74
75 int getKeyCode() const 75 int getKeyCode() const
76 { 76 {
77 return keyCode; 77 return keyCode;
78 } 78 }
79 QCString getChannel() const 79 QCString getChannel() const
80 { 80 {
81 return channel; 81 return channel;
82 } 82 }
83 QCString getMessage() const 83 QCString getMessage() const
84 { 84 {
85 return message; 85 return message;
86 } 86 }
87 87
88private: 88private:
89 int keyCode; 89 int keyCode;
90 QCString channel, message; 90 QCString channel, message;
91}; 91};
92 92
93typedef QValueList<QCopKeyRegister> KeyRegisterList; 93typedef QValueList<QCopKeyRegister> KeyRegisterList;
94KeyRegisterList keyRegisterList; 94KeyRegisterList keyRegisterList;
95 95
96static Desktop* qpedesktop = 0; 96static Desktop* qpedesktop = 0;
97static int loggedin = 0; 97static int loggedin = 0;
98static void login( bool at_poweron ) 98static void login( bool at_poweron )
99{ 99{
100 if ( !loggedin ) { 100 if ( !loggedin ) {
101 Global::terminateBuiltin( "calibrate" ); 101 Global::terminateBuiltin( "calibrate" );
102 Password::authenticate( at_poweron ); 102 Password::authenticate( at_poweron );
103 loggedin = 1; 103 loggedin = 1;
104 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 104 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
105 } 105 }
106} 106}
107 107
108bool Desktop::screenLocked() 108bool Desktop::screenLocked()
109{ 109{
110 return loggedin == 0; 110 return loggedin == 0;
111} 111}
112 112
113/* 113/*
114 Priority is number of alerts that are needed to pop up 114 Priority is number of alerts that are needed to pop up
115 alert. 115 alert.
116 */ 116 */
117class DesktopPowerAlerter : public QMessageBox 117class DesktopPowerAlerter : public QMessageBox
118{ 118{
119public: 119public:
120 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 120 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
121 : QMessageBox( tr( "Battery Status" ), "Low Battery", 121 : QMessageBox( tr( "Battery Status" ), "Low Battery",
122 QMessageBox::Critical, 122 QMessageBox::Critical,
123 QMessageBox::Ok | QMessageBox::Default, 123 QMessageBox::Ok | QMessageBox::Default,
124 QMessageBox::NoButton, QMessageBox::NoButton, 124 QMessageBox::NoButton, QMessageBox::NoButton,
125 parent, name, FALSE ) 125 parent, name, FALSE )
126 { 126 {
127 currentPriority = INT_MAX; 127 currentPriority = INT_MAX;
128 alertCount = 0; 128 alertCount = 0;
129 } 129 }
130 130
131 void alert( const QString &text, int priority ); 131 void alert( const QString &text, int priority );
132 void hideEvent( QHideEvent * ); 132 void hideEvent( QHideEvent * );
133private: 133private:
134 int currentPriority; 134 int currentPriority;
135 int alertCount; 135 int alertCount;
136}; 136};
137 137
138void DesktopPowerAlerter::alert( const QString &text, int priority ) 138void DesktopPowerAlerter::alert( const QString &text, int priority )
139{ 139{
140 alertCount++; 140 alertCount++;
141 if ( alertCount < priority ) 141 if ( alertCount < priority )
142 return ; 142 return ;
143 if ( priority > currentPriority ) 143 if ( priority > currentPriority )
144 return ; 144 return ;
145 currentPriority = priority; 145 currentPriority = priority;
146 setText( text ); 146 setText( text );
147 show(); 147 show();
148} 148}
149 149
150 150
151void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 151void DesktopPowerAlerter::hideEvent( QHideEvent *e )
152{ 152{
153 QMessageBox::hideEvent( e ); 153 QMessageBox::hideEvent( e );
154 alertCount = 0; 154 alertCount = 0;
155 currentPriority = INT_MAX; 155 currentPriority = INT_MAX;
156} 156}
157 157
158 158
159void DesktopApplication::switchLCD ( bool on ) 159void DesktopApplication::switchLCD ( bool on )
160{ 160{
161 if ( qApp ) { 161 if ( qApp ) {
162 DesktopApplication *dapp = (DesktopApplication *) qApp; 162 DesktopApplication *dapp = (DesktopApplication *) qApp;
163 163
164 if ( dapp-> m_screensaver ) { 164 if ( dapp-> m_screensaver ) {
165 if ( on ) { 165 if ( on ) {
166 dapp-> m_screensaver-> setDisplayState ( true ); 166 dapp-> m_screensaver-> setDisplayState ( true );
167 dapp-> m_screensaver-> setBacklight ( -3 ); 167 dapp-> m_screensaver-> setBacklight ( -3 );
168 } 168 }
169 else { 169 else {
170 dapp-> m_screensaver-> setDisplayState ( false ); 170 dapp-> m_screensaver-> setDisplayState ( false );
171 } 171 }
172 } 172 }
173 } 173 }
174} 174}
175 175
176 176
177DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 177DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
178 : QPEApplication( argc, argv, appType ) 178 : QPEApplication( argc, argv, appType )
179{ 179{
180 m_ps = new PowerStatus; 180 m_ps = new PowerStatus;
181 m_ps_last = new PowerStatus; 181 m_ps_last = new PowerStatus;
182 pa = new DesktopPowerAlerter( 0 ); 182 pa = new DesktopPowerAlerter( 0 );
183 183
184 m_apm_timer = new QTimer ( this ); 184 m_apm_timer = new QTimer ( this );
185 connect ( m_apm_timer, SIGNAL( timeout ( )), this, SLOT( apmTimeout ( ))); 185 connect ( m_apm_timer, SIGNAL( timeout ( )), this, SLOT( apmTimeout ( )));
186 reloadPowerWarnSettings ( ); 186 reloadPowerWarnSettings ( );
187 187
188 m_last_button = 0; 188 m_last_button = 0;
189 m_button_timer = new QTimer ( ); 189 m_button_timer = new QTimer ( );
190 connect ( m_button_timer, SIGNAL( timeout ( )), this, SLOT( sendHeldAction ( ))); 190 connect ( m_button_timer, SIGNAL( timeout ( )), this, SLOT( sendHeldAction ( )));
191 191
192 channel = new QCopChannel( "QPE/System", this ); 192 channel = new QCopChannel( "QPE/System", this );
193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
194 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 194 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
195 195
196 channel = new QCopChannel( "QPE/Launcher", this ); 196 channel = new QCopChannel( "QPE/Launcher", this );
197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
198 this, SLOT( launcherMessage( const QCString&, const QByteArray& ) ) ); 198 this, SLOT( launcherMessage( const QCString&, const QByteArray& ) ) );
199 199
200 m_screensaver = new OpieScreenSaver ( ); 200 m_screensaver = new OpieScreenSaver ( );
201 m_screensaver-> setInterval ( -1 ); 201 m_screensaver-> setInterval ( -1 );
202 QWSServer::setScreenSaver( m_screensaver ); 202 QWSServer::setScreenSaver( m_screensaver );
203 203
204 rereadVolumes(); 204 rereadVolumes();
205 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); 205 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
206 206
207 apmTimeout ( ); 207 apmTimeout ( );
208 208
209 grabKeyboard ( ); 209 grabKeyboard ( );
210} 210}
211 211
212 212
213DesktopApplication::~DesktopApplication() 213DesktopApplication::~DesktopApplication()
214{ 214{
215 ungrabKeyboard ( ); 215 ungrabKeyboard ( );
216 216
217 delete m_ps; 217 delete m_ps;
218 delete m_ps_last; 218 delete m_ps_last;
219 delete pa; 219 delete pa;
220} 220}
221 221
222void DesktopApplication::apmTimeout() 222void DesktopApplication::apmTimeout()
223{ 223{
224 qpedesktop-> checkMemory ( ); // in case no events are being generated 224 qpedesktop-> checkMemory ( ); // in case no events are being generated
225 225
226 *m_ps_last = *m_ps; 226 *m_ps_last = *m_ps;
227 *m_ps = PowerStatusManager::readStatus(); 227 *m_ps = PowerStatusManager::readStatus();
228 228
229 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) 229 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( ))
230 m_screensaver-> powerStatusChanged ( *m_ps ); 230 m_screensaver-> powerStatusChanged ( *m_ps );
231 231
232 if ( m_ps-> acStatus ( ) != PowerStatus::Online ) { 232 if ( m_ps-> acStatus ( ) != PowerStatus::Online ) {
233 int bat = m_ps-> batteryPercentRemaining ( ); 233 int bat = m_ps-> batteryPercentRemaining ( );
234 234
235 if ( bat < m_ps_last-> batteryPercentRemaining ( )) { 235 if ( bat < m_ps_last-> batteryPercentRemaining ( )) {
236 if ( bat <= m_powerCritical ) 236 if ( bat <= m_powerCritical )
237 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); 237 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 );
238 else if ( bat <= m_powerVeryLow ) 238 else if ( bat <= m_powerVeryLow )
239 pa->alert( tr( "Battery is running very low." ), 2 ); 239 pa->alert( tr( "Battery is running very low." ), 2 );
240 } 240 }
241 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) 241 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow )
242 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); 242 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 );
243 } 243 }
244} 244}
245 245
246 246
247void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 247void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
248{ 248{
249 QDataStream stream ( data, IO_ReadOnly ); 249 QDataStream stream ( data, IO_ReadOnly );
250 250
251 if ( msg == "setScreenSaverInterval(int)" ) { 251 if ( msg == "setScreenSaverInterval(int)" ) {
252 int time; 252 int time;
253 stream >> time; 253 stream >> time;
254 m_screensaver-> setInterval( time ); 254 m_screensaver-> setInterval( time );
255 } 255 }
256 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 256 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
257 int t1, t2, t3; 257 int t1, t2, t3;
258 stream >> t1 >> t2 >> t3; 258 stream >> t1 >> t2 >> t3;
259 m_screensaver-> setIntervals( t1, t2, t3 ); 259 m_screensaver-> setIntervals( t1, t2, t3 );
260 } 260 }
261 else if ( msg == "setBacklight(int)" ) { 261 else if ( msg == "setBacklight(int)" ) {
262 int bright; 262 int bright;
263 stream >> bright; 263 stream >> bright;
264 m_screensaver-> setBacklight( bright ); 264 m_screensaver-> setBacklight( bright );
265 } 265 }
266 else if ( msg == "setScreenSaverMode(int)" ) { 266 else if ( msg == "setScreenSaverMode(int)" ) {
267 int mode; 267 int mode;
268 stream >> mode; 268 stream >> mode;
269 m_screensaver-> setMode ( mode ); 269 m_screensaver-> setMode ( mode );
270 } 270 }
271 else if ( msg == "reloadPowerWarnSettings()" ) { 271 else if ( msg == "reloadPowerWarnSettings()" ) {
272 reloadPowerWarnSettings(); 272 reloadPowerWarnSettings();
273 } 273 }
274 else if ( msg == "setDisplayState(int)" ) { 274 else if ( msg == "setDisplayState(int)" ) {
275 int state; 275 int state;
276 stream >> state; 276 stream >> state;
277 m_screensaver-> setDisplayState ( state != 0 ); 277 m_screensaver-> setDisplayState ( state != 0 );
278 } 278 }
279 else if ( msg == "suspend()" ) { 279 else if ( msg == "suspend()" ) {
280 emit power(); 280 emit power();
281 } 281 }
282 else if ( msg == "sendBusinessCard()" ) { 282 else if ( msg == "sendBusinessCard()" ) {
283 QString card = ::getenv ( "HOME" ); 283 QString card = ::getenv ( "HOME" );
284 card += "/Applications/addressbook/businesscard.vcf"; 284 card += "/Applications/addressbook/businesscard.vcf";
285 285
286 if ( QFile::exists( card ) ) { 286 if ( QFile::exists( card ) ) {
287 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); 287 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
288 QString mimetype = "text/x-vCard"; 288 QString mimetype = "text/x-vCard";
289 e << tr( "business card" ) << card << mimetype; 289 e << tr( "business card" ) << card << mimetype;
290 } 290 }
291 } 291 }
292} 292}
293 293
294void DesktopApplication::reloadPowerWarnSettings ( ) 294void DesktopApplication::reloadPowerWarnSettings ( )
295{ 295{
296 Config cfg ( "apm" ); 296 Config cfg ( "apm" );
297 cfg. setGroup ( "Warnings" ); 297 cfg. setGroup ( "Warnings" );
298 298
299 int iv = cfg. readNumEntry ( "checkinterval", 10000 ); 299 int iv = cfg. readNumEntry ( "checkinterval", 10000 );
300 300
301 m_apm_timer-> stop ( ); 301 m_apm_timer-> stop ( );
302 if ( iv ) 302 if ( iv )
303 m_apm_timer-> start ( iv ); 303 m_apm_timer-> start ( iv );
304 304
305 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); 305 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
306 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); 306 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
307} 307}
308 308
309 309
310enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 310enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
311 311
312 312
313void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) 313void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data )
314{ 314{
315 QDataStream stream ( data, IO_ReadOnly ); 315 QDataStream stream ( data, IO_ReadOnly );
316 316
317 if ( msg == "deviceButton(int,int,int)" ) { 317 if ( msg == "deviceButton(int,int,int)" ) {
318 int keycode, press, autoRepeat; 318 int keycode, press, autoRepeat;
319 stream >> keycode >> press >> autoRepeat; 319 stream >> keycode >> press >> autoRepeat;
320 320
321 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); 321 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode );
322 322
323 if ( db ) 323 if ( db )
324 checkButtonAction ( db, keycode, press, autoRepeat ); 324 checkButtonAction ( db, keycode, press, autoRepeat );
325 } 325 }
326 else if ( msg == "keyRegister(int,QCString,QCString)" ) { 326 else if ( msg == "keyRegister(int,QCString,QCString)" ) {
327 int k; 327 int k;
328 QCString c, m; 328 QCString c, m;
329 stream >> k >> c >> m; 329 stream >> k >> c >> m;
330 330
331 keyRegisterList.append ( QCopKeyRegister ( k, c, m )); 331 keyRegisterList.append ( QCopKeyRegister ( k, c, m ));
332 } 332 }
333} 333}
334 334
335void DesktopApplication::sendHeldAction ( ) 335void DesktopApplication::sendHeldAction ( )
336{ 336{
337 if ( m_last_button ) { 337 if ( m_last_button ) {
338 m_last_button-> heldAction ( ). send ( ); 338 m_last_button-> heldAction ( ). send ( );
339 m_last_button = 0; 339 m_last_button = 0;
340 } 340 }
341} 341}
342 342
343 343
344 344
345void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) 345bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat )
346 { 346 {
347 if ( db ) { 347 if ( db ) {
348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { 348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) {
349 m_button_timer-> stop ( ); 349 m_button_timer-> stop ( );
350 if ( !db-> pressedAction ( ). channel ( ). isEmpty ( )) { 350
351 db-> pressedAction ( ). send ( ); 351 if (!db-> pressedAction ( ). channel ( ) .isEmpty())
352 {
353 if ( db-> pressedAction ( ). channel ( )!="ignore") {
354 db-> pressedAction ( ). send ( );
355 }
356 else return false;
352 } 357 }
353 } 358 }
354 else if ( press && !autoRepeat ) { 359 else if ( press && !autoRepeat ) {
355 m_button_timer-> stop ( ); 360 m_button_timer-> stop ( );
361 if (!db-> pressedAction ( ). channel ( ) .isEmpty())
362 {
356 363
357 if ( !db-> heldAction ( ). channel ( ). isEmpty ( )) { 364 if ( db-> heldAction ( ). channel ( )!="ignore") {
358 m_last_button = db; 365 m_last_button = db;
359 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); 366 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true );
367 }
368 else return false;
360 } 369 }
361 } 370 }
362 } 371 }
372 return true;
363} 373}
364 374
365bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) 375bool DesktopApplication::eventFilter ( QObject *o, QEvent *e )
366{ 376{
367 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { 377 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
368 QKeyEvent *ke = (QKeyEvent *) e; 378 QKeyEvent *ke = (QKeyEvent *) e;
369 379
370 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); 380 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
371 381
372 if ( db ) { 382 if ( db ) {
373 checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); 383 return checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( ));
374 return true;
375 } 384 }
376 } 385 }
377 return QPEApplication::eventFilter ( o, e ); 386 return QPEApplication::eventFilter ( o, e );
378} 387}
379 388
380#ifdef Q_WS_QWS 389#ifdef Q_WS_QWS
381 390
382bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 391bool DesktopApplication::qwsEventFilter( QWSEvent *e )
383{ 392{
384 qpedesktop->checkMemory(); 393 qpedesktop->checkMemory();
385 394
386 if ( e->type == QWSEvent::Key ) { 395 if ( e->type == QWSEvent::Key ) {
387 QWSKeyEvent * ke = (QWSKeyEvent *) e; 396 QWSKeyEvent * ke = (QWSKeyEvent *) e;
388 ushort keycode = ke-> simpleData. keycode; 397 ushort keycode = ke-> simpleData. keycode;
389 398
390 if ( !loggedin && keycode != Key_F34 ) 399 if ( !loggedin && keycode != Key_F34 )
391 return true; 400 return true;
392 401
393 bool press = ke-> simpleData. is_press; 402 bool press = ke-> simpleData. is_press;
394 bool autoRepeat = ke-> simpleData. is_auto_repeat; 403 bool autoRepeat = ke-> simpleData. is_auto_repeat;
395 404
396 if ( !keyboardGrabbed ( )) { 405 if ( !keyboardGrabbed ( )) {
397 // app that registers key/message to be sent back to the app, when it doesn't have focus, 406 // app that registers key/message to be sent back to the app, when it doesn't have focus,
398 // when user presses key, unless keyboard has been requested from app. 407 // when user presses key, unless keyboard has been requested from app.
399 // will not send multiple repeats if user holds key 408 // will not send multiple repeats if user holds key
400 // i.e. one shot 409 // i.e. one shot
401 410
402 if ( keycode != 0 && press && !autoRepeat ) { 411 if ( keycode != 0 && press && !autoRepeat ) {
403 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 412 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
404 if (( *it ). getKeyCode ( ) == keycode ) { 413 if (( *it ). getKeyCode ( ) == keycode ) {
405 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); 414 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( ));
406 return true; 415 return true;
407 } 416 }
408 } 417 }
409 } 418 }
410 } 419 }
411 420
412 if ( keycode == HardKey_Suspend ) { 421 if ( keycode == HardKey_Suspend ) {
413 if ( press ) 422 if ( press )
414 emit power ( ); 423 emit power ( );
415 return true; 424 return true;
416 } 425 }
417 else if ( keycode == HardKey_Backlight ) { 426 else if ( keycode == HardKey_Backlight ) {
418 if ( press ) 427 if ( press )
419 emit backlight ( ); 428 emit backlight ( );
420 return true; 429 return true;
421 } 430 }
422 else if ( keycode == Key_F32 ) { 431 else if ( keycode == Key_F32 ) {
423 if ( press ) 432 if ( press )
424 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 433 QCopEnvelope e( "QPE/Desktop", "startSync()" );
425 return true; 434 return true;
426 } 435 }
427 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM 436 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM
428 if ( press ) 437 if ( press )
429 emit symbol ( ); 438 emit symbol ( );
430 return true; 439 return true;
431 } 440 }
432 else if ( keycode == Key_NumLock ) { 441 else if ( keycode == Key_NumLock ) {
433 if ( press ) 442 if ( press )
434 emit numLockStateToggle ( ); 443 emit numLockStateToggle ( );
435 } 444 }
436 else if ( keycode == Key_CapsLock ) { 445 else if ( keycode == Key_CapsLock ) {
437 if ( press ) 446 if ( press )
438 emit capsLockStateToggle(); 447 emit capsLockStateToggle();
439 } 448 }
440 if (( press && !autoRepeat ) || ( !press && autoRepeat )) { 449 if (( press && !autoRepeat ) || ( !press && autoRepeat )) {
441 if ( m_keyclick_sound ) 450 if ( m_keyclick_sound )
442 ODevice::inst ( )-> keySound ( ); 451 ODevice::inst ( )-> keySound ( );
443 } 452 }
444 } 453 }
445 else if ( e-> type == QWSEvent::Mouse ) { 454 else if ( e-> type == QWSEvent::Mouse ) {
446 QWSMouseEvent * me = ( QWSMouseEvent * ) e; 455 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
447 static bool up = true; 456 static bool up = true;
448 457
449 if ( me-> simpleData. state & LeftButton ) { 458 if ( me-> simpleData. state & LeftButton ) {
450 if ( up ) { 459 if ( up ) {
451 up = false; 460 up = false;
452 if ( m_screentap_sound ) 461 if ( m_screentap_sound )
453 ODevice::inst ( ) -> touchSound ( ); 462 ODevice::inst ( ) -> touchSound ( );
454 } 463 }
455 } 464 }
456 else { 465 else {
457 up = true; 466 up = true;
458 } 467 }
459 } 468 }
460 469
461 return QPEApplication::qwsEventFilter ( e ); 470 return QPEApplication::qwsEventFilter ( e );
462} 471}
463#endif 472#endif
464 473
465 474
466 475
467#if defined(QPE_HAVE_MEMALERTER) 476#if defined(QPE_HAVE_MEMALERTER)
468QPE_MEMALERTER_IMPL 477QPE_MEMALERTER_IMPL
469#endif 478#endif
470 479
471//=========================================================================== 480//===========================================================================
472 481
473Desktop::Desktop() : 482Desktop::Desktop() :
474 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 483 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
475 qcopBridge( 0 ), 484 qcopBridge( 0 ),
476 transferServer( 0 ), 485 transferServer( 0 ),
477 packageSlave( 0 ) 486 packageSlave( 0 )
478{ 487{
479 qpedesktop = this; 488 qpedesktop = this;
480 489
481 // bg = new Info( this ); 490 // bg = new Info( this );
482 tb = new TaskBar; 491 tb = new TaskBar;
483 492
484 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 493 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
485 494
486 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); 495 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
487 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); 496 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
488 497
489 int displayw = qApp->desktop() ->width(); 498 int displayw = qApp->desktop() ->width();
490 int displayh = qApp->desktop() ->height(); 499 int displayh = qApp->desktop() ->height();
491 500
492 501
493 QSize sz = tb->sizeHint(); 502 QSize sz = tb->sizeHint();
494 503
495 setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 504 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
496 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 505 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
497 506
498 tb->show(); 507 tb->show();
499 launcher->showMaximized(); 508 launcher->showMaximized();
500 launcher->show(); 509 launcher->show();
501 launcher->raise(); 510 launcher->raise();
502#if defined(QPE_HAVE_MEMALERTER) 511#if defined(QPE_HAVE_MEMALERTER)
503 512
504 initMemalerter(); 513 initMemalerter();
505#endif 514#endif
506 // start services 515 // start services
507 startTransferServer(); 516 startTransferServer();
508 ( void ) new IrServer( this ); 517 ( void ) new IrServer( this );
509 518
510 packageSlave = new PackageSlave( this ); 519 packageSlave = new PackageSlave( this );
511 520
512 qApp->installEventFilter( this ); 521 qApp->installEventFilter( this );
513 522
514 qApp-> setMainWidget ( launcher ); 523 qApp-> setMainWidget ( launcher );
515} 524}
516 525
517void Desktop::show() 526void Desktop::show()
518{ 527{
519 login( TRUE ); 528 login( TRUE );
520 QWidget::show(); 529 QWidget::show();
521} 530}
522 531
523Desktop::~Desktop() 532Desktop::~Desktop()
524{ 533{
525 delete launcher; 534 delete launcher;
526 delete tb; 535 delete tb;
527 delete qcopBridge; 536 delete qcopBridge;
528 delete transferServer; 537 delete transferServer;
529} 538}
530 539
531bool Desktop::recoverMemory() 540bool Desktop::recoverMemory()
532{ 541{
533 return tb->recoverMemory(); 542 return tb->recoverMemory();
534} 543}
535 544
536void Desktop::checkMemory() 545void Desktop::checkMemory()
537{ 546{
538#if defined(QPE_HAVE_MEMALERTER) 547#if defined(QPE_HAVE_MEMALERTER)
539 static bool ignoreNormal = FALSE; 548 static bool ignoreNormal = FALSE;
540 static bool existingMessage = FALSE; 549 static bool existingMessage = FALSE;
541 550
542 if ( existingMessage ) 551 if ( existingMessage )
543 return ; // don't show a second message while still on first 552 return ; // don't show a second message while still on first
544 553
545 existingMessage = TRUE; 554 existingMessage = TRUE;
546 switch ( memstate ) { 555 switch ( memstate ) {
547 case Unknown: 556 case Unknown:
548 break; 557 break;
549 case Low: 558 case Low:
550 memstate = Unknown; 559 memstate = Unknown;
551 if ( recoverMemory() ) 560 if ( recoverMemory() )
552 ignoreNormal = TRUE; 561 ignoreNormal = TRUE;
553 else 562 else
554 QMessageBox::warning( 0 , "Memory Status", 563 QMessageBox::warning( 0 , "Memory Status",
555 "The memory smacks of shortage. \n" 564 "The memory smacks of shortage. \n"
556 "Please save data. " ); 565 "Please save data. " );
557 break; 566 break;
558 case Normal: 567 case Normal:
559 memstate = Unknown; 568 memstate = Unknown;
560 if ( ignoreNormal ) 569 if ( ignoreNormal )
561 ignoreNormal = FALSE; 570 ignoreNormal = FALSE;
562 // else 571 // else
563 // QMessageBox::information ( 0 , "Memory Status", 572 // QMessageBox::information ( 0 , "Memory Status",
564 // "There is enough memory again." ); 573 // "There is enough memory again." );
565 break; 574 break;
566 case VeryLow: 575 case VeryLow:
567 memstate = Unknown; 576 memstate = Unknown;
568 QMessageBox::critical( 0 , "Memory Status", 577 QMessageBox::critical( 0 , "Memory Status",
569 "The memory is very low. \n" 578 "The memory is very low. \n"
570 "Please end this application \n" 579 "Please end this application \n"
571 "immediately." ); 580 "immediately." );
572 recoverMemory(); 581 recoverMemory();
573 } 582 }
574 existingMessage = FALSE; 583 existingMessage = FALSE;
575#endif 584#endif
576} 585}
577 586
578static bool isVisibleWindow( int wid ) 587static bool isVisibleWindow( int wid )
579{ 588{
580#ifdef QWS 589#ifdef QWS
581 const QList<QWSWindow> &list = qwsServer->clientWindows(); 590 const QList<QWSWindow> &list = qwsServer->clientWindows();
582 QWSWindow* w; 591 QWSWindow* w;
583 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 592 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
584 if ( w->winId() == wid ) 593 if ( w->winId() == wid )
585 return !w->isFullyObscured(); 594 return !w->isFullyObscured();
586 } 595 }
587#endif 596#endif
588 return FALSE; 597 return FALSE;
589} 598}
590 599
591static bool hasVisibleWindow( const QString& clientname ) 600static bool hasVisibleWindow( const QString& clientname )
592{ 601{
593#ifdef QWS 602#ifdef QWS
594 const QList<QWSWindow> &list = qwsServer->clientWindows(); 603 const QList<QWSWindow> &list = qwsServer->clientWindows();
595 QWSWindow* w; 604 QWSWindow* w;
596 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 605 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
597 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 606 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
598 return TRUE; 607 return TRUE;
599 } 608 }
600#endif 609#endif
601 return FALSE; 610 return FALSE;
602} 611}
603 612
604 613
605void Desktop::executeOrModify( const QString& appLnkFile ) 614void Desktop::executeOrModify( const QString& appLnkFile )
606{ 615{
607 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 616 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
608 if ( lnk.isValid() ) { 617 if ( lnk.isValid() ) {
609 QCString app = lnk.exec().utf8(); 618 QCString app = lnk.exec().utf8();
610 Global::terminateBuiltin( "calibrate" ); 619 Global::terminateBuiltin( "calibrate" );
611 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 620 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
612 // MRUList::addTask( &lnk ); 621 // MRUList::addTask( &lnk );
613 if ( hasVisibleWindow( app ) ) 622 if ( hasVisibleWindow( app ) )
614 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 623 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
615 else 624 else
616 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 625 QCopChannel::send( "QPE/Application/" + app, "raise()" );
617 } 626 }
618 else { 627 else {
619 lnk.execute(); 628 lnk.execute();
620 } 629 }
621 } 630 }
622} 631}
623 632
624// autoStarts apps on resume and start 633// autoStarts apps on resume and start
625void Desktop::execAutoStart() 634void Desktop::execAutoStart()
626{ 635{
627 QString appName; 636 QString appName;
628 int delay; 637 int delay;
629 QDateTime now = QDateTime::currentDateTime(); 638 QDateTime now = QDateTime::currentDateTime();
630 Config cfg( "autostart" ); 639 Config cfg( "autostart" );
631 cfg.setGroup( "AutoStart" ); 640 cfg.setGroup( "AutoStart" );
632 appName = cfg.readEntry( "Apps", "" ); 641 appName = cfg.readEntry( "Apps", "" );
633 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 642 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
634 // If the time between suspend and resume was longer then the 643 // If the time between suspend and resume was longer then the
635 // value saved as delay, start the app 644 // value saved as delay, start the app
636 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 645 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
637 QCopEnvelope e( "QPE/System", "execute(QString)" ); 646 QCopEnvelope e( "QPE/System", "execute(QString)" );
638 e << QString( appName ); 647 e << QString( appName );
639 } 648 }
640} 649}
641 650
642#if defined(QPE_HAVE_TOGGLELIGHT) 651#if defined(QPE_HAVE_TOGGLELIGHT)
643#include <qpe/config.h> 652#include <qpe/config.h>
644 653
645#include <sys/ioctl.h> 654#include <sys/ioctl.h>
646#include <sys/types.h> 655#include <sys/types.h>
647#include <fcntl.h> 656#include <fcntl.h>
648#include <unistd.h> 657#include <unistd.h>
649#include <errno.h> 658#include <errno.h>
650#include <linux/ioctl.h> 659#include <linux/ioctl.h>
651#include <time.h> 660#include <time.h>
652#endif 661#endif
653 662
654 663
655void Desktop::togglePower() 664void Desktop::togglePower()
656{ 665{
657 static bool excllock = false; 666 static bool excllock = false;
658 667
659 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); 668 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
660 669
661 if ( excllock ) 670 if ( excllock )
662 return ; 671 return ;
663 672
664 excllock = true; 673 excllock = true;
665 674
666 bool wasloggedin = loggedin; 675 bool wasloggedin = loggedin;
667 loggedin = 0; 676 loggedin = 0;
668 suspendTime = QDateTime::currentDateTime(); 677 suspendTime = QDateTime::currentDateTime();
669 678
670#ifdef QWS 679#ifdef QWS
671 680
672 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 681 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
673 // Should use a big black window instead. 682 // Should use a big black window instead.
674 // But this would not show up fast enough 683 // But this would not show up fast enough
675 QGfx *g = qt_screen-> screenGfx ( ); 684 QGfx *g = qt_screen-> screenGfx ( );
676 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 685 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
677 delete g; 686 delete g;
678 } 687 }
679#endif 688#endif
680 689
681 ODevice::inst ( )-> suspend ( ); 690 ODevice::inst ( )-> suspend ( );
682 691
683 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 692 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
684 QWSServer::screenSaverActivate ( false ); 693 QWSServer::screenSaverActivate ( false );
685 694
686 { 695 {
687 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 696 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
688 } 697 }
689 698
690 if ( wasloggedin ) 699 if ( wasloggedin )
691 login ( true ); 700 login ( true );
692 701
693 execAutoStart(); 702 execAutoStart();
694 //qcopBridge->closeOpenConnections(); 703 //qcopBridge->closeOpenConnections();
695 704
696 excllock = false; 705 excllock = false;
697} 706}
698 707
699void Desktop::toggleLight() 708void Desktop::toggleLight()
700{ 709{
701 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 710 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
702 e << -2; // toggle 711 e << -2; // toggle
703} 712}
704 713
705void Desktop::toggleSymbolInput() 714void Desktop::toggleSymbolInput()
706{ 715{
707 tb->toggleSymbolInput(); 716 tb->toggleSymbolInput();
708} 717}
709 718
710void Desktop::toggleNumLockState() 719void Desktop::toggleNumLockState()
711{ 720{
712 tb->toggleNumLockState(); 721 tb->toggleNumLockState();
713} 722}
714 723
715void Desktop::toggleCapsLockState() 724void Desktop::toggleCapsLockState()
716{ 725{
717 tb->toggleCapsLockState(); 726 tb->toggleCapsLockState();
718} 727}
719 728
720void Desktop::styleChange( QStyle &s ) 729void Desktop::styleChange( QStyle &s )
721{ 730{
722 QWidget::styleChange( s ); 731 QWidget::styleChange( s );
723 int displayw = qApp->desktop() ->width(); 732 int displayw = qApp->desktop() ->width();
724 int displayh = qApp->desktop() ->height(); 733 int displayh = qApp->desktop() ->height();
725 734
726 QSize sz = tb->sizeHint(); 735 QSize sz = tb->sizeHint();
727 736
728 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 737 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
729} 738}
730 739
731void DesktopApplication::shutdown() 740void DesktopApplication::shutdown()
732{ 741{
733 if ( type() != GuiServer ) 742 if ( type() != GuiServer )
734 return ; 743 return ;
735 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 744 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
736 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 745 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
737 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 746 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
738 sd->showMaximized(); 747 sd->showMaximized();
739} 748}
740 749
741void DesktopApplication::shutdown( ShutdownImpl::Type t ) 750void DesktopApplication::shutdown( ShutdownImpl::Type t )
742{ 751{
743 char *opt = 0; 752 char *opt = 0;
744 753
745 switch ( t ) { 754 switch ( t ) {
746 case ShutdownImpl::ShutdownSystem: 755 case ShutdownImpl::ShutdownSystem:
747 opt = "-h"; 756 opt = "-h";
748 // fall through 757 // fall through
749 case ShutdownImpl::RebootSystem: 758 case ShutdownImpl::RebootSystem:
750 if ( opt == 0 ) 759 if ( opt == 0 )
751 opt = "-r"; 760 opt = "-r";
752 761
753 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) 762 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 )
754 perror("shutdown"); 763 perror("shutdown");
755 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); 764 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" );
756 765
757 break; 766 break;
758 case ShutdownImpl::RestartDesktop: 767 case ShutdownImpl::RestartDesktop:
759 restart(); 768 restart();
760 break; 769 break;
761 case ShutdownImpl::TerminateDesktop: 770 case ShutdownImpl::TerminateDesktop:
762 prepareForTermination( FALSE ); 771 prepareForTermination( FALSE );
763 772
764 // This is a workaround for a Qt bug 773 // This is a workaround for a Qt bug
765 // clipboard applet has to stop its poll timer, or Qt/E 774 // clipboard applet has to stop its poll timer, or Qt/E
766 // will hang on quit() right before it emits aboutToQuit() 775 // will hang on quit() right before it emits aboutToQuit()
767 emit aboutToQuit ( ); 776 emit aboutToQuit ( );
768 777
769 quit(); 778 quit();
770 break; 779 break;
771 } 780 }
772} 781}
773 782
774void DesktopApplication::restart() 783void DesktopApplication::restart()
775{ 784{
776 prepareForTermination( TRUE ); 785 prepareForTermination( TRUE );
777 786
778#ifdef Q_WS_QWS 787#ifdef Q_WS_QWS
779 788
780 for ( int fd = 3; fd < 100; fd++ ) 789 for ( int fd = 3; fd < 100; fd++ )
781 close( fd ); 790 close( fd );
782#if defined(QT_DEMO_SINGLE_FLOPPY) 791#if defined(QT_DEMO_SINGLE_FLOPPY)
783 792
784 execl( "/sbin/init", "qpe", 0 ); 793 execl( "/sbin/init", "qpe", 0 );
785#elif defined(QT_QWS_CASSIOPEIA) 794#elif defined(QT_QWS_CASSIOPEIA)
786 795
787 execl( "/bin/sh", "sh", 0 ); 796 execl( "/bin/sh", "sh", 0 );
788#else 797#else
789 798
790 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 799 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
791#endif 800#endif
792 801
793 exit( 1 ); 802 exit( 1 );
794#endif 803#endif
795} 804}
796 805
797void Desktop::startTransferServer() 806void Desktop::startTransferServer()
798{ 807{
799 // start qcop bridge server 808 // start qcop bridge server
800 qcopBridge = new QCopBridge( 4243 ); 809 qcopBridge = new QCopBridge( 4243 );
801 if ( !qcopBridge->ok() ) { 810 if ( !qcopBridge->ok() ) {
802 delete qcopBridge; 811 delete qcopBridge;
803 qcopBridge = 0; 812 qcopBridge = 0;
804 } 813 }
805 // start transfer server 814 // start transfer server
806 transferServer = new TransferServer( 4242 ); 815 transferServer = new TransferServer( 4242 );
807 if ( !transferServer->ok() ) { 816 if ( !transferServer->ok() ) {
808 delete transferServer; 817 delete transferServer;
809 transferServer = 0; 818 transferServer = 0;
810 } 819 }
811 if ( !transferServer || !qcopBridge ) 820 if ( !transferServer || !qcopBridge )
812 startTimer( 2000 ); 821 startTimer( 2000 );
813} 822}
814 823
815void Desktop::timerEvent( QTimerEvent *e ) 824void Desktop::timerEvent( QTimerEvent *e )
816{ 825{
817 killTimer( e->timerId() ); 826 killTimer( e->timerId() );
818 startTransferServer(); 827 startTransferServer();
819} 828}
820 829
821void Desktop::terminateServers() 830void Desktop::terminateServers()
822{ 831{
823 delete transferServer; 832 delete transferServer;
824 delete qcopBridge; 833 delete qcopBridge;
825 transferServer = 0; 834 transferServer = 0;
826 qcopBridge = 0; 835 qcopBridge = 0;
827} 836}
828 837
829void DesktopApplication::rereadVolumes() 838void DesktopApplication::rereadVolumes()
830{ 839{
831 Config cfg( "qpe" ); 840 Config cfg( "qpe" );
832 cfg. setGroup ( "Volume" ); 841 cfg. setGroup ( "Volume" );
833 842
834 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); 843 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
835 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); 844 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
836 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); 845 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
837} 846}
838 847
839void DesktopApplication::soundAlarm() 848void DesktopApplication::soundAlarm()
840{ 849{
841 if ( me ( )-> m_alarm_sound ) 850 if ( me ( )-> m_alarm_sound )
842 ODevice::inst ( )-> alarmSound ( ); 851 ODevice::inst ( )-> alarmSound ( );
843} 852}
844 853
845DesktopApplication *DesktopApplication::me ( ) 854DesktopApplication *DesktopApplication::me ( )
846{ 855{
847 return (DesktopApplication *) qApp; 856 return (DesktopApplication *) qApp;
848} 857}
849 858
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index db0173e..4024c38 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -1,155 +1,155 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __DESKTOP_H__ 21#ifndef __DESKTOP_H__
22#define __DESKTOP_H__ 22#define __DESKTOP_H__
23 23
24 24
25#include "shutdownimpl.h" 25#include "shutdownimpl.h"
26 26
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <opie/odevicebutton.h> 28#include <opie/odevicebutton.h>
29 29
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32 32
33class Background; 33class Background;
34class Launcher; 34class Launcher;
35class TaskBar; 35class TaskBar;
36class PowerStatus; 36class PowerStatus;
37class QCopBridge; 37class QCopBridge;
38class TransferServer; 38class TransferServer;
39class DesktopPowerAlerter; 39class DesktopPowerAlerter;
40class PackageSlave; 40class PackageSlave;
41class OpieScreenSaver; 41class OpieScreenSaver;
42 42
43class DesktopApplication : public QPEApplication 43class DesktopApplication : public QPEApplication
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 DesktopApplication( int& argc, char **argv, Type t ); 47 DesktopApplication( int& argc, char **argv, Type t );
48 ~DesktopApplication(); 48 ~DesktopApplication();
49 49
50 static void switchLCD ( bool on ); // only for togglePower in Desktop 50 static void switchLCD ( bool on ); // only for togglePower in Desktop
51 51
52 static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar 52 static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar
53 53
54signals: 54signals:
55 void menu(); 55 void menu();
56 void home(); 56 void home();
57 void launch(); 57 void launch();
58 void backlight(); 58 void backlight();
59 void power(); 59 void power();
60 void symbol(); 60 void symbol();
61 void numLockStateToggle(); 61 void numLockStateToggle();
62 void capsLockStateToggle(); 62 void capsLockStateToggle();
63 void prepareForRestart(); 63 void prepareForRestart();
64 64
65protected: 65protected:
66#ifdef Q_WS_QWS 66#ifdef Q_WS_QWS
67 67
68 bool qwsEventFilter( QWSEvent * ); 68 bool qwsEventFilter( QWSEvent * );
69#endif 69#endif
70 70
71 void shutdown(); 71 void shutdown();
72 void restart(); 72 void restart();
73 73
74public slots: 74public slots:
75 virtual void systemMessage ( const QCString &msg, const QByteArray &data ); 75 virtual void systemMessage ( const QCString &msg, const QByteArray &data );
76 virtual void launcherMessage ( const QCString &msg, const QByteArray &data ); 76 virtual void launcherMessage ( const QCString &msg, const QByteArray &data );
77 void rereadVolumes(); 77 void rereadVolumes();
78 78
79protected slots: 79protected slots:
80 void shutdown ( ShutdownImpl::Type ); 80 void shutdown ( ShutdownImpl::Type );
81 void apmTimeout ( ); 81 void apmTimeout ( );
82 void sendHeldAction ( ); 82 void sendHeldAction ( );
83 83
84protected: 84protected:
85 virtual bool eventFilter ( QObject *o, QEvent *e ); 85 virtual bool eventFilter ( QObject *o, QEvent *e );
86 void checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat ); 86 bool checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat );
87 87
88private: 88private:
89 static DesktopApplication *me ( ); 89 static DesktopApplication *me ( );
90 90
91private: 91private:
92 void reloadPowerWarnSettings(); 92 void reloadPowerWarnSettings();
93 DesktopPowerAlerter *pa; 93 DesktopPowerAlerter *pa;
94 PowerStatus *m_ps, *m_ps_last; 94 PowerStatus *m_ps, *m_ps_last;
95 QTimer *cardSendTimer; 95 QTimer *cardSendTimer;
96 QCopChannel *channel; 96 QCopChannel *channel;
97 OpieScreenSaver *m_screensaver; 97 OpieScreenSaver *m_screensaver;
98 QTimer * m_apm_timer; 98 QTimer * m_apm_timer;
99 int m_powerVeryLow; 99 int m_powerVeryLow;
100 int m_powerCritical; 100 int m_powerCritical;
101 int m_currentPowerLevel; 101 int m_currentPowerLevel;
102 102
103 const Opie::ODeviceButton *m_last_button; 103 const Opie::ODeviceButton *m_last_button;
104 QTimer *m_button_timer; 104 QTimer *m_button_timer;
105 105
106 bool m_keyclick_sound : 1; 106 bool m_keyclick_sound : 1;
107 bool m_screentap_sound : 1; 107 bool m_screentap_sound : 1;
108 bool m_alarm_sound : 1; 108 bool m_alarm_sound : 1;
109}; 109};
110 110
111 111
112class Desktop : public QWidget 112class Desktop : public QWidget
113{ 113{
114 Q_OBJECT 114 Q_OBJECT
115public: 115public:
116 Desktop(); 116 Desktop();
117 ~Desktop(); 117 ~Desktop();
118 118
119 static bool screenLocked(); 119 static bool screenLocked();
120 120
121 void show(); 121 void show();
122 void checkMemory(); 122 void checkMemory();
123 123
124public slots: 124public slots:
125 void execAutoStart(); 125 void execAutoStart();
126 void togglePower(); 126 void togglePower();
127 void toggleLight(); 127 void toggleLight();
128 void toggleNumLockState(); 128 void toggleNumLockState();
129 void toggleCapsLockState(); 129 void toggleCapsLockState();
130 void toggleSymbolInput(); 130 void toggleSymbolInput();
131 void terminateServers(); 131 void terminateServers();
132 132
133protected: 133protected:
134 void executeOrModify( const QString& appLnkFile ); 134 void executeOrModify( const QString& appLnkFile );
135 void styleChange( QStyle & ); 135 void styleChange( QStyle & );
136 void timerEvent( QTimerEvent *e ); 136 void timerEvent( QTimerEvent *e );
137 137
138 QWidget *bg; 138 QWidget *bg;
139 Launcher *launcher; 139 Launcher *launcher;
140 TaskBar *tb; 140 TaskBar *tb;
141 141
142private: 142private:
143 void startTransferServer(); 143 void startTransferServer();
144 bool recoverMemory(); 144 bool recoverMemory();
145 145
146 QCopBridge *qcopBridge; 146 QCopBridge *qcopBridge;
147 TransferServer *transferServer; 147 TransferServer *transferServer;
148 PackageSlave *packageSlave; 148 PackageSlave *packageSlave;
149 149
150 QDateTime suspendTime; 150 QDateTime suspendTime;
151}; 151};
152 152
153 153
154#endif // __DESKTOP_H__ 154#endif // __DESKTOP_H__
155 155
diff --git a/core/settings/button/buttonsettings.cpp b/core/settings/button/buttonsettings.cpp
index eabb779..942d5e4 100644
--- a/core/settings/button/buttonsettings.cpp
+++ b/core/settings/button/buttonsettings.cpp
@@ -1,257 +1,256 @@
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 <qlayout.h> 28#include <qlayout.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qtimer.h> 30#include <qtimer.h>
31 31
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33 33
34#include <opie/odevice.h> 34#include <opie/odevice.h>
35 35
36#include "buttonsettings.h" 36#include "buttonsettings.h"
37#include "buttonutils.h" 37#include "buttonutils.h"
38#include "remapdlg.h" 38#include "remapdlg.h"
39 39
40using namespace Opie; 40using namespace Opie;
41 41
42struct buttoninfo { 42struct buttoninfo {
43 const ODeviceButton *m_button; 43 const ODeviceButton *m_button;
44 int m_index; 44 int m_index;
45 45
46 OQCopMessage m_pmsg; 46 OQCopMessage m_pmsg;
47 QLabel *m_picon; 47 QLabel *m_picon;
48 QLabel *m_plabel; 48 QLabel *m_plabel;
49 49
50 OQCopMessage m_hmsg; 50 OQCopMessage m_hmsg;
51 QLabel *m_hicon; 51 QLabel *m_hicon;
52 QLabel *m_hlabel; 52 QLabel *m_hlabel;
53 53
54 bool m_pdirty : 1; 54 bool m_pdirty : 1;
55 bool m_hdirty : 1; 55 bool m_hdirty : 1;
56}; 56};
57 57
58 58
59ButtonSettings::ButtonSettings ( ) 59ButtonSettings::ButtonSettings ( )
60 : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) 60 : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp )
61{ 61{
62 const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); 62 const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( );
63 (void) ButtonUtils::inst ( ); // initialise 63 (void) ButtonUtils::inst ( ); // initialise
64 64
65 setCaption ( tr( "Button Settings" )); 65 setCaption ( tr( "Button Settings" ));
66 66
67 QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); 67 QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 );
68 68
69 QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); 69 QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this );
70 toplay-> addWidget ( l ); 70 toplay-> addWidget ( l );
71 71
72 QGridLayout *lay = new QGridLayout ( toplay ); 72 QGridLayout *lay = new QGridLayout ( toplay );
73 lay-> setMargin ( 0 ); 73 lay-> setMargin ( 0 );
74 lay-> setColStretch ( 0, 0 ); 74 lay-> setColStretch ( 0, 0 );
75 lay-> setColStretch ( 1, 0 ); 75 lay-> setColStretch ( 1, 0 );
76 lay-> setColStretch ( 2, 0 ); 76 lay-> setColStretch ( 2, 0 );
77 lay-> setColStretch ( 3, 10 ); 77 lay-> setColStretch ( 3, 10 );
78 78
79 m_infos. setAutoDelete ( true ); 79 m_infos. setAutoDelete ( true );
80 80
81 int i = 1; 81 int i = 1;
82 int index = 0; 82 int index = 0;
83 for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { 83 for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) {
84 if ( it != buttons. begin ( )) { 84 if ( it != buttons. begin ( )) {
85 QFrame *f = new QFrame ( this ); 85 QFrame *f = new QFrame ( this );
86 f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); 86 f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine );
87 lay-> addMultiCellWidget ( f, i, i, 0, 3 ); 87 lay-> addMultiCellWidget ( f, i, i, 0, 3 );
88 i++; 88 i++;
89 } 89 }
90 90
91 buttoninfo *bi = new buttoninfo ( ); 91 buttoninfo *bi = new buttoninfo ( );
92 bi-> m_button = &(*it); 92 bi-> m_button = &(*it);
93 bi-> m_index = index++; 93 bi-> m_index = index++;
94 bi-> m_pmsg = (*it). pressedAction ( ); 94 bi-> m_pmsg = (*it). pressedAction ( );
95 bi-> m_hmsg = (*it). heldAction ( ); 95 bi-> m_hmsg = (*it). heldAction ( );
96 bi-> m_pdirty = false; 96 bi-> m_pdirty = false;
97 bi-> m_hdirty = false; 97 bi-> m_hdirty = false;
98 98
99 l = new QLabel ( this ); 99 l = new QLabel ( this );
100 l-> setPixmap (( *it ). pixmap ( )); 100 l-> setPixmap (( *it ). pixmap ( ));
101 101
102 lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); 102 lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 );
103 103
104 l = new QLabel ( tr( "Press:" ), this ); 104 l = new QLabel ( tr( "Press:" ), this );
105 lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); 105 lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom );
106 l = new QLabel ( tr( "Hold:" ), this ); 106 l = new QLabel ( tr( "Hold:" ), this );
107 lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); 107 lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop );
108 108
109 l = new QLabel ( this ); 109 l = new QLabel ( this );
110 l-> setFixedSize ( 16, 16 ); 110 l-> setFixedSize ( 16, 16 );
111 lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); 111 lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom );
112 bi-> m_picon = l; 112 bi-> m_picon = l;
113 113
114 l = new QLabel ( this ); 114 l = new QLabel ( this );
115 l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); 115 l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine );
116 lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); 116 lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom );
117 bi-> m_plabel = l; 117 bi-> m_plabel = l;
118 118
119 l = new QLabel ( this ); 119 l = new QLabel ( this );
120 l-> setFixedSize ( 16, 16 ); 120 l-> setFixedSize ( 16, 16 );
121 lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); 121 lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop );
122 bi-> m_hicon = l; 122 bi-> m_hicon = l;
123 123
124 l = new QLabel ( this ); 124 l = new QLabel ( this );
125 l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); 125 l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine );
126 lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); 126 lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop );
127 bi-> m_hlabel = l; 127 bi-> m_hlabel = l;
128 128
129 i += 2; 129 i += 2;
130 130
131 m_infos. append ( bi ); 131 m_infos. append ( bi );
132 } 132 }
133 133
134 toplay-> addStretch ( 10 ); 134 toplay-> addStretch ( 10 );
135 135
136 m_last_button = 0; 136 m_last_button = 0;
137 m_lock = false; 137 m_lock = false;
138 138
139 m_timer = new QTimer ( this ); 139 m_timer = new QTimer ( this );
140 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( ))); 140 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( )));
141 141
142 updateLabels ( ); 142 updateLabels ( );
143 143
144 QPEApplication::grabKeyboard ( ); 144 QPEApplication::grabKeyboard ( );
145} 145}
146 146
147ButtonSettings::~ButtonSettings ( ) 147ButtonSettings::~ButtonSettings ( )
148{ 148{
149 QPEApplication::ungrabKeyboard ( ); 149 QPEApplication::ungrabKeyboard ( );
150} 150}
151 151
152void ButtonSettings::updateLabels ( ) 152void ButtonSettings::updateLabels ( )
153{ 153{
154 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { 154 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
155 qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); 155 qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg );
156 156
157 (*it)-> m_picon-> setPixmap ( cip. m_icon ); 157 (*it)-> m_picon-> setPixmap ( cip. m_icon );
158 (*it)-> m_plabel-> setText ( cip. m_name ); 158 (*it)-> m_plabel-> setText ( cip. m_name );
159 159
160 qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); 160 qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg );
161 161
162 (*it)-> m_hicon-> setPixmap ( cih. m_icon ); 162 (*it)-> m_hicon-> setPixmap ( cih. m_icon );
163 (*it)-> m_hlabel-> setText ( cih. m_name ); 163 (*it)-> m_hlabel-> setText ( cih. m_name );
164 } 164 }
165} 165}
166 166
167buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) 167buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key )
168{ 168{
169 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { 169 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
170 if ((*it)-> m_button-> keycode ( ) == key ) 170 if ((*it)-> m_button-> keycode ( ) == key )
171 return *it; 171 return *it;
172 } 172 }
173 return 0; 173 return 0;
174} 174}
175 175
176void ButtonSettings::keyPressEvent ( QKeyEvent *e ) 176void ButtonSettings::keyPressEvent ( QKeyEvent *e )
177{ 177{
178 buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); 178 buttoninfo *bi = buttonInfoForKeycode ( e-> key ( ));
179 179
180 if ( bi && !e-> isAutoRepeat ( )) { 180 if ( bi && !e-> isAutoRepeat ( )) {
181 m_timer-> stop ( ); 181 m_timer-> stop ( );
182 m_last_button = bi; 182 m_last_button = bi;
183 m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); 183 m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true );
184 } 184 }
185 else 185 else
186 QDialog::keyPressEvent ( e ); 186 QDialog::keyPressEvent ( e );
187} 187}
188 188
189void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) 189void ButtonSettings::keyReleaseEvent ( QKeyEvent *e )
190{ 190{
191 buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); 191 buttoninfo *bi = buttonInfoForKeycode ( e-> key ( ));
192 192
193 if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { 193 if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) {
194 m_timer-> stop ( ); 194 m_timer-> stop ( );
195 edit ( bi, false ); 195 edit ( bi, false );
196 } 196 }
197 else 197 else
198 QDialog::keyReleaseEvent ( e ); 198 QDialog::keyReleaseEvent ( e );
199} 199}
200 200
201void ButtonSettings::keyTimeout ( ) 201void ButtonSettings::keyTimeout ( )
202{ 202{
203 if ( m_last_button ) { 203 if ( m_last_button ) {
204 edit ( m_last_button, true ); 204 edit ( m_last_button, true );
205 m_last_button = false; 205 m_last_button = false;
206 } 206 }
207} 207}
208 208
209void ButtonSettings::edit ( buttoninfo *bi, bool hold ) 209void ButtonSettings::edit ( buttoninfo *bi, bool hold )
210{ 210{
211 qDebug ( "remap %s for %s", hold ? "hold" : "press", bi-> m_button-> userText ( ). latin1 ( ));
212 211
213 if ( m_lock ) 212 if ( m_lock )
214 return; 213 return;
215 m_lock = true; 214 m_lock = true;
216 215
217 RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); 216 RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this );
218 217
219 d-> showMaximized ( ); 218 d-> showMaximized ( );
220 if ( d-> exec ( ) == QDialog::Accepted ) { 219 if ( d-> exec ( ) == QDialog::Accepted ) {
221 qDebug ( " -> %s %s", d-> message ( ). channel ( ). data ( ), d-> message ( ). message ( ). data ( )); 220
222 221
223 if ( hold ) { 222 if ( hold ) {
224 bi-> m_hmsg = d-> message ( ); 223 bi-> m_hmsg = d-> message ( );
225 bi-> m_hdirty = true; 224 bi-> m_hdirty = true;
226 } 225 }
227 else { 226 else {
228 bi-> m_pmsg = d-> message ( ); 227 bi-> m_pmsg = d-> message ( );
229 bi-> m_pdirty = true; 228 bi-> m_pdirty = true;
230 } 229 }
231 230
232 updateLabels ( ); 231 updateLabels ( );
233 } 232 }
234 233
235 delete d; 234 delete d;
236 235
237 m_lock = false; 236 m_lock = false;
238} 237}
239 238
240void ButtonSettings::accept ( ) 239void ButtonSettings::accept ( )
241{ 240{
242 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { 241 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
243 buttoninfo *bi = *it; 242 buttoninfo *bi = *it;
244 243
245 if ( bi-> m_pdirty ) 244 if ( bi-> m_pdirty )
246 ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg ); 245 ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg );
247 if ( bi-> m_hdirty ) 246 if ( bi-> m_hdirty )
248 ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg ); 247 ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg );
249 } 248 }
250 QDialog::accept ( ); 249 QDialog::accept ( );
251} 250}
252 251
253void ButtonSettings::done ( int r ) 252void ButtonSettings::done ( int r )
254{ 253{
255 QDialog::done ( r ); 254 QDialog::done ( r );
256 close ( ); 255 close ( );
257} 256}
diff --git a/core/settings/button/buttonutils.cpp b/core/settings/button/buttonutils.cpp
index 91d2af3..27a2f38 100644
--- a/core/settings/button/buttonutils.cpp
+++ b/core/settings/button/buttonutils.cpp
@@ -1,127 +1,128 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qapplication.h> 3#include <qapplication.h>
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qpe/applnk.h> 5#include <qpe/applnk.h>
6#include <qpe/mimetype.h> 6#include <qpe/mimetype.h>
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8 8
9#include "buttonutils.h" 9#include "buttonutils.h"
10 10
11using namespace Opie; 11using namespace Opie;
12 12
13struct predef_qcop { 13struct predef_qcop {
14 const char *m_text; 14 const char *m_text;
15 const char *m_pixmap; 15 const char *m_pixmap;
16 const char *m_channel; 16 const char *m_channel;
17 const char *m_function; 17 const char *m_function;
18}; 18};
19 19
20static const predef_qcop predef [] = { 20static const predef_qcop predef [] = {
21 21
22 { QT_TRANSLATE_NOOP( "ButtonSettings", "Beam VCard" ), "beam", "QPE/Application/addressbook", "beamBusinessCard()" }, 22 { QT_TRANSLATE_NOOP( "ButtonSettings", "Beam VCard" ), "beam", "QPE/Application/addressbook", "beamBusinessCard()" },
23 { QT_TRANSLATE_NOOP( "ButtonSettings", "Send eMail" ), "buttonsettings/mail", "QPE/Application/mail", "newMail()" }, 23 { QT_TRANSLATE_NOOP( "ButtonSettings", "Send eMail" ), "buttonsettings/mail", "QPE/Application/mail", "newMail()" },
24 24
25 25
26 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Menu" ), "buttonsettings/menu", "QPE/TaskBar", "toggleMenu()" }, 26 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Menu" ), "buttonsettings/menu", "QPE/TaskBar", "toggleMenu()" },
27 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle O-Menu" ), "buttonsettings/omenu", "QPE/TaskBar", "toggleStartMenu()" }, 27 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle O-Menu" ), "buttonsettings/omenu", "QPE/TaskBar", "toggleStartMenu()" },
28 { QT_TRANSLATE_NOOP( "ButtonSettings", "Show Desktop" ), "home", "QPE/Launcher", "home()" }, 28 { QT_TRANSLATE_NOOP( "ButtonSettings", "Show Desktop" ), "home", "QPE/Launcher", "home()" },
29 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Recording" ), "buttonsettings/record", "QPE/VMemo", "toggleRecord()" }, 29 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Recording" ), "buttonsettings/record", "QPE/VMemo", "toggleRecord()" },
30 30
31 { 0, 0, 0, 0 } 31 { 0, 0, 0, 0 }
32}; 32};
33 33
34 34
35 35
36 36
37ButtonUtils *ButtonUtils::ButtonUtils::inst ( ) 37ButtonUtils *ButtonUtils::ButtonUtils::inst ( )
38{ 38{
39 static ButtonUtils *p = 0; 39 static ButtonUtils *p = 0;
40 40
41 if ( !p ) { 41 if ( !p ) {
42 p = new ButtonUtils ( ); 42 p = new ButtonUtils ( );
43 ::atexit ( cleanup ); 43 ::atexit ( cleanup );
44 } 44 }
45 return p; 45 return p;
46} 46}
47 47
48void ButtonUtils::cleanup ( ) 48void ButtonUtils::cleanup ( )
49{ 49{
50 delete inst ( ); 50 delete inst ( );
51} 51}
52 52
53ButtonUtils::ButtonUtils ( ) 53ButtonUtils::ButtonUtils ( )
54{ 54{
55 m_apps = new AppLnkSet( MimeType::appsFolderName ( )); 55 m_apps = new AppLnkSet( MimeType::appsFolderName ( ));
56} 56}
57 57
58ButtonUtils::~ButtonUtils ( ) 58ButtonUtils::~ButtonUtils ( )
59{ 59{
60 delete m_apps; 60 delete m_apps;
61} 61}
62 62
63qCopInfo ButtonUtils::messageToInfo ( const OQCopMessage &c ) 63qCopInfo ButtonUtils::messageToInfo ( const OQCopMessage &c )
64{ 64{
65 QCString ch = c. channel ( ); 65 QCString ch = c. channel ( );
66 QCString f = c. message ( ); 66 QCString f = c. message ( );
67 67
68 if ( ch. isNull ( )) 68
69 if ( ch == "ignore" )
69 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Ignored</nobr>" )); 70 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Ignored</nobr>" ));
70 71
71 for ( const predef_qcop *p = predef; p-> m_text; p++ ) { 72 for ( const predef_qcop *p = predef; p-> m_text; p++ ) {
72 if (( ch == p-> m_channel ) && ( f == p-> m_function )) 73 if (( ch == p-> m_channel ) && ( f == p-> m_function ))
73 return qCopInfo ( qApp-> translate ( "ButtonSettings", p-> m_text ), Resource::loadPixmap ( p-> m_pixmap )); 74 return qCopInfo ( qApp-> translate ( "ButtonSettings", p-> m_text ), Resource::loadPixmap ( p-> m_pixmap ));
74 } 75 }
75 76
76 if ( ch. left ( 16 ) == "QPE/Application/" ) { 77 if ( ch. left ( 16 ) == "QPE/Application/" ) {
77 QString app = ch. mid ( 16 ); 78 QString app = ch. mid ( 16 );
78 const AppLnk *applnk = m_apps-> findExec ( app ); 79 const AppLnk *applnk = m_apps-> findExec ( app );
79 if ( applnk ) 80 if ( applnk )
80 app = applnk-> name ( ); 81 app = applnk-> name ( );
81 82
82 if (( f == "raise()" ) || ( f == "nextView()" )) 83 if (( f == "raise()" ) || ( f == "nextView()" ))
83 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Show <b>%1</b></nobr>" ). arg ( app ), applnk ? applnk-> pixmap ( ) : QPixmap ( )); 84 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Show <b>%1</b></nobr>" ). arg ( app ), applnk ? applnk-> pixmap ( ) : QPixmap ( ));
84 else 85 else
85 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Call <b>%1</b>: <i>%2</i></nobr>" ). arg ( app ). arg ( f ), applnk ? applnk-> pixmap ( ) : QPixmap ( )); 86 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Call <b>%1</b>: <i>%2</i></nobr>" ). arg ( app ). arg ( f ), applnk ? applnk-> pixmap ( ) : QPixmap ( ));
86 } 87 }
87 else { 88 else {
88 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Call <b>%1</b> <i>%2</i></nobr>" ). arg (( ch. left ( 4 ) == "QPE/" ) ? ch. mid ( 4 ) : ch ). arg ( f )); 89 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Call <b>%1</b> <i>%2</i></nobr>" ). arg (( ch. left ( 4 ) == "QPE/" ) ? ch. mid ( 4 ) : ch ). arg ( f ));
89 } 90 }
90} 91}
91 92
92 93
93void ButtonUtils::insertActions ( QListViewItem *here ) 94void ButtonUtils::insertActions ( QListViewItem *here )
94{ 95{
95 for ( const predef_qcop *p = predef; p-> m_text; p++ ) { 96 for ( const predef_qcop *p = predef; p-> m_text; p++ ) {
96 QListViewItem *item = new QListViewItem ( here, qApp-> translate ( "ButtonSettings", p-> m_text ), p-> m_channel, p-> m_function ); 97 QListViewItem *item = new QListViewItem ( here, qApp-> translate ( "ButtonSettings", p-> m_text ), p-> m_channel, p-> m_function );
97 item-> setPixmap ( 0, Resource::loadPixmap ( p-> m_pixmap )); 98 item-> setPixmap ( 0, Resource::loadPixmap ( p-> m_pixmap ));
98 } 99 }
99} 100}
100 101
101 102
102void ButtonUtils::insertAppLnks ( QListViewItem *here ) 103void ButtonUtils::insertAppLnks ( QListViewItem *here )
103{ 104{
104 QStringList types = m_apps-> types ( ); 105 QStringList types = m_apps-> types ( );
105 QListViewItem *typeitem [types. count ( )]; 106 QListViewItem *typeitem [types. count ( )];
106 107
107 int i = 0; 108 int i = 0;
108 for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { 109 for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) {
109 QListViewItem *item = new QListViewItem ( here, m_apps-> typeName ( *it )); 110 QListViewItem *item = new QListViewItem ( here, m_apps-> typeName ( *it ));
110 item-> setPixmap ( 0, m_apps-> typePixmap ( *it )); 111 item-> setPixmap ( 0, m_apps-> typePixmap ( *it ));
111 112
112 typeitem [i++] = item; 113 typeitem [i++] = item;
113 } 114 }
114 115
115 for ( QListIterator <AppLnk> appit ( m_apps-> children ( )); *appit; ++appit ) { 116 for ( QListIterator <AppLnk> appit ( m_apps-> children ( )); *appit; ++appit ) {
116 AppLnk *l = *appit; 117 AppLnk *l = *appit;
117 118
118 int i = 0; 119 int i = 0;
119 for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { 120 for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) {
120 if ( l-> type ( ) == *it ) { 121 if ( l-> type ( ) == *it ) {
121 QListViewItem *sub = new QListViewItem ( typeitem [i], l-> name ( ), QString ( "QPE/Application/" ) + l-> exec ( ), "raise()" ); 122 QListViewItem *sub = new QListViewItem ( typeitem [i], l-> name ( ), QString ( "QPE/Application/" ) + l-> exec ( ), "raise()" );
122 sub-> setPixmap ( 0, l-> pixmap ( )); 123 sub-> setPixmap ( 0, l-> pixmap ( ));
123 } 124 }
124 i++; 125 i++;
125 } 126 }
126 } 127 }
127} 128}
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp
index a251bd4..b6ee60b 100644
--- a/core/settings/button/remapdlg.cpp
+++ b/core/settings/button/remapdlg.cpp
@@ -1,132 +1,150 @@
1#include <qlistview.h> 1#include <qlistview.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qtimer.h> 4#include <qtimer.h>
5 5
6#include "remapdlg.h" 6#include "remapdlg.h"
7#include "buttonutils.h" 7#include "buttonutils.h"
8 8
9using namespace Opie; 9using namespace Opie;
10 10
11class NoSortItem : public QListViewItem { 11class NoSortItem : public QListViewItem {
12public: 12public:
13 NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) 13 NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 )
14 : QListViewItem ( lv, str, s1, s2 ) 14 : QListViewItem ( lv, str, s1, s2 )
15 { 15 {
16 m_key = QString ( QChar ( 'a' + pos )); 16 m_key = QString ( QChar ( 'a' + pos ));
17 m_def = false; 17 m_def = false;
18 } 18 }
19 19
20 void setDefault ( bool b ) 20 void setDefault ( bool b )
21 { 21 {
22 m_def = b; 22 m_def = b;
23 } 23 }
24 24
25 virtual QString key ( int /*column*/, bool /*ascending*/ ) const 25 virtual QString key ( int /*column*/, bool /*ascending*/ ) const
26 { 26 {
27 return m_key; 27 return m_key;
28 } 28 }
29 29
30 virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) 30 virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )
31 { 31 {
32 if ( m_def ) { 32 if ( m_def ) {
33 QFont f ( listView ( )-> font ( )); 33 QFont f ( listView ( )-> font ( ));
34 f. setBold ( true ); 34 f. setBold ( true );
35 p-> setFont ( f ); 35 p-> setFont ( f );
36 } 36 }
37 QListViewItem::paintCell ( p, cg, column, width, align ); 37 QListViewItem::paintCell ( p, cg, column, width, align );
38 } 38 }
39 39
40private: 40private:
41 QString m_key; 41 QString m_key;
42 bool m_def; 42 bool m_def;
43}; 43};
44 44
45 45
46RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) 46RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name )
47 : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) 47 : RemapDlgBase ( parent, name, true, WStyle_ContextHelp )
48{ 48{
49 setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); 49 setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( )));
50 50
51 m_current = 0; 51 m_current = 0;
52 52
53 static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; 53 static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 };
54 w_channel-> insertStrList ((const char **) def_channels ); 54 w_channel-> insertStrList ((const char **) def_channels );
55 55
56 m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); 56 m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( );
57 m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); 57 m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( );
58 58
59 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); 59 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" ));
60 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); 60 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
61 ((NoSortItem *) m_map_preset )-> setDefault ( true ); 61 ((NoSortItem *) m_map_preset )-> setDefault ( true );
62 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); 62
63 if (m_msg. channel ( ) == "ignore")
64 {
65 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
66
67 m_current = m_map_none;
68 }
69 else
70 {
71 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
72 m_current = m_map_custom;
73 }
63 74
64 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); 75 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
65 ButtonUtils::inst ( )-> insertActions ( it ); 76 ButtonUtils::inst ( )-> insertActions ( it );
66 it-> setOpen ( true ); 77 it-> setOpen ( true );
67 78
68 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); 79 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" ));
69 80
70 m_current = m_map_custom;
71 w_list-> setCurrentItem ( m_current ); 81 w_list-> setCurrentItem ( m_current );
72 82
73 QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); 83 QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
74} 84}
75 85
76RemapDlg::~RemapDlg ( ) 86RemapDlg::~RemapDlg ( )
77{ 87{
78} 88}
79 89
80void RemapDlg::delayedInit ( ) 90void RemapDlg::delayedInit ( )
81{ 91{
82 bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); 92 bool b = w_list-> viewport ( )-> isUpdatesEnabled ( );
83 w_list-> viewport ( )-> setUpdatesEnabled ( false ); 93 w_list-> viewport ( )-> setUpdatesEnabled ( false );
84 94
85 ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); 95 ButtonUtils::inst ( )-> insertAppLnks ( m_map_show );
86 96
87 w_list-> viewport ( )-> setUpdatesEnabled ( b ); 97 w_list-> viewport ( )-> setUpdatesEnabled ( b );
88 98
89 m_map_show-> repaint ( ); 99 m_map_show-> repaint ( );
90} 100}
91 101
92void RemapDlg::itemChanged ( QListViewItem *it ) 102void RemapDlg::itemChanged ( QListViewItem *it )
93{ 103{
94 bool enabled = false; 104 bool enabled = false;
95 OQCopMessage m; 105 OQCopMessage m;
96 106
97 m_current = it; 107 m_current = it;
98 108
99 if ( it == m_map_none ) 109 if ( it == m_map_none )
100 m_msg = m = OQCopMessage ( 0, 0 ); 110 {
111 m_msg = m = OQCopMessage ( "ignore", 0 );
112 qDebug ("***ignoring");
113 }
101 else if ( it == m_map_preset ) 114 else if ( it == m_map_preset )
115 {
102 m_msg = m = m_msg_preset; 116 m_msg = m = m_msg_preset;
103 else if ( it && !it-> childCount ( )) { 117 qDebug ("***Preset");
118 }
119 else if ( it && !it-> childCount ( ))
120 {
121 qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
104 enabled = ( it == m_map_custom ); 122 enabled = ( it == m_map_custom );
105 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); 123 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
106 } 124 }
107 125
108 w_channel-> setEnabled ( enabled ); 126 w_channel-> setEnabled ( enabled );
109 w_message-> setEnabled ( enabled ); 127 w_message-> setEnabled ( enabled );
110 128
111 w_channel-> setEditText ( m. channel ( )); 129 w_channel-> setEditText ( m. channel ( ));
112 w_message-> setEditText ( m. message ( )); 130 w_message-> setEditText ( m. message ( ));
113} 131}
114 132
115void RemapDlg::textChanged ( const QString &str ) 133void RemapDlg::textChanged ( const QString &str )
116{ 134{
117 if ( !m_current ) 135 if ( !m_current )
118 return; 136 return;
119 137
120 QComboBox *which = (QComboBox *) sender ( ); 138 QComboBox *which = (QComboBox *) sender ( );
121 139
122 if ( which == w_channel ) 140 if ( which == w_channel )
123 m_current-> setText ( 1, str ); 141 m_current-> setText ( 1, str );
124 else if ( which == w_message ) 142 else if ( which == w_message )
125 m_current-> setText ( 2, str ); 143 m_current-> setText ( 2, str );
126} 144}
127 145
128OQCopMessage RemapDlg::message ( ) 146OQCopMessage RemapDlg::message ( )
129{ 147{
130 return m_msg; 148 return m_msg;
131} 149}
132 150
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9e97c56..d5e3c5c 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,1211 +1,1216 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#include <linux/soundcard.h> 26#include <linux/soundcard.h>
27#include <math.h> 27#include <math.h>
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37 37
38#include "odevice.h" 38#include "odevice.h"
39 39
40#include <qwindowsystem_qws.h> 40#include <qwindowsystem_qws.h>
41 41
42 42
43// _IO and friends are only defined in kernel headers ... 43// _IO and friends are only defined in kernel headers ...
44 44
45#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 45#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
46 46
47#define OD_IO(type,number) OD_IOC(0,type,number,0) 47#define OD_IO(type,number) OD_IOC(0,type,number,0)
48#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 48#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
49#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 49#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
51 51
52using namespace Opie; 52using namespace Opie;
53 53
54class ODeviceData { 54class ODeviceData {
55public: 55public:
56 bool m_qwsserver; 56 bool m_qwsserver;
57 57
58 QString m_vendorstr; 58 QString m_vendorstr;
59 OVendor m_vendor; 59 OVendor m_vendor;
60 60
61 QString m_modelstr; 61 QString m_modelstr;
62 OModel m_model; 62 OModel m_model;
63 63
64 QString m_systemstr; 64 QString m_systemstr;
65 OSystem m_system; 65 OSystem m_system;
66 66
67 QString m_sysverstr; 67 QString m_sysverstr;
68 68
69 Transformation m_rotation; 69 Transformation m_rotation;
70 70
71 QValueList <ODeviceButton> m_buttons; 71 QValueList <ODeviceButton> m_buttons;
72 uint m_holdtime; 72 uint m_holdtime;
73}; 73};
74 74
75 75
76class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 76class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
77protected: 77protected:
78 virtual void init ( ); 78 virtual void init ( );
79 79
80public: 80public:
81 virtual bool setSoftSuspend ( bool soft ); 81 virtual bool setSoftSuspend ( bool soft );
82 82
83 virtual bool setDisplayBrightness ( int b ); 83 virtual bool setDisplayBrightness ( int b );
84 virtual int displayBrightnessResolution ( ) const; 84 virtual int displayBrightnessResolution ( ) const;
85 85
86 virtual void alarmSound ( ); 86 virtual void alarmSound ( );
87 87
88 virtual QValueList <OLed> ledList ( ) const; 88 virtual QValueList <OLed> ledList ( ) const;
89 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 89 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
90 virtual OLedState ledState ( OLed led ) const; 90 virtual OLedState ledState ( OLed led ) const;
91 virtual bool setLedState ( OLed led, OLedState st ); 91 virtual bool setLedState ( OLed led, OLedState st );
92 92
93 virtual bool hasLightSensor ( ) const; 93 virtual bool hasLightSensor ( ) const;
94 virtual int readLightSensor ( ); 94 virtual int readLightSensor ( );
95 virtual int lightSensorResolution ( ) const; 95 virtual int lightSensorResolution ( ) const;
96 96
97protected: 97protected:
98 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 98 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
99 virtual void timerEvent ( QTimerEvent *te ); 99 virtual void timerEvent ( QTimerEvent *te );
100 100
101 int m_power_timer; 101 int m_power_timer;
102 102
103 OLedState m_leds [2]; 103 OLedState m_leds [2];
104}; 104};
105 105
106class Zaurus : public ODevice { 106class Zaurus : public ODevice {
107protected: 107protected:
108 virtual void init ( ); 108 virtual void init ( );
109 109
110 public: 110 public:
111 virtual bool setSoftSuspend ( bool soft ); 111 virtual bool setSoftSuspend ( bool soft );
112 112
113 virtual bool setDisplayBrightness ( int b ); 113 virtual bool setDisplayBrightness ( int b );
114 virtual int displayBrightnessResolution ( ) const; 114 virtual int displayBrightnessResolution ( ) const;
115 115
116 virtual void alarmSound ( ); 116 virtual void alarmSound ( );
117 virtual void keySound ( ); 117 virtual void keySound ( );
118 virtual void touchSound ( ); 118 virtual void touchSound ( );
119 119
120 virtual QValueList <OLed> ledList ( ) const; 120 virtual QValueList <OLed> ledList ( ) const;
121 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 121 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
122 virtual OLedState ledState ( OLed led ) const; 122 virtual OLedState ledState ( OLed led ) const;
123 virtual bool setLedState ( OLed led, OLedState st ); 123 virtual bool setLedState ( OLed led, OLedState st );
124 124
125protected: 125protected:
126 virtual void buzzer ( int snd ); 126 virtual void buzzer ( int snd );
127 127
128 OLedState m_leds [1]; 128 OLedState m_leds [1];
129}; 129};
130 130
131 131
132struct i_button { 132struct i_button {
133 uint model; 133 uint model;
134 Qt::Key code; 134 Qt::Key code;
135 char *utext; 135 char *utext;
136 char *pix; 136 char *pix;
137 char *fpressedservice; 137 char *fpressedservice;
138 char *fpressedaction; 138 char *fpressedaction;
139 char *fheldservice; 139 char *fheldservice;
140 char *fheldaction; 140 char *fheldaction;
141} ipaq_buttons [] = { 141} ipaq_buttons [] = {
142 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 142 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
143 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 143 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
144 "devicebuttons/ipaq_calendar", 144 "devicebuttons/ipaq_calendar",
145 "datebook", "nextView()", 145 "datebook", "nextView()",
146 "today", "raise()" }, 146 "today", "raise()" },
147 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 147 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
148 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 148 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
149 "devicebuttons/ipaq_contact", 149 "devicebuttons/ipaq_contact",
150 "addressbook", "raise()", 150 "addressbook", "raise()",
151 "addressbook", "beamBusinessCard()" }, 151 "addressbook", "beamBusinessCard()" },
152 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 152 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
153 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 153 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
154 "devicebuttons/ipaq_menu", 154 "devicebuttons/ipaq_menu",
155 "QPE/TaskBar", "toggleMenu()", 155 "QPE/TaskBar", "toggleMenu()",
156 "QPE/TaskBar", "toggleStartMenu()" }, 156 "QPE/TaskBar", "toggleStartMenu()" },
157 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 157 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
158 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 158 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
159 "devicebuttons/ipaq_mail", 159 "devicebuttons/ipaq_mail",
160 "mail", "raise()", 160 "mail", "raise()",
161 "mail", "newMail()" }, 161 "mail", "newMail()" },
162 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 162 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
163 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 163 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
164 "devicebuttons/ipaq_home", 164 "devicebuttons/ipaq_home",
165 "QPE/Launcher", "home()", 165 "QPE/Launcher", "home()",
166 "buttonsettings", "raise()" }, 166 "buttonsettings", "raise()" },
167 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 167 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
168 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 168 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
169 "devicebuttons/ipaq_record", 169 "devicebuttons/ipaq_record",
170 "QPE/VMemo", "toggleRecord()", 170 "QPE/VMemo", "toggleRecord()",
171 "sound", "raise()" }, 171 "sound", "raise()" },
172}; 172};
173 173
174struct z_button { 174struct z_button {
175 Qt::Key code; 175 Qt::Key code;
176 char *utext; 176 char *utext;
177 char *pix; 177 char *pix;
178 char *fpressedservice; 178 char *fpressedservice;
179 char *fpressedaction; 179 char *fpressedaction;
180 char *fheldservice; 180 char *fheldservice;
181 char *fheldaction; 181 char *fheldaction;
182} z_buttons [] = { 182} z_buttons [] = {
183 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 183 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
184 "devicebuttons/z_calendar", 184 "devicebuttons/z_calendar",
185 "datebook", "nextView()", 185 "datebook", "nextView()",
186 "today", "raise()" }, 186 "today", "raise()" },
187 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 187 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
188 "devicebuttons/z_contact", 188 "devicebuttons/z_contact",
189 "addressbook", "raise()", 189 "addressbook", "raise()",
190 "addressbook", "beamBusinessCard()" }, 190 "addressbook", "beamBusinessCard()" },
191 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 191 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
192 "devicebuttons/z_home", 192 "devicebuttons/z_home",
193 "QPE/Launcher", "home()", 193 "QPE/Launcher", "home()",
194 "buttonsettings", "raise()" }, 194 "buttonsettings", "raise()" },
195 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 195 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
196 "devicebuttons/z_menu", 196 "devicebuttons/z_menu",
197 "QPE/TaskBar", "toggleMenu()", 197 "QPE/TaskBar", "toggleMenu()",
198 "QPE/TaskBar", "toggleStartMenu()" }, 198 "QPE/TaskBar", "toggleStartMenu()" },
199 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 199 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
200 "devicebuttons/z_mail", 200 "devicebuttons/z_mail",
201 "mail", "raise()", 201 "mail", "raise()",
202 "mail", "newMail()" }, 202 "mail", "newMail()" },
203}; 203};
204 204
205static QCString makeChannel ( const char *str ) 205static QCString makeChannel ( const char *str )
206{ 206{
207 if ( str && !::strchr ( str, '/' )) 207 if ( str && !::strchr ( str, '/' ))
208 return QCString ( "QPE/Application/" ) + str; 208 return QCString ( "QPE/Application/" ) + str;
209 else 209 else
210 return str; 210 return str;
211} 211}
212 212
213 213
214 214
215 215
216ODevice *ODevice::inst ( ) 216ODevice *ODevice::inst ( )
217{ 217{
218 static ODevice *dev = 0; 218 static ODevice *dev = 0;
219 219
220 if ( !dev ) { 220 if ( !dev ) {
221 if ( QFile::exists ( "/proc/hal/model" )) 221 if ( QFile::exists ( "/proc/hal/model" ))
222 dev = new iPAQ ( ); 222 dev = new iPAQ ( );
223 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 223 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
224 dev = new Zaurus ( ); 224 dev = new Zaurus ( );
225 else 225 else
226 dev = new ODevice ( ); 226 dev = new ODevice ( );
227 227
228 dev-> init ( ); 228 dev-> init ( );
229 } 229 }
230 return dev; 230 return dev;
231} 231}
232 232
233 233
234/************************************************** 234/**************************************************
235 * 235 *
236 * common 236 * common
237 * 237 *
238 **************************************************/ 238 **************************************************/
239 239
240 240
241ODevice::ODevice ( ) 241ODevice::ODevice ( )
242{ 242{
243 d = new ODeviceData; 243 d = new ODeviceData;
244 244
245 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 245 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
246 246
247 d-> m_modelstr = "Unknown"; 247 d-> m_modelstr = "Unknown";
248 d-> m_model = Model_Unknown; 248 d-> m_model = Model_Unknown;
249 d-> m_vendorstr = "Unknown"; 249 d-> m_vendorstr = "Unknown";
250 d-> m_vendor = Vendor_Unknown; 250 d-> m_vendor = Vendor_Unknown;
251 d-> m_systemstr = "Unknown"; 251 d-> m_systemstr = "Unknown";
252 d-> m_system = System_Unknown; 252 d-> m_system = System_Unknown;
253 d-> m_sysverstr = "0.0"; 253 d-> m_sysverstr = "0.0";
254 d-> m_rotation = Rot0; 254 d-> m_rotation = Rot0;
255 255
256 d-> m_holdtime = 1000; // 1000ms 256 d-> m_holdtime = 1000; // 1000ms
257 257
258 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 258 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
259 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 259 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
260} 260}
261 261
262void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 262void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
263{ 263{
264 if ( msg == "deviceButtonMappingChanged()" ) { 264 if ( msg == "deviceButtonMappingChanged()" ) {
265 reloadButtonMapping ( ); 265 reloadButtonMapping ( );
266 } 266 }
267} 267}
268 268
269void ODevice::init ( ) 269void ODevice::init ( )
270{ 270{
271 // Simulation uses iPAQ 3660 device buttons 271 // Simulation uses iPAQ 3660 device buttons
272 272
273 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 273 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
274 i_button *ib = ipaq_buttons + i; 274 i_button *ib = ipaq_buttons + i;
275 ODeviceButton b; 275 ODeviceButton b;
276 276
277 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 277 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
278 b. setKeycode ( ib-> code ); 278 b. setKeycode ( ib-> code );
279 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 279 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
280 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 280 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
283
284 d-> m_buttons. append ( b ); 283 d-> m_buttons. append ( b );
285 } 284 }
286 } 285 }
287 reloadButtonMapping ( ); 286 reloadButtonMapping ( );
288} 287}
289 288
290ODevice::~ODevice ( ) 289ODevice::~ODevice ( )
291{ 290{
292 delete d; 291 delete d;
293} 292}
294 293
295bool ODevice::setSoftSuspend ( bool /*soft*/ ) 294bool ODevice::setSoftSuspend ( bool /*soft*/ )
296{ 295{
297 return false; 296 return false;
298} 297}
299 298
300//#include <linux/apm_bios.h> 299//#include <linux/apm_bios.h>
301 300
302#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 301#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
303 302
304 303
305bool ODevice::suspend ( ) 304bool ODevice::suspend ( )
306{ 305{
307 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 306 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
308 return false; 307 return false;
309 308
310 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 309 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
311 return false; 310 return false;
312 311
313 bool res = false; 312 bool res = false;
314 313
315 struct timeval tvs, tvn; 314 struct timeval tvs, tvn;
316 ::gettimeofday ( &tvs, 0 ); 315 ::gettimeofday ( &tvs, 0 );
317 316
318 ::sync ( ); // flush fs caches 317 ::sync ( ); // flush fs caches
319 res = ( ::system ( "apm --suspend" ) == 0 ); 318 res = ( ::system ( "apm --suspend" ) == 0 );
320 319
321 // This is needed because the iPAQ apm implementation is asynchronous and we 320 // This is needed because the iPAQ apm implementation is asynchronous and we
322 // can not be sure when exactly the device is really suspended 321 // can not be sure when exactly the device is really suspended
323 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 322 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
324 323
325 if ( res ) { 324 if ( res ) {
326 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 325 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
327 ::usleep ( 200 * 1000 ); 326 ::usleep ( 200 * 1000 );
328 ::gettimeofday ( &tvn, 0 ); 327 ::gettimeofday ( &tvn, 0 );
329 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 328 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
330 } 329 }
331 330
332 return res; 331 return res;
333} 332}
334 333
335//#include <linux/fb.h> better not rely on kernel headers in userspace ... 334//#include <linux/fb.h> better not rely on kernel headers in userspace ...
336 335
337#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 336#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
338 337
339/* VESA Blanking Levels */ 338/* VESA Blanking Levels */
340#define VESA_NO_BLANKING 0 339#define VESA_NO_BLANKING 0
341#define VESA_VSYNC_SUSPEND 1 340#define VESA_VSYNC_SUSPEND 1
342#define VESA_HSYNC_SUSPEND 2 341#define VESA_HSYNC_SUSPEND 2
343#define VESA_POWERDOWN 3 342#define VESA_POWERDOWN 3
344 343
345 344
346bool ODevice::setDisplayStatus ( bool on ) 345bool ODevice::setDisplayStatus ( bool on )
347{ 346{
348 if ( d-> m_model == Model_Unknown ) 347 if ( d-> m_model == Model_Unknown )
349 return false; 348 return false;
350 349
351 bool res = false; 350 bool res = false;
352 int fd; 351 int fd;
353 352
354 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 353 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
355 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 354 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
356 ::close ( fd ); 355 ::close ( fd );
357 } 356 }
358 return res; 357 return res;
359} 358}
360 359
361bool ODevice::setDisplayBrightness ( int ) 360bool ODevice::setDisplayBrightness ( int )
362{ 361{
363 return false; 362 return false;
364} 363}
365 364
366int ODevice::displayBrightnessResolution ( ) const 365int ODevice::displayBrightnessResolution ( ) const
367{ 366{
368 return 16; 367 return 16;
369} 368}
370 369
371QString ODevice::vendorString ( ) const 370QString ODevice::vendorString ( ) const
372{ 371{
373 return d-> m_vendorstr; 372 return d-> m_vendorstr;
374} 373}
375 374
376OVendor ODevice::vendor ( ) const 375OVendor ODevice::vendor ( ) const
377{ 376{
378 return d-> m_vendor; 377 return d-> m_vendor;
379} 378}
380 379
381QString ODevice::modelString ( ) const 380QString ODevice::modelString ( ) const
382{ 381{
383 return d-> m_modelstr; 382 return d-> m_modelstr;
384} 383}
385 384
386OModel ODevice::model ( ) const 385OModel ODevice::model ( ) const
387{ 386{
388 return d-> m_model; 387 return d-> m_model;
389} 388}
390 389
391QString ODevice::systemString ( ) const 390QString ODevice::systemString ( ) const
392{ 391{
393 return d-> m_systemstr; 392 return d-> m_systemstr;
394} 393}
395 394
396OSystem ODevice::system ( ) const 395OSystem ODevice::system ( ) const
397{ 396{
398 return d-> m_system; 397 return d-> m_system;
399} 398}
400 399
401QString ODevice::systemVersionString ( ) const 400QString ODevice::systemVersionString ( ) const
402{ 401{
403 return d-> m_sysverstr; 402 return d-> m_sysverstr;
404} 403}
405 404
406Transformation ODevice::rotation ( ) const 405Transformation ODevice::rotation ( ) const
407{ 406{
408 return d-> m_rotation; 407 return d-> m_rotation;
409} 408}
410 409
411void ODevice::alarmSound ( ) 410void ODevice::alarmSound ( )
412{ 411{
413#ifndef QT_NO_SOUND 412#ifndef QT_NO_SOUND
414 static Sound snd ( "alarm" ); 413 static Sound snd ( "alarm" );
415 414
416 if ( snd. isFinished ( )) 415 if ( snd. isFinished ( ))
417 snd. play ( ); 416 snd. play ( );
418#endif 417#endif
419} 418}
420 419
421void ODevice::keySound ( ) 420void ODevice::keySound ( )
422{ 421{
423#ifndef QT_NO_SOUND 422#ifndef QT_NO_SOUND
424 static Sound snd ( "keysound" ); 423 static Sound snd ( "keysound" );
425 424
426 if ( snd. isFinished ( )) 425 if ( snd. isFinished ( ))
427 snd. play ( ); 426 snd. play ( );
428#endif 427#endif
429} 428}
430 429
431void ODevice::touchSound ( ) 430void ODevice::touchSound ( )
432{ 431{
433 432
434#ifndef QT_NO_SOUND 433#ifndef QT_NO_SOUND
435 static Sound snd ( "touchsound" ); 434 static Sound snd ( "touchsound" );
436 435
437 if ( snd. isFinished ( )) 436 if ( snd. isFinished ( ))
438 snd. play ( ); 437 snd. play ( );
439#endif 438#endif
440} 439}
441 440
442 441
443QValueList <OLed> ODevice::ledList ( ) const 442QValueList <OLed> ODevice::ledList ( ) const
444{ 443{
445 return QValueList <OLed> ( ); 444 return QValueList <OLed> ( );
446} 445}
447 446
448QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 447QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
449{ 448{
450 return QValueList <OLedState> ( ); 449 return QValueList <OLedState> ( );
451} 450}
452 451
453OLedState ODevice::ledState ( OLed /*which*/ ) const 452OLedState ODevice::ledState ( OLed /*which*/ ) const
454{ 453{
455 return Led_Off; 454 return Led_Off;
456} 455}
457 456
458bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 457bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
459{ 458{
460 return false; 459 return false;
461} 460}
462 461
463bool ODevice::hasLightSensor ( ) const 462bool ODevice::hasLightSensor ( ) const
464{ 463{
465 return false; 464 return false;
466} 465}
467 466
468int ODevice::readLightSensor ( ) 467int ODevice::readLightSensor ( )
469{ 468{
470 return -1; 469 return -1;
471} 470}
472 471
473int ODevice::lightSensorResolution ( ) const 472int ODevice::lightSensorResolution ( ) const
474{ 473{
475 return 0; 474 return 0;
476} 475}
477 476
478const QValueList <ODeviceButton> &ODevice::buttons ( ) const 477const QValueList <ODeviceButton> &ODevice::buttons ( ) const
479{ 478{
480 return d-> m_buttons; 479 return d-> m_buttons;
481} 480}
482 481
483uint ODevice::buttonHoldTime ( ) const 482uint ODevice::buttonHoldTime ( ) const
484{ 483{
485 return d-> m_holdtime; 484 return d-> m_holdtime;
486} 485}
487 486
488const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 487const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
489{ 488{
490 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { 489 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) {
491 if ( (*it). keycode ( ) == code ) 490 if ( (*it). keycode ( ) == code )
492 return &(*it); 491 return &(*it);
493 } 492 }
494 return 0; 493 return 0;
495} 494}
496 495
497void ODevice::reloadButtonMapping ( ) 496void ODevice::reloadButtonMapping ( )
498{ 497{
499 Config cfg ( "ButtonSettings" ); 498 Config cfg ( "ButtonSettings" );
500 499
501 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { 500 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) {
502 ODeviceButton &b = d-> m_buttons [i]; 501 ODeviceButton &b = d-> m_buttons [i];
503 QString group = "Button" + QString::number ( i ); 502 QString group = "Button" + QString::number ( i );
504 503
505 QCString pch, hch; 504 QCString pch, hch;
506 QCString pm, hm; 505 QCString pm, hm;
507 QByteArray pdata, hdata; 506 QByteArray pdata, hdata;
508 507
509 if ( cfg. hasGroup ( group )) { 508 if ( cfg. hasGroup ( group )) {
510 cfg. setGroup ( group ); 509 cfg. setGroup ( group );
511 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 510 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
512 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 511 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
513 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 512 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
514 513
515 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 514 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
516 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 515 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
517 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 516 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
518 } 517 }
519 518
520 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 519 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
520
521 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 521 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
522 } 522 }
523} 523}
524 524
525void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 525void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
526{ 526{
527 QString mb_chan;
528
527 if ( button >= (int) d-> m_buttons. count ( )) 529 if ( button >= (int) d-> m_buttons. count ( ))
528 return; 530 return;
531
529 532
530 ODeviceButton &b = d-> m_buttons [button]; 533 ODeviceButton &b = d-> m_buttons [button];
531 b. setPressedAction ( action ); 534 b. setPressedAction ( action );
535
536 mb_chan=b. pressedAction ( ). channel ( );
532 537
533 Config buttonFile ( "ButtonSettings" ); 538 Config buttonFile ( "ButtonSettings" );
534 buttonFile. setGroup ( "Button" + QString::number ( button )); 539 buttonFile. setGroup ( "Button" + QString::number ( button ));
535 buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); 540 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
536 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 541 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
537 542
538 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 543 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
539 544
540 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 545 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
541} 546}
542 547
543void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 548void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
544{ 549{
545 if ( button >= (int) d-> m_buttons. count ( )) 550 if ( button >= (int) d-> m_buttons. count ( ))
546 return; 551 return;
547 552
548 ODeviceButton &b = d-> m_buttons [button]; 553 ODeviceButton &b = d-> m_buttons [button];
549 b. setHeldAction ( action ); 554 b. setHeldAction ( action );
550 555
551 Config buttonFile ( "ButtonSettings" ); 556 Config buttonFile ( "ButtonSettings" );
552 buttonFile. setGroup ( "Button" + QString::number ( button )); 557 buttonFile. setGroup ( "Button" + QString::number ( button ));
553 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 558 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
554 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 559 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
555 560
556 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 561 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
557 562
558 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 563 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
559} 564}
560 565
561 566
562 567
563 568
564/************************************************** 569/**************************************************
565 * 570 *
566 * iPAQ 571 * iPAQ
567 * 572 *
568 **************************************************/ 573 **************************************************/
569 574
570void iPAQ::init ( ) 575void iPAQ::init ( )
571{ 576{
572 d-> m_vendorstr = "HP"; 577 d-> m_vendorstr = "HP";
573 d-> m_vendor = Vendor_HP; 578 d-> m_vendor = Vendor_HP;
574 579
575 QFile f ( "/proc/hal/model" ); 580 QFile f ( "/proc/hal/model" );
576 581
577 if ( f. open ( IO_ReadOnly )) { 582 if ( f. open ( IO_ReadOnly )) {
578 QTextStream ts ( &f ); 583 QTextStream ts ( &f );
579 584
580 d-> m_modelstr = "H" + ts. readLine ( ); 585 d-> m_modelstr = "H" + ts. readLine ( );
581 586
582 if ( d-> m_modelstr == "H3100" ) 587 if ( d-> m_modelstr == "H3100" )
583 d-> m_model = Model_iPAQ_H31xx; 588 d-> m_model = Model_iPAQ_H31xx;
584 else if ( d-> m_modelstr == "H3600" ) 589 else if ( d-> m_modelstr == "H3600" )
585 d-> m_model = Model_iPAQ_H36xx; 590 d-> m_model = Model_iPAQ_H36xx;
586 else if ( d-> m_modelstr == "H3700" ) 591 else if ( d-> m_modelstr == "H3700" )
587 d-> m_model = Model_iPAQ_H37xx; 592 d-> m_model = Model_iPAQ_H37xx;
588 else if ( d-> m_modelstr == "H3800" ) 593 else if ( d-> m_modelstr == "H3800" )
589 d-> m_model = Model_iPAQ_H38xx; 594 d-> m_model = Model_iPAQ_H38xx;
590 else if ( d-> m_modelstr == "H3900" ) 595 else if ( d-> m_modelstr == "H3900" )
591 d-> m_model = Model_iPAQ_H39xx; 596 d-> m_model = Model_iPAQ_H39xx;
592 else 597 else
593 d-> m_model = Model_Unknown; 598 d-> m_model = Model_Unknown;
594 599
595 f. close ( ); 600 f. close ( );
596 } 601 }
597 602
598 switch ( d-> m_model ) { 603 switch ( d-> m_model ) {
599 case Model_iPAQ_H31xx: 604 case Model_iPAQ_H31xx:
600 case Model_iPAQ_H38xx: 605 case Model_iPAQ_H38xx:
601 d-> m_rotation = Rot90; 606 d-> m_rotation = Rot90;
602 break; 607 break;
603 case Model_iPAQ_H36xx: 608 case Model_iPAQ_H36xx:
604 case Model_iPAQ_H37xx: 609 case Model_iPAQ_H37xx:
605 case Model_iPAQ_H39xx: 610 case Model_iPAQ_H39xx:
606 default: 611 default:
607 d-> m_rotation = Rot270; 612 d-> m_rotation = Rot270;
608 break; 613 break;
609 } 614 }
610 615
611 f. setName ( "/etc/familiar-version" ); 616 f. setName ( "/etc/familiar-version" );
612 if ( f. open ( IO_ReadOnly )) { 617 if ( f. open ( IO_ReadOnly )) {
613 d-> m_systemstr = "Familiar"; 618 d-> m_systemstr = "Familiar";
614 d-> m_system = System_Familiar; 619 d-> m_system = System_Familiar;
615 620
616 QTextStream ts ( &f ); 621 QTextStream ts ( &f );
617 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 622 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
618 623
619 f. close ( ); 624 f. close ( );
620 } 625 }
621 626
622 m_leds [0] = m_leds [1] = Led_Off; 627 m_leds [0] = m_leds [1] = Led_Off;
623 628
624 m_power_timer = 0; 629 m_power_timer = 0;
625 630
626 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 631 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
627 i_button *ib = ipaq_buttons + i; 632 i_button *ib = ipaq_buttons + i;
628 ODeviceButton b; 633 ODeviceButton b;
629 634
630 if (( ib-> model & d-> m_model ) == d-> m_model ) { 635 if (( ib-> model & d-> m_model ) == d-> m_model ) {
631 b. setKeycode ( ib-> code ); 636 b. setKeycode ( ib-> code );
632 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 637 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
633 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 638 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
634 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 639 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
635 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 640 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
636 641
637 d-> m_buttons. append ( b ); 642 d-> m_buttons. append ( b );
638 } 643 }
639 } 644 }
640 reloadButtonMapping ( ); 645 reloadButtonMapping ( );
641 646
642 if ( d-> m_qwsserver ) 647 if ( d-> m_qwsserver )
643 QWSServer::setKeyboardFilter ( this ); 648 QWSServer::setKeyboardFilter ( this );
644} 649}
645 650
646//#include <linux/h3600_ts.h> // including kernel headers is evil ... 651//#include <linux/h3600_ts.h> // including kernel headers is evil ...
647 652
648typedef struct { 653typedef struct {
649 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 654 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
650 unsigned char TotalTime; /* Units of 5 seconds */ 655 unsigned char TotalTime; /* Units of 5 seconds */
651 unsigned char OnTime; /* units of 100m/s */ 656 unsigned char OnTime; /* units of 100m/s */
652 unsigned char OffTime; /* units of 100m/s */ 657 unsigned char OffTime; /* units of 100m/s */
653} LED_IN; 658} LED_IN;
654 659
655typedef struct { 660typedef struct {
656 unsigned char mode; 661 unsigned char mode;
657 unsigned char pwr; 662 unsigned char pwr;
658 unsigned char brightness; 663 unsigned char brightness;
659} FLITE_IN; 664} FLITE_IN;
660 665
661#define LED_ON OD_IOW( 'f', 5, LED_IN ) 666#define LED_ON OD_IOW( 'f', 5, LED_IN )
662#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 667#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
663 668
664 669
665QValueList <OLed> iPAQ::ledList ( ) const 670QValueList <OLed> iPAQ::ledList ( ) const
666{ 671{
667 QValueList <OLed> vl; 672 QValueList <OLed> vl;
668 vl << Led_Power; 673 vl << Led_Power;
669 674
670 if ( d-> m_model == Model_iPAQ_H38xx ) 675 if ( d-> m_model == Model_iPAQ_H38xx )
671 vl << Led_BlueTooth; 676 vl << Led_BlueTooth;
672 return vl; 677 return vl;
673} 678}
674 679
675QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 680QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
676{ 681{
677 QValueList <OLedState> vl; 682 QValueList <OLedState> vl;
678 683
679 if ( l == Led_Power ) 684 if ( l == Led_Power )
680 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 685 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
681 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 686 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
682 vl << Led_Off; // << Led_On << ??? 687 vl << Led_Off; // << Led_On << ???
683 688
684 return vl; 689 return vl;
685} 690}
686 691
687OLedState iPAQ::ledState ( OLed l ) const 692OLedState iPAQ::ledState ( OLed l ) const
688 { 693 {
689 switch ( l ) { 694 switch ( l ) {
690 case Led_Power: 695 case Led_Power:
691 return m_leds [0]; 696 return m_leds [0];
692 case Led_BlueTooth: 697 case Led_BlueTooth:
693 return m_leds [1]; 698 return m_leds [1];
694 default: 699 default:
695 return Led_Off; 700 return Led_Off;
696 } 701 }
697} 702}
698 703
699bool iPAQ::setLedState ( OLed l, OLedState st ) 704bool iPAQ::setLedState ( OLed l, OLedState st )
700{ 705{
701 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 706 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
702 707
703 if ( l == Led_Power ) { 708 if ( l == Led_Power ) {
704 if ( fd >= 0 ) { 709 if ( fd >= 0 ) {
705 LED_IN leds; 710 LED_IN leds;
706 ::memset ( &leds, 0, sizeof( leds )); 711 ::memset ( &leds, 0, sizeof( leds ));
707 leds. TotalTime = 0; 712 leds. TotalTime = 0;
708 leds. OnTime = 0; 713 leds. OnTime = 0;
709 leds. OffTime = 1; 714 leds. OffTime = 1;
710 leds. OffOnBlink = 2; 715 leds. OffOnBlink = 2;
711 716
712 switch ( st ) { 717 switch ( st ) {
713 case Led_Off : leds. OffOnBlink = 0; break; 718 case Led_Off : leds. OffOnBlink = 0; break;
714 case Led_On : leds. OffOnBlink = 1; break; 719 case Led_On : leds. OffOnBlink = 1; break;
715 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 720 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
716 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 721 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
717 } 722 }
718 723
719 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 724 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
720 m_leds [0] = st; 725 m_leds [0] = st;
721 return true; 726 return true;
722 } 727 }
723 } 728 }
724 } 729 }
725 return false; 730 return false;
726} 731}
727 732
728 733
729bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 734bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
730{ 735{
731 int newkeycode = keycode; 736 int newkeycode = keycode;
732 737
733 switch ( keycode ) { 738 switch ( keycode ) {
734 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 739 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
735 case HardKey_Menu: { 740 case HardKey_Menu: {
736 if (( d-> m_model == Model_iPAQ_H38xx ) || 741 if (( d-> m_model == Model_iPAQ_H38xx ) ||
737 ( d-> m_model == Model_iPAQ_H39xx )) { 742 ( d-> m_model == Model_iPAQ_H39xx )) {
738 newkeycode = HardKey_Mail; 743 newkeycode = HardKey_Mail;
739 } 744 }
740 break; 745 break;
741 } 746 }
742 747
743 // Rotate cursor keys 180° 748 // Rotate cursor keys 180°
744 case Key_Left : 749 case Key_Left :
745 case Key_Right: 750 case Key_Right:
746 case Key_Up : 751 case Key_Up :
747 case Key_Down : { 752 case Key_Down : {
748 if (( d-> m_model == Model_iPAQ_H31xx ) || 753 if (( d-> m_model == Model_iPAQ_H31xx ) ||
749 ( d-> m_model == Model_iPAQ_H38xx )) { 754 ( d-> m_model == Model_iPAQ_H38xx )) {
750 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 755 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
751 } 756 }
752 break; 757 break;
753 } 758 }
754 759
755 // map Power Button short/long press to F34/F35 760 // map Power Button short/long press to F34/F35
756 case Key_SysReq: { 761 case Key_SysReq: {
757 if ( isPress ) { 762 if ( isPress ) {
758 if ( m_power_timer ) 763 if ( m_power_timer )
759 killTimer ( m_power_timer ); 764 killTimer ( m_power_timer );
760 m_power_timer = startTimer ( 500 ); 765 m_power_timer = startTimer ( 500 );
761 } 766 }
762 else if ( m_power_timer ) { 767 else if ( m_power_timer ) {
763 killTimer ( m_power_timer ); 768 killTimer ( m_power_timer );
764 m_power_timer = 0; 769 m_power_timer = 0;
765 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 770 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
766 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 771 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
767 } 772 }
768 newkeycode = Key_unknown; 773 newkeycode = Key_unknown;
769 break; 774 break;
770 } 775 }
771 } 776 }
772 777
773 if ( newkeycode != keycode ) { 778 if ( newkeycode != keycode ) {
774 if ( newkeycode != Key_unknown ) 779 if ( newkeycode != Key_unknown )
775 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 780 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
776 return true; 781 return true;
777 } 782 }
778 else 783 else
779 return false; 784 return false;
780} 785}
781 786
782void iPAQ::timerEvent ( QTimerEvent * ) 787void iPAQ::timerEvent ( QTimerEvent * )
783{ 788{
784 killTimer ( m_power_timer ); 789 killTimer ( m_power_timer );
785 m_power_timer = 0; 790 m_power_timer = 0;
786 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 791 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
787 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 792 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
788} 793}
789 794
790 795
791void iPAQ::alarmSound ( ) 796void iPAQ::alarmSound ( )
792{ 797{
793#ifndef QT_NO_SOUND 798#ifndef QT_NO_SOUND
794 static Sound snd ( "alarm" ); 799 static Sound snd ( "alarm" );
795 int fd; 800 int fd;
796 int vol; 801 int vol;
797 bool vol_reset = false; 802 bool vol_reset = false;
798 803
799 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 804 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
800 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 805 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
801 Config cfg ( "qpe" ); 806 Config cfg ( "qpe" );
802 cfg. setGroup ( "Volume" ); 807 cfg. setGroup ( "Volume" );
803 808
804 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 809 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
805 if ( volalarm < 0 ) 810 if ( volalarm < 0 )
806 volalarm = 0; 811 volalarm = 0;
807 else if ( volalarm > 100 ) 812 else if ( volalarm > 100 )
808 volalarm = 100; 813 volalarm = 100;
809 volalarm |= ( volalarm << 8 ); 814 volalarm |= ( volalarm << 8 );
810 815
811 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 816 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
812 vol_reset = true; 817 vol_reset = true;
813 } 818 }
814 } 819 }
815 820
816 snd. play ( ); 821 snd. play ( );
817 while ( !snd. isFinished ( )) 822 while ( !snd. isFinished ( ))
818 qApp-> processEvents ( ); 823 qApp-> processEvents ( );
819 824
820 if ( fd >= 0 ) { 825 if ( fd >= 0 ) {
821 if ( vol_reset ) 826 if ( vol_reset )
822 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 827 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
823 ::close ( fd ); 828 ::close ( fd );
824 } 829 }
825#endif 830#endif
826} 831}
827 832
828 833
829bool iPAQ::setSoftSuspend ( bool soft ) 834bool iPAQ::setSoftSuspend ( bool soft )
830{ 835{
831 bool res = false; 836 bool res = false;
832 int fd; 837 int fd;
833 838
834 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 839 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
835 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 840 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
836 res = true; 841 res = true;
837 else 842 else
838 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 843 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
839 844
840 ::close ( fd ); 845 ::close ( fd );
841 } 846 }
842 else 847 else
843 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 848 ::perror ( "/proc/sys/ts/suspend_button_mode" );
844 849
845 return res; 850 return res;
846} 851}
847 852
848 853
849bool iPAQ::setDisplayBrightness ( int bright ) 854bool iPAQ::setDisplayBrightness ( int bright )
850{ 855{
851 bool res = false; 856 bool res = false;
852 int fd; 857 int fd;
853 858
854 if ( bright > 255 ) 859 if ( bright > 255 )
855 bright = 255; 860 bright = 255;
856 if ( bright < 0 ) 861 if ( bright < 0 )
857 bright = 0; 862 bright = 0;
858 863
859 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 864 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
860 FLITE_IN bl; 865 FLITE_IN bl;
861 bl. mode = 1; 866 bl. mode = 1;
862 bl. pwr = bright ? 1 : 0; 867 bl. pwr = bright ? 1 : 0;
863 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 868 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
864 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 869 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
865 ::close ( fd ); 870 ::close ( fd );
866 } 871 }
867 return res; 872 return res;
868} 873}
869 874
870int iPAQ::displayBrightnessResolution ( ) const 875int iPAQ::displayBrightnessResolution ( ) const
871{ 876{
872 switch ( model ( )) { 877 switch ( model ( )) {
873 case Model_iPAQ_H31xx: 878 case Model_iPAQ_H31xx:
874 case Model_iPAQ_H36xx: 879 case Model_iPAQ_H36xx:
875 case Model_iPAQ_H37xx: 880 case Model_iPAQ_H37xx:
876 return 128; // really 256, but >128 could damage the LCD 881 return 128; // really 256, but >128 could damage the LCD
877 882
878 case Model_iPAQ_H38xx: 883 case Model_iPAQ_H38xx:
879 case Model_iPAQ_H39xx: 884 case Model_iPAQ_H39xx:
880 return 64; 885 return 64;
881 886
882 default: 887 default:
883 return 2; 888 return 2;
884 } 889 }
885} 890}
886 891
887 892
888bool iPAQ::hasLightSensor ( ) const 893bool iPAQ::hasLightSensor ( ) const
889{ 894{
890 return true; 895 return true;
891} 896}
892 897
893int iPAQ::readLightSensor ( ) 898int iPAQ::readLightSensor ( )
894{ 899{
895 int fd; 900 int fd;
896 int val = -1; 901 int val = -1;
897 902
898 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 903 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
899 char buffer [8]; 904 char buffer [8];
900 905
901 if ( ::read ( fd, buffer, 5 ) == 5 ) { 906 if ( ::read ( fd, buffer, 5 ) == 5 ) {
902 char *endptr; 907 char *endptr;
903 908
904 buffer [4] = 0; 909 buffer [4] = 0;
905 val = ::strtol ( buffer + 2, &endptr, 16 ); 910 val = ::strtol ( buffer + 2, &endptr, 16 );
906 911
907 if ( *endptr != 0 ) 912 if ( *endptr != 0 )
908 val = -1; 913 val = -1;
909 } 914 }
910 ::close ( fd ); 915 ::close ( fd );
911 } 916 }
912 917
913 return val; 918 return val;
914} 919}
915 920
916int iPAQ::lightSensorResolution ( ) const 921int iPAQ::lightSensorResolution ( ) const
917{ 922{
918 return 256; 923 return 256;
919} 924}
920 925
921/************************************************** 926/**************************************************
922 * 927 *
923 * Zaurus 928 * Zaurus
924 * 929 *
925 **************************************************/ 930 **************************************************/
926 931
927 932
928 933
929void Zaurus::init ( ) 934void Zaurus::init ( )
930{ 935{
931 d-> m_vendorstr = "Sharp"; 936 d-> m_vendorstr = "Sharp";
932 d-> m_vendor = Vendor_Sharp; 937 d-> m_vendor = Vendor_Sharp;
933 938
934 QFile f ( "/proc/filesystems" ); 939 QFile f ( "/proc/filesystems" );
935 940
936 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 941 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
937 d-> m_vendorstr = "OpenZaurus Team"; 942 d-> m_vendorstr = "OpenZaurus Team";
938 d-> m_systemstr = "OpenZaurus"; 943 d-> m_systemstr = "OpenZaurus";
939 d-> m_system = System_OpenZaurus; 944 d-> m_system = System_OpenZaurus;
940 945
941 f. close ( ); 946 f. close ( );
942 947
943 f. setName ( "/etc/oz_version" ); 948 f. setName ( "/etc/oz_version" );
944 if ( f. open ( IO_ReadOnly )) { 949 if ( f. open ( IO_ReadOnly )) {
945 QTextStream ts ( &f ); 950 QTextStream ts ( &f );
946 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 951 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
947 f. close ( ); 952 f. close ( );
948 } 953 }
949 } 954 }
950 else { 955 else {
951 d-> m_systemstr = "Zaurus"; 956 d-> m_systemstr = "Zaurus";
952 d-> m_system = System_Zaurus; 957 d-> m_system = System_Zaurus;
953 } 958 }
954 959
955 f. setName ( "/proc/deviceinfo/product" ); 960 f. setName ( "/proc/deviceinfo/product" );
956 if ( f. open ( IO_ReadOnly ) ) { 961 if ( f. open ( IO_ReadOnly ) ) {
957 QTextStream ts ( &f ); 962 QTextStream ts ( &f );
958 QString model = ts. readLine ( ); 963 QString model = ts. readLine ( );
959 f. close ( ); 964 f. close ( );
960 965
961 d-> m_modelstr = QString("Zaurus ") + model; 966 d-> m_modelstr = QString("Zaurus ") + model;
962 if ( model == "SL-5500" ) 967 if ( model == "SL-5500" )
963 d-> m_model = Model_Zaurus_SL5500; 968 d-> m_model = Model_Zaurus_SL5500;
964 else if ( model == "SL-C700" ) 969 else if ( model == "SL-C700" )
965 d-> m_model = Model_Zaurus_SLC700; 970 d-> m_model = Model_Zaurus_SLC700;
966 else if ( model == "SL-A300" ) 971 else if ( model == "SL-A300" )
967 d-> m_model = Model_Zaurus_SLA300; 972 d-> m_model = Model_Zaurus_SLA300;
968 else if ( model == "SL-B600" || model == "SL-5600" ) 973 else if ( model == "SL-B600" || model == "SL-5600" )
969 d-> m_model = Model_Zaurus_SLB600; 974 d-> m_model = Model_Zaurus_SLB600;
970 else 975 else
971 d-> m_model = Model_Zaurus_SL5000; 976 d-> m_model = Model_Zaurus_SL5000;
972 } 977 }
973 else { 978 else {
974 d-> m_model = Model_Zaurus_SL5000; 979 d-> m_model = Model_Zaurus_SL5000;
975 d-> m_modelstr = "Zaurus (model unknown)"; 980 d-> m_modelstr = "Zaurus (model unknown)";
976 } 981 }
977 982
978 switch ( d-> m_model ) { 983 switch ( d-> m_model ) {
979 case Model_Zaurus_SLC700: 984 case Model_Zaurus_SLC700:
980 /* note for C700, we must check the display rotation 985 /* note for C700, we must check the display rotation
981 * sensor to set an appropriate value 986 * sensor to set an appropriate value
982 */ 987 */
983 case Model_Zaurus_SLA300: 988 case Model_Zaurus_SLA300:
984 case Model_Zaurus_SLB600: 989 case Model_Zaurus_SLB600:
985 case Model_Zaurus_SL5500: 990 case Model_Zaurus_SL5500:
986 case Model_Zaurus_SL5000: 991 case Model_Zaurus_SL5000:
987 default: 992 default:
988 d-> m_rotation = Rot270; 993 d-> m_rotation = Rot270;
989 break; 994 break;
990 } 995 }
991 996
992 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { 997 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
993 z_button *zb = z_buttons + i; 998 z_button *zb = z_buttons + i;
994 ODeviceButton b; 999 ODeviceButton b;
995 1000
996 b. setKeycode ( zb-> code ); 1001 b. setKeycode ( zb-> code );
997 b. setUserText ( qApp-> translate ( "Button", zb-> utext )); 1002 b. setUserText ( qApp-> translate ( "Button", zb-> utext ));
998 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1003 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
999 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1004 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1000 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1005 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1001 1006
1002 d-> m_buttons. append ( b ); 1007 d-> m_buttons. append ( b );
1003 } 1008 }
1004 reloadButtonMapping ( ); 1009 reloadButtonMapping ( );
1005 1010
1006 m_leds [0] = Led_Off; 1011 m_leds [0] = Led_Off;
1007} 1012}
1008 1013
1009#include <unistd.h> 1014#include <unistd.h>
1010#include <fcntl.h> 1015#include <fcntl.h>
1011#include <sys/ioctl.h> 1016#include <sys/ioctl.h>
1012 1017
1013//#include <asm/sharp_char.h> // including kernel headers is evil ... 1018//#include <asm/sharp_char.h> // including kernel headers is evil ...
1014 1019
1015#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1020#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1016 1021
1017 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1022 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1018#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1023#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1019 1024
1020#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1025#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1021#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1026#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1022#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1027#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1023 1028
1024/* --- for SHARP_BUZZER device --- */ 1029/* --- for SHARP_BUZZER device --- */
1025 1030
1026 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1031 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1027//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1032//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1028 1033
1029#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1034#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1030#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1035#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1031#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1036#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1032#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1037#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1033#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1038#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1034 1039
1035//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1040//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1036//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1041//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1037 1042
1038//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1043//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1039//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1044//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1040//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1045//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1041//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1046//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1042//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1047//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1043//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1048//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1044//#define SHARP_PDA_APPSTART 9 /* application start */ 1049//#define SHARP_PDA_APPSTART 9 /* application start */
1045//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1050//#define SHARP_PDA_APPQUIT 10 /* application ends */
1046 1051
1047//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1052//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1048//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1053//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1049//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1054//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1050//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1055//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1051// 1056//
1052 1057
1053 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1058 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1054#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1059#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1055 1060
1056typedef struct sharp_led_status { 1061typedef struct sharp_led_status {
1057 int which; /* select which LED status is wanted. */ 1062 int which; /* select which LED status is wanted. */
1058 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1063 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1059} sharp_led_status; 1064} sharp_led_status;
1060 1065
1061#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1066#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1062 1067
1063#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1068#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1064#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1069#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1065#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1070#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1066 1071
1067// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1072// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1068 1073
1069#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1074#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1070#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1075#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1071#define APM_EVT_POWER_BUTTON (1 << 0) 1076#define APM_EVT_POWER_BUTTON (1 << 0)
1072 1077
1073#define FL_IOCTL_STEP_CONTRAST 100 1078#define FL_IOCTL_STEP_CONTRAST 100
1074 1079
1075 1080
1076void Zaurus::buzzer ( int sound ) 1081void Zaurus::buzzer ( int sound )
1077{ 1082{
1078 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 1083 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
1079 1084
1080 if ( fd >= 0 ) 1085 if ( fd >= 0 )
1081 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1086 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1082} 1087}
1083 1088
1084 1089
1085void Zaurus::alarmSound ( ) 1090void Zaurus::alarmSound ( )
1086{ 1091{
1087 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1092 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1088} 1093}
1089 1094
1090void Zaurus::touchSound ( ) 1095void Zaurus::touchSound ( )
1091{ 1096{
1092 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1097 buzzer ( SHARP_BUZ_TOUCHSOUND );
1093} 1098}
1094 1099
1095void Zaurus::keySound ( ) 1100void Zaurus::keySound ( )
1096{ 1101{
1097 buzzer ( SHARP_BUZ_KEYSOUND ); 1102 buzzer ( SHARP_BUZ_KEYSOUND );
1098} 1103}
1099 1104
1100 1105
1101QValueList <OLed> Zaurus::ledList ( ) const 1106QValueList <OLed> Zaurus::ledList ( ) const
1102{ 1107{
1103 QValueList <OLed> vl; 1108 QValueList <OLed> vl;
1104 vl << Led_Mail; 1109 vl << Led_Mail;
1105 return vl; 1110 return vl;
1106} 1111}
1107 1112
1108QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1113QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1109{ 1114{
1110 QValueList <OLedState> vl; 1115 QValueList <OLedState> vl;
1111 1116
1112 if ( l == Led_Mail ) 1117 if ( l == Led_Mail )
1113 vl << Led_Off << Led_On << Led_BlinkSlow; 1118 vl << Led_Off << Led_On << Led_BlinkSlow;
1114 return vl; 1119 return vl;
1115} 1120}
1116 1121
1117OLedState Zaurus::ledState ( OLed which ) const 1122OLedState Zaurus::ledState ( OLed which ) const
1118{ 1123{
1119 if ( which == Led_Mail ) 1124 if ( which == Led_Mail )
1120 return m_leds [0]; 1125 return m_leds [0];
1121 else 1126 else
1122 return Led_Off; 1127 return Led_Off;
1123} 1128}
1124 1129
1125bool Zaurus::setLedState ( OLed which, OLedState st ) 1130bool Zaurus::setLedState ( OLed which, OLedState st )
1126{ 1131{
1127 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1132 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1128 1133
1129 if ( which == Led_Mail ) { 1134 if ( which == Led_Mail ) {
1130 if ( fd >= 0 ) { 1135 if ( fd >= 0 ) {
1131 struct sharp_led_status leds; 1136 struct sharp_led_status leds;
1132 ::memset ( &leds, 0, sizeof( leds )); 1137 ::memset ( &leds, 0, sizeof( leds ));
1133 leds. which = SHARP_LED_MAIL_EXISTS; 1138 leds. which = SHARP_LED_MAIL_EXISTS;
1134 bool ok = true; 1139 bool ok = true;
1135 1140
1136 switch ( st ) { 1141 switch ( st ) {
1137 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1142 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1138 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1143 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1139 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1144 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1140 default : ok = false; 1145 default : ok = false;
1141 } 1146 }
1142 1147
1143 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1148 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1144 m_leds [0] = st; 1149 m_leds [0] = st;
1145 return true; 1150 return true;
1146 } 1151 }
1147 } 1152 }
1148 } 1153 }
1149 return false; 1154 return false;
1150} 1155}
1151 1156
1152bool Zaurus::setSoftSuspend ( bool soft ) 1157bool Zaurus::setSoftSuspend ( bool soft )
1153{ 1158{
1154 bool res = false; 1159 bool res = false;
1155 int fd; 1160 int fd;
1156 1161
1157 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1162 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1158 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1163 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1159 1164
1160 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1165 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1161 1166
1162 if ( sources >= 0 ) { 1167 if ( sources >= 0 ) {
1163 if ( soft ) 1168 if ( soft )
1164 sources &= ~APM_EVT_POWER_BUTTON; 1169 sources &= ~APM_EVT_POWER_BUTTON;
1165 else 1170 else
1166 sources |= APM_EVT_POWER_BUTTON; 1171 sources |= APM_EVT_POWER_BUTTON;
1167 1172
1168 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1173 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1169 res = true; 1174 res = true;
1170 else 1175 else
1171 perror ( "APM_IOCGEVTSRC" ); 1176 perror ( "APM_IOCGEVTSRC" );
1172 } 1177 }
1173 else 1178 else
1174 perror ( "APM_IOCGEVTSRC" ); 1179 perror ( "APM_IOCGEVTSRC" );
1175 1180
1176 ::close ( fd ); 1181 ::close ( fd );
1177 } 1182 }
1178 else 1183 else
1179 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1184 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1180 1185
1181 return res; 1186 return res;
1182} 1187}
1183 1188
1184 1189
1185bool Zaurus::setDisplayBrightness ( int bright ) 1190bool Zaurus::setDisplayBrightness ( int bright )
1186{ 1191{
1187 bool res = false; 1192 bool res = false;
1188 int fd; 1193 int fd;
1189 1194
1190 if ( bright > 255 ) 1195 if ( bright > 255 )
1191 bright = 255; 1196 bright = 255;
1192 if ( bright < 0 ) 1197 if ( bright < 0 )
1193 bright = 0; 1198 bright = 0;
1194 1199
1195 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1200 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1196 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1201 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1197 if ( bright && !bl ) 1202 if ( bright && !bl )
1198 bl = 1; 1203 bl = 1;
1199 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1204 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1200 ::close ( fd ); 1205 ::close ( fd );
1201 } 1206 }
1202 return res; 1207 return res;
1203} 1208}
1204 1209
1205 1210
1206int Zaurus::displayBrightnessResolution ( ) const 1211int Zaurus::displayBrightnessResolution ( ) const
1207{ 1212{
1208 return 5; 1213 return 5;
1209} 1214}
1210 1215
1211 1216
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
index 2270343..4b22358 100644
--- a/libopie/odevicebutton.cpp
+++ b/libopie/odevicebutton.cpp
@@ -1,234 +1,235 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include <qstring.h> 22#include <qstring.h>
23 23
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <opie/odevicebutton.h> 25#include <opie/odevicebutton.h>
26 26
27using namespace Opie; 27using namespace Opie;
28 28
29 29
30class OQCopMessageData { 30class OQCopMessageData {
31 public: 31 public:
32 QCString m_channel; 32 QCString m_channel;
33 QCString m_message; 33 QCString m_message;
34 QByteArray m_data; 34 QByteArray m_data;
35}; 35};
36 36
37 37
38OQCopMessage::OQCopMessage ( ) 38OQCopMessage::OQCopMessage ( )
39 : d ( 0 ) 39 : d ( 0 )
40{ 40{
41 init ( QCString ( ), QCString ( ), QByteArray ( )); 41 init ( QCString ( ), QCString ( ), QByteArray ( ));
42} 42}
43 43
44OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 44OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
45 : d ( 0 ) 45 : d ( 0 )
46{ 46{
47 init ( copy. channel ( ), copy. message ( ), copy. data ( )); 47 init ( copy. channel ( ), copy. message ( ), copy. data ( ));
48} 48}
49 49
50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
51{ 51{
52 init ( assign. channel ( ), assign. message ( ), assign. data ( )); 52 init ( assign. channel ( ), assign. message ( ), assign. data ( ));
53 return *this; 53 return *this;
54} 54}
55 55
56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
57 : d ( 0 ) 57 : d ( 0 )
58{ 58{
59 init ( ch, m, arg ); 59 init ( ch, m, arg );
60} 60}
61 61
62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
63{ 63{
64 if ( !d ) 64 if ( !d )
65 d = new OQCopMessageData ( ); 65 d = new OQCopMessageData ( );
66 d-> m_channel = ch; 66 d-> m_channel = ch;
67 d-> m_message = m; 67 d-> m_message = m;
68 d-> m_data = arg; 68 d-> m_data = arg;
69} 69}
70 70
71bool OQCopMessage::send ( ) 71bool OQCopMessage::send ( )
72{ 72{
73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( )) 73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
74 return false; 74 return false;
75 75
76 QCopEnvelope e ( d-> m_channel, d-> m_message ); 76 QCopEnvelope e ( d-> m_channel, d-> m_message );
77 77
78 if ( d-> m_data. size ( )) 78 if ( d-> m_data. size ( ))
79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( )); 79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
80 80
81 return true; 81 return true;
82} 82}
83 83
84QCString OQCopMessage::channel ( ) const 84QCString OQCopMessage::channel ( ) const
85{ 85{
86 return d-> m_channel; 86 return d-> m_channel;
87} 87}
88 88
89QCString OQCopMessage::message ( ) const 89QCString OQCopMessage::message ( ) const
90{ 90{
91 return d-> m_message; 91 return d-> m_message;
92} 92}
93 93
94QByteArray OQCopMessage::data ( ) const 94QByteArray OQCopMessage::data ( ) const
95{ 95{
96 return d-> m_data; 96 return d-> m_data;
97} 97}
98 98
99void OQCopMessage::setChannel ( const QCString &ch ) 99void OQCopMessage::setChannel ( const QCString &ch )
100{ 100{
101 d-> m_channel = ch; 101 d-> m_channel = ch;
102} 102}
103 103
104void OQCopMessage::setMessage ( const QCString &m ) 104void OQCopMessage::setMessage ( const QCString &m )
105{ 105{
106 d-> m_message = m; 106 d-> m_message = m;
107} 107}
108 108
109void OQCopMessage::setData ( const QByteArray &data ) 109void OQCopMessage::setData ( const QByteArray &data )
110{ 110{
111 d-> m_data = data; 111 d-> m_data = data;
112} 112}
113 113
114/*! \class ODeviceButton 114/*! \class ODeviceButton
115 \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device. 115 \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device.
116 116
117 This class represents a physical button on a Qtopia device. A 117 This class represents a physical button on a Qtopia device. A
118 device may have "user programmable" buttons. 118 device may have "user programmable" buttons.
119 The location and number of buttons will vary from device to 119 The location and number of buttons will vary from device to
120 device. userText() and pixmap() may be used to describe this button 120 device. userText() and pixmap() may be used to describe this button
121 to the user in help documentation. 121 to the user in help documentation.
122 122
123 \ingroup qtopiaemb 123 \ingroup qtopiaemb
124 \internal 124 \internal
125*/ 125*/
126 126
127ODeviceButton::ODeviceButton() 127ODeviceButton::ODeviceButton()
128{ 128{
129} 129}
130 130
131ODeviceButton::~ODeviceButton() 131ODeviceButton::~ODeviceButton()
132{ 132{
133} 133}
134 134
135/*! 135/*!
136 Returns the button's keycode. 136 Returns the button's keycode.
137 */ 137 */
138ushort ODeviceButton::keycode() const 138ushort ODeviceButton::keycode() const
139{ 139{
140 return m_Keycode; 140 return m_Keycode;
141} 141}
142 142
143 143
144/*! 144/*!
145 This function returns a human readable, translated description of the button. 145 This function returns a human readable, translated description of the button.
146 */ 146 */
147QString ODeviceButton::userText() const 147QString ODeviceButton::userText() const
148{ 148{
149 return m_UserText; 149 return m_UserText;
150} 150}
151 151
152/*! 152/*!
153 This function returns the pixmap for this button. If there isn't one 153 This function returns the pixmap for this button. If there isn't one
154 it will return an empty (null) pixmap. 154 it will return an empty (null) pixmap.
155 */ 155 */
156QPixmap ODeviceButton::pixmap() const 156QPixmap ODeviceButton::pixmap() const
157{ 157{
158 return m_Pixmap; 158 return m_Pixmap;
159} 159}
160 160
161/*! 161/*!
162 This function returns the factory preset (default) action for when this button 162 This function returns the factory preset (default) action for when this button
163 is pressed. The return value is a legal QCop message. 163 is pressed. The return value is a legal QCop message.
164 */ 164 */
165OQCopMessage ODeviceButton::factoryPresetPressedAction() const 165OQCopMessage ODeviceButton::factoryPresetPressedAction() const
166{ 166{
167 return m_FactoryPresetPressedAction; 167 return m_FactoryPresetPressedAction;
168} 168}
169 169
170/*! 170/*!
171 This function returns the user assigned action for when this button is pressed. 171 This function returns the user assigned action for when this button is pressed.
172 If no action is assigned, factoryPresetAction() is returned. 172 If no action is assigned, factoryPresetAction() is returned.
173 */ 173 */
174OQCopMessage ODeviceButton::pressedAction() const 174OQCopMessage ODeviceButton::pressedAction() const
175{ 175{
176 if (m_PressedAction.channel().isEmpty()) 176 if (m_PressedAction.channel().isEmpty())
177 return factoryPresetPressedAction(); 177 return factoryPresetPressedAction();
178 return m_PressedAction; 178 return m_PressedAction;
179} 179}
180 180
181/*! 181/*!
182 This function returns the factory preset (default) action for when this button 182 This function returns the factory preset (default) action for when this button
183 is pressed and held. The return value is a legal QCop message. 183 is pressed and held. The return value is a legal QCop message.
184 */ 184 */
185OQCopMessage ODeviceButton::factoryPresetHeldAction() const 185OQCopMessage ODeviceButton::factoryPresetHeldAction() const
186{ 186{
187 return m_FactoryPresetHeldAction; 187 return m_FactoryPresetHeldAction;
188} 188}
189 189
190/*! 190/*!
191 This function returns the user assigned action for when this button is pressed 191 This function returns the user assigned action for when this button is pressed
192 and held. If no action is assigned, factoryPresetAction() is returned. 192 and held. If no action is assigned, factoryPresetAction() is returned.
193 */ 193 */
194OQCopMessage ODeviceButton::heldAction() const 194OQCopMessage ODeviceButton::heldAction() const
195{ 195{
196 if (m_HeldAction.channel().isEmpty()) 196 if (m_HeldAction.channel().isEmpty())
197 return factoryPresetHeldAction(); 197 return factoryPresetHeldAction();
198 return m_HeldAction; 198 return m_HeldAction;
199} 199}
200 200
201void ODeviceButton::setKeycode(ushort keycode) 201void ODeviceButton::setKeycode(ushort keycode)
202{ 202{
203 m_Keycode = keycode; 203 m_Keycode = keycode;
204} 204}
205 205
206void ODeviceButton::setUserText(const QString& text) 206void ODeviceButton::setUserText(const QString& text)
207{ 207{
208 m_UserText = text; 208 m_UserText = text;
209} 209}
210 210
211void ODeviceButton::setPixmap(const QPixmap& picture) 211void ODeviceButton::setPixmap(const QPixmap& picture)
212{ 212{
213 m_Pixmap = picture; 213 m_Pixmap = picture;
214} 214}
215 215
216void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 216void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
217{ 217{
218 m_FactoryPresetPressedAction = action; 218 m_FactoryPresetPressedAction = action;
219} 219}
220 220
221
221void ODeviceButton::setPressedAction(const OQCopMessage& action) 222void ODeviceButton::setPressedAction(const OQCopMessage& action)
222{ 223{
223 m_PressedAction = action; 224 m_PressedAction = action;
224} 225}
225 226
226void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 227void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
227{ 228{
228 m_FactoryPresetHeldAction = action; 229 m_FactoryPresetHeldAction = action;
229} 230}
230 231
231void ODeviceButton::setHeldAction(const OQCopMessage& action) 232void ODeviceButton::setHeldAction(const OQCopMessage& action)
232{ 233{
233 m_HeldAction = action; 234 m_HeldAction = action;
234} 235}