summaryrefslogtreecommitdiff
path: root/core/launcher/server.cpp
Side-by-side diff
Diffstat (limited to 'core/launcher/server.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/server.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 068d716..ea0b792 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -54,216 +54,216 @@
#include <opie2/odevice.h>
#include <unistd.h>
#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 ) { \
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 },
};
//---------------------------------------------------------------------------
//===========================================================================
Server::Server() :
QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
qcopBridge( 0 ),
transferServer( 0 ),
packageHandler( 0 ),
syncDialog( 0 )
{
Global::setBuiltinCommands(builtins);
tid_xfer = 0;
/* ### FIXME ### */
/* tid_today = startTimer(3600*2*1000);*/
last_today_show = QDate::currentDate();
#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 &)) );
+ 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 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 &)) );
+ 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( 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 Opie::ODeviceButton* button, bool held)
{
Global::terminateBuiltin("calibrate"); // No tr
Opie::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();
}
#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 } },
@@ -520,194 +520,194 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data)
}
} 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()" ) {
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 );
}
}
}
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;
// at this point the directory doesn't exist
// go through the directory tree and start creating the direcotories
// that don't exist; if we can't create the directories, return false
QString dirSeps = "/";
int dirIndex = localPath.find(dirSeps);
QString checkedPath;
// didn't find any seps; weird, use the cur dir instead
if (dirIndex == -1) {
//qDebug("No seperators found in path %s", localPath.latin1());
checkedPath = QDir::currentDirPath();
}
while (checkedPath != localPath) {
// no more seperators found, use the local path
if (dirIndex == -1)
checkedPath = localPath;
else {
// the next directory to check
checkedPath = localPath.left(dirIndex) + "/";
// advance the iterator; the next dir seperator
dirIndex = localPath.find(dirSeps, dirIndex+1);
}
QDir checkDir(checkedPath);
if (!checkDir.exists()) {
//qDebug("mkdir making dir %s", checkedPath.latin1());
if (!checkDir.mkdir(checkedPath)) {
qDebug("Unable to make directory %s", checkedPath.latin1());
return FALSE;
}
}
}
return TRUE;
}
void Server::styleChange( QStyle &s )
{
QWidget::styleChange( s );
}
void Server::startTransferServer()
{
if ( !qcopBridge ) {
// start qcop bridge server
qcopBridge = new QCopBridge( 4243 );
if ( qcopBridge->ok() ) {
// ... OK
- connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress &)),
- this, SLOT(syncConnectionClosed(const QHostAddress &)) );
+ connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)),
+ this, SLOT(syncConnectionClosed(const QHostAddress&)) );
} else {
delete qcopBridge;
qcopBridge = 0;
}
}
if ( !transferServer ) {
// start transfer server
transferServer = new TransferServer( 4242 );
if ( transferServer->ok() ) {
// ... 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();
}
/* ### 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();