summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 4587ec6..da535d9 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,430 +1,434 @@
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/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39#include <qpe/global.h> 39#include <qpe/global.h>
40#ifdef QT_QWS_CUSTOM 40#ifdef QT_QWS_CUSTOM
41#include "qpe/custom.h" 41#include "qpe/custom.h"
42#endif 42#endif
43 43
44#include <qgfx_qws.h> 44#include <qgfx_qws.h>
45#include <qmainwindow.h> 45#include <qmainwindow.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qtimer.h> 47#include <qtimer.h>
48#include <qwindowsystem_qws.h> 48#include <qwindowsystem_qws.h>
49 49
50#include <qvaluelist.h> 50#include <qvaluelist.h>
51 51
52#include <stdlib.h> 52#include <stdlib.h>
53#include <unistd.h> 53#include <unistd.h>
54 54
55class QCopKeyRegister 55class QCopKeyRegister
56{ 56{
57public: 57public:
58 QCopKeyRegister() : keyCode(0) { } 58 QCopKeyRegister() : keyCode(0) { }
59 QCopKeyRegister(int k, const QString &c, const QString &m) 59 QCopKeyRegister(int k, const QString &c, const QString &m)
60 : keyCode(k), channel(c), message(m) { } 60 : keyCode(k), channel(c), message(m) { }
61 61
62 int getKeyCode() const { return keyCode; } 62 int getKeyCode() const { return keyCode; }
63 QString getChannel() const { return channel; } 63 QString getChannel() const { return channel; }
64 QString getMessage() const { return message; } 64 QString getMessage() const { return message; }
65 65
66private: 66private:
67 int keyCode; 67 int keyCode;
68 QString channel, message; 68 QString channel, message;
69}; 69};
70 70
71typedef QValueList<QCopKeyRegister> KeyRegisterList; 71typedef QValueList<QCopKeyRegister> KeyRegisterList;
72KeyRegisterList keyRegisterList; 72KeyRegisterList keyRegisterList;
73 73
74static Desktop* qpedesktop = 0; 74static Desktop* qpedesktop = 0;
75static int loggedin=0; 75static int loggedin=0;
76static void login(bool at_poweron) 76static void login(bool at_poweron)
77{ 77{
78 if ( !loggedin ) { 78 if ( !loggedin ) {
79 Global::terminateBuiltin("calibrate"); 79 Global::terminateBuiltin("calibrate");
80 Password::authenticate(at_poweron); 80 Password::authenticate(at_poweron);
81 loggedin=1; 81 loggedin=1;
82 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 82 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
83 } 83 }
84} 84}
85 85
86bool Desktop::screenLocked() 86bool Desktop::screenLocked()
87{ 87{
88 return loggedin == 0; 88 return loggedin == 0;
89} 89}
90 90
91/* 91/*
92 Priority is number of alerts that are needed to pop up 92 Priority is number of alerts that are needed to pop up
93 alert. 93 alert.
94 */ 94 */
95class DesktopPowerAlerter : public QMessageBox 95class DesktopPowerAlerter : public QMessageBox
96{ 96{
97public: 97public:
98 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 98 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
99 : QMessageBox( tr("Battery Status"), "Low Battery", 99 : QMessageBox( tr("Battery Status"), "Low Battery",
100 QMessageBox::Critical, 100 QMessageBox::Critical,
101 QMessageBox::Ok | QMessageBox::Default, 101 QMessageBox::Ok | QMessageBox::Default,
102 QMessageBox::NoButton, QMessageBox::NoButton, 102 QMessageBox::NoButton, QMessageBox::NoButton,
103 parent, name, FALSE ) 103 parent, name, FALSE )
104 { 104 {
105 currentPriority = INT_MAX; 105 currentPriority = INT_MAX;
106 alertCount = 0; 106 alertCount = 0;
107 } 107 }
108 108
109 void alert( const QString &text, int priority ); 109 void alert( const QString &text, int priority );
110 void hideEvent( QHideEvent * ); 110 void hideEvent( QHideEvent * );
111private: 111private:
112 int currentPriority; 112 int currentPriority;
113 int alertCount; 113 int alertCount;
114}; 114};
115 115
116void DesktopPowerAlerter::alert( const QString &text, int priority ) 116void DesktopPowerAlerter::alert( const QString &text, int priority )
117{ 117{
118 alertCount++; 118 alertCount++;
119 if ( alertCount < priority ) 119 if ( alertCount < priority )
120 return; 120 return;
121 if ( priority > currentPriority ) 121 if ( priority > currentPriority )
122 return; 122 return;
123 currentPriority = priority; 123 currentPriority = priority;
124 setText( text ); 124 setText( text );
125 show(); 125 show();
126} 126}
127 127
128 128
129void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 129void DesktopPowerAlerter::hideEvent( QHideEvent *e )
130{ 130{
131 QMessageBox::hideEvent( e ); 131 QMessageBox::hideEvent( e );
132 alertCount = 0; 132 alertCount = 0;
133 currentPriority = INT_MAX; 133 currentPriority = INT_MAX;
134} 134}
135 135
136 136
137 137
138DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) 138DesktopApplication::DesktopApplication( int& argc, char **argv, Type t )
139 : QPEApplication( argc, argv, t ) 139 : QPEApplication( argc, argv, t )
140{ 140{
141 141
142 QTimer *t = new QTimer( this ); 142 QTimer *t = new QTimer( this );
143 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 143 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
144 t->start( 10000 ); 144 t->start( 10000 );
145 ps = new PowerStatus; 145 ps = new PowerStatus;
146 pa = new DesktopPowerAlerter( 0 ); 146 pa = new DesktopPowerAlerter( 0 );
147 147
148 channel = new QCopChannel( "QPE/Desktop", this ); 148 channel = new QCopChannel( "QPE/Desktop", this );
149 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 149 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
150 this, SLOT(receive(const QCString&, const QByteArray&)) ); 150 this, SLOT(receive(const QCString&, const QByteArray&)) );
151} 151}
152 152
153 153
154DesktopApplication::~DesktopApplication() 154DesktopApplication::~DesktopApplication()
155{ 155{
156 delete ps; 156 delete ps;
157 delete pa; 157 delete pa;
158} 158}
159 159
160void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 160void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
161{ 161{
162 QDataStream stream( data, IO_ReadOnly ); 162 QDataStream stream( data, IO_ReadOnly );
163 if (msg == "keyRegister(int key, QString channel, QString message)") 163 if (msg == "keyRegister(int key, QString channel, QString message)")
164 { 164 {
165 int k; 165 int k;
166 QString c, m; 166 QString c, m;
167 167
168 stream >> k; 168 stream >> k;
169 stream >> c; 169 stream >> c;
170 stream >> m; 170 stream >> m;
171 171
172 qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); 172 qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m);
173 keyRegisterList.append(QCopKeyRegister(k,c,m)); 173 keyRegisterList.append(QCopKeyRegister(k,c,m));
174 } 174 }
175 else if (msg == "suspend()"){
176 emit power();
177 }
178
175} 179}
176 180
177enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 181enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
178 182
179#ifdef Q_WS_QWS 183#ifdef Q_WS_QWS
180bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 184bool DesktopApplication::qwsEventFilter( QWSEvent *e )
181{ 185{
182 qpedesktop->checkMemory(); 186 qpedesktop->checkMemory();
183 187
184 if ( e->type == QWSEvent::Key ) { 188 if ( e->type == QWSEvent::Key ) {
185 QWSKeyEvent *ke = (QWSKeyEvent *)e; 189 QWSKeyEvent *ke = (QWSKeyEvent *)e;
186 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 190 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
187 return TRUE; 191 return TRUE;
188 bool press = ke->simpleData.is_press; 192 bool press = ke->simpleData.is_press;
189 193
190 if (!keyRegisterList.isEmpty()) 194 if (!keyRegisterList.isEmpty())
191 { 195 {
192 KeyRegisterList::Iterator it; 196 KeyRegisterList::Iterator it;
193 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) 197 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
194 { 198 {
195 if ((*it).getKeyCode() == ke->simpleData.keycode) 199 if ((*it).getKeyCode() == ke->simpleData.keycode)
196 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 200 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
197 } 201 }
198 } 202 }
199 203
200 if ( !keyboardGrabbed() ) { 204 if ( !keyboardGrabbed() ) {
201 if ( ke->simpleData.keycode == Key_F9 ) { 205 if ( ke->simpleData.keycode == Key_F9 ) {
202 if ( press ) emit datebook(); 206 if ( press ) emit datebook();
203 return TRUE; 207 return TRUE;
204 } 208 }
205 if ( ke->simpleData.keycode == Key_F10 ) { 209 if ( ke->simpleData.keycode == Key_F10 ) {
206 if ( !press && cardSendTimer ) { 210 if ( !press && cardSendTimer ) {
207 emit contacts(); 211 emit contacts();
208 delete cardSendTimer; 212 delete cardSendTimer;
209 } else if ( press ) { 213 } else if ( press ) {
210 cardSendTimer = new QTimer(); 214 cardSendTimer = new QTimer();
211 cardSendTimer->start( 2000, TRUE ); 215 cardSendTimer->start( 2000, TRUE );
212 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 216 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
213 } 217 }
214 return TRUE; 218 return TRUE;
215 } 219 }
216 /* menu key now opens application menu/toolbar 220 /* menu key now opens application menu/toolbar
217 if ( ke->simpleData.keycode == Key_F11 ) { 221 if ( ke->simpleData.keycode == Key_F11 ) {
218 if ( press ) emit menu(); 222 if ( press ) emit menu();
219 return TRUE; 223 return TRUE;
220 } 224 }
221 */ 225 */
222 if ( ke->simpleData.keycode == Key_F12 ) { 226 if ( ke->simpleData.keycode == Key_F12 ) {
223 while( activePopupWidget() ) 227 while( activePopupWidget() )
224 activePopupWidget()->close(); 228 activePopupWidget()->close();
225 if ( press ) emit launch(); 229 if ( press ) emit launch();
226 return TRUE; 230 return TRUE;
227 } 231 }
228 if ( ke->simpleData.keycode == Key_F13 ) { 232 if ( ke->simpleData.keycode == Key_F13 ) {
229 if ( press ) emit email(); 233 if ( press ) emit email();
230 return TRUE; 234 return TRUE;
231 } 235 }
232 } 236 }
233 237
234 if ( ke->simpleData.keycode == Key_F34 ) { 238 if ( ke->simpleData.keycode == Key_F34 ) {
235 if ( press ) emit power(); 239 if ( press ) emit power();
236 return TRUE; 240 return TRUE;
237 } 241 }
238 if ( ke->simpleData.keycode == Key_F35 ) { 242 if ( ke->simpleData.keycode == Key_F35 ) {
239 if ( press ) emit backlight(); 243 if ( press ) emit backlight();
240 return TRUE; 244 return TRUE;
241 } 245 }
242 if ( ke->simpleData.keycode == Key_F32 ) { 246 if ( ke->simpleData.keycode == Key_F32 ) {
243 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 247 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
244 return TRUE; 248 return TRUE;
245 } 249 }
246 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 250 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
247 if ( press ) emit symbol(); 251 if ( press ) emit symbol();
248 return TRUE; 252 return TRUE;
249 } 253 }
250 if ( ke->simpleData.keycode == Key_NumLock ) { 254 if ( ke->simpleData.keycode == Key_NumLock ) {
251 if ( press ) emit numLockStateToggle(); 255 if ( press ) emit numLockStateToggle();
252 } 256 }
253 if ( ke->simpleData.keycode == Key_CapsLock ) { 257 if ( ke->simpleData.keycode == Key_CapsLock ) {
254 if ( press ) emit capsLockStateToggle(); 258 if ( press ) emit capsLockStateToggle();
255 } 259 }
256 if ( press ) 260 if ( press )
257 qpedesktop->keyClick(); 261 qpedesktop->keyClick();
258 } else { 262 } else {
259 if ( e->type == QWSEvent::Mouse ) { 263 if ( e->type == QWSEvent::Mouse ) {
260 QWSMouseEvent *me = (QWSMouseEvent *)e; 264 QWSMouseEvent *me = (QWSMouseEvent *)e;
261 static bool up = TRUE; 265 static bool up = TRUE;
262 if ( me->simpleData.state&LeftButton ) { 266 if ( me->simpleData.state&LeftButton ) {
263 if ( up ) { 267 if ( up ) {
264 up = FALSE; 268 up = FALSE;
265 qpedesktop->screenClick(); 269 qpedesktop->screenClick();
266 } 270 }
267 } else { 271 } else {
268 up = TRUE; 272 up = TRUE;
269 } 273 }
270 } 274 }
271 } 275 }
272 276
273 return QPEApplication::qwsEventFilter( e ); 277 return QPEApplication::qwsEventFilter( e );
274} 278}
275#endif 279#endif
276 280
277void DesktopApplication::psTimeout() 281void DesktopApplication::psTimeout()
278{ 282{
279 qpedesktop->checkMemory(); // in case no events are being generated 283 qpedesktop->checkMemory(); // in case no events are being generated
280 284
281 *ps = PowerStatusManager::readStatus(); 285 *ps = PowerStatusManager::readStatus();
282 286
283 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 287 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
284 pa->alert( tr( "Battery is running very low." ), 6 ); 288 pa->alert( tr( "Battery is running very low." ), 6 );
285 } 289 }
286 290
287 if ( ps->batteryStatus() == PowerStatus::Critical ) { 291 if ( ps->batteryStatus() == PowerStatus::Critical ) {
288 pa->alert( tr( "Battery level is critical!\n" 292 pa->alert( tr( "Battery level is critical!\n"
289 "Keep power off until power restored!" ), 1 ); 293 "Keep power off until power restored!" ), 1 );
290 } 294 }
291 295
292 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 296 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
293 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 297 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
294 } 298 }
295} 299}
296 300
297 301
298void DesktopApplication::sendCard() 302void DesktopApplication::sendCard()
299{ 303{
300 delete cardSendTimer; 304 delete cardSendTimer;
301 cardSendTimer = 0; 305 cardSendTimer = 0;
302 QString card = getenv("HOME"); 306 QString card = getenv("HOME");
303 card += "/Applications/addressbook/businesscard.vcf"; 307 card += "/Applications/addressbook/businesscard.vcf";
304 308
305 if ( QFile::exists( card ) ) { 309 if ( QFile::exists( card ) ) {
306 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 310 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
307 QString mimetype = "text/x-vCard"; 311 QString mimetype = "text/x-vCard";
308 e << tr("business card") << card << mimetype; 312 e << tr("business card") << card << mimetype;
309 } 313 }
310} 314}
311 315
312#if defined(QPE_HAVE_MEMALERTER) 316#if defined(QPE_HAVE_MEMALERTER)
313QPE_MEMALERTER_IMPL 317QPE_MEMALERTER_IMPL
314#endif 318#endif
315 319
316#if defined(CUSTOM_SOUND_IMPL) 320#if defined(CUSTOM_SOUND_IMPL)
317CUSTOM_SOUND_IMPL 321CUSTOM_SOUND_IMPL
318#endif 322#endif
319 323
320//=========================================================================== 324//===========================================================================
321 325
322Desktop::Desktop() : 326Desktop::Desktop() :
323 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 327 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
324 qcopBridge( 0 ), 328 qcopBridge( 0 ),
325 transferServer( 0 ), 329 transferServer( 0 ),
326 packageSlave( 0 ) 330 packageSlave( 0 )
327{ 331{
328#ifdef CUSTOM_SOUND_INIT 332#ifdef CUSTOM_SOUND_INIT
329 CUSTOM_SOUND_INIT; 333 CUSTOM_SOUND_INIT;
330#endif 334#endif
331 335
332 qpedesktop = this; 336 qpedesktop = this;
333 337
334// bg = new Info( this ); 338// bg = new Info( this );
335 tb = new TaskBar; 339 tb = new TaskBar;
336 340
337 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 341 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
338 342
339 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 343 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
340 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 344 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
341 345
342 int displayw = qApp->desktop()->width(); 346 int displayw = qApp->desktop()->width();
343 int displayh = qApp->desktop()->height(); 347 int displayh = qApp->desktop()->height();
344 348
345 349
346 QSize sz = tb->sizeHint(); 350 QSize sz = tb->sizeHint();
347 351
348 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 352 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
349 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 353 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
350 354
351 tb->show(); 355 tb->show();
352 launcher->showMaximized(); 356 launcher->showMaximized();
353 launcher->show(); 357 launcher->show();
354 launcher->raise(); 358 launcher->raise();
355#if defined(QPE_HAVE_MEMALERTER) 359#if defined(QPE_HAVE_MEMALERTER)
356 initMemalerter(); 360 initMemalerter();
357#endif 361#endif
358 // start services 362 // start services
359 startTransferServer(); 363 startTransferServer();
360 (void) new IrServer( this ); 364 (void) new IrServer( this );
361 rereadVolumes(); 365 rereadVolumes();
362 366
363 packageSlave = new PackageSlave( this ); 367 packageSlave = new PackageSlave( this );
364 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 368 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
365 369
366 qApp->installEventFilter( this ); 370 qApp->installEventFilter( this );
367} 371}
368 372
369void Desktop::show() 373void Desktop::show()
370{ 374{
371 login(TRUE); 375 login(TRUE);
372 QWidget::show(); 376 QWidget::show();
373} 377}
374 378
375Desktop::~Desktop() 379Desktop::~Desktop()
376{ 380{
377 delete launcher; 381 delete launcher;
378 delete tb; 382 delete tb;
379 delete qcopBridge; 383 delete qcopBridge;
380 delete transferServer; 384 delete transferServer;
381} 385}
382 386
383bool Desktop::recoverMemory() 387bool Desktop::recoverMemory()
384{ 388{
385 return tb->recoverMemory(); 389 return tb->recoverMemory();
386} 390}
387 391
388void Desktop::checkMemory() 392void Desktop::checkMemory()
389{ 393{
390#if defined(QPE_HAVE_MEMALERTER) 394#if defined(QPE_HAVE_MEMALERTER)
391 static bool ignoreNormal=FALSE; 395 static bool ignoreNormal=FALSE;
392 static bool existingMessage=FALSE; 396 static bool existingMessage=FALSE;
393 397
394 if(existingMessage) 398 if(existingMessage)
395 return; // don't show a second message while still on first 399 return; // don't show a second message while still on first
396 400
397 existingMessage = TRUE; 401 existingMessage = TRUE;
398 switch ( memstate ) { 402 switch ( memstate ) {
399 case Unknown: 403 case Unknown:
400 break; 404 break;
401 case Low: 405 case Low:
402 memstate = Unknown; 406 memstate = Unknown;
403 if ( recoverMemory() ) 407 if ( recoverMemory() )
404 ignoreNormal = TRUE; 408 ignoreNormal = TRUE;
405 else 409 else
406 QMessageBox::warning( 0 , "Memory Status", 410 QMessageBox::warning( 0 , "Memory Status",
407 "The memory smacks of shortage. \n" 411 "The memory smacks of shortage. \n"
408 "Please save data. " ); 412 "Please save data. " );
409 break; 413 break;
410 case Normal: 414 case Normal:
411 memstate = Unknown; 415 memstate = Unknown;
412 if ( ignoreNormal ) 416 if ( ignoreNormal )
413 ignoreNormal = FALSE; 417 ignoreNormal = FALSE;
414 else 418 else
415 QMessageBox::information ( 0 , "Memory Status", 419 QMessageBox::information ( 0 , "Memory Status",
416 "There is enough memory again." ); 420 "There is enough memory again." );
417 break; 421 break;
418 case VeryLow: 422 case VeryLow:
419 memstate = Unknown; 423 memstate = Unknown;
420 QMessageBox::critical( 0 , "Memory Status", 424 QMessageBox::critical( 0 , "Memory Status",
421 "The memory is very low. \n" 425 "The memory is very low. \n"
422 "Please end this application \n" 426 "Please end this application \n"
423 "immediately." ); 427 "immediately." );
424 recoverMemory(); 428 recoverMemory();
425 } 429 }
426 existingMessage = FALSE; 430 existingMessage = FALSE;
427#endif 431#endif
428} 432}
429 433
430static bool isVisibleWindow(int wid) 434static bool isVisibleWindow(int wid)