summaryrefslogtreecommitdiff
path: root/core/launcher
Side-by-side diff
Diffstat (limited to 'core/launcher') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/appicons.cpp14
-rw-r--r--core/launcher/applauncher.cpp8
-rw-r--r--core/launcher/firstuse.cpp8
-rw-r--r--core/launcher/inputmethods.cpp4
-rw-r--r--core/launcher/launcher.cpp12
-rw-r--r--core/launcher/launcherview.cpp12
-rw-r--r--core/launcher/packageslave.cpp4
-rw-r--r--core/launcher/qcopbridge.cpp12
-rw-r--r--core/launcher/runningappbar.cpp4
-rw-r--r--core/launcher/server.cpp18
-rw-r--r--core/launcher/serverapp.cpp10
-rw-r--r--core/launcher/shutdownimpl.cpp6
-rw-r--r--core/launcher/taskbar.cpp4
-rw-r--r--core/launcher/transferserver.cpp12
14 files changed, 65 insertions, 63 deletions
diff --git a/core/launcher/appicons.cpp b/core/launcher/appicons.cpp
index c51ee5a..4d48b24 100644
--- a/core/launcher/appicons.cpp
+++ b/core/launcher/appicons.cpp
@@ -1,129 +1,131 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** 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 "appicons.h"
-#include <qpe/qcopenvelope_qws.h>
+#ifdef QWS
+#include <qtopia/qcopenvelope_qws.h>
+#endif
#include <qtooltip.h>
#include <qpixmap.h>
AppIcons::AppIcons( QWidget *parent ) :
QHBox(parent)
{
buttons.setAutoDelete(TRUE);
#ifndef QT_NO_COP
QCopChannel* channel = new QCopChannel("Qt/Tray", this);
- connect(channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(receive(const QCString&, const QByteArray&)));
+ connect(channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(receive(const QCString&,const QByteArray&)));
#endif
}
void AppIcons::setIcon(int id, const QPixmap& pm)
{
button(id)->setPixmap(pm);
}
class FlatButton : public QLabel {
Q_OBJECT
public:
FlatButton(QWidget* parent) : QLabel(parent) { }
void mouseDoubleClickEvent(QMouseEvent* e)
{
emit clicked(e->pos(),e->button(),TRUE);
}
void mouseReleaseEvent(QMouseEvent* e)
{
if ( rect().contains(e->pos()) )
emit clicked(e->pos(),e->button(),FALSE);
}
signals:
void clicked(const QPoint&, int, bool);
};
QLabel* AppIcons::button(int id)
{
QLabel* f = buttons.find(id);
if ( !f ) {
buttons.insert(id,f=new FlatButton(this));
- connect(f,SIGNAL(clicked(const QPoint&, int, bool)),this,SLOT(clicked(const QPoint&, int, bool)));
+ connect(f,SIGNAL(clicked(const QPoint&,int,bool)),this,SLOT(clicked(const QPoint&,int,bool)));
f->show();
}
return f;
}
int AppIcons::findId(QLabel* b)
{
QIntDictIterator<QLabel> it(buttons);
for ( ; ; ++it )
if ( it.current() == b ) return it.currentKey();
}
void AppIcons::clicked(const QPoint& relpos, int button, bool dbl)
{
#ifndef QT_NO_COP
QLabel* s = (QLabel*)sender();
if ( button == RightButton ) {
QCopEnvelope("Qt/Tray","popup(int,QPoint)")
<< findId(s) << s->mapToGlobal(QPoint(0,0));
} else {
QCopEnvelope("Qt/Tray",
dbl ? "doubleClicked(int,QPoint)" : "clicked(int,QPoint)")
<< findId(s) << relpos;
}
#endif
}
void AppIcons::setToolTip(int id, const QString& tip)
{
QToolTip::add(button(id),tip);
}
void AppIcons::remove(int id)
{
buttons.remove(id);
}
void AppIcons::receive( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "remove(int)" ) {
int id;
stream >> id;
remove(id);
} else if ( msg == "setIcon(int,QPixmap)" ) {
int id;
QPixmap pm;
stream >> id >> pm;
setIcon(id,pm);
} else if ( msg == "setToolTip(int,QString)" ) {
int id;
QString s;
stream >> id >> s;
setToolTip(id,s);
}
}
#include "appicons.moc"
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index 7d3c032..08a3cb4 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -1,190 +1,190 @@
/**********************************************************************
** 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 QTOPIA_INTERNAL_PRELOADACCESS
#define QTOPIA_INTERNAL_PRELOADACCESS
#endif
#ifndef QTOPIA_INTERNAL_FILEOPERATIONS
#define QTOPIA_INTERNAL_FILEOPERATIONS
#endif
#ifndef QTOPIA_PROGRAM_MONITOR
#define QTOPIA_PROGRAM_MONITOR
#endif
#include <opie2/oglobal.h>
#ifndef Q_OS_WIN32
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/file.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <errno.h>
#else
#include <process.h>
#include <windows.h>
#include <winbase.h>
#endif
#include <signal.h>
#include <sys/types.h>
#include <stdlib.h>
#include <qtimer.h>
#include <qwindowsystem_qws.h>
#include <qmessagebox.h>
#include <qfileinfo.h>
#include <qtopia/qcopenvelope_qws.h>
#include <qtopia/qpeapplication.h>
#include "applauncher.h"
#include "documentlist.h"
const int AppLauncher::RAISE_TIMEOUT_MS = 5000;
//---------------------------------------------------------------------------
static AppLauncher* appLauncherPtr;
const int appStopEventID = 1290;
class AppStoppedEvent : public QCustomEvent
{
public:
AppStoppedEvent(int pid, int status)
: QCustomEvent( appStopEventID ), mPid(pid), mStatus(status) { }
int pid() { return mPid; }
int status() { return mStatus; }
private:
int mPid, mStatus;
};
AppLauncher::AppLauncher(QObject *parent, const char *name)
: QObject(parent, name), qlPid(0), qlReady(FALSE),
appKillerBox(0)
{
connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&)));
connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&)));
QCopChannel* channel = new QCopChannel( "QPE/System", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(received(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(received(const QCString&,const QByteArray&)) );
channel = new QCopChannel( "QPE/Server", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(received(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(received(const QCString&,const QByteArray&)) );
#ifndef Q_OS_WIN32
signal(SIGCHLD, signalHandler);
#else
runningAppsProc.setAutoDelete( TRUE );
#endif
QString tmp = qApp->argv()[0];
int pos = tmp.findRev('/');
if ( pos > -1 )
tmp = tmp.mid(++pos);
runningApps[::getpid()] = tmp;
appLauncherPtr = this;
QTimer::singleShot( 1000, this, SLOT(createQuickLauncher()) );
}
AppLauncher::~AppLauncher()
{
appLauncherPtr = 0;
#ifndef Q_OS_WIN32
signal(SIGCHLD, SIG_DFL);
#endif
if ( qlPid ) {
int status;
::kill( qlPid, SIGTERM );
waitpid( qlPid, &status, 0 );
}
}
/* We use the QCopChannel of the app as an indicator of when it has been launched
so that we can disable the busy indicators */
void AppLauncher::newQcopChannel(const QString& channelName)
{
// qDebug("channel %s added", channelName.data() );
QString prefix("QPE/Application/");
if (channelName.startsWith(prefix)) {
{
QCopEnvelope e("QPE/System", "newChannel(QString)");
e << channelName;
}
QString appName = channelName.mid(prefix.length());
if ( appName != "quicklauncher" ) {
emit connected( appName );
QCopEnvelope e("QPE/System", "notBusy(QString)");
e << appName;
}
} else if (channelName.startsWith("QPE/QuickLauncher-")) {
qDebug("Registered %s", channelName.latin1());
int pid = channelName.mid(18).toInt();
if (pid == qlPid)
qlReady = TRUE;
}
}
void AppLauncher::removedQcopChannel(const QString& channelName)
{
if (channelName.startsWith("QPE/Application/")) {
QCopEnvelope e("QPE/System", "removedChannel(QString)");
e << channelName;
}
}
void AppLauncher::received(const QCString& msg, const QByteArray& data)
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "execute(QString)" ) {
QString t;
stream >> t;
if ( !executeBuiltin( t, QString::null ) )
execute(t, QString::null);
} else if ( msg == "execute(QString,QString)" ) {
QString t,d;
stream >> t >> d;
if ( !executeBuiltin( t, d ) )
execute( t, d );
} else if ( msg == "processQCop(QString)" ) { // from QPE/Server
QString t;
stream >> t;
if ( !executeBuiltin( t, QString::null ) )
execute( t, QString::null, TRUE);
} else if ( msg == "raise(QString)" ) {
QString appName;
stream >> appName;
if ( !executeBuiltin( appName, QString::null ) ) {
if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) {
//qDebug( "Raising: %s", appName.latin1() );
QCString channel = "QPE/Application/";
channel += appName.latin1();
// Need to lock it to avoid race conditions with QPEApplication::processQCopFile
QFile f("/tmp/qcop-msg-" + appName);
if ( f.open(IO_WriteOnly | IO_Append) ) {
#ifndef Q_OS_WIN32
flock(f.handle(), LOCK_EX);
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp
index 50ae6c2..4316648 100644
--- a/core/launcher/firstuse.cpp
+++ b/core/launcher/firstuse.cpp
@@ -5,253 +5,253 @@
**
** 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.
**
**********************************************************************/
// I need access to some things you don't normally get access to.
#ifndef _MSC_VER
//### revise to allow removal of translators under MSVC
#define private public
#define protected public
#endif
#include "firstuse.h"
#include "inputmethods.h"
#include "applauncher.h"
#include "serverapp.h"
//#include <qtopia/custom.h>
#include "calibrate.h"
#include "documentlist.h"
#include <qtopia/resource.h>
#include <qtopia/qcopenvelope_qws.h>
#include <qtopia/config.h>
#include <qtopia/fontmanager.h>
#include <qfile.h>
#include <qpainter.h>
#include <qsimplerichtext.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qtimer.h>
#if defined( Q_WS_QWS )
#include <qwsdisplay_qws.h>
#include <qgfx_qws.h>
#endif
#include <stdlib.h>
#include <sys/types.h>
#if defined(Q_OS_LINUX) || defined(_OS_LINUX_)
#include <unistd.h>
#endif
struct {
bool enabled;
const char *app;
const char *start;
const char *stop;
const char *desc;
}
settingsTable [] =
{
{ FALSE, "language", "raise()", "accept()", // No tr
QT_TR_NOOP("Language") },
{ FALSE, "doctab", "raise()", "accept()", // No tr
QT_TR_NOOP("DocTab") },
#ifndef Q_OS_WIN32
{ FALSE, "systemtime", "raise()", "accept()", // No tr
QT_TR_NOOP("Time and Date") },
#endif
{ FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr
QT_TR_NOOP("Personal Information") },
{ FALSE, 0, 0, 0, 0 }
};
FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) :
QDialog( parent, name, TRUE, wf),
transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1),
waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE)
{
ServerApplication::allowRestart = FALSE;
// we force our height beyound the maximum (which we set anyway)
QRect desk = qApp->desktop()->geometry();
setGeometry( 0, 0, desk.width(), desk.height() );
connect(qwsServer, SIGNAL(newChannel(const QString&)),
this, SLOT(newQcopChannel(const QString&)));
// Create a DocumentList so appLauncher has appLnkSet to search
docList = new DocumentList( 0, FALSE );
appLauncher = new AppLauncher( this );
- connect( appLauncher, SIGNAL(terminated(int, const QString&)),
- this, SLOT(terminated(int, const QString&)) );
+ connect( appLauncher, SIGNAL(terminated(int,const QString&)),
+ this, SLOT(terminated(int,const QString&)) );
// more hackery
// I will be run as either the main server or as part of the main server
QWSServer::setScreenSaverIntervals(0);
loadPixmaps();
//check if there is a language program
#ifndef Q_OS_WIN32
QString exeSuffix;
#else
QString exeSuffix(".exe");
#endif
for ( int i = 0; settingsTable[i].app; i++ ) {
QString file = QPEApplication::qpeDir() + "bin/";
file += settingsTable[i].app;
file += exeSuffix;
if ( QFile::exists(file) )
settingsTable[i].enabled = TRUE;
}
setFocusPolicy(NoFocus);
taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader);
inputMethods = new InputMethods(taskBar);
connect(inputMethods, SIGNAL(inputToggled(bool)),
this, SLOT(calcMaxWindowRect()));
back = new QPushButton(tr("<< Back"), taskBar);
back->setFocusPolicy(NoFocus);
connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) );
next = new QPushButton(tr("Next >>"), taskBar);
next->setFocusPolicy(NoFocus);
connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) );
// need to set the geom to lower corner
QSize sz = inputMethods->sizeHint();
int buttonWidth = (width() - sz.width()) / 2;
int x = 0;
controlHeight = back->sizeHint().height();
inputMethods->setGeometry(0,0, sz.width(), controlHeight );
x += sz.width();
back->setGeometry(x, 0, buttonWidth, controlHeight);
x += buttonWidth;
next->setGeometry(x, 0, buttonWidth, controlHeight);
taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight);
taskBar->hide();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
qDebug("Setting up QCop to QPE/System");
QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
- connect(sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(message(const QCString &, const QByteArray &)) );
+ connect(sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(message(const QCString&,const QByteArray&)) );
#endif
calcMaxWindowRect();
m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false;
if ( m_calHandler) {
if ( !QFile::exists("/etc/pointercal") ) {
needCalibrate = TRUE;
grabMouse();
}
}
Config config("locale");
config.setGroup( "Language");
lang = config.readEntry( "Language", "en");
defaultFont = font();
//###language/font hack; should look it up somewhere
#ifdef Q_WS_QWS
if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
qApp->setFont( fn, TRUE );
}
#endif
}
FirstUse::~FirstUse()
{
delete appLauncher;
delete docList;
delete taskBar;
ServerApplication::allowRestart = TRUE;
}
void FirstUse::calcMaxWindowRect()
{
#ifdef Q_WS_QWS
QRect wr;
int displayWidth = qApp->desktop()->width();
QRect ir = inputMethods->inputRect();
if ( ir.isValid() ) {
wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
} else {
wr.setCoords( 0, 0, displayWidth-1,
qApp->desktop()->height() - controlHeight-1);
}
#if QT_VERSION < 0x030000
QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
QSize(qt_screen->width(),qt_screen->height()))
);
#else
QWSServer::setMaxWindowRect( wr );
#endif
#endif
}
/* cancel current dialog, and bring up next */
void FirstUse::nextDialog()
{
int prevApp = currApp;
do {
currApp++;
qDebug( "currApp = %d", currApp );
if ( settingsTable[currApp].app == 0 ) {
if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
// The last application is still running.
// Tell it to stop, and when its done we'll come back
// to nextDialog and exit.
qDebug( "Waiting for %s to exit", settingsTable[prevApp].app );
QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
settingsTable[prevApp].stop );
currApp = prevApp;
} else {
qDebug( "Done!" );
Config config( "qpe" );
config.setGroup( "Startup" );
config.writeEntry( "FirstUse", FALSE );
QPixmap pix = Resource::loadPixmap("bigwait");
QLabel *lblWait = new QLabel(0, "wait hack!", // No tr
QWidget::WStyle_Customize | QWidget::WDestructiveClose |
QWidget::WStyle_NoBorder | QWidget::WStyle_Tool |
QWidget::WStyle_StaysOnTop);
lblWait->setPixmap( pix );
lblWait->setAlignment( QWidget::AlignCenter );
lblWait->setGeometry( qApp->desktop()->geometry() );
lblWait->show();
qApp->processEvents();
QTimer::singleShot( 1000, lblWait, SLOT(close()) );
repaint();
close();
ServerApplication::allowRestart = TRUE;
}
return;
}
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp
index 683f1e2..19e799a 100644
--- a/core/launcher/inputmethods.cpp
+++ b/core/launcher/inputmethods.cpp
@@ -52,194 +52,194 @@ static const char * tri_xpm[]={
"9 9 2 1",
"a c #000000",
". c None",
".........",
".........",
".........",
"....a....",
"...aaa...",
"..aaaaa..",
".aaaaaaa.",
".........",
"........."};
int InputMethod::operator <(const InputMethod& o) const
{
return name() < o.name();
}
int InputMethod::operator >(const InputMethod& o) const
{
return name() > o.name();
}
int InputMethod::operator <=(const InputMethod& o) const
{
return name() <= o.name();
}
/*
Slightly hacky: We use WStyle_Tool as a flag to say "this widget
belongs to the IM system, so clicking it should not cause a reset".
*/
class IMToolButton : public QToolButton
{
public:
IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent )
{ setWFlags( WStyle_Tool ); }
};
InputMethods::InputMethods( QWidget *parent ) :
QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ),
mkeyboard(0), imethod(0)
{
Config cfg( "Launcher" );
cfg.setGroup( "InputMethods" );
inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool;
inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0;
inputWidgetWidth = cfg.readNumEntry( "Width", 100 );
setBackgroundMode( PaletteBackground );
QHBoxLayout *hbox = new QHBoxLayout( this );
kbdButton = new IMToolButton( this);
kbdButton->setFocusPolicy(NoFocus);
kbdButton->setToggleButton( TRUE );
if (parent->sizeHint().height() > 0)
kbdButton->setFixedHeight( parent->sizeHint().height() );
kbdButton->setFixedWidth( 32 );
kbdButton->setAutoRaise( TRUE );
kbdButton->setUsesBigPixmap( TRUE );
hbox->addWidget( kbdButton );
connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) );
kbdChoice = new IMToolButton( this );
kbdChoice->setFocusPolicy(NoFocus);
kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) );
if (parent->sizeHint().height() > 0)
kbdChoice->setFixedHeight( parent->sizeHint().height() );
kbdChoice->setFixedWidth( 13 );
kbdChoice->setAutoRaise( TRUE );
hbox->addWidget( kbdChoice );
connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) );
connect( (QPEApplication*)qApp, SIGNAL(clientMoused()),
this, SLOT(resetStates()) );
imButton = new QWidgetStack( this ); // later a widget stack
imButton->setFocusPolicy(NoFocus);
if (parent->sizeHint().height() > 0)
imButton->setFixedHeight( parent->sizeHint().height() );
hbox->addWidget(imButton);
imChoice = new QToolButton( this );
imChoice->setFocusPolicy(NoFocus);
imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) );
if (parent->sizeHint().height() > 0)
imChoice->setFixedHeight( parent->sizeHint().height() );
imChoice->setFixedWidth( 13 );
imChoice->setAutoRaise( TRUE );
hbox->addWidget( imChoice );
connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) );
loadInputMethods();
QCopChannel *channel = new QCopChannel( "QPE/IME", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(qcopReceive(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(qcopReceive(const QCString&,const QByteArray&)) );
}
InputMethods::~InputMethods()
{
Config cfg("qpe");
cfg.setGroup("InputMethod");
if (imethod)
cfg.writeEntry("im", imethod->name() );
if (mkeyboard)
cfg.writeEntry("current", mkeyboard->name() );
unloadInputMethods();
}
void InputMethods::hideInputMethod()
{
kbdButton->setOn( FALSE );
}
void InputMethods::showInputMethod()
{
kbdButton->setOn( TRUE );
}
void InputMethods::showInputMethod(const QString& name)
{
int i = 0;
QValueList<InputMethod>::Iterator it;
InputMethod *im = 0;
for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) {
QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1);
if ( (*it).name() == name || lname == name ) {
im = &(*it);
break;
}
}
if ( im )
chooseKeyboard(im);
}
void InputMethods::resetStates()
{
if ( mkeyboard && !mkeyboard->newIM )
mkeyboard->interface->resetState();
}
QRect InputMethods::inputRect() const
{
if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() )
return QRect();
else
return mkeyboard->widget->geometry();
}
void InputMethods::unloadInputMethods()
{
unloadMethod( inputMethodList );
unloadMethod( inputModifierList );
inputMethodList.clear();
inputModifierList.clear();
}
void InputMethods::unloadMethod( QValueList<InputMethod>& list ) {
QValueList<InputMethod>::Iterator it;
for (it = list.begin(); it != list.end(); ++it )
(*it).releaseInterface();
}
QStringList InputMethods::plugins()const {
QString path = QPEApplication::qpeDir() + "/plugins/inputmethods";
#ifdef Q_OS_MACX
QDir dir( path, "lib*.dylib" );
#else
QDir dir( path, "lib*.so" );
#endif /* Q_OS_MACX */
return dir.entryList();
}
void InputMethods::installTranslator( const QString& type ) {
QStringList langs = Global::languageList();
QStringList::ConstIterator lit;
for ( lit= langs.begin(); lit!=langs.end(); ++lit) {
QString lang = *lit;
QTranslator * trans = new QTranslator(qApp);
QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
if ( trans->load( tfn ))
qApp->installTranslator( trans );
else
delete trans;
}
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 54efb0b..5d0c778 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -5,196 +5,196 @@
**
** 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 <qtopia/global.h>
#ifdef Q_WS_QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
#include <qtopia/resource.h>
#include <qtopia/applnk.h>
#include <qtopia/config.h>
#include <qtopia/qpeapplication.h>
#include <qtopia/mimetype.h>
#include <qtopia/private/categories.h>
//#include <qtopia/custom.h>
#include <qdir.h>
#ifdef Q_WS_QWS
#include <qwindowsystem_qws.h>
#endif
#include <qtimer.h>
#include <qcombobox.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qstyle.h>
#include <qpushbutton.h>
#include <qtabbar.h>
#include <qwidgetstack.h>
#include <qregexp.h>
#include <qmessagebox.h>
#include <qframe.h>
#include <qpainter.h>
#include <qlabel.h>
#include <qtextstream.h>
#include <qpopupmenu.h>
#include "startmenu.h"
#include "taskbar.h"
#include "serverinterface.h"
#include "launcherview.h"
#include "launcher.h"
#include "server.h"
#define QTOPIA_INTERNAL_FSLP
#include <qtopia/lnkproperties.h>
#include <stdlib.h>
#include <assert.h>
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <unistd.h>
#include <stdio.h>
#include <sys/vfs.h>
#include <mntent.h>
#endif
#ifdef Q_WS_QWS
#include <qkeyboard_qws.h>
#include <qpe/lnkproperties.h>
#endif
static bool isVisibleWindow( int );
//===========================================================================
LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
QVBox( parent ), docview( 0 )
{
docLoadingWidgetEnabled = false;
docLoadingWidget = 0;
docLoadingWidgetProgress = 0;
launcher = parent;
categoryBar = new LauncherTabBar( this );
QPalette pal = categoryBar->palette();
pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
categoryBar->setPalette( pal );
stack = new QWidgetStack(this);
connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
categoryBar->show();
stack->show();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
- connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
- this, SLOT(appMessage(const QCString&, const QByteArray&)));
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(launcherMessage(const QCString&,const QByteArray&)) );
+ connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
+ this, SLOT(appMessage(const QCString&,const QByteArray&)));
#endif
createDocLoadingWidget();
}
void LauncherTabWidget::createDocLoadingWidget()
{
// Construct the 'doc loading widget' shown when finding documents
// ### LauncherView class needs changing to be more generic so
// this widget can change its background similar to the iconviews
// so the background for this matches
docLoadingWidget = new LauncherView( stack );
docLoadingWidget->hideIcons();
QVBox *docLoadingVBox = new QVBox( docLoadingWidget );
docLoadingVBox->setSpacing( 20 );
docLoadingVBox->setMargin( 10 );
QWidget *space1 = new QWidget( docLoadingVBox );
docLoadingVBox->setStretchFactor( space1, 1 );
QLabel *waitPixmap = new QLabel( docLoadingVBox );
waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) );
waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
bool docTabEnabled = cfg.readBoolEntry( "Enable", true );
QLabel *textLabel = new QLabel( docLoadingVBox );
textLabel->setAlignment( int( QLabel::AlignCenter ) );
docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
docLoadingWidgetProgress->setProgress( 0 );
docLoadingWidgetProgress->setCenterIndicator( TRUE );
docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
setProgressStyle();
if ( docTabEnabled )
{
textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
}
else
{
textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>"
"Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) );
docLoadingWidgetProgress->hide();
docLoadingWidgetEnabled = true;
}
QWidget *space2 = new QWidget( docLoadingVBox );
docLoadingVBox->setStretchFactor( space2, 1 );
cfg.setGroup( "Tab Documents" ); // No tr
setTabViewAppearance( docLoadingWidget, cfg );
stack->addWidget( docLoadingWidget, 0 );
}
void LauncherTabWidget::initLayout()
{
layout()->activate();
docView()->setFocus();
categoryBar->showTab("Documents");
}
void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
{
if ( message == "nextView()" )
categoryBar->nextTab();
}
void LauncherTabWidget::raiseTabWidget()
{
if ( categoryBar->currentView() == docView()
&& docLoadingWidgetEnabled ) {
stack->raiseWidget( docLoadingWidget );
docLoadingWidget->updateGeometry();
} else {
stack->raiseWidget( categoryBar->currentView() );
}
}
void LauncherTabWidget::tabProperties()
{
LauncherView *view = categoryBar->currentView();
QPopupMenu *m = new QPopupMenu( this );
m->insertItem( tr("Icon View"), LauncherView::Icon );
m->insertItem( tr("List View"), LauncherView::List );
m->setItemChecked( (int)view->viewMode(), TRUE );
int rv = m->exec( QCursor::pos() );
if ( rv >= 0 && rv != view->viewMode() ) {
view->setViewMode( (LauncherView::ViewMode)rv );
}
@@ -384,194 +384,194 @@ void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &
stream >> id;
int mode;
stream >> mode;
QString pixmapOrColor;
stream >> pixmapOrColor;
if ( view(id) )
view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
if ( id == "Documents" )
docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
} else if ( msg == "setTextColor(QString,QString)" ) {
QString id;
stream >> id;
QString color;
stream >> color;
if ( view(id) )
view(id)->setTextColor( QColor(color) );
if ( id == "Documents" )
docLoadingWidget->setTextColor( QColor(color) );
} else if ( msg == "setFont(QString,QString,int,int,int)" ) {
QString id;
stream >> id;
QString fam;
stream >> fam;
int size;
stream >> size;
int weight;
stream >> weight;
int italic;
stream >> italic;
if ( view(id) ) {
if ( !fam.isEmpty() ) {
view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic );
} else {
view(id)->clearViewFont();
}
}
}else if ( msg == "setBusyIndicatorType(QString)" ) {
QString type;
stream >> type;
setBusyIndicatorType( type );
}else if ( msg == "home()" ) {
if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
if (categoryBar)
categoryBar->nextTab();
}else
static_cast<QWidget*>(parent())->raise();
}
}
//---------------------------------------------------------------------------
Launcher::Launcher()
: QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
{
tabs = 0;
tb = 0;
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
docTabEnabled = cfg.readBoolEntry( "Enable", true );
}
void Launcher::createGUI()
{
setCaption( tr("Launcher") );
// we have a pretty good idea how big we'll be
setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
tb = new TaskBar;
tabs = new LauncherTabWidget( this );
setCentralWidget( tabs );
ServerInterface::dockWidget( tb, ServerInterface::Bottom );
tb->show();
qApp->installEventFilter( this );
connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
connect( tb, SIGNAL(tabSelected(const QString&)),
this, SLOT(showTab(const QString&)) );
connect( tabs, SIGNAL(selected(const QString&)),
this, SLOT(viewSelected(const QString&)) );
connect( tabs, SIGNAL(clicked(const AppLnk*)),
this, SLOT(select(const AppLnk*)));
connect( tabs, SIGNAL(rightPressed(AppLnk*)),
this, SLOT(properties(AppLnk*)));
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
- connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
+ connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(systemMessage(const QCString&,const QByteArray&)) );
#endif
// all documents
QImage img( Resource::loadImage( "DocsIcon" ) );
QPixmap pm;
pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
// It could add this itself if it handles docs
tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
qApp->setMainWidget( this );
QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
}
Launcher::~Launcher()
{
if ( tb )
destroyGUI();
}
bool Launcher::requiresDocuments() const
{
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
return cfg.readBoolEntry( "Enable", true );
}
void Launcher::makeVisible()
{
showMaximized();
}
void Launcher::destroyGUI()
{
delete tb;
tb = 0;
delete tabs;
tabs =0;
}
bool Launcher::eventFilter( QObject*, QEvent *ev )
{
#ifdef QT_QWS_CUSTOM
if ( ev->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent *)ev;
if ( ke->key() == Qt::Key_F11 ) { // menu key
QWidget *active = qApp->activeWindow();
if ( active && active->isPopup() )
active->close();
else {
Global::terminateBuiltin("calibrate"); // No tr
tb->launchStartMenu();
}
return TRUE;
}
}
#else
Q_UNUSED(ev);
#endif
return FALSE;
}
void Launcher::toggleSymbolInput()
{
tb->toggleSymbolInput();
}
void Launcher::toggleNumLockState()
{
tb->toggleNumLockState();
}
void Launcher::toggleCapsLockState()
{
tb->toggleCapsLockState();
}
static bool isVisibleWindow(int wid)
{
#ifdef Q_WS_QWS
const QList<QWSWindow> &list = qwsServer->clientWindows();
QWSWindow* w;
for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
if ( w->winId() == wid )
return !w->isFullyObscured();
}
#endif
return FALSE;
}
void Launcher::viewSelected(const QString& s)
{
setCaption( s + tr(" - Launcher") );
}
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 513b1bd..6c7d487 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -522,200 +522,200 @@ void LauncherIconView::addItem(AppLnk* app, bool resort)
sort();
}
void LauncherIconView::updateCategoriesAndMimeTypes()
{
mimes.clear();
cats.clear();
LauncherItem* item = (LauncherItem*)firstItem();
while (item) {
addCatsAndMimes(item->appLnk());
item = (LauncherItem*)item->nextItem();
}
QListIterator<AppLnk> it(hidden);
AppLnk* l;
while ((l=it.current())) {
addCatsAndMimes(l);
++it;
}
}
void LauncherIconView::hideOrShowItems(bool resort)
{
viewport()->setUpdatesEnabled( FALSE );
hidden.setAutoDelete(FALSE);
QList<AppLnk> links=hidden;
hidden.clear();
hidden.setAutoDelete(TRUE);
LauncherItem* item = (LauncherItem*)firstItem();
while (item) {
links.append(item->takeAppLnk());
item = (LauncherItem*)item->nextItem();
}
clear();
QListIterator<AppLnk> it(links);
AppLnk* l;
while ((l=it.current())) {
addItem(l,FALSE);
++it;
}
if ( resort && !autoArrange() )
sort();
viewport()->setUpdatesEnabled( TRUE );
}
bool LauncherIconView::removeLink(const QString& linkfile)
{
LauncherItem* item = (LauncherItem*)firstItem();
AppLnk* l;
bool did = FALSE;
DocLnk dl(linkfile);
while (item) {
l = item->appLnk();
LauncherItem *nextItem = (LauncherItem *)item->nextItem();
if ( l->linkFileKnown() && l->linkFile() == linkfile
|| l->fileKnown() && (
l->file() == linkfile
|| dl.isValid() && dl.file() == l->file() ) ) {
delete item;
did = TRUE;
}
item = nextItem;
}
QListIterator<AppLnk> it(hidden);
while ((l=it.current())) {
++it;
if ( l->linkFileKnown() && l->linkFile() == linkfile
|| l->file() == linkfile
|| dl.isValid() && dl.file() == l->file() ) {
hidden.removeRef(l);
did = TRUE;
}
}
return did;
}
//===========================================================================
LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
: QVBox( parent, name, fl )
{
catmb = 0;
icons = new LauncherIconView( this );
setFocusProxy(icons);
QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
icons->setItemsMovable( FALSE );
icons->setAutoArrange( TRUE );
icons->setSorting( TRUE );
icons->setFrameStyle( QFrame::NoFrame );
icons->setMargin( 0 );
icons->setSelectionMode( QIconView::NoSelection );
icons->setBackgroundMode( PaletteBase );
icons->setResizeMode( QIconView::Fixed );
vmode = (ViewMode)-1;
setViewMode( Icon );
- connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
- SLOT(itemClicked(int, QIconViewItem *)) );
+ connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
+ SLOT(itemClicked(int,QIconViewItem*)) );
connect( icons, SIGNAL(selectionChanged()),
SLOT(selectionChanged()) );
- connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
- SLOT(returnPressed(QIconViewItem *)) );
- connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
- SLOT(itemPressed(int, QIconViewItem *)) );
+ connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
+ SLOT(returnPressed(QIconViewItem*)) );
+ connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
+ SLOT(itemPressed(int,QIconViewItem*)) );
tools = 0;
setBackgroundType( Ruled, QString::null );
}
LauncherView::~LauncherView()
{
if ( bgCache && bgCache->contains( bgName ) )
(*bgCache)[bgName]->ref--;
}
void LauncherView::hideIcons()
{
icons->hide();
}
void LauncherView::setToolsEnabled(bool y)
{
if ( !y != !tools ) {
if ( y ) {
tools = new QHBox(this);
// Type filter
typemb = new QComboBox(tools);
QSizePolicy p = typemb->sizePolicy();
p.setHorData(QSizePolicy::Expanding);
typemb->setSizePolicy(p);
// Category filter
updateTools();
tools->show();
// Always show vscrollbar
icons->setVScrollBarMode( QScrollView::AlwaysOn );
} else {
delete tools;
tools = 0;
}
}
}
void LauncherView::updateTools()
{
disconnect( typemb, SIGNAL(activated(int)),
this, SLOT(showType(int)) );
if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)),
this, SLOT(showCategory(int)) );
// ### I want to remove this
icons->updateCategoriesAndMimeTypes();
QString prev;
// Type filter
QStringList types;
typelist = icons->mimeTypes();
for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
QString t = *it;
if ( t.left(12) == "application/" ) {
MimeType mt(t);
const AppLnk* app = mt.application();
if ( app )
t = app->name();
else
t = t.mid(12);
} else {
t[0] = t[0].upper();
}
types += t;
}
types << tr("All types");
prev = typemb->currentText();
typemb->clear();
typemb->insertStringList(types);
for (int i=0; i<typemb->count(); i++) {
if ( typemb->text(i) == prev ) {
typemb->setCurrentItem(i);
break;
}
}
if ( prev.isNull() )
typemb->setCurrentItem(typemb->count()-1);
int pcat = catmb ? catmb->currentCategory() : -2;
if ( !catmb )
catmb = new CategorySelect(tools);
Categories cats( 0 );
cats.load( categoryFileName() );
QArray<int> vl( 0 );
catmb->setCategories( vl, "Document View", // No tr
tr("Document View") );
catmb->setRemoveCategoryEdit( TRUE );
catmb->setAllCategories( TRUE );
catmb->setCurrentCategory(pcat);
// if type has changed we need to redisplay
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp
index 321b5dd..7e61b0e 100644
--- a/core/launcher/packageslave.cpp
+++ b/core/launcher/packageslave.cpp
@@ -1,152 +1,152 @@
/**********************************************************************
** 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 "packageslave.h"
#include <qtopia/qprocess.h>
#ifdef Q_WS_QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
#ifdef Q_WS_QWS
#include <qcopchannel_qws.h>
#endif
#include <qtextstream.h>
#include <stdlib.h>
#include <sys/stat.h> // mkdir()
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <unistd.h>
#include <sys/vfs.h>
#include <mntent.h>
#elif defined(Q_OS_WIN32)
#include <windows.h>
#include <winbase.h>
#elif defined(Q_OS_MACX)
#include <unistd.h>
#endif
PackageHandler::PackageHandler( QObject *parent, char* name )
: QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE )
{
// setup qcop channel
#ifndef QT_NO_COP
packageChannel = new QCopChannel( "QPE/Package", this );
- connect( packageChannel, SIGNAL( received(const QCString &, const QByteArray &) ),
- this, SLOT( qcopMessage( const QCString &, const QByteArray &) ) );
+ connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
+ this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) );
#endif
}
void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "installPackage(QString)" ) {
QString file;
stream >> file;
installPackage( file );
} else if ( msg == "removePackage(QString)" ) {
QString file;
stream >> file;
removePackage( file );
} else if ( msg == "addPackageFiles(QString,QString)" ) {
QString location, listfile;
stream >> location >> listfile;
addPackageFiles( location, listfile);
} else if ( msg == "addPackages(QString)" ) {
QString location;
stream >> location;
addPackages( location );
} else if ( msg == "cleanupPackageFiles(QString)" ) {
QString listfile;
stream >> listfile;
cleanupPackageFiles( listfile );
} else if ( msg == "cleanupPackages(QString)" ) {
QString location;
stream >> location;
cleanupPackages( location );
} else if ( msg == "prepareInstall(QString,QString)" ) {
QString size, path;
stream >> size;
stream >> path;
prepareInstall( size, path );
}
}
void PackageHandler::installPackage( const QString &package )
{
if ( mNoSpaceLeft ) {
mNoSpaceLeft = FALSE;
// Don't emit that for now, I still couldn't test it (Wener)
//sendReply( "installFailed(QString)", package );
//return;
}
currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr
connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) );
connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) );
connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) );
currentPackage = package;
currentProcessError="";
sendReply( "installStarted(QString)", package );
currentProcess->start();
}
void PackageHandler::removePackage( const QString &package )
{
currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr
connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) );
connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) );
connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) );
currentPackage = package;
currentProcessError="";
sendReply( "removeStarted(QString)", package );
currentProcess->start();
}
void PackageHandler::sendReply( const QCString& msg, const QString& arg )
{
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", msg );
e << arg;
#endif
}
void PackageHandler::addPackageFiles( const QString &location,
const QString &listfile )
{
QFile f(listfile);
#ifndef Q_OS_WIN32
//make a copy so we can remove the symlinks later
mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 );
system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii());
#else
QDir d;
//#### revise
qDebug("Copy file at %s: %s", __FILE__, __LINE__ );
d.mkdir(("/usr/lib/ipkg/info/" + location).ascii());
system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii());
#endif
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp
index 24f471d..53efba4 100644
--- a/core/launcher/qcopbridge.cpp
+++ b/core/launcher/qcopbridge.cpp
@@ -1,202 +1,202 @@
/**********************************************************************
** 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 "qcopbridge.h"
#include "transferserver.h"
#include <opie2/oglobal.h>
#ifdef Q_WS_QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
#include <qtopia/qpeapplication.h>
#include <qtopia/version.h>
#include <qtextstream.h>
#include <qtimer.h>
#ifdef Q_WS_QWS
#include <qcopchannel_qws.h>
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#ifndef Q_OS_WIN32
#include <pwd.h>
#include <unistd.h>
#include <sys/types.h>
#endif
#if defined(_OS_LINUX_)
#include <shadow.h>
#endif
//#define INSECURE
const int block_size = 51200;
QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent,
const char* name )
: QServerSocket( port, 1, parent, name ),
desktopChannel( 0 ),
cardChannel( 0 )
{
if ( !ok() )
qWarning( "Failed to bind to port %d", port );
else {
#ifndef QT_NO_COP
desktopChannel = new QCopChannel( "QPE/Desktop", this );
- connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(desktopMessage( const QCString &, const QByteArray &)) );
+ connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(desktopMessage(const QCString&,const QByteArray&)) );
cardChannel = new QCopChannel( "QPE/Card", this );
- connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(desktopMessage( const QCString &, const QByteArray &)) );
+ connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(desktopMessage(const QCString&,const QByteArray&)) );
#endif
}
sendSync = FALSE;
openConnections.setAutoDelete( TRUE );
authorizeConnections();
}
QCopBridge::~QCopBridge()
{
#ifndef QT_NO_COP
delete desktopChannel;
#endif
}
void QCopBridge::authorizeConnections()
{
Config cfg("Security");
cfg.setGroup("SyncMode");
m_mode = Mode(cfg.readNumEntry("Mode", Sharp ));
QListIterator<QCopBridgePI> it(openConnections);
while ( it.current() ) {
if ( !it.current()->verifyAuthorised() ) {
- disconnect ( it.current(), SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( closed( QCopBridgePI *) ) );
+ disconnect ( it.current(), SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) );
openConnections.removeRef( it.current() );
} else
++it;
}
}
void QCopBridge::newConnection( int socket )
{
QCopBridgePI *pi = new QCopBridgePI( socket, this );
openConnections.append( pi );
- connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( closed( QCopBridgePI *) ) );
+ connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) );
/* ### libqtopia merge FIXME */
#if 0
QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend );
#endif
#ifndef QT_NO_COP
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
#endif
if ( sendSync ) {
pi ->startSync();
sendSync = FALSE;
}
}
void QCopBridge::closed( QCopBridgePI *pi )
{
emit connectionClosed( pi->peerAddress() );
openConnections.removeRef( pi );
if ( openConnections.count() == 0 ) {
/* ### FIXME libqtopia merge */
#if 0
QPEApplication::setTempScreenSaverMode( QPEApplication::Enable );
#endif
#ifndef QT_NO_COP
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
#endif
}
}
void QCopBridge::closeOpenConnections()
{
QCopBridgePI *pi;
for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() )
pi->close();
}
void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data )
{
if ( command == "startSync()" ) {
// we need to buffer it a bit
sendSync = TRUE;
startTimer( 20000 );
}
if ( m_mode & Qtopia1_7 ) {
// send the command to all open connections
QCopBridgePI *pi;
for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) {
pi->sendDesktopMessage( command, data );
}
}
if ( ( m_mode & Sharp ) || (m_mode & IntelliSync) )
sendDesktopMessageOld( command, data );
}
#ifndef OPIE_NO_OLD_SYNC_CODE
/*
* Old compat mode
*/
void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) {
command.stripWhiteSpace();
int paren = command.find( "(" );
if ( paren <= 0 ) {
qDebug("DesktopMessage: bad qcop syntax");
return;
}
QString params = command.mid( paren + 1 );
if ( params[params.length()-1] != ')' ) {
qDebug("DesktopMessage: bad qcop syntax");
return;
}
params.truncate( params.length()-1 );
QStringList paramList = QStringList::split( ",", params );
QString data;
if ( paramList.count() ) {
QDataStream stream( args, IO_ReadOnly );
for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) {
QString str;
if ( *it == "QString" ) {
stream >> str;
} else if ( *it == "QCString" ) {
QCString cstr;
stream >> cstr;
str = QString::fromLocal8Bit( cstr );
} else if ( *it == "int" ) {
int i;
stream >> i;
str = QString::number( i );
} else if ( *it == "bool" ) {
int i;
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp
index 11d10dc..2e9d2a9 100644
--- a/core/launcher/runningappbar.cpp
+++ b/core/launcher/runningappbar.cpp
@@ -1,134 +1,134 @@
/**********************************************************************
** 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.
**
***********************************************************************/
#define QTOPIA_INTERNAL_PRELOADACCESS
#include <stdlib.h>
#include <qpainter.h>
#include <qtopia/qcopenvelope_qws.h>
#include "runningappbar.h"
#include "serverinterface.h"
RunningAppBar::RunningAppBar(QWidget* parent)
: QFrame(parent), selectedAppIndex(-1)
{
QCopChannel* channel = new QCopChannel( "QPE/System", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(received(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(received(const QCString&,const QByteArray&)) );
spacing = AppLnk::smallIconSize()+3;
}
RunningAppBar::~RunningAppBar()
{
}
void RunningAppBar::received(const QCString& msg, const QByteArray& data) {
// Since fast apps appear and disappear without disconnecting from their
// channel we need to watch for the showing/hiding events and update according.
QDataStream stream( data, IO_ReadOnly );
if ( msg == "fastAppShowing(QString)") {
QString appName;
stream >> appName;
// qDebug("fastAppShowing %s", appName.data() );
const AppLnk* f = ServerInterface::appLnks().findExec(appName);
if ( f ) addTask(*f);
} else if ( msg == "fastAppHiding(QString)") {
QString appName;
stream >> appName;
const AppLnk* f = ServerInterface::appLnks().findExec(appName);
if ( f ) removeTask(*f);
}
}
void RunningAppBar::addTask(const AppLnk& appLnk) {
qDebug("Added %s to app list.", appLnk.name().latin1());
AppLnk* newApp = new AppLnk(appLnk);
newApp->setExec(appLnk.exec());
appList.prepend(newApp);
update();
}
void RunningAppBar::removeTask(const AppLnk& appLnk) {
unsigned int i = 0;
for (; i < appList.count() ; i++) {
AppLnk* target = appList.at(i);
if (target->exec() == appLnk.exec()) {
qDebug("Removing %s from app list.", appLnk.name().latin1());
appList.remove();
delete target;
}
}
update();
}
void RunningAppBar::mousePressEvent(QMouseEvent *e)
{
// Find out if the user is clicking on an app icon...
// If so, snag the index so when we repaint we show it
// as highlighed.
selectedAppIndex = 0;
int x=0;
QListIterator<AppLnk> it( appList );
for ( ; it.current(); ++it,++selectedAppIndex,x+=spacing ) {
if ( x + spacing <= width() ) {
if ( e->x() >= x && e->x() < x+spacing ) {
if ( selectedAppIndex < (int)appList.count() ) {
repaint(FALSE);
return;
}
}
} else {
break;
}
}
selectedAppIndex = -1;
repaint( FALSE );
}
void RunningAppBar::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() == QMouseEvent::RightButton)
return;
if ( selectedAppIndex >= 0 ) {
QString app = appList.at(selectedAppIndex)->exec();
QCopEnvelope e("QPE/System", "raise(QString)");
e << app;
selectedAppIndex = -1;
update();
}
}
void RunningAppBar::paintEvent( QPaintEvent * )
{
QPainter p( this );
AppLnk *curApp;
int x = 0;
int y = (height() - AppLnk::smallIconSize()) / 2;
int i = 0;
p.fillRect( 0, 0, width(), height(), colorGroup().background() );
QListIterator<AppLnk> it(appList);
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();
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index f7c2341..d38dd97 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -208,204 +208,204 @@ bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepe
emit activate(button, FALSE);
} else if ( press ) {
heldButton = button;
held_tid = startTimer( ODevice::inst ()->buttonHoldTime () );
} else if ( heldButton ) {
heldButton = 0;
emit activate(button, FALSE);
}
QWSServer::screenSaverActivate(FALSE);
return TRUE;
}
return false;
}
if ( keycode == HardKey_Suspend ) {
if ( press ) emit power();
return TRUE;
}
if ( keycode == HardKey_Backlight ) {
if ( press ) emit backlight();
return TRUE;
}
if ( keycode == Key_F32 ) {
#ifndef QT_NO_COP
if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
#endif
return TRUE;
}
if ( keycode == Key_F31 ) {
if ( press ) emit symbol();
QWSServer::screenSaverActivate(FALSE);
return TRUE;
}
if ( keycode == Key_NumLock )
if ( press ) emit numLockStateToggle();
if ( keycode == Key_CapsLock )
if ( press ) emit capsLockStateToggle();
if ( serverApp )
serverApp->keyClick(keycode,press,autoRepeat);
return FALSE;
}
enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown;
#if defined(QPE_HAVE_MEMALERTER)
QPE_MEMALERTER_IMPL
#endif
//---------------------------------------------------------------------------
bool ServerApplication::doRestart = FALSE;
bool ServerApplication::allowRestart = TRUE;
bool ServerApplication::ms_is_starting = TRUE;
void ServerApplication::switchLCD( bool on ) {
if ( !qApp )
return;
ServerApplication *dapp = ServerApplication::me() ;
if ( !dapp-> m_screensaver )
return;
if ( on ) {
dapp-> m_screensaver-> setDisplayState ( true );
dapp-> m_screensaver-> setBacklight ( -3 );
}else
dapp-> m_screensaver-> setDisplayState ( false );
}
ServerApplication::ServerApplication( int& argc, char **argv, Type t )
: QPEApplication( argc, argv, t )
{
ms_is_starting = true;
// We know we'll have lots of cached pixmaps due to App/DocLnks
QPixmapCache::setCacheLimit(512);
m_ps = new PowerStatus;
m_ps_last = new PowerStatus;
pa = new DesktopPowerAlerter( 0 );
m_apm_timer = new QTimer( this );
connect(m_apm_timer, SIGNAL( timeout() ),
this, SLOT( apmTimeout() ) );
reloadPowerWarnSettings();
QCopChannel *channel = new QCopChannel( "QPE/System", this );
- connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
- this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) );
+ connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ),
+ this, SLOT(systemMessage(const QCString&,const QByteArray&) ) );
channel = new QCopChannel("QPE/Launcher", this );
- connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
- this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) );
+ connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ),
+ this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) );
m_screensaver = new OpieScreenSaver();
m_screensaver->setInterval( -1 );
QWSServer::setScreenSaver( m_screensaver );
- connect( qApp, SIGNAL( volumeChanged( bool ) ),
+ connect( qApp, SIGNAL( volumeChanged(bool) ),
this, SLOT( rereadVolumes() ) );
/* ### PluginLoader libqtopia SafeMode */
#if 0
if ( PluginLoader::inSafeMode() )
QTimer::singleShot(500, this, SLOT(showSafeMode()) );
QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) );
#endif
kf = new KeyFilter(this);
connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) );
connect( kf, SIGNAL(power()), this, SIGNAL(power()) );
connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) );
connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol()));
connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle()));
connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle()));
connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)),
this,SIGNAL(activate(const Opie::ODeviceButton*,bool)));
connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) );
connect( this, SIGNAL(power() ),
SLOT(togglePower() ) );
rereadVolumes();
serverApp = this;
apmTimeout();
grabKeyboard();
/* make sure the event filter is installed */
const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 );
}
ServerApplication::~ServerApplication()
{
ungrabKeyboard();
delete pa;
delete m_ps;
delete m_ps_last;
}
void ServerApplication::apmTimeout() {
serverApp-> checkMemory( ); // in case no events are generated
*m_ps_last = *m_ps;
*m_ps = PowerStatusManager::readStatus();
if ( m_ps->acStatus() != m_ps_last-> acStatus() )
m_screensaver-> powerStatusChanged( *m_ps );
if ( m_ps->acStatus() == PowerStatus::Online ) {
return;
}
int bat = m_ps-> batteryPercentRemaining();
if ( bat < m_ps_last-> batteryPercentRemaining() ) {
if ( bat <= m_powerCritical ) {
QMessageBox battlow(
tr("WARNING"),
tr("<p>The battery level is critical!"
"<p>Keep power off until AC is restored"),
QMessageBox::Warning,
QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
0, QString::null, TRUE, WStyle_StaysOnTop);
battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
battlow.exec();
} else if ( bat <= m_powerVeryLow )
pa->alert( tr( "The battery is running very low. "), 2 );
}
if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) {
QMessageBox battlow(
tr("WARNING"),
tr("<p>The Back-up battery is very low"
"<p>Please charge the back-up battery"),
QMessageBox::Warning,
QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
0, QString::null, TRUE, WStyle_StaysOnTop);
battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
battlow.exec();
}
}
void ServerApplication::systemMessage( const QCString& msg,
const QByteArray& data ) {
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "setScreenSaverInterval(int)" ) {
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp
index f43a2a3..2731568 100644
--- a/core/launcher/shutdownimpl.cpp
+++ b/core/launcher/shutdownimpl.cpp
@@ -13,161 +13,161 @@
**
** 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 "shutdownimpl.h"
#include <qpe/global.h>
#include <qpe/qcopenvelope_qws.h>
#include <qtimer.h>
#include <qprogressbar.h>
#include <qpushbutton.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qlayout.h>
static void changeButtonColor ( QPushButton *btn, const QColor &col )
{
QPalette pal = btn-> palette ( );
pal. setColor ( QPalette::Active, QColorGroup::Button, col );
pal. setColor ( QPalette::Disabled, QColorGroup::Button, col );
pal. setColor ( QPalette::Inactive, QColorGroup::Button, col );
btn-> setPalette ( pal );
}
ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl )
: QWidget ( parent, name, fl )
{
setCaption ( tr( "Shutdown..." ) );
QVBoxLayout *vbox = new QVBoxLayout ( this );
vbox-> setSpacing ( 3 );
vbox-> setMargin ( 6 );
QButtonGroup *btngrp = new QButtonGroup ( this );
btngrp-> setTitle ( tr( "Terminate" ) );
btngrp-> setColumnLayout ( 0, Qt::Vertical );
btngrp-> layout ( ) -> setSpacing ( 0 );
btngrp-> layout ( ) -> setMargin ( 0 );
QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) );
grid-> setAlignment ( Qt::AlignTop );
grid-> setSpacing ( 3 );
grid-> setMargin ( 7 );
QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" );
changeButtonColor ( quit, QColor ( 236, 236, 179 ) );
btngrp-> insert ( quit, 4 );
grid-> addWidget ( quit, 1, 1 );
QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" );
changeButtonColor ( reboot, QColor( 236, 183, 181 ) );
btngrp-> insert ( reboot, 2 );
grid-> addWidget( reboot, 1, 0 );
QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" );
changeButtonColor ( restart, QColor( 236, 236, 179 ) );
btngrp-> insert ( restart, 3 );
grid-> addWidget ( restart, 0, 1 );
QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" );
changeButtonColor ( shutdown, QColor( 236, 183, 181 ) );
btngrp-> insert ( shutdown, 1 );
grid-> addWidget ( shutdown, 0, 0 );
vbox-> addWidget ( btngrp );
m_info = new QLabel ( this, "info" );
m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) );
vbox-> addWidget ( m_info );
m_progress = new QProgressBar ( this, "progressBar" );
m_progress-> setFrameShape ( QProgressBar::Panel );
m_progress-> setFrameShadow ( QProgressBar::Sunken );
m_progress-> setTotalSteps ( 20 );
m_progress-> setIndicatorFollowsStyle ( false );
vbox-> addWidget ( m_progress );
vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" );
changeButtonColor ( cancel, QColor( 181, 222, 178 ) );
cancel-> setDefault ( true );
cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) );
vbox-> addWidget ( cancel );
m_timer = new QTimer ( this );
- connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) );
+ connect ( m_timer, SIGNAL( timeout() ), this, SLOT( timeout() ) );
- connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) );
- connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) );
+ connect ( btngrp, SIGNAL( clicked(int) ), this, SLOT( buttonClicked(int) ) );
+ connect ( cancel, SIGNAL( clicked() ), this, SLOT( cancelClicked() ) );
m_progress-> hide ( );
Global::hideInputMethod ( );
}
void ShutdownImpl::buttonClicked ( int b )
{
m_counter = 0;
switch ( b ) {
case 1:
m_operation = ShutdownSystem;
break;
case 2:
m_operation = RebootSystem;
break;
case 3:
m_operation = RestartDesktop;
break;
case 4:
m_operation = TerminateDesktop;
break;
}
m_info-> hide ( );
m_progress-> show ( );
m_timer-> start ( 300 );
timeout ( );
}
void ShutdownImpl::cancelClicked ( )
{
m_progress-> hide ( );
m_info-> show ( );
if ( m_timer-> isActive ( ) )
m_timer-> stop ( );
else
close ( );
}
void ShutdownImpl::timeout ( )
{
if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) {
m_progress-> hide ( );
m_timer-> stop ( );
emit shutdown ( m_operation );
}
else
m_progress-> setProgress ( m_counter );
}
void ShutdownImpl::hide ( )
{
if ( isVisible ( )) {
// hack - shutdown is a launcher dialog, but treated like a standalone app
QCopEnvelope e( "QPE/System", "closing(QString)" );
e << QString ( "shutdown" );
}
QWidget::hide ( );
}
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 491a8a3..91e2f20 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -120,194 +120,194 @@ QSize SafeMode::sizeHint() const
return QSize( fm.width(message), fm.height() );
}
void SafeMode::paintEvent( QPaintEvent* )
{
QPainter p(this);
p.drawText( rect(), AlignCenter, message );
}
//---------------------------------------------------------------------------
class LockKeyState : public QWidget
{
public:
LockKeyState( QWidget *parent ) :
QWidget(parent),
nl(initNumLock()), cl(FALSE)
{
nl_pm = Resource::loadPixmap("numlock");
cl_pm = Resource::loadPixmap("capslock");
}
QSize sizeHint() const
{
return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
}
void toggleNumLockState()
{
nl = !nl; repaint();
}
void toggleCapsLockState()
{
cl = !cl; repaint();
}
void paintEvent( QPaintEvent * )
{
int y = (height()-sizeHint().height())/2;
QPainter p(this);
if ( nl )
p.drawPixmap(1,y,nl_pm);
if ( cl )
p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
}
private:
QPixmap nl_pm, cl_pm;
bool nl, cl;
};
//---------------------------------------------------------------------------
TaskBar::~TaskBar()
{
}
TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
{
Config cfg( "Launcher" );
cfg.setGroup( "InputMethods" );
resizeRunningApp = cfg.readBoolEntry( "Resize", true );
sm = new StartMenu( this );
connect( sm, SIGNAL(tabSelected(const QString&)), this,
SIGNAL(tabSelected(const QString&)) );
inputMethods = new InputMethods( this );
connect( inputMethods, SIGNAL(inputToggled(bool)),
this, SLOT(calcMaxWindowRect()) );
stack = new QWidgetStack( this );
stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
label = new QLabel(stack);
runningAppBar = new RunningAppBar(stack);
stack->raiseWidget(runningAppBar);
waitIcon = new Wait( this );
(void) new AppIcons( this );
sysTray = new SysTray( this );
/* ### FIXME plugin loader and safe mode */
#if 0
if (PluginLoader::inSafeMode())
(void)new SafeMode( this );
#endif
// ## make customizable in some way?
#ifdef QT_QWS_CUSTOM
lockState = new LockKeyState( this );
#else
lockState = 0;
#endif
#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(receive(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(receive(const QCString&,const QByteArray&)) );
#endif
#endif
waitTimer = new QTimer( this );
connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
clearer = new QTimer( this );
QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
}
void TaskBar::setStatusMessage( const QString &text )
{
if ( !text.isEmpty() ) {
label->setText( text );
stack->raiseWidget( label );
if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
sysTray->hide();
clearer->start( 3000, TRUE );
} else {
clearStatusBar();
}
}
void TaskBar::clearStatusBar()
{
label->clear();
stack->raiseWidget(runningAppBar);
if ( sysTray )
sysTray->show();
// stack->raiseWidget( mru );
}
void TaskBar::startWait()
{
waitIcon->setWaiting( true );
// a catchall stop after 10 seconds...
waitTimer->start( 10 * 1000, true );
}
void TaskBar::stopWait(const QString&)
{
waitTimer->stop();
waitIcon->setWaiting( false );
}
void TaskBar::stopWait()
{
waitTimer->stop();
waitIcon->setWaiting( false );
}
/*
* This resizeEvent will be captured by
* the ServerInterface and it'll layout
* and calc rect. Now if we go from bigger
* to smaller screen the SysTray is out of
* bounds and repaint() won't trigger an Event
*/
void TaskBar::resizeEvent( QResizeEvent *e )
{
if ( sysTray )
sysTray->hide();
QHBox::resizeEvent( e );
if ( sysTray )
sysTray->show();
qWarning("TaskBar::resize event");
}
void TaskBar::styleChange( QStyle &s )
{
QHBox::styleChange( s );
calcMaxWindowRect();
}
void TaskBar::calcMaxWindowRect()
{
if ( resizeRunningApp )
{
#if defined(Q_WS_QWS)
QRect wr;
int displayWidth = qApp->desktop()->width();
QRect ir = inputMethods->inputRect();
if ( ir.isValid() ) {
wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
} else {
wr.setCoords( 0, 0, displayWidth-1, y()-1 );
}
#if QT_VERSION < 0x030000
QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) );
#else
QWSServer::setMaxWindowRect( wr );
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index b998e95..a5e20b2 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -1,191 +1,191 @@
/**********************************************************************
** 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.
**
**********************************************************************/
//#define _XOPEN_SOURCE
#include <opie2/oglobal.h>
#ifndef Q_OS_WIN32
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#ifndef Q_OS_MACX
#include <shadow.h>
#include <crypt.h>
#endif /* Q_OS_MACX */
#else
#include <stdlib.h>
#include <time.h>
#endif
#if defined(_OS_LINUX_)
#include <shadow.h>
#endif
#include <qtextstream.h>
#include <qmessagebox.h>
//#include <qtopia/qcopchannel_qws.h>
#include <qtopia/process.h>
#include <qtopia/private/contact.h>
#include <qtopia/version.h>
#ifdef Q_WS_QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
#include "transferserver.h"
#include <qtopia/qprocess.h>
const int block_size = 51200;
TransferServer::TransferServer( Q_UINT16 port, QObject *parent,
const char* name)
: QServerSocket( port, 1, parent, name )
{
connections.setAutoDelete( TRUE );
if ( !ok() )
qWarning( "Failed to bind to port %d", port );
}
void TransferServer::authorizeConnections()
{
QListIterator<ServerPI> it(connections);
while ( it.current() ) {
if ( !it.current()->verifyAuthorised() ) {
- disconnect( it.current(), SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) );
+ disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) );
connections.removeRef( it.current() );
} else
++it;
}
}
void TransferServer::closed(ServerPI *item)
{
connections.removeRef(item);
}
TransferServer::~TransferServer()
{
}
void TransferServer::newConnection( int socket )
{
ServerPI *ptr = new ServerPI( socket, this );
- connect( ptr, SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) );
+ connect( ptr, SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) );
connections.append( ptr );
}
QString SyncAuthentication::serverId()
{
Config cfg("Security");
cfg.setGroup("Sync");
QString r = cfg.readEntry("serverid");
if ( r.isEmpty() ) {
r = OGlobal::generateUuid();
cfg.writeEntry("serverid", r );
}
return r;
}
QString SyncAuthentication::ownerName()
{
QString vfilename = Global::applicationFileName("addressbook",
"businesscard.vcf");
if (QFile::exists(vfilename)) {
Contact c;
c = Contact::readVCard( vfilename )[0];
return c.fullName();
}
return QString::null;
}
QString SyncAuthentication::loginName()
{
struct passwd *pw = 0L;
#ifndef Q_OS_WIN32
pw = getpwuid( geteuid() );
return QString::fromLocal8Bit( pw->pw_name );
#else
//### revise
return QString();
#endif
}
int SyncAuthentication::isAuthorized(QHostAddress peeraddress)
{
Config cfg("Security");
cfg.setGroup("Sync");
// QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0");
uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100);
// QHostAddress allowed;
// allowed.setAddress(allowedstr);
// uint auth_peer = allowed.ip4Addr();
uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24);
uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined
? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits));
return (peeraddress.ip4Addr() & mask) == auth_peer;
}
bool SyncAuthentication::checkUser( const QString& user )
{
if ( user.isEmpty() ) return FALSE;
QString euser = loginName();
return user == euser;
}
bool SyncAuthentication::checkPassword( const QString& password )
{
#ifdef ALLOW_UNIX_USER_FTP
// First, check system password...
struct passwd *pw = 0;
struct spwd *spw = 0;
pw = getpwuid( geteuid() );
spw = getspnam( pw->pw_name );
QString cpwd = QString::fromLocal8Bit( pw->pw_passwd );
if ( cpwd == "x" && spw )
cpwd = QString::fromLocal8Bit( spw->sp_pwdp );
// Note: some systems use more than crypt for passwords.
QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) );
if ( cpwd == cpassword )
return TRUE;
#endif
static int lastdenial=0;
static int denials=0;
int now = time(0);
Config cfg("Security");
cfg.setGroup("SyncMode");
int mode = cfg.readNumEntry("Mode", 0x02 );
//No pass word needed if the user really needs it
if (mode & 0x04) {
@@ -240,205 +240,205 @@ bool SyncAuthentication::checkPassword( const QString& password )
/*
* we need to support old Sync software and QtopiaDesktop
*/
if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) {
Config cfg( "Security" );
cfg.setGroup("Sync");
QStringList pwds = cfg.readListEntry("Passwords",' ');
for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) {
#ifndef Q_OS_WIN32
QString cpassword = QString::fromLocal8Bit(
crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) );
#else
// ### revise
QString cpassword("");
#endif
if ( *it == cpassword ) {
lock--;
return TRUE;
}
}
// Unrecognized system. Be careful...
QMessageBox unrecbox(
tr("Sync Connection"),
tr( "<p>An unrecognized system is requesting access to this device."
"<p>If you have just initiated a Sync for the first time, this is normal."),
QMessageBox::Warning,
QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
0, QString::null, TRUE, WStyle_StaysOnTop);
unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny"));
unrecbox.setButtonText(QMessageBox::Yes, tr("Allow"));
if ( (denials > 2 && now < lastdenial+600)
|| unrecbox.exec() != QMessageBox::Yes)
{
denials++;
lastdenial=now;
lock--;
return FALSE;
} else {
const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/.";
char salt[2];
salt[0]= salty[rand() % (sizeof(salty)-1)];
salt[1]= salty[rand() % (sizeof(salty)-1)];
#ifndef Q_OS_WIN32
QString cpassword = QString::fromLocal8Bit(
crypt( password.mid(8).local8Bit(), salt ) );
#else
//### revise
QString cpassword("");
#endif
denials=0;
pwds.prepend(cpassword);
cfg.writeEntry("Passwords",pwds,' ');
lock--;
return TRUE;
}
}
lock--;
return FALSE;
}
ServerPI::ServerPI( int socket, QObject *parent, const char* name )
: QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ),
storFileSize(-1)
{
state = Connected;
setSocket( socket );
peerport = peerPort();
peeraddress = peerAddress();
#ifndef INSECURE
if ( !SyncAuthentication::isAuthorized(peeraddress) ) {
state = Forbidden;
startTimer( 0 );
} else
#endif
{
connect( this, SIGNAL( readyRead() ), SLOT( read() ) );
connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
passiv = FALSE;
for( int i = 0; i < 4; i++ )
wait[i] = FALSE;
send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr
state = Wait_USER;
dtp = new ServerDTP( this );
connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) );
connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) );
- connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) );
+ connect( dtp, SIGNAL( error(int) ), SLOT( dtpError(int) ) );
directory = QDir::currentDirPath();
static int p = 1024;
while ( !serversocket || !serversocket->ok() ) {
delete serversocket;
serversocket = new ServerSocket( ++p, this );
}
- connect( serversocket, SIGNAL( newIncomming( int ) ),
- SLOT( newConnection( int ) ) );
+ connect( serversocket, SIGNAL( newIncomming(int) ),
+ SLOT( newConnection(int) ) );
}
}
ServerPI::~ServerPI()
{
close();
if ( dtp )
dtp->close();
delete dtp;
delete serversocket;
}
bool ServerPI::verifyAuthorised()
{
if ( !SyncAuthentication::isAuthorized(peerAddress()) ) {
state = Forbidden;
return FALSE;
}
return TRUE;
}
void ServerPI::connectionClosed()
{
// qDebug( "Debug: Connection closed" );
emit connectionClosed(this);
}
void ServerPI::send( const QString& msg )
{
QTextStream os( this );
os << msg << endl;
//qDebug( "Reply: %s", msg.latin1() );
}
void ServerPI::read()
{
while ( canReadLine() )
process( readLine().stripWhiteSpace() );
}
bool ServerPI::checkReadFile( const QString& file )
{
QString filename;
if ( file[0] != "/" )
filename = directory.path() + "/" + file;
else
filename = file;
QFileInfo fi( filename );
return ( fi.exists() && fi.isReadable() );
}
bool ServerPI::checkWriteFile( const QString& file )
{
QString filename;
if ( file[0] != "/" )
filename = directory.path() + "/" + file;
else
filename = file;
QFileInfo fi( filename );
if ( fi.exists() )
if ( !QFile( filename ).remove() )
return FALSE;
return TRUE;
}
void ServerPI::process( const QString& message )
{
//qDebug( "Command: %s", message.latin1() );
// split message using "," as separator
QStringList msg = QStringList::split( " ", message );
if ( msg.isEmpty() ) return;
// command token
QString cmd = msg[0].upper();
// argument token
QString arg;
if ( msg.count() >= 2 )
arg = msg[1];
// full argument string
QString args;
if ( msg.count() >= 2 ) {
QStringList copy( msg );
// FIXME: for Qt3
// copy.pop_front()
copy.remove( copy.begin() );
args = copy.join( " " );
}
@@ -993,193 +993,193 @@ QString ServerPI::fileListing( QFileInfo *info )
QString ServerPI::permissionString( QFileInfo *info )
{
if ( !info ) return QString( "---------" );
QString s;
// user
if ( info->permission( QFileInfo::ReadUser ) ) s += "r";
else s += "-";
if ( info->permission( QFileInfo::WriteUser ) ) s += "w";
else s += "-";
if ( info->permission( QFileInfo::ExeUser ) ) s += "x";
else s += "-";
// group
if ( info->permission( QFileInfo::ReadGroup ) ) s += "r";
else s += "-";
if ( info->permission( QFileInfo::WriteGroup ) )s += "w";
else s += "-";
if ( info->permission( QFileInfo::ExeGroup ) ) s += "x";
else s += "-";
// exec
if ( info->permission( QFileInfo::ReadOther ) ) s += "r";
else s += "-";
if ( info->permission( QFileInfo::WriteOther ) ) s += "w";
else s += "-";
if ( info->permission( QFileInfo::ExeOther ) ) s += "x";
else s += "-";
return s;
}
void ServerPI::newConnection( int socket )
{
//qDebug( "New incomming connection" );
if ( !passiv ) return;
if ( wait[SendFile] ) {
QStringList targets;
if ( backupRestoreGzip( waitfile, targets ) )
dtp->sendGzipFile( waitfile, targets );
else
dtp->sendFile( waitfile );
dtp->setSocket( socket );
}
else if ( wait[RetrieveFile] ) {
qDebug("check retrieve file");
if ( backupRestoreGzip( waitfile ) )
dtp->retrieveGzipFile( waitfile );
else
dtp->retrieveFile( waitfile, storFileSize );
dtp->setSocket( socket );
}
else if ( wait[SendByteArray] ) {
dtp->sendByteArray( waitarray );
dtp->setSocket( socket );
}
else if ( wait[RetrieveByteArray] ) {
qDebug("retrieve byte array");
dtp->retrieveByteArray();
dtp->setSocket( socket );
}
else
waitsocket = socket;
for( int i = 0; i < 4; i++ )
wait[i] = FALSE;
}
QString ServerPI::absFilePath( const QString& file )
{
if ( file.isEmpty() ) return file;
QString filepath( file );
if ( file[0] != "/" )
filepath = directory.path() + "/" + file;
return filepath;
}
void ServerPI::timerEvent( QTimerEvent * )
{
connectionClosed();
}
ServerDTP::ServerDTP( QObject *parent, const char* name)
: QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ),
retrieveTargzProc( 0 )
{
connect( this, SIGNAL( connected() ), SLOT( connected() ) );
connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
- connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) );
+ connect( this, SIGNAL( bytesWritten(int) ), SLOT( bytesWritten(int) ) );
connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) );
createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); // No tr
createTargzProc->setCommunication( QProcess::Stdout );
createTargzProc->setWorkingDirectory( QDir::rootDirPath() );
connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) );
retrieveTargzProc = new QProcess( this, "retrieveTargzProc" );
retrieveTargzProc->setCommunication( QProcess::Stdin );
retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() );
connect( retrieveTargzProc, SIGNAL( processExited() ),
SIGNAL( completed() ) );
connect( retrieveTargzProc, SIGNAL( processExited() ),
SLOT( extractTarDone() ) );
}
ServerDTP::~ServerDTP()
{
buf.close();
if ( RetrieveFile == mode && file.isOpen() ) {
// We're being shutdown before the client closed.
file.close();
if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) {
qDebug( "STOR incomplete" );
file.remove();
}
} else {
file.close();
}
createTargzProc->kill();
}
void ServerDTP::extractTarDone()
{
qDebug("extract done");
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/System", "restoreDone(QString)" );
e << file.name();
#endif
}
void ServerDTP::connected()
{
// send file mode
switch ( mode ) {
case SendFile :
if ( !file.exists() || !file.open( IO_ReadOnly) ) {
emit failed();
mode = Idle;
return;
}
//qDebug( "Debug: Sending file '%s'", file.name().latin1() );
bytes_written = 0;
if ( file.size() == 0 ) {
//make sure it doesn't hang on empty files
file.close();
emit completed();
mode = Idle;
} else {
// Don't write more if there is plenty buffered already.
if ( bytesToWrite() <= block_size && !file.atEnd() ) {
QCString s;
s.resize( block_size );
int bytes = file.readBlock( s.data(), block_size );
writeBlock( s.data(), bytes );
}
}
break;
case SendGzipFile:
if ( createTargzProc->isRunning() ) {
// SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY
qWarning("Previous tar --gzip process is still running; killing it...");
createTargzProc->kill();
}
bytes_written = 0;
qDebug("==>start send tar process");
if ( !createTargzProc->start() )
qWarning("Error starting %s",
createTargzProc->arguments().join(" ").latin1());
break;
case SendBuffer:
if ( !buf.open( IO_ReadOnly) ) {
emit failed();
mode = Idle;
return;
}
// qDebug( "Debug: Sending byte array" );
bytes_written = 0;
while( !buf.atEnd() )
putch( buf.getch() );
buf.close();
break;