summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp40
-rw-r--r--core/launcher/desktop.h1
2 files changed, 10 insertions, 31 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 4640a12..68949e6 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,1035 +1,1015 @@
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 "desktop.h" 21#include "desktop.h"
22#include "info.h" 22#include "info.h"
23#include "launcher.h" 23#include "launcher.h"
24//#include "mrulist.h" 24//#include "mrulist.h"
25#include "qcopbridge.h" 25#include "qcopbridge.h"
26#include "shutdownimpl.h" 26#include "shutdownimpl.h"
27#include "startmenu.h" 27#include "startmenu.h"
28#include "taskbar.h" 28#include "taskbar.h"
29#include "transferserver.h" 29#include "transferserver.h"
30#include "irserver.h" 30#include "irserver.h"
31#include "packageslave.h" 31#include "packageslave.h"
32 32
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/password.h> 35#include <qpe/password.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/timeconversion.h> 38#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/network.h> 40#include <qpe/network.h>
41#include <qpe/global.h> 41#include <qpe/global.h>
42 42
43#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 43#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
44#include <qpe/custom.h> 44#include <qpe/custom.h>
45#endif 45#endif
46 46
47#include <opie/odevice.h> 47#include <opie/odevice.h>
48 48
49#include <qgfx_qws.h> 49#include <qgfx_qws.h>
50#include <qmainwindow.h> 50#include <qmainwindow.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qtimer.h> 52#include <qtimer.h>
53#include <qwindowsystem_qws.h> 53#include <qwindowsystem_qws.h>
54 54
55#include <qvaluelist.h> 55#include <qvaluelist.h>
56 56
57#include <stdlib.h> 57#include <stdlib.h>
58#include <unistd.h> 58#include <unistd.h>
59#include <fcntl.h> 59#include <fcntl.h>
60 60
61using namespace Opie;
62
61class QCopKeyRegister 63class QCopKeyRegister
62{ 64{
63public: 65public:
64 QCopKeyRegister() : keyCode( 0 ) 66 QCopKeyRegister() : keyCode( 0 )
65 { } 67 { }
66 QCopKeyRegister( int k, const QString &c, const QString &m ) 68 QCopKeyRegister( int k, const QString &c, const QString &m )
67 : keyCode( k ), channel( c ), message( m ) 69 : keyCode( k ), channel( c ), message( m )
68 { } 70 { }
69 71
70 int getKeyCode() const 72 int getKeyCode() const
71 { 73 {
72 return keyCode; 74 return keyCode;
73 } 75 }
74 QString getChannel() const 76 QString getChannel() const
75 { 77 {
76 return channel; 78 return channel;
77 } 79 }
78 QString getMessage() const 80 QString getMessage() const
79 { 81 {
80 return message; 82 return message;
81 } 83 }
82 84
83private: 85private:
84 int keyCode; 86 int keyCode;
85 QString channel, message; 87 QString channel, message;
86}; 88};
87 89
88typedef QValueList<QCopKeyRegister> KeyRegisterList; 90typedef QValueList<QCopKeyRegister> KeyRegisterList;
89KeyRegisterList keyRegisterList; 91KeyRegisterList keyRegisterList;
90 92
91static Desktop* qpedesktop = 0; 93static Desktop* qpedesktop = 0;
92static int loggedin = 0; 94static int loggedin = 0;
93static void login( bool at_poweron ) 95static void login( bool at_poweron )
94{ 96{
95 if ( !loggedin ) { 97 if ( !loggedin ) {
96 Global::terminateBuiltin( "calibrate" ); 98 Global::terminateBuiltin( "calibrate" );
97 Password::authenticate( at_poweron ); 99 Password::authenticate( at_poweron );
98 loggedin = 1; 100 loggedin = 1;
99 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 101 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
100 } 102 }
101} 103}
102 104
103bool Desktop::screenLocked() 105bool Desktop::screenLocked()
104{ 106{
105 return loggedin == 0; 107 return loggedin == 0;
106} 108}
107 109
108/* 110/*
109 Priority is number of alerts that are needed to pop up 111 Priority is number of alerts that are needed to pop up
110 alert. 112 alert.
111 */ 113 */
112class DesktopPowerAlerter : public QMessageBox 114class DesktopPowerAlerter : public QMessageBox
113{ 115{
114public: 116public:
115 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 117 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
116 : QMessageBox( tr( "Battery Status" ), "Low Battery", 118 : QMessageBox( tr( "Battery Status" ), "Low Battery",
117 QMessageBox::Critical, 119 QMessageBox::Critical,
118 QMessageBox::Ok | QMessageBox::Default, 120 QMessageBox::Ok | QMessageBox::Default,
119 QMessageBox::NoButton, QMessageBox::NoButton, 121 QMessageBox::NoButton, QMessageBox::NoButton,
120 parent, name, FALSE ) 122 parent, name, FALSE )
121 { 123 {
122 currentPriority = INT_MAX; 124 currentPriority = INT_MAX;
123 alertCount = 0; 125 alertCount = 0;
124 } 126 }
125 127
126 void alert( const QString &text, int priority ); 128 void alert( const QString &text, int priority );
127 void hideEvent( QHideEvent * ); 129 void hideEvent( QHideEvent * );
128private: 130private:
129 int currentPriority; 131 int currentPriority;
130 int alertCount; 132 int alertCount;
131}; 133};
132 134
133void DesktopPowerAlerter::alert( const QString &text, int priority ) 135void DesktopPowerAlerter::alert( const QString &text, int priority )
134{ 136{
135 alertCount++; 137 alertCount++;
136 if ( alertCount < priority ) 138 if ( alertCount < priority )
137 return ; 139 return ;
138 if ( priority > currentPriority ) 140 if ( priority > currentPriority )
139 return ; 141 return ;
140 currentPriority = priority; 142 currentPriority = priority;
141 setText( text ); 143 setText( text );
142 show(); 144 show();
143} 145}
144 146
145 147
146void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 148void DesktopPowerAlerter::hideEvent( QHideEvent *e )
147{ 149{
148 QMessageBox::hideEvent( e ); 150 QMessageBox::hideEvent( e );
149 alertCount = 0; 151 alertCount = 0;
150 currentPriority = INT_MAX; 152 currentPriority = INT_MAX;
151} 153}
152 154
153 155
154class QPEScreenSaver : public QWSScreenSaver 156class QPEScreenSaver : public QWSScreenSaver
155{ 157{
156private: 158private:
157 int LcdOn; 159 int LcdOn;
158 160
159public: 161public:
160 QPEScreenSaver() 162 QPEScreenSaver()
161 { 163 {
162 m_disable_suspend = 100; 164 m_disable_suspend = 100;
163 m_enable_dim = false; 165 m_enable_dim = false;
164 m_enable_lightoff = false; 166 m_enable_lightoff = false;
165 m_enable_onlylcdoff = false; 167 m_enable_onlylcdoff = false;
166 168
167 m_lcd_status = true; 169 m_lcd_status = true;
168 170
169 m_backlight_bright = -1; 171 m_backlight_bright = -1;
170 m_backlight_forcedoff = false; 172 m_backlight_forcedoff = false;
171 173
172 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 174 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
173 ODevice::inst ( ) -> setDisplayStatus ( true ); 175 ODevice::inst ( ) -> setDisplayStatus ( true );
174 } 176 }
175 void restore() 177 void restore()
176 { 178 {
177 if ( !m_lcd_status ) // We must have turned it off 179 if ( !m_lcd_status ) // We must have turned it off
178 ODevice::inst ( ) -> setDisplayStatus ( true ); 180 ODevice::inst ( ) -> setDisplayStatus ( true );
179 181
180 setBacklight ( -1 ); 182 setBacklight ( -3 );
181 } 183 }
182 bool save( int level ) 184 bool save( int level )
183 { 185 {
184 switch ( level ) { 186 switch ( level ) {
185 case 0: 187 case 0:
186 if ( m_disable_suspend > 0 && m_enable_dim ) { 188 if ( m_disable_suspend > 0 && m_enable_dim ) {
187 if ( backlight() > 1 ) 189 if ( backlight() > 1 )
188 setBacklight( 1 ); // lowest non-off 190 setBacklight( 1 ); // lowest non-off
189 } 191 }
190 return true; 192 return true;
191 break; 193 break;
192 case 1: 194 case 1:
193 if ( m_disable_suspend > 1 && m_enable_lightoff ) { 195 if ( m_disable_suspend > 1 && m_enable_lightoff ) {
194 setBacklight( 0 ); // off 196 setBacklight( 0 ); // off
195 } 197 }
196 return true; 198 return true;
197 break; 199 break;
198 case 2: 200 case 2:
199 if ( m_enable_onlylcdoff ) { 201 if ( m_enable_onlylcdoff ) {
200 ODevice::inst ( ) -> setDisplayStatus ( false ); 202 ODevice::inst ( ) -> setDisplayStatus ( false );
201 m_lcd_status = false; 203 m_lcd_status = false;
202 return true; 204 return true;
203 } 205 }
204 else // We're going to suspend the whole machine 206 else // We're going to suspend the whole machine
205 { 207 {
206 if ( ( m_disable_suspend > 2 ) && 208 if ( ( m_disable_suspend > 2 ) &&
207 ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && 209 ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) &&
208 ( !Network::networkOnline ( ) ) ) { 210 ( !Network::networkOnline ( ) ) ) {
209 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 211 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
210 return true; 212 return true;
211 } 213 }
212 } 214 }
213 break; 215 break;
214 } 216 }
215 return false; 217 return false;
216 } 218 }
217 219
218private: 220private:
219 static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) 221 static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def )
220 { 222 {
221 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) 223 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 )
222 return 0; 224 return 0;
223 225
224 if ( interval < 0 ) { 226 if ( interval < 0 ) {
225 // Restore screen blanking and power saving state 227 // Restore screen blanking and power saving state
226 interval = config.readNumEntry( value, def ); 228 interval = config.readNumEntry( value, def );
227 } 229 }
228 return interval; 230 return interval;
229 } 231 }
230 232
231public: 233public:
232 void setIntervals( int i1, int i2, int i3 ) 234 void setIntervals( int i1, int i2, int i3 )
233 { 235 {
234 Config config( "qpe" ); 236 Config config( "qpe" );
235 config.setGroup( "Screensaver" ); 237 config.setGroup( "Screensaver" );
236 238
237 int v[ 4 ]; 239 int v[ 4 ];
238 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); 240 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 );
239 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); 241 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 );
240 i3 = ssi( i3, config, "", "Interval", 60 ); 242 i3 = ssi( i3, config, "", "Interval", 60 );
241 243
242 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 244 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
243 245
244 v [ 0 ] = QMAX( 1000 * i1, 100 ); 246 v [ 0 ] = QMAX( 1000 * i1, 100 );
245 v [ 1 ] = QMAX( 1000 * i2, 100 ); 247 v [ 1 ] = QMAX( 1000 * i2, 100 );
246 v [ 2 ] = QMAX( 1000 * i3, 100 ); 248 v [ 2 ] = QMAX( 1000 * i3, 100 );
247 v [ 3 ] = 0; 249 v [ 3 ] = 0;
248 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); 250 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false );
249 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); 251 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false );
250 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); 252 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 );
251 253
252 if ( !i1 && !i2 && !i3 ) 254 if ( !i1 && !i2 && !i3 )
253 QWSServer::setScreenSaverInterval( 0 ); 255 QWSServer::setScreenSaverInterval( 0 );
254 else 256 else
255 QWSServer::setScreenSaverIntervals( v ); 257 QWSServer::setScreenSaverIntervals( v );
256 } 258 }
257 259
258 void setInterval ( int interval ) 260 void setInterval ( int interval )
259 { 261 {
260 setIntervals ( -1, -1, interval ); 262 setIntervals ( -1, -1, interval );
261 } 263 }
262 264
263 void setMode ( int mode ) 265 void setMode ( int mode )
264 { 266 {
265 if ( mode > m_disable_suspend ) 267 if ( mode > m_disable_suspend )
266 setInterval( -1 ); 268 setInterval( -1 );
267 m_disable_suspend = mode; 269 m_disable_suspend = mode;
268 } 270 }
269 271
270 int backlight ( ) 272 int backlight ( )
271 { 273 {
272 if ( m_backlight_bright == -1 ) { 274 if ( m_backlight_bright == -1 ) {
273 // Read from config 275 // Read from config
274 Config config ( "qpe" ); 276 Config config ( "qpe" );
275 config. setGroup ( "Screensaver" ); 277 config. setGroup ( "Screensaver" );
276 m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); 278 m_backlight_bright = config. readNumEntry ( "Brightness", 255 );
277 } 279 }
278 return m_backlight_bright; 280 return m_backlight_bright;
279 } 281 }
280 282
281 void setBacklight ( int bright ) 283 void setBacklight ( int bright )
282 { 284 {
283 if ( bright == -3 ) { 285 if ( bright == -3 ) {
284 // Forced on 286 // Forced on
285 m_backlight_forcedoff = false; 287 m_backlight_forcedoff = false;
286 bright = -1; 288 bright = -1;
287 } 289 }
288 if ( m_backlight_forcedoff && bright != -2 ) 290 if ( m_backlight_forcedoff && bright != -2 )
289 return ; 291 return ;
290 if ( bright == -2 ) { 292 if ( bright == -2 ) {
291 // Toggle between off and on 293 // Toggle between off and on
292 bright = m_backlight_bright ? 0 : -1; 294 bright = m_backlight_bright ? 0 : -1;
293 m_backlight_forcedoff = !bright; 295 m_backlight_forcedoff = !bright;
294 } 296 }
295 297
296 m_backlight_bright = bright; 298 m_backlight_bright = bright;
297 299
298 bright = backlight ( ); 300 bright = backlight ( );
299 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 301 ODevice::inst ( ) -> setDisplayBrightness ( bright );
300 302
301 m_backlight_bright = bright; 303 m_backlight_bright = bright;
302 } 304 }
303 305
304private: 306private:
305 int m_disable_suspend; 307 int m_disable_suspend;
306 bool m_enable_dim; 308 bool m_enable_dim;
307 bool m_enable_lightoff; 309 bool m_enable_lightoff;
308 bool m_enable_onlylcdoff; 310 bool m_enable_onlylcdoff;
309 311
310 bool m_lcd_status; 312 bool m_lcd_status;
311 313
312 int m_backlight_bright; 314 int m_backlight_bright;
313 bool m_backlight_forcedoff; 315 bool m_backlight_forcedoff;
314}; 316};
315 317
316 318
317void DesktopApplication::switchLCD ( bool on ) 319void DesktopApplication::switchLCD ( bool on )
318{ 320{
319 if ( qApp ) { 321 if ( qApp ) {
320 DesktopApplication *dapp = (DesktopApplication *) qApp; 322 DesktopApplication *dapp = (DesktopApplication *) qApp;
321 323
322 if ( dapp-> m_screensaver ) 324 if ( dapp-> m_screensaver ) {
323 dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 ); 325 if ( on )
326 dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 );
327 else
328 dapp-> m_screensaver-> save ( 1 );
329
330 }
324 } 331 }
325} 332}
326 333
327 334
328DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 335DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
329 : QPEApplication( argc, argv, appType ) 336 : QPEApplication( argc, argv, appType )
330{ 337{
331 338
332 QTimer * t = new QTimer( this ); 339 QTimer * t = new QTimer( this );
333 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); 340 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
334 t->start( 10000 ); 341 t->start( 10000 );
335 ps = new PowerStatus; 342 ps = new PowerStatus;
336 pa = new DesktopPowerAlerter( 0 ); 343 pa = new DesktopPowerAlerter( 0 );
337 344
338 channel = new QCopChannel( "QPE/Desktop", this ); 345 channel = new QCopChannel( "QPE/Desktop", this );
339 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 346 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
340 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 347 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
341 348
342 channel = new QCopChannel( "QPE/System", this ); 349 channel = new QCopChannel( "QPE/System", this );
343 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 350 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
344 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 351 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
345 352
346 m_screensaver = new QPEScreenSaver; 353 m_screensaver = new QPEScreenSaver;
347 354
348 m_screensaver-> setInterval ( -1 ); 355 m_screensaver-> setInterval ( -1 );
349 QWSServer::setScreenSaver( m_screensaver ); 356 QWSServer::setScreenSaver( m_screensaver );
350} 357}
351 358
352 359
353DesktopApplication::~DesktopApplication() 360DesktopApplication::~DesktopApplication()
354{ 361{
355 delete ps; 362 delete ps;
356 delete pa; 363 delete pa;
357} 364}
358 365
359void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) 366void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
360{ 367{
361#ifdef Q_WS_QWS 368#ifdef Q_WS_QWS
362 QDataStream stream( data, IO_ReadOnly ); 369 QDataStream stream( data, IO_ReadOnly );
363 if ( msg == "keyRegister(int key, QString channel, QString message)" ) { 370 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
364 int k; 371 int k;
365 QString c, m; 372 QString c, m;
366 stream >> k; 373 stream >> k;
367 stream >> c; 374 stream >> c;
368 stream >> m; 375 stream >> m;
369 376
370 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); 377 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
371 keyRegisterList.append( QCopKeyRegister( k, c, m ) ); 378 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
372 } 379 }
373 else if ( msg == "suspend()" ) { 380 else if ( msg == "suspend()" ) {
374 emit power(); 381 emit power();
375 } 382 }
376#endif 383#endif
377} 384}
378 385
379 386
380void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 387void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
381{ 388{
382#ifdef Q_WS_QWS 389#ifdef Q_WS_QWS
383 QDataStream stream ( data, IO_ReadOnly ); 390 QDataStream stream ( data, IO_ReadOnly );
384 391
385 if ( msg == "setScreenSaverInterval(int)" ) { 392 if ( msg == "setScreenSaverInterval(int)" ) {
386 int time; 393 int time;
387 stream >> time; 394 stream >> time;
388 m_screensaver-> setInterval( time ); 395 m_screensaver-> setInterval( time );
389 } 396 }
390 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 397 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
391 int t1, t2, t3; 398 int t1, t2, t3;
392 stream >> t1 >> t2 >> t3; 399 stream >> t1 >> t2 >> t3;
393 m_screensaver-> setIntervals( t1, t2, t3 ); 400 m_screensaver-> setIntervals( t1, t2, t3 );
394 } 401 }
395 else if ( msg == "setBacklight(int)" ) { 402 else if ( msg == "setBacklight(int)" ) {
396 int bright; 403 int bright;
397 stream >> bright; 404 stream >> bright;
398 m_screensaver-> setBacklight( bright ); 405 m_screensaver-> setBacklight( bright );
399 } 406 }
400 else if ( msg == "setScreenSaverMode(int)" ) { 407 else if ( msg == "setScreenSaverMode(int)" ) {
401 int mode; 408 int mode;
402 stream >> mode; 409 stream >> mode;
403 m_screensaver-> setMode ( mode ); 410 m_screensaver-> setMode ( mode );
404 } 411 }
405#endif 412#endif
406} 413}
407 414
408enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 415enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
409 416
410#ifdef Q_WS_QWS 417#ifdef Q_WS_QWS
411bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 418bool DesktopApplication::qwsEventFilter( QWSEvent *e )
412{ 419{
413 qpedesktop->checkMemory(); 420 qpedesktop->checkMemory();
414 421
415 if ( e->type == QWSEvent::Key ) { 422 if ( e->type == QWSEvent::Key ) {
416 QWSKeyEvent * ke = ( QWSKeyEvent * ) e; 423 QWSKeyEvent * ke = ( QWSKeyEvent * ) e;
417 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 424 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
418 return TRUE; 425 return TRUE;
419 bool press = ke->simpleData.is_press; 426 bool press = ke->simpleData.is_press;
420 bool autoRepeat = ke->simpleData.is_auto_repeat; 427 bool autoRepeat = ke->simpleData.is_auto_repeat;
421 428
422 /* 429 /*
423 app that registers key/message to be sent back to the app, when it doesn't have focus, 430 app that registers key/message to be sent back to the app, when it doesn't have focus,
424 when user presses key, unless keyboard has been requested from app. 431 when user presses key, unless keyboard has been requested from app.
425 will not send multiple repeats if user holds key 432 will not send multiple repeats if user holds key
426 i.e. one shot 433 i.e. one shot
427 */ 434 */
428 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { 435 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) {
429// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); 436// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode);
430 KeyRegisterList::Iterator it; 437 KeyRegisterList::Iterator it;
431 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 438 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
432 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { 439 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) {
433 if ( press ) 440 if ( press )
434 qDebug( "press" ); 441 qDebug( "press" );
435 else 442 else
436 qDebug( "release" ); 443 qDebug( "release" );
437 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); 444 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() );
438 } 445 }
439 } 446 }
440 } 447 }
441 448
442 if ( !keyboardGrabbed() ) { 449 if ( !keyboardGrabbed() ) {
443 if ( ke->simpleData.keycode == Key_F9 ) { 450 if ( ke->simpleData.keycode == Key_F9 ) {
444 if ( press ) 451 if ( press )
445 emit datebook(); 452 emit datebook();
446 return TRUE; 453 return TRUE;
447 } 454 }
448 if ( ke->simpleData.keycode == Key_F10 ) { 455 if ( ke->simpleData.keycode == Key_F10 ) {
449 if ( !press && cardSendTimer ) { 456 if ( !press && cardSendTimer ) {
450 emit contacts(); 457 emit contacts();
451 delete cardSendTimer; 458 delete cardSendTimer;
452 } 459 }
453 else if ( press ) { 460 else if ( press ) {
454 cardSendTimer = new QTimer(); 461 cardSendTimer = new QTimer();
455 cardSendTimer->start( 2000, TRUE ); 462 cardSendTimer->start( 2000, TRUE );
456 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 463 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
457 } 464 }
458 return TRUE; 465 return TRUE;
459 } 466 }
460 /* menu key now opens application menu/toolbar 467 /* menu key now opens application menu/toolbar
461 if ( ke->simpleData.keycode == Key_F11 ) { 468 if ( ke->simpleData.keycode == Key_F11 ) {
462 if ( press ) emit menu(); 469 if ( press ) emit menu();
463 return TRUE; 470 return TRUE;
464 } 471 }
465 */ 472 */
466 if ( ke->simpleData.keycode == Key_F12 ) { 473 if ( ke->simpleData.keycode == Key_F12 ) {
467 while ( activePopupWidget() ) 474 while ( activePopupWidget() )
468 activePopupWidget() ->close(); 475 activePopupWidget() ->close();
469 if ( press ) 476 if ( press )
470 emit launch(); 477 emit launch();
471 return TRUE; 478 return TRUE;
472 } 479 }
473 if ( ke->simpleData.keycode == Key_F13 ) { 480 if ( ke->simpleData.keycode == Key_F13 ) {
474 if ( press ) 481 if ( press )
475 emit email(); 482 emit email();
476 return TRUE; 483 return TRUE;
477 } 484 }
478 } 485 }
479 486
480 if ( ke->simpleData.keycode == Key_F34 ) { 487 if ( ke->simpleData.keycode == Key_F34 ) {
481 if ( press ) 488 if ( press )
482 emit power(); 489 emit power();
483 return TRUE; 490 return TRUE;
484 } 491 }
485 // This was used for the iPAQ PowerButton 492 // This was used for the iPAQ PowerButton
486 // See main.cpp for new KeyboardFilter 493 // See main.cpp for new KeyboardFilter
487 // 494 //
488 // if ( ke->simpleData.keycode == Key_SysReq ) { 495 // if ( ke->simpleData.keycode == Key_SysReq ) {
489 // if ( press ) emit power(); 496 // if ( press ) emit power();
490 // return TRUE; 497 // return TRUE;
491 // } 498 // }
492 if ( ke->simpleData.keycode == Key_F35 ) { 499 if ( ke->simpleData.keycode == Key_F35 ) {
493 if ( press ) 500 if ( press )
494 emit backlight(); 501 emit backlight();
495 return TRUE; 502 return TRUE;
496 } 503 }
497 if ( ke->simpleData.keycode == Key_F32 ) { 504 if ( ke->simpleData.keycode == Key_F32 ) {
498 if ( press ) 505 if ( press )
499 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 506 QCopEnvelope e( "QPE/Desktop", "startSync()" );
500 return TRUE; 507 return TRUE;
501 } 508 }
502 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 509 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
503 if ( press ) 510 if ( press )
504 emit symbol(); 511 emit symbol();
505 return TRUE; 512 return TRUE;
506 } 513 }
507 if ( ke->simpleData.keycode == Key_NumLock ) { 514 if ( ke->simpleData.keycode == Key_NumLock ) {
508 if ( press ) 515 if ( press )
509 emit numLockStateToggle(); 516 emit numLockStateToggle();
510 } 517 }
511 if ( ke->simpleData.keycode == Key_CapsLock ) { 518 if ( ke->simpleData.keycode == Key_CapsLock ) {
512 if ( press ) 519 if ( press )
513 emit capsLockStateToggle(); 520 emit capsLockStateToggle();
514 } 521 }
515 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) 522 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) )
516 qpedesktop->keyClick(); 523 qpedesktop->keyClick();
517 } 524 }
518 else { 525 else {
519 if ( e->type == QWSEvent::Mouse ) { 526 if ( e->type == QWSEvent::Mouse ) {
520 QWSMouseEvent * me = ( QWSMouseEvent * ) e; 527 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
521 static bool up = TRUE; 528 static bool up = TRUE;
522 if ( me->simpleData.state & LeftButton ) { 529 if ( me->simpleData.state & LeftButton ) {
523 if ( up ) { 530 if ( up ) {
524 up = FALSE; 531 up = FALSE;
525 qpedesktop->screenClick(); 532 qpedesktop->screenClick();
526 } 533 }
527 } 534 }
528 else { 535 else {
529 up = TRUE; 536 up = TRUE;
530 } 537 }
531 } 538 }
532 } 539 }
533 540
534 return QPEApplication::qwsEventFilter( e ); 541 return QPEApplication::qwsEventFilter( e );
535} 542}
536#endif 543#endif
537 544
538void DesktopApplication::psTimeout() 545void DesktopApplication::psTimeout()
539{ 546{
540 qpedesktop->checkMemory(); // in case no events are being generated 547 qpedesktop->checkMemory(); // in case no events are being generated
541 548
542 *ps = PowerStatusManager::readStatus(); 549 *ps = PowerStatusManager::readStatus();
543 550
544 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { 551 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) {
545 pa->alert( tr( "Battery is running very low." ), 6 ); 552 pa->alert( tr( "Battery is running very low." ), 6 );
546 } 553 }
547 554
548 if ( ps->batteryStatus() == PowerStatus::Critical ) { 555 if ( ps->batteryStatus() == PowerStatus::Critical ) {
549 pa->alert( tr( "Battery level is critical!\n" 556 pa->alert( tr( "Battery level is critical!\n"
550 "Keep power off until power restored!" ), 1 ); 557 "Keep power off until power restored!" ), 1 );
551 } 558 }
552 559
553 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 560 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
554 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 561 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
555 } 562 }
556} 563}
557 564
558 565
559void DesktopApplication::sendCard() 566void DesktopApplication::sendCard()
560{ 567{
561 delete cardSendTimer; 568 delete cardSendTimer;
562 cardSendTimer = 0; 569 cardSendTimer = 0;
563 QString card = getenv( "HOME" ); 570 QString card = getenv( "HOME" );
564 card += "/Applications/addressbook/businesscard.vcf"; 571 card += "/Applications/addressbook/businesscard.vcf";
565 572
566 if ( QFile::exists( card ) ) { 573 if ( QFile::exists( card ) ) {
567 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); 574 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" );
568 QString mimetype = "text/x-vCard"; 575 QString mimetype = "text/x-vCard";
569 e << tr( "business card" ) << card << mimetype; 576 e << tr( "business card" ) << card << mimetype;
570 } 577 }
571} 578}
572 579
573#if defined(QPE_HAVE_MEMALERTER) 580#if defined(QPE_HAVE_MEMALERTER)
574QPE_MEMALERTER_IMPL 581QPE_MEMALERTER_IMPL
575#endif 582#endif
576 583
577//=========================================================================== 584//===========================================================================
578 585
579Desktop::Desktop() : 586Desktop::Desktop() :
580 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 587 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
581 qcopBridge( 0 ), 588 qcopBridge( 0 ),
582 transferServer( 0 ), 589 transferServer( 0 ),
583 packageSlave( 0 ) 590 packageSlave( 0 )
584{ 591{
585 qpedesktop = this; 592 qpedesktop = this;
586 593
587 // bg = new Info( this ); 594 // bg = new Info( this );
588 tb = new TaskBar; 595 tb = new TaskBar;
589 596
590 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 597 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
591 598
592 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); 599 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
593 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); 600 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
594 601
595 int displayw = qApp->desktop() ->width(); 602 int displayw = qApp->desktop() ->width();
596 int displayh = qApp->desktop() ->height(); 603 int displayh = qApp->desktop() ->height();
597 604
598 605
599 QSize sz = tb->sizeHint(); 606 QSize sz = tb->sizeHint();
600 607
601 setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 608 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
602 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 609 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
603 610
604 tb->show(); 611 tb->show();
605 launcher->showMaximized(); 612 launcher->showMaximized();
606 launcher->show(); 613 launcher->show();
607 launcher->raise(); 614 launcher->raise();
608#if defined(QPE_HAVE_MEMALERTER) 615#if defined(QPE_HAVE_MEMALERTER)
609 616
610 initMemalerter(); 617 initMemalerter();
611#endif 618#endif
612 // start services 619 // start services
613 startTransferServer(); 620 startTransferServer();
614 ( void ) new IrServer( this ); 621 ( void ) new IrServer( this );
615 rereadVolumes(); 622 rereadVolumes();
616 623
617 packageSlave = new PackageSlave( this ); 624 packageSlave = new PackageSlave( this );
618 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); 625 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
619 626
620 qApp->installEventFilter( this ); 627 qApp->installEventFilter( this );
621} 628}
622 629
623void Desktop::show() 630void Desktop::show()
624{ 631{
625 login( TRUE ); 632 login( TRUE );
626 QWidget::show(); 633 QWidget::show();
627} 634}
628 635
629Desktop::~Desktop() 636Desktop::~Desktop()
630{ 637{
631 delete launcher; 638 delete launcher;
632 delete tb; 639 delete tb;
633 delete qcopBridge; 640 delete qcopBridge;
634 delete transferServer; 641 delete transferServer;
635} 642}
636 643
637bool Desktop::recoverMemory() 644bool Desktop::recoverMemory()
638{ 645{
639 return tb->recoverMemory(); 646 return tb->recoverMemory();
640} 647}
641 648
642void Desktop::checkMemory() 649void Desktop::checkMemory()
643{ 650{
644#if defined(QPE_HAVE_MEMALERTER) 651#if defined(QPE_HAVE_MEMALERTER)
645 static bool ignoreNormal = FALSE; 652 static bool ignoreNormal = FALSE;
646 static bool existingMessage = FALSE; 653 static bool existingMessage = FALSE;
647 654
648 if ( existingMessage ) 655 if ( existingMessage )
649 return ; // don't show a second message while still on first 656 return ; // don't show a second message while still on first
650 657
651 existingMessage = TRUE; 658 existingMessage = TRUE;
652 switch ( memstate ) { 659 switch ( memstate ) {
653 case Unknown: 660 case Unknown:
654 break; 661 break;
655 case Low: 662 case Low:
656 memstate = Unknown; 663 memstate = Unknown;
657 if ( recoverMemory() ) 664 if ( recoverMemory() )
658 ignoreNormal = TRUE; 665 ignoreNormal = TRUE;
659 else 666 else
660 QMessageBox::warning( 0 , "Memory Status", 667 QMessageBox::warning( 0 , "Memory Status",
661 "The memory smacks of shortage. \n" 668 "The memory smacks of shortage. \n"
662 "Please save data. " ); 669 "Please save data. " );
663 break; 670 break;
664 case Normal: 671 case Normal:
665 memstate = Unknown; 672 memstate = Unknown;
666 if ( ignoreNormal ) 673 if ( ignoreNormal )
667 ignoreNormal = FALSE; 674 ignoreNormal = FALSE;
668 else 675 else
669 QMessageBox::information ( 0 , "Memory Status", 676 QMessageBox::information ( 0 , "Memory Status",
670 "There is enough memory again." ); 677 "There is enough memory again." );
671 break; 678 break;
672 case VeryLow: 679 case VeryLow:
673 memstate = Unknown; 680 memstate = Unknown;
674 QMessageBox::critical( 0 , "Memory Status", 681 QMessageBox::critical( 0 , "Memory Status",
675 "The memory is very low. \n" 682 "The memory is very low. \n"
676 "Please end this application \n" 683 "Please end this application \n"
677 "immediately." ); 684 "immediately." );
678 recoverMemory(); 685 recoverMemory();
679 } 686 }
680 existingMessage = FALSE; 687 existingMessage = FALSE;
681#endif 688#endif
682} 689}
683 690
684static bool isVisibleWindow( int wid ) 691static bool isVisibleWindow( int wid )
685{ 692{
686 const QList<QWSWindow> &list = qwsServer->clientWindows(); 693 const QList<QWSWindow> &list = qwsServer->clientWindows();
687 QWSWindow* w; 694 QWSWindow* w;
688 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 695 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
689 if ( w->winId() == wid ) 696 if ( w->winId() == wid )
690 return !w->isFullyObscured(); 697 return !w->isFullyObscured();
691 } 698 }
692 return FALSE; 699 return FALSE;
693} 700}
694 701
695static bool hasVisibleWindow( const QString& clientname ) 702static bool hasVisibleWindow( const QString& clientname )
696{ 703{
697 const QList<QWSWindow> &list = qwsServer->clientWindows(); 704 const QList<QWSWindow> &list = qwsServer->clientWindows();
698 QWSWindow* w; 705 QWSWindow* w;
699 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 706 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
700 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 707 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
701 return TRUE; 708 return TRUE;
702 } 709 }
703 return FALSE; 710 return FALSE;
704} 711}
705 712
706void Desktop::raiseLauncher() 713void Desktop::raiseLauncher()
707{ 714{
708 Config cfg( "qpe" ); //F12 'Home' 715 Config cfg( "qpe" ); //F12 'Home'
709 cfg.setGroup( "AppsKey" ); 716 cfg.setGroup( "AppsKey" );
710 QString tempItem; 717 QString tempItem;
711 tempItem = cfg.readEntry( "Middle", "Home" ); 718 tempItem = cfg.readEntry( "Middle", "Home" );
712 if ( tempItem == "Home" || tempItem.isEmpty() ) { 719 if ( tempItem == "Home" || tempItem.isEmpty() ) {
713 if ( isVisibleWindow( launcher->winId() ) ) 720 if ( isVisibleWindow( launcher->winId() ) )
714 launcher->nextView(); 721 launcher->nextView();
715 else 722 else
716 launcher->raise(); 723 launcher->raise();
717 } 724 }
718 else { 725 else {
719 QCopEnvelope e( "QPE/System", "execute(QString)" ); 726 QCopEnvelope e( "QPE/System", "execute(QString)" );
720 e << tempItem; 727 e << tempItem;
721 } 728 }
722} 729}
723 730
724void Desktop::executeOrModify( const QString& appLnkFile ) 731void Desktop::executeOrModify( const QString& appLnkFile )
725{ 732{
726 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 733 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
727 if ( lnk.isValid() ) { 734 if ( lnk.isValid() ) {
728 QCString app = lnk.exec().utf8(); 735 QCString app = lnk.exec().utf8();
729 Global::terminateBuiltin( "calibrate" ); 736 Global::terminateBuiltin( "calibrate" );
730 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 737 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
731 // MRUList::addTask( &lnk ); 738 // MRUList::addTask( &lnk );
732 if ( hasVisibleWindow( app ) ) 739 if ( hasVisibleWindow( app ) )
733 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 740 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
734 else 741 else
735 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 742 QCopChannel::send( "QPE/Application/" + app, "raise()" );
736 } 743 }
737 else { 744 else {
738 lnk.execute(); 745 lnk.execute();
739 } 746 }
740 } 747 }
741} 748}
742 749
743void Desktop::raiseDatebook() 750void Desktop::raiseDatebook()
744{ 751{
745 Config cfg( "qpe" ); //F9 'Activity' 752 Config cfg( "qpe" ); //F9 'Activity'
746 cfg.setGroup( "AppsKey" ); 753 cfg.setGroup( "AppsKey" );
747 QString tempItem; 754 QString tempItem;
748 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); 755 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" );
749 if ( tempItem == "Calendar" || tempItem.isEmpty() ) { 756 if ( tempItem == "Calendar" || tempItem.isEmpty() ) {
750 tempItem = "datebook"; 757 tempItem = "datebook";
751 } 758 }
752 QCopEnvelope e( "QPE/System", "execute(QString)" ); 759 QCopEnvelope e( "QPE/System", "execute(QString)" );
753 e << tempItem; 760 e << tempItem;
754} 761}
755 762
756void Desktop::raiseContacts() 763void Desktop::raiseContacts()
757{ 764{
758 Config cfg( "qpe" ); //F10, 'Contacts' 765 Config cfg( "qpe" ); //F10, 'Contacts'
759 cfg.setGroup( "AppsKey" ); 766 cfg.setGroup( "AppsKey" );
760 QString tempItem; 767 QString tempItem;
761 tempItem = cfg.readEntry( "Left2nd", "Address Book" ); 768 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
762 if ( tempItem == "Address Book" || tempItem.isEmpty() ) { 769 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
763 tempItem = "addressbook"; 770 tempItem = "addressbook";
764 } 771 }
765 QCopEnvelope e( "QPE/System", "execute(QString)" ); 772 QCopEnvelope e( "QPE/System", "execute(QString)" );
766 e << tempItem; 773 e << tempItem;
767} 774}
768 775
769void Desktop::raiseMenu() 776void Desktop::raiseMenu()
770{ 777{
771 Config cfg( "qpe" ); //F11, 'Menu 778 Config cfg( "qpe" ); //F11, 'Menu
772 cfg.setGroup( "AppsKey" ); 779 cfg.setGroup( "AppsKey" );
773 QString tempItem; 780 QString tempItem;
774 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); 781 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
775 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { 782 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
776 Global::terminateBuiltin( "calibrate" ); 783 Global::terminateBuiltin( "calibrate" );
777 tb->startMenu() ->launch(); 784 tb->startMenu() ->launch();
778 } 785 }
779 else { 786 else {
780 QCopEnvelope e( "QPE/System", "execute(QString)" ); 787 QCopEnvelope e( "QPE/System", "execute(QString)" );
781 e << tempItem; 788 e << tempItem;
782 } 789 }
783} 790}
784 791
785void Desktop::raiseEmail() 792void Desktop::raiseEmail()
786{ 793{
787 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 794 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
788 cfg.setGroup( "AppsKey" ); 795 cfg.setGroup( "AppsKey" );
789 QString tempItem; 796 QString tempItem;
790 tempItem = cfg.readEntry( "RightEnd", "Mail" ); 797 tempItem = cfg.readEntry( "RightEnd", "Mail" );
791 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { 798 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
792 tempItem = "mail"; 799 tempItem = "mail";
793 } 800 }
794 QCopEnvelope e( "QPE/System", "execute(QString)" ); 801 QCopEnvelope e( "QPE/System", "execute(QString)" );
795 e << tempItem; 802 e << tempItem;
796} 803}
797 804
798// autoStarts apps on resume and start 805// autoStarts apps on resume and start
799void Desktop::execAutoStart() 806void Desktop::execAutoStart()
800{ 807{
801 QString appName; 808 QString appName;
802 int delay; 809 int delay;
803 QDateTime now = QDateTime::currentDateTime(); 810 QDateTime now = QDateTime::currentDateTime();
804 Config cfg( "autostart" ); 811 Config cfg( "autostart" );
805 cfg.setGroup( "AutoStart" ); 812 cfg.setGroup( "AutoStart" );
806 appName = cfg.readEntry( "Apps", "" ); 813 appName = cfg.readEntry( "Apps", "" );
807 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 814 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
808 // If the time between suspend and resume was longer then the 815 // If the time between suspend and resume was longer then the
809 // value saved as delay, start the app 816 // value saved as delay, start the app
810 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 817 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
811 QCopEnvelope e( "QPE/System", "execute(QString)" ); 818 QCopEnvelope e( "QPE/System", "execute(QString)" );
812 e << QString( appName ); 819 e << QString( appName );
813 } 820 }
814} 821}
815 822
816#if defined(QPE_HAVE_TOGGLELIGHT) 823#if defined(QPE_HAVE_TOGGLELIGHT)
817#include <qpe/config.h> 824#include <qpe/config.h>
818 825
819#include <sys/ioctl.h> 826#include <sys/ioctl.h>
820#include <sys/types.h> 827#include <sys/types.h>
821#include <fcntl.h> 828#include <fcntl.h>
822#include <unistd.h> 829#include <unistd.h>
823#include <errno.h> 830#include <errno.h>
824#include <linux/ioctl.h> 831#include <linux/ioctl.h>
825#include <time.h> 832#include <time.h>
826#endif 833#endif
827 834
828 835
829void Desktop::togglePower() 836void Desktop::togglePower()
830{ 837{
831 static bool excllock = false; 838 static bool excllock = false;
832 839
833 if ( excllock ) 840 if ( excllock )
834 return ; 841 return ;
835 842
836 excllock = true; 843 excllock = true;
837 844
838 bool wasloggedin = loggedin; 845 bool wasloggedin = loggedin;
839 loggedin = 0; 846 loggedin = 0;
840 suspendTime = QDateTime::currentDateTime(); 847 suspendTime = QDateTime::currentDateTime();
841 848
842 ODevice::inst ( ) -> suspend ( ); 849 ODevice::inst ( ) -> suspend ( );
843 850
844 QWSServer::screenSaverActivate ( false ); 851 QWSServer::screenSaverActivate ( false );
845 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 852 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
846 853
847 { 854 {
848 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 855 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
849 } 856 }
850 857
851 if ( wasloggedin ) 858 if ( wasloggedin )
852 login( TRUE ); 859 login( TRUE );
853 860
854 execAutoStart(); 861 execAutoStart();
855 //qcopBridge->closeOpenConnections(); 862 //qcopBridge->closeOpenConnections();
856 863
857 excllock = false; 864 excllock = false;
858} 865}
859 866
860void Desktop::toggleLight() 867void Desktop::toggleLight()
861{ 868{
862 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 869 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
863 e << -2; // toggle 870 e << -2; // toggle
864} 871}
865 872
866void Desktop::toggleSymbolInput() 873void Desktop::toggleSymbolInput()
867{ 874{
868 tb->toggleSymbolInput(); 875 tb->toggleSymbolInput();
869} 876}
870 877
871void Desktop::toggleNumLockState() 878void Desktop::toggleNumLockState()
872{ 879{
873 tb->toggleNumLockState(); 880 tb->toggleNumLockState();
874} 881}
875 882
876void Desktop::toggleCapsLockState() 883void Desktop::toggleCapsLockState()
877{ 884{
878 tb->toggleCapsLockState(); 885 tb->toggleCapsLockState();
879} 886}
880 887
881void Desktop::styleChange( QStyle &s ) 888void Desktop::styleChange( QStyle &s )
882{ 889{
883 QWidget::styleChange( s ); 890 QWidget::styleChange( s );
884 int displayw = qApp->desktop() ->width(); 891 int displayw = qApp->desktop() ->width();
885 int displayh = qApp->desktop() ->height(); 892 int displayh = qApp->desktop() ->height();
886 893
887 QSize sz = tb->sizeHint(); 894 QSize sz = tb->sizeHint();
888 895
889 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 896 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
890} 897}
891 898
892void DesktopApplication::shutdown() 899void DesktopApplication::shutdown()
893{ 900{
894 if ( type() != GuiServer ) 901 if ( type() != GuiServer )
895 return ; 902 return ;
896 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 903 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
897 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 904 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
898 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 905 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
899 sd->showMaximized(); 906 sd->showMaximized();
900} 907}
901 908
902void DesktopApplication::shutdown( ShutdownImpl::Type t ) 909void DesktopApplication::shutdown( ShutdownImpl::Type t )
903{ 910{
904 switch ( t ) { 911 switch ( t ) {
905 case ShutdownImpl::ShutdownSystem: 912 case ShutdownImpl::ShutdownSystem:
906 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); 913 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 );
907 break; 914 break;
908 case ShutdownImpl::RebootSystem: 915 case ShutdownImpl::RebootSystem:
909 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); 916 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 );
910 break; 917 break;
911 case ShutdownImpl::RestartDesktop: 918 case ShutdownImpl::RestartDesktop:
912 restart(); 919 restart();
913 break; 920 break;
914 case ShutdownImpl::TerminateDesktop: 921 case ShutdownImpl::TerminateDesktop:
915 prepareForTermination( FALSE ); 922 prepareForTermination( FALSE );
916 923
917 // This is a workaround for a Qt bug 924 // This is a workaround for a Qt bug
918 // clipboard applet has to stop its poll timer, or Qt/E 925 // clipboard applet has to stop its poll timer, or Qt/E
919 // will hang on quit() right before it emits aboutToQuit() 926 // will hang on quit() right before it emits aboutToQuit()
920 emit aboutToQuit ( ); 927 emit aboutToQuit ( );
921 928
922 quit(); 929 quit();
923 break; 930 break;
924 } 931 }
925} 932}
926 933
927void DesktopApplication::restart() 934void DesktopApplication::restart()
928{ 935{
929 prepareForTermination( TRUE ); 936 prepareForTermination( TRUE );
930 937
931#ifdef Q_WS_QWS 938#ifdef Q_WS_QWS
932 939
933 for ( int fd = 3; fd < 100; fd++ ) 940 for ( int fd = 3; fd < 100; fd++ )
934 close( fd ); 941 close( fd );
935#if defined(QT_DEMO_SINGLE_FLOPPY) 942#if defined(QT_DEMO_SINGLE_FLOPPY)
936 943
937 execl( "/sbin/init", "qpe", 0 ); 944 execl( "/sbin/init", "qpe", 0 );
938#elif defined(QT_QWS_CASSIOPEIA) 945#elif defined(QT_QWS_CASSIOPEIA)
939 946
940 execl( "/bin/sh", "sh", 0 ); 947 execl( "/bin/sh", "sh", 0 );
941#else 948#else
942 949
943 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 950 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
944#endif 951#endif
945 952
946 exit( 1 ); 953 exit( 1 );
947#endif 954#endif
948} 955}
949 956
950void Desktop::startTransferServer() 957void Desktop::startTransferServer()
951{ 958{
952 // start qcop bridge server 959 // start qcop bridge server
953 qcopBridge = new QCopBridge( 4243 ); 960 qcopBridge = new QCopBridge( 4243 );
954 if ( !qcopBridge->ok() ) { 961 if ( !qcopBridge->ok() ) {
955 delete qcopBridge; 962 delete qcopBridge;
956 qcopBridge = 0; 963 qcopBridge = 0;
957 } 964 }
958 // start transfer server 965 // start transfer server
959 transferServer = new TransferServer( 4242 ); 966 transferServer = new TransferServer( 4242 );
960 if ( !transferServer->ok() ) { 967 if ( !transferServer->ok() ) {
961 delete transferServer; 968 delete transferServer;
962 transferServer = 0; 969 transferServer = 0;
963 } 970 }
964 if ( !transferServer || !qcopBridge ) 971 if ( !transferServer || !qcopBridge )
965 startTimer( 2000 ); 972 startTimer( 2000 );
966} 973}
967 974
968void Desktop::timerEvent( QTimerEvent *e ) 975void Desktop::timerEvent( QTimerEvent *e )
969{ 976{
970 killTimer( e->timerId() ); 977 killTimer( e->timerId() );
971 startTransferServer(); 978 startTransferServer();
972} 979}
973 980
974void Desktop::terminateServers() 981void Desktop::terminateServers()
975{ 982{
976 delete transferServer; 983 delete transferServer;
977 delete qcopBridge; 984 delete qcopBridge;
978 transferServer = 0; 985 transferServer = 0;
979 qcopBridge = 0; 986 qcopBridge = 0;
980} 987}
981 988
982void Desktop::rereadVolumes() 989void Desktop::rereadVolumes()
983{ 990{
984 Config cfg( "qpe" ); 991 Config cfg( "qpe" );
985 cfg.setGroup( "Volume" ); 992 cfg.setGroup( "Volume" );
986 touchclick = cfg.readBoolEntry( "TouchSound" ); 993 touchclick = cfg.readBoolEntry( "TouchSound" );
987 keyclick = cfg.readBoolEntry( "KeySound" ); 994 keyclick = cfg.readBoolEntry( "KeySound" );
988 alarmsound = cfg.readBoolEntry( "AlarmSound" ); 995 alarmsound = cfg.readBoolEntry( "AlarmSound" );
989} 996}
990 997
991void Desktop::keyClick() 998void Desktop::keyClick()
992{ 999{
993 if ( keyclick ) 1000 if ( keyclick )
994 ODevice::inst ( ) -> keySound ( ); 1001 ODevice::inst ( ) -> keySound ( );
995} 1002}
996 1003
997void Desktop::screenClick() 1004void Desktop::screenClick()
998{ 1005{
999 if ( touchclick ) 1006 if ( touchclick )
1000 ODevice::inst ( ) -> touchSound ( ); 1007 ODevice::inst ( ) -> touchSound ( );
1001} 1008}
1002 1009
1003void Desktop::soundAlarm() 1010void Desktop::soundAlarm()
1004{ 1011{
1005 if ( qpedesktop-> alarmsound ) 1012 if ( qpedesktop-> alarmsound )
1006 ODevice::inst ( ) -> alarmSound ( ); 1013 ODevice::inst ( ) -> alarmSound ( );
1007} 1014}
1008 1015
1009bool Desktop::eventFilter( QObject *, QEvent *ev )
1010{
1011 if ( ev-> type ( ) == QEvent::KeyPress ) {
1012 QKeyEvent * ke = ( QKeyEvent * ) ev;
1013 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
1014 QWidget * active = qApp-> activeWindow ( );
1015
1016 if ( active && active-> isPopup ( ) )
1017 active->close();
1018
1019 /*
1020 * On iPAQ 38xx that key is not the "menu key" but the mail key
1021 * To not confuse the users, make it launch the mail app on 38xx
1022 */
1023 if ( ODevice::inst() ->model() == OMODEL_iPAQ_H38xx ) {
1024 QCopEnvelope e( "QPE/System", "execute(QString)" );
1025 e << QString( "mail" );
1026 return true;
1027 }
1028 else {
1029 raiseMenu ( );
1030 return true;
1031 }
1032 }
1033 }
1034 return false;
1035}
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index b9ff39f..f7c3e3f 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -1,145 +1,144 @@
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 28
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32class Background; 32class Background;
33class Launcher; 33class Launcher;
34class TaskBar; 34class TaskBar;
35class PowerStatus; 35class PowerStatus;
36class QCopBridge; 36class QCopBridge;
37class TransferServer; 37class TransferServer;
38class DesktopPowerAlerter; 38class DesktopPowerAlerter;
39class PackageSlave; 39class PackageSlave;
40class QPEScreenSaver; 40class QPEScreenSaver;
41 41
42class DesktopApplication : public QPEApplication 42class DesktopApplication : public QPEApplication
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45public: 45public:
46 DesktopApplication( int& argc, char **argv, Type t ); 46 DesktopApplication( int& argc, char **argv, Type t );
47 ~DesktopApplication(); 47 ~DesktopApplication();
48 48
49 static void switchLCD ( bool on ); // only for togglePower in Desktop 49 static void switchLCD ( bool on ); // only for togglePower in Desktop
50 50
51signals: 51signals:
52 void home(); 52 void home();
53 void datebook(); 53 void datebook();
54 void contacts(); 54 void contacts();
55 void launch(); 55 void launch();
56 void email(); 56 void email();
57 void backlight(); 57 void backlight();
58 void power(); 58 void power();
59 void symbol(); 59 void symbol();
60 void numLockStateToggle(); 60 void numLockStateToggle();
61 void capsLockStateToggle(); 61 void capsLockStateToggle();
62 void prepareForRestart(); 62 void prepareForRestart();
63 63
64protected: 64protected:
65#ifdef Q_WS_QWS 65#ifdef Q_WS_QWS
66 66
67 bool qwsEventFilter( QWSEvent * ); 67 bool qwsEventFilter( QWSEvent * );
68#endif 68#endif
69 69
70 void shutdown(); 70 void shutdown();
71 void restart(); 71 void restart();
72 72
73public slots: 73public slots:
74 virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); 74 virtual void desktopMessage ( const QCString &msg, const QByteArray &data );
75 virtual void systemMessage ( const QCString &msg, const QByteArray &data ); 75 virtual void systemMessage ( const QCString &msg, const QByteArray &data );
76 76
77protected slots: 77protected slots:
78 void shutdown( ShutdownImpl::Type ); 78 void shutdown( ShutdownImpl::Type );
79 void psTimeout(); 79 void psTimeout();
80 void sendCard(); 80 void sendCard();
81private: 81private:
82 DesktopPowerAlerter *pa; 82 DesktopPowerAlerter *pa;
83 PowerStatus *ps; 83 PowerStatus *ps;
84 QTimer *cardSendTimer; 84 QTimer *cardSendTimer;
85 QCopChannel *channel; 85 QCopChannel *channel;
86 QPEScreenSaver *m_screensaver; 86 QPEScreenSaver *m_screensaver;
87}; 87};
88 88
89 89
90class Desktop : public QWidget 90class Desktop : public QWidget
91{ 91{
92 Q_OBJECT 92 Q_OBJECT
93public: 93public:
94 Desktop(); 94 Desktop();
95 ~Desktop(); 95 ~Desktop();
96 96
97 static bool screenLocked(); 97 static bool screenLocked();
98 98
99 void show(); 99 void show();
100 void checkMemory(); 100 void checkMemory();
101 101
102 void keyClick(); 102 void keyClick();
103 void screenClick(); 103 void screenClick();
104 static void soundAlarm(); 104 static void soundAlarm();
105 105
106public slots: 106public slots:
107 void raiseDatebook(); 107 void raiseDatebook();
108 void raiseContacts(); 108 void raiseContacts();
109 void raiseMenu(); 109 void raiseMenu();
110 void raiseLauncher(); 110 void raiseLauncher();
111 void raiseEmail(); 111 void raiseEmail();
112 void execAutoStart(); 112 void execAutoStart();
113 void togglePower(); 113 void togglePower();
114 void toggleLight(); 114 void toggleLight();
115 void toggleNumLockState(); 115 void toggleNumLockState();
116 void toggleCapsLockState(); 116 void toggleCapsLockState();
117 void toggleSymbolInput(); 117 void toggleSymbolInput();
118 void terminateServers(); 118 void terminateServers();
119 void rereadVolumes(); 119 void rereadVolumes();
120 120
121protected: 121protected:
122 void executeOrModify( const QString& appLnkFile ); 122 void executeOrModify( const QString& appLnkFile );
123 void styleChange( QStyle & ); 123 void styleChange( QStyle & );
124 void timerEvent( QTimerEvent *e ); 124 void timerEvent( QTimerEvent *e );
125 bool eventFilter( QObject *, QEvent * );
126 125
127 QWidget *bg; 126 QWidget *bg;
128 Launcher *launcher; 127 Launcher *launcher;
129 TaskBar *tb; 128 TaskBar *tb;
130 129
131private: 130private:
132 void startTransferServer(); 131 void startTransferServer();
133 bool recoverMemory(); 132 bool recoverMemory();
134 133
135 QCopBridge *qcopBridge; 134 QCopBridge *qcopBridge;
136 TransferServer *transferServer; 135 TransferServer *transferServer;
137 PackageSlave *packageSlave; 136 PackageSlave *packageSlave;
138 137
139 QDateTime suspendTime; 138 QDateTime suspendTime;
140 bool keyclick, touchclick, alarmsound; 139 bool keyclick, touchclick, alarmsound;
141}; 140};
142 141
143 142
144#endif // __DESKTOP_H__ 143#endif // __DESKTOP_H__
145 144