summaryrefslogtreecommitdiff
path: root/core/launcher/transferserver.cpp
Unidiff
Diffstat (limited to 'core/launcher/transferserver.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/transferserver.cpp191
1 files changed, 113 insertions, 78 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index cbda247..0337a94 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -29,9 +29,10 @@
29#include <qglobal.h> 29#include <qglobal.h>
30 30
31#ifndef _OS_LINUX_ 31#ifndef _OS_LINUX_
32 32
33extern "C" { 33extern "C"
34{
34#include <uuid/uuid.h> 35#include <uuid/uuid.h>
35#define UUID_H_INCLUDED 36#define UUID_H_INCLUDED
36} 37}
37 38
@@ -58,9 +59,9 @@ extern "C" {
58#include <qpe/version.h> 59#include <qpe/version.h>
59#include <qpe/qcopenvelope_qws.h> 60#include <qpe/qcopenvelope_qws.h>
60 61
61#include "transferserver.h" 62#include "transferserver.h"
62#include "qprocess.h" 63#include <opie/oprocess.h>
63 64
64const int block_size = 51200; 65const int block_size = 51200;
65 66
66TransferServer::TransferServer( Q_UINT16 port, QObject *parent , 67TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
@@ -72,9 +73,8 @@ TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
72} 73}
73 74
74TransferServer::~TransferServer() 75TransferServer::~TransferServer()
75{ 76{
76
77} 77}
78 78
79void TransferServer::newConnection( int socket ) 79void TransferServer::newConnection( int socket )
80{ 80{
@@ -84,14 +84,18 @@ void TransferServer::newConnection( int socket )
84/* 84/*
85 * small class in anonymous namespace 85 * small class in anonymous namespace
86 * to generate a QUUid for us 86 * to generate a QUUid for us
87 */ 87 */
88namespace { 88namespace
89 struct UidGen { 89{
90struct UidGen
91{
90 QString uuid(); 92 QString uuid();
91 }; 93 };
92#if !defined(_OS_LINUX_) 94#if !defined(_OS_LINUX_)
93 QString UidGen::uuid() { 95
96QString UidGen::uuid()
97{
94 uuid_t uuid; 98 uuid_t uuid;
95 uuid_generate( uuid ); 99 uuid_generate( uuid );
96 return QUUid( uuid ).toString(); 100 return QUUid( uuid ).toString();
97 } 101 }
@@ -99,9 +103,10 @@ namespace {
99 /* 103 /*
100 * linux got a /proc/sys/kernel/random/uuid file 104 * linux got a /proc/sys/kernel/random/uuid file
101 * it'll generate the uuids for us 105 * it'll generate the uuids for us
102 */ 106 */
103 QString UidGen::uuid() { 107QString UidGen::uuid()
108{
104 QFile file( "/proc/sys/kernel/random/uuid" ); 109 QFile file( "/proc/sys/kernel/random/uuid" );
105 if (!file.open(IO_ReadOnly ) ) 110 if (!file.open(IO_ReadOnly ) )
106 return QString::null; 111 return QString::null;
107 112
@@ -162,9 +167,10 @@ int SyncAuthentication::isAuthorized(QHostAddress peeraddress)
162} 167}
163 168
164bool SyncAuthentication::checkUser( const QString& user ) 169bool SyncAuthentication::checkUser( const QString& user )
165{ 170{
166 if ( user.isEmpty() ) return FALSE; 171 if ( user.isEmpty() )
172 return FALSE;
167 QString euser = loginName(); 173 QString euser = loginName();
168 return user == euser; 174 return user == euser;
169} 175}
170 176
@@ -229,14 +235,14 @@ bool SyncAuthentication::checkPassword( const QString& password )
229 if ( (denials > 2 && now < lastdenial+600) 235 if ( (denials > 2 && now < lastdenial+600)
230 || QMessageBox::warning(0,tr("Sync Connection"), 236 || QMessageBox::warning(0,tr("Sync Connection"),
231 tr("<p>An unrecognized system is requesting access to this device." 237 tr("<p>An unrecognized system is requesting access to this device."
232 "<p>If you have just initiated a Sync for the first time, this is normal."), 238 "<p>If you have just initiated a Sync for the first time, this is normal."),
233 tr("Allow"),tr("Deny"), 0, 1, 1 ) ==1 ) 239 tr("Allow"), tr("Deny"), 0, 1, 1 ) == 1 ) {
234 {
235 denials++; 240 denials++;
236 lastdenial=now; 241 lastdenial=now;
237 return FALSE; 242 return FALSE;
238 } else { 243 }
244 else {
239 denials=0; 245 denials=0;
240 cfg.writeEntry("Passwords",pwds+" "+cpassword); 246 cfg.writeEntry("Passwords",pwds+" "+cpassword);
241 return TRUE; 247 return TRUE;
242 } 248 }
@@ -255,12 +261,14 @@ ServerPI::ServerPI( int socket, QObject *parent , const char* name )
255 peerport = peerPort(); 261 peerport = peerPort();
256 peeraddress = peerAddress(); 262 peeraddress = peerAddress();
257 263
258#ifndef INSECURE 264#ifndef INSECURE
265
259 if ( !SyncAuthentication::isAuthorized(peeraddress) ) { 266 if ( !SyncAuthentication::isAuthorized(peeraddress) ) {
260 state = Forbidden; 267 state = Forbidden;
261 startTimer( 0 ); 268 startTimer( 0 );
262 } else 269 }
270 else
263#endif 271#endif
264 { 272 {
265 connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); 273 connect( this, SIGNAL( readyRead() ), SLOT( read() ) );
266 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 274 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
@@ -292,9 +300,8 @@ ServerPI::ServerPI( int socket, QObject *parent , const char* name )
292} 300}
293 301
294ServerPI::~ServerPI() 302ServerPI::~ServerPI()
295{ 303{
296
297} 304}
298 305
299void ServerPI::connectionClosed() 306void ServerPI::connectionClosed()
300{ 307{
@@ -350,9 +357,10 @@ void ServerPI::process( const QString& message )
350 //qDebug( "Command: %s", message.latin1() ); 357 //qDebug( "Command: %s", message.latin1() );
351 358
352 // split message using "," as separator 359 // split message using "," as separator
353 QStringList msg = QStringList::split( " ", message ); 360 QStringList msg = QStringList::split( " ", message );
354 if ( msg.isEmpty() ) return; 361 if ( msg.isEmpty() )
362 return ;
355 363
356 // command token 364 // command token
357 QString cmd = msg[0].upper(); 365 QString cmd = msg[0].upper();
358 366
@@ -589,9 +597,10 @@ void ServerPI::process( const QString& message )
589 if ( file.remove() ) { 597 if ( file.remove() ) {
590 send( "250 Requested file action okay, completed" ); 598 send( "250 Requested file action okay, completed" );
591 QCopEnvelope e("QPE/System", "linkChanged(QString)" ); 599 QCopEnvelope e("QPE/System", "linkChanged(QString)" );
592 e << file.name(); 600 e << file.name();
593 } else { 601 }
602 else {
594 send( "550 Requested action not taken" ); 603 send( "550 Requested action not taken" );
595 } 604 }
596 } 605 }
597 } 606 }
@@ -733,9 +742,10 @@ void ServerPI::sendFile( const QString& file )
733 else { 742 else {
734 QStringList targets; 743 QStringList targets;
735 if ( backupRestoreGzip( file, targets ) ) 744 if ( backupRestoreGzip( file, targets ) )
736 dtp->sendGzipFile( file, targets, peeraddress, peerport ); 745 dtp->sendGzipFile( file, targets, peeraddress, peerport );
737 else dtp->sendFile( file, peeraddress, peerport ); 746 else
747 dtp->sendFile( file, peeraddress, peerport );
738 } 748 }
739} 749}
740 750
741void ServerPI::retrieveFile( const QString& file ) 751void ServerPI::retrieveFile( const QString& file )
@@ -757,9 +767,10 @@ void ServerPI::retrieveFile( const QString& file )
757 767
758bool ServerPI::parsePort( const QString& pp ) 768bool ServerPI::parsePort( const QString& pp )
759{ 769{
760 QStringList p = QStringList::split( ",", pp ); 770 QStringList p = QStringList::split( ",", pp );
761 if ( p.count() != 6 ) return FALSE; 771 if ( p.count() != 6 )
772 return FALSE;
762 773
763 // h1,h2,h3,h4,p1,p2 774 // h1,h2,h3,h4,p1,p2
764 peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + 775 peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) +
765 ( p[2].toInt() << 8 ) + p[3].toInt() ); 776 ( p[2].toInt() << 8 ) + p[3].toInt() );
@@ -809,9 +820,10 @@ bool ServerPI::sendList( const QString& arg )
809 if ( fn.isEmpty() ) 820 if ( fn.isEmpty() )
810 fn = directory.path(); 821 fn = directory.path();
811 822
812 QFileInfo fi( fn ); 823 QFileInfo fi( fn );
813 if ( !fi.exists() ) return FALSE; 824 if ( !fi.exists() )
825 return FALSE;
814 826
815 // return file listing 827 // return file listing
816 if ( fi.isFile() ) { 828 if ( fi.isFile() ) {
817 ts << fileListing( &fi ) << endl; 829 ts << fileListing( &fi ) << endl;
@@ -857,9 +869,10 @@ bool ServerPI::sendList( const QString& arg )
857} 869}
858 870
859QString ServerPI::fileListing( QFileInfo *info ) 871QString ServerPI::fileListing( QFileInfo *info )
860{ 872{
861 if ( !info ) return QString::null; 873 if ( !info )
874 return QString::null;
862 QString s; 875 QString s;
863 876
864 // type char 877 // type char
865 if ( info->isDir() ) 878 if ( info->isDir() )
@@ -907,43 +920,63 @@ QString ServerPI::fileListing( QFileInfo *info )
907} 920}
908 921
909QString ServerPI::permissionString( QFileInfo *info ) 922QString ServerPI::permissionString( QFileInfo *info )
910{ 923{
911 if ( !info ) return QString( "---------" ); 924 if ( !info )
925 return QString( "---------" );
912 QString s; 926 QString s;
913 927
914 // user 928 // user
915 if ( info->permission( QFileInfo::ReadUser ) ) s += "r"; 929 if ( info->permission( QFileInfo::ReadUser ) )
916 else s += "-"; 930 s += "r";
917 if ( info->permission( QFileInfo::WriteUser ) ) s += "w"; 931 else
918 else s += "-"; 932 s += "-";
919 if ( info->permission( QFileInfo::ExeUser ) ) s += "x"; 933 if ( info->permission( QFileInfo::WriteUser ) )
920 else s += "-"; 934 s += "w";
935 else
936 s += "-";
937 if ( info->permission( QFileInfo::ExeUser ) )
938 s += "x";
939 else
940 s += "-";
921 941
922 // group 942 // group
923 if ( info->permission( QFileInfo::ReadGroup ) ) s += "r"; 943 if ( info->permission( QFileInfo::ReadGroup ) )
924 else s += "-"; 944 s += "r";
925 if ( info->permission( QFileInfo::WriteGroup ) )s += "w"; 945 else
926 else s += "-"; 946 s += "-";
927 if ( info->permission( QFileInfo::ExeGroup ) ) s += "x"; 947 if ( info->permission( QFileInfo::WriteGroup ) )
928 else s += "-"; 948 s += "w";
949 else
950 s += "-";
951 if ( info->permission( QFileInfo::ExeGroup ) )
952 s += "x";
953 else
954 s += "-";
929 955
930 // exec 956 // exec
931 if ( info->permission( QFileInfo::ReadOther ) ) s += "r"; 957 if ( info->permission( QFileInfo::ReadOther ) )
932 else s += "-"; 958 s += "r";
933 if ( info->permission( QFileInfo::WriteOther ) ) s += "w"; 959 else
934 else s += "-"; 960 s += "-";
935 if ( info->permission( QFileInfo::ExeOther ) ) s += "x"; 961 if ( info->permission( QFileInfo::WriteOther ) )
936 else s += "-"; 962 s += "w";
963 else
964 s += "-";
965 if ( info->permission( QFileInfo::ExeOther ) )
966 s += "x";
967 else
968 s += "-";
937 969
938 return s; 970 return s;
939} 971}
940 972
941void ServerPI::newConnection( int socket ) 973void ServerPI::newConnection( int socket )
942{ 974{
943 //qDebug( "New incomming connection" ); 975 //qDebug( "New incomming connection" );
944 976
945 if ( !passiv ) return; 977 if ( !passiv )
978 return ;
946 979
947 if ( wait[SendFile] ) { 980 if ( wait[SendFile] ) {
948 QStringList targets; 981 QStringList targets;
949 if ( backupRestoreGzip( waitfile, targets ) ) 982 if ( backupRestoreGzip( waitfile, targets ) )
@@ -977,9 +1010,10 @@ void ServerPI::newConnection( int socket )
977} 1010}
978 1011
979QString ServerPI::absFilePath( const QString& file ) 1012QString ServerPI::absFilePath( const QString& file )
980{ 1013{
981 if ( file.isEmpty() ) return file; 1014 if ( file.isEmpty() )
1015 return file;
982 1016
983 QString filepath( file ); 1017 QString filepath( file );
984 if ( file[0] != "/" ) 1018 if ( file[0] != "/" )
985 filepath = directory.path() + "/" + file; 1019 filepath = directory.path() + "/" + file;
@@ -1003,24 +1037,21 @@ retrieveTargzProc( 0 ), gzipProc( 0 )
1003 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 1037 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
1004 connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) ); 1038 connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) );
1005 connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); 1039 connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) );
1006 1040
1007 gzipProc = new QProcess( this, "gzipProc" ); 1041 gzipProc = new OProcess( this, "gzipProc" );
1008 gzipProc->setCommunication( QProcess::Stdin | QProcess::Stdout );
1009 1042
1010 createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); 1043 createTargzProc = new OProcess( QString("tar"), this, "createTargzProc");
1011 createTargzProc->setCommunication( QProcess::Stdout );
1012 createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); 1044 createTargzProc->setWorkingDirectory( QDir::rootDirPath() );
1013 connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) ); 1045 connect( createTargzProc, SIGNAL( processExited(OProcess *) ), SLOT( targzDone() ) );
1014 1046
1015 QStringList args = "tar"; 1047 QStringList args = "tar";
1016 args += "-xv"; 1048 args += "-xv";
1017 retrieveTargzProc = new QProcess( args, this, "retrieveTargzProc" ); 1049 retrieveTargzProc = new OProcess( args, this, "retrieveTargzProc" );
1018 retrieveTargzProc->setCommunication( QProcess::Stdin );
1019 retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); 1050 retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() );
1020 connect( retrieveTargzProc, SIGNAL( processExited() ), 1051 connect( retrieveTargzProc, SIGNAL( processExited(OProcess *) ),
1021 SIGNAL( completed() ) ); 1052 SIGNAL( completed() ) );
1022 connect( retrieveTargzProc, SIGNAL( processExited() ), 1053 connect( retrieveTargzProc, SIGNAL( processExited(OProcess *) ),
1023 SLOT( extractTarDone() ) ); 1054 SLOT( extractTarDone() ) );
1024} 1055}
1025 1056
1026ServerDTP::~ServerDTP() 1057ServerDTP::~ServerDTP()
@@ -1033,8 +1064,9 @@ ServerDTP::~ServerDTP()
1033void ServerDTP::extractTarDone() 1064void ServerDTP::extractTarDone()
1034{ 1065{
1035 qDebug("extract done"); 1066 qDebug("extract done");
1036#ifndef QT_NO_COP 1067#ifndef QT_NO_COP
1068
1037 QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); 1069 QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" );
1038 e << file.name(); 1070 e << file.name();
1039#endif 1071#endif
1040} 1072}
@@ -1057,9 +1089,10 @@ void ServerDTP::connected()
1057 //make sure it doesn't hang on empty files 1089 //make sure it doesn't hang on empty files
1058 file.close(); 1090 file.close();
1059 emit completed(); 1091 emit completed();
1060 mode = Idle; 1092 mode = Idle;
1061 } else { 1093 }
1094 else {
1062 1095
1063 if( !file.atEnd() ) { 1096 if( !file.atEnd() ) {
1064 QCString s; 1097 QCString s;
1065 s.resize( block_size ); 1098 s.resize( block_size );
@@ -1076,12 +1109,12 @@ void ServerDTP::connected()
1076 } 1109 }
1077 1110
1078 bytes_written = 0; 1111 bytes_written = 0;
1079 qDebug("==>start send tar process"); 1112 qDebug("==>start send tar process");
1080 if ( !createTargzProc->start() ) 1113 if ( !createTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdout) )
1081 qWarning("Error starting %s or %s", 1114 qWarning("Error starting %s or %s",
1082 createTargzProc->arguments().join(" ").latin1(), 1115 createTargzProc->args()[0].data(),
1083 gzipProc->arguments().join(" ").latin1() ); 1116 gzipProc->args()[0].data());
1084 break; 1117 break;
1085 case SendBuffer: 1118 case SendBuffer:
1086 if ( !buf.open( IO_ReadOnly) ) { 1119 if ( !buf.open( IO_ReadOnly) ) {
1087 emit failed(); 1120 emit failed();
@@ -1211,14 +1244,14 @@ void ServerDTP::readyRead()
1211 file.writeBlock( s.data(), s.size() ); 1244 file.writeBlock( s.data(), s.size() );
1212 } 1245 }
1213 else if ( RetrieveGzipFile == mode ) { 1246 else if ( RetrieveGzipFile == mode ) {
1214 if ( !gzipProc->isRunning() ) 1247 if ( !gzipProc->isRunning() )
1215 gzipProc->start(); 1248 gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout ));
1216 1249
1217 QByteArray s; 1250 QByteArray s;
1218 s.resize( bytesAvailable() ); 1251 s.resize( bytesAvailable() );
1219 readBlock( s.data(), bytesAvailable() ); 1252 readBlock( s.data(), bytesAvailable() );
1220 gzipProc->writeToStdin( s ); 1253 gzipProc->writeStdin( s.data(), s.size() );
1221 qDebug("wrote %d bytes to ungzip ", s.size() ); 1254 qDebug("wrote %d bytes to ungzip ", s.size() );
1222 } 1255 }
1223 // retrieve buffer mode 1256 // retrieve buffer mode
1224 else if ( RetrieveBuffer == mode ) { 1257 else if ( RetrieveBuffer == mode ) {
@@ -1228,38 +1261,37 @@ void ServerDTP::readyRead()
1228 buf.writeBlock( s.data(), s.size() ); 1261 buf.writeBlock( s.data(), s.size() );
1229 } 1262 }
1230} 1263}
1231 1264
1232void ServerDTP::writeTargzBlock() 1265void ServerDTP::writeTargzBlock(OProcess *, char *buffer, int buflen)
1233{ 1266{
1234 QByteArray block = gzipProc->readStdout(); 1267 writeBlock( buffer, buflen );
1235 writeBlock( block.data(), block.size() ); 1268 qDebug("writeTargzBlock %d", buflen);
1236 qDebug("writeTargzBlock %d", block.size());
1237 if ( !createTargzProc->isRunning() ) { 1269 if ( !createTargzProc->isRunning() ) {
1238 qDebug("tar and gzip done"); 1270 qDebug("tar and gzip done");
1239 emit completed(); 1271 emit completed();
1240 mode = Idle; 1272 mode = Idle;
1241 disconnect( gzipProc, SIGNAL( readyReadStdout() ), 1273 disconnect( gzipProc, SIGNAL( receivedStdout(OProcess *, char *, int ) ),
1242 this, SLOT( writeTargzBlock() ) ); 1274 this, SLOT( writeTargzBlock(OProcess *, char *, int) ) );
1243 } 1275 }
1244} 1276}
1245 1277
1246void ServerDTP::targzDone() 1278void ServerDTP::targzDone()
1247{ 1279{
1248 //qDebug("targz done"); 1280 //qDebug("targz done");
1249 disconnect( createTargzProc, SIGNAL( readyReadStdout() ), 1281 disconnect( createTargzProc, SIGNAL( receivedStdout(OProcess *, char *, int) ),
1250 this, SLOT( gzipTarBlock() ) ); 1282 this, SLOT( gzipTarBlock(OProcess *, char *, int) ) );
1251 gzipProc->closeStdin(); 1283 gzipProc->closeStdin();
1252} 1284}
1253 1285
1254void ServerDTP::gzipTarBlock() 1286void ServerDTP::gzipTarBlock(OProcess *, char *buffer, int buflen)
1255{ 1287{
1256 //qDebug("gzipTarBlock"); 1288 //qDebug("gzipTarBlock");
1257 if ( !gzipProc->isRunning() ) { 1289 if ( !gzipProc->isRunning() ) {
1258 //qDebug("auto start gzip proc"); 1290 //qDebug("auto start gzip proc");
1259 gzipProc->start(); 1291 gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout ));
1260 } 1292 }
1261 gzipProc->writeToStdin( createTargzProc->readStdout() ); 1293 gzipProc->writeStdin( buffer, buflen );
1262} 1294}
1263 1295
1264void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) 1296void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port )
1265{ 1297{
@@ -1291,36 +1323,38 @@ void ServerDTP::sendGzipFile( const QString &fn,
1291 QStringList args = "tar"; 1323 QStringList args = "tar";
1292 args += "-cv"; 1324 args += "-cv";
1293 args += archiveTargets; 1325 args += archiveTargets;
1294 qDebug("sendGzipFile %s", args.join(" ").latin1() ); 1326 qDebug("sendGzipFile %s", args.join(" ").latin1() );
1295 createTargzProc->setArguments( args ); 1327 createTargzProc->clearArguments( );
1328 *createTargzProc << args;
1296 connect( createTargzProc, 1329 connect( createTargzProc,
1297 SIGNAL( readyReadStdout() ), SLOT( gzipTarBlock() ) ); 1330 SIGNAL( receivedStdout(OProcess *, char *, int) ), SLOT( gzipTarBlock(OProcess *, char *, int) ) );
1298 1331
1299 gzipProc->setArguments( "gzip" ); 1332 gzipProc->clearArguments( );
1300 connect( gzipProc, SIGNAL( readyReadStdout() ), 1333 *gzipProc << "gzip";
1301 SLOT( writeTargzBlock() ) ); 1334 connect( gzipProc, SIGNAL( receivedStdout(OProcess *, char *, int) ),
1335 SLOT( writeTargzBlock(OProcess *, char *, int) ) );
1302} 1336}
1303 1337
1304void ServerDTP::gunzipDone() 1338void ServerDTP::gunzipDone()
1305{ 1339{
1306 qDebug("gunzipDone"); 1340 qDebug("gunzipDone");
1307 disconnect( gzipProc, SIGNAL( processExited() ), 1341 disconnect( gzipProc, SIGNAL( processExited() ),
1308 this, SLOT( gunzipDone() ) ); 1342 this, SLOT( gunzipDone() ) );
1309 retrieveTargzProc->closeStdin(); 1343 retrieveTargzProc->closeStdin();
1310 disconnect( gzipProc, SIGNAL( readyReadStdout() ), 1344 disconnect( gzipProc, SIGNAL( receivedStdout(OProcess *, char *, int) ),
1311 this, SLOT( tarExtractBlock() ) ); 1345 this, SLOT( tarExtractBlock(OProcess *, char *, int) ) );
1312} 1346}
1313 1347
1314void ServerDTP::tarExtractBlock() 1348void ServerDTP::tarExtractBlock(OProcess *, char *buffer, int buflen)
1315{ 1349{
1316 qDebug("ungzipTarBlock"); 1350 qDebug("tarExtractBlock");
1317 if ( !retrieveTargzProc->isRunning() ) { 1351 if ( !retrieveTargzProc->isRunning() ) {
1318 qDebug("auto start ungzip proc"); 1352 qDebug("auto start ungzip proc");
1319 if ( !retrieveTargzProc->start() ) 1353 if ( !retrieveTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdin) )
1320 qWarning(" failed to start tar -x process"); 1354 qWarning(" failed to start tar -x process");
1321 } 1355 }
1322 retrieveTargzProc->writeToStdin( gzipProc->readStdout() ); 1356 retrieveTargzProc->writeStdin( buffer, buflen );
1323} 1357}
1324 1358
1325 1359
1326void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) 1360void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port )
@@ -1341,9 +1375,10 @@ void ServerDTP::retrieveGzipFile( const QString &fn )
1341 qDebug("retrieveGzipFile %s", fn.latin1()); 1375 qDebug("retrieveGzipFile %s", fn.latin1());
1342 file.setName( fn ); 1376 file.setName( fn );
1343 mode = RetrieveGzipFile; 1377 mode = RetrieveGzipFile;
1344 1378
1345 gzipProc->setArguments( "gunzip" ); 1379 gzipProc->clearArguments();
1380 *gzipProc << "gunzip";
1346 connect( gzipProc, SIGNAL( readyReadStdout() ), 1381 connect( gzipProc, SIGNAL( readyReadStdout() ),
1347 SLOT( tarExtractBlock() ) ); 1382 SLOT( tarExtractBlock() ) );
1348 connect( gzipProc, SIGNAL( processExited() ), 1383 connect( gzipProc, SIGNAL( processExited() ),
1349 SLOT( gunzipDone() ) ); 1384 SLOT( gunzipDone() ) );