summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/qws/config.in13
-rw-r--r--core/qws/oqwsserver.cpp2
-rw-r--r--core/qws/oqwsserver.h2
-rw-r--r--core/qws/qws.pro4
-rw-r--r--core/qws/transferserver.cpp47
-rw-r--r--core/qws/transferserver.h15
6 files changed, 37 insertions, 46 deletions
diff --git a/core/qws/config.in b/core/qws/config.in
index 3706405..903eaa1 100644
--- a/core/qws/config.in
+++ b/core/qws/config.in
@@ -1,16 +1,5 @@
config QWS
boolean "Minimal QWS Server"
default "n"
- depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && EXPERIMENTAL
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && EXPERIMENTAL
-# menu "Advanced QWS Server Config"
-# config QWS_QCOP
-# bool "QCop bridge and Transfer server (sync)"
-# default y
-# depends on QWS
-#
-# config QWS_PACKAGE
-# bool "Package Slave (package installs via sync software)"
-# default n
-# depends on QWS
-# endmenu
diff --git a/core/qws/oqwsserver.cpp b/core/qws/oqwsserver.cpp
index 907686a..d6b6504 100644
--- a/core/qws/oqwsserver.cpp
+++ b/core/qws/oqwsserver.cpp
@@ -1,64 +1,64 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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 <syslog.h>
#include "oqwsserver.h"
#include "qcopbridge.h"
#include "transferserver.h"
#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ )
#include <qpe/custom.h>
#endif
-#include <opie/odevice.h>
+#include <opie2/odevice.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
using namespace Opie;
OQWSServer::OQWSServer( int& argc, char **argv, Type appType )
: QPEApplication( argc, argv, appType )
{
startServers();
}
OQWSServer::~OQWSServer()
{
terminateServers();
}
bool OQWSServer::eventFilter ( QObject *o, QEvent *e )
{
#if 0
if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
QKeyEvent *ke = (QKeyEvent *) e;
const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
if ( db ) {
if (checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )))
return true; //checkButtonAction retrune false if events should be routed through
}
diff --git a/core/qws/oqwsserver.h b/core/qws/oqwsserver.h
index b95c3fb..c8622d4 100644
--- a/core/qws/oqwsserver.h
+++ b/core/qws/oqwsserver.h
@@ -1,57 +1,57 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef __DESKTOP_H__
#define __DESKTOP_H__
#include <qpe/qpeapplication.h>
-#include <opie/odevicebutton.h>
+#include <opie2/odevicebutton.h>
#include <qwidget.h>
#include <qdatetime.h>
class QCopBridge;
class TransferServer;
class OQWSServer : public QPEApplication
{
Q_OBJECT
public:
OQWSServer( int& argc, char **argv, Type t );
~OQWSServer();
protected:
virtual bool eventFilter ( QObject *o, QEvent *e );
#ifdef Q_WS_QWS
bool qwsEventFilter( QWSEvent * );
#endif
private:
void startServers();
void terminateServers();
QCopBridge *m_qcopBridge;
TransferServer *m_transferServer;
};
#endif // __DESKTOP_H__
diff --git a/core/qws/qws.pro b/core/qws/qws.pro
index 5656a59..50d0b2b 100644
--- a/core/qws/qws.pro
+++ b/core/qws/qws.pro
@@ -1,20 +1,20 @@
TEMPLATE = app
CONFIG = qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = \
transferserver.h \
qcopbridge.h \
oqwsserver.h
SOURCES = \
main.cpp \
transferserver.cpp \
qcopbridge.cpp \
oqwsserver.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include .
-TARGET = op-qws
-LIBS += -lqpe -lopie
+TARGET = qws
+LIBS += -lqpe -lopiecore2 -lopieui2
include ( $(OPIEDIR)/include.pro )
diff --git a/core/qws/transferserver.cpp b/core/qws/transferserver.cpp
index daf63ec..d0fec89 100644
--- a/core/qws/transferserver.cpp
+++ b/core/qws/transferserver.cpp
@@ -35,65 +35,66 @@
// anywhere ? Therfore I removed it completely..
// I think it should be made permanentyl !? (eilers)
#warning "Where should uuid/uuid.h be found ? Removed this part .. (eilers)"
#if 0
extern "C"
{
#include <uuid/uuid.h>
#define UUID_H_INCLUDED
}
#endif
#endif // not defined linux
#if defined(_OS_LINUX_)
#include <shadow.h>
#elif defined(Q_OS_MACX)
#include <stdlib.h>
#endif
#include <qtextstream.h>
#include <qmessagebox.h>
//#include <qpe/qcopchannel_qws.h>
#include <qpe/process.h>
#include <qpe/global.h>
#include <qpe/config.h>
#include <qpe/contact.h>
#include <qpe/version.h>
#include <qpe/qcopenvelope_qws.h>
#include "transferserver.h"
-#include <opie/oprocess.h>
+#include <opie2/oprocess.h>
+using namespace Opie::Core;
const int block_size = 51200;
TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
const char* name )
: QServerSocket( port, 1, parent, name )
{
if ( !ok() )
qWarning( "Failed to bind to port %d", port );
}
TransferServer::~TransferServer()
{
}
void TransferServer::newConnection( int socket )
{
(void) new ServerPI( socket, this );
}
/*
* small class in anonymous namespace
* to generate a QUUid for us
*/
namespace
{
struct UidGen
{
QString uuid();
};
#if defined(Q_OS_MACX)
QString UidGen::uuid()
@@ -1020,137 +1021,137 @@ void ServerPI::newConnection( int socket )
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 ), gzipProc( 0 )
{
connect( this, SIGNAL( connected() ), SLOT( connected() ) );
connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
connect( this, SIGNAL( bytesWritten(int) ), SLOT( bytesWritten(int) ) );
connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) );
- gzipProc = new OProcess( this, "gzipProc" );
+ gzipProc = new Opie::Core::OProcess( this, "gzipProc" );
- createTargzProc = new OProcess( QString("tar"), this, "createTargzProc");
+ createTargzProc = new Opie::Core::OProcess( QString("tar"), this, "createTargzProc");
createTargzProc->setWorkingDirectory( QDir::rootDirPath() );
- connect( createTargzProc, SIGNAL( processExited(OProcess*) ), SLOT( targzDone() ) );
+ connect( createTargzProc, SIGNAL( processExited(Opie::Core::OProcess*) ), SLOT( targzDone() ) );
QStringList args = "tar";
args += "-xv";
- retrieveTargzProc = new OProcess( args, this, "retrieveTargzProc" );
+ retrieveTargzProc = new Opie::Core::OProcess( args, this, "retrieveTargzProc" );
retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() );
- connect( retrieveTargzProc, SIGNAL( processExited(OProcess*) ),
+ connect( retrieveTargzProc, SIGNAL( processExited(Opie::Core::OProcess*) ),
SIGNAL( completed() ) );
- connect( retrieveTargzProc, SIGNAL( processExited(OProcess*) ),
+ connect( retrieveTargzProc, SIGNAL( processExited(Opie::Core::OProcess*) ),
SLOT( extractTarDone() ) );
}
ServerDTP::~ServerDTP()
{
buf.close();
file.close();
createTargzProc->kill();
}
void ServerDTP::extractTarDone()
{
qDebug("extract done");
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "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 {
if ( !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(OProcess::NotifyOnExit, OProcess::Stdout) )
+ if ( !createTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdout) )
qWarning("Error starting %s or %s",
createTargzProc->args()[0].data(),
gzipProc->args()[0].data());
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;
case RetrieveFile:
// retrieve file mode
if ( file.exists() && !file.remove() ) {
emit failed();
mode = Idle;
return ;
}
if ( !file.open( IO_WriteOnly) ) {
emit failed();
mode = Idle;
return ;
}
// qDebug( "Debug: Retrieving file %s", file.name().latin1() );
break;
@@ -1227,170 +1228,170 @@ void ServerDTP::bytesWritten( int bytes )
mode = Idle;
}
else if ( !file.atEnd() ) {
QCString s;
s.resize( block_size );
int bytes = file.readBlock( s.data(), block_size );
writeBlock( s.data(), bytes );
}
}
// send buffer mode
if ( SendBuffer == mode ) {
if ( bytes_written == buf.size() ) {
// qDebug( "Debug: Sending complete: %d bytes", buf.size() );
emit completed();
mode = Idle;
}
}
}
void ServerDTP::readyRead()
{
// retrieve file mode
if ( RetrieveFile == mode ) {
QCString s;
s.resize( bytesAvailable() );
readBlock( s.data(), bytesAvailable() );
file.writeBlock( s.data(), s.size() );
}
else if ( RetrieveGzipFile == mode ) {
if ( !gzipProc->isRunning() )
- gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout ));
+ gzipProc->start(Opie::Core::OProcess::NotifyOnExit, (Opie::Core::OProcess::Communication) ( Opie::Core::OProcess::Stdin | Opie::Core::OProcess::Stdout ));
QByteArray s;
s.resize( bytesAvailable() );
readBlock( s.data(), bytesAvailable() );
gzipProc->writeStdin( s.data(), s.size() );
qDebug("wrote %d bytes to ungzip ", s.size() );
}
// retrieve buffer mode
else if ( RetrieveBuffer == mode ) {
QCString s;
s.resize( bytesAvailable() );
readBlock( s.data(), bytesAvailable() );
buf.writeBlock( s.data(), s.size() );
}
}
-void ServerDTP::writeTargzBlock(OProcess *, char *buffer, int buflen)
+void ServerDTP::writeTargzBlock(Opie::Core::OProcess *, char *buffer, int buflen)
{
writeBlock( buffer, buflen );
qDebug("writeTargzBlock %d", buflen);
if ( !createTargzProc->isRunning() ) {
qDebug("tar and gzip done");
emit completed();
mode = Idle;
- disconnect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ),
- this, SLOT( writeTargzBlock(OProcess*,char*,int) ) );
+ disconnect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
+ this, SLOT( writeTargzBlock(Opie::Core::OProcess*,char*,int) ) );
}
}
void ServerDTP::targzDone()
{
//qDebug("targz done");
- disconnect( createTargzProc, SIGNAL( receivedStdout(OProcess*,char*,int) ),
- this, SLOT( gzipTarBlock(OProcess*,char*,int) ) );
+ disconnect( createTargzProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
+ this, SLOT( gzipTarBlock(Opie::Core::OProcess*,char*,int) ) );
gzipProc->closeStdin();
}
-void ServerDTP::gzipTarBlock(OProcess *, char *buffer, int buflen)
+void ServerDTP::gzipTarBlock(Opie::Core::OProcess *, char *buffer, int buflen)
{
//qDebug("gzipTarBlock");
if ( !gzipProc->isRunning() ) {
//qDebug("auto start gzip proc");
- gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout ));
+ gzipProc->start(Opie::Core::OProcess::NotifyOnExit, (Opie::Core::OProcess::Communication) ( Opie::Core::OProcess::Stdin | Opie::Core::OProcess::Stdout ));
}
gzipProc->writeStdin( buffer, buflen );
}
void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port )
{
file.setName( fn );
mode = SendFile;
connectToHost( host.toString(), port );
}
void ServerDTP::sendFile( const QString fn )
{
file.setName( fn );
mode = SendFile;
}
void ServerDTP::sendGzipFile( const QString &fn,
const QStringList &archiveTargets,
const QHostAddress& host, Q_UINT16 port )
{
sendGzipFile( fn, archiveTargets );
connectToHost( host.toString(), port );
}
void ServerDTP::sendGzipFile( const QString &fn,
const QStringList &archiveTargets )
{
mode = SendGzipFile;
file.setName( fn );
QStringList args = "tar";
args += "-cv";
args += archiveTargets;
qDebug("sendGzipFile %s", args.join(" ").latin1() );
createTargzProc->clearArguments( );
*createTargzProc << args;
connect( createTargzProc,
- SIGNAL( receivedStdout(OProcess*,char*,int) ), SLOT( gzipTarBlock(OProcess*,char*,int) ) );
+ SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ), SLOT( gzipTarBlock(Opie::Core::OProcess*,char*,int) ) );
gzipProc->clearArguments( );
*gzipProc << "gzip";
- connect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ),
- SLOT( writeTargzBlock(OProcess*,char*,int) ) );
+ connect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
+ SLOT( writeTargzBlock(Opie::Core::OProcess*,char*,int) ) );
}
void ServerDTP::gunzipDone()
{
qDebug("gunzipDone");
disconnect( gzipProc, SIGNAL( processExited() ),
this, SLOT( gunzipDone() ) );
retrieveTargzProc->closeStdin();
- disconnect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ),
- this, SLOT( tarExtractBlock(OProcess*,char*,int) ) );
+ disconnect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
+ this, SLOT( tarExtractBlock(Opie::Core::OProcess*,char*,int) ) );
}
-void ServerDTP::tarExtractBlock(OProcess *, char *buffer, int buflen)
+void ServerDTP::tarExtractBlock(Opie::Core::OProcess *, char *buffer, int buflen)
{
qDebug("tarExtractBlock");
if ( !retrieveTargzProc->isRunning() ) {
qDebug("auto start ungzip proc");
- if ( !retrieveTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdin) )
+ if ( !retrieveTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdin) )
qWarning(" failed to start tar -x process");
}
retrieveTargzProc->writeStdin( buffer, buflen );
}
void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port )
{
file.setName( fn );
mode = RetrieveFile;
connectToHost( host.toString(), port );
}
void ServerDTP::retrieveFile( const QString fn )
{
file.setName( fn );
mode = RetrieveFile;
}
void ServerDTP::retrieveGzipFile( const QString &fn )
{
qDebug("retrieveGzipFile %s", fn.latin1());
file.setName( fn );
mode = RetrieveGzipFile;
gzipProc->clearArguments();
*gzipProc << "gunzip";
connect( gzipProc, SIGNAL( readyReadStdout() ),
SLOT( tarExtractBlock() ) );
connect( gzipProc, SIGNAL( processExited() ),
SLOT( gunzipDone() ) );
}
diff --git a/core/qws/transferserver.h b/core/qws/transferserver.h
index 1c5ab4b..82dae40 100644
--- a/core/qws/transferserver.h
+++ b/core/qws/transferserver.h
@@ -1,59 +1,60 @@
/**********************************************************************
** 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 <qserversocket.h>
#include <qsocket.h>
#include <qdir.h>
#include <qfile.h>
#include <qbuffer.h>
class QFileInfo;
-class OProcess;
+namespace Opie { namespace Core { class OProcess; } }
+
class TransferServer : public QServerSocket
{
Q_OBJECT
public:
TransferServer( Q_UINT16 port, QObject *parent = 0, const char* name = 0 );
virtual ~TransferServer();
void newConnection( int socket );
};
class SyncAuthentication : QObject
{
Q_OBJECT
public:
static int isAuthorized(QHostAddress peeraddress);
static bool checkPassword(const QString& pw);
static bool checkUser(const QString& user);
static QString serverId();
static QString loginName();
static QString ownerName();
};
class ServerDTP : public QSocket
{
Q_OBJECT
public:
ServerDTP( QObject *parent = 0, const char* name = 0 );
@@ -63,81 +64,81 @@ public:
RetrieveFile, RetrieveGzipFile, RetrieveBuffer };
void sendFile( const QString fn );
void sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port );
void sendGzipFile( const QString &fn, const QStringList &archiveTargets );
void sendGzipFile( const QString &fn, const QStringList &archiveTargets,
const QHostAddress& host, Q_UINT16 port );
void sendByteArray( const QByteArray& array );
void sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port );
void retrieveFile( const QString fn );
void retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port );
void retrieveGzipFile( const QString &fn );
void retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port );
void retrieveByteArray();
void retrieveByteArray( const QHostAddress& host, Q_UINT16 port );
Mode dtpMode() { return mode; }
QByteArray buffer() { return buf.buffer(); }
QString fileName() const { return file.name(); }
void setSocket( int socket );
signals:
void completed();
void failed();
private slots:
void connectionClosed();
void connected();
void bytesWritten( int bytes );
void readyRead();
- void writeTargzBlock(OProcess *, char *, int);
+ void writeTargzBlock(Opie::Core::OProcess *, char *, int);
void targzDone();
- void gzipTarBlock(OProcess *, char *, int);
- void tarExtractBlock(OProcess *, char *, int);
+ void gzipTarBlock(Opie::Core::OProcess *, char *, int);
+ void tarExtractBlock(Opie::Core::OProcess *, char *, int);
void gunzipDone();
void extractTarDone();
private:
unsigned long bytes_written;
Mode mode;
QFile file;
QBuffer buf;
- OProcess *createTargzProc;
- OProcess *retrieveTargzProc;
- OProcess *gzipProc;
+ Opie::Core::OProcess *createTargzProc;
+ Opie::Core::OProcess *retrieveTargzProc;
+ Opie::Core::OProcess *gzipProc;
};
class ServerSocket : public QServerSocket
{
Q_OBJECT
public:
ServerSocket( Q_UINT16 port, QObject *parent = 0, const char* name = 0 )
: QServerSocket( port, 1, parent, name ) {}
void newConnection( int socket ) { emit newIncomming( socket ); }
signals:
void newIncomming( int socket );
};
class ServerPI : public QSocket
{
Q_OBJECT
enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden };
enum Transfer { SendFile = 0, RetrieveFile = 1, SendByteArray = 2, RetrieveByteArray = 3 };
public:
ServerPI( int socket, QObject *parent = 0, const char* name = 0 );
virtual ~ServerPI();
protected slots:
void read();
void send( const QString& msg );
void process( const QString& command );
void connectionClosed();
void dtpCompleted();