summaryrefslogtreecommitdiff
authorjeremy <jeremy>2002-02-15 21:12:53 (UTC)
committer jeremy <jeremy>2002-02-15 21:12:53 (UTC)
commitb0768575b7bc1e4fe477d37a49cccc7e3d92bf85 (patch) (unidiff)
tree4c66c26f74ec710204f3f2e4303a6d6d8968c6a7
parentb15950bcf97b5590d37373ec2beedab80e40ded6 (diff)
downloadopie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.zip
opie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.tar.gz
opie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.tar.bz2
Added new QCop support. Desktop now listens on channel QPE/Desktop to the
keyRegister(int key, QString channel, QString message) message. What this will do is allow an app to reiceve keyboard input for a particular key no matter if they have focus or not.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp132
-rw-r--r--core/launcher/desktop.h4
-rw-r--r--core/launcher/opie-taskbar.control4
3 files changed, 100 insertions, 40 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index d39af25..ce99bad 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,603 +1,659 @@
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>
51
50#include <stdlib.h> 52#include <stdlib.h>
51#include <unistd.h> 53#include <unistd.h>
52 54
55
56class QCopKeyRegister
57{
58public:
59 QCopKeyRegister() : keyCode(0) { }
60 QCopKeyRegister(int k, const QString &c, const QString &m)
61 : keyCode(k), channel(c), message(m) { }
62
63 int getKeyCode() const { return keyCode; }
64 QString getChannel() const { return channel; }
65 QString getMessage() const { return message; }
66
67private:
68 int keyCode;
69 QString channel, message;
70};
71
72typedef QValueList<QCopKeyRegister> KeyRegisterList;
73KeyRegisterList keyRegisterList;
74
53static Desktop* qpedesktop = 0; 75static Desktop* qpedesktop = 0;
54static int loggedin=0; 76static int loggedin=0;
55static void login(bool at_poweron) 77static void login(bool at_poweron)
56{ 78{
57 if ( !loggedin ) { 79 if ( !loggedin ) {
58 Global::terminateBuiltin("calibrate"); 80 Global::terminateBuiltin("calibrate");
59 Password::authenticate(at_poweron); 81 Password::authenticate(at_poweron);
60 loggedin=1; 82 loggedin=1;
61 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 83 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
62 } 84 }
63} 85}
64 86
65bool Desktop::screenLocked() 87bool Desktop::screenLocked()
66{ 88{
67 return loggedin == 0; 89 return loggedin == 0;
68} 90}
69 91
70/* 92/*
71 Priority is number of alerts that are needed to pop up 93 Priority is number of alerts that are needed to pop up
72 alert. 94 alert.
73 */ 95 */
74class DesktopPowerAlerter : public QMessageBox 96class DesktopPowerAlerter : public QMessageBox
75{ 97{
76public: 98public:
77 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 99 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
78 : QMessageBox( tr("Battery Status"), "Low Battery", 100 : QMessageBox( tr("Battery Status"), "Low Battery",
79 QMessageBox::Critical, 101 QMessageBox::Critical,
80 QMessageBox::Ok | QMessageBox::Default, 102 QMessageBox::Ok | QMessageBox::Default,
81 QMessageBox::NoButton, QMessageBox::NoButton, 103 QMessageBox::NoButton, QMessageBox::NoButton,
82 parent, name, FALSE ) 104 parent, name, FALSE )
83 { 105 {
84 currentPriority = INT_MAX; 106 currentPriority = INT_MAX;
85 alertCount = 0; 107 alertCount = 0;
86 } 108 }
87 109
88 void alert( const QString &text, int priority ); 110 void alert( const QString &text, int priority );
89 void hideEvent( QHideEvent * ); 111 void hideEvent( QHideEvent * );
90private: 112private:
91 int currentPriority; 113 int currentPriority;
92 int alertCount; 114 int alertCount;
93}; 115};
94 116
95void DesktopPowerAlerter::alert( const QString &text, int priority ) 117void DesktopPowerAlerter::alert( const QString &text, int priority )
96{ 118{
97 alertCount++; 119 alertCount++;
98 if ( alertCount < priority ) 120 if ( alertCount < priority )
99 return; 121 return;
100 if ( priority > currentPriority ) 122 if ( priority > currentPriority )
101 return; 123 return;
102 currentPriority = priority; 124 currentPriority = priority;
103 setText( text ); 125 setText( text );
104 show(); 126 show();
105} 127}
106 128
107 129
108void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 130void DesktopPowerAlerter::hideEvent( QHideEvent *e )
109{ 131{
110 QMessageBox::hideEvent( e ); 132 QMessageBox::hideEvent( e );
111 alertCount = 0; 133 alertCount = 0;
112 currentPriority = INT_MAX; 134 currentPriority = INT_MAX;
113} 135}
114 136
115 137
116 138
117DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) 139DesktopApplication::DesktopApplication( int& argc, char **argv, Type t )
118 : QPEApplication( argc, argv, t ) 140 : QPEApplication( argc, argv, t )
119{ 141{
120 142
121 QTimer *t = new QTimer( this ); 143 QTimer *t = new QTimer( this );
122 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 144 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
123 t->start( 10000 ); 145 t->start( 10000 );
124 ps = new PowerStatus; 146 ps = new PowerStatus;
125 pa = new DesktopPowerAlerter( 0 ); 147 pa = new DesktopPowerAlerter( 0 );
148
149 channel = new QCopChannel( "QPE/Desktop", this );
150 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
151 this, SLOT(receive(const QCString&, const QByteArray&)) );
126} 152}
127 153
128 154
129DesktopApplication::~DesktopApplication() 155DesktopApplication::~DesktopApplication()
130{ 156{
131 delete ps; 157 delete ps;
132 delete pa; 158 delete pa;
133} 159}
134 160
161void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
162{
163 QDataStream stream( data, IO_ReadOnly );
164 if (msg == "keyRegister(int key, QString channel, QString message)")
165 {
166 int k;
167 QString c, m;
168
169 stream >> k;
170 stream >> c;
171 stream >> m;
172
173 qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m);
174 keyRegisterList.append(QCopKeyRegister(k,c,m));
175 }
176}
135 177
136enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 178enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
137 179
138#ifdef Q_WS_QWS 180#ifdef Q_WS_QWS
139bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 181bool DesktopApplication::qwsEventFilter( QWSEvent *e )
140{ 182{
141 qpedesktop->checkMemory(); 183 qpedesktop->checkMemory();
142 184
143 if ( e->type == QWSEvent::Key ) { 185 if ( e->type == QWSEvent::Key ) {
144 QWSKeyEvent *ke = (QWSKeyEvent *)e; 186 QWSKeyEvent *ke = (QWSKeyEvent *)e;
145 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 187 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
146 return TRUE; 188 return TRUE;
147 bool press = ke->simpleData.is_press; 189 bool press = ke->simpleData.is_press;
148 if ( !keyboardGrabbed() ) { 190
191 KeyRegisterList::Iterator it;
192 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
193 {
194 if ((*it).getKeyCode() == ke->simpleData.keycode)
195 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
196 }
197
198 if ( !keyboardGrabbed() ) {
149 if ( ke->simpleData.keycode == Key_F9 ) { 199 if ( ke->simpleData.keycode == Key_F9 ) {
150 if ( press ) emit datebook(); 200 if ( press ) emit datebook();
151 return TRUE; 201 return TRUE;
152 } 202 }
153 if ( ke->simpleData.keycode == Key_F10 ) { 203 if ( ke->simpleData.keycode == Key_F10 ) {
154 if ( !press && cardSendTimer ) { 204 if ( !press && cardSendTimer ) {
155 emit contacts(); 205 emit contacts();
156 delete cardSendTimer; 206 delete cardSendTimer;
157 } else if ( press ) { 207 } else if ( press ) {
158 cardSendTimer = new QTimer(); 208 cardSendTimer = new QTimer();
159 cardSendTimer->start( 2000, TRUE ); 209 cardSendTimer->start( 2000, TRUE );
160 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 210 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
161 } 211 }
162 return TRUE; 212 return TRUE;
163 } 213 }
164 /* menu key now opens application menu/toolbar 214 /* menu key now opens application menu/toolbar
165 if ( ke->simpleData.keycode == Key_F11 ) { 215 if ( ke->simpleData.keycode == Key_F11 ) {
166 if ( press ) emit menu(); 216 if ( press ) emit menu();
167 return TRUE; 217 return TRUE;
168 } 218 }
169 */ 219 */
170 if ( ke->simpleData.keycode == Key_F12 ) { 220 if ( ke->simpleData.keycode == Key_F12 ) {
171 while( activePopupWidget() ) 221 while( activePopupWidget() )
172 activePopupWidget()->close(); 222 activePopupWidget()->close();
173 if ( press ) emit launch(); 223 if ( press ) emit launch();
174 return TRUE; 224 return TRUE;
175 } 225 }
176 if ( ke->simpleData.keycode == Key_F13 ) { 226 if ( ke->simpleData.keycode == Key_F13 ) {
177 if ( press ) emit email(); 227 if ( press ) emit email();
178 return TRUE; 228 return TRUE;
179 } 229 }
180 } 230 }
181 if ( ke->simpleData.keycode == Key_F34 ) { 231 /*
232 if ( ke->simpleData.keycode == 4096 ) {
233 QCopEnvelope e("QPE/VMemo", "toggleRecord()");
234 return TRUE;
235 }
236 */
237 if ( ke->simpleData.keycode == Key_F34 ) {
182 if ( press ) emit power(); 238 if ( press ) emit power();
183 return TRUE; 239 return TRUE;
184 } 240 }
185 if ( ke->simpleData.keycode == Key_F35 ) { 241 if ( ke->simpleData.keycode == Key_F35 ) {
186 if ( press ) emit backlight(); 242 if ( press ) emit backlight();
187 return TRUE; 243 return TRUE;
188 } 244 }
189 if ( ke->simpleData.keycode == Key_F32 ) { 245 if ( ke->simpleData.keycode == Key_F32 ) {
190 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 246 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
191 return TRUE; 247 return TRUE;
192 } 248 }
193 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 249 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
194 if ( press ) emit symbol(); 250 if ( press ) emit symbol();
195 return TRUE; 251 return TRUE;
196 } 252 }
197 if ( ke->simpleData.keycode == Key_NumLock ) { 253 if ( ke->simpleData.keycode == Key_NumLock ) {
198 if ( press ) emit numLockStateToggle(); 254 if ( press ) emit numLockStateToggle();
199 } 255 }
200 if ( ke->simpleData.keycode == Key_CapsLock ) { 256 if ( ke->simpleData.keycode == Key_CapsLock ) {
201 if ( press ) emit capsLockStateToggle(); 257 if ( press ) emit capsLockStateToggle();
202 } 258 }
203 if ( press ) 259 if ( press )
204 qpedesktop->keyClick(); 260 qpedesktop->keyClick();
205 } else { 261 } else {
206 if ( e->type == QWSEvent::Mouse ) { 262 if ( e->type == QWSEvent::Mouse ) {
207 QWSMouseEvent *me = (QWSMouseEvent *)e; 263 QWSMouseEvent *me = (QWSMouseEvent *)e;
208 static bool up = TRUE; 264 static bool up = TRUE;
209 if ( me->simpleData.state&LeftButton ) { 265 if ( me->simpleData.state&LeftButton ) {
210 if ( up ) { 266 if ( up ) {
211 up = FALSE; 267 up = FALSE;
212 qpedesktop->screenClick(); 268 qpedesktop->screenClick();
213 } 269 }
214 } else { 270 } else {
215 up = TRUE; 271 up = TRUE;
216 } 272 }
217 } 273 }
218 } 274 }
219 275
220 return QPEApplication::qwsEventFilter( e ); 276 return QPEApplication::qwsEventFilter( e );
221} 277}
222#endif 278#endif
223 279
224void DesktopApplication::psTimeout() 280void DesktopApplication::psTimeout()
225{ 281{
226 qpedesktop->checkMemory(); // in case no events are being generated 282 qpedesktop->checkMemory(); // in case no events are being generated
227 283
228 *ps = PowerStatusManager::readStatus(); 284 *ps = PowerStatusManager::readStatus();
229 285
230 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 286 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
231 pa->alert( tr( "Battery is running very low." ), 6 ); 287 pa->alert( tr( "Battery is running very low." ), 6 );
232 } 288 }
233 289
234 if ( ps->batteryStatus() == PowerStatus::Critical ) { 290 if ( ps->batteryStatus() == PowerStatus::Critical ) {
235 pa->alert( tr( "Battery level is critical!\n" 291 pa->alert( tr( "Battery level is critical!\n"
236 "Keep power off until power restored!" ), 1 ); 292 "Keep power off until power restored!" ), 1 );
237 } 293 }
238 294
239 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 295 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
240 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 296 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
241 } 297 }
242} 298}
243 299
244 300
245void DesktopApplication::sendCard() 301void DesktopApplication::sendCard()
246{ 302{
247 delete cardSendTimer; 303 delete cardSendTimer;
248 cardSendTimer = 0; 304 cardSendTimer = 0;
249 QString card = getenv("HOME"); 305 QString card = getenv("HOME");
250 card += "/Applications/addressbook/businesscard.vcf"; 306 card += "/Applications/addressbook/businesscard.vcf";
251 307
252 if ( QFile::exists( card ) ) { 308 if ( QFile::exists( card ) ) {
253 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 309 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
254 QString mimetype = "text/x-vCard"; 310 QString mimetype = "text/x-vCard";
255 e << tr("business card") << card << mimetype; 311 e << tr("business card") << card << mimetype;
256 } 312 }
257} 313}
258 314
259#if defined(QPE_HAVE_MEMALERTER) 315#if defined(QPE_HAVE_MEMALERTER)
260QPE_MEMALERTER_IMPL 316QPE_MEMALERTER_IMPL
261#endif 317#endif
262 318
263#if defined(CUSTOM_SOUND_IMPL) 319#if defined(CUSTOM_SOUND_IMPL)
264CUSTOM_SOUND_IMPL 320CUSTOM_SOUND_IMPL
265#endif 321#endif
266 322
267//=========================================================================== 323//===========================================================================
268 324
269Desktop::Desktop() : 325Desktop::Desktop() :
270 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 326 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
271 qcopBridge( 0 ), 327 qcopBridge( 0 ),
272 transferServer( 0 ), 328 transferServer( 0 ),
273 packageSlave( 0 ) 329 packageSlave( 0 )
274{ 330{
275#ifdef CUSTOM_SOUND_INIT 331#ifdef CUSTOM_SOUND_INIT
276 CUSTOM_SOUND_INIT; 332 CUSTOM_SOUND_INIT;
277#endif 333#endif
278 334
279 qpedesktop = this; 335 qpedesktop = this;
280 336
281// bg = new Info( this ); 337// bg = new Info( this );
282 tb = new TaskBar; 338 tb = new TaskBar;
283 339
284 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 340 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
285 341
286 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 342 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
287 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 343 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
288 344
289 int displayw = qApp->desktop()->width(); 345 int displayw = qApp->desktop()->width();
290 int displayh = qApp->desktop()->height(); 346 int displayh = qApp->desktop()->height();
291 347
292 348
293 QSize sz = tb->sizeHint(); 349 QSize sz = tb->sizeHint();
294 350
295 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 351 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
296 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 352 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
297 353
298 tb->show(); 354 tb->show();
299 launcher->showMaximized(); 355 launcher->showMaximized();
300 launcher->show(); 356 launcher->show();
301 launcher->raise(); 357 launcher->raise();
302#if defined(QPE_HAVE_MEMALERTER) 358#if defined(QPE_HAVE_MEMALERTER)
303 initMemalerter(); 359 initMemalerter();
304#endif 360#endif
305 // start services 361 // start services
306 startTransferServer(); 362 startTransferServer();
307 (void) new IrServer( this ); 363 (void) new IrServer( this );
308 rereadVolumes(); 364 rereadVolumes();
309 365
310 packageSlave = new PackageSlave( this ); 366 packageSlave = new PackageSlave( this );
311 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 367 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
312 368
313 qApp->installEventFilter( this ); 369 qApp->installEventFilter( this );
314} 370}
315 371
316void Desktop::show() 372void Desktop::show()
317{ 373{
318 login(TRUE); 374 login(TRUE);
319 QWidget::show(); 375 QWidget::show();
320} 376}
321 377
322Desktop::~Desktop() 378Desktop::~Desktop()
323{ 379{
324 delete launcher; 380 delete launcher;
325 delete tb; 381 delete tb;
326 delete qcopBridge; 382 delete qcopBridge;
327 delete transferServer; 383 delete transferServer;
328} 384}
329 385
330bool Desktop::recoverMemory() 386bool Desktop::recoverMemory()
331{ 387{
332 return tb->recoverMemory(); 388 return tb->recoverMemory();
333} 389}
334 390
335void Desktop::checkMemory() 391void Desktop::checkMemory()
336{ 392{
337#if defined(QPE_HAVE_MEMALERTER) 393#if defined(QPE_HAVE_MEMALERTER)
338 static bool ignoreNormal=FALSE; 394 static bool ignoreNormal=FALSE;
339 static bool existingMessage=FALSE; 395 static bool existingMessage=FALSE;
340 396
341 if(existingMessage) 397 if(existingMessage)
342 return; // don't show a second message while still on first 398 return; // don't show a second message while still on first
343 399
344 existingMessage = TRUE; 400 existingMessage = TRUE;
345 switch ( memstate ) { 401 switch ( memstate ) {
346 case Unknown: 402 case Unknown:
347 break; 403 break;
348 case Low: 404 case Low:
349 memstate = Unknown; 405 memstate = Unknown;
350 if ( recoverMemory() ) 406 if ( recoverMemory() )
351 ignoreNormal = TRUE; 407 ignoreNormal = TRUE;
352 else 408 else
353 QMessageBox::warning( 0 , "Memory Status", 409 QMessageBox::warning( 0 , "Memory Status",
354 "The memory smacks of shortage. \n" 410 "The memory smacks of shortage. \n"
355 "Please save data. " ); 411 "Please save data. " );
356 break; 412 break;
357 case Normal: 413 case Normal:
358 memstate = Unknown; 414 memstate = Unknown;
359 if ( ignoreNormal ) 415 if ( ignoreNormal )
360 ignoreNormal = FALSE; 416 ignoreNormal = FALSE;
361 else 417 else
362 QMessageBox::information ( 0 , "Memory Status", 418 QMessageBox::information ( 0 , "Memory Status",
363 "There is enough memory again." ); 419 "There is enough memory again." );
364 break; 420 break;
365 case VeryLow: 421 case VeryLow:
366 memstate = Unknown; 422 memstate = Unknown;
367 QMessageBox::critical( 0 , "Memory Status", 423 QMessageBox::critical( 0 , "Memory Status",
368 "The memory is very low. \n" 424 "The memory is very low. \n"
369 "Please end this application \n" 425 "Please end this application \n"
370 "immediately." ); 426 "immediately." );
371 recoverMemory(); 427 recoverMemory();
372 } 428 }
373 existingMessage = FALSE; 429 existingMessage = FALSE;
374#endif 430#endif
375} 431}
376 432
377static bool isVisibleWindow(int wid) 433static bool isVisibleWindow(int wid)
378{ 434{
379 const QList<QWSWindow> &list = qwsServer->clientWindows(); 435 const QList<QWSWindow> &list = qwsServer->clientWindows();
380 QWSWindow* w; 436 QWSWindow* w;
381 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 437 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
382 if ( w->winId() == wid ) 438 if ( w->winId() == wid )
383 return !w->isFullyObscured(); 439 return !w->isFullyObscured();
384 } 440 }
385 return FALSE; 441 return FALSE;
386} 442}
387 443
388static bool hasVisibleWindow(const QString& clientname) 444static bool hasVisibleWindow(const QString& clientname)
389{ 445{
390 const QList<QWSWindow> &list = qwsServer->clientWindows(); 446 const QList<QWSWindow> &list = qwsServer->clientWindows();
391 QWSWindow* w; 447 QWSWindow* w;
392 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 448 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
393 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 449 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
394 return TRUE; 450 return TRUE;
395 } 451 }
396 return FALSE; 452 return FALSE;
397} 453}
398 454
399void Desktop::raiseLauncher() 455void Desktop::raiseLauncher()
400{ 456{
401 if ( isVisibleWindow(launcher->winId()) ) 457 if ( isVisibleWindow(launcher->winId()) )
402 launcher->nextView(); 458 launcher->nextView();
403 else 459 else
404 launcher->raise(); 460 launcher->raise();
405} 461}
406 462
407void Desktop::executeOrModify(const QString& appLnkFile) 463void Desktop::executeOrModify(const QString& appLnkFile)
408{ 464{
409 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 465 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
410 if ( lnk.isValid() ) { 466 if ( lnk.isValid() ) {
411 QCString app = lnk.exec().utf8(); 467 QCString app = lnk.exec().utf8();
412 Global::terminateBuiltin("calibrate"); 468 Global::terminateBuiltin("calibrate");
413 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 469 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
414 MRUList::addTask(&lnk); 470 MRUList::addTask(&lnk);
415 if ( hasVisibleWindow(app) ) 471 if ( hasVisibleWindow(app) )
416 QCopChannel::send("QPE/Application/" + app, "nextView()"); 472 QCopChannel::send("QPE/Application/" + app, "nextView()");
417 else 473 else
418 QCopChannel::send("QPE/Application/" + app, "raise()"); 474 QCopChannel::send("QPE/Application/" + app, "raise()");
419 } else { 475 } else {
420 lnk.execute(); 476 lnk.execute();
421 } 477 }
422 } 478 }
423} 479}
424 480
425void Desktop::raiseDatebook() 481void Desktop::raiseDatebook()
426{ 482{
427 executeOrModify("Applications/datebook.desktop"); 483 executeOrModify("Applications/datebook.desktop");
428} 484}
429 485
430void Desktop::raiseContacts() 486void Desktop::raiseContacts()
431{ 487{
432 executeOrModify("Applications/addressbook.desktop"); 488 executeOrModify("Applications/addressbook.desktop");
433} 489}
434 490
435void Desktop::raiseMenu() 491void Desktop::raiseMenu()
436{ 492{
437 Global::terminateBuiltin("calibrate"); 493 Global::terminateBuiltin("calibrate");
438 tb->startMenu()->launch(); 494 tb->startMenu()->launch();
439} 495}
440 496
441void Desktop::raiseEmail() 497void Desktop::raiseEmail()
442{ 498{
443 executeOrModify("Applications/qtmail.desktop"); 499 executeOrModify("Applications/qtmail.desktop");
444} 500}
445 501
446#if defined(QPE_HAVE_TOGGLELIGHT) 502#if defined(QPE_HAVE_TOGGLELIGHT)
447#include <qpe/config.h> 503#include <qpe/config.h>
448 504
449#include <sys/ioctl.h> 505#include <sys/ioctl.h>
450#include <sys/types.h> 506#include <sys/types.h>
451#include <fcntl.h> 507#include <fcntl.h>
452#include <unistd.h> 508#include <unistd.h>
453#include <errno.h> 509#include <errno.h>
454#include <linux/ioctl.h> 510#include <linux/ioctl.h>
455#include <time.h> 511#include <time.h>
456#endif 512#endif
457 513
458static bool blanked=FALSE; 514static bool blanked=FALSE;
459 515
460static void blankScreen() 516static void blankScreen()
461{ 517{
462 if ( !qt_screen ) return; 518 if ( !qt_screen ) return;
463 /* Should use a big black window instead. 519 /* Should use a big black window instead.
464 QGfx* g = qt_screen->screenGfx(); 520 QGfx* g = qt_screen->screenGfx();
465 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 521 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
466 delete g; 522 delete g;
467 */ 523 */
468 blanked = TRUE; 524 blanked = TRUE;
469} 525}
470 526
471static void darkScreen() 527static void darkScreen()
472{ 528{
473 extern void qpe_setBacklight(int); 529 extern void qpe_setBacklight(int);
474 qpe_setBacklight(0); // force off 530 qpe_setBacklight(0); // force off
475} 531}
476 532
477 533
478void Desktop::togglePower() 534void Desktop::togglePower()
479{ 535{
480 bool wasloggedin = loggedin; 536 bool wasloggedin = loggedin;
481 loggedin=0; 537 loggedin=0;
482 darkScreen(); 538 darkScreen();
483 if ( wasloggedin ) 539 if ( wasloggedin )
484 blankScreen(); 540 blankScreen();
485 system("apm --suspend"); 541 system("apm --suspend");
486 QWSServer::screenSaverActivate( FALSE ); 542 QWSServer::screenSaverActivate( FALSE );
487 { 543 {
488 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 544 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
489 QCopEnvelope e("QPE/System", "setBacklight(int)"); 545 QCopEnvelope e("QPE/System", "setBacklight(int)");
490 e << -3; // Force on 546 e << -3; // Force on
491 } 547 }
492 if ( wasloggedin ) 548 if ( wasloggedin )
493 login(TRUE); 549 login(TRUE);
494 //qcopBridge->closeOpenConnections(); 550 //qcopBridge->closeOpenConnections();
495 //qDebug("called togglePower()!!!!!!"); 551 //qDebug("called togglePower()!!!!!!");
496} 552}
497 553
498void Desktop::toggleLight() 554void Desktop::toggleLight()
499{ 555{
500 QCopEnvelope e("QPE/System", "setBacklight(int)"); 556 QCopEnvelope e("QPE/System", "setBacklight(int)");
501 e << -2; // toggle 557 e << -2; // toggle
502} 558}
503 559
504void Desktop::toggleSymbolInput() 560void Desktop::toggleSymbolInput()
505{ 561{
506 tb->toggleSymbolInput(); 562 tb->toggleSymbolInput();
507} 563}
508 564
509void Desktop::toggleNumLockState() 565void Desktop::toggleNumLockState()
510{ 566{
511 tb->toggleNumLockState(); 567 tb->toggleNumLockState();
512} 568}
513 569
514void Desktop::toggleCapsLockState() 570void Desktop::toggleCapsLockState()
515{ 571{
516 tb->toggleCapsLockState(); 572 tb->toggleCapsLockState();
517} 573}
518 574
519void Desktop::styleChange( QStyle &s ) 575void Desktop::styleChange( QStyle &s )
520{ 576{
521 QWidget::styleChange( s ); 577 QWidget::styleChange( s );
522 int displayw = qApp->desktop()->width(); 578 int displayw = qApp->desktop()->width();
523 int displayh = qApp->desktop()->height(); 579 int displayh = qApp->desktop()->height();
524 580
525 QSize sz = tb->sizeHint(); 581 QSize sz = tb->sizeHint();
526 582
527 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 583 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
528} 584}
529 585
530void DesktopApplication::shutdown() 586void DesktopApplication::shutdown()
531{ 587{
532 if ( type() != GuiServer ) 588 if ( type() != GuiServer )
533 return; 589 return;
534 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 590 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
535 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 591 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
536 this, SLOT(shutdown(ShutdownImpl::Type)) ); 592 this, SLOT(shutdown(ShutdownImpl::Type)) );
537 sd->showMaximized(); 593 sd->showMaximized();
538} 594}
539 595
540void DesktopApplication::shutdown( ShutdownImpl::Type t ) 596void DesktopApplication::shutdown( ShutdownImpl::Type t )
541{ 597{
542 switch ( t ) { 598 switch ( t ) {
543 case ShutdownImpl::ShutdownSystem: 599 case ShutdownImpl::ShutdownSystem:
544 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 600 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
545 break; 601 break;
546 case ShutdownImpl::RebootSystem: 602 case ShutdownImpl::RebootSystem:
547 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 603 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
548 break; 604 break;
549 case ShutdownImpl::RestartDesktop: 605 case ShutdownImpl::RestartDesktop:
550 restart(); 606 restart();
551 break; 607 break;
552 case ShutdownImpl::TerminateDesktop: 608 case ShutdownImpl::TerminateDesktop:
553 prepareForTermination(FALSE); 609 prepareForTermination(FALSE);
554 quit(); 610 quit();
555 break; 611 break;
556 } 612 }
557} 613}
558 614
559void DesktopApplication::restart() 615void DesktopApplication::restart()
560{ 616{
561 prepareForTermination(TRUE); 617 prepareForTermination(TRUE);
562 618
563#ifdef Q_WS_QWS 619#ifdef Q_WS_QWS
564 for ( int fd = 3; fd < 100; fd++ ) 620 for ( int fd = 3; fd < 100; fd++ )
565 close( fd ); 621 close( fd );
566#if defined(QT_DEMO_SINGLE_FLOPPY) 622#if defined(QT_DEMO_SINGLE_FLOPPY)
567 execl( "/sbin/init", "qpe", 0 ); 623 execl( "/sbin/init", "qpe", 0 );
568#elif defined(QT_QWS_CASSIOPEIA) 624#elif defined(QT_QWS_CASSIOPEIA)
569 execl( "/bin/sh", "sh", 0 ); 625 execl( "/bin/sh", "sh", 0 );
570#else 626#else
571 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 627 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
572#endif 628#endif
573 exit(1); 629 exit(1);
574#endif 630#endif
575} 631}
576 632
577void Desktop::startTransferServer() 633void Desktop::startTransferServer()
578{ 634{
579 // start qcop bridge server 635 // start qcop bridge server
580 qcopBridge = new QCopBridge( 4243 ); 636 qcopBridge = new QCopBridge( 4243 );
581 if ( !qcopBridge->ok() ) { 637 if ( !qcopBridge->ok() ) {
582 delete qcopBridge; 638 delete qcopBridge;
583 qcopBridge = 0; 639 qcopBridge = 0;
584 } 640 }
585 // start transfer server 641 // start transfer server
586 transferServer = new TransferServer( 4242 ); 642 transferServer = new TransferServer( 4242 );
587 if ( !transferServer->ok() ) { 643 if ( !transferServer->ok() ) {
588 delete transferServer; 644 delete transferServer;
589 transferServer = 0; 645 transferServer = 0;
590 } 646 }
591 if ( !transferServer || !qcopBridge ) 647 if ( !transferServer || !qcopBridge )
592 startTimer( 2000 ); 648 startTimer( 2000 );
593} 649}
594 650
595void Desktop::timerEvent( QTimerEvent *e ) 651void Desktop::timerEvent( QTimerEvent *e )
596{ 652{
597 killTimer( e->timerId() ); 653 killTimer( e->timerId() );
598 startTransferServer(); 654 startTransferServer();
599} 655}
600 656
601void Desktop::terminateServers() 657void Desktop::terminateServers()
602{ 658{
603 delete transferServer; 659 delete transferServer;
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index dfdbeab..f0a7cba 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -1,129 +1,133 @@
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 30
31class Background; 31class Background;
32class Launcher; 32class Launcher;
33class TaskBar; 33class TaskBar;
34class PowerStatus; 34class PowerStatus;
35class QCopBridge; 35class QCopBridge;
36class TransferServer; 36class TransferServer;
37class DesktopPowerAlerter; 37class DesktopPowerAlerter;
38class PackageSlave; 38class PackageSlave;
39 39
40class DesktopApplication : public QPEApplication 40class DesktopApplication : public QPEApplication
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 DesktopApplication( int& argc, char **argv, Type t ); 44 DesktopApplication( int& argc, char **argv, Type t );
45 ~DesktopApplication(); 45 ~DesktopApplication();
46signals: 46signals:
47 void home(); 47 void home();
48 void datebook(); 48 void datebook();
49 void contacts(); 49 void contacts();
50 void launch(); 50 void launch();
51 void email(); 51 void email();
52 void backlight(); 52 void backlight();
53 void power(); 53 void power();
54 void symbol(); 54 void symbol();
55 void numLockStateToggle(); 55 void numLockStateToggle();
56 void capsLockStateToggle(); 56 void capsLockStateToggle();
57 void prepareForRestart(); 57 void prepareForRestart();
58 58
59protected: 59protected:
60#ifdef Q_WS_QWS 60#ifdef Q_WS_QWS
61 bool qwsEventFilter( QWSEvent * ); 61 bool qwsEventFilter( QWSEvent * );
62#endif 62#endif
63 void shutdown(); 63 void shutdown();
64 void restart(); 64 void restart();
65 65
66public slots:
67 void receive( const QCString &msg, const QByteArray &data );
68
66protected slots: 69protected slots:
67 void shutdown(ShutdownImpl::Type); 70 void shutdown(ShutdownImpl::Type);
68 void psTimeout(); 71 void psTimeout();
69 void sendCard(); 72 void sendCard();
70private: 73private:
71 DesktopPowerAlerter *pa; 74 DesktopPowerAlerter *pa;
72 PowerStatus *ps; 75 PowerStatus *ps;
73 QTimer *cardSendTimer; 76 QTimer *cardSendTimer;
77 QCopChannel *channel;
74}; 78};
75 79
76 80
77class Desktop : public QWidget { 81class Desktop : public QWidget {
78 Q_OBJECT 82 Q_OBJECT
79public: 83public:
80 Desktop(); 84 Desktop();
81 ~Desktop(); 85 ~Desktop();
82 86
83 static bool screenLocked(); 87 static bool screenLocked();
84 88
85 void show(); 89 void show();
86 void checkMemory(); 90 void checkMemory();
87 91
88 void keyClick(); 92 void keyClick();
89 void screenClick(); 93 void screenClick();
90 static void soundAlarm(); 94 static void soundAlarm();
91 95
92public slots: 96public slots:
93 void raiseDatebook(); 97 void raiseDatebook();
94 void raiseContacts(); 98 void raiseContacts();
95 void raiseMenu(); 99 void raiseMenu();
96 void raiseLauncher(); 100 void raiseLauncher();
97 void raiseEmail(); 101 void raiseEmail();
98 void togglePower(); 102 void togglePower();
99 void toggleLight(); 103 void toggleLight();
100 void toggleNumLockState(); 104 void toggleNumLockState();
101 void toggleCapsLockState(); 105 void toggleCapsLockState();
102 void toggleSymbolInput(); 106 void toggleSymbolInput();
103 void terminateServers(); 107 void terminateServers();
104 void rereadVolumes(); 108 void rereadVolumes();
105 109
106protected: 110protected:
107 void executeOrModify(const QString& appLnkFile); 111 void executeOrModify(const QString& appLnkFile);
108 void styleChange( QStyle & ); 112 void styleChange( QStyle & );
109 void timerEvent( QTimerEvent *e ); 113 void timerEvent( QTimerEvent *e );
110 bool eventFilter( QObject *, QEvent * ); 114 bool eventFilter( QObject *, QEvent * );
111 115
112 QWidget *bg; 116 QWidget *bg;
113 Launcher *launcher; 117 Launcher *launcher;
114 TaskBar *tb; 118 TaskBar *tb;
115 119
116private: 120private:
117 void startTransferServer(); 121 void startTransferServer();
118 bool recoverMemory(); 122 bool recoverMemory();
119 123
120 QCopBridge *qcopBridge; 124 QCopBridge *qcopBridge;
121 TransferServer *transferServer; 125 TransferServer *transferServer;
122 PackageSlave *packageSlave; 126 PackageSlave *packageSlave;
123 127
124 bool keyclick,touchclick; 128 bool keyclick,touchclick;
125}; 129};
126 130
127 131
128#endif // __DESKTOP_H__ 132#endif // __DESKTOP_H__
129 133
diff --git a/core/launcher/opie-taskbar.control b/core/launcher/opie-taskbar.control
index 53daa82..3db0480 100644
--- a/core/launcher/opie-taskbar.control
+++ b/core/launcher/opie-taskbar.control
@@ -1,9 +1,9 @@
1Files: bin/qpe apps/Settings/Calibrate.desktop 1Files: bin/qpe apps/Settings/Calibrate.desktop
2Priority: required 2Priority: required
3Section: opie/system 3Section: opie/system
4Maintainer: Warwick Allison <warwick@trolltech.com> 4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION.1
7Depends: qt-embedded (>=$QTE_VERSION) 7Depends: qt-embedded (>=$QTE_VERSION)
8Description: Launcher for Opie 8Description: Launcher for Opie
9 The "finder" or "explorer", or whatever you want to call it. 9 The "finder" or "explorer", or whatever you want to call it. \ No newline at end of file