summaryrefslogtreecommitdiff
path: root/core/launcher/server.cpp
Unidiff
Diffstat (limited to 'core/launcher/server.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/server.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 9a86a80..b9fa1e5 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -15,77 +15,77 @@
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 38
39/* OPIE */
40#include <opie2/odebug.h>
41#include <opie2/odevicebutton.h>
42#include <opie2/odevice.h>
39#include <qtopia/applnk.h> 43#include <qtopia/applnk.h>
40#include <qtopia/private/categories.h> 44#include <qtopia/private/categories.h>
41#include <qtopia/mimetype.h> 45#include <qtopia/mimetype.h>
42#include <qtopia/config.h> 46#include <qtopia/config.h>
43#include <qtopia/resource.h> 47#include <qtopia/resource.h>
44#include <qtopia/version.h> 48#include <qtopia/version.h>
45#include <qtopia/storage.h> 49#include <qtopia/storage.h>
46
47#include <qtopia/qcopenvelope_qws.h> 50#include <qtopia/qcopenvelope_qws.h>
48#include <qwindowsystem_qws.h>
49#include <qgfx_qws.h>
50#include <qtopia/global.h> 51#include <qtopia/global.h>
51//#include <qtopia/custom.h> 52using namespace Opie::Core;
52
53#include <opie2/odevicebutton.h>
54#include <opie2/odevice.h>
55 53
56#include <unistd.h> 54/* QT */
57#include <qmainwindow.h> 55#include <qmainwindow.h>
58#include <qmessagebox.h> 56#include <qmessagebox.h>
59#include <qtimer.h> 57#include <qtimer.h>
60#include <qtextstream.h> 58#include <qtextstream.h>
59#include <qwindowsystem_qws.h>
60#include <qgfx_qws.h>
61 61
62/* STD */
63#include <unistd.h>
62#include <stdlib.h> 64#include <stdlib.h>
63 65
64extern QRect qt_maxWindowRect; 66extern QRect qt_maxWindowRect;
65 67
66
67using namespace Opie::Core;
68static QWidget *calibrate(bool) 68static QWidget *calibrate(bool)
69{ 69{
70#ifdef Q_WS_QWS 70#ifdef Q_WS_QWS
71 Calibrate *c = new Calibrate; 71 Calibrate *c = new Calibrate;
72 c->show(); 72 c->show();
73 return c; 73 return c;
74#else 74#else
75 return 0; 75 return 0;
76#endif 76#endif
77} 77}
78 78
79#define FACTORY(T) \ 79#define FACTORY(T) \
80 static QWidget *new##T( bool maximized ) { \ 80 static QWidget *new##T( bool maximized ) { \
81 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 81 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
82 if ( maximized ) { \ 82 if ( maximized ) { \
83 if ( qApp->desktop()->width() <= 350 ) { \ 83 if ( qApp->desktop()->width() <= 350 ) { \
84 w->showMaximized(); \ 84 w->showMaximized(); \
85 } else { \ 85 } else { \
86 w->resize( QSize( 300, 300 ) ); \ 86 w->resize( QSize( 300, 300 ) ); \
87 } \ 87 } \
88 } \ 88 } \
89 w->show(); \ 89 w->show(); \
90 return w; \ 90 return w; \
91 } 91 }
@@ -308,49 +308,49 @@ bool Server::setKeyboardLayout( const QString &kb )
308 308
309#endif 309#endif
310 310
311void Server::systemMsg(const QCString &msg, const QByteArray &data) 311void Server::systemMsg(const QCString &msg, const QByteArray &data)
312{ 312{
313 QDataStream stream( data, IO_ReadOnly ); 313 QDataStream stream( data, IO_ReadOnly );
314 314
315 if ( msg == "securityChanged()" ) { 315 if ( msg == "securityChanged()" ) {
316 if ( transferServer ) 316 if ( transferServer )
317 transferServer->authorizeConnections(); 317 transferServer->authorizeConnections();
318 if ( qcopBridge ) 318 if ( qcopBridge )
319 qcopBridge->authorizeConnections(); 319 qcopBridge->authorizeConnections();
320 } 320 }
321 /* ### FIXME support TempScreenSaverMode */ 321 /* ### FIXME support TempScreenSaverMode */
322#if 0 322#if 0
323 else if ( msg == "setTempScreenSaverMode(int,int)" ) { 323 else if ( msg == "setTempScreenSaverMode(int,int)" ) {
324 int mode, pid; 324 int mode, pid;
325 stream >> mode >> pid; 325 stream >> mode >> pid;
326 tsmMonitor->setTempMode(mode, pid); 326 tsmMonitor->setTempMode(mode, pid);
327 } 327 }
328#endif 328#endif
329 else if ( msg == "linkChanged(QString)" ) { 329 else if ( msg == "linkChanged(QString)" ) {
330 QString link; 330 QString link;
331 stream >> link; 331 stream >> link;
332 qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); 332 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl;
333 docList->linkChanged(link); 333 docList->linkChanged(link);
334 } else if ( msg == "serviceChanged(QString)" ) { 334 } else if ( msg == "serviceChanged(QString)" ) {
335 MimeType::updateApplications(); 335 MimeType::updateApplications();
336 } else if ( msg == "mkdir(QString)" ) { 336 } else if ( msg == "mkdir(QString)" ) {
337 QString dir; 337 QString dir;
338 stream >> dir; 338 stream >> dir;
339 if ( !dir.isEmpty() ) 339 if ( !dir.isEmpty() )
340 mkdir( dir ); 340 mkdir( dir );
341 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 341 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
342 QString baseFile, sigFile; 342 QString baseFile, sigFile;
343 stream >> baseFile >> sigFile; 343 stream >> baseFile >> sigFile;
344 QRsync::generateSignature( baseFile, sigFile ); 344 QRsync::generateSignature( baseFile, sigFile );
345 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 345 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
346 QString baseFile, sigFile, deltaFile; 346 QString baseFile, sigFile, deltaFile;
347 stream >> baseFile >> sigFile >> deltaFile; 347 stream >> baseFile >> sigFile >> deltaFile;
348 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 348 QRsync::generateDiff( baseFile, sigFile, deltaFile );
349 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 349 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
350 QString baseFile, deltaFile; 350 QString baseFile, deltaFile;
351 stream >> baseFile >> deltaFile; 351 stream >> baseFile >> deltaFile;
352 if ( !QFile::exists( baseFile ) ) { 352 if ( !QFile::exists( baseFile ) ) {
353 QFile f( baseFile ); 353 QFile f( baseFile );
354 f.open( IO_WriteOnly ); 354 f.open( IO_WriteOnly );
355 f.close(); 355 f.close();
356 } 356 }
@@ -413,49 +413,49 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data)
413 } 413 }
414 if ( !homeFs.isEmpty() ) 414 if ( !homeFs.isEmpty() )
415 s += homeFs; 415 s += homeFs;
416 416
417#ifndef QT_NO_COP 417#ifndef QT_NO_COP
418 e << s; 418 e << s;
419#endif 419#endif
420 } else if ( msg == "sendSyncDate(QString)" ) { 420 } else if ( msg == "sendSyncDate(QString)" ) {
421 QString app; 421 QString app;
422 stream >> app; 422 stream >> app;
423 Config cfg( "qpe" ); 423 Config cfg( "qpe" );
424 cfg.setGroup("SyncDate"); 424 cfg.setGroup("SyncDate");
425#ifndef QT_NO_COP 425#ifndef QT_NO_COP
426 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 426 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
427 e << app << cfg.readEntry( app ); 427 e << app << cfg.readEntry( app );
428#endif 428#endif
429 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 429 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
430 //cfg.readEntry( app ).latin1() ); 430 //cfg.readEntry( app ).latin1() );
431 } else if ( msg == "setSyncDate(QString,QString)" ) { 431 } else if ( msg == "setSyncDate(QString,QString)" ) {
432 QString app, date; 432 QString app, date;
433 stream >> app >> date; 433 stream >> app >> date;
434 Config cfg( "qpe" ); 434 Config cfg( "qpe" );
435 cfg.setGroup("SyncDate"); 435 cfg.setGroup("SyncDate");
436 cfg.writeEntry( app, date ); 436 cfg.writeEntry( app, date );
437 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 437 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl;
438 } else if ( msg == "startSync(QString)" ) { 438 } else if ( msg == "startSync(QString)" ) {
439 QString what; 439 QString what;
440 stream >> what; 440 stream >> what;
441 delete syncDialog; 441 delete syncDialog;
442 syncDialog = new SyncDialog( this, what ); 442 syncDialog = new SyncDialog( this, what );
443 syncDialog->show(); 443 syncDialog->show();
444 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); 444 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) );
445 } else if ( msg == "stopSync()") { 445 } else if ( msg == "stopSync()") {
446 delete syncDialog; 446 delete syncDialog;
447 syncDialog = 0; 447 syncDialog = 0;
448 } else if (msg == "restoreDone(QString)") { 448 } else if (msg == "restoreDone(QString)") {
449 docList->restoreDone(); 449 docList->restoreDone();
450 } else if ( msg == "getAllDocLinks()" ) { 450 } else if ( msg == "getAllDocLinks()" ) {
451 docList->sendAllDocLinks(); 451 docList->sendAllDocLinks();
452 } 452 }
453#ifdef Q_WS_QWS 453#ifdef Q_WS_QWS
454 else if ( msg == "setMouseProto(QString)" ) { 454 else if ( msg == "setMouseProto(QString)" ) {
455 QString mice; 455 QString mice;
456 stream >> mice; 456 stream >> mice;
457 setenv("QWS_MOUSE_PROTO",mice.latin1(),1); 457 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
458 qwsServer->openMouse(); 458 qwsServer->openMouse();
459 } else if ( msg == "setKeyboard(QString)" ) { 459 } else if ( msg == "setKeyboard(QString)" ) {
460 QString kb; 460 QString kb;
461 stream >> kb; 461 stream >> kb;
@@ -551,69 +551,69 @@ void Server::cancelSync()
551{ 551{
552#ifndef QT_NO_COP 552#ifndef QT_NO_COP
553 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 553 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
554#endif 554#endif
555 delete syncDialog; 555 delete syncDialog;
556 syncDialog = 0; 556 syncDialog = 0;
557} 557}
558 558
559bool Server::mkdir(const QString &localPath) 559bool Server::mkdir(const QString &localPath)
560{ 560{
561 QDir fullDir(localPath); 561 QDir fullDir(localPath);
562 if (fullDir.exists()) 562 if (fullDir.exists())
563 return true; 563 return true;
564 564
565 // at this point the directory doesn't exist 565 // at this point the directory doesn't exist
566 // go through the directory tree and start creating the direcotories 566 // go through the directory tree and start creating the direcotories
567 // that don't exist; if we can't create the directories, return false 567 // that don't exist; if we can't create the directories, return false
568 568
569 QString dirSeps = "/"; 569 QString dirSeps = "/";
570 int dirIndex = localPath.find(dirSeps); 570 int dirIndex = localPath.find(dirSeps);
571 QString checkedPath; 571 QString checkedPath;
572 572
573 // didn't find any seps; weird, use the cur dir instead 573 // didn't find any seps; weird, use the cur dir instead
574 if (dirIndex == -1) { 574 if (dirIndex == -1) {
575 //qDebug("No seperators found in path %s", localPath.latin1()); 575 //odebug << "No seperators found in path " << localPath << "" << oendl;
576 checkedPath = QDir::currentDirPath(); 576 checkedPath = QDir::currentDirPath();
577 } 577 }
578 578
579 while (checkedPath != localPath) { 579 while (checkedPath != localPath) {
580 // no more seperators found, use the local path 580 // no more seperators found, use the local path
581 if (dirIndex == -1) 581 if (dirIndex == -1)
582 checkedPath = localPath; 582 checkedPath = localPath;
583 else { 583 else {
584 // the next directory to check 584 // the next directory to check
585 checkedPath = localPath.left(dirIndex) + "/"; 585 checkedPath = localPath.left(dirIndex) + "/";
586 // advance the iterator; the next dir seperator 586 // advance the iterator; the next dir seperator
587 dirIndex = localPath.find(dirSeps, dirIndex+1); 587 dirIndex = localPath.find(dirSeps, dirIndex+1);
588 } 588 }
589 589
590 QDir checkDir(checkedPath); 590 QDir checkDir(checkedPath);
591 if (!checkDir.exists()) { 591 if (!checkDir.exists()) {
592 //qDebug("mkdir making dir %s", checkedPath.latin1()); 592 //odebug << "mkdir making dir " << checkedPath << "" << oendl;
593 593
594 if (!checkDir.mkdir(checkedPath)) { 594 if (!checkDir.mkdir(checkedPath)) {
595 qDebug("Unable to make directory %s", checkedPath.latin1()); 595 odebug << "Unable to make directory " << checkedPath << "" << oendl;
596 return FALSE; 596 return FALSE;
597 } 597 }
598 } 598 }
599 599
600 } 600 }
601 return TRUE; 601 return TRUE;
602} 602}
603 603
604void Server::styleChange( QStyle &s ) 604void Server::styleChange( QStyle &s )
605{ 605{
606 QWidget::styleChange( s ); 606 QWidget::styleChange( s );
607} 607}
608 608
609void Server::startTransferServer() 609void Server::startTransferServer()
610{ 610{
611 if ( !qcopBridge ) { 611 if ( !qcopBridge ) {
612 // start qcop bridge server 612 // start qcop bridge server
613 qcopBridge = new QCopBridge( 4243 ); 613 qcopBridge = new QCopBridge( 4243 );
614 if ( qcopBridge->ok() ) { 614 if ( qcopBridge->ok() ) {
615 // ... OK 615 // ... OK
616 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), 616 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)),
617 this, SLOT(syncConnectionClosed(const QHostAddress&)) ); 617 this, SLOT(syncConnectionClosed(const QHostAddress&)) );
618 } else { 618 } else {
619 delete qcopBridge; 619 delete qcopBridge;
@@ -649,49 +649,49 @@ void Server::timerEvent( QTimerEvent *e )
649 last_today_show = today; 649 last_today_show = today;
650 Config cfg("today"); 650 Config cfg("today");
651 cfg.setGroup("Start"); 651 cfg.setGroup("Start");
652#ifndef QPE_DEFAULT_TODAY_MODE 652#ifndef QPE_DEFAULT_TODAY_MODE
653#define QPE_DEFAULT_TODAY_MODE "Never" 653#define QPE_DEFAULT_TODAY_MODE "Never"
654#endif 654#endif
655 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { 655 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) {
656 QCopEnvelope env(Service::channel("today"),"raise()"); 656 QCopEnvelope env(Service::channel("today"),"raise()");
657 } 657 }
658 } 658 }
659 } 659 }
660#endif 660#endif
661} 661}
662 662
663void Server::terminateServers() 663void Server::terminateServers()
664{ 664{
665 delete transferServer; 665 delete transferServer;
666 delete qcopBridge; 666 delete qcopBridge;
667 transferServer = 0; 667 transferServer = 0;
668 qcopBridge = 0; 668 qcopBridge = 0;
669} 669}
670 670
671void Server::syncConnectionClosed( const QHostAddress & ) 671void Server::syncConnectionClosed( const QHostAddress & )
672{ 672{
673 qDebug( "Lost sync connection" ); 673 odebug << "Lost sync connection" << oendl;
674 delete syncDialog; 674 delete syncDialog;
675 syncDialog = 0; 675 syncDialog = 0;
676} 676}
677 677
678void Server::pokeTimeMonitors() 678void Server::pokeTimeMonitors()
679{ 679{
680#if 0 680#if 0
681 // inform all TimeMonitors 681 // inform all TimeMonitors
682 QStrList tms = Service::channels("TimeMonitor"); 682 QStrList tms = Service::channels("TimeMonitor");
683 for (const char* ch = tms.first(); ch; ch=tms.next()) { 683 for (const char* ch = tms.first(); ch; ch=tms.next()) {
684 QString t = getenv("TZ"); 684 QString t = getenv("TZ");
685 QCopEnvelope e(ch, "timeChange(QString)"); 685 QCopEnvelope e(ch, "timeChange(QString)");
686 e << t; 686 e << t;
687 } 687 }
688#endif 688#endif
689} 689}
690 690
691void Server::applicationLaunched(int, const QString &app) 691void Server::applicationLaunched(int, const QString &app)
692{ 692{
693 serverGui->applicationStateChanged( app, ServerInterface::Launching ); 693 serverGui->applicationStateChanged( app, ServerInterface::Launching );
694} 694}
695 695
696void Server::applicationTerminated(int pid, const QString &app) 696void Server::applicationTerminated(int pid, const QString &app)
697{ 697{