-rw-r--r-- | core/launcher/server.cpp | 22 | ||||
-rw-r--r-- | core/launcher/server.h | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 15cd686..921b790 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp @@ -1,265 +1,270 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "server.h" #include "serverapp.h" #include "startmenu.h" #include "launcher.h" #include "transferserver.h" #include "qcopbridge.h" #include "irserver.h" #include "packageslave.h" #include "calibrate.h" #include "qrsync.h" #include "syncdialog.h" #include "shutdownimpl.h" #include "applauncher.h" #if 0 #include "suspendmonitor.h" #endif #include "documentlist.h" #include "qrr.h" /* OPIE */ #include <opie2/odebug.h> #include <opie2/odevicebutton.h> #include <opie2/odevice.h> +#include <opie2/oprocess.h> + #include <qtopia/applnk.h> #include <qtopia/private/categories.h> #include <qtopia/mimetype.h> #include <qtopia/config.h> #include <qtopia/resource.h> #include <qtopia/version.h> #include <qtopia/storage.h> #include <qtopia/qcopenvelope_qws.h> #include <qtopia/global.h> using namespace Opie::Core; /* QT */ #include <qmainwindow.h> #include <qmessagebox.h> #include <qtimer.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> #include <qgfx_qws.h> /* STD */ #include <unistd.h> #include <stdlib.h> extern QRect qt_maxWindowRect; static QWidget *calibrate(bool) { #ifdef Q_WS_QWS Calibrate *c = new Calibrate; c->show(); return c; #else return 0; #endif } #define FACTORY(T) \ static QWidget *new##T( bool maximized ) { \ QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ if ( maximized ) { \ if ( qApp->desktop()->width() <= 350 ) { \ w->showMaximized(); \ } else { \ w->resize( QSize( 300, 300 ) ); \ } \ } \ w->show(); \ return w; \ } #ifdef SINGLE_APP #define APP(a,b,c,d) FACTORY(b) #include "apps.h" #undef APP #endif // SINGLE_APP static Global::Command builtins[] = { #ifdef SINGLE_APP #define APP(a,b,c,d) { a, new##b, c, d }, #include "apps.h" #undef APP #endif /* FIXME defines need to be defined*/ #if !defined(OPIE_NO_BUILTIN_CALIBRATE) { "calibrate", calibrate, 1, 0 }, // No tr #endif #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) { "shutdown", Global::shutdown, 1, 0 }, // No tr // { "run", run, 1, 0 }, // No tr #endif { 0, calibrate, 0, 0 }, }; #ifdef QPE_HAVE_DIRECT_ACCESS extern void readyDirectAccess(QString cardInfo, QString installLocations); extern const char *directAccessQueueFile(); #endif //--------------------------------------------------------------------------- //=========================================================================== Server::Server() : QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), qcopBridge( 0 ), transferServer( 0 ), packageHandler( 0 ), - syncDialog( 0 ) + syncDialog( 0 ), + process( 0 ) { Global::setBuiltinCommands(builtins); tid_xfer = 0; /* ### FIXME ### */ /* tid_today = startTimer(3600*2*1000);*/ 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 & )) ); #endif + soundServerExited(); + // 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(); } 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 QT_VERSION < 0x030000 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, QSize(qt_screen->width(),qt_screen->height()) ); # else QRect mwr = qt_maxWindowRect; # endif 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(); bool vis = hasVisibleWindow(app, app != "qpe"); if ( sr.message() == "raise()" && vis ) { sr.setMessage("nextView()"); } else { // "back door" sr << (int)vis; } sr.send(); @@ -891,96 +896,111 @@ void Server::desktopMessage( const QCString &message, const QByteArray &data ) 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() ); } else if ( message == "removeFailed(QString)" ) { QString package; stream >> package; qDebug( "\tRemove Failed for package %s", package.latin1() ); } if ( qrr && qrr->waitingForMessages ) 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; 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()" ); } #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; } #warning FIXME support TempScreenSaverMode #if 0 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 } #endif } void Server::finishedQueuedRequests() { if ( qrr->readyToDelete ) { 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); #endif } else { qrr->readyToDelete = TRUE; QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); } } +void Server::startSoundServer() { + if ( !process ) { + process = new Opie::Core::OProcess( this ); + connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), + SLOT(soundServerExited())); + } + + process->clearArguments(); + *process << QPEApplication::qpeDir() + "bin/qss"; + process->start(); +} + +void Server::soundServerExited() { + QTimer::singleShot(5000, this, SLOT(startSoundServer())); +} diff --git a/core/launcher/server.h b/core/launcher/server.h index d71d68a..5b2f995 100644 --- a/core/launcher/server.h +++ b/core/launcher/server.h @@ -1,111 +1,118 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef DESKTOP_H #define DESKTOP_H #include <qwidget.h> #include <qdatetime.h> //#include "qcopbridge.h" class QCopBridge; class QHostAddress; class TransferServer; class PackageHandler; class ServiceRequest; class TempScreenSaverMonitor; class AppLauncher; class AppLnkSet; class StorageInfo; class SyncDialog; class DocumentList; class ServerInterface; class QueuedRequestRunner; namespace Opie { namespace Core { class ODeviceButton; + class OProcess; } } class Server : public QWidget { Q_OBJECT public: Server(); ~Server(); static bool mkdir(const QString &path); void show(); static bool setKeyboardLayout( const QString &kb ); public slots: void systemMsg(const QCString &, const QByteArray &); void receiveTaskBar(const QCString &msg, const QByteArray &data); void terminateServers(); void pokeTimeMonitors(); private slots: + //@{ + void startSoundServer(); + void soundServerExited(); + //@} void activate(const Opie::Core::ODeviceButton*,bool); void syncConnectionClosed( const QHostAddress & ); void applicationLaunched(int pid, const QString &app); void applicationTerminated(int pid, const QString &app); void applicationConnected(const QString &app); void storageChanged(); void cancelSync(); void desktopMessage( const QCString &, const QByteArray & ); void runDirectAccess(); void finishedQueuedRequests(); protected: void styleChange( QStyle & ); void timerEvent( QTimerEvent *e ); private: void layout(); void startTransferServer(); void preloadApps(); void prepareDirectAccess(); void postDirectAccess(); QString cardInfoString(); QString installLocationsString(); QCopBridge *qcopBridge; TransferServer *transferServer; PackageHandler *packageHandler; QDate last_today_show; int tid_xfer; /* ### FIXME two below### */ // int tid_today; // TempScreenSaverMonitor *tsmMonitor; StorageInfo *storage; SyncDialog *syncDialog; AppLauncher *appLauncher; DocumentList *docList; ServerInterface *serverGui; int pendingFlushes; bool directAccessRun; QueuedRequestRunner *qrr; + + Opie::Core::OProcess *process; }; #endif // DESKTOP_H |