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