summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 33bea36..c4c6050 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,48 +1,47 @@
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"
25#include "qcopbridge.h" 24#include "qcopbridge.h"
26#include "shutdownimpl.h" 25#include "shutdownimpl.h"
27#include "startmenu.h" 26#include "startmenu.h"
28#include "taskbar.h" 27#include "taskbar.h"
29#include "transferserver.h" 28#include "transferserver.h"
30#include "irserver.h" 29#include "irserver.h"
31#include "packageslave.h" 30#include "packageslave.h"
32 31
33#include <qpe/applnk.h> 32#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 33#include <qpe/mimetype.h>
35#include <qpe/password.h> 34#include <qpe/password.h>
36#include <qpe/config.h> 35#include <qpe/config.h>
37#include <qpe/power.h> 36#include <qpe/power.h>
38#include <qpe/timeconversion.h> 37#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
40#include <qpe/network.h> 39#include <qpe/network.h>
41#include <qpe/global.h> 40#include <qpe/global.h>
42 41
43#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
44#include <qpe/custom.h> 43#include <qpe/custom.h>
45#endif 44#endif
46 45
47#include <opie/odevice.h> 46#include <opie/odevice.h>
48 47
@@ -148,94 +147,99 @@ void DesktopPowerAlerter::alert( const QString &text, int priority )
148void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 147void DesktopPowerAlerter::hideEvent( QHideEvent *e )
149{ 148{
150 QMessageBox::hideEvent( e ); 149 QMessageBox::hideEvent( e );
151 alertCount = 0; 150 alertCount = 0;
152 currentPriority = INT_MAX; 151 currentPriority = INT_MAX;
153} 152}
154 153
155class QPEScreenSaver : public QWSScreenSaver 154class QPEScreenSaver : public QWSScreenSaver
156{ 155{
157private: 156private:
158 int LcdOn; 157 int LcdOn;
159 158
160public: 159public:
161 QPEScreenSaver() 160 QPEScreenSaver()
162 { 161 {
163 m_disable_suspend = 100; 162 m_disable_suspend = 100;
164 m_enable_dim = false; 163 m_enable_dim = false;
165 m_enable_lightoff = false; 164 m_enable_lightoff = false;
166 m_enable_onlylcdoff = false; 165 m_enable_onlylcdoff = false;
167 166
168 m_disable_suspend_ac = 100; 167 m_disable_suspend_ac = 100;
169 m_enable_dim_ac = false; 168 m_enable_dim_ac = false;
170 m_enable_lightoff_ac = false; 169 m_enable_lightoff_ac = false;
171 m_enable_onlylcdoff_ac = false; 170 m_enable_onlylcdoff_ac = false;
171 m_disable_apm_ac = false;
172 172
173 m_lcd_status = true; 173 m_lcd_status = true;
174 174
175 m_backlight_normal = -1; 175 m_backlight_normal = -1;
176 m_backlight_current = -1; 176 m_backlight_current = -1;
177 m_backlight_forcedoff = false; 177 m_backlight_forcedoff = false;
178 178
179 // 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)
180 ODevice::inst ( )-> setDisplayStatus ( true ); 180 ODevice::inst ( )-> setDisplayStatus ( true );
181 setBacklight ( -1 ); 181 setBacklight ( -1 );
182 } 182 }
183 void restore() 183 void restore()
184 { 184 {
185 if ( !m_lcd_status ) { // We must have turned it off 185 if ( !m_lcd_status ) { // We must have turned it off
186 ODevice::inst ( ) -> setDisplayStatus ( true ); 186 ODevice::inst ( ) -> setDisplayStatus ( true );
187 m_lcd_status = true; 187 m_lcd_status = true;
188 } 188 }
189 189
190 setBacklightInternal ( -1 ); 190 setBacklightInternal ( -1 );
191 } 191 }
192 bool save( int level ) 192 bool save( int level )
193 { 193 {
194 bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ); 194 bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online );
195 195
196 switch ( level ) { 196 switch ( level ) {
197 case 0: 197 case 0:
198 198
199 if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) { 199 if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) {
200 if ( m_backlight_current > 1 ) 200 if ( m_backlight_current > 1 )
201 setBacklight( 1 ); // lowest non-off 201 setBacklight( 1 ); // lowest non-off
202 } else if ( m_disable_suspend > 0 && m_enable_dim ) { 202 } else if ( m_disable_suspend > 0 && m_enable_dim ) {
203 if ( m_backlight_current > 1 ) 203 if ( m_backlight_current > 1 )
204 setBacklightInternal( 1 ); // lowest non-off 204 setBacklightInternal( 1 ); // lowest non-off
205 } 205 }
206 return true; 206 return true;
207 break; 207 break;
208 case 1: 208 case 1:
209 209
210 if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) { 210 if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) {
211 setBacklightInternal( 0 ); // off 211 setBacklightInternal( 0 ); // off
212 } else if ( m_disable_suspend > 1 && m_enable_lightoff ) { 212 } else if ( m_disable_suspend > 1 && m_enable_lightoff ) {
213 setBacklightInternal( 0 ); // off 213 setBacklightInternal( 0 ); // off
214 } 214 }
215 return true; 215 return true;
216 break; 216 break;
217 case 2: 217 case 2:
218 if ( m_disable_apm_ac && onAC ) {
219 return true;
220 }
221
218 if ( m_enable_onlylcdoff_ac && onAC ) { 222 if ( m_enable_onlylcdoff_ac && onAC ) {
219 ODevice::inst ( ) -> setDisplayStatus ( false ); 223 ODevice::inst ( ) -> setDisplayStatus ( false );
220 m_lcd_status = false; 224 m_lcd_status = false;
221 return true; 225 return true;
222 } 226 }
223 else if ( m_enable_onlylcdoff ) { 227 else if ( m_enable_onlylcdoff ) {
224 ODevice::inst ( ) -> setDisplayStatus ( false ); 228 ODevice::inst ( ) -> setDisplayStatus ( false );
225 m_lcd_status = false; 229 m_lcd_status = false;
226 return true; 230 return true;
227 } 231 }
228 else // We're going to suspend the whole machine 232 else // We're going to suspend the whole machine
229 { 233 {
230 if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) { 234 if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) {
231 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 235 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
232 return true; 236 return true;
233 } 237 }
234 if ( ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) { 238 if ( ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) {
235 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 239 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
236 return true; 240 return true;
237 } 241 }
238 } 242 }
239 break; 243 break;
240 } 244 }
241 return false; 245 return false;
@@ -252,75 +256,76 @@ private:
252 interval = config.readNumEntry( value, def ); 256 interval = config.readNumEntry( value, def );
253 } 257 }
254 return interval; 258 return interval;
255 } 259 }
256 260
257public: 261public:
258 void setIntervals( int i1, int i2, int i3 ) 262 void setIntervals( int i1, int i2, int i3 )
259 { 263 {
260 Config config( "qpe" ); 264 Config config( "qpe" );
261 config.setGroup( "Screensaver" ); 265 config.setGroup( "Screensaver" );
262 266
263 int v[ 4 ]; 267 int v[ 4 ];
264 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); 268 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 );
265 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); 269 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 );
266 i3 = ssi( i3, config, "", "Interval", 60 ); 270 i3 = ssi( i3, config, "", "Interval", 60 );
267 271
268 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 272 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
269 273
270 v [ 0 ] = QMAX( 1000 * i1, 100 ); 274 v [ 0 ] = QMAX( 1000 * i1, 100 );
271 v [ 1 ] = QMAX( 1000 * i2, 100 ); 275 v [ 1 ] = QMAX( 1000 * i2, 100 );
272 v [ 2 ] = QMAX( 1000 * i3, 100 ); 276 v [ 2 ] = QMAX( 1000 * i3, 100 );
273 v [ 3 ] = 0; 277 v [ 3 ] = 0;
274 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); 278 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false );
275 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); 279 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false );
276 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); 280 m_enable_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 );
277 281
278 if ( !i1 && !i2 && !i3 ) 282 if ( !i1 && !i2 && !i3 )
279 QWSServer::setScreenSaverInterval( 0 ); 283 QWSServer::setScreenSaverInterval( 0 );
280 else 284 else
281 QWSServer::setScreenSaverIntervals( v ); 285 QWSServer::setScreenSaverIntervals( v );
282 } 286 }
283 287
284 void setIntervalsAC( int i1, int i2, int i3 ) 288 void setIntervalsAC( int i1, int i2, int i3 )
285 { 289 {
286 Config config( "qpe" ); 290 Config config( "qpe" );
287 config.setGroup( "Screensaver" ); 291 config.setGroup( "Screensaver" );
288 292
289 int v[ 4 ]; 293 int v[ 4 ];
290 i1 = ssi( i1, config, "DimAC", "Interval_DimAC", 30 ); 294 i1 = ssi( i1, config, "DimAC", "Interval_DimAC", 30 );
291 i2 = ssi( i2, config, "LightOffAC", "Interval_LightOffAC", 20 ); 295 i2 = ssi( i2, config, "LightOffAC", "Interval_LightOffAC", 20 );
292 i3 = ssi( i3, config, "", "IntervalAC", 60 ); 296 i3 = ssi( i3, config, "", "IntervalAC", 60 );
293 297
294 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 298 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
295 299
296 v [ 0 ] = QMAX( 1000 * i1, 100 ); 300 v [ 0 ] = QMAX( 1000 * i1, 100 );
297 v [ 1 ] = QMAX( 1000 * i2, 100 ); 301 v [ 1 ] = QMAX( 1000 * i2, 100 );
298 v [ 2 ] = QMAX( 1000 * i3, 100 ); 302 v [ 2 ] = QMAX( 1000 * i3, 100 );
299 v [ 3 ] = 0; 303 v [ 3 ] = 0;
300 m_enable_dim_ac = ( ( i1 != 0 ) ? config.readNumEntry ( "DimAC", 1 ) : false ); 304 m_enable_dim_ac = ( ( i1 != 0 ) ? config.readNumEntry ( "DimAC", 1 ) : false );
301 m_enable_lightoff_ac = ( ( i2 != 0 ) ? config.readNumEntry ( "LightOffAC", 1 ) : false ); 305 m_enable_lightoff_ac = ( ( i2 != 0 ) ? config.readNumEntry ( "LightOffAC", 1 ) : false );
302 m_enable_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnlyAC", 0 ); 306 m_enable_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnlyAC", 0 );
307 m_disable_apm_ac = config.readNumEntry ( "NoApmAC", 0 );
303 308
304 if ( !i1 && !i2 && !i3 ) 309 if ( !i1 && !i2 && !i3 )
305 QWSServer::setScreenSaverInterval( 0 ); 310 QWSServer::setScreenSaverInterval( 0 );
306 else 311 else
307 QWSServer::setScreenSaverIntervals( v ); 312 QWSServer::setScreenSaverIntervals( v );
308 } 313 }
309 314
310 void setInterval ( int interval ) 315 void setInterval ( int interval )
311 { 316 {
312 setIntervals ( -1, -1, interval ); 317 setIntervals ( -1, -1, interval );
313 } 318 }
314 319
315 void setMode ( int mode ) 320 void setMode ( int mode )
316 { 321 {
317 if ( mode > m_disable_suspend ) 322 if ( mode > m_disable_suspend )
318 setInterval( -1 ); 323 setInterval( -1 );
319 m_disable_suspend = mode; 324 m_disable_suspend = mode;
320 } 325 }
321 326
322 void setBacklight ( int bright ) 327 void setBacklight ( int bright )
323 { 328 {
324 // Read from config 329 // Read from config
325 Config config ( "qpe" ); 330 Config config ( "qpe" );
326 config. setGroup ( "Screensaver" ); 331 config. setGroup ( "Screensaver" );
@@ -351,48 +356,49 @@ private:
351 ODevice::inst ( )-> setDisplayBrightness ( bright ); 356 ODevice::inst ( )-> setDisplayBrightness ( bright );
352 m_backlight_current = bright; 357 m_backlight_current = bright;
353 } 358 }
354 } 359 }
355 360
356public: 361public:
357 void setDisplayState ( bool on ) 362 void setDisplayState ( bool on )
358 { 363 {
359 if ( m_lcd_status != on ) { 364 if ( m_lcd_status != on ) {
360 ODevice::inst ( ) -> setDisplayStatus ( on ); 365 ODevice::inst ( ) -> setDisplayStatus ( on );
361 m_lcd_status = on; 366 m_lcd_status = on;
362 } 367 }
363 } 368 }
364 369
365private: 370private:
366 int m_disable_suspend; 371 int m_disable_suspend;
367 bool m_enable_dim; 372 bool m_enable_dim;
368 bool m_enable_lightoff; 373 bool m_enable_lightoff;
369 bool m_enable_onlylcdoff; 374 bool m_enable_onlylcdoff;
370 375
371 int m_disable_suspend_ac; 376 int m_disable_suspend_ac;
372 bool m_enable_dim_ac; 377 bool m_enable_dim_ac;
373 bool m_enable_lightoff_ac; 378 bool m_enable_lightoff_ac;
374 bool m_enable_onlylcdoff_ac; 379 bool m_enable_onlylcdoff_ac;
380 bool m_disable_apm_ac;
375 381
376 bool m_lcd_status; 382 bool m_lcd_status;
377 383
378 int m_backlight_normal; 384 int m_backlight_normal;
379 int m_backlight_current; 385 int m_backlight_current;
380 bool m_backlight_forcedoff; 386 bool m_backlight_forcedoff;
381}; 387};
382 388
383void DesktopApplication::switchLCD ( bool on ) 389void DesktopApplication::switchLCD ( bool on )
384{ 390{
385 if ( qApp ) { 391 if ( qApp ) {
386 DesktopApplication *dapp = (DesktopApplication *) qApp; 392 DesktopApplication *dapp = (DesktopApplication *) qApp;
387 393
388 if ( dapp-> m_screensaver ) { 394 if ( dapp-> m_screensaver ) {
389 if ( on ) { 395 if ( on ) {
390 dapp-> m_screensaver-> setDisplayState ( true ); 396 dapp-> m_screensaver-> setDisplayState ( true );
391 dapp-> m_screensaver-> setBacklight ( -3 ); 397 dapp-> m_screensaver-> setBacklight ( -3 );
392 } 398 }
393 else { 399 else {
394 dapp-> m_screensaver-> setDisplayState ( false ); 400 dapp-> m_screensaver-> setDisplayState ( false );
395 } 401 }
396 } 402 }
397 } 403 }
398} 404}