author | llornkcor <llornkcor> | 2004-10-08 10:22:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-10-08 10:22:20 (UTC) |
commit | 0e41f335c0db28250216a5292a2b7bcee2a1cf4a (patch) (unidiff) | |
tree | cac0c40b6e35117b199b45bf5674215ceeb9abd9 | |
parent | b2e0fd018e1122f65dbbf8ab564e992988f35385 (diff) | |
download | opie-0e41f335c0db28250216a5292a2b7bcee2a1cf4a.zip opie-0e41f335c0db28250216a5292a2b7bcee2a1cf4a.tar.gz opie-0e41f335c0db28250216a5292a2b7bcee2a1cf4a.tar.bz2 |
this patch will add support for QD installing directly to opie device via sync. not functioning until QD 1.7.1 released. should compile for now
-rw-r--r-- | core/launcher/applauncher.h | 9 | ||||
-rw-r--r-- | core/launcher/documentlist.cpp | 31 | ||||
-rw-r--r-- | core/launcher/packageslave.cpp | 14 | ||||
-rw-r--r-- | core/launcher/packageslave.h | 2 | ||||
-rw-r--r-- | core/launcher/qrr.cpp | 220 | ||||
-rw-r--r-- | core/launcher/qrr.h | 66 | ||||
-rw-r--r-- | core/launcher/server.cpp | 391 | ||||
-rw-r--r-- | core/launcher/server.h | 12 | ||||
-rw-r--r-- | core/launcher/server.pro | 5 | ||||
-rw-r--r-- | core/launcher/serverapp.cpp | 7 |
10 files changed, 657 insertions, 100 deletions
diff --git a/core/launcher/applauncher.h b/core/launcher/applauncher.h index 4fd5491..22a458f 100644 --- a/core/launcher/applauncher.h +++ b/core/launcher/applauncher.h | |||
@@ -1,82 +1,83 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 APP_LAUNCHER_H | 21 | #ifndef APP_LAUNCHER_H |
22 | #define APP_LAUNCHER_H | 22 | #define APP_LAUNCHER_H |
23 | 23 | ||
24 | #include <qtopia/global.h> | 24 | #include <qtopia/global.h> |
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qmap.h> | 26 | #include <qmap.h> |
27 | #ifdef Q_OS_WIN32 | 27 | #ifdef Q_OS_WIN32 |
28 | #include <qtopia/qprocess.h> | 28 | #include <qtopia/qprocess.h> |
29 | #include <qlist.h> | 29 | #include <qlist.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | class QMessageBox; | 32 | class QMessageBox; |
33 | 33 | ||
34 | class AppLauncher : public QObject | 34 | class AppLauncher : public QObject |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | AppLauncher(QObject *parent = 0, const char *name = 0); | 38 | AppLauncher(QObject *parent = 0, const char *name = 0); |
39 | ~AppLauncher(); | 39 | ~AppLauncher(); |
40 | 40 | ||
41 | bool isRunning(const QString &app); | 41 | bool isRunning(const QString &app); |
42 | const QMap<int,QString> &runningApplications() { return runningApps; } | ||
42 | 43 | ||
43 | static const int RAISE_TIMEOUT_MS; | 44 | static const int RAISE_TIMEOUT_MS; |
44 | 45 | ||
45 | signals: | 46 | signals: |
46 | void launched(int pid, const QString &app); | 47 | void launched(int pid, const QString &app); |
47 | void terminated(int pid, const QString &app); | 48 | void terminated(int pid, const QString &app); |
48 | void connected(const QString &app); | 49 | void connected(const QString &app); |
49 | 50 | ||
50 | protected slots: | 51 | protected slots: |
51 | void sigStopped(int sigPid, int sigStatus); | 52 | void sigStopped(int sigPid, int sigStatus); |
52 | void received(const QCString& msg, const QByteArray& data); | 53 | void received(const QCString& msg, const QByteArray& data); |
53 | void newQcopChannel(const QString& channel); | 54 | void newQcopChannel(const QString& channel); |
54 | void removedQcopChannel(const QString& channel); | 55 | void removedQcopChannel(const QString& channel); |
55 | void createQuickLauncher(); | 56 | void createQuickLauncher(); |
56 | void processExited(); | 57 | void processExited(); |
57 | 58 | ||
58 | protected: | 59 | protected: |
59 | bool event(QEvent *); | 60 | bool event(QEvent *); |
60 | void timerEvent( QTimerEvent * ); | 61 | void timerEvent( QTimerEvent * ); |
61 | 62 | ||
62 | private: | 63 | private: |
63 | static void signalHandler(int sig); | 64 | static void signalHandler(int sig); |
64 | bool executeBuiltin(const QString &c, const QString &document); | 65 | bool executeBuiltin(const QString &c, const QString &document); |
65 | bool execute(const QString &c, const QString &document, bool noRaise = FALSE); | 66 | bool execute(const QString &c, const QString &document, bool noRaise = FALSE); |
66 | void kill( int pid ); | 67 | void kill( int pid ); |
67 | int pidForName( const QString & ); | 68 | int pidForName( const QString & ); |
68 | 69 | ||
69 | private: | 70 | private: |
70 | QMap<int,QString> runningApps; | 71 | QMap<int,QString> runningApps; |
71 | QMap<QString,int> waitingHeartbeat; | 72 | QMap<QString,int> waitingHeartbeat; |
72 | #ifdef Q_OS_WIN32 | 73 | #ifdef Q_OS_WIN32 |
73 | QList<QProcess> runningAppsProc; | 74 | QList<QProcess> runningAppsProc; |
74 | #endif | 75 | #endif |
75 | int qlPid; | 76 | int qlPid; |
76 | bool qlReady; | 77 | bool qlReady; |
77 | QMessageBox *appKillerBox; | 78 | QMessageBox *appKillerBox; |
78 | QString appKillerName; | 79 | QString appKillerName; |
79 | }; | 80 | }; |
80 | 81 | ||
81 | #endif | 82 | #endif |
82 | 83 | ||
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 44ceb0c..d8e7a83 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -262,326 +262,337 @@ void DocumentList::reloadAppLnks() | |||
262 | } | 262 | } |
263 | 263 | ||
264 | if ( d->sendAppLnks && d->serverGui ) | 264 | if ( d->sendAppLnks && d->serverGui ) |
265 | d->serverGui->applicationScanningProgress( 100 ); | 265 | d->serverGui->applicationScanningProgress( 100 ); |
266 | } | 266 | } |
267 | 267 | ||
268 | void DocumentList::reloadDocLnks() | 268 | void DocumentList::reloadDocLnks() |
269 | { | 269 | { |
270 | if ( !d->scanDocs ) | 270 | if ( !d->scanDocs ) |
271 | return; | 271 | return; |
272 | 272 | ||
273 | if ( d->sendDocLnks && d->serverGui ) { | 273 | if ( d->sendDocLnks && d->serverGui ) { |
274 | d->serverGui->documentScanningProgress( 0 ); | 274 | d->serverGui->documentScanningProgress( 0 ); |
275 | d->serverGui->allDocumentsRemoved(); | 275 | d->serverGui->allDocumentsRemoved(); |
276 | } | 276 | } |
277 | 277 | ||
278 | rescan(); | 278 | rescan(); |
279 | } | 279 | } |
280 | 280 | ||
281 | void DocumentList::linkChanged( QString arg ) | 281 | void DocumentList::linkChanged( QString arg ) |
282 | { | 282 | { |
283 | //odebug << "linkchanged( " << arg << " )" << oendl; | 283 | //odebug << "linkchanged( " << arg << " )" << oendl; |
284 | 284 | ||
285 | if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { | 285 | if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { |
286 | reloadAppLnks(); | 286 | reloadAppLnks(); |
287 | } else { | 287 | } else { |
288 | 288 | ||
289 | const QList<DocLnk> &list = d->dls.children(); | 289 | const QList<DocLnk> &list = d->dls.children(); |
290 | QListIterator<DocLnk> it( list ); | 290 | QListIterator<DocLnk> it( list ); |
291 | while ( it.current() ) { | 291 | while ( it.current() ) { |
292 | DocLnk *doc = it.current(); | 292 | DocLnk *doc = it.current(); |
293 | ++it; | 293 | ++it; |
294 | if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) | 294 | if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) |
295 | || ( doc->fileKnown() && doc->file() == arg ) ) { | 295 | || ( doc->fileKnown() && doc->file() == arg ) ) { |
296 | //odebug << "found old link" << oendl; | 296 | //odebug << "found old link" << oendl; |
297 | DocLnk* dl = new DocLnk( arg ); | 297 | DocLnk* dl = new DocLnk( arg ); |
298 | // add new one if it exists and matches the mimetype | 298 | // add new one if it exists and matches the mimetype |
299 | if ( d->store( dl ) ) { | 299 | if ( d->store( dl ) ) { |
300 | // Existing link has been changed, send old link ref and a ref | 300 | // Existing link has been changed, send old link ref and a ref |
301 | // to the new link | 301 | // to the new link |
302 | //odebug << "change case" << oendl; | 302 | //odebug << "change case" << oendl; |
303 | if ( d->serverGui ) | 303 | if ( d->serverGui ) |
304 | d->serverGui->documentChanged( *doc, *dl ); | 304 | d->serverGui->documentChanged( *doc, *dl ); |
305 | 305 | ||
306 | } else { | 306 | } else { |
307 | // Link has been removed or doesn't match the mimetypes any more | 307 | // Link has been removed or doesn't match the mimetypes any more |
308 | // so we aren't interested in it, so take it away from the list | 308 | // so we aren't interested in it, so take it away from the list |
309 | //odebug << "removal case" << oendl; | 309 | //odebug << "removal case" << oendl; |
310 | if ( d->serverGui ) | 310 | if ( d->serverGui ) |
311 | d->serverGui->documentRemoved( *doc ); | 311 | d->serverGui->documentRemoved( *doc ); |
312 | 312 | ||
313 | } | 313 | } |
314 | d->dls.remove( doc ); // remove old link from docLnkSet | 314 | d->dls.remove( doc ); // remove old link from docLnkSet |
315 | delete doc; | 315 | delete doc; |
316 | return; | 316 | return; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | // Didn't find existing link, must be new | 319 | // Didn't find existing link, must be new |
320 | DocLnk* dl = new DocLnk( arg ); | 320 | DocLnk* dl = new DocLnk( arg ); |
321 | if ( d->store( dl ) ) { | 321 | if ( d->store( dl ) ) { |
322 | // Add if it's a link we are interested in | 322 | // Add if it's a link we are interested in |
323 | //odebug << "add case" << oendl; | 323 | //odebug << "add case" << oendl; |
324 | add( *dl ); | 324 | add( *dl ); |
325 | } | 325 | } |
326 | 326 | ||
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | void DocumentList::restoreDone() | 330 | void DocumentList::restoreDone() |
331 | { | 331 | { |
332 | reloadAppLnks(); | 332 | reloadAppLnks(); |
333 | reloadDocLnks(); | 333 | reloadDocLnks(); |
334 | } | 334 | } |
335 | 335 | ||
336 | void DocumentList::DiffAppLnks() | 336 | void DocumentList::DiffAppLnks() |
337 | { | 337 | { |
338 | static AppLnkSet *appLnkSet2; | 338 | static AppLnkSet *appLnkSet2; |
339 | 339 | ||
340 | appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); | 340 | appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); |
341 | 341 | ||
342 | if ( d->sendAppLnks && d->serverGui ) { | 342 | if ( d->sendAppLnks && d->serverGui ) { |
343 | static QStringList prevTypeList = appLnkSet->types(); | 343 | static QStringList prevTypeList = appLnkSet->types(); |
344 | QStringList types = appLnkSet2->types(); | 344 | QStringList types = appLnkSet2->types(); |
345 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { | 345 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { |
346 | if ( !(*ittypes).isEmpty() ) { | 346 | if ( !(*ittypes).isEmpty() ) { |
347 | if ( !prevTypeList.contains(*ittypes) ) { | 347 | if ( !prevTypeList.contains(*ittypes) ) { |
348 | QString name = appLnkSet2->typeName(*ittypes); | 348 | QString name = appLnkSet2->typeName(*ittypes); |
349 | QPixmap pm = appLnkSet2->typePixmap(*ittypes); | 349 | QPixmap pm = appLnkSet2->typePixmap(*ittypes); |
350 | QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); | 350 | QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); |
351 | 351 | ||
352 | if (pm.isNull()) { | 352 | if (pm.isNull()) { |
353 | QImage img( Resource::loadImage( "UnknownDocument" ) ); | 353 | QImage img( Resource::loadImage( "UnknownDocument" ) ); |
354 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 354 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
355 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); | 355 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); |
356 | } | 356 | } |
357 | 357 | ||
358 | odebug << "adding type " << (*ittypes) << "" << oendl; | 358 | odebug << "adding type " << (*ittypes) << "" << oendl; |
359 | 359 | ||
360 | // ### our current launcher expects docs tab to be last | 360 | // ### our current launcher expects docs tab to be last |
361 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); | 361 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); |
362 | } | 362 | } |
363 | prevTypeList.remove(*ittypes); | 363 | prevTypeList.remove(*ittypes); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { | 366 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { |
367 | odebug << "removing type " << (*ittypes) << "" << oendl; | 367 | odebug << "removing type " << (*ittypes) << "" << oendl; |
368 | d->serverGui->typeRemoved(*ittypes); | 368 | d->serverGui->typeRemoved(*ittypes); |
369 | } | 369 | } |
370 | prevTypeList = types; | 370 | prevTypeList = types; |
371 | } | 371 | } |
372 | 372 | ||
373 | 373 | ||
374 | QListIterator<AppLnk> it1( appLnkSet->children() ); | 374 | QListIterator<AppLnk> it1( appLnkSet->children() ); |
375 | QListIterator<AppLnk> it2( appLnkSet2->children() ); | 375 | QListIterator<AppLnk> it2( appLnkSet2->children() ); |
376 | 376 | ||
377 | AppLnk *i; | 377 | AppLnk *i; |
378 | AppLnk *j; | 378 | AppLnk *j; |
379 | bool found; | 379 | bool found; |
380 | 380 | ||
381 | while ( (j=it2.current()) ) { | 381 | while ( (j=it2.current()) ) { |
382 | it1 = appLnkSet->children(); | 382 | it1 = appLnkSet->children(); |
383 | found = false; | 383 | found = false; |
384 | while ( (i=it1.current()) ){ | 384 | while ( (i=it1.current()) ){ |
385 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) | 385 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) |
386 | found = true; | 386 | found = true; |
387 | ++it1; | 387 | ++it1; |
388 | } | 388 | } |
389 | if (!found) { | 389 | if (!found) { |
390 | odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; | 390 | odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; |
391 | d->serverGui->applicationAdded( j->type(), *j ); | 391 | d->serverGui->applicationAdded( j->type(), *j ); |
392 | } | 392 | } |
393 | ++it2; | 393 | ++it2; |
394 | } | 394 | } |
395 | 395 | ||
396 | it1 = appLnkSet->children(); | 396 | it1 = appLnkSet->children(); |
397 | while ( (i=it1.current()) ) { | 397 | while ( (i=it1.current()) ) { |
398 | it2 = appLnkSet2->children(); | 398 | it2 = appLnkSet2->children(); |
399 | found = false; | 399 | found = false; |
400 | while ( (j=it2.current()) ){ | 400 | while ( (j=it2.current()) ){ |
401 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) | 401 | if (strcmp(i->name().ascii(),j->name().ascii()) == 0) |
402 | found = true; | 402 | found = true; |
403 | ++it2; | 403 | ++it2; |
404 | } | 404 | } |
405 | if (!found) { | 405 | if (!found) { |
406 | odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; | 406 | odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; |
407 | d->serverGui->applicationRemoved( i->type(), *i ); | 407 | d->serverGui->applicationRemoved( i->type(), *i ); |
408 | } | 408 | } |
409 | 409 | ||
410 | ++it1; | 410 | ++it1; |
411 | } | 411 | } |
412 | 412 | ||
413 | delete appLnkSet; | 413 | delete appLnkSet; |
414 | appLnkSet = appLnkSet2; | 414 | appLnkSet = appLnkSet2; |
415 | 415 | ||
416 | } | 416 | } |
417 | void DocumentList::storageChanged() | 417 | void DocumentList::storageChanged() |
418 | { | 418 | { |
419 | QTime t; | 419 | QTime t; |
420 | // ### can implement better | 420 | // ### can implement better |
421 | 421 | ||
422 | t.start(); | 422 | t.start(); |
423 | DiffAppLnks(); | 423 | DiffAppLnks(); |
424 | // reloadAppLnks(); | 424 | // reloadAppLnks(); |
425 | odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; | 425 | odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; |
426 | reloadDocLnks(); | 426 | reloadDocLnks(); |
427 | // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; | 427 | // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; |
428 | odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; | 428 | odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; |
429 | // ### Optimization opportunity | 429 | // ### Optimization opportunity |
430 | // Could be a bit more intelligent and somehow work out which | 430 | // Could be a bit more intelligent and somehow work out which |
431 | // mtab entry has changed and then only scan that and add and remove | 431 | // mtab entry has changed and then only scan that and add and remove |
432 | // links appropriately. | 432 | // links appropriately. |
433 | // rescan(); | 433 | // rescan(); |
434 | } | 434 | } |
435 | 435 | ||
436 | void DocumentList::sendAllDocLinks() | 436 | void DocumentList::sendAllDocLinks() |
437 | { | 437 | { |
438 | if ( d->tid != 0 ) { | 438 | if ( d->tid != 0 ) { |
439 | // We are in the middle of scanning, set a flag so | 439 | // We are in the middle of scanning, set a flag so |
440 | // we do this when we finish our scanning | 440 | // we do this when we finish our scanning |
441 | d->needToSendAllDocLinks = true; | 441 | d->needToSendAllDocLinks = true; |
442 | return; | 442 | return; |
443 | } | 443 | } |
444 | 444 | ||
445 | QString contents; | 445 | QString contents; |
446 | Categories cats; | 446 | Categories cats; |
447 | for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { | 447 | for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { |
448 | DocLnk *doc = it.current(); | 448 | DocLnk *doc = it.current(); |
449 | QFileInfo fi( doc->file() ); | 449 | QFileInfo fi( doc->file() ); |
450 | if ( !fi.exists() ) | 450 | if ( !fi.exists() ) |
451 | continue; | 451 | continue; |
452 | 452 | ||
453 | bool fake = !doc->linkFileKnown(); | 453 | bool fake = !doc->linkFileKnown(); |
454 | if ( !fake ) { | 454 | if ( !fake ) { |
455 | QFile f( doc->linkFile() ); | 455 | QFile f( doc->linkFile() ); |
456 | if ( f.open( IO_ReadOnly ) ) { | 456 | if ( f.open( IO_ReadOnly ) ) { |
457 | QTextStream ts( &f ); | 457 | QTextStream ts( &f ); |
458 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 458 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
459 | contents += ts.read(); | 459 | QString docLnk = ts.read(); |
460 | // Strip out the (stale) LinkFile entry | ||
461 | int start = docLnk.find( "\nLinkFile = " ) + 1; | ||
462 | if ( start > 0 ) { | ||
463 | int end = docLnk.find( "\n", start + 1 ) + 1; | ||
464 | contents += docLnk.left(start); | ||
465 | contents += docLnk.mid(end); | ||
466 | } else { | ||
467 | contents += docLnk; | ||
468 | } | ||
469 | contents += "LinkFile = " + doc->linkFile() + "\n"; | ||
470 | |||
460 | f.close(); | 471 | f.close(); |
461 | } else | 472 | } else |
462 | fake = TRUE; | 473 | fake = TRUE; |
463 | } | 474 | } |
464 | if (fake) { | 475 | if (fake) { |
465 | contents += "[Desktop Entry]\n"; // No tr | 476 | contents += "[Desktop Entry]\n"; // No tr |
466 | contents += "Categories = " + // No tr | 477 | contents += "Categories = " + // No tr |
467 | cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 478 | cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
468 | contents += "Name = "+doc->name()+"\n"; // No tr | 479 | contents += "Name = "+doc->name()+"\n"; // No tr |
469 | contents += "Type = "+doc->type()+"\n"; // No tr | 480 | contents += "Type = "+doc->type()+"\n"; // No tr |
470 | } | 481 | } |
471 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 482 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
472 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 483 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
473 | } | 484 | } |
474 | 485 | ||
475 | //odebug << "sending length " << contents.length() << "" << oendl; | 486 | //odebug << "sending length " << contents.length() << "" << oendl; |
476 | #ifndef QT_NO_COP | 487 | #ifndef QT_NO_COP |
477 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 488 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
478 | e << contents; | 489 | e << contents; |
479 | #endif | 490 | #endif |
480 | //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; | 491 | //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; |
481 | 492 | ||
482 | d->needToSendAllDocLinks = false; | 493 | d->needToSendAllDocLinks = false; |
483 | } | 494 | } |
484 | 495 | ||
485 | 496 | ||
486 | 497 | ||
487 | 498 | ||
488 | 499 | ||
489 | 500 | ||
490 | 501 | ||
491 | 502 | ||
492 | 503 | ||
493 | 504 | ||
494 | 505 | ||
495 | 506 | ||
496 | 507 | ||
497 | 508 | ||
498 | 509 | ||
499 | 510 | ||
500 | 511 | ||
501 | 512 | ||
502 | 513 | ||
503 | 514 | ||
504 | 515 | ||
505 | 516 | ||
506 | 517 | ||
507 | 518 | ||
508 | DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) | 519 | DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) |
509 | { | 520 | { |
510 | storage = new StorageInfo( this ); | 521 | storage = new StorageInfo( this ); |
511 | serverGui = gui; | 522 | serverGui = gui; |
512 | if ( serverGui ) { | 523 | if ( serverGui ) { |
513 | sendAppLnks = serverGui->requiresApplications(); | 524 | sendAppLnks = serverGui->requiresApplications(); |
514 | sendDocLnks = serverGui->requiresDocuments(); | 525 | sendDocLnks = serverGui->requiresDocuments(); |
515 | } else { | 526 | } else { |
516 | sendAppLnks = false; | 527 | sendAppLnks = false; |
517 | sendDocLnks = false; | 528 | sendDocLnks = false; |
518 | } | 529 | } |
519 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { | 530 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { |
520 | listDirs[i] = 0; | 531 | listDirs[i] = 0; |
521 | lists[i] = 0; | 532 | lists[i] = 0; |
522 | listPositions[i] = 0; | 533 | listPositions[i] = 0; |
523 | } | 534 | } |
524 | initialize(); | 535 | initialize(); |
525 | tid = 0; | 536 | tid = 0; |
526 | } | 537 | } |
527 | 538 | ||
528 | void DocumentListPrivate::appendDocpath(FileSystem*fs) | 539 | void DocumentListPrivate::appendDocpath(FileSystem*fs) |
529 | { | 540 | { |
530 | QDir defPath(fs->path()+"/Documents"); | 541 | QDir defPath(fs->path()+"/Documents"); |
531 | QFileInfo f(fs->path()+"/.opiestorage.cf"); | 542 | QFileInfo f(fs->path()+"/.opiestorage.cf"); |
532 | if (!f.exists()) { | 543 | if (!f.exists()) { |
533 | Mediadlg dlg(fs); | 544 | Mediadlg dlg(fs); |
534 | if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { | 545 | if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { |
535 | return; | 546 | return; |
536 | } | 547 | } |
537 | } | 548 | } |
538 | Config conf(f.filePath(), Config::File ); | 549 | Config conf(f.filePath(), Config::File ); |
539 | conf.setGroup("main"); | 550 | conf.setGroup("main"); |
540 | if (!conf.readBoolEntry("check",false)) { | 551 | if (!conf.readBoolEntry("check",false)) { |
541 | return; | 552 | return; |
542 | } | 553 | } |
543 | conf.setGroup("subdirs"); | 554 | conf.setGroup("subdirs"); |
544 | bool read_all = conf.readBoolEntry("wholemedia",true); | 555 | bool read_all = conf.readBoolEntry("wholemedia",true); |
545 | if (read_all) { | 556 | if (read_all) { |
546 | docPaths+=fs->path(); | 557 | docPaths+=fs->path(); |
547 | return; | 558 | return; |
548 | } | 559 | } |
549 | QStringList subDirs = conf.readListEntry("subdirs",':'); | 560 | QStringList subDirs = conf.readListEntry("subdirs",':'); |
550 | if (subDirs.isEmpty()) { | 561 | if (subDirs.isEmpty()) { |
551 | if (defPath.exists()) { | 562 | if (defPath.exists()) { |
552 | docPaths+=defPath.path(); | 563 | docPaths+=defPath.path(); |
553 | } | 564 | } |
554 | return; | 565 | return; |
555 | } | 566 | } |
556 | for (unsigned c = 0; c < subDirs.count();++c) { | 567 | for (unsigned c = 0; c < subDirs.count();++c) { |
557 | QDir docDir(QString(fs->path()+"/"+subDirs[c])); | 568 | QDir docDir(QString(fs->path()+"/"+subDirs[c])); |
558 | if (docDir.exists()) { | 569 | if (docDir.exists()) { |
559 | docPaths+=docDir.path(); | 570 | docPaths+=docDir.path(); |
560 | } | 571 | } |
561 | } | 572 | } |
562 | } | 573 | } |
563 | 574 | ||
564 | void DocumentListPrivate::initialize() | 575 | void DocumentListPrivate::initialize() |
565 | { | 576 | { |
566 | // Reset | 577 | // Reset |
567 | dls.clear(); | 578 | dls.clear(); |
568 | docPaths.clear(); | 579 | docPaths.clear(); |
569 | reference.clear(); | 580 | reference.clear(); |
570 | 581 | ||
571 | QDir docDir( QPEApplication::documentDir() ); | 582 | QDir docDir( QPEApplication::documentDir() ); |
572 | if ( docDir.exists() ) | 583 | if ( docDir.exists() ) |
573 | docPaths += QPEApplication::documentDir(); | 584 | docPaths += QPEApplication::documentDir(); |
574 | int i = 1; | 585 | int i = 1; |
575 | const QList<FileSystem> &fs = storage->fileSystems(); | 586 | const QList<FileSystem> &fs = storage->fileSystems(); |
576 | QListIterator<FileSystem> it( fs ); | 587 | QListIterator<FileSystem> it( fs ); |
577 | for ( ; it.current(); ++it ) { | 588 | for ( ; it.current(); ++it ) { |
578 | if ( (*it)->isRemovable() ) { | 589 | if ( (*it)->isRemovable() ) { |
579 | appendDocpath((*it)); | 590 | appendDocpath((*it)); |
580 | ++i; | 591 | ++i; |
581 | } | 592 | } |
582 | } | 593 | } |
583 | 594 | ||
584 | for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { | 595 | for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { |
585 | if ( listDirs[i] ) { | 596 | if ( listDirs[i] ) { |
586 | delete listDirs[i]; | 597 | delete listDirs[i]; |
587 | listDirs[i] = 0; | 598 | listDirs[i] = 0; |
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index 0461432..abbc610 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp | |||
@@ -1,233 +1,243 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 "packageslave.h" | 21 | #include "packageslave.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <qtopia/qprocess.h> | 25 | #include <qtopia/qprocess.h> |
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #endif | 28 | #endif |
29 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
30 | 30 | ||
31 | /* QT */ | 31 | /* QT */ |
32 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
33 | #include <qcopchannel_qws.h> | 33 | #include <qcopchannel_qws.h> |
34 | #endif | 34 | #endif |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include <sys/stat.h> // mkdir() | 39 | #include <sys/stat.h> // mkdir() |
40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <sys/vfs.h> | 42 | #include <sys/vfs.h> |
43 | #include <mntent.h> | 43 | #include <mntent.h> |
44 | #elif defined(Q_OS_MACX) | 44 | #elif defined(Q_OS_MACX) |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | PackageHandler::PackageHandler( QObject *parent, char* name ) | 49 | PackageHandler::PackageHandler( QObject *parent, char* name ) |
50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) | 50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) |
51 | { | 51 | { |
52 | // setup qcop channel | 52 | // setup qcop channel |
53 | #ifndef QT_NO_COP | 53 | #ifndef QT_NO_COP |
54 | packageChannel = new QCopChannel( "QPE/Package", this ); | 54 | packageChannel = new QCopChannel( "QPE/Package", this ); |
55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
56 | this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) ); | 56 | this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) ); |
57 | #endif | 57 | #endif |
58 | } | 58 | } |
59 | 59 | ||
60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) | 60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) |
61 | { | 61 | { |
62 | QDataStream stream( data, IO_ReadOnly ); | 62 | QDataStream stream( data, IO_ReadOnly ); |
63 | 63 | ||
64 | if ( msg == "installPackage(QString)" ) { | 64 | if ( msg == "installPackage(QString)" ) { |
65 | QString file; | 65 | QString file; |
66 | stream >> file; | 66 | stream >> file; |
67 | installPackage( file ); | 67 | installPackage( file ); |
68 | } else if ( msg == "installPackage(QString,QString)" ) { | ||
69 | QString file, dest; | ||
70 | stream >> file >> dest; | ||
71 | installPackage( file, dest ); | ||
68 | } else if ( msg == "removePackage(QString)" ) { | 72 | } else if ( msg == "removePackage(QString)" ) { |
69 | QString file; | 73 | QString file; |
70 | stream >> file; | 74 | stream >> file; |
71 | removePackage( file ); | 75 | removePackage( file ); |
72 | } else if ( msg == "addPackageFiles(QString,QString)" ) { | 76 | } else if ( msg == "addPackageFiles(QString,QString)" ) { |
73 | QString location, listfile; | 77 | QString location, listfile; |
74 | stream >> location >> listfile; | 78 | stream >> location >> listfile; |
75 | addPackageFiles( location, listfile); | 79 | addPackageFiles( location, listfile); |
76 | } else if ( msg == "addPackages(QString)" ) { | 80 | } else if ( msg == "addPackages(QString)" ) { |
77 | QString location; | 81 | QString location; |
78 | stream >> location; | 82 | stream >> location; |
79 | addPackages( location ); | 83 | addPackages( location ); |
80 | } else if ( msg == "cleanupPackageFiles(QString)" ) { | 84 | } else if ( msg == "cleanupPackageFiles(QString)" ) { |
81 | QString listfile; | 85 | QString listfile; |
82 | stream >> listfile; | 86 | stream >> listfile; |
83 | cleanupPackageFiles( listfile ); | 87 | cleanupPackageFiles( listfile ); |
84 | } else if ( msg == "cleanupPackages(QString)" ) { | 88 | } else if ( msg == "cleanupPackages(QString)" ) { |
85 | QString location; | 89 | QString location; |
86 | stream >> location; | 90 | stream >> location; |
87 | cleanupPackages( location ); | 91 | cleanupPackages( location ); |
88 | } else if ( msg == "prepareInstall(QString,QString)" ) { | 92 | } else if ( msg == "prepareInstall(QString,QString)" ) { |
89 | QString size, path; | 93 | QString size, path; |
90 | stream >> size; | 94 | stream >> size; |
91 | stream >> path; | 95 | stream >> path; |
92 | prepareInstall( size, path ); | 96 | prepareInstall( size, path ); |
93 | } | 97 | } |
94 | } | 98 | } |
95 | 99 | ||
96 | void PackageHandler::installPackage( const QString &package ) | 100 | void PackageHandler::installPackage( const QString &package, const QString &dest ) |
97 | { | 101 | { |
98 | if ( mNoSpaceLeft ) { | 102 | if ( mNoSpaceLeft ) { |
99 | mNoSpaceLeft = FALSE; | 103 | mNoSpaceLeft = FALSE; |
100 | // Don't emit that for now, I still couldn't test it (Wener) | 104 | // Don't emit that for now, I still couldn't test it (Wener) |
101 | //sendReply( "installFailed(QString)", package ); | 105 | //sendReply( "installFailed(QString)", package ); |
102 | //return; | 106 | //return; |
103 | } | 107 | } |
104 | 108 | ||
105 | currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr | 109 | QStringList cmd; |
110 | cmd << "ipkg"; | ||
111 | if ( !dest.isEmpty() ) { | ||
112 | cmd << "-d" << dest; | ||
113 | } | ||
114 | cmd << "install" << package; | ||
115 | currentProcess = new QProcess( cmd ); // No tr | ||
106 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); | 116 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); |
107 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 117 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
108 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 118 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
109 | currentPackage = package; | 119 | currentPackage = package; |
110 | 120 | ||
111 | currentProcessError=""; | 121 | currentProcessError=""; |
112 | sendReply( "installStarted(QString)", package ); | 122 | sendReply( "installStarted(QString)", package ); |
113 | currentProcess->start(); | 123 | currentProcess->start(); |
114 | } | 124 | } |
115 | 125 | ||
116 | void PackageHandler::removePackage( const QString &package ) | 126 | void PackageHandler::removePackage( const QString &package ) |
117 | { | 127 | { |
118 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr | 128 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr |
119 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); | 129 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); |
120 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 130 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
121 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 131 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
122 | currentPackage = package; | 132 | currentPackage = package; |
123 | 133 | ||
124 | currentProcessError=""; | 134 | currentProcessError=""; |
125 | sendReply( "removeStarted(QString)", package ); | 135 | sendReply( "removeStarted(QString)", package ); |
126 | currentProcess->start(); | 136 | currentProcess->start(); |
127 | } | 137 | } |
128 | 138 | ||
129 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) | 139 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) |
130 | { | 140 | { |
131 | #ifndef QT_NO_COP | 141 | #ifndef QT_NO_COP |
132 | QCopEnvelope e( "QPE/Desktop", msg ); | 142 | QCopEnvelope e( "QPE/Desktop", msg ); |
133 | e << arg; | 143 | e << arg; |
134 | #endif | 144 | #endif |
135 | } | 145 | } |
136 | 146 | ||
137 | void PackageHandler::addPackageFiles( const QString &location, | 147 | void PackageHandler::addPackageFiles( const QString &location, |
138 | const QString &listfile ) | 148 | const QString &listfile ) |
139 | { | 149 | { |
140 | QFile f(listfile); | 150 | QFile f(listfile); |
141 | #ifndef Q_OS_WIN32 | 151 | #ifndef Q_OS_WIN32 |
142 | //make a copy so we can remove the symlinks later | 152 | //make a copy so we can remove the symlinks later |
143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); | 153 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); |
144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 154 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
145 | #else | 155 | #else |
146 | QDir d; | 156 | QDir d; |
147 | //#### revise | 157 | //#### revise |
148 | odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl; | 158 | odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl; |
149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); | 159 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); |
150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 160 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
151 | #endif | 161 | #endif |
152 | 162 | ||
153 | 163 | ||
154 | if ( f.open(IO_ReadOnly) ) { | 164 | if ( f.open(IO_ReadOnly) ) { |
155 | QTextStream ts(&f); | 165 | QTextStream ts(&f); |
156 | 166 | ||
157 | QString s; | 167 | QString s; |
158 | while ( !ts.eof() ) { // until end of file... | 168 | while ( !ts.eof() ) { // until end of file... |
159 | s = ts.readLine(); // line of text excluding '\n' | 169 | s = ts.readLine(); // line of text excluding '\n' |
160 | // for s, do link/mkdir. | 170 | // for s, do link/mkdir. |
161 | if ( s.right(1) == "/" ) { | 171 | if ( s.right(1) == "/" ) { |
162 | odebug << "do mkdir for " << s.ascii() << "" << oendl; | 172 | odebug << "do mkdir for " << s.ascii() << "" << oendl; |
163 | #ifndef Q_OS_WIN32 | 173 | #ifndef Q_OS_WIN32 |
164 | mkdir( s.ascii(), 0777 ); | 174 | mkdir( s.ascii(), 0777 ); |
165 | //possible optimization: symlink directories | 175 | //possible optimization: symlink directories |
166 | //that don't exist already. -- Risky. | 176 | //that don't exist already. -- Risky. |
167 | #else | 177 | #else |
168 | d.mkdir( s.ascii()); | 178 | d.mkdir( s.ascii()); |
169 | #endif | 179 | #endif |
170 | 180 | ||
171 | } else { | 181 | } else { |
172 | #ifndef Q_OS_WIN32 | 182 | #ifndef Q_OS_WIN32 |
173 | odebug << "do symlink for " << s.ascii() << "" << oendl; | 183 | odebug << "do symlink for " << s.ascii() << "" << oendl; |
174 | symlink( (location + s).ascii(), s.ascii() ); | 184 | symlink( (location + s).ascii(), s.ascii() ); |
175 | #else | 185 | #else |
176 | odebug << "Copy file instead of a symlink for WIN32" << oendl; | 186 | odebug << "Copy file instead of a symlink for WIN32" << oendl; |
177 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) | 187 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) |
178 | owarn << "Unable to create symlinkfor " << (location + s).ascii() << oendl; | 188 | owarn << "Unable to create symlinkfor " << (location + s).ascii() << oendl; |
179 | #endif | 189 | #endif |
180 | } | 190 | } |
181 | } | 191 | } |
182 | f.close(); | 192 | f.close(); |
183 | } | 193 | } |
184 | } | 194 | } |
185 | 195 | ||
186 | void PackageHandler::addPackages( const QString &location ) | 196 | void PackageHandler::addPackages( const QString &location ) |
187 | { | 197 | { |
188 | // get list of *.list in location/usr/lib/ipkg/info/*.list | 198 | // get list of *.list in location/usr/lib/ipkg/info/*.list |
189 | QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr | 199 | QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr |
190 | QDir::Name, QDir::Files); | 200 | QDir::Name, QDir::Files); |
191 | if ( !dir.exists() ) | 201 | if ( !dir.exists() ) |
192 | return; | 202 | return; |
193 | 203 | ||
194 | QStringList packages = dir.entryList(); | 204 | QStringList packages = dir.entryList(); |
195 | for ( QStringList::Iterator it = packages.begin(); | 205 | for ( QStringList::Iterator it = packages.begin(); |
196 | it != packages.end(); ++it ) { | 206 | it != packages.end(); ++it ) { |
197 | addPackageFiles( location, *it ); | 207 | addPackageFiles( location, *it ); |
198 | } | 208 | } |
199 | } | 209 | } |
200 | 210 | ||
201 | 211 | ||
202 | void PackageHandler::cleanupPackageFiles( const QString &listfile ) | 212 | void PackageHandler::cleanupPackageFiles( const QString &listfile ) |
203 | { | 213 | { |
204 | QFile f(listfile); | 214 | QFile f(listfile); |
205 | 215 | ||
206 | if ( f.open(IO_ReadOnly) ) { | 216 | if ( f.open(IO_ReadOnly) ) { |
207 | QTextStream ts(&f); | 217 | QTextStream ts(&f); |
208 | 218 | ||
209 | QString s; | 219 | QString s; |
210 | while ( !ts.eof() ) { // until end of file... | 220 | while ( !ts.eof() ) { // until end of file... |
211 | s = ts.readLine(); // line of text excluding '\n' | 221 | s = ts.readLine(); // line of text excluding '\n' |
212 | // for s, do link/mkdir. | 222 | // for s, do link/mkdir. |
213 | if ( s.right(1) == "/" ) { | 223 | if ( s.right(1) == "/" ) { |
214 | //should rmdir if empty, after all files have been removed | 224 | //should rmdir if empty, after all files have been removed |
215 | } else { | 225 | } else { |
216 | #ifndef Q_OS_WIN32 | 226 | #ifndef Q_OS_WIN32 |
217 | odebug << "remove symlink for " << s.ascii() << "" << oendl; | 227 | odebug << "remove symlink for " << s.ascii() << "" << oendl; |
218 | //check if it is a symlink first (don't remove /etc/passwd...) | 228 | //check if it is a symlink first (don't remove /etc/passwd...) |
219 | char buf[10]; //we don't care about the contents | 229 | char buf[10]; //we don't care about the contents |
220 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) | 230 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) |
221 | ::unlink( s.ascii() ); | 231 | ::unlink( s.ascii() ); |
222 | #else | 232 | #else |
223 | // ### revise | 233 | // ### revise |
224 | owarn << "Unable to remove symlink " << __FILE__ << ":" << __LINE__ << "" << oendl; | 234 | owarn << "Unable to remove symlink " << __FILE__ << ":" << __LINE__ << "" << oendl; |
225 | #endif | 235 | #endif |
226 | } | 236 | } |
227 | } | 237 | } |
228 | f.close(); | 238 | f.close(); |
229 | 239 | ||
230 | //remove the list file | 240 | //remove the list file |
231 | ::unlink( listfile.ascii() ); | 241 | ::unlink( listfile.ascii() ); |
232 | 242 | ||
233 | } | 243 | } |
diff --git a/core/launcher/packageslave.h b/core/launcher/packageslave.h index 878b4c3..83dfe6f 100644 --- a/core/launcher/packageslave.h +++ b/core/launcher/packageslave.h | |||
@@ -1,73 +1,73 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 __packageslave_h__ | 21 | #ifndef __packageslave_h__ |
22 | #define __packageslave_h__ | 22 | #define __packageslave_h__ |
23 | 23 | ||
24 | #include <qtopia/global.h> | 24 | #include <qtopia/global.h> |
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | 26 | ||
27 | class QCopChannel; | 27 | class QCopChannel; |
28 | class QProcess; | 28 | class QProcess; |
29 | 29 | ||
30 | class PackageHandler : public QObject | 30 | class PackageHandler : public QObject |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | 33 | ||
34 | public: | 34 | public: |
35 | PackageHandler( QObject *parent, char* name = 0 ); | 35 | PackageHandler( QObject *parent, char* name = 0 ); |
36 | 36 | ||
37 | public slots: | 37 | public slots: |
38 | void redoPackages(); | 38 | void redoPackages(); |
39 | 39 | ||
40 | protected: | 40 | protected: |
41 | void installPackage( const QString &package ); | 41 | void installPackage( const QString &package, const QString &dest = QString::null ); |
42 | void removePackage( const QString &package ); | 42 | void removePackage( const QString &package ); |
43 | 43 | ||
44 | void addPackageFiles( const QString &location, const QString &listfile ); | 44 | void addPackageFiles( const QString &location, const QString &listfile ); |
45 | void addPackages( const QString &location ); | 45 | void addPackages( const QString &location ); |
46 | 46 | ||
47 | void cleanupPackageFiles( const QString &listfile ); | 47 | void cleanupPackageFiles( const QString &listfile ); |
48 | void cleanupPackages( const QString &location ); | 48 | void cleanupPackages( const QString &location ); |
49 | 49 | ||
50 | void prepareInstall( const QString& size, const QString& path ); | 50 | void prepareInstall( const QString& size, const QString& path ); |
51 | 51 | ||
52 | protected slots: | 52 | protected slots: |
53 | void qcopMessage( const QCString &msg, const QByteArray &data ); | 53 | void qcopMessage( const QCString &msg, const QByteArray &data ); |
54 | void iProcessExited(); | 54 | void iProcessExited(); |
55 | void rmProcessExited(); | 55 | void rmProcessExited(); |
56 | void readyReadStdout(); | 56 | void readyReadStdout(); |
57 | void readyReadStderr(); | 57 | void readyReadStderr(); |
58 | 58 | ||
59 | private: | 59 | private: |
60 | void sendReply( const QCString& msg, const QString& arg ); | 60 | void sendReply( const QCString& msg, const QString& arg ); |
61 | 61 | ||
62 | private: | 62 | private: |
63 | QCopChannel *packageChannel; | 63 | QCopChannel *packageChannel; |
64 | QProcess *currentProcess; | 64 | QProcess *currentProcess; |
65 | QString currentPackage; | 65 | QString currentPackage; |
66 | QString currentProcessError; | 66 | QString currentProcessError; |
67 | bool mNoSpaceLeft; | 67 | bool mNoSpaceLeft; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | 70 | ||
71 | #endif // __QUICK_LAUNCHER_H__ | 71 | #endif // __QUICK_LAUNCHER_H__ |
72 | 72 | ||
73 | 73 | ||
diff --git a/core/launcher/qrr.cpp b/core/launcher/qrr.cpp new file mode 100644 index 0000000..5809ca9 --- a/dev/null +++ b/core/launcher/qrr.cpp | |||
@@ -0,0 +1,220 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "qrr.h" | ||
22 | |||
23 | #include <qtopia/qcopenvelope_qws.h> | ||
24 | #include <qfile.h> | ||
25 | #include <qtimer.h> | ||
26 | #include <qdialog.h> | ||
27 | #include <qlayout.h> | ||
28 | #include <qlabel.h> | ||
29 | #include <qprogressbar.h> | ||
30 | #include <qapplication.h> | ||
31 | #include <qevent.h> | ||
32 | |||
33 | |||
34 | class CenteringDialog : public QDialog | ||
35 | { | ||
36 | public: | ||
37 | CenteringDialog( QWidget *parent = 0, char *name = 0, bool modal = FALSE, WFlags f = 0 ); | ||
38 | virtual ~CenteringDialog(); | ||
39 | |||
40 | protected: | ||
41 | void resizeEvent( QResizeEvent *e ); | ||
42 | }; | ||
43 | |||
44 | CenteringDialog::CenteringDialog( QWidget *parent, char *name, bool modal, WFlags f ) | ||
45 | : QDialog( parent, name, modal, f ) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | CenteringDialog::~CenteringDialog() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | void CenteringDialog::resizeEvent( QResizeEvent *e ) | ||
54 | { | ||
55 | int dist = -((width() - e->oldSize().width()) / 2); | ||
56 | qDebug( "move %d", dist ); | ||
57 | move( pos().x() + dist, pos().y() ); | ||
58 | } | ||
59 | |||
60 | // ===================================================================== | ||
61 | |||
62 | QueuedRequestRunner::QueuedRequestRunner( QFile *f, QWidget *parent ) | ||
63 | : readyToDelete( FALSE ), waitingForMessages( FALSE ), file( 0 ) | ||
64 | { | ||
65 | file = f; | ||
66 | waitMsgs.setAutoDelete( TRUE ); | ||
67 | if ( parent ) { | ||
68 | progressDialog = new CenteringDialog( parent, 0, TRUE ); | ||
69 | QVBoxLayout *l = new QVBoxLayout( progressDialog ); | ||
70 | l->setMargin( 6 ); | ||
71 | l->setSpacing( 6 ); | ||
72 | progressLabel = new QLabel( progressDialog ); | ||
73 | progressLabel->setText( tr("Processing Queued Requests") ); | ||
74 | progressBar = new QProgressBar( progressDialog ); | ||
75 | l->addWidget( progressLabel ); | ||
76 | l->addWidget( progressBar ); | ||
77 | //progressDialog->setFixedSize( qApp->desktop()->width(), qApp->desktop()->height() ); | ||
78 | progressDialog->show(); | ||
79 | } | ||
80 | int totalSteps = countSteps(); | ||
81 | if ( parent ) { | ||
82 | qDebug( "%d steps", totalSteps ); | ||
83 | progressBar->setTotalSteps( totalSteps ); | ||
84 | progressBar->setProgress( 0 ); | ||
85 | } | ||
86 | file->open( IO_ReadOnly ); | ||
87 | } | ||
88 | |||
89 | QueuedRequestRunner::~QueuedRequestRunner() | ||
90 | { | ||
91 | delete progressDialog; | ||
92 | delete file; | ||
93 | } | ||
94 | |||
95 | void QueuedRequestRunner::process() | ||
96 | { | ||
97 | if ( process( FALSE ) ) { | ||
98 | if ( !waitingForMessages || action == "wait" ) | ||
99 | QTimer::singleShot( 100, this, SLOT(process()) ); | ||
100 | } else { | ||
101 | file->remove(); | ||
102 | emit finished(); | ||
103 | } | ||
104 | |||
105 | } | ||
106 | |||
107 | int QueuedRequestRunner::countSteps() | ||
108 | { | ||
109 | int totalSteps = 0; | ||
110 | bool more = TRUE; | ||
111 | file->open( IO_ReadOnly ); | ||
112 | while ( more ) { | ||
113 | steps = 0; | ||
114 | more = process( TRUE ); | ||
115 | totalSteps += steps; | ||
116 | } | ||
117 | file->close(); | ||
118 | waitingForMessages = FALSE; | ||
119 | return totalSteps; | ||
120 | } | ||
121 | |||
122 | bool QueuedRequestRunner::process( bool counting ) | ||
123 | { | ||
124 | QDataStream stream( file ); | ||
125 | stream >> action; | ||
126 | if ( action == "info" ) { | ||
127 | QString message; | ||
128 | stream >> message; | ||
129 | qDebug( "info %s", message.latin1() ); | ||
130 | if ( counting ) { | ||
131 | steps++; | ||
132 | } else { | ||
133 | progressLabel->setText( message ); | ||
134 | } | ||
135 | } else if ( action == "qcop" ) { | ||
136 | QCString channel; | ||
137 | QCString message; | ||
138 | int args; | ||
139 | stream >> channel >> message >> args; | ||
140 | qDebug( "qcop %s %s", channel.data(), message.data() ); | ||
141 | #ifndef QT_NO_COP | ||
142 | QCopEnvelope *e = 0; | ||
143 | if ( !counting ) { | ||
144 | e = new QCopEnvelope( channel, message ); | ||
145 | } | ||
146 | #endif | ||
147 | QCString type; | ||
148 | for ( int i = 0; i < args; ++i ) { | ||
149 | stream >> type; | ||
150 | if ( type == "QString" ) { | ||
151 | QString arg; | ||
152 | stream >> arg; | ||
153 | qDebug( " %s %s", type.data(), arg.latin1() ); | ||
154 | #ifndef QT_NO_COP | ||
155 | if ( !counting ) | ||
156 | (*e) << arg; | ||
157 | #endif | ||
158 | } else if ( type == "int" ) { | ||
159 | int arg; | ||
160 | stream >> arg; | ||
161 | qDebug( " %s %d", type.data(), arg ); | ||
162 | #ifndef QT_NO_COP | ||
163 | if ( !counting ) | ||
164 | (*e) << arg; | ||
165 | #endif | ||
166 | } else { | ||
167 | qDebug( "\tBUG unknown type '%s'!", type.data() ); | ||
168 | } | ||
169 | } | ||
170 | if ( counting ) { | ||
171 | steps++; | ||
172 | } else { | ||
173 | #ifndef QT_NO_COP | ||
174 | // this causes the QCop message to be sent | ||
175 | delete e; | ||
176 | #endif | ||
177 | } | ||
178 | } else if ( action == "wait" ) { | ||
179 | int messageCount; | ||
180 | QCString message; | ||
181 | waitMsgs.clear(); | ||
182 | stream >> messageCount; | ||
183 | for ( int i = 0; i < messageCount; ++i ) { | ||
184 | stream >> message; | ||
185 | qDebug( "wait %s", message.data() ); | ||
186 | if ( !counting ) { | ||
187 | waitMsgs.append( new QCString( message ) ); | ||
188 | } | ||
189 | } | ||
190 | if ( counting ) | ||
191 | steps++; | ||
192 | waitingForMessages = TRUE; | ||
193 | } else { | ||
194 | qDebug( "\tBUG unknown action '%s'!", action.data() ); | ||
195 | } | ||
196 | |||
197 | if ( !counting ) { | ||
198 | progressBar->setProgress( progressBar->progress() + 1 ); | ||
199 | } | ||
200 | |||
201 | return !file->atEnd(); | ||
202 | } | ||
203 | |||
204 | void QueuedRequestRunner::desktopMessage( const QCString &message, const QByteArray & ) | ||
205 | { | ||
206 | bool found = FALSE; | ||
207 | QCString *msg; | ||
208 | for ( QListIterator<QCString> iter( waitMsgs ); ( msg = iter.current() ) != 0; ++iter ) { | ||
209 | if ( *msg == message ) { | ||
210 | found = TRUE; | ||
211 | break; | ||
212 | } | ||
213 | } | ||
214 | if ( found ) { | ||
215 | waitMsgs.clear(); | ||
216 | waitingForMessages = FALSE; | ||
217 | QTimer::singleShot( 100, this, SLOT(process()) ); | ||
218 | } | ||
219 | } | ||
220 | |||
diff --git a/core/launcher/qrr.h b/core/launcher/qrr.h new file mode 100644 index 0000000..4c0a8db --- a/dev/null +++ b/core/launcher/qrr.h | |||
@@ -0,0 +1,66 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef QRR_H | ||
21 | #define QRR_H | ||
22 | |||
23 | #include <qobject.h> | ||
24 | #include <qlist.h> | ||
25 | #include <qcstring.h> | ||
26 | |||
27 | class QFile; | ||
28 | class QDialog; | ||
29 | class QLabel; | ||
30 | class QProgressBar; | ||
31 | class QWidget; | ||
32 | |||
33 | class QueuedRequestRunner : public QObject | ||
34 | { | ||
35 | Q_OBJECT | ||
36 | public: | ||
37 | QueuedRequestRunner( QFile *f, QWidget *parent ); | ||
38 | virtual ~QueuedRequestRunner(); | ||
39 | |||
40 | void desktopMessage( const QCString &message, const QByteArray &data ); | ||
41 | |||
42 | bool readyToDelete; | ||
43 | bool waitingForMessages; | ||
44 | |||
45 | signals: | ||
46 | void finished(); | ||
47 | |||
48 | public slots: | ||
49 | void process(); | ||
50 | |||
51 | private: | ||
52 | int countSteps(); | ||
53 | bool process( bool counting ); | ||
54 | |||
55 | QFile *file; | ||
56 | QList<QCString> waitMsgs; | ||
57 | QDialog *progressDialog; | ||
58 | QLabel *progressLabel; | ||
59 | QProgressBar *progressBar; | ||
60 | int steps; | ||
61 | QCString action; | ||
62 | }; | ||
63 | |||
64 | |||
65 | #endif // QRR_H | ||
66 | |||
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 3bef36e..524e6dd 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -1,750 +1,979 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 "server.h" | 21 | #include "server.h" |
22 | #include "serverapp.h" | 22 | #include "serverapp.h" |
23 | #include "startmenu.h" | 23 | #include "startmenu.h" |
24 | #include "launcher.h" | 24 | #include "launcher.h" |
25 | #include "transferserver.h" | 25 | #include "transferserver.h" |
26 | #include "qcopbridge.h" | 26 | #include "qcopbridge.h" |
27 | #include "irserver.h" | 27 | #include "irserver.h" |
28 | #include "packageslave.h" | 28 | #include "packageslave.h" |
29 | #include "calibrate.h" | 29 | #include "calibrate.h" |
30 | #include "qrsync.h" | 30 | #include "qrsync.h" |
31 | #include "syncdialog.h" | 31 | #include "syncdialog.h" |
32 | #include "shutdownimpl.h" | 32 | #include "shutdownimpl.h" |
33 | #include "applauncher.h" | 33 | #include "applauncher.h" |
34 | #if 0 | 34 | #if 0 |
35 | #include "suspendmonitor.h" | 35 | #include "suspendmonitor.h" |
36 | #endif | 36 | #endif |
37 | #include "documentlist.h" | 37 | #include "documentlist.h" |
38 | #include "qrr.h" | ||
38 | 39 | ||
39 | /* OPIE */ | 40 | /* OPIE */ |
40 | #include <opie2/odebug.h> | 41 | #include <opie2/odebug.h> |
41 | #include <opie2/odevicebutton.h> | 42 | #include <opie2/odevicebutton.h> |
42 | #include <opie2/odevice.h> | 43 | #include <opie2/odevice.h> |
43 | #include <qtopia/applnk.h> | 44 | #include <qtopia/applnk.h> |
44 | #include <qtopia/private/categories.h> | 45 | #include <qtopia/private/categories.h> |
45 | #include <qtopia/mimetype.h> | 46 | #include <qtopia/mimetype.h> |
46 | #include <qtopia/config.h> | 47 | #include <qtopia/config.h> |
47 | #include <qtopia/resource.h> | 48 | #include <qtopia/resource.h> |
48 | #include <qtopia/version.h> | 49 | #include <qtopia/version.h> |
49 | #include <qtopia/storage.h> | 50 | #include <qtopia/storage.h> |
50 | #include <qtopia/qcopenvelope_qws.h> | 51 | #include <qtopia/qcopenvelope_qws.h> |
51 | #include <qtopia/global.h> | 52 | #include <qtopia/global.h> |
52 | using namespace Opie::Core; | 53 | using namespace Opie::Core; |
53 | 54 | ||
54 | /* QT */ | 55 | /* QT */ |
55 | #include <qmainwindow.h> | 56 | #include <qmainwindow.h> |
56 | #include <qmessagebox.h> | 57 | #include <qmessagebox.h> |
57 | #include <qtimer.h> | 58 | #include <qtimer.h> |
58 | #include <qtextstream.h> | 59 | #include <qtextstream.h> |
59 | #include <qwindowsystem_qws.h> | 60 | #include <qwindowsystem_qws.h> |
60 | #include <qgfx_qws.h> | 61 | #include <qgfx_qws.h> |
61 | 62 | ||
62 | /* STD */ | 63 | /* STD */ |
63 | #include <unistd.h> | 64 | #include <unistd.h> |
64 | #include <stdlib.h> | 65 | #include <stdlib.h> |
65 | 66 | ||
66 | extern QRect qt_maxWindowRect; | 67 | extern QRect qt_maxWindowRect; |
67 | 68 | ||
68 | static QWidget *calibrate(bool) | 69 | static QWidget *calibrate(bool) |
69 | { | 70 | { |
70 | #ifdef Q_WS_QWS | 71 | #ifdef Q_WS_QWS |
71 | Calibrate *c = new Calibrate; | 72 | Calibrate *c = new Calibrate; |
72 | c->show(); | 73 | c->show(); |
73 | return c; | 74 | return c; |
74 | #else | 75 | #else |
75 | return 0; | 76 | return 0; |
76 | #endif | 77 | #endif |
77 | } | 78 | } |
78 | 79 | ||
79 | #define FACTORY(T) \ | 80 | #define FACTORY(T) \ |
80 | static QWidget *new##T( bool maximized ) { \ | 81 | static QWidget *new##T( bool maximized ) { \ |
81 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 82 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
82 | if ( maximized ) { \ | 83 | if ( maximized ) { \ |
83 | if ( qApp->desktop()->width() <= 350 ) { \ | 84 | if ( qApp->desktop()->width() <= 350 ) { \ |
84 | w->showMaximized(); \ | 85 | w->showMaximized(); \ |
85 | } else { \ | 86 | } else { \ |
86 | w->resize( QSize( 300, 300 ) ); \ | 87 | w->resize( QSize( 300, 300 ) ); \ |
87 | } \ | 88 | } \ |
88 | } \ | 89 | } \ |
89 | w->show(); \ | 90 | w->show(); \ |
90 | return w; \ | 91 | return w; \ |
91 | } | 92 | } |
92 | 93 | ||
93 | 94 | ||
94 | #ifdef SINGLE_APP | 95 | #ifdef SINGLE_APP |
95 | #define APP(a,b,c,d) FACTORY(b) | 96 | #define APP(a,b,c,d) FACTORY(b) |
96 | #include "apps.h" | 97 | #include "apps.h" |
97 | #undef APP | 98 | #undef APP |
98 | #endif // SINGLE_APP | 99 | #endif // SINGLE_APP |
99 | 100 | ||
100 | static Global::Command builtins[] = { | 101 | static Global::Command builtins[] = { |
101 | 102 | ||
102 | #ifdef SINGLE_APP | 103 | #ifdef SINGLE_APP |
103 | #define APP(a,b,c,d) { a, new##b, c, d }, | 104 | #define APP(a,b,c,d) { a, new##b, c, d }, |
104 | #include "apps.h" | 105 | #include "apps.h" |
105 | #undef APP | 106 | #undef APP |
106 | #endif | 107 | #endif |
107 | 108 | ||
108 | /* FIXME defines need to be defined*/ | 109 | /* FIXME defines need to be defined*/ |
109 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) | 110 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) |
110 | { "calibrate", calibrate, 1, 0 }, // No tr | 111 | { "calibrate", calibrate, 1, 0 }, // No tr |
111 | #endif | 112 | #endif |
112 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) | 113 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) |
113 | { "shutdown", Global::shutdown, 1, 0 }, // No tr | 114 | { "shutdown", Global::shutdown, 1, 0 }, // No tr |
114 | // { "run", run, 1, 0 }, // No tr | 115 | // { "run", run, 1, 0 }, // No tr |
115 | #endif | 116 | #endif |
116 | 117 | ||
117 | { 0, calibrate, 0, 0 }, | 118 | { 0, calibrate, 0, 0 }, |
118 | }; | 119 | }; |
119 | 120 | ||
121 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
122 | extern void readyDirectAccess(QString cardInfo, QString installLocations); | ||
123 | extern const char *directAccessQueueFile(); | ||
124 | #endif | ||
120 | 125 | ||
121 | //--------------------------------------------------------------------------- | 126 | //--------------------------------------------------------------------------- |
122 | 127 | ||
123 | 128 | ||
124 | //=========================================================================== | 129 | //=========================================================================== |
125 | 130 | ||
126 | Server::Server() : | 131 | Server::Server() : |
127 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 132 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
128 | qcopBridge( 0 ), | 133 | qcopBridge( 0 ), |
129 | transferServer( 0 ), | 134 | transferServer( 0 ), |
130 | packageHandler( 0 ), | 135 | packageHandler( 0 ), |
131 | syncDialog( 0 ) | 136 | syncDialog( 0 ) |
132 | { | 137 | { |
133 | Global::setBuiltinCommands(builtins); | 138 | Global::setBuiltinCommands(builtins); |
134 | 139 | ||
135 | tid_xfer = 0; | 140 | tid_xfer = 0; |
136 | /* ### FIXME ### */ | 141 | /* ### FIXME ### */ |
137 | /* tid_today = startTimer(3600*2*1000);*/ | 142 | /* tid_today = startTimer(3600*2*1000);*/ |
138 | last_today_show = QDate::currentDate(); | 143 | last_today_show = QDate::currentDate(); |
139 | 144 | ||
145 | #warning FIXME support TempScreenSaverMode | ||
140 | #if 0 | 146 | #if 0 |
141 | tsmMonitor = new TempScreenSaverMode(); | 147 | tsmMonitor = new TempScreenSaverMode(); |
142 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); | 148 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); |
143 | #endif | 149 | #endif |
144 | 150 | ||
145 | serverGui = new Launcher; | 151 | serverGui = new Launcher; |
146 | serverGui->createGUI(); | 152 | serverGui->createGUI(); |
147 | 153 | ||
148 | docList = new DocumentList( serverGui ); | 154 | docList = new DocumentList( serverGui ); |
149 | appLauncher = new AppLauncher(this); | 155 | appLauncher = new AppLauncher(this); |
150 | connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); | 156 | connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); |
151 | connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); | 157 | connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); |
152 | connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); | 158 | connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); |
153 | 159 | ||
154 | storage = new StorageInfo( this ); | 160 | storage = new StorageInfo( this ); |
155 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); | 161 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); |
156 | 162 | ||
163 | |||
164 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
165 | QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); | ||
166 | connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), | ||
167 | this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); | ||
168 | #endif | ||
169 | |||
157 | // start services | 170 | // start services |
158 | startTransferServer(); | 171 | startTransferServer(); |
159 | (void) new IrServer( this ); | 172 | (void) new IrServer( this ); |
160 | 173 | ||
161 | packageHandler = new PackageHandler( this ); | 174 | packageHandler = new PackageHandler( this ); |
162 | connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), | 175 | connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), |
163 | this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); | 176 | this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); |
164 | 177 | ||
165 | setGeometry( -10, -10, 9, 9 ); | 178 | setGeometry( -10, -10, 9, 9 ); |
166 | 179 | ||
167 | QCopChannel *channel = new QCopChannel("QPE/System", this); | 180 | QCopChannel *channel = new QCopChannel("QPE/System", this); |
168 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | 181 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
169 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); | 182 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); |
170 | 183 | ||
171 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); | 184 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); |
172 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 185 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
173 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); | 186 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); |
174 | 187 | ||
175 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); | 188 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); |
176 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); | 189 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); |
177 | 190 | ||
178 | preloadApps(); | 191 | preloadApps(); |
179 | } | 192 | } |
180 | 193 | ||
181 | void Server::show() | 194 | void Server::show() |
182 | { | 195 | { |
183 | ServerApplication::login(TRUE); | 196 | ServerApplication::login(TRUE); |
184 | QWidget::show(); | 197 | QWidget::show(); |
185 | } | 198 | } |
186 | 199 | ||
187 | Server::~Server() | 200 | Server::~Server() |
188 | { | 201 | { |
189 | serverGui->destroyGUI(); | 202 | serverGui->destroyGUI(); |
190 | delete docList; | 203 | delete docList; |
191 | delete qcopBridge; | 204 | delete qcopBridge; |
192 | delete transferServer; | 205 | delete transferServer; |
193 | delete serverGui; | 206 | delete serverGui; |
194 | #if 0 | 207 | #if 0 |
195 | delete tsmMonitor; | 208 | delete tsmMonitor; |
196 | #endif | 209 | #endif |
197 | } | 210 | } |
198 | 211 | ||
199 | 212 | ||
213 | static bool hasVisibleWindow(const QString& clientname, bool partial) | ||
214 | { | ||
215 | #ifdef QWS | ||
216 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | ||
217 | QWSWindow* w; | ||
218 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | ||
219 | if ( w->client()->identity() == clientname ) { | ||
220 | if ( partial && !w->isFullyObscured() ) | ||
221 | return TRUE; | ||
222 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | ||
223 | # if QT_VERSION < 0x030000 | ||
224 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | ||
225 | QSize(qt_screen->width(),qt_screen->height()) ); | ||
226 | # else | ||
227 | QRect mwr = qt_maxWindowRect; | ||
228 | # endif | ||
229 | if ( mwr.contains(w->requested().boundingRect()) ) | ||
230 | return TRUE; | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | #endif | ||
235 | return FALSE; | ||
236 | } | ||
237 | |||
200 | void Server::activate(const ODeviceButton* button, bool held) | 238 | void Server::activate(const ODeviceButton* button, bool held) |
201 | { | 239 | { |
202 | Global::terminateBuiltin("calibrate"); // No tr | 240 | Global::terminateBuiltin("calibrate"); // No tr |
203 | OQCopMessage om; | 241 | OQCopMessage om; |
204 | if ( held ) { | 242 | if ( held ) { |
205 | om = button->heldAction(); | 243 | om = button->heldAction(); |
206 | } else { | 244 | } else { |
207 | om = button->pressedAction(); | 245 | om = button->pressedAction(); |
208 | } | 246 | } |
209 | 247 | ||
210 | if ( om.channel() != "ignore" ) | 248 | if ( om.channel() != "ignore" ) |
211 | om.send(); | 249 | om.send(); |
212 | 250 | ||
213 | // A button with no action defined, will return a null ServiceRequest. Don't attempt | 251 | // A button with no action defined, will return a null ServiceRequest. Don't attempt |
214 | // to send/do anything with this as it will crash | 252 | // to send/do anything with this as it will crash |
215 | /* ### FIXME */ | 253 | /* ### FIXME */ |
216 | #if 0 | 254 | #if 0 |
217 | if ( !sr.isNull() ) { | 255 | if ( !sr.isNull() ) { |
218 | QString app = sr.app(); | 256 | QString app = sr.app(); |
219 | bool vis = hasVisibleWindow(app, app != "qpe"); | 257 | bool vis = hasVisibleWindow(app, app != "qpe"); |
220 | if ( sr.message() == "raise()" && vis ) { | 258 | if ( sr.message() == "raise()" && vis ) { |
221 | sr.setMessage("nextView()"); | 259 | sr.setMessage("nextView()"); |
222 | } else { | 260 | } else { |
223 | // "back door" | 261 | // "back door" |
224 | sr << (int)vis; | 262 | sr << (int)vis; |
225 | } | 263 | } |
226 | 264 | ||
227 | sr.send(); | 265 | sr.send(); |
228 | } | 266 | } |
229 | #endif | 267 | #endif |
230 | } | 268 | } |
231 | 269 | ||
232 | 270 | ||
233 | #ifdef Q_WS_QWS | 271 | #ifdef Q_WS_QWS |
234 | 272 | ||
235 | typedef struct KeyOverride { | 273 | typedef struct KeyOverride { |
236 | ushort scan_code; | 274 | ushort scan_code; |
237 | QWSServer::KeyMap map; | 275 | QWSServer::KeyMap map; |
238 | }; | 276 | }; |
239 | 277 | ||
240 | 278 | ||
241 | static const KeyOverride jp109keys[] = { | 279 | static const KeyOverride jp109keys[] = { |
242 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, | 280 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, |
243 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, | 281 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, |
244 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, | 282 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, |
245 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, | 283 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, |
246 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, | 284 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, |
247 | { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } }, | 285 | { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } }, |
248 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, | 286 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, |
249 | { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } }, | 287 | { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } }, |
250 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, | 288 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, |
251 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } }, | 289 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } }, |
252 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, | 290 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, |
253 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, | 291 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, |
254 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } }, | 292 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } }, |
255 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, | 293 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, |
256 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } }, | 294 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } }, |
257 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, | 295 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, |
258 | { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } }, | 296 | { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } }, |
259 | { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, | 297 | { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, |
260 | { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, | 298 | { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, |
261 | { 0x00, { 0, 0xffff, 0xffff, 0xffff } } | 299 | { 0x00, { 0, 0xffff, 0xffff, 0xffff } } |
262 | }; | 300 | }; |
263 | 301 | ||
264 | bool Server::setKeyboardLayout( const QString &kb ) | 302 | bool Server::setKeyboardLayout( const QString &kb ) |
265 | { | 303 | { |
266 | //quick demo version that can be extended | 304 | //quick demo version that can be extended |
267 | 305 | ||
268 | QIntDict<QWSServer::KeyMap> *om = 0; | 306 | QIntDict<QWSServer::KeyMap> *om = 0; |
269 | if ( kb == "us101" ) { // No tr | 307 | if ( kb == "us101" ) { // No tr |
270 | om = 0; | 308 | om = 0; |
271 | } else if ( kb == "jp109" ) { | 309 | } else if ( kb == "jp109" ) { |
272 | om = new QIntDict<QWSServer::KeyMap>(37); | 310 | om = new QIntDict<QWSServer::KeyMap>(37); |
273 | const KeyOverride *k = jp109keys; | 311 | const KeyOverride *k = jp109keys; |
274 | while ( k->scan_code ) { | 312 | while ( k->scan_code ) { |
275 | om->insert( k->scan_code, &k->map ); | 313 | om->insert( k->scan_code, &k->map ); |
276 | k++; | 314 | k++; |
277 | } | 315 | } |
278 | } | 316 | } |
279 | QWSServer::setOverrideKeys( om ); | 317 | QWSServer::setOverrideKeys( om ); |
280 | 318 | ||
281 | return TRUE; | 319 | return TRUE; |
282 | } | 320 | } |
283 | #endif | 321 | #endif |
284 | 322 | ||
285 | void Server::systemMsg(const QCString &msg, const QByteArray &data) | 323 | void Server::systemMsg(const QCString &msg, const QByteArray &data) |
286 | { | 324 | { |
287 | QDataStream stream( data, IO_ReadOnly ); | 325 | QDataStream stream( data, IO_ReadOnly ); |
288 | 326 | ||
289 | if ( msg == "securityChanged()" ) { | 327 | if ( msg == "securityChanged()" ) { |
290 | if ( transferServer ) | 328 | if ( transferServer ) |
291 | transferServer->authorizeConnections(); | 329 | transferServer->authorizeConnections(); |
292 | 330 | ||
293 | if ( qcopBridge ) | 331 | if ( qcopBridge ) |
294 | qcopBridge->authorizeConnections(); | 332 | qcopBridge->authorizeConnections(); |
295 | } else | 333 | #warning FIXME support TempScreenSaverMode |
296 | |||
297 | #if 0 | 334 | #if 0 |
298 | /* ### FIXME support TempScreenSaverMode */ | 335 | } else if ( msg == "setTempScreenSaverMode(int,int)" ) { |
299 | if ( msg == "setTempScreenSaverMode(int,int)" ) { | ||
300 | int mode, pid; | 336 | int mode, pid; |
301 | stream >> mode >> pid; | 337 | stream >> mode >> pid; |
302 | tsmMonitor->setTempMode(mode, pid); | 338 | tsmMonitor->setTempMode(mode, pid); |
303 | } else | ||
304 | #endif | 339 | #endif |
305 | 340 | } else if ( msg == "linkChanged(QString)" ) { | |
306 | if ( msg == "linkChanged(QString)" ) { | ||
307 | QString link; | 341 | QString link; |
308 | stream >> link; | 342 | stream >> link; |
309 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; | 343 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; |
310 | docList->linkChanged(link); | 344 | docList->linkChanged(link); |
311 | } else | 345 | } else if ( msg == "serviceChanged(QString)" ) { |
312 | |||
313 | if ( msg == "serviceChanged(QString)" ) { | ||
314 | MimeType::updateApplications(); | 346 | MimeType::updateApplications(); |
315 | } else | 347 | } else if ( msg == "mkdir(QString)" ) { |
316 | |||
317 | if ( msg == "mkdir(QString)" ) { | ||
318 | QString dir; | 348 | QString dir; |
319 | stream >> dir; | 349 | stream >> dir; |
320 | if ( !dir.isEmpty() ) | 350 | if ( !dir.isEmpty() ) |
321 | mkdir( dir ); | 351 | mkdir( dir ); |
322 | } else | 352 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
323 | |||
324 | if ( msg == "rdiffGenSig(QString,QString)" ) { | ||
325 | QString baseFile, sigFile; | 353 | QString baseFile, sigFile; |
326 | stream >> baseFile >> sigFile; | 354 | stream >> baseFile >> sigFile; |
327 | QRsync::generateSignature( baseFile, sigFile ); | 355 | QRsync::generateSignature( baseFile, sigFile ); |
328 | } else | 356 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
329 | |||
330 | if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | ||
331 | QString baseFile, sigFile, deltaFile; | 357 | QString baseFile, sigFile, deltaFile; |
332 | stream >> baseFile >> sigFile >> deltaFile; | 358 | stream >> baseFile >> sigFile >> deltaFile; |
333 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 359 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
334 | } else | 360 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
335 | |||
336 | if ( msg == "rdiffApplyPatch(QString,QString)" ) { | ||
337 | QString baseFile, deltaFile; | 361 | QString baseFile, deltaFile; |
338 | stream >> baseFile >> deltaFile; | 362 | stream >> baseFile >> deltaFile; |
339 | if ( !QFile::exists( baseFile ) ) { | 363 | if ( !QFile::exists( baseFile ) ) { |
340 | QFile f( baseFile ); | 364 | QFile f( baseFile ); |
341 | f.open( IO_WriteOnly ); | 365 | f.open( IO_WriteOnly ); |
342 | f.close(); | 366 | f.close(); |
343 | } | 367 | } |
344 | QRsync::applyDiff( baseFile, deltaFile ); | 368 | QRsync::applyDiff( baseFile, deltaFile ); |
345 | #ifndef QT_NO_COP | 369 | #ifndef QT_NO_COP |
346 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 370 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
347 | e << baseFile; | 371 | e << baseFile; |
348 | #endif | 372 | #endif |
349 | } else | 373 | } else if ( msg == "rdiffCleanup()" ) { |
350 | |||
351 | if ( msg == "rdiffCleanup()" ) { | ||
352 | mkdir( "/tmp/rdiff" ); | 374 | mkdir( "/tmp/rdiff" ); |
353 | QDir dir; | 375 | QDir dir; |
354 | dir.setPath( "/tmp/rdiff" ); | 376 | dir.setPath( "/tmp/rdiff" ); |
355 | QStringList entries = dir.entryList(); | 377 | QStringList entries = dir.entryList(); |
356 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 378 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
357 | dir.remove( *it ); | 379 | dir.remove( *it ); |
358 | } else | 380 | } else if ( msg == "sendHandshakeInfo()" ) { |
359 | |||
360 | if ( msg == "sendHandshakeInfo()" ) { | ||
361 | QString home = getenv( "HOME" ); | 381 | QString home = getenv( "HOME" ); |
362 | #ifndef QT_NO_COP | 382 | #ifndef QT_NO_COP |
363 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 383 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
364 | e << home; | 384 | e << home; |
365 | int locked = (int) ServerApplication::screenLocked(); | 385 | int locked = (int) ServerApplication::screenLocked(); |
366 | e << locked; | 386 | e << locked; |
367 | #endif | 387 | #endif |
368 | } else | 388 | } else if ( msg == "sendVersionInfo()" ) { |
369 | |||
370 | /* | 389 | /* |
371 | * QtopiaDesktop relies on the major number | 390 | * QtopiaDesktop relies on the major number |
372 | * to start with 1. We're at 0.9 | 391 | * to start with 1. |
373 | * so wee need to fake at least 1.4 to be able | 392 | * we need to fake at least 1.4 to be able |
374 | * to sync with QtopiaDesktop1.6 | 393 | * to sync with QtopiaDesktop1.6 |
375 | */ | 394 | */ |
376 | if ( msg == "sendVersionInfo()" ) { | ||
377 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); | 395 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); |
378 | /* ### FIXME Architecture ### */ | 396 | /* ### FIXME Architecture ### */ |
379 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; | 397 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; |
380 | } else | 398 | } else if ( msg == "sendCardInfo()" ) { |
381 | |||
382 | if ( msg == "sendCardInfo()" ) { | ||
383 | #ifndef QT_NO_COP | 399 | #ifndef QT_NO_COP |
384 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 400 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
385 | #endif | 401 | #endif |
386 | storage->update(); | 402 | storage->update(); |
387 | const QList<FileSystem> &fs = storage->fileSystems(); | 403 | const QList<FileSystem> &fs = storage->fileSystems(); |
388 | QListIterator<FileSystem> it ( fs ); | 404 | QListIterator<FileSystem> it ( fs ); |
389 | QString s; | 405 | QString s; |
390 | QString homeDir = getenv("HOME"); | 406 | QString homeDir = getenv("HOME"); |
391 | QString homeFs, homeFsPath; | 407 | QString homeFs, homeFsPath; |
392 | for ( ; it.current(); ++it ) { | 408 | for ( ; it.current(); ++it ) { |
393 | int k4 = (*it)->blockSize()/256; | 409 | int k4 = (*it)->blockSize()/256; |
394 | if ( (*it)->isRemovable() ) { | 410 | if ( (*it)->isRemovable() ) { |
395 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | 411 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr |
396 | + QString::number( (*it)->availBlocks() * k4/4 ) | 412 | + QString::number( (*it)->availBlocks() * k4/4 ) |
397 | + "K " + (*it)->options() + ";"; | 413 | + "K " + (*it)->options() + ";"; |
398 | } else if ( homeDir.contains( (*it)->path() ) && | 414 | } else if ( homeDir.contains( (*it)->path() ) && |
399 | (*it)->path().length() > homeFsPath.length() ) { | 415 | (*it)->path().length() > homeFsPath.length() ) { |
400 | homeFsPath = (*it)->path(); | 416 | homeFsPath = (*it)->path(); |
401 | homeFs = | 417 | homeFs = |
402 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | 418 | (*it)->name() + "=" + homeDir + "/Documents " // No tr |
403 | + QString::number( (*it)->availBlocks() * k4/4 ) | 419 | + QString::number( (*it)->availBlocks() * k4/4 ) |
404 | + "K " + (*it)->options() + ";"; | 420 | + "K " + (*it)->options() + ";"; |
405 | } | 421 | } |
406 | } | 422 | } |
407 | if ( !homeFs.isEmpty() ) | 423 | if ( !homeFs.isEmpty() ) |
408 | s += homeFs; | 424 | s += homeFs; |
409 | #ifndef QT_NO_COP | 425 | #ifndef QT_NO_COP |
410 | e << s; | 426 | e << s; |
411 | #endif | 427 | #endif |
412 | } else | 428 | } else if ( msg == "sendInstallLocations()" ) { |
413 | 429 | #ifndef QT_NO_COP | |
414 | if ( msg == "sendSyncDate(QString)" ) { | 430 | QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); |
431 | e << installLocationsString(); | ||
432 | #endif | ||
433 | } else if ( msg == "sendSyncDate(QString)" ) { | ||
415 | QString app; | 434 | QString app; |
416 | stream >> app; | 435 | stream >> app; |
417 | Config cfg( "qpe" ); | 436 | Config cfg( "qpe" ); |
418 | cfg.setGroup("SyncDate"); | 437 | cfg.setGroup("SyncDate"); |
419 | #ifndef QT_NO_COP | 438 | #ifndef QT_NO_COP |
420 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 439 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
421 | e << app << cfg.readEntry( app ); | 440 | e << app << cfg.readEntry( app ); |
422 | #endif | 441 | #endif |
423 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " | 442 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " |
424 | // << cfg.readEntry( app ).latin1() << oendl; | 443 | // << cfg.readEntry( app ).latin1() << oendl; |
425 | } else | 444 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
426 | |||
427 | if ( msg == "setSyncDate(QString,QString)" ) { | ||
428 | QString app, date; | 445 | QString app, date; |
429 | stream >> app >> date; | 446 | stream >> app >> date; |
430 | Config cfg( "qpe" ); | 447 | Config cfg( "qpe" ); |
431 | cfg.setGroup("SyncDate"); | 448 | cfg.setGroup("SyncDate"); |
432 | cfg.writeEntry( app, date ); | 449 | cfg.writeEntry( app, date ); |
433 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; | 450 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; |
434 | } else | 451 | } else if ( msg == "startSync(QString)" ) { |
435 | |||
436 | if ( msg == "startSync(QString)" ) { | ||
437 | QString what; | 452 | QString what; |
438 | stream >> what; | 453 | stream >> what; |
439 | delete syncDialog; | 454 | delete syncDialog; |
440 | syncDialog = new SyncDialog( this, what ); | 455 | syncDialog = new SyncDialog( this, what ); |
441 | syncDialog->show(); | 456 | syncDialog->show(); |
442 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 457 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
443 | } else | 458 | } else if ( msg == "stopSync()") { |
444 | |||
445 | if ( msg == "stopSync()") { | ||
446 | delete syncDialog; | 459 | delete syncDialog; |
447 | syncDialog = 0; | 460 | syncDialog = 0; |
448 | } else | 461 | } else if (msg == "restoreDone(QString)") { |
449 | |||
450 | if (msg == "restoreDone(QString)") { | ||
451 | docList->restoreDone(); | 462 | docList->restoreDone(); |
452 | } else | 463 | } else if ( msg == "getAllDocLinks()" ) { |
453 | |||
454 | if ( msg == "getAllDocLinks()" ) { | ||
455 | docList->sendAllDocLinks(); | 464 | docList->sendAllDocLinks(); |
456 | } else | 465 | } |
457 | 466 | #ifdef QPE_HAVE_DIRECT_ACCESS | |
467 | else if ( msg == "prepareDirectAccess()" ) { | ||
468 | prepareDirectAccess(); | ||
469 | } else if ( msg == "postDirectAccess()" ) { | ||
470 | postDirectAccess(); | ||
471 | } | ||
472 | #endif | ||
458 | #ifdef Q_WS_QWS | 473 | #ifdef Q_WS_QWS |
459 | if ( msg == "setMouseProto(QString)" ) { | 474 | |
475 | else if ( msg == "setMouseProto(QString)" ) { | ||
460 | QString mice; | 476 | QString mice; |
461 | stream >> mice; | 477 | stream >> mice; |
462 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 478 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
463 | qwsServer->openMouse(); | 479 | qwsServer->openMouse(); |
464 | } else | 480 | } else if ( msg == "setKeyboard(QString)" ) { |
465 | |||
466 | if ( msg == "setKeyboard(QString)" ) { | ||
467 | QString kb; | 481 | QString kb; |
468 | stream >> kb; | 482 | stream >> kb; |
469 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 483 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
470 | qwsServer->openKeyboard(); | 484 | qwsServer->openKeyboard(); |
471 | } else | 485 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
472 | |||
473 | if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | ||
474 | int delay, period; | 486 | int delay, period; |
475 | stream >> delay >> period; | 487 | stream >> delay >> period; |
476 | qwsSetKeyboardAutoRepeat( delay, period ); | 488 | qwsSetKeyboardAutoRepeat( delay, period ); |
477 | Config cfg( "qpe" ); | 489 | Config cfg( "qpe" ); |
478 | cfg.setGroup("Keyboard"); | 490 | cfg.setGroup("Keyboard"); |
479 | cfg.writeEntry( "RepeatDelay", delay ); | 491 | cfg.writeEntry( "RepeatDelay", delay ); |
480 | cfg.writeEntry( "RepeatPeriod", period ); | 492 | cfg.writeEntry( "RepeatPeriod", period ); |
481 | } else | 493 | } else if ( msg == "setKeyboardLayout(QString)" ) { |
482 | |||
483 | if ( msg == "setKeyboardLayout(QString)" ) { | ||
484 | QString kb; | 494 | QString kb; |
485 | stream >> kb; | 495 | stream >> kb; |
486 | setKeyboardLayout( kb ); | 496 | setKeyboardLayout( kb ); |
487 | Config cfg( "qpe" ); | 497 | Config cfg( "qpe" ); |
488 | cfg.setGroup("Keyboard"); | 498 | cfg.setGroup("Keyboard"); |
489 | cfg.writeEntry( "Layout", kb ); | 499 | cfg.writeEntry( "Layout", kb ); |
490 | } else | 500 | } else if ( msg == "autoStart(QString)" ) { |
491 | |||
492 | if ( msg == "autoStart(QString)" ) { | ||
493 | QString appName; | 501 | QString appName; |
494 | stream >> appName; | 502 | stream >> appName; |
495 | Config cfg( "autostart" ); | 503 | Config cfg( "autostart" ); |
496 | cfg.setGroup( "AutoStart" ); | 504 | cfg.setGroup( "AutoStart" ); |
497 | if ( appName.compare("clear") == 0){ | 505 | if ( appName.compare("clear") == 0){ |
498 | cfg.writeEntry("Apps", ""); | 506 | cfg.writeEntry("Apps", ""); |
499 | } | 507 | } |
500 | } else | 508 | } else if ( msg == "autoStart(QString,QString)" ) { |
501 | |||
502 | if ( msg == "autoStart(QString,QString)" ) { | ||
503 | QString modifier, appName; | 509 | QString modifier, appName; |
504 | stream >> modifier >> appName; | 510 | stream >> modifier >> appName; |
505 | Config cfg( "autostart" ); | 511 | Config cfg( "autostart" ); |
506 | cfg.setGroup( "AutoStart" ); | 512 | cfg.setGroup( "AutoStart" ); |
507 | if ( modifier.compare("add") == 0 ){ | 513 | if ( modifier.compare("add") == 0 ){ |
508 | // only add if appname is entered | 514 | // only add if appname is entered |
509 | if (!appName.isEmpty()) { | 515 | if (!appName.isEmpty()) { |
510 | cfg.writeEntry("Apps", appName); | 516 | cfg.writeEntry("Apps", appName); |
511 | } | 517 | } |
512 | } else if (modifier.compare("remove") == 0 ) { | 518 | } else if (modifier.compare("remove") == 0 ) { |
513 | // need to change for multiple entries | 519 | // need to change for multiple entries |
514 | // actually remove is right now simular to clear, but in future there | 520 | // actually remove is right now simular to clear, but in future there |
515 | // should be multiple apps in autostart possible. | 521 | // should be multiple apps in autostart possible. |
516 | QString checkName; | 522 | QString checkName; |
517 | checkName = cfg.readEntry("Apps", ""); | 523 | checkName = cfg.readEntry("Apps", ""); |
518 | if (checkName == appName) { | 524 | if (checkName == appName) { |
519 | cfg.writeEntry("Apps", ""); | 525 | cfg.writeEntry("Apps", ""); |
520 | } | 526 | } |
521 | } | 527 | } |
522 | // case the autostart feature should be delayed | 528 | // case the autostart feature should be delayed |
523 | } else | 529 | } else if ( msg == "autoStart(QString,QString,QString)") { |
524 | |||
525 | if ( msg == "autoStart(QString,QString,QString)") { | ||
526 | QString modifier, appName, delay; | 530 | QString modifier, appName, delay; |
527 | stream >> modifier >> appName >> delay; | 531 | stream >> modifier >> appName >> delay; |
528 | Config cfg( "autostart" ); | 532 | Config cfg( "autostart" ); |
529 | 533 | ||
530 | cfg.setGroup( "AutoStart" ); | 534 | cfg.setGroup( "AutoStart" ); |
531 | if ( modifier.compare("add") == 0 ){ | 535 | if ( modifier.compare("add") == 0 ){ |
532 | // only add it appname is entered | 536 | // only add it appname is entered |
533 | if (!appName.isEmpty()) { | 537 | if (!appName.isEmpty()) { |
534 | cfg.writeEntry("Apps", appName); | 538 | cfg.writeEntry("Apps", appName); |
535 | cfg.writeEntry("Delay", delay); | 539 | cfg.writeEntry("Delay", delay); |
536 | } | 540 | } |
537 | } | 541 | } |
538 | } | 542 | } |
539 | #endif | 543 | #endif |
540 | } | 544 | } |
541 | 545 | ||
546 | QString Server::cardInfoString() | ||
547 | { | ||
548 | storage->update(); | ||
549 | const QList<FileSystem> &fs = storage->fileSystems(); | ||
550 | QListIterator<FileSystem> it ( fs ); | ||
551 | QString s; | ||
552 | QString homeDir = getenv("HOME"); | ||
553 | QString homeFs, homeFsPath; | ||
554 | for ( ; it.current(); ++it ) { | ||
555 | int k4 = (*it)->blockSize()/256; | ||
556 | if ( (*it)->isRemovable() ) { | ||
557 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | ||
558 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
559 | + "K " + (*it)->options() + ";"; | ||
560 | } else if ( homeDir.contains( (*it)->path() ) && | ||
561 | (*it)->path().length() > homeFsPath.length() ) { | ||
562 | homeFsPath = (*it)->path(); | ||
563 | homeFs = | ||
564 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | ||
565 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
566 | + "K " + (*it)->options() + ";"; | ||
567 | } | ||
568 | } | ||
569 | if ( !homeFs.isEmpty() ) | ||
570 | s += homeFs; | ||
571 | return s; | ||
572 | } | ||
573 | |||
574 | QString Server::installLocationsString() | ||
575 | { | ||
576 | storage->update(); | ||
577 | const QList<FileSystem> &fs = storage->fileSystems(); | ||
578 | QListIterator<FileSystem> it ( fs ); | ||
579 | QString s; | ||
580 | QString homeDir = getenv("HOME"); | ||
581 | QString homeFs, homeFsPath; | ||
582 | for ( ; it.current(); ++it ) { | ||
583 | int k4 = (*it)->blockSize()/256; | ||
584 | if ( (*it)->isRemovable() ) { | ||
585 | s += (*it)->name() + "=" + (*it)->path() + " " // No tr | ||
586 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
587 | + "K " + (*it)->options() + ";"; | ||
588 | } else if ( homeDir.contains( (*it)->path() ) && | ||
589 | (*it)->path().length() > homeFsPath.length() ) { | ||
590 | homeFsPath = (*it)->path(); | ||
591 | homeFs = | ||
592 | (*it)->name() + "=" + homeDir + " " // No tr | ||
593 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
594 | + "K " + (*it)->options() + ";"; | ||
595 | } | ||
596 | } | ||
597 | if ( !homeFs.isEmpty() ) | ||
598 | s = homeFs + s; | ||
599 | return s; | ||
600 | } | ||
601 | |||
542 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) | 602 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) |
543 | { | 603 | { |
544 | QDataStream stream( data, IO_ReadOnly ); | 604 | QDataStream stream( data, IO_ReadOnly ); |
545 | 605 | ||
546 | if ( msg == "reloadApps()" ) { | 606 | if ( msg == "reloadApps()" ) { |
547 | docList->reloadAppLnks(); | 607 | docList->reloadAppLnks(); |
548 | } else | 608 | } else if ( msg == "soundAlarm()" ) { |
549 | |||
550 | if ( msg == "soundAlarm()" ) { | ||
551 | ServerApplication::soundAlarm(); | 609 | ServerApplication::soundAlarm(); |
552 | } else | 610 | } else if ( msg == "setLed(int,bool)" ) { |
553 | |||
554 | if ( msg == "setLed(int,bool)" ) { | ||
555 | int led, status; | 611 | int led, status; |
556 | stream >> led >> status; | 612 | stream >> led >> status; |
557 | 613 | ||
558 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); | 614 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); |
559 | if ( ll. count ( )) { | 615 | if ( ll. count ( )) { |
560 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | 616 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; |
561 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); | 617 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); |
562 | 618 | ||
563 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); | 619 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); |
564 | } | 620 | } |
565 | } | 621 | } |
566 | } | 622 | } |
567 | 623 | ||
568 | void Server::cancelSync() | 624 | void Server::cancelSync() |
569 | { | 625 | { |
570 | #ifndef QT_NO_COP | 626 | #ifndef QT_NO_COP |
571 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 627 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
572 | #endif | 628 | #endif |
573 | delete syncDialog; | 629 | delete syncDialog; |
574 | syncDialog = 0; | 630 | syncDialog = 0; |
575 | } | 631 | } |
576 | 632 | ||
577 | bool Server::mkdir(const QString &localPath) | 633 | bool Server::mkdir(const QString &localPath) |
578 | { | 634 | { |
579 | QDir fullDir(localPath); | 635 | QDir fullDir(localPath); |
580 | if (fullDir.exists()) | 636 | if (fullDir.exists()) |
581 | return true; | 637 | return true; |
582 | 638 | ||
583 | // at this point the directory doesn't exist | 639 | // at this point the directory doesn't exist |
584 | // go through the directory tree and start creating the direcotories | 640 | // go through the directory tree and start creating the direcotories |
585 | // that don't exist; if we can't create the directories, return false | 641 | // that don't exist; if we can't create the directories, return false |
586 | 642 | ||
587 | QString dirSeps = "/"; | 643 | QString dirSeps = "/"; |
588 | int dirIndex = localPath.find(dirSeps); | 644 | int dirIndex = localPath.find(dirSeps); |
589 | QString checkedPath; | 645 | QString checkedPath; |
590 | 646 | ||
591 | // didn't find any seps; weird, use the cur dir instead | 647 | // didn't find any seps; weird, use the cur dir instead |
592 | if (dirIndex == -1) { | 648 | if (dirIndex == -1) { |
593 | //odebug << "No seperators found in path " << localPath << "" << oendl; | 649 | //odebug << "No seperators found in path " << localPath << "" << oendl; |
594 | checkedPath = QDir::currentDirPath(); | 650 | checkedPath = QDir::currentDirPath(); |
595 | } | 651 | } |
596 | 652 | ||
597 | while (checkedPath != localPath) { | 653 | while (checkedPath != localPath) { |
598 | // no more seperators found, use the local path | 654 | // no more seperators found, use the local path |
599 | if (dirIndex == -1) { | 655 | if (dirIndex == -1) { |
600 | checkedPath = localPath; | 656 | checkedPath = localPath; |
601 | } else { | 657 | } else { |
602 | // the next directory to check | 658 | // the next directory to check |
603 | checkedPath = localPath.left(dirIndex) + "/"; | 659 | checkedPath = localPath.left(dirIndex) + "/"; |
604 | // advance the iterator; the next dir seperator | 660 | // advance the iterator; the next dir seperator |
605 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 661 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
606 | } | 662 | } |
607 | 663 | ||
608 | QDir checkDir(checkedPath); | 664 | QDir checkDir(checkedPath); |
609 | if (!checkDir.exists()) { | 665 | if (!checkDir.exists()) { |
610 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; | 666 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; |
611 | 667 | ||
612 | if (!checkDir.mkdir(checkedPath)) { | 668 | if (!checkDir.mkdir(checkedPath)) { |
613 | odebug << "Unable to make directory " << checkedPath << "" << oendl; | 669 | odebug << "Unable to make directory " << checkedPath << "" << oendl; |
614 | return FALSE; | 670 | return FALSE; |
615 | } | 671 | } |
616 | } | 672 | } |
617 | 673 | ||
618 | } | 674 | } |
619 | return TRUE; | 675 | return TRUE; |
620 | } | 676 | } |
621 | 677 | ||
622 | void Server::styleChange( QStyle &s ) | 678 | void Server::styleChange( QStyle &s ) |
623 | { | 679 | { |
624 | QWidget::styleChange( s ); | 680 | QWidget::styleChange( s ); |
625 | } | 681 | } |
626 | 682 | ||
627 | void Server::startTransferServer() | 683 | void Server::startTransferServer() |
628 | { | 684 | { |
629 | if ( !qcopBridge ) { | 685 | if ( !qcopBridge ) { |
630 | // start qcop bridge server | 686 | // start qcop bridge server |
631 | qcopBridge = new QCopBridge( 4243 ); | 687 | qcopBridge = new QCopBridge( 4243 ); |
632 | if ( qcopBridge->ok() ) { | 688 | if ( qcopBridge->ok() ) { |
633 | // ... OK | 689 | // ... OK |
634 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), | 690 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), |
635 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); | 691 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); |
636 | } else { | 692 | } else { |
637 | delete qcopBridge; | 693 | delete qcopBridge; |
638 | qcopBridge = 0; | 694 | qcopBridge = 0; |
639 | } | 695 | } |
640 | } | 696 | } |
641 | 697 | ||
642 | if ( !transferServer ) { | 698 | if ( !transferServer ) { |
643 | // start transfer server | 699 | // start transfer server |
644 | transferServer = new TransferServer( 4242 ); | 700 | transferServer = new TransferServer( 4242 ); |
645 | if ( transferServer->ok() ) { | 701 | if ( transferServer->ok() ) { |
646 | // ... OK | 702 | // ... OK |
647 | } else { | 703 | } else { |
648 | delete transferServer; | 704 | delete transferServer; |
649 | transferServer = 0; | 705 | transferServer = 0; |
650 | } | 706 | } |
651 | 707 | ||
652 | if ( !qcopBridge ) | 708 | if ( !qcopBridge ) |
653 | tid_xfer = startTimer( 2000 ); | 709 | tid_xfer = startTimer( 2000 ); |
654 | } | 710 | } |
655 | } | 711 | } |
656 | 712 | ||
657 | void Server::timerEvent( QTimerEvent *e ) | 713 | void Server::timerEvent( QTimerEvent *e ) |
658 | { | 714 | { |
659 | if ( e->timerId() == tid_xfer ) { | 715 | if ( e->timerId() == tid_xfer ) { |
660 | killTimer( tid_xfer ); | 716 | killTimer( tid_xfer ); |
661 | tid_xfer = 0; | 717 | tid_xfer = 0; |
662 | startTransferServer(); | 718 | startTransferServer(); |
663 | } | 719 | } |
664 | #if 0 | 720 | #if 0 |
665 | /* ### FIXME today startin */ | 721 | /* ### FIXME today startin */ |
666 | else if ( e->timerId() == tid_today ) { | 722 | else if ( e->timerId() == tid_today ) { |
667 | QDate today = QDate::currentDate(); | 723 | QDate today = QDate::currentDate(); |
668 | if ( today != last_today_show ) { | 724 | if ( today != last_today_show ) { |
669 | last_today_show = today; | 725 | last_today_show = today; |
670 | Config cfg("today"); | 726 | Config cfg("today"); |
671 | cfg.setGroup("Start"); | 727 | cfg.setGroup("Start"); |
672 | #ifndef QPE_DEFAULT_TODAY_MODE | 728 | #ifndef QPE_DEFAULT_TODAY_MODE |
673 | #define QPE_DEFAULT_TODAY_MODE "Never" | 729 | #define QPE_DEFAULT_TODAY_MODE "Never" |
674 | #endif | 730 | #endif |
675 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { | 731 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { |
676 | QCopEnvelope env(Service::channel("today"),"raise()"); | 732 | QCopEnvelope env(Service::channel("today"),"raise()"); |
677 | } | 733 | } |
678 | } | 734 | } |
679 | } | 735 | } |
680 | #endif | 736 | #endif |
681 | } | 737 | } |
682 | 738 | ||
683 | void Server::terminateServers() | 739 | void Server::terminateServers() |
684 | { | 740 | { |
685 | delete transferServer; | 741 | delete transferServer; |
686 | delete qcopBridge; | 742 | delete qcopBridge; |
687 | transferServer = 0; | 743 | transferServer = 0; |
688 | qcopBridge = 0; | 744 | qcopBridge = 0; |
689 | } | 745 | } |
690 | 746 | ||
691 | void Server::syncConnectionClosed( const QHostAddress & ) | 747 | void Server::syncConnectionClosed( const QHostAddress & ) |
692 | { | 748 | { |
693 | odebug << "Lost sync connection" << oendl; | 749 | odebug << "Lost sync connection" << oendl; |
694 | delete syncDialog; | 750 | delete syncDialog; |
695 | syncDialog = 0; | 751 | syncDialog = 0; |
696 | } | 752 | } |
697 | 753 | ||
698 | void Server::pokeTimeMonitors() | 754 | void Server::pokeTimeMonitors() |
699 | { | 755 | { |
700 | #if 0 | 756 | #if 0 |
701 | // inform all TimeMonitors | 757 | // inform all TimeMonitors |
702 | QStrList tms = Service::channels("TimeMonitor"); | 758 | QStrList tms = Service::channels("TimeMonitor"); |
703 | for (const char* ch = tms.first(); ch; ch=tms.next()) { | 759 | for (const char* ch = tms.first(); ch; ch=tms.next()) { |
704 | QString t = getenv("TZ"); | 760 | QString t = getenv("TZ"); |
705 | QCopEnvelope e(ch, "timeChange(QString)"); | 761 | QCopEnvelope e(ch, "timeChange(QString)"); |
706 | e << t; | 762 | e << t; |
707 | } | 763 | } |
708 | #endif | 764 | #endif |
709 | } | 765 | } |
710 | 766 | ||
711 | void Server::applicationLaunched(int, const QString &app) | 767 | void Server::applicationLaunched(int, const QString &app) |
712 | { | 768 | { |
713 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); | 769 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); |
714 | } | 770 | } |
715 | 771 | ||
716 | void Server::applicationTerminated(int pid, const QString &app) | 772 | void Server::applicationTerminated(int pid, const QString &app) |
717 | { | 773 | { |
718 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); | 774 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); |
719 | #if 0 | 775 | #if 0 |
720 | tsmMonitor->applicationTerminated( pid ); | 776 | tsmMonitor->applicationTerminated( pid ); |
721 | #else | 777 | #else |
722 | Q_UNUSED( pid ) | 778 | Q_UNUSED( pid ) |
723 | #endif | 779 | #endif |
724 | } | 780 | } |
725 | 781 | ||
726 | void Server::applicationConnected(const QString &app) | 782 | void Server::applicationConnected(const QString &app) |
727 | { | 783 | { |
728 | serverGui->applicationStateChanged( app, ServerInterface::Running ); | 784 | serverGui->applicationStateChanged( app, ServerInterface::Running ); |
729 | } | 785 | } |
730 | 786 | ||
731 | void Server::storageChanged() | 787 | void Server::storageChanged() |
732 | { | 788 | { |
733 | system( "opie-update-symlinks" ); | 789 | system( "opie-update-symlinks" ); |
734 | serverGui->storageChanged( storage->fileSystems() ); | 790 | serverGui->storageChanged( storage->fileSystems() ); |
735 | docList->storageChanged(); | 791 | docList->storageChanged(); |
736 | } | 792 | } |
737 | 793 | ||
738 | 794 | ||
739 | 795 | ||
740 | void Server::preloadApps() | 796 | void Server::preloadApps() |
741 | { | 797 | { |
742 | Config cfg("Launcher"); | 798 | Config cfg("Launcher"); |
743 | cfg.setGroup("Preload"); | 799 | cfg.setGroup("Preload"); |
744 | QStringList apps = cfg.readListEntry("Apps",','); | 800 | QStringList apps = cfg.readListEntry("Apps",','); |
745 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 801 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
746 | #ifndef QT_NO_COP | 802 | #ifndef QT_NO_COP |
747 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 803 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
748 | #endif | 804 | #endif |
749 | } | 805 | } |
750 | } | 806 | } |
807 | |||
808 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined | ||
809 | void Server::prepareDirectAccess() | ||
810 | { | ||
811 | qDebug( "Server::prepareDirectAccess()" ); | ||
812 | // Put up a pretty dialog | ||
813 | syncDialog = new SyncDialog( this, tr("USB Lock") ); | ||
814 | syncDialog->show(); | ||
815 | |||
816 | // Prevent the PDA from acting as a PDA | ||
817 | terminateServers(); | ||
818 | |||
819 | // suspend the mtab monitor | ||
820 | #ifndef QT_NO_COP | ||
821 | { | ||
822 | QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); | ||
823 | } | ||
824 | #endif | ||
825 | |||
826 | // send out a flush message | ||
827 | // once flushes are done call runDirectAccess() | ||
828 | // We just count the number of apps and set a timer. | ||
829 | // Either the timer expires or the correct number of apps responds. | ||
830 | // Note: quicklauncher isn't in the runningApps list but it responds | ||
831 | // to the flush so we start the counter at 1 | ||
832 | pendingFlushes = 1; | ||
833 | directAccessRun = FALSE; | ||
834 | for ( QMap<int,QString>::ConstIterator it = | ||
835 | appLauncher->runningApplications().begin(); | ||
836 | it != appLauncher->runningApplications().end(); | ||
837 | ++it ) { | ||
838 | pendingFlushes++; | ||
839 | } | ||
840 | #ifndef QT_NO_COP | ||
841 | QCopEnvelope e1( "QPE/System", "flush()" ); | ||
842 | #endif | ||
843 | QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); | ||
844 | #warning FIXME support TempScreenSaverMode | ||
845 | #if 0 | ||
846 | QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); | ||
847 | #endif | ||
848 | } | ||
849 | |||
850 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined | ||
851 | // It fakes the presence of Qtopia Desktop | ||
852 | void Server::desktopMessage( const QCString &message, const QByteArray &data ) | ||
853 | { | ||
854 | QDataStream stream( data, IO_ReadOnly ); | ||
855 | if ( message == "flushDone(QString)" ) { | ||
856 | QString app; | ||
857 | stream >> app; | ||
858 | qDebug( "flushDone from %s", app.latin1() ); | ||
859 | if ( --pendingFlushes == 0 ) { | ||
860 | qDebug( "pendingFlushes == 0, all the apps responded" ); | ||
861 | runDirectAccess(); | ||
862 | } | ||
863 | } else if ( message == "installStarted(QString)" ) { | ||
864 | QString package; | ||
865 | stream >> package; | ||
866 | qDebug( "\tInstall Started for package %s", package.latin1() ); | ||
867 | } else if ( message == "installStep(QString)" ) { | ||
868 | QString step; | ||
869 | stream >> step; | ||
870 | qDebug( "\tInstall Step %s", step.latin1() ); | ||
871 | } else if ( message == "installDone(QString)" ) { | ||
872 | QString package; | ||
873 | stream >> package; | ||
874 | qDebug( "\tInstall Finished for package %s", package.latin1() ); | ||
875 | } else if ( message == "installFailed(QString,int,QString)" ) { | ||
876 | QString package, error; | ||
877 | int status; | ||
878 | stream >> package >> status >> error; | ||
879 | qDebug( "\tInstall Failed for package %s with error code %d and error message %s", | ||
880 | package.latin1(), status, error.latin1() ); | ||
881 | } else if ( message == "removeStarted(QString)" ) { | ||
882 | QString package; | ||
883 | stream >> package; | ||
884 | qDebug( "\tRemove Started for package %s", package.latin1() ); | ||
885 | } else if ( message == "removeDone(QString)" ) { | ||
886 | QString package; | ||
887 | stream >> package; | ||
888 | qDebug( "\tRemove Finished for package %s", package.latin1() ); | ||
889 | } else if ( message == "removeFailed(QString)" ) { | ||
890 | QString package; | ||
891 | stream >> package; | ||
892 | qDebug( "\tRemove Failed for package %s", package.latin1() ); | ||
893 | } | ||
894 | |||
895 | if ( qrr && qrr->waitingForMessages ) | ||
896 | qrr->desktopMessage( message, data ); | ||
897 | } | ||
898 | |||
899 | |||
900 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined | ||
901 | void Server::runDirectAccess() | ||
902 | { | ||
903 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
904 | // The timer must have fired after all the apps responded | ||
905 | // with flushDone(). Just ignore it. | ||
906 | if ( directAccessRun ) | ||
907 | return; | ||
908 | |||
909 | directAccessRun = TRUE; | ||
910 | ::readyDirectAccess(cardInfoString(), installLocationsString()); | ||
911 | #endif | ||
912 | } | ||
913 | |||
914 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined | ||
915 | void Server::postDirectAccess() | ||
916 | { | ||
917 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
918 | qDebug( "Server::postDirectAccess()" ); | ||
919 | |||
920 | // Categories may have changed | ||
921 | QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); | ||
922 | // Apps need to reload their data | ||
923 | QCopEnvelope e2( "QPE/System", "reload()" ); | ||
924 | // Reload DocLinks | ||
925 | docList->storageChanged(); | ||
926 | // Restart the PDA server stuff | ||
927 | startTransferServer(); | ||
928 | |||
929 | // restart the mtab monitor | ||
930 | #ifndef QT_NO_COP | ||
931 | { | ||
932 | QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); | ||
933 | } | ||
934 | #endif | ||
935 | |||
936 | // Process queued requests | ||
937 | const char *queueFile = ::directAccessQueueFile(); | ||
938 | QFile *file = new QFile( queueFile ); | ||
939 | if ( !file->exists() ) { | ||
940 | delete file; | ||
941 | // Get rid of the dialog | ||
942 | if ( syncDialog ) { | ||
943 | delete syncDialog; | ||
944 | syncDialog = 0; | ||
945 | } | ||
946 | #warning FIXME support TempScreenSaverMode | ||
947 | #if 0 | ||
948 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); | ||
949 | #endif | ||
950 | } else { | ||
951 | qrr = new QueuedRequestRunner( file, syncDialog ); | ||
952 | connect( qrr, SIGNAL(finished()), | ||
953 | this, SLOT(finishedQueuedRequests()) ); | ||
954 | QTimer::singleShot( 100, qrr, SLOT(process()) ); | ||
955 | // qrr will remove the sync dialog later | ||
956 | } | ||
957 | #endif | ||
958 | } | ||
959 | |||
960 | void Server::finishedQueuedRequests() | ||
961 | { | ||
962 | if ( qrr->readyToDelete ) { | ||
963 | delete qrr; | ||
964 | qrr = 0; | ||
965 | // Get rid of the dialog | ||
966 | if ( syncDialog ) { | ||
967 | delete syncDialog; | ||
968 | syncDialog = 0; | ||
969 | } | ||
970 | #warning FIXME support TempScreenSaverMode | ||
971 | #if 0 | ||
972 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); | ||
973 | #endif | ||
974 | } else { | ||
975 | qrr->readyToDelete = TRUE; | ||
976 | QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); | ||
977 | } | ||
978 | } | ||
979 | |||
diff --git a/core/launcher/server.h b/core/launcher/server.h index 1dc5e7e..d71d68a 100644 --- a/core/launcher/server.h +++ b/core/launcher/server.h | |||
@@ -1,99 +1,111 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #ifndef DESKTOP_H | 20 | #ifndef DESKTOP_H |
21 | #define DESKTOP_H | 21 | #define DESKTOP_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | 25 | ||
26 | //#include "qcopbridge.h" | 26 | //#include "qcopbridge.h" |
27 | 27 | ||
28 | class QCopBridge; | 28 | class QCopBridge; |
29 | class QHostAddress; | 29 | class QHostAddress; |
30 | class TransferServer; | 30 | class TransferServer; |
31 | class PackageHandler; | 31 | class PackageHandler; |
32 | class ServiceRequest; | 32 | class ServiceRequest; |
33 | class TempScreenSaverMonitor; | 33 | class TempScreenSaverMonitor; |
34 | class AppLauncher; | 34 | class AppLauncher; |
35 | class AppLnkSet; | 35 | class AppLnkSet; |
36 | class StorageInfo; | 36 | class StorageInfo; |
37 | class SyncDialog; | 37 | class SyncDialog; |
38 | class DocumentList; | 38 | class DocumentList; |
39 | class ServerInterface; | 39 | class ServerInterface; |
40 | class QueuedRequestRunner; | ||
40 | namespace Opie { | 41 | namespace Opie { |
41 | namespace Core { | 42 | namespace Core { |
42 | class ODeviceButton; | 43 | class ODeviceButton; |
43 | } | 44 | } |
44 | } | 45 | } |
45 | 46 | ||
46 | class Server : public QWidget { | 47 | class Server : public QWidget { |
47 | Q_OBJECT | 48 | Q_OBJECT |
48 | public: | 49 | public: |
49 | Server(); | 50 | Server(); |
50 | ~Server(); | 51 | ~Server(); |
51 | 52 | ||
52 | static bool mkdir(const QString &path); | 53 | static bool mkdir(const QString &path); |
53 | 54 | ||
54 | void show(); | 55 | void show(); |
55 | 56 | ||
56 | static bool setKeyboardLayout( const QString &kb ); | 57 | static bool setKeyboardLayout( const QString &kb ); |
57 | 58 | ||
58 | public slots: | 59 | public slots: |
59 | void systemMsg(const QCString &, const QByteArray &); | 60 | void systemMsg(const QCString &, const QByteArray &); |
60 | void receiveTaskBar(const QCString &msg, const QByteArray &data); | 61 | void receiveTaskBar(const QCString &msg, const QByteArray &data); |
61 | void terminateServers(); | 62 | void terminateServers(); |
62 | void pokeTimeMonitors(); | 63 | void pokeTimeMonitors(); |
63 | 64 | ||
64 | private slots: | 65 | private slots: |
65 | void activate(const Opie::Core::ODeviceButton*,bool); | 66 | void activate(const Opie::Core::ODeviceButton*,bool); |
66 | void syncConnectionClosed( const QHostAddress & ); | 67 | void syncConnectionClosed( const QHostAddress & ); |
67 | void applicationLaunched(int pid, const QString &app); | 68 | void applicationLaunched(int pid, const QString &app); |
68 | void applicationTerminated(int pid, const QString &app); | 69 | void applicationTerminated(int pid, const QString &app); |
69 | void applicationConnected(const QString &app); | 70 | void applicationConnected(const QString &app); |
70 | void storageChanged(); | 71 | void storageChanged(); |
71 | void cancelSync(); | 72 | void cancelSync(); |
73 | void desktopMessage( const QCString &, const QByteArray & ); | ||
74 | void runDirectAccess(); | ||
75 | void finishedQueuedRequests(); | ||
72 | 76 | ||
73 | protected: | 77 | protected: |
74 | void styleChange( QStyle & ); | 78 | void styleChange( QStyle & ); |
75 | void timerEvent( QTimerEvent *e ); | 79 | void timerEvent( QTimerEvent *e ); |
76 | 80 | ||
77 | private: | 81 | private: |
78 | void layout(); | 82 | void layout(); |
79 | void startTransferServer(); | 83 | void startTransferServer(); |
80 | void preloadApps(); | 84 | void preloadApps(); |
85 | void prepareDirectAccess(); | ||
86 | void postDirectAccess(); | ||
87 | QString cardInfoString(); | ||
88 | QString installLocationsString(); | ||
81 | 89 | ||
82 | QCopBridge *qcopBridge; | 90 | QCopBridge *qcopBridge; |
83 | TransferServer *transferServer; | 91 | TransferServer *transferServer; |
84 | PackageHandler *packageHandler; | 92 | PackageHandler *packageHandler; |
85 | QDate last_today_show; | 93 | QDate last_today_show; |
86 | int tid_xfer; | 94 | int tid_xfer; |
87 | /* ### FIXME two below### */ | 95 | /* ### FIXME two below### */ |
88 | // int tid_today; | 96 | // int tid_today; |
89 | // TempScreenSaverMonitor *tsmMonitor; | 97 | // TempScreenSaverMonitor *tsmMonitor; |
90 | StorageInfo *storage; | 98 | StorageInfo *storage; |
91 | SyncDialog *syncDialog; | 99 | SyncDialog *syncDialog; |
92 | AppLauncher *appLauncher; | 100 | AppLauncher *appLauncher; |
93 | DocumentList *docList; | 101 | DocumentList *docList; |
94 | ServerInterface *serverGui; | 102 | ServerInterface *serverGui; |
103 | |||
104 | int pendingFlushes; | ||
105 | bool directAccessRun; | ||
106 | QueuedRequestRunner *qrr; | ||
95 | }; | 107 | }; |
96 | 108 | ||
97 | 109 | ||
98 | #endif // DESKTOP_H | 110 | #endif // DESKTOP_H |
99 | 111 | ||
diff --git a/core/launcher/server.pro b/core/launcher/server.pro index f366f54..5f2aa02 100644 --- a/core/launcher/server.pro +++ b/core/launcher/server.pro | |||
@@ -1,84 +1,89 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | 2 | ||
3 | CONFIG += qt warn_on | 3 | CONFIG += qt warn_on |
4 | 4 | ||
5 | DESTDIR = $$(OPIEDIR)/bin | 5 | DESTDIR = $$(OPIEDIR)/bin |
6 | 6 | ||
7 | HEADERS += server.h \ | 7 | HEADERS += server.h \ |
8 | qrr.h \ | ||
8 | serverinterface.h \ | 9 | serverinterface.h \ |
9 | launchertab.h \ | 10 | launchertab.h \ |
10 | documentlist.h \ | 11 | documentlist.h \ |
11 | appicons.h \ | 12 | appicons.h \ |
12 | taskbar.h \ | 13 | taskbar.h \ |
13 | runningappbar.h \ | 14 | runningappbar.h \ |
14 | applauncher.h \ | 15 | applauncher.h \ |
15 | stabmon.h \ | 16 | stabmon.h \ |
16 | inputmethods.h \ | 17 | inputmethods.h \ |
17 | systray.h \ | 18 | systray.h \ |
18 | wait.h \ | 19 | wait.h \ |
19 | shutdownimpl.h \ | 20 | shutdownimpl.h \ |
20 | launcher.h \ | 21 | launcher.h \ |
21 | launcherview.h \ | 22 | launcherview.h \ |
22 | $$(OPIEDIR)/core/apps/calibrate/calibrate.h \ | 23 | $$(OPIEDIR)/core/apps/calibrate/calibrate.h \ |
23 | startmenu.h \ | 24 | startmenu.h \ |
24 | transferserver.h \ | 25 | transferserver.h \ |
25 | qcopbridge.h \ | 26 | qcopbridge.h \ |
26 | packageslave.h \ | 27 | packageslave.h \ |
27 | irserver.h \ | 28 | irserver.h \ |
28 | firstuse.h \ | 29 | firstuse.h \ |
29 | syncdialog.h \ | 30 | syncdialog.h \ |
30 | serverapp.h \ | 31 | serverapp.h \ |
31 | qprocess.h \ | 32 | qprocess.h \ |
32 | screensaver.h \ | 33 | screensaver.h \ |
33 | $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.h \ | 34 | $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.h \ |
34 | mediadlg.h | 35 | mediadlg.h |
35 | 36 | ||
36 | SOURCES += server.cpp \ | 37 | SOURCES += server.cpp \ |
38 | qrr.cpp \ | ||
37 | serverinterface.cpp \ | 39 | serverinterface.cpp \ |
38 | launchertab.cpp \ | 40 | launchertab.cpp \ |
39 | documentlist.cpp \ | 41 | documentlist.cpp \ |
40 | appicons.cpp \ | 42 | appicons.cpp \ |
41 | taskbar.cpp \ | 43 | taskbar.cpp \ |
42 | runningappbar.cpp \ | 44 | runningappbar.cpp \ |
43 | applauncher.cpp \ | 45 | applauncher.cpp \ |
44 | stabmon.cpp \ | 46 | stabmon.cpp \ |
45 | inputmethods.cpp \ | 47 | inputmethods.cpp \ |
46 | systray.cpp \ | 48 | systray.cpp \ |
47 | wait.cpp \ | 49 | wait.cpp \ |
48 | shutdownimpl.cpp \ | 50 | shutdownimpl.cpp \ |
49 | launcher.cpp \ | 51 | launcher.cpp \ |
50 | launcherview.cpp \ | 52 | launcherview.cpp \ |
51 | $$(OPIEDIR)/core/apps/calibrate/calibrate.cpp \ | 53 | $$(OPIEDIR)/core/apps/calibrate/calibrate.cpp \ |
52 | transferserver.cpp \ | 54 | transferserver.cpp \ |
53 | packageslave.cpp \ | 55 | packageslave.cpp \ |
54 | irserver.cpp \ | 56 | irserver.cpp \ |
55 | qcopbridge.cpp \ | 57 | qcopbridge.cpp \ |
56 | startmenu.cpp \ | 58 | startmenu.cpp \ |
57 | main.cpp \ | 59 | main.cpp \ |
58 | firstuse.cpp \ | 60 | firstuse.cpp \ |
59 | syncdialog.cpp \ | 61 | syncdialog.cpp \ |
60 | serverapp.cpp \ | 62 | serverapp.cpp \ |
61 | qprocess.cpp \ | 63 | qprocess.cpp \ |
62 | qprocess_unix.cpp \ | 64 | qprocess_unix.cpp \ |
63 | screensaver.cpp \ | 65 | screensaver.cpp \ |
64 | $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.cc \ | 66 | $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.cc \ |
65 | mediadlg.cpp | 67 | mediadlg.cpp |
66 | 68 | ||
67 | 69 | ||
68 | INCLUDEPATH += $(OPIEDIR)/core/apps/calibrate | 70 | INCLUDEPATH += $(OPIEDIR)/core/apps/calibrate |
69 | DEPENDPATH+= $(OPIEDIR)/core/apps/calibrate | 71 | DEPENDPATH+= $(OPIEDIR)/core/apps/calibrate |
70 | 72 | ||
71 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/rsync | 73 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/rsync |
72 | DEPENDPATH+= $(OPIEDIR)/rsync | 74 | DEPENDPATH+= $(OPIEDIR)/rsync |
73 | 75 | ||
74 | INCLUDEPATH += $(OPIEDIR)/noncore/settings/mediummount | 76 | INCLUDEPATH += $(OPIEDIR)/noncore/settings/mediummount |
75 | DEPENDPATH += $(OPIEDIR)/noncore/settings/mediummount | 77 | DEPENDPATH += $(OPIEDIR)/noncore/settings/mediummount |
76 | 78 | ||
77 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiesecurity2 -lqrsync | 79 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiesecurity2 -lqrsync |
78 | TARGET = qpe | 80 | TARGET = qpe |
79 | 81 | ||
82 | ## not ready for use yet | ||
83 | # DEFINES += QPE_HAVE_DIRECT_ACCESS | ||
84 | |||
80 | contains( $(CONFIG_TARGET_MACOSX), y ) { | 85 | contains( $(CONFIG_TARGET_MACOSX), y ) { |
81 | LIBS += -lcrypt | 86 | LIBS += -lcrypt |
82 | } | 87 | } |
83 | 88 | ||
84 | include ( $(OPIEDIR)/include.pro ) | 89 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 66cc788..fac52a6 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -1,295 +1,298 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 "serverapp.h" | 21 | #include "serverapp.h" |
22 | #include "screensaver.h" | 22 | #include "screensaver.h" |
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <opie2/odevice.h> | 26 | #include <opie2/odevice.h> |
27 | #include <opie2/multiauthpassword.h> | 27 | #include <opie2/multiauthpassword.h> |
28 | 28 | ||
29 | #include <qtopia/config.h> | 29 | #include <qtopia/config.h> |
30 | #include <qtopia/power.h> | 30 | #include <qtopia/power.h> |
31 | 31 | ||
32 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
33 | #include <qtopia/qcopenvelope_qws.h> | 33 | #include <qtopia/qcopenvelope_qws.h> |
34 | #endif | 34 | #endif |
35 | #include <qtopia/global.h> | 35 | #include <qtopia/global.h> |
36 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #ifdef Q_WS_QWS | 39 | #ifdef Q_WS_QWS |
40 | #include <qgfx_qws.h> | 40 | #include <qgfx_qws.h> |
41 | #endif | 41 | #endif |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qpainter.h> | 44 | #include <qpainter.h> |
45 | #include <qfile.h> | 45 | #include <qfile.h> |
46 | #include <qpixmapcache.h> | 46 | #include <qpixmapcache.h> |
47 | 47 | ||
48 | /* STD */ | 48 | /* STD */ |
49 | #ifdef Q_OS_WIN32 | 49 | #ifdef Q_OS_WIN32 |
50 | #include <io.h> | 50 | #include <io.h> |
51 | #include <process.h> | 51 | #include <process.h> |
52 | #else | 52 | #else |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #endif | 54 | #endif |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | 56 | ||
57 | static ServerApplication *serverApp = 0; | 57 | static ServerApplication *serverApp = 0; |
58 | static int loggedin=0; | 58 | static int loggedin=0; |
59 | 59 | ||
60 | QCopKeyRegister::QCopKeyRegister() | 60 | QCopKeyRegister::QCopKeyRegister() |
61 | : m_keyCode( 0 ) | 61 | : m_keyCode( 0 ) |
62 | { | 62 | { |
63 | odebug << "KeyRegister1 " << m_keyCode << oendl; | ||
63 | } | 64 | } |
64 | 65 | ||
65 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) | 66 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
66 | :m_keyCode( k ), m_channel( c ), m_message( m ) | 67 | :m_keyCode( k ), m_channel( c ), m_message( m ) |
67 | { | 68 | { |
69 | odebug << "keyRegister2 " << m_keyCode << c << m << oendl; | ||
68 | } | 70 | } |
69 | 71 | ||
70 | int QCopKeyRegister::keyCode() const | 72 | int QCopKeyRegister::keyCode() const |
71 | { | 73 | { |
72 | return m_keyCode; | 74 | return m_keyCode; |
73 | } | 75 | } |
74 | 76 | ||
75 | QCString QCopKeyRegister::channel() const | 77 | QCString QCopKeyRegister::channel() const |
76 | { | 78 | { |
77 | return m_channel; | 79 | return m_channel; |
78 | } | 80 | } |
79 | 81 | ||
80 | QCString QCopKeyRegister::message() const | 82 | QCString QCopKeyRegister::message() const |
81 | { | 83 | { |
82 | return m_message; | 84 | return m_message; |
83 | } | 85 | } |
84 | 86 | ||
85 | bool QCopKeyRegister::send() | 87 | bool QCopKeyRegister::send() |
86 | { | 88 | { |
87 | if (m_channel.isNull() ) | 89 | if (m_channel.isNull() ) |
88 | return false; | 90 | return false; |
89 | 91 | qDebug("Send Message: "+m_channel+" "+m_message); | |
90 | QCopEnvelope( m_channel, m_message ); | 92 | QCopEnvelope e( m_channel, m_message ); |
91 | 93 | ||
92 | return true; | 94 | return true; |
93 | } | 95 | } |
94 | 96 | ||
95 | //--------------------------------------------------------------------------- | 97 | //--------------------------------------------------------------------------- |
96 | 98 | ||
97 | /* | 99 | /* |
98 | Priority is number of alerts that are needed to pop up | 100 | Priority is number of alerts that are needed to pop up |
99 | alert. | 101 | alert. |
100 | */ | 102 | */ |
101 | class DesktopPowerAlerter : public QMessageBox | 103 | class DesktopPowerAlerter : public QMessageBox |
102 | { | 104 | { |
103 | Q_OBJECT | 105 | Q_OBJECT |
104 | public: | 106 | public: |
105 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 107 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
106 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), | 108 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), |
107 | QMessageBox::Critical, | 109 | QMessageBox::Critical, |
108 | QMessageBox::Ok | QMessageBox::Default, | 110 | QMessageBox::Ok | QMessageBox::Default, |
109 | QMessageBox::NoButton, QMessageBox::NoButton, | 111 | QMessageBox::NoButton, QMessageBox::NoButton, |
110 | parent, name, FALSE ) | 112 | parent, name, FALSE ) |
111 | { | 113 | { |
112 | currentPriority = INT_MAX; | 114 | currentPriority = INT_MAX; |
113 | alertCount = 0; | 115 | alertCount = 0; |
114 | } | 116 | } |
115 | 117 | ||
116 | void alert( const QString &text, int priority ); | 118 | void alert( const QString &text, int priority ); |
117 | void hideEvent( QHideEvent * ); | 119 | void hideEvent( QHideEvent * ); |
118 | private: | 120 | private: |
119 | int currentPriority; | 121 | int currentPriority; |
120 | int alertCount; | 122 | int alertCount; |
121 | }; | 123 | }; |
122 | 124 | ||
123 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 125 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
124 | { | 126 | { |
125 | alertCount++; | 127 | alertCount++; |
126 | if ( alertCount < priority ) | 128 | if ( alertCount < priority ) |
127 | return; | 129 | return; |
128 | if ( priority > currentPriority ) | 130 | if ( priority > currentPriority ) |
129 | return; | 131 | return; |
130 | currentPriority = priority; | 132 | currentPriority = priority; |
131 | setText( text ); | 133 | setText( text ); |
132 | show(); | 134 | show(); |
133 | } | 135 | } |
134 | 136 | ||
135 | 137 | ||
136 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 138 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
137 | { | 139 | { |
138 | QMessageBox::hideEvent( e ); | 140 | QMessageBox::hideEvent( e ); |
139 | alertCount = 0; | 141 | alertCount = 0; |
140 | currentPriority = INT_MAX; | 142 | currentPriority = INT_MAX; |
141 | } | 143 | } |
142 | 144 | ||
143 | //--------------------------------------------------------------------------- | 145 | //--------------------------------------------------------------------------- |
144 | 146 | ||
145 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 147 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) |
146 | { | 148 | { |
147 | /* We don't do this cause it would interfere with ODevice */ | 149 | /* We don't do this cause it would interfere with ODevice */ |
148 | #if 0 | 150 | #if 0 |
149 | qwsServer->setKeyboardFilter(this); | 151 | qwsServer->setKeyboardFilter(this); |
150 | #endif | 152 | #endif |
151 | } | 153 | } |
152 | 154 | ||
153 | void KeyFilter::timerEvent(QTimerEvent* e) | 155 | void KeyFilter::timerEvent(QTimerEvent* e) |
154 | { | 156 | { |
155 | if ( e->timerId() == held_tid ) { | 157 | if ( e->timerId() == held_tid ) { |
156 | killTimer(held_tid); | 158 | killTimer(held_tid); |
157 | // button held | 159 | // button held |
158 | if ( heldButton ) { | 160 | if ( heldButton ) { |
159 | emit activate(heldButton, TRUE); | 161 | emit activate(heldButton, TRUE); |
160 | heldButton = 0; | 162 | heldButton = 0; |
161 | } | 163 | } |
162 | held_tid = 0; | 164 | held_tid = 0; |
163 | } | 165 | } |
164 | } | 166 | } |
165 | 167 | ||
166 | void KeyFilter::registerKey( const QCopKeyRegister& key ) | 168 | void KeyFilter::registerKey( const QCopKeyRegister& key ) |
167 | { | 169 | { |
170 | odebug << "KeyFilter::registerKey " << key.keyCode() << key.channel() << key.message() << oendl; | ||
168 | m_keys.insert( key.keyCode(), key ); | 171 | m_keys.insert( key.keyCode(), key ); |
169 | } | 172 | } |
170 | 173 | ||
171 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) | 174 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) |
172 | { | 175 | { |
173 | m_keys.remove( key.keyCode() ); | 176 | m_keys.remove( key.keyCode() ); |
174 | } | 177 | } |
175 | 178 | ||
176 | bool KeyFilter::keyRegistered( int key ) | 179 | bool KeyFilter::keyRegistered( int key ) |
177 | { | 180 | { |
178 | /* | 181 | /* |
179 | * Check if we've a key registered | 182 | * Check if we've a key registered |
180 | */ | 183 | */ |
181 | if ( !m_keys[key].send()) | 184 | if ( !m_keys[key].send()) |
182 | return false; | 185 | return false; |
183 | else | 186 | else |
184 | return true; | 187 | return true; |
185 | } | 188 | } |
186 | 189 | ||
187 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 190 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
188 | { | 191 | { |
189 | if ( !loggedin | 192 | if ( !loggedin |
190 | // Permitted keys | 193 | // Permitted keys |
191 | && keycode != Key_F34 // power | 194 | && keycode != Key_F34 // power |
192 | && keycode != Key_F30 // select | 195 | && keycode != Key_F30 // select |
193 | && keycode != Key_Enter | 196 | && keycode != Key_Enter |
194 | && keycode != Key_Return | 197 | && keycode != Key_Return |
195 | && keycode != Key_Space | 198 | && keycode != Key_Space |
196 | && keycode != Key_Left | 199 | && keycode != Key_Left |
197 | && keycode != Key_Right | 200 | && keycode != Key_Right |
198 | && keycode != Key_Up | 201 | && keycode != Key_Up |
199 | && keycode != Key_Down ) | 202 | && keycode != Key_Down ) |
200 | return TRUE; | 203 | return TRUE; |
201 | 204 | ||
202 | /* check if it was registered */ | 205 | /* check if it was registered */ |
203 | if (!db ) { | 206 | if (!db ) { |
204 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 207 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
205 | return true; | 208 | return true; |
206 | } else { | 209 | } else { |
207 | 210 | ||
208 | // First check to see if DeviceButtonManager knows something about this button: | 211 | // First check to see if DeviceButtonManager knows something about this button: |
209 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); | 212 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); |
210 | if (button && !autoRepeat) { | 213 | if (button && !autoRepeat) { |
211 | if ( held_tid ) { | 214 | if ( held_tid ) { |
212 | killTimer(held_tid); | 215 | killTimer(held_tid); |
213 | held_tid = 0; | 216 | held_tid = 0; |
214 | } | 217 | } |
215 | if ( button->heldAction().isNull() ) { | 218 | if ( button->heldAction().isNull() ) { |
216 | if ( press ) | 219 | if ( press ) |
217 | emit activate(button, FALSE); | 220 | emit activate(button, FALSE); |
218 | } else if ( press ) { | 221 | } else if ( press ) { |
219 | heldButton = button; | 222 | heldButton = button; |
220 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 223 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
221 | } else if ( heldButton ) { | 224 | } else if ( heldButton ) { |
222 | heldButton = 0; | 225 | heldButton = 0; |
223 | emit activate(button, FALSE); | 226 | emit activate(button, FALSE); |
224 | } | 227 | } |
225 | QWSServer::screenSaverActivate(FALSE); | 228 | QWSServer::screenSaverActivate(FALSE); |
226 | return TRUE; | 229 | return TRUE; |
227 | } | 230 | } |
228 | return false; | 231 | return false; |
229 | } | 232 | } |
230 | if ( keycode == HardKey_Suspend ) { | 233 | if ( keycode == HardKey_Suspend ) { |
231 | if ( press ) emit power(); | 234 | if ( press ) emit power(); |
232 | return TRUE; | 235 | return TRUE; |
233 | } | 236 | } |
234 | if ( keycode == HardKey_Backlight ) { | 237 | if ( keycode == HardKey_Backlight ) { |
235 | if ( press ) emit backlight(); | 238 | if ( press ) emit backlight(); |
236 | return TRUE; | 239 | return TRUE; |
237 | } | 240 | } |
238 | if ( keycode == Key_F32 ) { | 241 | if ( keycode == Key_F32 ) { |
239 | #ifndef QT_NO_COP | 242 | #ifndef QT_NO_COP |
240 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 243 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
241 | #endif | 244 | #endif |
242 | return TRUE; | 245 | return TRUE; |
243 | } | 246 | } |
244 | if ( keycode == Key_F31 ) { | 247 | if ( keycode == Key_F31 ) { |
245 | if ( press ) emit symbol(); | 248 | if ( press ) emit symbol(); |
246 | QWSServer::screenSaverActivate(FALSE); | 249 | QWSServer::screenSaverActivate(FALSE); |
247 | return TRUE; | 250 | return TRUE; |
248 | } | 251 | } |
249 | 252 | ||
250 | if ( keycode == Key_NumLock ) | 253 | if ( keycode == Key_NumLock ) |
251 | if ( press ) emit numLockStateToggle(); | 254 | if ( press ) emit numLockStateToggle(); |
252 | 255 | ||
253 | if ( keycode == Key_CapsLock ) | 256 | if ( keycode == Key_CapsLock ) |
254 | if ( press ) emit capsLockStateToggle(); | 257 | if ( press ) emit capsLockStateToggle(); |
255 | 258 | ||
256 | if ( serverApp ) | 259 | if ( serverApp ) |
257 | serverApp->keyClick(keycode,press,autoRepeat); | 260 | serverApp->keyClick(keycode,press,autoRepeat); |
258 | 261 | ||
259 | return FALSE; | 262 | return FALSE; |
260 | } | 263 | } |
261 | 264 | ||
262 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 265 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
263 | 266 | ||
264 | #if defined(QPE_HAVE_MEMALERTER) | 267 | #if defined(QPE_HAVE_MEMALERTER) |
265 | QPE_MEMALERTER_IMPL | 268 | QPE_MEMALERTER_IMPL |
266 | #endif | 269 | #endif |
267 | 270 | ||
268 | 271 | ||
269 | 272 | ||
270 | //--------------------------------------------------------------------------- | 273 | //--------------------------------------------------------------------------- |
271 | 274 | ||
272 | bool ServerApplication::doRestart = FALSE; | 275 | bool ServerApplication::doRestart = FALSE; |
273 | bool ServerApplication::allowRestart = TRUE; | 276 | bool ServerApplication::allowRestart = TRUE; |
274 | bool ServerApplication::ms_is_starting = TRUE; | 277 | bool ServerApplication::ms_is_starting = TRUE; |
275 | 278 | ||
276 | void ServerApplication::switchLCD( bool on ) | 279 | void ServerApplication::switchLCD( bool on ) |
277 | { | 280 | { |
278 | if ( !qApp ) | 281 | if ( !qApp ) |
279 | return; | 282 | return; |
280 | 283 | ||
281 | ServerApplication *dapp = ServerApplication::me() ; | 284 | ServerApplication *dapp = ServerApplication::me() ; |
282 | 285 | ||
283 | if ( !dapp-> m_screensaver ) | 286 | if ( !dapp-> m_screensaver ) |
284 | return; | 287 | return; |
285 | 288 | ||
286 | if ( on ) { | 289 | if ( on ) { |
287 | dapp-> m_screensaver-> setDisplayState ( true ); | 290 | dapp-> m_screensaver-> setDisplayState ( true ); |
288 | dapp-> m_screensaver-> setBacklight ( -3 ); | 291 | dapp-> m_screensaver-> setBacklight ( -3 ); |
289 | } else | 292 | } else |
290 | dapp-> m_screensaver-> setDisplayState ( false ); | 293 | dapp-> m_screensaver-> setDisplayState ( false ); |
291 | 294 | ||
292 | 295 | ||
293 | } | 296 | } |
294 | 297 | ||
295 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 298 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |