-rw-r--r-- | core/launcher/server.cpp | 145 | ||||
-rw-r--r-- | core/launcher/server.h | 13 |
2 files changed, 117 insertions, 41 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 08baa8e..450d8e5 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp @@ -19,69 +19,66 @@ **********************************************************************/ #include "server.h" #include "serverapp.h" #include "launcher.h" #include "startmenu.h" #include "transferserver.h" #include "qcopbridge.h" #include "irserver.h" #include "packageslave.h" #include "calibrate.h" #include "qrsync.h" #include "syncdialog.h" #include "launcher.h" #include "shutdownimpl.h" #include "applauncher.h" +#if 0 #include "suspendmonitor.h" +#endif #include "documentlist.h" #include <qtopia/applnk.h> -#include <qtopia/categories.h> +#include <qtopia/private/categories.h> #include <qtopia/mimetype.h> #include <qtopia/config.h> -#include <qtopia/services.h> -#include <qtopia/devicebuttonmanager.h> -#include <qtopia/pluginloader.h> #include <qtopia/resource.h> #include <qtopia/version.h> #include <qtopia/storage.h> -#ifdef Q_WS_QWS #include <qtopia/qcopenvelope_qws.h> #include <qwindowsystem_qws.h> #include <qgfx_qws.h> -#endif #include <qtopia/global.h> #include <qtopia/custom.h> -#ifdef Q_OS_WIN32 -#include <io.h> -#include <process.h> -#else +#include <opie/odevicebutton.h> +#include <opie/odevice.h> + #include <unistd.h> -#endif #include <qmainwindow.h> #include <qmessagebox.h> #include <qtimer.h> #include <qtextstream.h> #include <stdlib.h> extern QRect qt_maxWindowRect; +using namespace Opie; + 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 ) { \ @@ -96,164 +93,178 @@ static QWidget *calibrate(bool) #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(QPE_NEED_CALIBRATION) - { "calibrate", calibrate, 1, 0 }, // No tr + { "calibrate", calibrate, 1, 0 }, // No tr #endif #if !defined(QT_QWS_CASSIOPEIA) - { "shutdown", Global::shutdown, 1, 0 }, // No tr + { "shutdown", Global::shutdown, 1, 0 }, // No tr // { "run", run, 1, 0 }, // No tr #endif { 0, calibrate, 0, 0 }, }; //--------------------------------------------------------------------------- //=========================================================================== Server::Server() : QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), qcopBridge( 0 ), transferServer( 0 ), packageHandler( 0 ), syncDialog( 0 ) { Global::setBuiltinCommands(builtins); tid_xfer = 0; - tid_today = startTimer(3600*2*1000); + /* ### FIXME ### */ +/* tid_today = startTimer(3600*2*1000);*/ last_today_show = QDate::currentDate(); - tsmMonitor = new TempScreenSaverMonitor(); +#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()) ); // start services startTransferServer(); (void) new IrServer( this ); packageHandler = new PackageHandler( this ); - connect(qApp, SIGNAL(activate(const DeviceButton*,bool)),this,SLOT(activate(const DeviceButton*,bool))); + connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), + this,SLOT(activate(const Opie::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 DeviceButton* button, bool held) +void Server::activate(const Opie::ODeviceButton* button, bool held) { Global::terminateBuiltin("calibrate"); // No tr - ServiceRequest sr; + Opie::OQCopMessage om; if ( held ) { - sr = button->heldAction(); + om = button->heldAction(); } else { - sr = button->pressedAction(); + 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(); } +#endif } #ifdef Q_WS_QWS typedef struct KeyOverride { ushort scan_code; QWSServer::KeyMap map; }; static const KeyOverride jp109keys[] = { { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, @@ -294,37 +305,42 @@ bool Server::setKeyboardLayout( const QString &kb ) QWSServer::setOverrideKeys( om ); return TRUE; } #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(); - } else if ( msg == "setTempScreenSaverMode(int,int)" ) { + } + /* ### FIXME support TempScreenSaverMode */ +#if 0 + else if ( msg == "setTempScreenSaverMode(int,int)" ) { int mode, pid; stream >> mode >> pid; tsmMonitor->setTempMode(mode, pid); - } else if ( msg == "linkChanged(QString)" ) { + } +#endif + else if ( msg == "linkChanged(QString)" ) { QString link; stream >> link; qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); docList->linkChanged(link); } 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)" ) { @@ -347,36 +363,43 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) } else if ( msg == "rdiffCleanup()" ) { mkdir( "/tmp/rdiff" ); QDir dir; dir.setPath( "/tmp/rdiff" ); QStringList entries = dir.entryList(); for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) dir.remove( *it ); } else if ( msg == "sendHandshakeInfo()" ) { QString home = getenv( "HOME" ); #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); e << home; int locked = (int) ServerApplication::screenLocked(); e << locked; #endif - } else if ( msg == "sendVersionInfo()" ) { + } + /* + * QtopiaDesktop relies on the major number + * to start with 1. We're at 0.9 + * so wee need to fake at least 1.4 to be able + * to sync with QtopiaDesktop1.6 + */ + else if ( msg == "sendVersionInfo()" ) { QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); - QString v = QPE_VERSION; - e << Global::version() << Global::architecture(); + /* ### FIXME Architecture ### */ + e << QString::fromLatin1("1.7") << "Uncustomized Device"; } else if ( msg == "sendCardInfo()" ) { #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); #endif 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() + ";"; @@ -442,52 +465,100 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) } 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; stream >> kb; setKeyboardLayout( kb ); Config cfg( "qpe" ); cfg.setGroup("Keyboard"); cfg.writeEntry( "Layout", kb ); + } else if ( msg == "autoStart(QString)" ) { + QString appName; + stream >> appName; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( appName.compare("clear") == 0){ + cfg.writeEntry("Apps", ""); + } + } else if ( msg == "autoStart(QString,QString)" ) { + QString modifier, appName; + stream >> modifier >> appName; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( modifier.compare("add") == 0 ){ + // only add if appname is entered + if (!appName.isEmpty()) { + cfg.writeEntry("Apps", appName); + } + } else if (modifier.compare("remove") == 0 ) { + // need to change for multiple entries + // actually remove is right now simular to clear, but in future there + // should be multiple apps in autostart possible. + QString checkName; + checkName = cfg.readEntry("Apps", ""); + if (checkName == appName) { + cfg.writeEntry("Apps", ""); + } + } + // case the autostart feature should be delayed + } else if ( msg == "autoStart(QString,QString,QString)") { + QString modifier, appName, delay; + 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); + } + } else { + } } #endif } void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "reloadApps()" ) { docList->reloadAppLnks(); } else if ( msg == "soundAlarm()" ) { - soundAlarm(); + ServerApplication::soundAlarm(); } -#ifdef CUSTOM_LEDS else if ( msg == "setLed(int,bool)" ) { int led, status; stream >> led >> status; - CUSTOM_LEDS( 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 ); + } } -#endif } void Server::cancelSync() { #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); #endif delete syncDialog; syncDialog = 0; } bool Server::mkdir(const QString &localPath) { QDir fullDir(localPath); if (fullDir.exists()) return true; @@ -557,101 +628,103 @@ void Server::startTransferServer() // ... OK } else { delete transferServer; transferServer = 0; } } if ( !transferServer || !qcopBridge ) tid_xfer = startTimer( 2000 ); } void Server::timerEvent( QTimerEvent *e ) { if ( e->timerId() == tid_xfer ) { killTimer( tid_xfer ); tid_xfer = 0; startTransferServer(); - } else if ( e->timerId() == tid_today ) { + } + /* ### FIXME today startin */ +#if 0 + else if ( e->timerId() == tid_today ) { QDate today = QDate::currentDate(); if ( today != last_today_show ) { last_today_show = today; Config cfg("today"); cfg.setGroup("Start"); #ifndef QPE_DEFAULT_TODAY_MODE #define QPE_DEFAULT_TODAY_MODE "Never" #endif if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { QCopEnvelope env(Service::channel("today"),"raise()"); } } } +#endif } void Server::terminateServers() { delete transferServer; delete qcopBridge; transferServer = 0; qcopBridge = 0; } void Server::syncConnectionClosed( const QHostAddress & ) { qDebug( "Lost sync connection" ); delete syncDialog; syncDialog = 0; } void Server::pokeTimeMonitors() { +#if 0 // inform all TimeMonitors QStrList tms = Service::channels("TimeMonitor"); for (const char* ch = tms.first(); ch; ch=tms.next()) { QString t = getenv("TZ"); QCopEnvelope e(ch, "timeChange(QString)"); e << t; } +#endif } void Server::applicationLaunched(int, const QString &app) { serverGui->applicationStateChanged( app, ServerInterface::Launching ); } void Server::applicationTerminated(int pid, const QString &app) { serverGui->applicationStateChanged( app, ServerInterface::Terminated ); +#if 0 tsmMonitor->applicationTerminated( pid ); +#endif } void Server::applicationConnected(const QString &app) { serverGui->applicationStateChanged( app, ServerInterface::Running ); } void Server::storageChanged() { system( "qtopia-update-symlinks" ); serverGui->storageChanged( storage->fileSystems() ); docList->storageChanged(); } -void Server::soundAlarm() -{ -#ifdef CUSTOM_SOUND_ALARM - CUSTOM_SOUND_ALARM; -#endif -} 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 } } diff --git a/core/launcher/server.h b/core/launcher/server.h index 21b03af..91bf883 100644 --- a/core/launcher/server.h +++ b/core/launcher/server.h @@ -16,79 +16,82 @@ ** 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 DeviceButton; class ServiceRequest; class TempScreenSaverMonitor; class AppLauncher; class AppLnkSet; class StorageInfo; class SyncDialog; class DocumentList; class ServerInterface; +namespace Opie { + class ODeviceButton; +} class Server : public QWidget { Q_OBJECT public: Server(); ~Server(); static bool mkdir(const QString &path); void show(); - static void soundAlarm(); 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 activate(const DeviceButton*,bool); + void activate(const Opie::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(); protected: void styleChange( QStyle & ); void timerEvent( QTimerEvent *e ); private: + void layout(); void startTransferServer(); void preloadApps(); QCopBridge *qcopBridge; TransferServer *transferServer; PackageHandler *packageHandler; QDate last_today_show; int tid_xfer; - int tid_today; - TempScreenSaverMonitor *tsmMonitor; + /* ### FIXME two below### */ +// int tid_today; +// TempScreenSaverMonitor *tsmMonitor; StorageInfo *storage; SyncDialog *syncDialog; AppLauncher *appLauncher; DocumentList *docList; ServerInterface *serverGui; }; #endif // DESKTOP_H |