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