summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-24 00:20:42 (UTC)
committer mickeyl <mickeyl>2004-03-24 00:20:42 (UTC)
commitcc2fd242ec29023784748e6c9d662cb1f89e83ec (patch) (unidiff)
tree55fa7676f1c64607e9a9327c2b206dd3a95625a4
parentf08adf125dbaa2a411fad9fba22443c7364afca3 (diff)
downloadopie-cc2fd242ec29023784748e6c9d662cb1f89e83ec.zip
opie-cc2fd242ec29023784748e6c9d662cb1f89e83ec.tar.gz
opie-cc2fd242ec29023784748e6c9d662cb1f89e83ec.tar.bz2
convert to libopie2
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 @@
1 config QWS 1 config QWS
2 boolean "Minimal QWS Server" 2 boolean "Minimal QWS Server"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && EXPERIMENTAL 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && EXPERIMENTAL
5 5
6# menu "Advanced QWS Server Config"
7# config QWS_QCOP
8# bool "QCop bridge and Transfer server (sync)"
9# default y
10# depends on QWS
11#
12# config QWS_PACKAGE
13# bool "Package Slave (package installs via sync software)"
14# default n
15# depends on QWS
16# 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
@@ -8,49 +8,49 @@
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <syslog.h> 21#include <syslog.h>
22 22
23#include "oqwsserver.h" 23#include "oqwsserver.h"
24#include "qcopbridge.h" 24#include "qcopbridge.h"
25#include "transferserver.h" 25#include "transferserver.h"
26 26
27 27
28#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ ) 28#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ )
29#include <qpe/custom.h> 29#include <qpe/custom.h>
30#endif 30#endif
31 31
32#include <opie/odevice.h> 32#include <opie2/odevice.h>
33 33
34 34
35 35
36#include <stdlib.h> 36#include <stdlib.h>
37#include <unistd.h> 37#include <unistd.h>
38#include <fcntl.h> 38#include <fcntl.h>
39 39
40using namespace Opie; 40using namespace Opie;
41 41
42OQWSServer::OQWSServer( int& argc, char **argv, Type appType ) 42OQWSServer::OQWSServer( int& argc, char **argv, Type appType )
43 : QPEApplication( argc, argv, appType ) 43 : QPEApplication( argc, argv, appType )
44{ 44{
45 startServers(); 45 startServers();
46} 46}
47 47
48OQWSServer::~OQWSServer() 48OQWSServer::~OQWSServer()
49{ 49{
50 terminateServers(); 50 terminateServers();
51} 51}
52 52
53bool OQWSServer::eventFilter ( QObject *o, QEvent *e ) 53bool OQWSServer::eventFilter ( QObject *o, QEvent *e )
54{ 54{
55#if 0 55#if 0
56 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { 56 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
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
@@ -2,49 +2,49 @@
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __DESKTOP_H__ 21#ifndef __DESKTOP_H__
22#define __DESKTOP_H__ 22#define __DESKTOP_H__
23 23
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <opie/odevicebutton.h> 26#include <opie2/odevicebutton.h>
27 27
28#include <qwidget.h> 28#include <qwidget.h>
29#include <qdatetime.h> 29#include <qdatetime.h>
30 30
31class QCopBridge; 31class QCopBridge;
32class TransferServer; 32class TransferServer;
33 33
34class OQWSServer : public QPEApplication 34class OQWSServer : public QPEApplication
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
38 OQWSServer( int& argc, char **argv, Type t ); 38 OQWSServer( int& argc, char **argv, Type t );
39 ~OQWSServer(); 39 ~OQWSServer();
40 40
41protected: 41protected:
42 virtual bool eventFilter ( QObject *o, QEvent *e ); 42 virtual bool eventFilter ( QObject *o, QEvent *e );
43 43
44#ifdef Q_WS_QWS 44#ifdef Q_WS_QWS
45 bool qwsEventFilter( QWSEvent * ); 45 bool qwsEventFilter( QWSEvent * );
46#endif 46#endif
47 47
48private: 48private:
49 void startServers(); 49 void startServers();
50 void terminateServers(); 50 void terminateServers();
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 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 4
5 HEADERS = \ 5 HEADERS = \
6 transferserver.h \ 6 transferserver.h \
7 qcopbridge.h \ 7 qcopbridge.h \
8 oqwsserver.h 8 oqwsserver.h
9 SOURCES = \ 9 SOURCES = \
10 main.cpp \ 10 main.cpp \
11 transferserver.cpp \ 11 transferserver.cpp \
12 qcopbridge.cpp \ 12 qcopbridge.cpp \
13 oqwsserver.cpp 13 oqwsserver.cpp
14 14
15 INCLUDEPATH+= $(OPIEDIR)/include 15 INCLUDEPATH+= $(OPIEDIR)/include
16 DEPENDPATH+= $(OPIEDIR)/include . 16 DEPENDPATH+= $(OPIEDIR)/include .
17 TARGET = op-qws 17 TARGET = qws
18 LIBS += -lqpe -lopie 18 LIBS += -lqpe -lopiecore2 -lopieui2
19 19
20include ( $(OPIEDIR)/include.pro ) 20include ( $(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
@@ -43,49 +43,50 @@ extern "C"
43#define UUID_H_INCLUDED 43#define UUID_H_INCLUDED
44} 44}
45 45
46#endif 46#endif
47 47
48#endif // not defined linux 48#endif // not defined linux
49 49
50#if defined(_OS_LINUX_) 50#if defined(_OS_LINUX_)
51#include <shadow.h> 51#include <shadow.h>
52#elif defined(Q_OS_MACX) 52#elif defined(Q_OS_MACX)
53#include <stdlib.h> 53#include <stdlib.h>
54#endif 54#endif
55 55
56#include <qtextstream.h> 56#include <qtextstream.h>
57#include <qmessagebox.h> 57#include <qmessagebox.h>
58//#include <qpe/qcopchannel_qws.h> 58//#include <qpe/qcopchannel_qws.h>
59#include <qpe/process.h> 59#include <qpe/process.h>
60#include <qpe/global.h> 60#include <qpe/global.h>
61#include <qpe/config.h> 61#include <qpe/config.h>
62#include <qpe/contact.h> 62#include <qpe/contact.h>
63#include <qpe/version.h> 63#include <qpe/version.h>
64#include <qpe/qcopenvelope_qws.h> 64#include <qpe/qcopenvelope_qws.h>
65 65
66#include "transferserver.h" 66#include "transferserver.h"
67#include <opie/oprocess.h> 67#include <opie2/oprocess.h>
68using namespace Opie::Core;
68 69
69const int block_size = 51200; 70const int block_size = 51200;
70 71
71TransferServer::TransferServer( Q_UINT16 port, QObject *parent , 72TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
72 const char* name ) 73 const char* name )
73 : QServerSocket( port, 1, parent, name ) 74 : QServerSocket( port, 1, parent, name )
74{ 75{
75 if ( !ok() ) 76 if ( !ok() )
76 qWarning( "Failed to bind to port %d", port ); 77 qWarning( "Failed to bind to port %d", port );
77} 78}
78 79
79TransferServer::~TransferServer() 80TransferServer::~TransferServer()
80{ 81{
81} 82}
82 83
83void TransferServer::newConnection( int socket ) 84void TransferServer::newConnection( int socket )
84{ 85{
85 (void) new ServerPI( socket, this ); 86 (void) new ServerPI( socket, this );
86} 87}
87 88
88/* 89/*
89 * small class in anonymous namespace 90 * small class in anonymous namespace
90 * to generate a QUUid for us 91 * to generate a QUUid for us
91 */ 92 */
@@ -1028,61 +1029,61 @@ QString ServerPI::absFilePath( const QString& file )
1028 QString filepath( file ); 1029 QString filepath( file );
1029 if ( file[0] != "/" ) 1030 if ( file[0] != "/" )
1030 filepath = directory.path() + "/" + file; 1031 filepath = directory.path() + "/" + file;
1031 1032
1032 return filepath; 1033 return filepath;
1033} 1034}
1034 1035
1035 1036
1036void ServerPI::timerEvent( QTimerEvent * ) 1037void ServerPI::timerEvent( QTimerEvent * )
1037{ 1038{
1038 connectionClosed(); 1039 connectionClosed();
1039} 1040}
1040 1041
1041 1042
1042ServerDTP::ServerDTP( QObject *parent, const char* name) 1043ServerDTP::ServerDTP( QObject *parent, const char* name)
1043 : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), 1044 : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ),
1044 retrieveTargzProc( 0 ), gzipProc( 0 ) 1045 retrieveTargzProc( 0 ), gzipProc( 0 )
1045{ 1046{
1046 1047
1047 connect( this, SIGNAL( connected() ), SLOT( connected() ) ); 1048 connect( this, SIGNAL( connected() ), SLOT( connected() ) );
1048 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 1049 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
1049 connect( this, SIGNAL( bytesWritten(int) ), SLOT( bytesWritten(int) ) ); 1050 connect( this, SIGNAL( bytesWritten(int) ), SLOT( bytesWritten(int) ) );
1050 connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); 1051 connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) );
1051 1052
1052 gzipProc = new OProcess( this, "gzipProc" ); 1053 gzipProc = new Opie::Core::OProcess( this, "gzipProc" );
1053 1054
1054 createTargzProc = new OProcess( QString("tar"), this, "createTargzProc"); 1055 createTargzProc = new Opie::Core::OProcess( QString("tar"), this, "createTargzProc");
1055 createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); 1056 createTargzProc->setWorkingDirectory( QDir::rootDirPath() );
1056 connect( createTargzProc, SIGNAL( processExited(OProcess*) ), SLOT( targzDone() ) ); 1057 connect( createTargzProc, SIGNAL( processExited(Opie::Core::OProcess*) ), SLOT( targzDone() ) );
1057 1058
1058 QStringList args = "tar"; 1059 QStringList args = "tar";
1059 args += "-xv"; 1060 args += "-xv";
1060 retrieveTargzProc = new OProcess( args, this, "retrieveTargzProc" ); 1061 retrieveTargzProc = new Opie::Core::OProcess( args, this, "retrieveTargzProc" );
1061 retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); 1062 retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() );
1062 connect( retrieveTargzProc, SIGNAL( processExited(OProcess*) ), 1063 connect( retrieveTargzProc, SIGNAL( processExited(Opie::Core::OProcess*) ),
1063 SIGNAL( completed() ) ); 1064 SIGNAL( completed() ) );
1064 connect( retrieveTargzProc, SIGNAL( processExited(OProcess*) ), 1065 connect( retrieveTargzProc, SIGNAL( processExited(Opie::Core::OProcess*) ),
1065 SLOT( extractTarDone() ) ); 1066 SLOT( extractTarDone() ) );
1066} 1067}
1067 1068
1068ServerDTP::~ServerDTP() 1069ServerDTP::~ServerDTP()
1069{ 1070{
1070 buf.close(); 1071 buf.close();
1071 file.close(); 1072 file.close();
1072 createTargzProc->kill(); 1073 createTargzProc->kill();
1073} 1074}
1074 1075
1075void ServerDTP::extractTarDone() 1076void ServerDTP::extractTarDone()
1076{ 1077{
1077 qDebug("extract done"); 1078 qDebug("extract done");
1078#ifndef QT_NO_COP 1079#ifndef QT_NO_COP
1079 1080
1080 QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); 1081 QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" );
1081 e << file.name(); 1082 e << file.name();
1082#endif 1083#endif
1083} 1084}
1084 1085
1085void ServerDTP::connected() 1086void ServerDTP::connected()
1086{ 1087{
1087 // send file mode 1088 // send file mode
1088 switch ( mode ) { 1089 switch ( mode ) {
@@ -1100,49 +1101,49 @@ void ServerDTP::connected()
1100 //make sure it doesn't hang on empty files 1101 //make sure it doesn't hang on empty files
1101 file.close(); 1102 file.close();
1102 emit completed(); 1103 emit completed();
1103 mode = Idle; 1104 mode = Idle;
1104 } 1105 }
1105 else { 1106 else {
1106 1107
1107 if ( !file.atEnd() ) { 1108 if ( !file.atEnd() ) {
1108 QCString s; 1109 QCString s;
1109 s.resize( block_size ); 1110 s.resize( block_size );
1110 int bytes = file.readBlock( s.data(), block_size ); 1111 int bytes = file.readBlock( s.data(), block_size );
1111 writeBlock( s.data(), bytes ); 1112 writeBlock( s.data(), bytes );
1112 } 1113 }
1113 } 1114 }
1114 break; 1115 break;
1115 case SendGzipFile: 1116 case SendGzipFile:
1116 if ( createTargzProc->isRunning() ) { 1117 if ( createTargzProc->isRunning() ) {
1117 // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY 1118 // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY
1118 qWarning("Previous tar --gzip process is still running; killing it..."); 1119 qWarning("Previous tar --gzip process is still running; killing it...");
1119 createTargzProc->kill(); 1120 createTargzProc->kill();
1120 } 1121 }
1121 1122
1122 bytes_written = 0; 1123 bytes_written = 0;
1123 qDebug("==>start send tar process"); 1124 qDebug("==>start send tar process");
1124 if ( !createTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdout) ) 1125 if ( !createTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdout) )
1125 qWarning("Error starting %s or %s", 1126 qWarning("Error starting %s or %s",
1126 createTargzProc->args()[0].data(), 1127 createTargzProc->args()[0].data(),
1127 gzipProc->args()[0].data()); 1128 gzipProc->args()[0].data());
1128 break; 1129 break;
1129 case SendBuffer: 1130 case SendBuffer:
1130 if ( !buf.open( IO_ReadOnly) ) { 1131 if ( !buf.open( IO_ReadOnly) ) {
1131 emit failed(); 1132 emit failed();
1132 mode = Idle; 1133 mode = Idle;
1133 return ; 1134 return ;
1134 } 1135 }
1135 1136
1136 // qDebug( "Debug: Sending byte array" ); 1137 // qDebug( "Debug: Sending byte array" );
1137 bytes_written = 0; 1138 bytes_written = 0;
1138 while ( !buf.atEnd() ) 1139 while ( !buf.atEnd() )
1139 putch( buf.getch() ); 1140 putch( buf.getch() );
1140 buf.close(); 1141 buf.close();
1141 break; 1142 break;
1142 case RetrieveFile: 1143 case RetrieveFile:
1143 // retrieve file mode 1144 // retrieve file mode
1144 if ( file.exists() && !file.remove() ) { 1145 if ( file.exists() && !file.remove() ) {
1145 emit failed(); 1146 emit failed();
1146 mode = Idle; 1147 mode = Idle;
1147 return ; 1148 return ;
1148 } 1149 }
@@ -1235,154 +1236,154 @@ void ServerDTP::bytesWritten( int bytes )
1235 } 1236 }
1236 1237
1237 // send buffer mode 1238 // send buffer mode
1238 if ( SendBuffer == mode ) { 1239 if ( SendBuffer == mode ) {
1239 1240
1240 if ( bytes_written == buf.size() ) { 1241 if ( bytes_written == buf.size() ) {
1241 // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); 1242 // qDebug( "Debug: Sending complete: %d bytes", buf.size() );
1242 emit completed(); 1243 emit completed();
1243 mode = Idle; 1244 mode = Idle;
1244 } 1245 }
1245 } 1246 }
1246} 1247}
1247 1248
1248void ServerDTP::readyRead() 1249void ServerDTP::readyRead()
1249{ 1250{
1250 // retrieve file mode 1251 // retrieve file mode
1251 if ( RetrieveFile == mode ) { 1252 if ( RetrieveFile == mode ) {
1252 QCString s; 1253 QCString s;
1253 s.resize( bytesAvailable() ); 1254 s.resize( bytesAvailable() );
1254 readBlock( s.data(), bytesAvailable() ); 1255 readBlock( s.data(), bytesAvailable() );
1255 file.writeBlock( s.data(), s.size() ); 1256 file.writeBlock( s.data(), s.size() );
1256 } 1257 }
1257 else if ( RetrieveGzipFile == mode ) { 1258 else if ( RetrieveGzipFile == mode ) {
1258 if ( !gzipProc->isRunning() ) 1259 if ( !gzipProc->isRunning() )
1259 gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout )); 1260 gzipProc->start(Opie::Core::OProcess::NotifyOnExit, (Opie::Core::OProcess::Communication) ( Opie::Core::OProcess::Stdin | Opie::Core::OProcess::Stdout ));
1260 1261
1261 QByteArray s; 1262 QByteArray s;
1262 s.resize( bytesAvailable() ); 1263 s.resize( bytesAvailable() );
1263 readBlock( s.data(), bytesAvailable() ); 1264 readBlock( s.data(), bytesAvailable() );
1264 gzipProc->writeStdin( s.data(), s.size() ); 1265 gzipProc->writeStdin( s.data(), s.size() );
1265 qDebug("wrote %d bytes to ungzip ", s.size() ); 1266 qDebug("wrote %d bytes to ungzip ", s.size() );
1266 } 1267 }
1267 // retrieve buffer mode 1268 // retrieve buffer mode
1268 else if ( RetrieveBuffer == mode ) { 1269 else if ( RetrieveBuffer == mode ) {
1269 QCString s; 1270 QCString s;
1270 s.resize( bytesAvailable() ); 1271 s.resize( bytesAvailable() );
1271 readBlock( s.data(), bytesAvailable() ); 1272 readBlock( s.data(), bytesAvailable() );
1272 buf.writeBlock( s.data(), s.size() ); 1273 buf.writeBlock( s.data(), s.size() );
1273 } 1274 }
1274} 1275}
1275 1276
1276void ServerDTP::writeTargzBlock(OProcess *, char *buffer, int buflen) 1277void ServerDTP::writeTargzBlock(Opie::Core::OProcess *, char *buffer, int buflen)
1277{ 1278{
1278 writeBlock( buffer, buflen ); 1279 writeBlock( buffer, buflen );
1279 qDebug("writeTargzBlock %d", buflen); 1280 qDebug("writeTargzBlock %d", buflen);
1280 if ( !createTargzProc->isRunning() ) { 1281 if ( !createTargzProc->isRunning() ) {
1281 qDebug("tar and gzip done"); 1282 qDebug("tar and gzip done");
1282 emit completed(); 1283 emit completed();
1283 mode = Idle; 1284 mode = Idle;
1284 disconnect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), 1285 disconnect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
1285 this, SLOT( writeTargzBlock(OProcess*,char*,int) ) ); 1286 this, SLOT( writeTargzBlock(Opie::Core::OProcess*,char*,int) ) );
1286 } 1287 }
1287} 1288}
1288 1289
1289void ServerDTP::targzDone() 1290void ServerDTP::targzDone()
1290{ 1291{
1291 //qDebug("targz done"); 1292 //qDebug("targz done");
1292 disconnect( createTargzProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), 1293 disconnect( createTargzProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
1293 this, SLOT( gzipTarBlock(OProcess*,char*,int) ) ); 1294 this, SLOT( gzipTarBlock(Opie::Core::OProcess*,char*,int) ) );
1294 gzipProc->closeStdin(); 1295 gzipProc->closeStdin();
1295} 1296}
1296 1297
1297void ServerDTP::gzipTarBlock(OProcess *, char *buffer, int buflen) 1298void ServerDTP::gzipTarBlock(Opie::Core::OProcess *, char *buffer, int buflen)
1298{ 1299{
1299 //qDebug("gzipTarBlock"); 1300 //qDebug("gzipTarBlock");
1300 if ( !gzipProc->isRunning() ) { 1301 if ( !gzipProc->isRunning() ) {
1301 //qDebug("auto start gzip proc"); 1302 //qDebug("auto start gzip proc");
1302 gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout )); 1303 gzipProc->start(Opie::Core::OProcess::NotifyOnExit, (Opie::Core::OProcess::Communication) ( Opie::Core::OProcess::Stdin | Opie::Core::OProcess::Stdout ));
1303 } 1304 }
1304 gzipProc->writeStdin( buffer, buflen ); 1305 gzipProc->writeStdin( buffer, buflen );
1305} 1306}
1306 1307
1307void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) 1308void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port )
1308{ 1309{
1309 file.setName( fn ); 1310 file.setName( fn );
1310 mode = SendFile; 1311 mode = SendFile;
1311 connectToHost( host.toString(), port ); 1312 connectToHost( host.toString(), port );
1312} 1313}
1313 1314
1314void ServerDTP::sendFile( const QString fn ) 1315void ServerDTP::sendFile( const QString fn )
1315{ 1316{
1316 file.setName( fn ); 1317 file.setName( fn );
1317 mode = SendFile; 1318 mode = SendFile;
1318} 1319}
1319 1320
1320void ServerDTP::sendGzipFile( const QString &fn, 1321void ServerDTP::sendGzipFile( const QString &fn,
1321 const QStringList &archiveTargets, 1322 const QStringList &archiveTargets,
1322 const QHostAddress& host, Q_UINT16 port ) 1323 const QHostAddress& host, Q_UINT16 port )
1323{ 1324{
1324 sendGzipFile( fn, archiveTargets ); 1325 sendGzipFile( fn, archiveTargets );
1325 connectToHost( host.toString(), port ); 1326 connectToHost( host.toString(), port );
1326} 1327}
1327 1328
1328void ServerDTP::sendGzipFile( const QString &fn, 1329void ServerDTP::sendGzipFile( const QString &fn,
1329 const QStringList &archiveTargets ) 1330 const QStringList &archiveTargets )
1330{ 1331{
1331 mode = SendGzipFile; 1332 mode = SendGzipFile;
1332 file.setName( fn ); 1333 file.setName( fn );
1333 1334
1334 QStringList args = "tar"; 1335 QStringList args = "tar";
1335 args += "-cv"; 1336 args += "-cv";
1336 args += archiveTargets; 1337 args += archiveTargets;
1337 qDebug("sendGzipFile %s", args.join(" ").latin1() ); 1338 qDebug("sendGzipFile %s", args.join(" ").latin1() );
1338 createTargzProc->clearArguments( ); 1339 createTargzProc->clearArguments( );
1339 *createTargzProc << args; 1340 *createTargzProc << args;
1340 connect( createTargzProc, 1341 connect( createTargzProc,
1341 SIGNAL( receivedStdout(OProcess*,char*,int) ), SLOT( gzipTarBlock(OProcess*,char*,int) ) ); 1342 SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ), SLOT( gzipTarBlock(Opie::Core::OProcess*,char*,int) ) );
1342 1343
1343 gzipProc->clearArguments( ); 1344 gzipProc->clearArguments( );
1344 *gzipProc << "gzip"; 1345 *gzipProc << "gzip";
1345 connect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), 1346 connect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
1346 SLOT( writeTargzBlock(OProcess*,char*,int) ) ); 1347 SLOT( writeTargzBlock(Opie::Core::OProcess*,char*,int) ) );
1347} 1348}
1348 1349
1349void ServerDTP::gunzipDone() 1350void ServerDTP::gunzipDone()
1350{ 1351{
1351 qDebug("gunzipDone"); 1352 qDebug("gunzipDone");
1352 disconnect( gzipProc, SIGNAL( processExited() ), 1353 disconnect( gzipProc, SIGNAL( processExited() ),
1353 this, SLOT( gunzipDone() ) ); 1354 this, SLOT( gunzipDone() ) );
1354 retrieveTargzProc->closeStdin(); 1355 retrieveTargzProc->closeStdin();
1355 disconnect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), 1356 disconnect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
1356 this, SLOT( tarExtractBlock(OProcess*,char*,int) ) ); 1357 this, SLOT( tarExtractBlock(Opie::Core::OProcess*,char*,int) ) );
1357} 1358}
1358 1359
1359void ServerDTP::tarExtractBlock(OProcess *, char *buffer, int buflen) 1360void ServerDTP::tarExtractBlock(Opie::Core::OProcess *, char *buffer, int buflen)
1360{ 1361{
1361 qDebug("tarExtractBlock"); 1362 qDebug("tarExtractBlock");
1362 if ( !retrieveTargzProc->isRunning() ) { 1363 if ( !retrieveTargzProc->isRunning() ) {
1363 qDebug("auto start ungzip proc"); 1364 qDebug("auto start ungzip proc");
1364 if ( !retrieveTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdin) ) 1365 if ( !retrieveTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdin) )
1365 qWarning(" failed to start tar -x process"); 1366 qWarning(" failed to start tar -x process");
1366 } 1367 }
1367 retrieveTargzProc->writeStdin( buffer, buflen ); 1368 retrieveTargzProc->writeStdin( buffer, buflen );
1368} 1369}
1369 1370
1370 1371
1371void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) 1372void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port )
1372{ 1373{
1373 file.setName( fn ); 1374 file.setName( fn );
1374 mode = RetrieveFile; 1375 mode = RetrieveFile;
1375 connectToHost( host.toString(), port ); 1376 connectToHost( host.toString(), port );
1376} 1377}
1377 1378
1378void ServerDTP::retrieveFile( const QString fn ) 1379void ServerDTP::retrieveFile( const QString fn )
1379{ 1380{
1380 file.setName( fn ); 1381 file.setName( fn );
1381 mode = RetrieveFile; 1382 mode = RetrieveFile;
1382} 1383}
1383 1384
1384void ServerDTP::retrieveGzipFile( const QString &fn ) 1385void ServerDTP::retrieveGzipFile( const QString &fn )
1385{ 1386{
1386 qDebug("retrieveGzipFile %s", fn.latin1()); 1387 qDebug("retrieveGzipFile %s", fn.latin1());
1387 file.setName( fn ); 1388 file.setName( fn );
1388 mode = RetrieveGzipFile; 1389 mode = RetrieveGzipFile;
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
@@ -3,49 +3,50 @@
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qserversocket.h> 20#include <qserversocket.h>
21#include <qsocket.h> 21#include <qsocket.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qfile.h> 23#include <qfile.h>
24#include <qbuffer.h> 24#include <qbuffer.h>
25 25
26class QFileInfo; 26class QFileInfo;
27class OProcess; 27namespace Opie { namespace Core { class OProcess; } }
28
28class TransferServer : public QServerSocket 29class TransferServer : public QServerSocket
29{ 30{
30 Q_OBJECT 31 Q_OBJECT
31 32
32public: 33public:
33 TransferServer( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); 34 TransferServer( Q_UINT16 port, QObject *parent = 0, const char* name = 0 );
34 virtual ~TransferServer(); 35 virtual ~TransferServer();
35 36
36 void newConnection( int socket ); 37 void newConnection( int socket );
37}; 38};
38 39
39class SyncAuthentication : QObject 40class SyncAuthentication : QObject
40{ 41{
41 Q_OBJECT 42 Q_OBJECT
42 43
43public: 44public:
44 static int isAuthorized(QHostAddress peeraddress); 45 static int isAuthorized(QHostAddress peeraddress);
45 static bool checkPassword(const QString& pw); 46 static bool checkPassword(const QString& pw);
46 static bool checkUser(const QString& user); 47 static bool checkUser(const QString& user);
47 48
48 static QString serverId(); 49 static QString serverId();
49 static QString loginName(); 50 static QString loginName();
50 static QString ownerName(); 51 static QString ownerName();
51}; 52};
@@ -71,65 +72,65 @@ public:
71 void sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port ); 72 void sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port );
72 73
73 void retrieveFile( const QString fn ); 74 void retrieveFile( const QString fn );
74 void retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ); 75 void retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port );
75 void retrieveGzipFile( const QString &fn ); 76 void retrieveGzipFile( const QString &fn );
76 void retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ); 77 void retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port );
77 void retrieveByteArray(); 78 void retrieveByteArray();
78 void retrieveByteArray( const QHostAddress& host, Q_UINT16 port ); 79 void retrieveByteArray( const QHostAddress& host, Q_UINT16 port );
79 80
80 Mode dtpMode() { return mode; } 81 Mode dtpMode() { return mode; }
81 QByteArray buffer() { return buf.buffer(); } 82 QByteArray buffer() { return buf.buffer(); }
82 QString fileName() const { return file.name(); } 83 QString fileName() const { return file.name(); }
83 84
84 void setSocket( int socket ); 85 void setSocket( int socket );
85 86
86signals: 87signals:
87 void completed(); 88 void completed();
88 void failed(); 89 void failed();
89 90
90private slots: 91private slots:
91 void connectionClosed(); 92 void connectionClosed();
92 void connected(); 93 void connected();
93 void bytesWritten( int bytes ); 94 void bytesWritten( int bytes );
94 void readyRead(); 95 void readyRead();
95 void writeTargzBlock(OProcess *, char *, int); 96 void writeTargzBlock(Opie::Core::OProcess *, char *, int);
96 void targzDone(); 97 void targzDone();
97 98
98 void gzipTarBlock(OProcess *, char *, int); 99 void gzipTarBlock(Opie::Core::OProcess *, char *, int);
99 void tarExtractBlock(OProcess *, char *, int); 100 void tarExtractBlock(Opie::Core::OProcess *, char *, int);
100 void gunzipDone(); 101 void gunzipDone();
101 void extractTarDone(); 102 void extractTarDone();
102 103
103private: 104private:
104 105
105 unsigned long bytes_written; 106 unsigned long bytes_written;
106 Mode mode; 107 Mode mode;
107 QFile file; 108 QFile file;
108 QBuffer buf; 109 QBuffer buf;
109 OProcess *createTargzProc; 110 Opie::Core::OProcess *createTargzProc;
110 OProcess *retrieveTargzProc; 111 Opie::Core::OProcess *retrieveTargzProc;
111 OProcess *gzipProc; 112 Opie::Core::OProcess *gzipProc;
112}; 113};
113 114
114class ServerSocket : public QServerSocket 115class ServerSocket : public QServerSocket
115{ 116{
116 Q_OBJECT 117 Q_OBJECT
117 118
118public: 119public:
119 ServerSocket( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ) 120 ServerSocket( Q_UINT16 port, QObject *parent = 0, const char* name = 0 )
120 : QServerSocket( port, 1, parent, name ) {} 121 : QServerSocket( port, 1, parent, name ) {}
121 122
122 void newConnection( int socket ) { emit newIncomming( socket ); } 123 void newConnection( int socket ) { emit newIncomming( socket ); }
123signals: 124signals:
124 void newIncomming( int socket ); 125 void newIncomming( int socket );
125}; 126};
126 127
127class ServerPI : public QSocket 128class ServerPI : public QSocket
128{ 129{
129 Q_OBJECT 130 Q_OBJECT
130 131
131 enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden }; 132 enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden };
132 enum Transfer { SendFile = 0, RetrieveFile = 1, SendByteArray = 2, RetrieveByteArray = 3 }; 133 enum Transfer { SendFile = 0, RetrieveFile = 1, SendByteArray = 2, RetrieveByteArray = 3 };
133 134
134public: 135public:
135 ServerPI( int socket, QObject *parent = 0, const char* name = 0 ); 136 ServerPI( int socket, QObject *parent = 0, const char* name = 0 );