-rw-r--r-- | core/launcher/server.cpp | 210 |
1 files changed, 106 insertions, 104 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 42186d3..15cd686 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp @@ -143,49 +143,49 @@ Server::Server() : last_today_show = QDate::currentDate(); #warning FIXME support TempScreenSaverMode #if 0 tsmMonitor = new TempScreenSaverMode(); connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); #endif serverGui = new Launcher; serverGui->createGUI(); docList = new DocumentList( serverGui ); appLauncher = new AppLauncher(this); connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); storage = new StorageInfo( this ); connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); #ifdef QPE_HAVE_DIRECT_ACCESS QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), - this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); + this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); #endif // start services startTransferServer(); (void) new IrServer( this ); packageHandler = new PackageHandler( this ); connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); setGeometry( -10, -10, 9, 9 ); QCopChannel *channel = new QCopChannel("QPE/System", this); connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); preloadApps(); @@ -195,62 +195,62 @@ void Server::show() { ServerApplication::login(TRUE); QWidget::show(); } Server::~Server() { serverGui->destroyGUI(); delete docList; delete qcopBridge; delete transferServer; delete serverGui; #if 0 delete tsmMonitor; #endif } static bool hasVisibleWindow(const QString& clientname, bool partial) { #ifdef QWS const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { - if ( w->client()->identity() == clientname ) { - if ( partial && !w->isFullyObscured() ) - return TRUE; - if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { + if ( w->client()->identity() == clientname ) { + if ( partial && !w->isFullyObscured() ) + return TRUE; + if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { # if QT_VERSION < 0x030000 - QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, - QSize(qt_screen->width(),qt_screen->height()) ); + QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, + QSize(qt_screen->width(),qt_screen->height()) ); # else - QRect mwr = qt_maxWindowRect; + QRect mwr = qt_maxWindowRect; # endif - if ( mwr.contains(w->requested().boundingRect()) ) - return TRUE; - } - } + if ( mwr.contains(w->requested().boundingRect()) ) + return TRUE; + } + } } #endif return FALSE; } void Server::activate(const ODeviceButton* button, bool held) { Global::terminateBuiltin("calibrate"); // No tr OQCopMessage om; if ( held ) { om = button->heldAction(); } else { om = button->pressedAction(); } if ( om.channel() != "ignore" ) om.send(); // A button with no action defined, will return a null ServiceRequest. Don't attempt // to send/do anything with this as it will crash /* ### FIXME */ #if 0 if ( !sr.isNull() ) { QString app = sr.app(); @@ -321,48 +321,50 @@ bool Server::setKeyboardLayout( const QString &kb ) #endif void Server::systemMsg(const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "securityChanged()" ) { if ( transferServer ) transferServer->authorizeConnections(); if ( qcopBridge ) qcopBridge->authorizeConnections(); #warning FIXME support TempScreenSaverMode #if 0 } else if ( msg == "setTempScreenSaverMode(int,int)" ) { int mode, pid; stream >> mode >> pid; tsmMonitor->setTempMode(mode, pid); #endif } else if ( msg == "linkChanged(QString)" ) { QString link; stream >> link; odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; docList->linkChanged(link); + } else if (msg =="reforceDocuments()") { + docList->reforceDocuments(); } else if ( msg == "serviceChanged(QString)" ) { MimeType::updateApplications(); } else if ( msg == "mkdir(QString)" ) { QString dir; stream >> dir; if ( !dir.isEmpty() ) mkdir( dir ); } else if ( msg == "rdiffGenSig(QString,QString)" ) { QString baseFile, sigFile; stream >> baseFile >> sigFile; QRsync::generateSignature( baseFile, sigFile ); } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { QString baseFile, sigFile, deltaFile; stream >> baseFile >> sigFile >> deltaFile; QRsync::generateDiff( baseFile, sigFile, deltaFile ); } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { QString baseFile, deltaFile; stream >> baseFile >> deltaFile; if ( !QFile::exists( baseFile ) ) { QFile f( baseFile ); f.open( IO_WriteOnly ); f.close(); } QRsync::applyDiff( baseFile, deltaFile ); @@ -411,89 +413,89 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) QString homeDir = getenv("HOME"); QString homeFs, homeFsPath; for ( ; it.current(); ++it ) { int k4 = (*it)->blockSize()/256; if ( (*it)->isRemovable() ) { s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr + QString::number( (*it)->availBlocks() * k4/4 ) + "K " + (*it)->options() + ";"; } else if ( homeDir.contains( (*it)->path() ) && (*it)->path().length() > homeFsPath.length() ) { homeFsPath = (*it)->path(); homeFs = (*it)->name() + "=" + homeDir + "/Documents " // No tr + QString::number( (*it)->availBlocks() * k4/4 ) + "K " + (*it)->options() + ";"; } } if ( !homeFs.isEmpty() ) s += homeFs; #ifndef QT_NO_COP e << s; #endif } else if ( msg == "sendInstallLocations()" ) { #ifndef QT_NO_COP - QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); - e << installLocationsString(); + QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); + e << installLocationsString(); #endif } else if ( msg == "sendSyncDate(QString)" ) { QString app; stream >> app; Config cfg( "qpe" ); cfg.setGroup("SyncDate"); #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); e << app << cfg.readEntry( app ); #endif //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " // << cfg.readEntry( app ).latin1() << oendl; } else if ( msg == "setSyncDate(QString,QString)" ) { QString app, date; stream >> app >> date; Config cfg( "qpe" ); cfg.setGroup("SyncDate"); cfg.writeEntry( app, date ); //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; } else if ( msg == "startSync(QString)" ) { QString what; stream >> what; delete syncDialog; syncDialog = new SyncDialog( this, what ); syncDialog->show(); connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); } else if ( msg == "stopSync()") { delete syncDialog; syncDialog = 0; } else if (msg == "restoreDone(QString)") { docList->restoreDone(); } else if ( msg == "getAllDocLinks()" ) { docList->sendAllDocLinks(); } #ifdef QPE_HAVE_DIRECT_ACCESS else if ( msg == "prepareDirectAccess()" ) { - prepareDirectAccess(); + prepareDirectAccess(); } else if ( msg == "postDirectAccess()" ) { - postDirectAccess(); + postDirectAccess(); } #endif #ifdef Q_WS_QWS else if ( msg == "setMouseProto(QString)" ) { QString mice; stream >> mice; setenv("QWS_MOUSE_PROTO",mice.latin1(),1); qwsServer->openMouse(); } else if ( msg == "setKeyboard(QString)" ) { QString kb; stream >> kb; setenv("QWS_KEYBOARD",kb.latin1(),1); qwsServer->openKeyboard(); } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { int delay, period; stream >> delay >> period; qwsSetKeyboardAutoRepeat( delay, period ); Config cfg( "qpe" ); cfg.setGroup("Keyboard"); cfg.writeEntry( "RepeatDelay", delay ); cfg.writeEntry( "RepeatPeriod", period ); } else if ( msg == "setKeyboardLayout(QString)" ) { QString kb; @@ -536,92 +538,92 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) stream >> modifier >> appName >> delay; Config cfg( "autostart" ); cfg.setGroup( "AutoStart" ); if ( modifier.compare("add") == 0 ){ // only add it appname is entered if (!appName.isEmpty()) { cfg.writeEntry("Apps", appName); cfg.writeEntry("Delay", delay); } } } #endif } QString Server::cardInfoString() { storage->update(); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString homeFs, homeFsPath; for ( ; it.current(); ++it ) { - int k4 = (*it)->blockSize()/256; - if ( (*it)->isRemovable() ) { - s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } else if ( homeDir.contains( (*it)->path() ) && - (*it)->path().length() > homeFsPath.length() ) { - homeFsPath = (*it)->path(); - homeFs = - (*it)->name() + "=" + homeDir + "/Documents " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } + int k4 = (*it)->blockSize()/256; + if ( (*it)->isRemovable() ) { + s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } else if ( homeDir.contains( (*it)->path() ) && + (*it)->path().length() > homeFsPath.length() ) { + homeFsPath = (*it)->path(); + homeFs = + (*it)->name() + "=" + homeDir + "/Documents " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } } if ( !homeFs.isEmpty() ) - s += homeFs; + s += homeFs; return s; } QString Server::installLocationsString() { storage->update(); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString homeFs, homeFsPath; for ( ; it.current(); ++it ) { - int k4 = (*it)->blockSize()/256; - if ( (*it)->isRemovable() ) { - s += (*it)->name() + "=" + (*it)->path() + " " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } else if ( homeDir.contains( (*it)->path() ) && - (*it)->path().length() > homeFsPath.length() ) { - homeFsPath = (*it)->path(); - homeFs = - (*it)->name() + "=" + homeDir + " " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } + int k4 = (*it)->blockSize()/256; + if ( (*it)->isRemovable() ) { + s += (*it)->name() + "=" + (*it)->path() + " " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } else if ( homeDir.contains( (*it)->path() ) && + (*it)->path().length() > homeFsPath.length() ) { + homeFsPath = (*it)->path(); + homeFs = + (*it)->name() + "=" + homeDir + " " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } } if ( !homeFs.isEmpty() ) - s = homeFs + s; + s = homeFs + s; return s; } void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "reloadApps()" ) { docList->reloadAppLnks(); } else if ( msg == "soundAlarm()" ) { ServerApplication::soundAlarm(); } else if ( msg == "setLed(int,bool)" ) { int led, status; stream >> led >> status; QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); if ( ll. count ( )) { OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); } } } @@ -803,182 +805,182 @@ void Server::preloadApps() Config cfg("Launcher"); cfg.setGroup("Preload"); QStringList apps = cfg.readListEntry("Apps",','); for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { #ifndef QT_NO_COP QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); #endif } } // This is only called if QPE_HAVE_DIRECT_ACCESS is defined void Server::prepareDirectAccess() { qDebug( "Server::prepareDirectAccess()" ); // Put up a pretty dialog syncDialog = new SyncDialog( this, tr("USB Lock") ); syncDialog->show(); // Prevent the PDA from acting as a PDA terminateServers(); // suspend the mtab monitor #ifndef QT_NO_COP { - QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); + QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); } #endif // send out a flush message // once flushes are done call runDirectAccess() // We just count the number of apps and set a timer. // Either the timer expires or the correct number of apps responds. // Note: quicklauncher isn't in the runningApps list but it responds // to the flush so we start the counter at 1 pendingFlushes = 1; directAccessRun = FALSE; for ( QMap<int,QString>::ConstIterator it = - appLauncher->runningApplications().begin(); - it != appLauncher->runningApplications().end(); - ++it ) { - pendingFlushes++; + appLauncher->runningApplications().begin(); + it != appLauncher->runningApplications().end(); + ++it ) { + pendingFlushes++; } #ifndef QT_NO_COP QCopEnvelope e1( "QPE/System", "flush()" ); #endif QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); #warning FIXME support TempScreenSaverMode #if 0 QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); #endif } // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined // It fakes the presence of Qtopia Desktop void Server::desktopMessage( const QCString &message, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( message == "flushDone(QString)" ) { - QString app; - stream >> app; - qDebug( "flushDone from %s", app.latin1() ); - if ( --pendingFlushes == 0 ) { - qDebug( "pendingFlushes == 0, all the apps responded" ); - runDirectAccess(); - } + QString app; + stream >> app; + qDebug( "flushDone from %s", app.latin1() ); + if ( --pendingFlushes == 0 ) { + qDebug( "pendingFlushes == 0, all the apps responded" ); + runDirectAccess(); + } } else if ( message == "installStarted(QString)" ) { - QString package; - stream >> package; - qDebug( "\tInstall Started for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tInstall Started for package %s", package.latin1() ); } else if ( message == "installStep(QString)" ) { - QString step; - stream >> step; - qDebug( "\tInstall Step %s", step.latin1() ); + QString step; + stream >> step; + qDebug( "\tInstall Step %s", step.latin1() ); } else if ( message == "installDone(QString)" ) { - QString package; - stream >> package; - qDebug( "\tInstall Finished for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tInstall Finished for package %s", package.latin1() ); } else if ( message == "installFailed(QString,int,QString)" ) { - QString package, error; - int status; - stream >> package >> status >> error; - qDebug( "\tInstall Failed for package %s with error code %d and error message %s", - package.latin1(), status, error.latin1() ); + QString package, error; + int status; + stream >> package >> status >> error; + qDebug( "\tInstall Failed for package %s with error code %d and error message %s", + package.latin1(), status, error.latin1() ); } else if ( message == "removeStarted(QString)" ) { - QString package; - stream >> package; - qDebug( "\tRemove Started for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tRemove Started for package %s", package.latin1() ); } else if ( message == "removeDone(QString)" ) { - QString package; - stream >> package; - qDebug( "\tRemove Finished for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tRemove Finished for package %s", package.latin1() ); } else if ( message == "removeFailed(QString)" ) { - QString package; - stream >> package; - qDebug( "\tRemove Failed for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tRemove Failed for package %s", package.latin1() ); } if ( qrr && qrr->waitingForMessages ) - qrr->desktopMessage( message, data ); + qrr->desktopMessage( message, data ); } // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined void Server::runDirectAccess() { #ifdef QPE_HAVE_DIRECT_ACCESS // The timer must have fired after all the apps responded // with flushDone(). Just ignore it. if ( directAccessRun ) - return; + return; directAccessRun = TRUE; ::readyDirectAccess(cardInfoString(), installLocationsString()); #endif } // This is only called if QPE_HAVE_DIRECT_ACCESS is defined void Server::postDirectAccess() { #ifdef QPE_HAVE_DIRECT_ACCESS qDebug( "Server::postDirectAccess()" ); // Categories may have changed QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); // Apps need to reload their data QCopEnvelope e2( "QPE/System", "reload()" ); // Reload DocLinks docList->storageChanged(); // Restart the PDA server stuff startTransferServer(); // restart the mtab monitor #ifndef QT_NO_COP { - QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); + QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); } #endif // Process queued requests const char *queueFile = ::directAccessQueueFile(); QFile *file = new QFile( queueFile ); if ( !file->exists() ) { - delete file; - // Get rid of the dialog - if ( syncDialog ) { - delete syncDialog; - syncDialog = 0; - } + delete file; + // Get rid of the dialog + if ( syncDialog ) { + delete syncDialog; + syncDialog = 0; + } #warning FIXME support TempScreenSaverMode #if 0 - QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); + QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); #endif } else { - qrr = new QueuedRequestRunner( file, syncDialog ); - connect( qrr, SIGNAL(finished()), - this, SLOT(finishedQueuedRequests()) ); - QTimer::singleShot( 100, qrr, SLOT(process()) ); - // qrr will remove the sync dialog later + qrr = new QueuedRequestRunner( file, syncDialog ); + connect( qrr, SIGNAL(finished()), + this, SLOT(finishedQueuedRequests()) ); + QTimer::singleShot( 100, qrr, SLOT(process()) ); + // qrr will remove the sync dialog later } #endif } void Server::finishedQueuedRequests() { if ( qrr->readyToDelete ) { - delete qrr; - qrr = 0; - // Get rid of the dialog - if ( syncDialog ) { - delete syncDialog; - syncDialog = 0; - } + delete qrr; + qrr = 0; + // Get rid of the dialog + if ( syncDialog ) { + delete syncDialog; + syncDialog = 0; + } #warning FIXME support TempScreenSaverMode #if 0 - QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); + QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); #endif } else { - qrr->readyToDelete = TRUE; - QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); + qrr->readyToDelete = TRUE; + QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); } } |