summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-07 11:05:40 (UTC)
committer harlekin <harlekin>2002-03-07 11:05:40 (UTC)
commita2f42b6df21b2e5d52b49376542d0f4c7443a897 (patch) (unidiff)
treebfbacf25dd213cdb2b7a86a007e4598a1634bb18
parent09444065297662fca1396abf8c0c9dd00380699f (diff)
downloadopie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.zip
opie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.tar.gz
opie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.tar.bz2
beginning support for autostart
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp48
-rw-r--r--core/launcher/desktop.h1
-rw-r--r--core/launcher/launcher.cpp60
3 files changed, 80 insertions, 29 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index a00fae2..4587ec6 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,709 +1,723 @@
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
55
56class QCopKeyRegister 55class QCopKeyRegister
57{ 56{
58public: 57public:
59 QCopKeyRegister() : keyCode(0) { } 58 QCopKeyRegister() : keyCode(0) { }
60 QCopKeyRegister(int k, const QString &c, const QString &m) 59 QCopKeyRegister(int k, const QString &c, const QString &m)
61 : keyCode(k), channel(c), message(m) { } 60 : keyCode(k), channel(c), message(m) { }
62 61
63 int getKeyCode() const { return keyCode; } 62 int getKeyCode() const { return keyCode; }
64 QString getChannel() const { return channel; } 63 QString getChannel() const { return channel; }
65 QString getMessage() const { return message; } 64 QString getMessage() const { return message; }
66 65
67private: 66private:
68 int keyCode; 67 int keyCode;
69 QString channel, message; 68 QString channel, message;
70}; 69};
71 70
72typedef QValueList<QCopKeyRegister> KeyRegisterList; 71typedef QValueList<QCopKeyRegister> KeyRegisterList;
73KeyRegisterList keyRegisterList; 72KeyRegisterList keyRegisterList;
74 73
75static Desktop* qpedesktop = 0; 74static Desktop* qpedesktop = 0;
76static int loggedin=0; 75static int loggedin=0;
77static void login(bool at_poweron) 76static void login(bool at_poweron)
78{ 77{
79 if ( !loggedin ) { 78 if ( !loggedin ) {
80 Global::terminateBuiltin("calibrate"); 79 Global::terminateBuiltin("calibrate");
81 Password::authenticate(at_poweron); 80 Password::authenticate(at_poweron);
82 loggedin=1; 81 loggedin=1;
83 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 82 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
84 } 83 }
85} 84}
86 85
87bool Desktop::screenLocked() 86bool Desktop::screenLocked()
88{ 87{
89 return loggedin == 0; 88 return loggedin == 0;
90} 89}
91 90
92/* 91/*
93 Priority is number of alerts that are needed to pop up 92 Priority is number of alerts that are needed to pop up
94 alert. 93 alert.
95 */ 94 */
96class DesktopPowerAlerter : public QMessageBox 95class DesktopPowerAlerter : public QMessageBox
97{ 96{
98public: 97public:
99 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 98 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
100 : QMessageBox( tr("Battery Status"), "Low Battery", 99 : QMessageBox( tr("Battery Status"), "Low Battery",
101 QMessageBox::Critical, 100 QMessageBox::Critical,
102 QMessageBox::Ok | QMessageBox::Default, 101 QMessageBox::Ok | QMessageBox::Default,
103 QMessageBox::NoButton, QMessageBox::NoButton, 102 QMessageBox::NoButton, QMessageBox::NoButton,
104 parent, name, FALSE ) 103 parent, name, FALSE )
105 { 104 {
106 currentPriority = INT_MAX; 105 currentPriority = INT_MAX;
107 alertCount = 0; 106 alertCount = 0;
108 } 107 }
109 108
110 void alert( const QString &text, int priority ); 109 void alert( const QString &text, int priority );
111 void hideEvent( QHideEvent * ); 110 void hideEvent( QHideEvent * );
112private: 111private:
113 int currentPriority; 112 int currentPriority;
114 int alertCount; 113 int alertCount;
115}; 114};
116 115
117void DesktopPowerAlerter::alert( const QString &text, int priority ) 116void DesktopPowerAlerter::alert( const QString &text, int priority )
118{ 117{
119 alertCount++; 118 alertCount++;
120 if ( alertCount < priority ) 119 if ( alertCount < priority )
121 return; 120 return;
122 if ( priority > currentPriority ) 121 if ( priority > currentPriority )
123 return; 122 return;
124 currentPriority = priority; 123 currentPriority = priority;
125 setText( text ); 124 setText( text );
126 show(); 125 show();
127} 126}
128 127
129 128
130void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 129void DesktopPowerAlerter::hideEvent( QHideEvent *e )
131{ 130{
132 QMessageBox::hideEvent( e ); 131 QMessageBox::hideEvent( e );
133 alertCount = 0; 132 alertCount = 0;
134 currentPriority = INT_MAX; 133 currentPriority = INT_MAX;
135} 134}
136 135
137 136
138 137
139DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) 138DesktopApplication::DesktopApplication( int& argc, char **argv, Type t )
140 : QPEApplication( argc, argv, t ) 139 : QPEApplication( argc, argv, t )
141{ 140{
142 141
143 QTimer *t = new QTimer( this ); 142 QTimer *t = new QTimer( this );
144 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 143 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
145 t->start( 10000 ); 144 t->start( 10000 );
146 ps = new PowerStatus; 145 ps = new PowerStatus;
147 pa = new DesktopPowerAlerter( 0 ); 146 pa = new DesktopPowerAlerter( 0 );
148 147
149 channel = new QCopChannel( "QPE/Desktop", this ); 148 channel = new QCopChannel( "QPE/Desktop", this );
150 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 149 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
151 this, SLOT(receive(const QCString&, const QByteArray&)) ); 150 this, SLOT(receive(const QCString&, const QByteArray&)) );
152} 151}
153 152
154 153
155DesktopApplication::~DesktopApplication() 154DesktopApplication::~DesktopApplication()
156{ 155{
157 delete ps; 156 delete ps;
158 delete pa; 157 delete pa;
159} 158}
160 159
161void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 160void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
162{ 161{
163 QDataStream stream( data, IO_ReadOnly ); 162 QDataStream stream( data, IO_ReadOnly );
164 if (msg == "keyRegister(int key, QString channel, QString message)") 163 if (msg == "keyRegister(int key, QString channel, QString message)")
165 { 164 {
166 int k; 165 int k;
167 QString c, m; 166 QString c, m;
168 167
169 stream >> k; 168 stream >> k;
170 stream >> c; 169 stream >> c;
171 stream >> m; 170 stream >> m;
172 171
173 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);
174 keyRegisterList.append(QCopKeyRegister(k,c,m)); 173 keyRegisterList.append(QCopKeyRegister(k,c,m));
175 } 174 }
176} 175}
177 176
178enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 177enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
179 178
180#ifdef Q_WS_QWS 179#ifdef Q_WS_QWS
181bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 180bool DesktopApplication::qwsEventFilter( QWSEvent *e )
182{ 181{
183 qpedesktop->checkMemory(); 182 qpedesktop->checkMemory();
184 183
185 if ( e->type == QWSEvent::Key ) { 184 if ( e->type == QWSEvent::Key ) {
186 QWSKeyEvent *ke = (QWSKeyEvent *)e; 185 QWSKeyEvent *ke = (QWSKeyEvent *)e;
187 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 186 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
188 return TRUE; 187 return TRUE;
189 bool press = ke->simpleData.is_press; 188 bool press = ke->simpleData.is_press;
190 189
191 if (!keyRegisterList.isEmpty()) 190 if (!keyRegisterList.isEmpty())
192 { 191 {
193 KeyRegisterList::Iterator it; 192 KeyRegisterList::Iterator it;
194 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) 193 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
195 { 194 {
196 if ((*it).getKeyCode() == ke->simpleData.keycode) 195 if ((*it).getKeyCode() == ke->simpleData.keycode)
197 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 196 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
198 } 197 }
199 } 198 }
200 199
201 if ( !keyboardGrabbed() ) { 200 if ( !keyboardGrabbed() ) {
202 if ( ke->simpleData.keycode == Key_F9 ) { 201 if ( ke->simpleData.keycode == Key_F9 ) {
203 if ( press ) emit datebook(); 202 if ( press ) emit datebook();
204 return TRUE; 203 return TRUE;
205 } 204 }
206 if ( ke->simpleData.keycode == Key_F10 ) { 205 if ( ke->simpleData.keycode == Key_F10 ) {
207 if ( !press && cardSendTimer ) { 206 if ( !press && cardSendTimer ) {
208 emit contacts(); 207 emit contacts();
209 delete cardSendTimer; 208 delete cardSendTimer;
210 } else if ( press ) { 209 } else if ( press ) {
211 cardSendTimer = new QTimer(); 210 cardSendTimer = new QTimer();
212 cardSendTimer->start( 2000, TRUE ); 211 cardSendTimer->start( 2000, TRUE );
213 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 212 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
214 } 213 }
215 return TRUE; 214 return TRUE;
216 } 215 }
217 /* menu key now opens application menu/toolbar 216 /* menu key now opens application menu/toolbar
218 if ( ke->simpleData.keycode == Key_F11 ) { 217 if ( ke->simpleData.keycode == Key_F11 ) {
219 if ( press ) emit menu(); 218 if ( press ) emit menu();
220 return TRUE; 219 return TRUE;
221 } 220 }
222 */ 221 */
223 if ( ke->simpleData.keycode == Key_F12 ) { 222 if ( ke->simpleData.keycode == Key_F12 ) {
224 while( activePopupWidget() ) 223 while( activePopupWidget() )
225 activePopupWidget()->close(); 224 activePopupWidget()->close();
226 if ( press ) emit launch(); 225 if ( press ) emit launch();
227 return TRUE; 226 return TRUE;
228 } 227 }
229 if ( ke->simpleData.keycode == Key_F13 ) { 228 if ( ke->simpleData.keycode == Key_F13 ) {
230 if ( press ) emit email(); 229 if ( press ) emit email();
231 return TRUE; 230 return TRUE;
232 } 231 }
233 } 232 }
234 233
235 if ( ke->simpleData.keycode == Key_F34 ) { 234 if ( ke->simpleData.keycode == Key_F34 ) {
236 if ( press ) emit power(); 235 if ( press ) emit power();
237 return TRUE; 236 return TRUE;
238 } 237 }
239 if ( ke->simpleData.keycode == Key_F35 ) { 238 if ( ke->simpleData.keycode == Key_F35 ) {
240 if ( press ) emit backlight(); 239 if ( press ) emit backlight();
241 return TRUE; 240 return TRUE;
242 } 241 }
243 if ( ke->simpleData.keycode == Key_F32 ) { 242 if ( ke->simpleData.keycode == Key_F32 ) {
244 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 243 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
245 return TRUE; 244 return TRUE;
246 } 245 }
247 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 246 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
248 if ( press ) emit symbol(); 247 if ( press ) emit symbol();
249 return TRUE; 248 return TRUE;
250 } 249 }
251 if ( ke->simpleData.keycode == Key_NumLock ) { 250 if ( ke->simpleData.keycode == Key_NumLock ) {
252 if ( press ) emit numLockStateToggle(); 251 if ( press ) emit numLockStateToggle();
253 } 252 }
254 if ( ke->simpleData.keycode == Key_CapsLock ) { 253 if ( ke->simpleData.keycode == Key_CapsLock ) {
255 if ( press ) emit capsLockStateToggle(); 254 if ( press ) emit capsLockStateToggle();
256 } 255 }
257 if ( press ) 256 if ( press )
258 qpedesktop->keyClick(); 257 qpedesktop->keyClick();
259 } else { 258 } else {
260 if ( e->type == QWSEvent::Mouse ) { 259 if ( e->type == QWSEvent::Mouse ) {
261 QWSMouseEvent *me = (QWSMouseEvent *)e; 260 QWSMouseEvent *me = (QWSMouseEvent *)e;
262 static bool up = TRUE; 261 static bool up = TRUE;
263 if ( me->simpleData.state&LeftButton ) { 262 if ( me->simpleData.state&LeftButton ) {
264 if ( up ) { 263 if ( up ) {
265 up = FALSE; 264 up = FALSE;
266 qpedesktop->screenClick(); 265 qpedesktop->screenClick();
267 } 266 }
268 } else { 267 } else {
269 up = TRUE; 268 up = TRUE;
270 } 269 }
271 } 270 }
272 } 271 }
273 272
274 return QPEApplication::qwsEventFilter( e ); 273 return QPEApplication::qwsEventFilter( e );
275} 274}
276#endif 275#endif
277 276
278void DesktopApplication::psTimeout() 277void DesktopApplication::psTimeout()
279{ 278{
280 qpedesktop->checkMemory(); // in case no events are being generated 279 qpedesktop->checkMemory(); // in case no events are being generated
281 280
282 *ps = PowerStatusManager::readStatus(); 281 *ps = PowerStatusManager::readStatus();
283 282
284 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 283 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
285 pa->alert( tr( "Battery is running very low." ), 6 ); 284 pa->alert( tr( "Battery is running very low." ), 6 );
286 } 285 }
287 286
288 if ( ps->batteryStatus() == PowerStatus::Critical ) { 287 if ( ps->batteryStatus() == PowerStatus::Critical ) {
289 pa->alert( tr( "Battery level is critical!\n" 288 pa->alert( tr( "Battery level is critical!\n"
290 "Keep power off until power restored!" ), 1 ); 289 "Keep power off until power restored!" ), 1 );
291 } 290 }
292 291
293 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 292 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
294 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 293 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
295 } 294 }
296} 295}
297 296
298 297
299void DesktopApplication::sendCard() 298void DesktopApplication::sendCard()
300{ 299{
301 delete cardSendTimer; 300 delete cardSendTimer;
302 cardSendTimer = 0; 301 cardSendTimer = 0;
303 QString card = getenv("HOME"); 302 QString card = getenv("HOME");
304 card += "/Applications/addressbook/businesscard.vcf"; 303 card += "/Applications/addressbook/businesscard.vcf";
305 304
306 if ( QFile::exists( card ) ) { 305 if ( QFile::exists( card ) ) {
307 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 306 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
308 QString mimetype = "text/x-vCard"; 307 QString mimetype = "text/x-vCard";
309 e << tr("business card") << card << mimetype; 308 e << tr("business card") << card << mimetype;
310 } 309 }
311} 310}
312 311
313#if defined(QPE_HAVE_MEMALERTER) 312#if defined(QPE_HAVE_MEMALERTER)
314QPE_MEMALERTER_IMPL 313QPE_MEMALERTER_IMPL
315#endif 314#endif
316 315
317#if defined(CUSTOM_SOUND_IMPL) 316#if defined(CUSTOM_SOUND_IMPL)
318CUSTOM_SOUND_IMPL 317CUSTOM_SOUND_IMPL
319#endif 318#endif
320 319
321//=========================================================================== 320//===========================================================================
322 321
323Desktop::Desktop() : 322Desktop::Desktop() :
324 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 323 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
325 qcopBridge( 0 ), 324 qcopBridge( 0 ),
326 transferServer( 0 ), 325 transferServer( 0 ),
327 packageSlave( 0 ) 326 packageSlave( 0 )
328{ 327{
329#ifdef CUSTOM_SOUND_INIT 328#ifdef CUSTOM_SOUND_INIT
330 CUSTOM_SOUND_INIT; 329 CUSTOM_SOUND_INIT;
331#endif 330#endif
332 331
333 qpedesktop = this; 332 qpedesktop = this;
334 333
335// bg = new Info( this ); 334// bg = new Info( this );
336 tb = new TaskBar; 335 tb = new TaskBar;
337 336
338 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 337 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
339 338
340 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 339 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
341 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 340 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
342 341
343 int displayw = qApp->desktop()->width(); 342 int displayw = qApp->desktop()->width();
344 int displayh = qApp->desktop()->height(); 343 int displayh = qApp->desktop()->height();
345 344
346 345
347 QSize sz = tb->sizeHint(); 346 QSize sz = tb->sizeHint();
348 347
349 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 348 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
350 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 349 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
351 350
352 tb->show(); 351 tb->show();
353 launcher->showMaximized(); 352 launcher->showMaximized();
354 launcher->show(); 353 launcher->show();
355 launcher->raise(); 354 launcher->raise();
356#if defined(QPE_HAVE_MEMALERTER) 355#if defined(QPE_HAVE_MEMALERTER)
357 initMemalerter(); 356 initMemalerter();
358#endif 357#endif
359 // start services 358 // start services
360 startTransferServer(); 359 startTransferServer();
361 (void) new IrServer( this ); 360 (void) new IrServer( this );
362 rereadVolumes(); 361 rereadVolumes();
363 362
364 packageSlave = new PackageSlave( this ); 363 packageSlave = new PackageSlave( this );
365 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 364 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
366 365
367 qApp->installEventFilter( this ); 366 qApp->installEventFilter( this );
368} 367}
369 368
370void Desktop::show() 369void Desktop::show()
371{ 370{
372 login(TRUE); 371 login(TRUE);
373 QWidget::show(); 372 QWidget::show();
374} 373}
375 374
376Desktop::~Desktop() 375Desktop::~Desktop()
377{ 376{
378 delete launcher; 377 delete launcher;
379 delete tb; 378 delete tb;
380 delete qcopBridge; 379 delete qcopBridge;
381 delete transferServer; 380 delete transferServer;
382} 381}
383 382
384bool Desktop::recoverMemory() 383bool Desktop::recoverMemory()
385{ 384{
386 return tb->recoverMemory(); 385 return tb->recoverMemory();
387} 386}
388 387
389void Desktop::checkMemory() 388void Desktop::checkMemory()
390{ 389{
391#if defined(QPE_HAVE_MEMALERTER) 390#if defined(QPE_HAVE_MEMALERTER)
392 static bool ignoreNormal=FALSE; 391 static bool ignoreNormal=FALSE;
393 static bool existingMessage=FALSE; 392 static bool existingMessage=FALSE;
394 393
395 if(existingMessage) 394 if(existingMessage)
396 return; // don't show a second message while still on first 395 return; // don't show a second message while still on first
397 396
398 existingMessage = TRUE; 397 existingMessage = TRUE;
399 switch ( memstate ) { 398 switch ( memstate ) {
400 case Unknown: 399 case Unknown:
401 break; 400 break;
402 case Low: 401 case Low:
403 memstate = Unknown; 402 memstate = Unknown;
404 if ( recoverMemory() ) 403 if ( recoverMemory() )
405 ignoreNormal = TRUE; 404 ignoreNormal = TRUE;
406 else 405 else
407 QMessageBox::warning( 0 , "Memory Status", 406 QMessageBox::warning( 0 , "Memory Status",
408 "The memory smacks of shortage. \n" 407 "The memory smacks of shortage. \n"
409 "Please save data. " ); 408 "Please save data. " );
410 break; 409 break;
411 case Normal: 410 case Normal:
412 memstate = Unknown; 411 memstate = Unknown;
413 if ( ignoreNormal ) 412 if ( ignoreNormal )
414 ignoreNormal = FALSE; 413 ignoreNormal = FALSE;
415 else 414 else
416 QMessageBox::information ( 0 , "Memory Status", 415 QMessageBox::information ( 0 , "Memory Status",
417 "There is enough memory again." ); 416 "There is enough memory again." );
418 break; 417 break;
419 case VeryLow: 418 case VeryLow:
420 memstate = Unknown; 419 memstate = Unknown;
421 QMessageBox::critical( 0 , "Memory Status", 420 QMessageBox::critical( 0 , "Memory Status",
422 "The memory is very low. \n" 421 "The memory is very low. \n"
423 "Please end this application \n" 422 "Please end this application \n"
424 "immediately." ); 423 "immediately." );
425 recoverMemory(); 424 recoverMemory();
426 } 425 }
427 existingMessage = FALSE; 426 existingMessage = FALSE;
428#endif 427#endif
429} 428}
430 429
431static bool isVisibleWindow(int wid) 430static bool isVisibleWindow(int wid)
432{ 431{
433 const QList<QWSWindow> &list = qwsServer->clientWindows(); 432 const QList<QWSWindow> &list = qwsServer->clientWindows();
434 QWSWindow* w; 433 QWSWindow* w;
435 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 434 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
436 if ( w->winId() == wid ) 435 if ( w->winId() == wid )
437 return !w->isFullyObscured(); 436 return !w->isFullyObscured();
438 } 437 }
439 return FALSE; 438 return FALSE;
440} 439}
441 440
442static bool hasVisibleWindow(const QString& clientname) 441static bool hasVisibleWindow(const QString& clientname)
443{ 442{
444 const QList<QWSWindow> &list = qwsServer->clientWindows(); 443 const QList<QWSWindow> &list = qwsServer->clientWindows();
445 QWSWindow* w; 444 QWSWindow* w;
446 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 445 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
447 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 446 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
448 return TRUE; 447 return TRUE;
449 } 448 }
450 return FALSE; 449 return FALSE;
451} 450}
452 451
453void Desktop::raiseLauncher() 452void Desktop::raiseLauncher()
454{ 453{
455 if ( isVisibleWindow(launcher->winId()) ) 454 if ( isVisibleWindow(launcher->winId()) )
456 launcher->nextView(); 455 launcher->nextView();
457 else 456 else
458 launcher->raise(); 457 launcher->raise();
459} 458}
460 459
461void Desktop::executeOrModify(const QString& appLnkFile) 460void Desktop::executeOrModify(const QString& appLnkFile)
462{ 461{
463 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 462 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
464 if ( lnk.isValid() ) { 463 if ( lnk.isValid() ) {
465 QCString app = lnk.exec().utf8(); 464 QCString app = lnk.exec().utf8();
466 Global::terminateBuiltin("calibrate"); 465 Global::terminateBuiltin("calibrate");
467 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 466 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
468 MRUList::addTask(&lnk); 467 MRUList::addTask(&lnk);
469 if ( hasVisibleWindow(app) ) 468 if ( hasVisibleWindow(app) )
470 QCopChannel::send("QPE/Application/" + app, "nextView()"); 469 QCopChannel::send("QPE/Application/" + app, "nextView()");
471 else 470 else
472 QCopChannel::send("QPE/Application/" + app, "raise()"); 471 QCopChannel::send("QPE/Application/" + app, "raise()");
473 } else { 472 } else {
474 lnk.execute(); 473 lnk.execute();
475 } 474 }
476 } 475 }
477} 476}
478 477
479void Desktop::raiseDatebook() 478void Desktop::raiseDatebook()
480{ 479{
481 executeOrModify("Applications/datebook.desktop"); 480 executeOrModify("Applications/datebook.desktop");
482} 481}
483 482
484void Desktop::raiseContacts() 483void Desktop::raiseContacts()
485{ 484{
486 executeOrModify("Applications/addressbook.desktop"); 485 executeOrModify("Applications/addressbook.desktop");
487} 486}
488 487
489void Desktop::raiseMenu() 488void Desktop::raiseMenu()
490{ 489{
491 Global::terminateBuiltin("calibrate"); 490 Global::terminateBuiltin("calibrate");
492 tb->startMenu()->launch(); 491 tb->startMenu()->launch();
493} 492}
494 493
495void Desktop::raiseEmail() 494void Desktop::raiseEmail()
496{ 495{
497 executeOrModify("Applications/qtmail.desktop"); 496 executeOrModify("Applications/qtmail.desktop");
498} 497}
499 498
499// autoStarts apps on resume and start
500void Desktop::execAutoStart()
501{
502 QString appName;
503 Config cfg( "autostart" );
504 cfg.setGroup( "AutoStart" );
505 appName = cfg.readEntry("Apps", "");
506 QCopEnvelope e("QPE/System", "execute(QString)");
507 e << QString(appName);
508}
509
500#if defined(QPE_HAVE_TOGGLELIGHT) 510#if defined(QPE_HAVE_TOGGLELIGHT)
501#include <qpe/config.h> 511#include <qpe/config.h>
502 512
503#include <sys/ioctl.h> 513#include <sys/ioctl.h>
504#include <sys/types.h> 514#include <sys/types.h>
505#include <fcntl.h> 515#include <fcntl.h>
506#include <unistd.h> 516#include <unistd.h>
507#include <errno.h> 517#include <errno.h>
508#include <linux/ioctl.h> 518#include <linux/ioctl.h>
509#include <time.h> 519#include <time.h>
510#endif 520#endif
511 521
512static bool blanked=FALSE; 522static bool blanked=FALSE;
513 523
514static void blankScreen() 524static void blankScreen()
515{ 525{
516 if ( !qt_screen ) return; 526 if ( !qt_screen ) return;
517 /* Should use a big black window instead. 527 /* Should use a big black window instead.
518 QGfx* g = qt_screen->screenGfx(); 528 QGfx* g = qt_screen->screenGfx();
519 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 529 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
520 delete g; 530 delete g;
521 */ 531 */
522 blanked = TRUE; 532 blanked = TRUE;
523} 533}
524 534
525static void darkScreen() 535static void darkScreen()
526{ 536{
527 extern void qpe_setBacklight(int); 537 extern void qpe_setBacklight(int);
528 qpe_setBacklight(0); // force off 538 qpe_setBacklight(0); // force off
529} 539}
530 540
531 541
532void Desktop::togglePower() 542void Desktop::togglePower()
533{ 543{
534 bool wasloggedin = loggedin; 544 bool wasloggedin = loggedin;
535 loggedin=0; 545 loggedin=0;
536 darkScreen(); 546 darkScreen();
537 if ( wasloggedin ) 547 if ( wasloggedin )
538 blankScreen(); 548 blankScreen();
539 system("apm --suspend"); 549
540 QWSServer::screenSaverActivate( FALSE ); 550 system("apm --suspend");
541 { 551 execAutoStart();
542 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 552 QWSServer::screenSaverActivate( FALSE );
543 QCopEnvelope e("QPE/System", "setBacklight(int)"); 553 {
544 e << -3; // Force on 554 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
545 } 555 QCopEnvelope e("QPE/System", "setBacklight(int)");
546 if ( wasloggedin ) 556 e << -3; // Force on
547 login(TRUE); 557 }
548 //qcopBridge->closeOpenConnections(); 558 if ( wasloggedin ) {
549 //qDebug("called togglePower()!!!!!!"); 559 login(TRUE);
560 }
561
562 //qcopBridge->closeOpenConnections();
563 //qDebug("called togglePower()!!!!!!");
550} 564}
551 565
552void Desktop::toggleLight() 566void Desktop::toggleLight()
553{ 567{
554 QCopEnvelope e("QPE/System", "setBacklight(int)"); 568 QCopEnvelope e("QPE/System", "setBacklight(int)");
555 e << -2; // toggle 569 e << -2; // toggle
556} 570}
557 571
558void Desktop::toggleSymbolInput() 572void Desktop::toggleSymbolInput()
559{ 573{
560 tb->toggleSymbolInput(); 574 tb->toggleSymbolInput();
561} 575}
562 576
563void Desktop::toggleNumLockState() 577void Desktop::toggleNumLockState()
564{ 578{
565 tb->toggleNumLockState(); 579 tb->toggleNumLockState();
566} 580}
567 581
568void Desktop::toggleCapsLockState() 582void Desktop::toggleCapsLockState()
569{ 583{
570 tb->toggleCapsLockState(); 584 tb->toggleCapsLockState();
571} 585}
572 586
573void Desktop::styleChange( QStyle &s ) 587void Desktop::styleChange( QStyle &s )
574{ 588{
575 QWidget::styleChange( s ); 589 QWidget::styleChange( s );
576 int displayw = qApp->desktop()->width(); 590 int displayw = qApp->desktop()->width();
577 int displayh = qApp->desktop()->height(); 591 int displayh = qApp->desktop()->height();
578 592
579 QSize sz = tb->sizeHint(); 593 QSize sz = tb->sizeHint();
580 594
581 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 595 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
582} 596}
583 597
584void DesktopApplication::shutdown() 598void DesktopApplication::shutdown()
585{ 599{
586 if ( type() != GuiServer ) 600 if ( type() != GuiServer )
587 return; 601 return;
588 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 602 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
589 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 603 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
590 this, SLOT(shutdown(ShutdownImpl::Type)) ); 604 this, SLOT(shutdown(ShutdownImpl::Type)) );
591 sd->showMaximized(); 605 sd->showMaximized();
592} 606}
593 607
594void DesktopApplication::shutdown( ShutdownImpl::Type t ) 608void DesktopApplication::shutdown( ShutdownImpl::Type t )
595{ 609{
596 switch ( t ) { 610 switch ( t ) {
597 case ShutdownImpl::ShutdownSystem: 611 case ShutdownImpl::ShutdownSystem:
598 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 612 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
599 break; 613 break;
600 case ShutdownImpl::RebootSystem: 614 case ShutdownImpl::RebootSystem:
601 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 615 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
602 break; 616 break;
603 case ShutdownImpl::RestartDesktop: 617 case ShutdownImpl::RestartDesktop:
604 restart(); 618 restart();
605 break; 619 break;
606 case ShutdownImpl::TerminateDesktop: 620 case ShutdownImpl::TerminateDesktop:
607 prepareForTermination(FALSE); 621 prepareForTermination(FALSE);
608 quit(); 622 quit();
609 break; 623 break;
610 } 624 }
611} 625}
612 626
613void DesktopApplication::restart() 627void DesktopApplication::restart()
614{ 628{
615 prepareForTermination(TRUE); 629 prepareForTermination(TRUE);
616 630
617#ifdef Q_WS_QWS 631#ifdef Q_WS_QWS
618 for ( int fd = 3; fd < 100; fd++ ) 632 for ( int fd = 3; fd < 100; fd++ )
619 close( fd ); 633 close( fd );
620#if defined(QT_DEMO_SINGLE_FLOPPY) 634#if defined(QT_DEMO_SINGLE_FLOPPY)
621 execl( "/sbin/init", "qpe", 0 ); 635 execl( "/sbin/init", "qpe", 0 );
622#elif defined(QT_QWS_CASSIOPEIA) 636#elif defined(QT_QWS_CASSIOPEIA)
623 execl( "/bin/sh", "sh", 0 ); 637 execl( "/bin/sh", "sh", 0 );
624#else 638#else
625 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 639 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
626#endif 640#endif
627 exit(1); 641 exit(1);
628#endif 642#endif
629} 643}
630 644
631void Desktop::startTransferServer() 645void Desktop::startTransferServer()
632{ 646{
633 // start qcop bridge server 647 // start qcop bridge server
634 qcopBridge = new QCopBridge( 4243 ); 648 qcopBridge = new QCopBridge( 4243 );
635 if ( !qcopBridge->ok() ) { 649 if ( !qcopBridge->ok() ) {
636 delete qcopBridge; 650 delete qcopBridge;
637 qcopBridge = 0; 651 qcopBridge = 0;
638 } 652 }
639 // start transfer server 653 // start transfer server
640 transferServer = new TransferServer( 4242 ); 654 transferServer = new TransferServer( 4242 );
641 if ( !transferServer->ok() ) { 655 if ( !transferServer->ok() ) {
642 delete transferServer; 656 delete transferServer;
643 transferServer = 0; 657 transferServer = 0;
644 } 658 }
645 if ( !transferServer || !qcopBridge ) 659 if ( !transferServer || !qcopBridge )
646 startTimer( 2000 ); 660 startTimer( 2000 );
647} 661}
648 662
649void Desktop::timerEvent( QTimerEvent *e ) 663void Desktop::timerEvent( QTimerEvent *e )
650{ 664{
651 killTimer( e->timerId() ); 665 killTimer( e->timerId() );
652 startTransferServer(); 666 startTransferServer();
653} 667}
654 668
655void Desktop::terminateServers() 669void Desktop::terminateServers()
656{ 670{
657 delete transferServer; 671 delete transferServer;
658 delete qcopBridge; 672 delete qcopBridge;
659 transferServer = 0; 673 transferServer = 0;
660 qcopBridge = 0; 674 qcopBridge = 0;
661} 675}
662 676
663void Desktop::rereadVolumes() 677void Desktop::rereadVolumes()
664{ 678{
665 Config cfg("Sound"); 679 Config cfg("Sound");
666 cfg.setGroup("System"); 680 cfg.setGroup("System");
667 touchclick = cfg.readBoolEntry("Touch"); 681 touchclick = cfg.readBoolEntry("Touch");
668 keyclick = cfg.readBoolEntry("Key"); 682 keyclick = cfg.readBoolEntry("Key");
669} 683}
670 684
671void Desktop::keyClick() 685void Desktop::keyClick()
672{ 686{
673#ifdef CUSTOM_SOUND_KEYCLICK 687#ifdef CUSTOM_SOUND_KEYCLICK
674 if ( keyclick ) 688 if ( keyclick )
675 CUSTOM_SOUND_KEYCLICK; 689 CUSTOM_SOUND_KEYCLICK;
676#endif 690#endif
677} 691}
678 692
679void Desktop::screenClick() 693void Desktop::screenClick()
680{ 694{
681#ifdef CUSTOM_SOUND_TOUCH 695#ifdef CUSTOM_SOUND_TOUCH
682 if ( touchclick ) 696 if ( touchclick )
683 CUSTOM_SOUND_TOUCH; 697 CUSTOM_SOUND_TOUCH;
684#endif 698#endif
685} 699}
686 700
687void Desktop::soundAlarm() 701void Desktop::soundAlarm()
688{ 702{
689#ifdef CUSTOM_SOUND_ALARM 703#ifdef CUSTOM_SOUND_ALARM
690 CUSTOM_SOUND_ALARM; 704 CUSTOM_SOUND_ALARM;
691#endif 705#endif
692} 706}
693 707
694bool Desktop::eventFilter( QObject *w, QEvent *ev ) 708bool Desktop::eventFilter( QObject *w, QEvent *ev )
695{ 709{
696 if ( ev->type() == QEvent::KeyPress ) { 710 if ( ev->type() == QEvent::KeyPress ) {
697 QKeyEvent *ke = (QKeyEvent *)ev; 711 QKeyEvent *ke = (QKeyEvent *)ev;
698 if ( ke->key() == Qt::Key_F11 ) { // menu key 712 if ( ke->key() == Qt::Key_F11 ) { // menu key
699 QWidget *active = qApp->activeWindow(); 713 QWidget *active = qApp->activeWindow();
700 if ( active && active->isPopup() ) { 714 if ( active && active->isPopup() ) {
701 active->close(); 715 active->close();
702 } 716 }
703 raiseMenu(); 717 raiseMenu();
704 return TRUE; 718 return TRUE;
705 } 719 }
706 } 720 }
707 return FALSE; 721 return FALSE;
708} 722}
709 723
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index f0a7cba..de0dbf0 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -1,133 +1,134 @@
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: 66public slots:
67 void receive( const QCString &msg, const QByteArray &data ); 67 void receive( const QCString &msg, const QByteArray &data );
68 68
69protected slots: 69protected slots:
70 void shutdown(ShutdownImpl::Type); 70 void shutdown(ShutdownImpl::Type);
71 void psTimeout(); 71 void psTimeout();
72 void sendCard(); 72 void sendCard();
73private: 73private:
74 DesktopPowerAlerter *pa; 74 DesktopPowerAlerter *pa;
75 PowerStatus *ps; 75 PowerStatus *ps;
76 QTimer *cardSendTimer; 76 QTimer *cardSendTimer;
77 QCopChannel *channel; 77 QCopChannel *channel;
78}; 78};
79 79
80 80
81class Desktop : public QWidget { 81class Desktop : public QWidget {
82 Q_OBJECT 82 Q_OBJECT
83public: 83public:
84 Desktop(); 84 Desktop();
85 ~Desktop(); 85 ~Desktop();
86 86
87 static bool screenLocked(); 87 static bool screenLocked();
88 88
89 void show(); 89 void show();
90 void checkMemory(); 90 void checkMemory();
91 91
92 void keyClick(); 92 void keyClick();
93 void screenClick(); 93 void screenClick();
94 static void soundAlarm(); 94 static void soundAlarm();
95 95
96public slots: 96public slots:
97 void raiseDatebook(); 97 void raiseDatebook();
98 void raiseContacts(); 98 void raiseContacts();
99 void raiseMenu(); 99 void raiseMenu();
100 void raiseLauncher(); 100 void raiseLauncher();
101 void raiseEmail(); 101 void raiseEmail();
102 void execAutoStart();
102 void togglePower(); 103 void togglePower();
103 void toggleLight(); 104 void toggleLight();
104 void toggleNumLockState(); 105 void toggleNumLockState();
105 void toggleCapsLockState(); 106 void toggleCapsLockState();
106 void toggleSymbolInput(); 107 void toggleSymbolInput();
107 void terminateServers(); 108 void terminateServers();
108 void rereadVolumes(); 109 void rereadVolumes();
109 110
110protected: 111protected:
111 void executeOrModify(const QString& appLnkFile); 112 void executeOrModify(const QString& appLnkFile);
112 void styleChange( QStyle & ); 113 void styleChange( QStyle & );
113 void timerEvent( QTimerEvent *e ); 114 void timerEvent( QTimerEvent *e );
114 bool eventFilter( QObject *, QEvent * ); 115 bool eventFilter( QObject *, QEvent * );
115 116
116 QWidget *bg; 117 QWidget *bg;
117 Launcher *launcher; 118 Launcher *launcher;
118 TaskBar *tb; 119 TaskBar *tb;
119 120
120private: 121private:
121 void startTransferServer(); 122 void startTransferServer();
122 bool recoverMemory(); 123 bool recoverMemory();
123 124
124 QCopBridge *qcopBridge; 125 QCopBridge *qcopBridge;
125 TransferServer *transferServer; 126 TransferServer *transferServer;
126 PackageSlave *packageSlave; 127 PackageSlave *packageSlave;
127 128
128 bool keyclick,touchclick; 129 bool keyclick,touchclick;
129}; 130};
130 131
131 132
132#endif // __DESKTOP_H__ 133#endif // __DESKTOP_H__
133 134
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 66a2ce5..0573330 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,804 +1,840 @@
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// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class.
23#define QTOPIA_INTERNAL_FSLP
24
21#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
22#include <qpe/resource.h> 26#include <qpe/resource.h>
23#include <qpe/applnk.h> 27#include <qpe/applnk.h>
24#include <qpe/config.h> 28#include <qpe/config.h>
25#include <qpe/global.h> 29#include <qpe/global.h>
26#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
27#include <qpe/mimetype.h> 31#include <qpe/mimetype.h>
28#include <qpe/storage.h> 32#include <qpe/storage.h>
29#include <qpe/palmtoprecord.h> 33#include <qpe/palmtoprecord.h>
30 34
31#include <qdir.h> 35#include <qdir.h>
32#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
33#include <qtimer.h> 37#include <qtimer.h>
34#include <qcombobox.h> 38#include <qcombobox.h>
35#include <qvbox.h> 39#include <qvbox.h>
36#include <qlayout.h> 40#include <qlayout.h>
37#include <qstyle.h> 41#include <qstyle.h>
38#include <qpushbutton.h> 42#include <qpushbutton.h>
39#include <qtabbar.h> 43#include <qtabbar.h>
40#include <qwidgetstack.h> 44#include <qwidgetstack.h>
41#include <qlayout.h> 45#include <qlayout.h>
42#include <qregexp.h> 46#include <qregexp.h>
43#include <qmessagebox.h> 47#include <qmessagebox.h>
44#include <qframe.h> 48#include <qframe.h>
45#include <qpainter.h> 49#include <qpainter.h>
46#include <qlabel.h> 50#include <qlabel.h>
47#include <qtextstream.h> 51#include <qtextstream.h>
48 52
49#include "launcherview.h" 53#include "launcherview.h"
50#include "launcher.h" 54#include "launcher.h"
51#include "syncdialog.h" 55#include "syncdialog.h"
52#include "desktop.h" 56#include "desktop.h"
53#include <qpe/lnkproperties.h> 57#include <qpe/lnkproperties.h>
54#include "mrulist.h" 58#include "mrulist.h"
55#include "qrsync.h" 59#include "qrsync.h"
56#include <stdlib.h> 60#include <stdlib.h>
57#include <unistd.h> 61#include <unistd.h>
58 62
59#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 63#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
60#include <stdio.h> 64#include <stdio.h>
61#include <sys/vfs.h> 65#include <sys/vfs.h>
62#include <mntent.h> 66#include <mntent.h>
63#endif 67#endif
64 68
65//#define SHOW_ALL 69//#define SHOW_ALL
66 70
67CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 71CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
68 QVBox( parent ) 72 QVBox( parent )
69{ 73{
70 categoryBar = 0; 74 categoryBar = 0;
71 stack = 0; 75 stack = 0;
72} 76}
73 77
74void CategoryTabWidget::prevTab() 78void CategoryTabWidget::prevTab()
75{ 79{
76 if ( categoryBar ) { 80 if ( categoryBar ) {
77 int n = categoryBar->count(); 81 int n = categoryBar->count();
78 int tab = categoryBar->currentTab(); 82 int tab = categoryBar->currentTab();
79 if ( tab >= 0 ) 83 if ( tab >= 0 )
80 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 84 categoryBar->setCurrentTab( (tab - 1 + n)%n );
81 } 85 }
82} 86}
83 87
84void CategoryTabWidget::nextTab() 88void CategoryTabWidget::nextTab()
85{ 89{
86 if ( categoryBar ) { 90 if ( categoryBar ) {
87 int n = categoryBar->count(); 91 int n = categoryBar->count();
88 int tab = categoryBar->currentTab(); 92 int tab = categoryBar->currentTab();
89 categoryBar->setCurrentTab( (tab + 1)%n ); 93 categoryBar->setCurrentTab( (tab + 1)%n );
90 } 94 }
91} 95}
92 96
93void CategoryTabWidget::addItem( const QString& linkfile ) 97void CategoryTabWidget::addItem( const QString& linkfile )
94{ 98{
95 int i=0; 99 int i=0;
96 AppLnk *app = new AppLnk(linkfile); 100 AppLnk *app = new AppLnk(linkfile);
97 if ( !app->isValid() ) { 101 if ( !app->isValid() ) {
98 delete app; 102 delete app;
99 return; 103 return;
100 } 104 }
101 if ( !app->file().isEmpty() ) { 105 if ( !app->file().isEmpty() ) {
102 // A document 106 // A document
103 delete app; 107 delete app;
104 app = new DocLnk(linkfile); 108 app = new DocLnk(linkfile);
105 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 109 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
106 return; 110 return;
107 } 111 }
108 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 112 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
109 if ( !(*it).isEmpty() ) { 113 if ( !(*it).isEmpty() ) {
110 QRegExp tf(*it,FALSE,TRUE); 114 QRegExp tf(*it,FALSE,TRUE);
111 if ( tf.match(app->type()) >= 0 ) { 115 if ( tf.match(app->type()) >= 0 ) {
112 ((LauncherView*)stack->widget(i))->addItem(app); 116 ((LauncherView*)stack->widget(i))->addItem(app);
113 return; 117 return;
114 } 118 }
115 i++; 119 i++;
116 } 120 }
117 } 121 }
118} 122}
119 123
120void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, 124void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
121 AppLnkSet* docFolder, const QList<FileSystem> &fs) 125 AppLnkSet* docFolder, const QList<FileSystem> &fs)
122{ 126{
123 delete categoryBar; 127 delete categoryBar;
124 categoryBar = new CategoryTabBar( this ); 128 categoryBar = new CategoryTabBar( this );
125 QPalette pal = categoryBar->palette(); 129 QPalette pal = categoryBar->palette();
126 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 130 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
127 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 131 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
128 categoryBar->setPalette( pal ); 132 categoryBar->setPalette( pal );
129 133
130 delete stack; 134 delete stack;
131 stack = new QWidgetStack(this); 135 stack = new QWidgetStack(this);
132 tabs=0; 136 tabs=0;
133 137
134 ids.clear(); 138 ids.clear();
135 139
136 QStringList types = rootFolder->types(); 140 QStringList types = rootFolder->types();
137 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 141 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
138 if ( !(*it).isEmpty() ) { 142 if ( !(*it).isEmpty() ) {
139 newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); 143 newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it));
140 } 144 }
141 } 145 }
142 QListIterator<AppLnk> it( rootFolder->children() ); 146 QListIterator<AppLnk> it( rootFolder->children() );
143 AppLnk* l; 147 AppLnk* l;
144 while ( (l=it.current()) ) { 148 while ( (l=it.current()) ) {
145 if ( l->type() == "Separator" ) { 149 if ( l->type() == "Separator" ) {
146 rootFolder->remove(l); 150 rootFolder->remove(l);
147 delete l; 151 delete l;
148 } else { 152 } else {
149 int i=0; 153 int i=0;
150 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 154 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
151 if ( *it == l->type() ) 155 if ( *it == l->type() )
152 ((LauncherView*)stack->widget(i))->addItem(l,FALSE); 156 ((LauncherView*)stack->widget(i))->addItem(l,FALSE);
153 i++; 157 i++;
154 } 158 }
155 } 159 }
156 ++it; 160 ++it;
157 } 161 }
158 rootFolder->detachChildren(); 162 rootFolder->detachChildren();
159 for (int i=0; i<tabs; i++) 163 for (int i=0; i<tabs; i++)
160 ((LauncherView*)stack->widget(i))->sort(); 164 ((LauncherView*)stack->widget(i))->sort();
161 165
162 // all documents 166 // all documents
163 docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); 167 docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents"));
164 docview->populate( docFolder, QString::null ); 168 docview->populate( docFolder, QString::null );
165 docFolder->detachChildren(); 169 docFolder->detachChildren();
166 docview->setFileSystems(fs); 170 docview->setFileSystems(fs);
167 docview->setToolsEnabled(TRUE); 171 docview->setToolsEnabled(TRUE);
168 172
169 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); 173 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) );
170 174
171 ((LauncherView*)stack->widget(0))->setFocus(); 175 ((LauncherView*)stack->widget(0))->setFocus();
172 176
173 categoryBar->show(); 177 categoryBar->show();
174 stack->show(); 178 stack->show();
175} 179}
176 180
177void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) 181void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs)
178{ 182{
179 docview->populate( docFolder, QString::null ); 183 docview->populate( docFolder, QString::null );
180 docFolder->detachChildren(); 184 docFolder->detachChildren();
181 docview->setFileSystems(fs); 185 docview->setFileSystems(fs);
182 docview->updateTools(); 186 docview->updateTools();
183} 187}
184 188
185LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 189LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
186{ 190{
187 LauncherView* view = new LauncherView( stack ); 191 LauncherView* view = new LauncherView( stack );
188 connect( view, SIGNAL(clicked(const AppLnk*)), 192 connect( view, SIGNAL(clicked(const AppLnk*)),
189 this, SIGNAL(clicked(const AppLnk*))); 193 this, SIGNAL(clicked(const AppLnk*)));
190 connect( view, SIGNAL(rightPressed(AppLnk*)), 194 connect( view, SIGNAL(rightPressed(AppLnk*)),
191 this, SIGNAL(rightPressed(AppLnk*))); 195 this, SIGNAL(rightPressed(AppLnk*)));
192 ids.append(id); 196 ids.append(id);
193 categoryBar->addTab( new QTab( pm, label ) ); 197 categoryBar->addTab( new QTab( pm, label ) );
194 stack->addWidget( view, tabs++ ); 198 stack->addWidget( view, tabs++ );
195 return view; 199 return view;
196} 200}
197 201
198void CategoryTabWidget::updateLink(const QString& linkfile) 202void CategoryTabWidget::updateLink(const QString& linkfile)
199{ 203{
200 int i=0; 204 int i=0;
201 LauncherView* view; 205 LauncherView* view;
202 while ((view = (LauncherView*)stack->widget(i++))) { 206 while ((view = (LauncherView*)stack->widget(i++))) {
203 if ( view->removeLink(linkfile) ) 207 if ( view->removeLink(linkfile) )
204 break; 208 break;
205 } 209 }
206 addItem(linkfile); 210 addItem(linkfile);
207 docview->updateTools(); 211 docview->updateTools();
208} 212}
209 213
210void CategoryTabWidget::paletteChange( const QPalette &p ) 214void CategoryTabWidget::paletteChange( const QPalette &p )
211{ 215{
212 QVBox::paletteChange( p ); 216 QVBox::paletteChange( p );
213 QPalette pal = palette(); 217 QPalette pal = palette();
214 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 218 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
215 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 219 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
216 categoryBar->setPalette( pal ); 220 categoryBar->setPalette( pal );
217 categoryBar->update(); 221 categoryBar->update();
218} 222}
219 223
220void CategoryTabWidget::setBusy(bool on) 224void CategoryTabWidget::setBusy(bool on)
221{ 225{
222 if ( on ) 226 if ( on )
223 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); 227 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE);
224 else 228 else
225 for (int i=0; i<tabs; i++) 229 for (int i=0; i<tabs; i++)
226 ((LauncherView*)stack->widget(i))->setBusy(FALSE); 230 ((LauncherView*)stack->widget(i))->setBusy(FALSE);
227} 231}
228 232
229 233
230CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) 234CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
231 : QTabBar( parent, name ) 235 : QTabBar( parent, name )
232{ 236{
233 setFocusPolicy( NoFocus ); 237 setFocusPolicy( NoFocus );
234 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); 238 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) );
235} 239}
236 240
237CategoryTabBar::~CategoryTabBar() 241CategoryTabBar::~CategoryTabBar()
238{ 242{
239} 243}
240 244
241void CategoryTabBar::layoutTabs() 245void CategoryTabBar::layoutTabs()
242{ 246{
243 if ( !count() ) 247 if ( !count() )
244 return; 248 return;
245 249
246// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; 250// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 };
247 int hiddenTabWidth = -12; 251 int hiddenTabWidth = -12;
248 int middleTab = currentTab(); 252 int middleTab = currentTab();
249 int hframe, vframe, overlap; 253 int hframe, vframe, overlap;
250 style().tabbarMetrics( this, hframe, vframe, overlap ); 254 style().tabbarMetrics( this, hframe, vframe, overlap );
251 QFontMetrics fm = fontMetrics(); 255 QFontMetrics fm = fontMetrics();
252 int x = 0; 256 int x = 0;
253 QRect r; 257 QRect r;
254 QTab *t; 258 QTab *t;
255 int available = width()-1; 259 int available = width()-1;
256 int required = 0; 260 int required = 0;
257 for ( int i = 0; i < count(); i++ ) { 261 for ( int i = 0; i < count(); i++ ) {
258 t = tab(i); 262 t = tab(i);
259 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { 263 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) {
260 if ( i != middleTab ) { 264 if ( i != middleTab ) {
261 // required += hiddenTabWidth + hframe - overlap; 265 // required += hiddenTabWidth + hframe - overlap;
262 available -= hiddenTabWidth + hframe - overlap; 266 available -= hiddenTabWidth + hframe - overlap;
263 if ( t->iconSet() != 0 ) 267 if ( t->iconSet() != 0 )
264 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 268 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
265 } else { 269 } else {
266 required += fm.width( t->text() ) + hframe - overlap; 270 required += fm.width( t->text() ) + hframe - overlap;
267 if ( t->iconSet() != 0 ) 271 if ( t->iconSet() != 0 )
268 required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 272 required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
269 } 273 }
270 } 274 }
271 for ( int i = 0; i < count(); i++ ) { 275 for ( int i = 0; i < count(); i++ ) {
272 t = tab(i); 276 t = tab(i);
273 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { 277 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) {
274 if ( i != middleTab ) { 278 if ( i != middleTab ) {
275 int w = hiddenTabWidth; 279 int w = hiddenTabWidth;
276 int ih = 0; 280 int ih = 0;
277 if ( t->iconSet() != 0 ) { 281 if ( t->iconSet() != 0 ) {
278 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 282 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
279 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 283 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
280 } 284 }
281 int h = QMAX( fm.height(), ih ); 285 int h = QMAX( fm.height(), ih );
282 h = QMAX( h, QApplication::globalStrut().height() ); 286 h = QMAX( h, QApplication::globalStrut().height() );
283 287
284 h += vframe; 288 h += vframe;
285 w += hframe; 289 w += hframe;
286 290
287 t->setRect( QRect(x, 0, w, h) ); 291 t->setRect( QRect(x, 0, w, h) );
288 x += t->rect().width() - overlap; 292 x += t->rect().width() - overlap;
289 r = r.unite( t->rect() ); 293 r = r.unite( t->rect() );
290 } else { 294 } else {
291 int w = fm.width( t->text() ); 295 int w = fm.width( t->text() );
292 int ih = 0; 296 int ih = 0;
293 if ( t->iconSet() != 0 ) { 297 if ( t->iconSet() != 0 ) {
294 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 298 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
295 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 299 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
296 } 300 }
297 int h = QMAX( fm.height(), ih ); 301 int h = QMAX( fm.height(), ih );
298 h = QMAX( h, QApplication::globalStrut().height() ); 302 h = QMAX( h, QApplication::globalStrut().height() );
299 303
300 h += vframe; 304 h += vframe;
301 w += hframe; 305 w += hframe;
302 306
303 // t->setRect( QRect(x, 0, w * available/required, h) ); 307 // t->setRect( QRect(x, 0, w * available/required, h) );
304 t->setRect( QRect(x, 0, available, h) ); 308 t->setRect( QRect(x, 0, available, h) );
305 x += t->rect().width() - overlap; 309 x += t->rect().width() - overlap;
306 r = r.unite( t->rect() ); 310 r = r.unite( t->rect() );
307 } 311 }
308 } 312 }
309 313
310 QRect rr = tab(count()-1)->rect(); 314 QRect rr = tab(count()-1)->rect();
311 rr.setRight(width()-1); 315 rr.setRight(width()-1);
312 tab(count()-1)->setRect( rr ); 316 tab(count()-1)->setRect( rr );
313 317
314 for ( t = tabList()->first(); t; t = tabList()->next() ) { 318 for ( t = tabList()->first(); t; t = tabList()->next() ) {
315 QRect tr = t->rect(); 319 QRect tr = t->rect();
316 tr.setHeight( r.height() ); 320 tr.setHeight( r.height() );
317 t->setRect( tr ); 321 t->setRect( tr );
318 } 322 }
319 323
320 update(); 324 update();
321} 325}
322 326
323 327
324void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 328void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
325{ 329{
326#if QT_VERSION >= 300 330#if QT_VERSION >= 300
327 QStyle::SFlags flags = QStyle::Style_Default; 331 QStyle::SFlags flags = QStyle::Style_Default;
328 if ( selected ) 332 if ( selected )
329 flags |= QStyle::Style_Selected; 333 flags |= QStyle::Style_Selected;
330 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 334 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
331 colorGroup(), flags, QStyleOption(t) ); 335 colorGroup(), flags, QStyleOption(t) );
332#else 336#else
333 style().drawTab( p, this, t, selected ); 337 style().drawTab( p, this, t, selected );
334#endif 338#endif
335 339
336 QRect r( t->rect() ); 340 QRect r( t->rect() );
337 QFont f( font() ); 341 QFont f( font() );
338 if ( selected ) 342 if ( selected )
339 f.setBold( TRUE ); 343 f.setBold( TRUE );
340 p->setFont( f ); 344 p->setFont( f );
341 345
342 int iw = 0; 346 int iw = 0;
343 int ih = 0; 347 int ih = 0;
344 if ( t->iconSet() != 0 ) { 348 if ( t->iconSet() != 0 ) {
345 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 349 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
346 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 350 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
347 } 351 }
348 int w = iw + p->fontMetrics().width( t->text() ) + 4; 352 int w = iw + p->fontMetrics().width( t->text() ) + 4;
349 int h = QMAX(p->fontMetrics().height() + 4, ih ); 353 int h = QMAX(p->fontMetrics().height() + 4, ih );
350 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 354 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
351 r.top() + (r.height()-h)/2, w, h ), t, 355 r.top() + (r.height()-h)/2, w, h ), t,
352#if QT_VERSION >= 300 356#if QT_VERSION >= 300
353 t->identifier() == keyboardFocusTab() 357 t->identifier() == keyboardFocusTab()
354#else 358#else
355 t->identitifer() == keyboardFocusTab() 359 t->identitifer() == keyboardFocusTab()
356#endif 360#endif
357 ); 361 );
358} 362}
359 363
360 364
361void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 365void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
362 QTab* t, bool has_focus ) const 366 QTab* t, bool has_focus ) const
363{ 367{
364 QRect r = t->rect(); 368 QRect r = t->rect();
365 // if ( t->id != currentTab() ) 369 // if ( t->id != currentTab() )
366 //r.moveBy( 1, 1 ); 370 //r.moveBy( 1, 1 );
367 // 371 //
368 if ( t->iconSet() ) { 372 if ( t->iconSet() ) {
369 // the tab has an iconset, draw it in the right mode 373 // the tab has an iconset, draw it in the right mode
370 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 374 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
371 if ( mode == QIconSet::Normal && has_focus ) 375 if ( mode == QIconSet::Normal && has_focus )
372 mode = QIconSet::Active; 376 mode = QIconSet::Active;
373 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 377 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
374 int pixw = pixmap.width(); 378 int pixw = pixmap.width();
375 int pixh = pixmap.height(); 379 int pixh = pixmap.height();
376 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 380 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
377 r.setLeft( r.left() + pixw + 5 ); 381 r.setLeft( r.left() + pixw + 5 );
378 } 382 }
379 383
380 QRect tr = r; 384 QRect tr = r;
381 385
382 if ( r.width() < 20 ) 386 if ( r.width() < 20 )
383 return; 387 return;
384 388
385 if ( t->isEnabled() && isEnabled() ) { 389 if ( t->isEnabled() && isEnabled() ) {
386#if defined(_WS_WIN32_) 390#if defined(_WS_WIN32_)
387 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 391 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
388 p->setPen( colorGroup().buttonText() ); 392 p->setPen( colorGroup().buttonText() );
389 else 393 else
390 p->setPen( colorGroup().foreground() ); 394 p->setPen( colorGroup().foreground() );
391#else 395#else
392 p->setPen( colorGroup().foreground() ); 396 p->setPen( colorGroup().foreground() );
393#endif 397#endif
394 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 398 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
395 } else { 399 } else {
396 p->setPen( palette().disabled().foreground() ); 400 p->setPen( palette().disabled().foreground() );
397 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 401 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
398 } 402 }
399} 403}
400 404
401//--------------------------------------------------------------------------- 405//---------------------------------------------------------------------------
402 406
403Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 407Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
404 : QMainWindow( parent, name, fl ) 408 : QMainWindow( parent, name, fl )
405{ 409{
406 setCaption( tr("Launcher") ); 410 setCaption( tr("Launcher") );
407 411
408 syncDialog = 0; 412 syncDialog = 0;
409 413
410 // we have a pretty good idea how big we'll be 414 // we have a pretty good idea how big we'll be
411 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 415 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
412 416
413 tabs = 0; 417 tabs = 0;
414 rootFolder = 0; 418 rootFolder = 0;
415 docsFolder = 0; 419 docsFolder = 0;
416 420
417 tabs = new CategoryTabWidget( this ); 421 tabs = new CategoryTabWidget( this );
418 tabs->setMaximumWidth( qApp->desktop()->width() ); 422 tabs->setMaximumWidth( qApp->desktop()->width() );
419 setCentralWidget( tabs ); 423 setCentralWidget( tabs );
420 424
421 connect( tabs, SIGNAL(selected(const QString&)), 425 connect( tabs, SIGNAL(selected(const QString&)),
422 this, SLOT(viewSelected(const QString&)) ); 426 this, SLOT(viewSelected(const QString&)) );
423 connect( tabs, SIGNAL(clicked(const AppLnk*)), 427 connect( tabs, SIGNAL(clicked(const AppLnk*)),
424 this, SLOT(select(const AppLnk*))); 428 this, SLOT(select(const AppLnk*)));
425 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 429 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
426 this, SLOT(properties(AppLnk*))); 430 this, SLOT(properties(AppLnk*)));
427 431
428#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 432#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
429 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 433 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
430 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 434 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
431 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 435 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
432#endif 436#endif
433 437
434 storage = new StorageInfo( this ); 438 storage = new StorageInfo( this );
435 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 439 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
436 440
437 updateTabs(); 441 updateTabs();
438 442
439 preloadApps(); 443 preloadApps();
440 444
441 in_lnk_props = FALSE; 445 in_lnk_props = FALSE;
442 got_lnk_change = FALSE; 446 got_lnk_change = FALSE;
443} 447}
444 448
445Launcher::~Launcher() 449Launcher::~Launcher()
446{ 450{
447} 451}
448 452
449static bool isVisibleWindow(int wid) 453static bool isVisibleWindow(int wid)
450{ 454{
451 const QList<QWSWindow> &list = qwsServer->clientWindows(); 455 const QList<QWSWindow> &list = qwsServer->clientWindows();
452 QWSWindow* w; 456 QWSWindow* w;
453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 457 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
454 if ( w->winId() == wid ) 458 if ( w->winId() == wid )
455 return !w->isFullyObscured(); 459 return !w->isFullyObscured();
456 } 460 }
457 return FALSE; 461 return FALSE;
458} 462}
459 463
460void Launcher::showMaximized() 464void Launcher::showMaximized()
461{ 465{
462 if ( isVisibleWindow( winId() ) ) 466 if ( isVisibleWindow( winId() ) )
463 doMaximize(); 467 doMaximize();
464 else 468 else
465 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 469 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
466} 470}
467 471
468void Launcher::doMaximize() 472void Launcher::doMaximize()
469{ 473{
470 QMainWindow::showMaximized(); 474 QMainWindow::showMaximized();
471} 475}
472 476
473void Launcher::updateMimeTypes() 477void Launcher::updateMimeTypes()
474{ 478{
475 MimeType::clear(); 479 MimeType::clear();
476 updateMimeTypes(rootFolder); 480 updateMimeTypes(rootFolder);
477} 481}
478 482
479void Launcher::updateMimeTypes(AppLnkSet* folder) 483void Launcher::updateMimeTypes(AppLnkSet* folder)
480{ 484{
481 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 485 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
482 AppLnk *app = it.current(); 486 AppLnk *app = it.current();
483 if ( app->type() == "Folder" ) 487 if ( app->type() == "Folder" )
484 updateMimeTypes((AppLnkSet *)app); 488 updateMimeTypes((AppLnkSet *)app);
485 else { 489 else {
486 MimeType::registerApp(*app); 490 MimeType::registerApp(*app);
487 } 491 }
488 } 492 }
489} 493}
490 494
491void Launcher::loadDocs() 495void Launcher::loadDocs()
492{ 496{
493 delete docsFolder; 497 delete docsFolder;
494 docsFolder = new DocLnkSet; 498 docsFolder = new DocLnkSet;
495 Global::findDocuments(docsFolder); 499 Global::findDocuments(docsFolder);
496} 500}
497 501
498void Launcher::updateTabs() 502void Launcher::updateTabs()
499{ 503{
500 MimeType::updateApplications(); // ### reads all applnks twice 504 MimeType::updateApplications(); // ### reads all applnks twice
501 505
502 delete rootFolder; 506 delete rootFolder;
503 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 507 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
504 508
505 loadDocs(); 509 loadDocs();
506 510
507 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 511 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
508} 512}
509 513
510void Launcher::updateDocs() 514void Launcher::updateDocs()
511{ 515{
512 loadDocs(); 516 loadDocs();
513 tabs->updateDocs(docsFolder,storage->fileSystems()); 517 tabs->updateDocs(docsFolder,storage->fileSystems());
514} 518}
515 519
516void Launcher::viewSelected(const QString& s) 520void Launcher::viewSelected(const QString& s)
517{ 521{
518 setCaption( s + tr(" - Launcher") ); 522 setCaption( s + tr(" - Launcher") );
519} 523}
520 524
521void Launcher::nextView() 525void Launcher::nextView()
522{ 526{
523 tabs->nextTab(); 527 tabs->nextTab();
524} 528}
525 529
526 530
527void Launcher::select( const AppLnk *appLnk ) 531void Launcher::select( const AppLnk *appLnk )
528{ 532{
529 if ( appLnk->type() == "Folder" ) { 533 if ( appLnk->type() == "Folder" ) {
530 // Not supported: flat is simpler for the user 534 // Not supported: flat is simpler for the user
531 } else { 535 } else {
532 if ( appLnk->exec().isNull() ) { 536 if ( appLnk->exec().isNull() ) {
533 QMessageBox::information(this,tr("No application"), 537 QMessageBox::information(this,tr("No application"),
534 tr("<p>No application is defined for this document." 538 tr("<p>No application is defined for this document."
535 "<p>Type is %1.").arg(appLnk->type())); 539 "<p>Type is %1.").arg(appLnk->type()));
536 return; 540 return;
537 } 541 }
538 tabs->setBusy(TRUE); 542 tabs->setBusy(TRUE);
539 emit executing( appLnk ); 543 emit executing( appLnk );
540 appLnk->execute(); 544 appLnk->execute();
541 } 545 }
542} 546}
543 547
544void Launcher::externalSelected(const AppLnk *appLnk) 548void Launcher::externalSelected(const AppLnk *appLnk)
545{ 549{
546 tabs->setBusy(TRUE); 550 tabs->setBusy(TRUE);
547 emit executing( appLnk ); 551 emit executing( appLnk );
548} 552}
549 553
550void Launcher::properties( AppLnk *appLnk ) 554void Launcher::properties( AppLnk *appLnk )
551{ 555{
552 if ( appLnk->type() == "Folder" ) { 556 if ( appLnk->type() == "Folder" ) {
553 // Not supported: flat is simpler for the user 557 // Not supported: flat is simpler for the user
554 } else { 558 } else {
555 in_lnk_props = TRUE; 559 in_lnk_props = TRUE;
556 got_lnk_change = FALSE; 560 got_lnk_change = FALSE;
557 LnkProperties prop(appLnk); 561 LnkProperties prop(appLnk);
558 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 562 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
559 prop.showMaximized(); 563 prop.showMaximized();
560 prop.exec(); 564 prop.exec();
561 in_lnk_props = FALSE; 565 in_lnk_props = FALSE;
562 if ( got_lnk_change ) { 566 if ( got_lnk_change ) {
563 updateLink(lnk_change); 567 updateLink(lnk_change);
564 } 568 }
565 } 569 }
566} 570}
567 571
568void Launcher::updateLink(const QString& link) 572void Launcher::updateLink(const QString& link)
569{ 573{
570 if (link.isNull()) 574 if (link.isNull())
571 updateTabs(); 575 updateTabs();
572 else if (link.isEmpty()) 576 else if (link.isEmpty())
573 updateDocs(); 577 updateDocs();
574 else 578 else
575 tabs->updateLink(link); 579 tabs->updateLink(link);
576} 580}
577 581
578void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 582void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
579{ 583{
580 QDataStream stream( data, IO_ReadOnly ); 584 QDataStream stream( data, IO_ReadOnly );
581 if ( msg == "linkChanged(QString)" ) { 585 if ( msg == "linkChanged(QString)" ) {
582 QString link; 586 QString link;
583 stream >> link; 587 stream >> link;
584 if ( in_lnk_props ) { 588 if ( in_lnk_props ) {
585 got_lnk_change = TRUE; 589 got_lnk_change = TRUE;
586 lnk_change = link; 590 lnk_change = link;
587 } else { 591 } else {
588 updateLink(link); 592 updateLink(link);
589 } 593 }
590 } else if ( msg == "busy()" ) { 594 } else if ( msg == "busy()" ) {
591 emit busy(); 595 emit busy();
592 } else if ( msg == "notBusy(QString)" ) { 596 } else if ( msg == "notBusy(QString)" ) {
593 QString app; 597 QString app;
594 stream >> app; 598 stream >> app;
595 tabs->setBusy(FALSE); 599 tabs->setBusy(FALSE);
596 emit notBusy(app); 600 emit notBusy(app);
597 } else if ( msg == "mkdir(QString)" ) { 601 } else if ( msg == "mkdir(QString)" ) {
598 QString dir; 602 QString dir;
599 stream >> dir; 603 stream >> dir;
600 if ( !dir.isEmpty() ) 604 if ( !dir.isEmpty() )
601 mkdir( dir ); 605 mkdir( dir );
602 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 606 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
603 QString baseFile, sigFile; 607 QString baseFile, sigFile;
604 stream >> baseFile >> sigFile; 608 stream >> baseFile >> sigFile;
605 QRsync::generateSignature( baseFile, sigFile ); 609 QRsync::generateSignature( baseFile, sigFile );
606 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 610 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
607 QString baseFile, sigFile, deltaFile; 611 QString baseFile, sigFile, deltaFile;
608 stream >> baseFile >> sigFile >> deltaFile; 612 stream >> baseFile >> sigFile >> deltaFile;
609 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 613 QRsync::generateDiff( baseFile, sigFile, deltaFile );
610 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 614 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
611 QString baseFile, deltaFile; 615 QString baseFile, deltaFile;
612 stream >> baseFile >> deltaFile; 616 stream >> baseFile >> deltaFile;
613 if ( !QFile::exists( baseFile ) ) { 617 if ( !QFile::exists( baseFile ) ) {
614 QFile f( baseFile ); 618 QFile f( baseFile );
615 f.open( IO_WriteOnly ); 619 f.open( IO_WriteOnly );
616 f.close(); 620 f.close();
617 } 621 }
618 QRsync::applyDiff( baseFile, deltaFile ); 622 QRsync::applyDiff( baseFile, deltaFile );
619 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 623 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
620 e << baseFile; 624 e << baseFile;
621 } else if ( msg == "rdiffCleanup()" ) { 625 } else if ( msg == "rdiffCleanup()" ) {
622 mkdir( "/tmp/rdiff" ); 626 mkdir( "/tmp/rdiff" );
623 QDir dir; 627 QDir dir;
624 dir.setPath( "/tmp/rdiff" ); 628 dir.setPath( "/tmp/rdiff" );
625 QStringList entries = dir.entryList(); 629 QStringList entries = dir.entryList();
626 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 630 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
627 dir.remove( *it ); 631 dir.remove( *it );
628 } else if ( msg == "sendHandshakeInfo()" ) { 632 } else if ( msg == "sendHandshakeInfo()" ) {
629 QString home = getenv( "HOME" ); 633 QString home = getenv( "HOME" );
630 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 634 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
631 e << home; 635 e << home;
632 int locked = (int) Desktop::screenLocked(); 636 int locked = (int) Desktop::screenLocked();
633 e << locked; 637 e << locked;
638 // register an app for autostart
639 // if clear is send the list is cleared.
640 } else if ( msg == "autoStart(QString)" ) {
641 QString appName;
642 stream >> appName;
643 Config cfg( "autostart" );
644 cfg.setGroup( "AutoStart" );
645 if ( appName.compare("clear") == 0){
646 cfg.writeEntry("Apps", "");
647 }
648 } else if ( msg == "autoStart(QString,QString)" ) {
649 QString modifier, appName;
650 stream >> modifier >> appName;
651 Config cfg( "autostart" );
652 cfg.setGroup( "AutoStart" );
653 if ( modifier.compare("add") == 0 ){
654 // only add it appname is entered
655 if (!appName.isEmpty()) {
656 cfg.writeEntry("Apps", appName);
657 }
658 } else if (modifier.compare("remove") == 0 ) {
659 // need to change for multiple entries
660 // actually remove is right now simular to clear, but in future there
661 // should be multiple apps in autostart possible.
662 QString checkName;
663 checkName = cfg.readEntry("Apps", "");
664 if (checkName == appName) {
665 cfg.writeEntry("Apps", "");
666 }
667 }
634 } else if ( msg == "sendCardInfo()" ) { 668 } else if ( msg == "sendCardInfo()" ) {
635 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 669 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
636 const QList<FileSystem> &fs = storage->fileSystems(); 670 const QList<FileSystem> &fs = storage->fileSystems();
637 QListIterator<FileSystem> it ( fs ); 671 QListIterator<FileSystem> it ( fs );
638 QString s; 672 QString s;
639 QString homeDir = getenv("HOME"); 673 QString homeDir = getenv("HOME");
640 QString hardDiskHome; 674 QString hardDiskHome;
641 for ( ; it.current(); ++it ) { 675 for ( ; it.current(); ++it ) {
642 if ( (*it)->isRemovable() ) 676 if ( (*it)->isRemovable() )
643 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 677 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
644 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 678 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
645 + " " + (*it)->options() + ";"; 679 + " " + (*it)->options() + ";";
646 else if ( (*it)->disk() == "/dev/mtdblock1" || 680 else if ( (*it)->disk() == "/dev/mtdblock1" ||
647 (*it)->disk() == "/dev/mtdblock/1" ) 681 (*it)->disk() == "/dev/mtdblock/1" )
648 s += (*it)->name() + "=" + homeDir + "/Documents " 682 s += (*it)->name() + "=" + homeDir + "/Documents "
649 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 683 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
650 + " " + (*it)->options() + ";"; 684 + " " + (*it)->options() + ";";
651 else if ( (*it)->name().contains( "Hard Disk") && 685 else if ( (*it)->name().contains( "Hard Disk") &&
652 homeDir.contains( (*it)->path() ) && 686 homeDir.contains( (*it)->path() ) &&
653 (*it)->path().length() > hardDiskHome.length() ) 687 (*it)->path().length() > hardDiskHome.length() )
654 hardDiskHome = 688 hardDiskHome =
655 (*it)->name() + "=" + homeDir + "/Documents " 689 (*it)->name() + "=" + homeDir + "/Documents "
656 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 690 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
657 + " " + (*it)->options() + ";"; 691 + " " + (*it)->options() + ";";
658 } 692 }
659 if ( !hardDiskHome.isEmpty() ) 693 if ( !hardDiskHome.isEmpty() )
660 s += hardDiskHome; 694 s += hardDiskHome;
661 695
662 e << s; 696 e << s;
663 } else if ( msg == "sendSyncDate(QString)" ) { 697 } else if ( msg == "sendSyncDate(QString)" ) {
664 QString app; 698 QString app;
665 stream >> app; 699 stream >> app;
666 Config cfg( "qpe" ); 700 Config cfg( "qpe" );
667 cfg.setGroup("SyncDate"); 701 cfg.setGroup("SyncDate");
668 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 702 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
669 e << app << cfg.readEntry( app ); 703 e << app << cfg.readEntry( app );
670 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 704 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
671 //cfg.readEntry( app ).latin1() ); 705 //cfg.readEntry( app ).latin1() );
672 } else if ( msg == "setSyncDate(QString,QString)" ) { 706 } else if ( msg == "setSyncDate(QString,QString)" ) {
673 QString app, date; 707 QString app, date;
674 stream >> app >> date; 708 stream >> app >> date;
675 Config cfg( "qpe" ); 709 Config cfg( "qpe" );
676 cfg.setGroup("SyncDate"); 710 cfg.setGroup("SyncDate");
677 cfg.writeEntry( app, date ); 711 cfg.writeEntry( app, date );
678 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 712 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
679 } else if ( msg == "startSync(QString)" ) { 713 } else if ( msg == "startSync(QString)" ) {
680 QString what; 714 QString what;
681 stream >> what; 715 stream >> what;
682 delete syncDialog; syncDialog = 0; 716 delete syncDialog; syncDialog = 0;
683 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 717 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
684 WStyle_Tool | WStyle_Customize | 718 WStyle_Tool | WStyle_Customize |
685 Qt::WStyle_StaysOnTop ); 719 Qt::WStyle_StaysOnTop );
686 syncDialog->showMaximized(); 720 syncDialog->showMaximized();
687 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 721 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
688 connect( syncDialog->buttonCancel, SIGNAL( clicked() ), 722 connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
689 SLOT( cancelSync() ) ); 723 SLOT( cancelSync() ) );
690 } 724 }
691 else if ( msg == "stopSync()") { 725 else if ( msg == "stopSync()") {
692 delete syncDialog; syncDialog = 0; 726 delete syncDialog; syncDialog = 0;
693 } else if ( msg == "getAllDocLinks()" ) { 727 } else if ( msg == "getAllDocLinks()" ) {
694 loadDocs(); 728 loadDocs();
695 729
696 QString contents; 730 QString contents;
697 731
698 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 732 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
699 DocLnk *doc = it.current(); 733 DocLnk *doc = it.current();
700 QString lfn = doc->linkFile();
701 QFileInfo fi( doc->file() ); 734 QFileInfo fi( doc->file() );
702 if ( !fi.exists() ) 735 if ( !fi.exists() )
703 continue; 736 continue;
704 737
705 738 bool fake = !doc->linkFileKnown();
706 739 if ( !fake ) {
707 QFile f( lfn ); 740 QFile f( doc->linkFile() );
708 if ( f.open( IO_ReadOnly ) ) { 741 if ( f.open( IO_ReadOnly ) ) {
709 QTextStream ts( &f ); 742 QTextStream ts( &f );
710 ts.setEncoding( QTextStream::UnicodeUTF8 ); 743 ts.setEncoding( QTextStream::UnicodeUTF8 );
711 contents += ts.read(); 744 contents += ts.read();
712 f.close(); 745 f.close();
713 } else { 746 } else
747 fake = TRUE;
748 }
749 if (fake) {
714 contents += "[Desktop Entry]\n"; 750 contents += "[Desktop Entry]\n";
715 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; 751 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n";
716 contents += "File = "+doc->file()+"\n"; 752 contents += "File = "+doc->file()+"\n";
717 contents += "Name = "+doc->name()+"\n"; 753 contents += "Name = "+doc->name()+"\n";
718 contents += "Type = "+doc->type()+"\n"; 754 contents += "Type = "+doc->type()+"\n";
719 } 755 }
720 contents += QString("Size = %1\n").arg( fi.size() ); 756 contents += QString("Size = %1\n").arg( fi.size() );
721 } 757 }
722 758
723 //qDebug( "sending length %d", contents.length() ); 759 //qDebug( "sending length %d", contents.length() );
724 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 760 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
725 e << contents; 761 e << contents;
726 762
727 //qDebug( "================ \n\n%s\n\n===============", 763 //qDebug( "================ \n\n%s\n\n===============",
728 //contents.latin1() ); 764 //contents.latin1() );
729 765
730 delete docsFolder; 766 delete docsFolder;
731 docsFolder = 0; 767 docsFolder = 0;
732 } 768 }
733} 769}
734 770
735void Launcher::cancelSync() 771void Launcher::cancelSync()
736{ 772{
737 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 773 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
738} 774}
739 775
740void Launcher::storageChanged() 776void Launcher::storageChanged()
741{ 777{
742 if ( in_lnk_props ) { 778 if ( in_lnk_props ) {
743 got_lnk_change = TRUE; 779 got_lnk_change = TRUE;
744 lnk_change = ""; 780 lnk_change = "";
745 } else { 781 } else {
746 updateDocs(); 782 updateDocs();
747 } 783 }
748} 784}
749 785
750 786
751bool Launcher::mkdir(const QString &localPath) 787bool Launcher::mkdir(const QString &localPath)
752{ 788{
753 QDir fullDir(localPath); 789 QDir fullDir(localPath);
754 if (fullDir.exists()) 790 if (fullDir.exists())
755 return true; 791 return true;
756 792
757 // at this point the directory doesn't exist 793 // at this point the directory doesn't exist
758 // go through the directory tree and start creating the direcotories 794 // go through the directory tree and start creating the direcotories
759 // that don't exist; if we can't create the directories, return false 795 // that don't exist; if we can't create the directories, return false
760 796
761 QString dirSeps = "/"; 797 QString dirSeps = "/";
762 int dirIndex = localPath.find(dirSeps); 798 int dirIndex = localPath.find(dirSeps);
763 QString checkedPath; 799 QString checkedPath;
764 800
765 // didn't find any seps; weird, use the cur dir instead 801 // didn't find any seps; weird, use the cur dir instead
766 if (dirIndex == -1) { 802 if (dirIndex == -1) {
767 //qDebug("No seperators found in path %s", localPath.latin1()); 803 //qDebug("No seperators found in path %s", localPath.latin1());
768 checkedPath = QDir::currentDirPath(); 804 checkedPath = QDir::currentDirPath();
769 } 805 }
770 806
771 while (checkedPath != localPath) { 807 while (checkedPath != localPath) {
772 // no more seperators found, use the local path 808 // no more seperators found, use the local path
773 if (dirIndex == -1) 809 if (dirIndex == -1)
774 checkedPath = localPath; 810 checkedPath = localPath;
775 else { 811 else {
776 // the next directory to check 812 // the next directory to check
777 checkedPath = localPath.left(dirIndex) + "/"; 813 checkedPath = localPath.left(dirIndex) + "/";
778 // advance the iterator; the next dir seperator 814 // advance the iterator; the next dir seperator
779 dirIndex = localPath.find(dirSeps, dirIndex+1); 815 dirIndex = localPath.find(dirSeps, dirIndex+1);
780 } 816 }
781 817
782 QDir checkDir(checkedPath); 818 QDir checkDir(checkedPath);
783 if (!checkDir.exists()) { 819 if (!checkDir.exists()) {
784 //qDebug("mkdir making dir %s", checkedPath.latin1()); 820 //qDebug("mkdir making dir %s", checkedPath.latin1());
785 821
786 if (!checkDir.mkdir(checkedPath)) { 822 if (!checkDir.mkdir(checkedPath)) {
787 qDebug("Unable to make directory %s", checkedPath.latin1()); 823 qDebug("Unable to make directory %s", checkedPath.latin1());
788 return FALSE; 824 return FALSE;
789 } 825 }
790 } 826 }
791 827
792 } 828 }
793 return TRUE; 829 return TRUE;
794} 830}
795 831
796void Launcher::preloadApps() 832void Launcher::preloadApps()
797{ 833{
798 Config cfg("Launcher"); 834 Config cfg("Launcher");
799 cfg.setGroup("Preload"); 835 cfg.setGroup("Preload");
800 QStringList apps = cfg.readListEntry("Apps",','); 836 QStringList apps = cfg.readListEntry("Apps",',');
801 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 837 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
802 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 838 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
803 } 839 }
804} 840}