summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/transferserver.cpp803
1 files changed, 402 insertions, 401 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index a6dab07..ed3e2c6 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -65,3 +65,3 @@ TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
65 if ( !ok() ) 65 if ( !ok() )
66 qWarning( "Failed to bind to port %d", port ); 66 qWarning( "Failed to bind to port %d", port );
67} 67}
@@ -84,5 +84,5 @@ QString SyncAuthentication::serverId()
84 if ( r.isEmpty() ) { 84 if ( r.isEmpty() ) {
85 uuid_t uuid; 85 uuid_t uuid;
86 uuid_generate( uuid ); 86 uuid_generate( uuid );
87 cfg.writeEntry("serverid",(r = QUuid( uuid ).toString())); 87 cfg.writeEntry("serverid",(r = QUuid( uuid ).toString()));
88 } 88 }
@@ -96,5 +96,5 @@ QString SyncAuthentication::ownerName()
96 if (QFile::exists(vfilename)) { 96 if (QFile::exists(vfilename)) {
97 Contact c; 97 Contact c;
98 c = Contact::readVCard( vfilename )[0]; 98 c = Contact::readVCard( vfilename )[0];
99 return c.fullName(); 99 return c.fullName();
100 } 100 }
@@ -115,9 +115,11 @@ int SyncAuthentication::isAuthorized(QHostAddress peeraddress)
115 cfg.setGroup("Sync"); 115 cfg.setGroup("Sync");
116 QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); 116// QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0");
117 QHostAddress allowed; 117 uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100);
118 allowed.setAddress(allowedstr); 118
119 uint auth_peer = allowed.ip4Addr(); 119// QHostAddress allowed;
120// allowed.setAddress(allowedstr);
121// uint auth_peer = allowed.ip4Addr();
120 uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); 122 uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24);
121 uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined 123 uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined
122 ? 0xffffffff : (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits)); 124 ? 0xffffffff : (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits));
123 return (peeraddress.ip4Addr() & mask) == auth_peer; 125 return (peeraddress.ip4Addr() & mask) == auth_peer;
@@ -145,3 +147,3 @@ bool SyncAuthentication::checkPassword( const QString& password )
145 if ( cpwd == "x" && spw ) 147 if ( cpwd == "x" && spw )
146 cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); 148 cpwd = QString::fromLocal8Bit( spw->sp_pwdp );
147 149
@@ -150,3 +152,3 @@ bool SyncAuthentication::checkPassword( const QString& password )
150 if ( cpwd == cpassword ) 152 if ( cpwd == cpassword )
151 return TRUE; 153 return TRUE;
152#endif 154#endif
@@ -159,12 +161,12 @@ bool SyncAuthentication::checkPassword( const QString& password )
159 if ( password.isEmpty() ) { 161 if ( password.isEmpty() ) {
160 if ( denials < 1 || now > lastdenial+600 ) { 162 if ( denials < 1 || now > lastdenial+600 ) {
161 QMessageBox::warning( 0,tr("Sync Connection"), 163 QMessageBox::warning( 0,tr("Sync Connection"),
162 tr("<p>An unauthorized system is requesting access to this device." 164 tr("<p>An unauthorized system is requesting access to this device."
163 "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " 165 "<p>If you are using a version of Qtopia Desktop older than 1.5.1, "
164 "please upgrade."), 166 "please upgrade."),
165 tr("Deny") ); 167 tr("Deny") );
166 denials++; 168 denials++;
167 lastdenial=now; 169 lastdenial=now;
168 } 170 }
169 return FALSE; 171 return FALSE;
170 } 172 }
@@ -173,25 +175,25 @@ bool SyncAuthentication::checkPassword( const QString& password )
173 if ( password.left(6) == "Qtopia" ) { 175 if ( password.left(6) == "Qtopia" ) {
174 QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); 176 QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) );
175 Config cfg("Security"); 177 Config cfg("Security");
176 cfg.setGroup("Sync"); 178 cfg.setGroup("Sync");
177 QString pwds = cfg.readEntry("Passwords"); 179 QString pwds = cfg.readEntry("Passwords");
178 if ( QStringList::split(QChar(' '),pwds).contains(cpassword) ) 180 if ( QStringList::split(QChar(' '),pwds).contains(cpassword) )
179 return TRUE; 181 return TRUE;
180 182
181 // Unrecognized system. Be careful... 183 // Unrecognized system. Be careful...
182 184
183 if ( (denials > 2 && now < lastdenial+600) 185 if ( (denials > 2 && now < lastdenial+600)
184 || QMessageBox::warning(0,tr("Sync Connection"), 186 || QMessageBox::warning(0,tr("Sync Connection"),
185 tr("<p>An unrecognized system is requesting access to this device." 187 tr("<p>An unrecognized system is requesting access to this device."
186 "<p>If you have just initiated a Sync for the first time, this is normal."), 188 "<p>If you have just initiated a Sync for the first time, this is normal."),
187 tr("Allow"),tr("Deny"))==1 ) 189 tr("Allow"),tr("Deny"))==1 )
188 { 190 {
189 denials++; 191 denials++;
190 lastdenial=now; 192 lastdenial=now;
191 return FALSE; 193 return FALSE;
192 } else { 194 } else {
193 denials=0; 195 denials=0;
194 cfg.writeEntry("Passwords",pwds+" "+cpassword); 196 cfg.writeEntry("Passwords",pwds+" "+cpassword);
195 return TRUE; 197 return TRUE;
196 } 198 }
197 } 199 }
@@ -201,3 +203,2 @@ bool SyncAuthentication::checkPassword( const QString& password )
201 203
202
203ServerPI::ServerPI( int socket, QObject *parent , const char* name ) 204ServerPI::ServerPI( int socket, QObject *parent , const char* name )
@@ -214,33 +215,33 @@ ServerPI::ServerPI( int socket, QObject *parent , const char* name )
214 if ( !SyncAuthentication::isAuthorized(peeraddress) ) { 215 if ( !SyncAuthentication::isAuthorized(peeraddress) ) {
215 state = Forbidden; 216 state = Forbidden;
216 startTimer( 0 ); 217 startTimer( 0 );
217 } else 218 } else
218 #endif 219#endif
219 { 220 {
220 connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); 221 connect( this, SIGNAL( readyRead() ), SLOT( read() ) );
221 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 222 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
222 223
223 passiv = FALSE; 224 passiv = FALSE;
224 for( int i = 0; i < 4; i++ ) 225 for( int i = 0; i < 4; i++ )
225 wait[i] = FALSE; 226 wait[i] = FALSE;
226 227
227 send( "220 Qtopia " QPE_VERSION " FTP Server" ); 228 send( "220 Qtopia " QPE_VERSION " FTP Server" );
228 state = Wait_USER; 229 state = Wait_USER;
229 230
230 dtp = new ServerDTP( this ); 231 dtp = new ServerDTP( this );
231 connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); 232 connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) );
232 connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); 233 connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) );
233 connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); 234 connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) );
234 235
235 236
236 directory = QDir::currentDirPath(); 237 directory = QDir::currentDirPath();
237 238
238 static int p = 1024; 239 static int p = 1024;
239 240
240 while ( !serversocket || !serversocket->ok() ) { 241 while ( !serversocket || !serversocket->ok() ) {
241 delete serversocket; 242 delete serversocket;
242 serversocket = new ServerSocket( ++p, this ); 243 serversocket = new ServerSocket( ++p, this );
243 } 244 }
244 connect( serversocket, SIGNAL( newIncomming( int ) ), 245 connect( serversocket, SIGNAL( newIncomming( int ) ),
245 SLOT( newConnection( int ) ) ); 246 SLOT( newConnection( int ) ) );
246 } 247 }
@@ -269,3 +270,3 @@ void ServerPI::read()
269 while ( canReadLine() ) 270 while ( canReadLine() )
270 process( readLine().stripWhiteSpace() ); 271 process( readLine().stripWhiteSpace() );
271} 272}
@@ -277,5 +278,5 @@ bool ServerPI::checkReadFile( const QString& file )
277 if ( file[0] != "/" ) 278 if ( file[0] != "/" )
278 filename = directory.path() + "/" + file; 279 filename = directory.path() + "/" + file;
279 else 280 else
280 filename = file; 281 filename = file;
281 282
@@ -290,5 +291,5 @@ bool ServerPI::checkWriteFile( const QString& file )
290 if ( file[0] != "/" ) 291 if ( file[0] != "/" )
291 filename = directory.path() + "/" + file; 292 filename = directory.path() + "/" + file;
292 else 293 else
293 filename = file; 294 filename = file;
294 295
@@ -297,4 +298,4 @@ bool ServerPI::checkWriteFile( const QString& file )
297 if ( fi.exists() ) 298 if ( fi.exists() )
298 if ( !QFile( filename ).remove() ) 299 if ( !QFile( filename ).remove() )
299 return FALSE; 300 return FALSE;
300 return TRUE; 301 return TRUE;
@@ -316,3 +317,3 @@ void ServerPI::process( const QString& message )
316 if ( msg.count() >= 2 ) 317 if ( msg.count() >= 2 )
317 arg = msg[1]; 318 arg = msg[1];
318 319
@@ -332,5 +333,5 @@ void ServerPI::process( const QString& message )
332 if ( cmd == "QUIT" ) { 333 if ( cmd == "QUIT" ) {
333 send( "211 Good bye!" ); 334 send( "211 Good bye!" );
334 delete this; 335 delete this;
335 return; 336 return;
336 } 337 }
@@ -339,3 +340,3 @@ void ServerPI::process( const QString& message )
339 if ( Connected == state ) 340 if ( Connected == state )
340 return; 341 return;
341 342
@@ -344,9 +345,9 @@ void ServerPI::process( const QString& message )
344 345
345 if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { 346 if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) {
346 send( "530 Please login with USER and PASS" ); 347 send( "530 Please login with USER and PASS" );
347 return; 348 return;
348 } 349 }
349 send( "331 User name ok, need password" ); 350 send( "331 User name ok, need password" );
350 state = Wait_PASS; 351 state = Wait_PASS;
351 return; 352 return;
352 } 353 }
@@ -356,9 +357,9 @@ void ServerPI::process( const QString& message )
356 357
357 if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { 358 if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) {
358 send( "530 Please login with USER and PASS" ); 359 send( "530 Please login with USER and PASS" );
359 return; 360 return;
360 } 361 }
361 send( "230 User logged in, proceed" ); 362 send( "230 User logged in, proceed" );
362 state = Ready; 363 state = Ready;
363 return; 364 return;
364 } 365 }
@@ -370,4 +371,4 @@ void ServerPI::process( const QString& message )
370 if ( cmd == "ACCT" ) { 371 if ( cmd == "ACCT" ) {
371 // even wu-ftp does not support it 372 // even wu-ftp does not support it
372 send( "502 Command not implemented" ); 373 send( "502 Command not implemented" );
373 } 374 }
@@ -377,10 +378,10 @@ void ServerPI::process( const QString& message )
377 378
378 if ( !args.isEmpty() ) { 379 if ( !args.isEmpty() ) {
379 if ( directory.cd( args, TRUE ) ) 380 if ( directory.cd( args, TRUE ) )
380 send( "250 Requested file action okay, completed" ); 381 send( "250 Requested file action okay, completed" );
381 else 382 else
382 send( "550 Requested action not taken" ); 383 send( "550 Requested action not taken" );
383 } 384 }
384 else 385 else
385 send( "500 Syntax error, command unrecognized" ); 386 send( "500 Syntax error, command unrecognized" );
386 } 387 }
@@ -389,6 +390,6 @@ void ServerPI::process( const QString& message )
389 else if ( cmd == "CDUP" ) { 390 else if ( cmd == "CDUP" ) {
390 if ( directory.cdUp() ) 391 if ( directory.cdUp() )
391 send( "250 Requested file action okay, completed" ); 392 send( "250 Requested file action okay, completed" );
392 else 393 else
393 send( "550 Requested action not taken" ); 394 send( "550 Requested action not taken" );
394 } 395 }
@@ -397,4 +398,4 @@ void ServerPI::process( const QString& message )
397 else if ( cmd == "SMNT" ) { 398 else if ( cmd == "SMNT" ) {
398 // even wu-ftp does not support it 399 // even wu-ftp does not support it
399 send( "502 Command not implemented" ); 400 send( "502 Command not implemented" );
400 } 401 }
@@ -403,4 +404,4 @@ void ServerPI::process( const QString& message )
403 else if ( cmd == "REIN" ) { 404 else if ( cmd == "REIN" ) {
404 // even wu-ftp does not support it 405 // even wu-ftp does not support it
405 send( "502 Command not implemented" ); 406 send( "502 Command not implemented" );
406 } 407 }
@@ -413,6 +414,6 @@ void ServerPI::process( const QString& message )
413 else if ( cmd == "PORT" ) { 414 else if ( cmd == "PORT" ) {
414 if ( parsePort( arg ) ) 415 if ( parsePort( arg ) )
415 send( "200 Command okay" ); 416 send( "200 Command okay" );
416 else 417 else
417 send( "500 Syntax error, command unrecognized" ); 418 send( "500 Syntax error, command unrecognized" );
418 } 419 }
@@ -421,7 +422,7 @@ void ServerPI::process( const QString& message )
421 else if ( cmd == "PASV" ) { 422 else if ( cmd == "PASV" ) {
422 passiv = TRUE; 423 passiv = TRUE;
423 send( "227 Entering Passive Mode (" 424 send( "227 Entering Passive Mode ("
424 + address().toString().replace( QRegExp( "\\." ), "," ) + "," 425 + address().toString().replace( QRegExp( "\\." ), "," ) + ","
425 + QString::number( ( serversocket->port() ) >> 8 ) + "," 426 + QString::number( ( serversocket->port() ) >> 8 ) + ","
426 + QString::number( ( serversocket->port() ) & 0xFF ) +")" ); 427 + QString::number( ( serversocket->port() ) & 0xFF ) +")" );
427 } 428 }
@@ -430,6 +431,6 @@ void ServerPI::process( const QString& message )
430 else if ( cmd == "TYPE" ) { 431 else if ( cmd == "TYPE" ) {
431 if ( arg.upper() == "A" || arg.upper() == "I" ) 432 if ( arg.upper() == "A" || arg.upper() == "I" )
432 send( "200 Command okay" ); 433 send( "200 Command okay" );
433 else 434 else
434 send( "504 Command not implemented for that parameter" ); 435 send( "504 Command not implemented for that parameter" );
435 } 436 }
@@ -438,6 +439,6 @@ void ServerPI::process( const QString& message )
438 else if ( cmd == "STRU" ) { 439 else if ( cmd == "STRU" ) {
439 if ( arg.upper() == "F" ) 440 if ( arg.upper() == "F" )
440 send( "200 Command okay" ); 441 send( "200 Command okay" );
441 else 442 else
442 send( "504 Command not implemented for that parameter" ); 443 send( "504 Command not implemented for that parameter" );
443 } 444 }
@@ -446,6 +447,6 @@ void ServerPI::process( const QString& message )
446 else if ( cmd == "MODE" ) { 447 else if ( cmd == "MODE" ) {
447 if ( arg.upper() == "S" ) 448 if ( arg.upper() == "S" )
448 send( "200 Command okay" ); 449 send( "200 Command okay" );
449 else 450 else
450 send( "504 Command not implemented for that parameter" ); 451 send( "504 Command not implemented for that parameter" );
451 } 452 }
@@ -458,11 +459,11 @@ void ServerPI::process( const QString& message )
458 else if ( cmd == "RETR" ) 459 else if ( cmd == "RETR" )
459 if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) 460 if ( !args.isEmpty() && checkReadFile( absFilePath( args ) )
460 || backupRestoreGzip( absFilePath( args ) ) ) { 461 || backupRestoreGzip( absFilePath( args ) ) ) {
461 send( "150 File status okay" ); 462 send( "150 File status okay" );
462 sendFile( absFilePath( args ) ); 463 sendFile( absFilePath( args ) );
463 } 464 }
464 else { 465 else {
465 qDebug("550 Requested action not taken"); 466 qDebug("550 Requested action not taken");
466 send( "550 Requested action not taken" ); 467 send( "550 Requested action not taken" );
467 } 468 }
468 469
@@ -470,8 +471,8 @@ void ServerPI::process( const QString& message )
470 else if ( cmd == "STOR" ) 471 else if ( cmd == "STOR" )
471 if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { 472 if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) {
472 send( "150 File status okay" ); 473 send( "150 File status okay" );
473 retrieveFile( absFilePath( args ) ); 474 retrieveFile( absFilePath( args ) );
474 } 475 }
475 else 476 else
476 send( "550 Requested action not taken" ); 477 send( "550 Requested action not taken" );
477 478
@@ -479,3 +480,3 @@ void ServerPI::process( const QString& message )
479 else if ( cmd == "STOU" ) { 480 else if ( cmd == "STOU" ) {
480 send( "502 Command not implemented" ); 481 send( "502 Command not implemented" );
481 } 482 }
@@ -484,3 +485,3 @@ void ServerPI::process( const QString& message )
484 else if ( cmd == "APPE" ) { 485 else if ( cmd == "APPE" ) {
485 send( "502 Command not implemented" ); 486 send( "502 Command not implemented" );
486 } 487 }
@@ -489,3 +490,3 @@ void ServerPI::process( const QString& message )
489 else if ( cmd == "ALLO" ) { 490 else if ( cmd == "ALLO" ) {
490 send( "200 Command okay" ); 491 send( "200 Command okay" );
491 } 492 }
@@ -494,3 +495,3 @@ void ServerPI::process( const QString& message )
494 else if ( cmd == "REST" ) { 495 else if ( cmd == "REST" ) {
495 send( "502 Command not implemented" ); 496 send( "502 Command not implemented" );
496 } 497 }
@@ -499,14 +500,14 @@ void ServerPI::process( const QString& message )
499 else if ( cmd == "RNFR" ) { 500 else if ( cmd == "RNFR" ) {
500 renameFrom = QString::null; 501 renameFrom = QString::null;
501 if ( args.isEmpty() ) 502 if ( args.isEmpty() )
502 send( "500 Syntax error, command unrecognized" ); 503 send( "500 Syntax error, command unrecognized" );
503 else { 504 else {
504 QFile file( absFilePath( args ) ); 505 QFile file( absFilePath( args ) );
505 if ( file.exists() ) { 506 if ( file.exists() ) {
506 send( "350 File exists, ready for destination name" ); 507 send( "350 File exists, ready for destination name" );
507 renameFrom = absFilePath( args ); 508 renameFrom = absFilePath( args );
508 } 509 }
509 else 510 else
510 send( "550 Requested action not taken" ); 511 send( "550 Requested action not taken" );
511 } 512 }
512 } 513 }
@@ -515,13 +516,13 @@ void ServerPI::process( const QString& message )
515 else if ( cmd == "RNTO" ) { 516 else if ( cmd == "RNTO" ) {
516 if ( lastCommand != "RNFR" ) 517 if ( lastCommand != "RNFR" )
517 send( "503 Bad sequence of commands" ); 518 send( "503 Bad sequence of commands" );
518 else if ( args.isEmpty() ) 519 else if ( args.isEmpty() )
519 send( "500 Syntax error, command unrecognized" ); 520 send( "500 Syntax error, command unrecognized" );
520 else { 521 else {
521 QDir dir( absFilePath( args ) ); 522 QDir dir( absFilePath( args ) );
522 if ( dir.rename( renameFrom, absFilePath( args ), TRUE ) ) 523 if ( dir.rename( renameFrom, absFilePath( args ), TRUE ) )
523 send( "250 Requested file action okay, completed." ); 524 send( "250 Requested file action okay, completed." );
524 else 525 else
525 send( "550 Requested action not taken" ); 526 send( "550 Requested action not taken" );
526 } 527 }
527 } 528 }
@@ -530,7 +531,7 @@ void ServerPI::process( const QString& message )
530 else if ( cmd.contains( "ABOR" ) ) { 531 else if ( cmd.contains( "ABOR" ) ) {
531 dtp->close(); 532 dtp->close();
532 if ( dtp->dtpMode() != ServerDTP::Idle ) 533 if ( dtp->dtpMode() != ServerDTP::Idle )
533 send( "426 Connection closed; transfer aborted" ); 534 send( "426 Connection closed; transfer aborted" );
534 else 535 else
535 send( "226 Closing data connection" ); 536 send( "226 Closing data connection" );
536 } 537 }
@@ -539,14 +540,14 @@ void ServerPI::process( const QString& message )
539 else if ( cmd == "DELE" ) { 540 else if ( cmd == "DELE" ) {
540 if ( args.isEmpty() ) 541 if ( args.isEmpty() )
541 send( "500 Syntax error, command unrecognized" ); 542 send( "500 Syntax error, command unrecognized" );
542 else { 543 else {
543 QFile file( absFilePath( args ) ) ; 544 QFile file( absFilePath( args ) ) ;
544 if ( file.remove() ) { 545 if ( file.remove() ) {
545 send( "250 Requested file action okay, completed" ); 546 send( "250 Requested file action okay, completed" );
546 QCopEnvelope e("QPE/System", "linkChanged(QString)" ); 547 QCopEnvelope e("QPE/System", "linkChanged(QString)" );
547 e << file.name(); 548 e << file.name();
548 } else { 549 } else {
549 send( "550 Requested action not taken" ); 550 send( "550 Requested action not taken" );
550 } 551 }
551 } 552 }
552 } 553 }
@@ -555,11 +556,11 @@ void ServerPI::process( const QString& message )
555 else if ( cmd == "RMD" ) { 556 else if ( cmd == "RMD" ) {
556 if ( args.isEmpty() ) 557 if ( args.isEmpty() )
557 send( "500 Syntax error, command unrecognized" ); 558 send( "500 Syntax error, command unrecognized" );
558 else { 559 else {
559 QDir dir; 560 QDir dir;
560 if ( dir.rmdir( absFilePath( args ), TRUE ) ) 561 if ( dir.rmdir( absFilePath( args ), TRUE ) )
561 send( "250 Requested file action okay, completed" ); 562 send( "250 Requested file action okay, completed" );
562 else 563 else
563 send( "550 Requested action not taken" ); 564 send( "550 Requested action not taken" );
564 } 565 }
565 } 566 }
@@ -568,13 +569,13 @@ void ServerPI::process( const QString& message )
568 else if ( cmd == "MKD" ) { 569 else if ( cmd == "MKD" ) {
569 if ( args.isEmpty() ) { 570 if ( args.isEmpty() ) {
570 qDebug(" Error: no arg"); 571 qDebug(" Error: no arg");
571 send( "500 Syntax error, command unrecognized" ); 572 send( "500 Syntax error, command unrecognized" );
572 } 573 }
573 else { 574 else {
574 QDir dir; 575 QDir dir;
575 if ( dir.mkdir( absFilePath( args ), TRUE ) ) 576 if ( dir.mkdir( absFilePath( args ), TRUE ) )
576 send( "250 Requested file action okay, completed." ); 577 send( "250 Requested file action okay, completed." );
577 else 578 else
578 send( "550 Requested action not taken" ); 579 send( "550 Requested action not taken" );
579 } 580 }
580 } 581 }
@@ -583,3 +584,3 @@ void ServerPI::process( const QString& message )
583 else if ( cmd == "PWD" ) { 584 else if ( cmd == "PWD" ) {
584 send( "257 \"" + directory.path() +"\"" ); 585 send( "257 \"" + directory.path() +"\"" );
585 } 586 }
@@ -588,6 +589,6 @@ void ServerPI::process( const QString& message )
588 else if ( cmd == "LIST" ) { 589 else if ( cmd == "LIST" ) {
589 if ( sendList( absFilePath( args ) ) ) 590 if ( sendList( absFilePath( args ) ) )
590 send( "150 File status okay" ); 591 send( "150 File status okay" );
591 else 592 else
592 send( "500 Syntax error, command unrecognized" ); 593 send( "500 Syntax error, command unrecognized" );
593 } 594 }
@@ -596,28 +597,28 @@ void ServerPI::process( const QString& message )
596 else if ( cmd == "SIZE" ) { 597 else if ( cmd == "SIZE" ) {
597 QString filePath = absFilePath( args ); 598 QString filePath = absFilePath( args );
598 QFileInfo fi( filePath ); 599 QFileInfo fi( filePath );
599 bool gzipfile = backupRestoreGzip( filePath ); 600 bool gzipfile = backupRestoreGzip( filePath );
600 if ( !fi.exists() && !gzipfile ) 601 if ( !fi.exists() && !gzipfile )
601 send( "500 Syntax error, command unrecognized" ); 602 send( "500 Syntax error, command unrecognized" );
602 else { 603 else {
603 if ( !gzipfile ) 604 if ( !gzipfile )
604 send( "213 " + QString::number( fi.size() ) ); 605 send( "213 " + QString::number( fi.size() ) );
605 else { 606 else {
606 Process duproc( QString("du") ); 607 Process duproc( QString("du") );
607 duproc.addArgument("-s"); 608 duproc.addArgument("-s");
608 QString in, out; 609 QString in, out;
609 if ( !duproc.exec(in, out) ) { 610 if ( !duproc.exec(in, out) ) {
610 qDebug("du process failed; just sending back 1K"); 611 qDebug("du process failed; just sending back 1K");
611 send( "213 1024"); 612 send( "213 1024");
612 } 613 }
613 else { 614 else {
614 QString size = out.left( out.find("\t") ); 615 QString size = out.left( out.find("\t") );
615 int guess = size.toInt()/5; 616 int guess = size.toInt()/5;
616 if ( filePath.contains("doc") ) 617 if ( filePath.contains("doc") )
617 guess *= 1000; 618 guess *= 1000;
618 qDebug("sending back gzip guess of %d", guess); 619 qDebug("sending back gzip guess of %d", guess);
619 send( "213 " + QString::number(guess) ); 620 send( "213 " + QString::number(guess) );
620 } 621 }
621 } 622 }
622 } 623 }
623 } 624 }
@@ -625,3 +626,3 @@ void ServerPI::process( const QString& message )
625 else if ( cmd == "NLST" ) { 626 else if ( cmd == "NLST" ) {
626 send( "502 Command not implemented" ); 627 send( "502 Command not implemented" );
627 } 628 }
@@ -630,3 +631,3 @@ void ServerPI::process( const QString& message )
630 else if ( cmd == "SITE" ) { 631 else if ( cmd == "SITE" ) {
631 send( "502 Command not implemented" ); 632 send( "502 Command not implemented" );
632 } 633 }
@@ -635,3 +636,3 @@ void ServerPI::process( const QString& message )
635 else if ( cmd == "SYST" ) { 636 else if ( cmd == "SYST" ) {
636 send( "215 UNIX Type: L8" ); 637 send( "215 UNIX Type: L8" );
637 } 638 }
@@ -640,3 +641,3 @@ void ServerPI::process( const QString& message )
640 else if ( cmd == "STAT" ) { 641 else if ( cmd == "STAT" ) {
641 send( "502 Command not implemented" ); 642 send( "502 Command not implemented" );
642 } 643 }
@@ -645,3 +646,3 @@ void ServerPI::process( const QString& message )
645 else if ( cmd == "HELP" ) { 646 else if ( cmd == "HELP" ) {
646 send( "502 Command not implemented" ); 647 send( "502 Command not implemented" );
647 } 648 }
@@ -650,3 +651,3 @@ void ServerPI::process( const QString& message )
650 else if ( cmd == "NOOP" ) { 651 else if ( cmd == "NOOP" ) {
651 send( "200 Command okay" ); 652 send( "200 Command okay" );
652 } 653 }
@@ -655,3 +656,3 @@ void ServerPI::process( const QString& message )
655 else 656 else
656 send( "502 Command not implemented" ); 657 send( "502 Command not implemented" );
657 658
@@ -663,3 +664,3 @@ bool ServerPI::backupRestoreGzip( const QString &file )
663 return (file.find( "backup" ) != -1 && 664 return (file.find( "backup" ) != -1 &&
664 file.findRev( ".tgz" ) == (int)file.length()-4 ); 665 file.findRev( ".tgz" ) == (int)file.length()-4 );
665} 666}
@@ -673,3 +674,3 @@ bool ServerPI::backupRestoreGzip( const QString &file, QStringList &targets )
673 qDebug("ServerPI::backupRestoreGzip for %s = %s", file.latin1(), 674 qDebug("ServerPI::backupRestoreGzip for %s = %s", file.latin1(),
674 targets.join(" ").latin1() ); 675 targets.join(" ").latin1() );
675 return true; 676 return true;
@@ -682,6 +683,6 @@ void ServerPI::sendFile( const QString& file )
682 if ( passiv ) { 683 if ( passiv ) {
683 wait[SendFile] = TRUE; 684 wait[SendFile] = TRUE;
684 waitfile = file; 685 waitfile = file;
685 if ( waitsocket ) 686 if ( waitsocket )
686 newConnection( waitsocket ); 687 newConnection( waitsocket );
687 } 688 }
@@ -690,3 +691,3 @@ void ServerPI::sendFile( const QString& file )
690 if ( backupRestoreGzip( file, targets ) ) 691 if ( backupRestoreGzip( file, targets ) )
691 dtp->sendGzipFile( file, targets, peeraddress, peerport ); 692 dtp->sendGzipFile( file, targets, peeraddress, peerport );
692 else dtp->sendFile( file, peeraddress, peerport ); 693 else dtp->sendFile( file, peeraddress, peerport );
@@ -698,6 +699,6 @@ void ServerPI::retrieveFile( const QString& file )
698 if ( passiv ) { 699 if ( passiv ) {
699 wait[RetrieveFile] = TRUE; 700 wait[RetrieveFile] = TRUE;
700 waitfile = file; 701 waitfile = file;
701 if ( waitsocket ) 702 if ( waitsocket )
702 newConnection( waitsocket ); 703 newConnection( waitsocket );
703 } 704 }
@@ -706,5 +707,5 @@ void ServerPI::retrieveFile( const QString& file )
706 if ( backupRestoreGzip( file, targets ) ) 707 if ( backupRestoreGzip( file, targets ) )
707 dtp->retrieveGzipFile( file, peeraddress, peerport ); 708 dtp->retrieveGzipFile( file, peeraddress, peerport );
708 else 709 else
709 dtp->retrieveFile( file, peeraddress, peerport ); 710 dtp->retrieveFile( file, peeraddress, peerport );
710 } 711 }
@@ -719,3 +720,3 @@ bool ServerPI::parsePort( const QString& pp )
719 peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + 720 peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) +
720 ( p[2].toInt() << 8 ) + p[3].toInt() ); 721 ( p[2].toInt() << 8 ) + p[3].toInt() );
721 peerport = ( p[4].toInt() << 8 ) + p[5].toInt(); 722 peerport = ( p[4].toInt() << 8 ) + p[5].toInt();
@@ -728,7 +729,7 @@ void ServerPI::dtpCompleted()
728 if ( dtp->dtpMode() == ServerDTP::RetrieveFile ) { 729 if ( dtp->dtpMode() == ServerDTP::RetrieveFile ) {
729 QString fn = dtp->fileName(); 730 QString fn = dtp->fileName();
730 if ( fn.right(8)==".desktop" && fn.find("/Documents/")>=0 ) { 731 if ( fn.right(8)==".desktop" && fn.find("/Documents/")>=0 ) {
731 QCopEnvelope e("QPE/System", "linkChanged(QString)" ); 732 QCopEnvelope e("QPE/System", "linkChanged(QString)" );
732 e << fn; 733 e << fn;
733 } 734 }
734 } 735 }
@@ -758,3 +759,3 @@ bool ServerPI::sendList( const QString& arg )
758 if ( !buffer.open( IO_WriteOnly ) ) 759 if ( !buffer.open( IO_WriteOnly ) )
759 return FALSE; 760 return FALSE;
760 761
@@ -764,3 +765,3 @@ bool ServerPI::sendList( const QString& arg )
764 if ( fn.isEmpty() ) 765 if ( fn.isEmpty() )
765 fn = directory.path(); 766 fn = directory.path();
766 767
@@ -771,3 +772,3 @@ bool ServerPI::sendList( const QString& arg )
771 if ( fi.isFile() ) { 772 if ( fi.isFile() ) {
772 ts << fileListing( &fi ) << endl; 773 ts << fileListing( &fi ) << endl;
773 } 774 }
@@ -776,26 +777,26 @@ bool ServerPI::sendList( const QString& arg )
776 else if ( fi.isDir() ) { 777 else if ( fi.isDir() ) {
777 QDir dir( fn ); 778 QDir dir( fn );
778 const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); 779 const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden );
779 780
780 QFileInfoListIterator it( *list ); 781 QFileInfoListIterator it( *list );
781 QFileInfo *info; 782 QFileInfo *info;
782 783
783 unsigned long total = 0; 784 unsigned long total = 0;
784 while ( ( info = it.current() ) ) { 785 while ( ( info = it.current() ) ) {
785 if ( info->fileName() != "." && info->fileName() != ".." ) 786 if ( info->fileName() != "." && info->fileName() != ".." )
786 total += info->size(); 787 total += info->size();
787 ++it; 788 ++it;
788 } 789 }
789 790
790 ts << "total " << QString::number( total / 1024 ) << endl; 791 ts << "total " << QString::number( total / 1024 ) << endl;
791 792
792 it.toFirst(); 793 it.toFirst();
793 while ( ( info = it.current() ) ) { 794 while ( ( info = it.current() ) ) {
794 if ( info->fileName() == "." || info->fileName() == ".." ) { 795 if ( info->fileName() == "." || info->fileName() == ".." ) {
795 ++it; 796 ++it;
796 continue; 797 continue;
797 } 798 }
798 ts << fileListing( info ) << endl; 799 ts << fileListing( info ) << endl;
799 ++it; 800 ++it;
800 } 801 }
801 } 802 }
@@ -803,9 +804,9 @@ bool ServerPI::sendList( const QString& arg )
803 if ( passiv ) { 804 if ( passiv ) {
804 waitarray = buffer.buffer(); 805 waitarray = buffer.buffer();
805 wait[SendByteArray] = TRUE; 806 wait[SendByteArray] = TRUE;
806 if ( waitsocket ) 807 if ( waitsocket )
807 newConnection( waitsocket ); 808 newConnection( waitsocket );
808 } 809 }
809 else 810 else
810 dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); 811 dtp->sendByteArray( buffer.buffer(), peeraddress, peerport );
811 return TRUE; 812 return TRUE;
@@ -820,7 +821,7 @@ QString ServerPI::fileListing( QFileInfo *info )
820 if ( info->isDir() ) 821 if ( info->isDir() )
821 s += "d"; 822 s += "d";
822 else if ( info->isSymLink() ) 823 else if ( info->isSymLink() )
823 s += "l"; 824 s += "l";
824 else 825 else
825 s += "-"; 826 s += "-";
826 827
@@ -833,3 +834,3 @@ QString ServerPI::fileListing( QFileInfo *info )
833 if ( info->isDir() ) 834 if ( info->isDir() )
834 subdirs = 2; 835 subdirs = 2;
835 // FIXME : this is to slow 836 // FIXME : this is to slow
@@ -853,5 +854,5 @@ QString ServerPI::fileListing( QFileInfo *info )
853 s += date.monthName( date.month() ) + " " 854 s += date.monthName( date.month() ) + " "
854 + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " 855 + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " "
855 + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" 856 + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":"
856 + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; 857 + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " ";
857 858
@@ -902,8 +903,8 @@ void ServerPI::newConnection( int socket )
902 if ( wait[SendFile] ) { 903 if ( wait[SendFile] ) {
903 QStringList targets; 904 QStringList targets;
904 if ( backupRestoreGzip( waitfile, targets ) ) 905 if ( backupRestoreGzip( waitfile, targets ) )
905 dtp->sendGzipFile( waitfile, targets ); 906 dtp->sendGzipFile( waitfile, targets );
906 else 907 else
907 dtp->sendFile( waitfile ); 908 dtp->sendFile( waitfile );
908 dtp->setSocket( socket ); 909 dtp->setSocket( socket );
909 } 910 }
@@ -912,5 +913,5 @@ void ServerPI::newConnection( int socket )
912 if ( backupRestoreGzip( waitfile ) ) 913 if ( backupRestoreGzip( waitfile ) )
913 dtp->retrieveGzipFile( waitfile ); 914 dtp->retrieveGzipFile( waitfile );
914 else 915 else
915 dtp->retrieveFile( waitfile ); 916 dtp->retrieveFile( waitfile );
916 dtp->setSocket( socket ); 917 dtp->setSocket( socket );
@@ -918,15 +919,15 @@ void ServerPI::newConnection( int socket )
918 else if ( wait[SendByteArray] ) { 919 else if ( wait[SendByteArray] ) {
919 dtp->sendByteArray( waitarray ); 920 dtp->sendByteArray( waitarray );
920 dtp->setSocket( socket ); 921 dtp->setSocket( socket );
921 } 922 }
922 else if ( wait[RetrieveByteArray] ) { 923 else if ( wait[RetrieveByteArray] ) {
923 qDebug("retrieve byte array"); 924 qDebug("retrieve byte array");
924 dtp->retrieveByteArray(); 925 dtp->retrieveByteArray();
925 dtp->setSocket( socket ); 926 dtp->setSocket( socket );
926 } 927 }
927 else 928 else
928 waitsocket = socket; 929 waitsocket = socket;
929 930
930 for( int i = 0; i < 4; i++ ) 931 for( int i = 0; i < 4; i++ )
931 wait[i] = FALSE; 932 wait[i] = FALSE;
932} 933}
@@ -939,3 +940,3 @@ QString ServerPI::absFilePath( const QString& file )
939 if ( file[0] != "/" ) 940 if ( file[0] != "/" )
940 filepath = directory.path() + "/" + file; 941 filepath = directory.path() + "/" + file;
941 942
@@ -975,5 +976,5 @@ retrieveTargzProc( 0 ), gzipProc( 0 )
975 connect( retrieveTargzProc, SIGNAL( processExited() ), 976 connect( retrieveTargzProc, SIGNAL( processExited() ),
976 SIGNAL( completed() ) ); 977 SIGNAL( completed() ) );
977 connect( retrieveTargzProc, SIGNAL( processExited() ), 978 connect( retrieveTargzProc, SIGNAL( processExited() ),
978 SLOT( extractTarDone() ) ); 979 SLOT( extractTarDone() ) );
979} 980}
@@ -1018,6 +1019,6 @@ void ServerDTP::connected()
1018 if( !file.atEnd() ) { 1019 if( !file.atEnd() ) {
1019 QCString s; 1020 QCString s;
1020 s.resize( block_size ); 1021 s.resize( block_size );
1021 int bytes = file.readBlock( s.data(), block_size ); 1022 int bytes = file.readBlock( s.data(), block_size );
1022 writeBlock( s.data(), bytes ); 1023 writeBlock( s.data(), bytes );
1023 } 1024 }
@@ -1036,4 +1037,4 @@ void ServerDTP::connected()
1036 qWarning("Error starting %s or %s", 1037 qWarning("Error starting %s or %s",
1037 createTargzProc->arguments().join(" ").latin1(), 1038 createTargzProc->arguments().join(" ").latin1(),
1038 gzipProc->arguments().join(" ").latin1() ); 1039 gzipProc->arguments().join(" ").latin1() );
1039 break; 1040 break;
@@ -1091,6 +1092,6 @@ void ServerDTP::connectionClosed()
1091 if ( SendFile == mode ) { 1092 if ( SendFile == mode ) {
1092 if ( bytes_written == file.size() ) 1093 if ( bytes_written == file.size() )
1093 emit completed(); 1094 emit completed();
1094 else 1095 else
1095 emit failed(); 1096 emit failed();
1096 } 1097 }
@@ -1099,6 +1100,6 @@ void ServerDTP::connectionClosed()
1099 else if ( SendBuffer == mode ) { 1100 else if ( SendBuffer == mode ) {
1100 if ( bytes_written == buf.size() ) 1101 if ( bytes_written == buf.size() )
1101 emit completed(); 1102 emit completed();
1102 else 1103 else
1103 emit failed(); 1104 emit failed();
1104 } 1105 }
@@ -1107,4 +1108,4 @@ void ServerDTP::connectionClosed()
1107 else if ( RetrieveFile == mode ) { 1108 else if ( RetrieveFile == mode ) {
1108 file.close(); 1109 file.close();
1109 emit completed(); 1110 emit completed();
1110 } 1111 }
@@ -1112,5 +1113,5 @@ void ServerDTP::connectionClosed()
1112 else if ( RetrieveGzipFile == mode ) { 1113 else if ( RetrieveGzipFile == mode ) {
1113 qDebug("Done writing ungzip file; closing input"); 1114 qDebug("Done writing ungzip file; closing input");
1114 gzipProc->flushStdin(); 1115 gzipProc->flushStdin();
1115 gzipProc->closeStdin(); 1116 gzipProc->closeStdin();
1116 } 1117 }
@@ -1119,4 +1120,4 @@ void ServerDTP::connectionClosed()
1119 else if ( RetrieveBuffer == mode ) { 1120 else if ( RetrieveBuffer == mode ) {
1120 buf.close(); 1121 buf.close();
1121 emit completed(); 1122 emit completed();
1122 } 1123 }
@@ -1133,14 +1134,14 @@ void ServerDTP::bytesWritten( int bytes )
1133 1134
1134 if ( bytes_written == file.size() ) { 1135 if ( bytes_written == file.size() ) {
1135 // qDebug( "Debug: Sending complete: %d bytes", file.size() ); 1136 // qDebug( "Debug: Sending complete: %d bytes", file.size() );
1136 file.close(); 1137 file.close();
1137 emit completed(); 1138 emit completed();
1138 mode = Idle; 1139 mode = Idle;
1139 } 1140 }
1140 else if( !file.atEnd() ) { 1141 else if( !file.atEnd() ) {
1141 QCString s; 1142 QCString s;
1142 s.resize( block_size ); 1143 s.resize( block_size );
1143 int bytes = file.readBlock( s.data(), block_size ); 1144 int bytes = file.readBlock( s.data(), block_size );
1144 writeBlock( s.data(), bytes ); 1145 writeBlock( s.data(), bytes );
1145 } 1146 }
1146 } 1147 }
@@ -1150,7 +1151,7 @@ void ServerDTP::bytesWritten( int bytes )
1150 1151
1151 if ( bytes_written == buf.size() ) { 1152 if ( bytes_written == buf.size() ) {
1152 // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); 1153 // qDebug( "Debug: Sending complete: %d bytes", buf.size() );
1153 emit completed(); 1154 emit completed();
1154 mode = Idle; 1155 mode = Idle;
1155 } 1156 }
1156 } 1157 }
@@ -1162,16 +1163,16 @@ void ServerDTP::readyRead()
1162 if ( RetrieveFile == mode ) { 1163 if ( RetrieveFile == mode ) {
1163 QCString s; 1164 QCString s;
1164 s.resize( bytesAvailable() ); 1165 s.resize( bytesAvailable() );
1165 readBlock( s.data(), bytesAvailable() ); 1166 readBlock( s.data(), bytesAvailable() );
1166 file.writeBlock( s.data(), s.size() ); 1167 file.writeBlock( s.data(), s.size() );
1167 } 1168 }
1168 else if ( RetrieveGzipFile == mode ) { 1169 else if ( RetrieveGzipFile == mode ) {
1169 if ( !gzipProc->isRunning() ) 1170 if ( !gzipProc->isRunning() )
1170 gzipProc->start(); 1171 gzipProc->start();
1171 1172
1172 QByteArray s; 1173 QByteArray s;
1173 s.resize( bytesAvailable() ); 1174 s.resize( bytesAvailable() );
1174 readBlock( s.data(), bytesAvailable() ); 1175 readBlock( s.data(), bytesAvailable() );
1175 gzipProc->writeToStdin( s ); 1176 gzipProc->writeToStdin( s );
1176 qDebug("wrote %d bytes to ungzip ", s.size() ); 1177 qDebug("wrote %d bytes to ungzip ", s.size() );
1177 } 1178 }
@@ -1179,6 +1180,6 @@ void ServerDTP::readyRead()
1179 else if ( RetrieveBuffer == mode ) { 1180 else if ( RetrieveBuffer == mode ) {
1180 QCString s; 1181 QCString s;
1181 s.resize( bytesAvailable() ); 1182 s.resize( bytesAvailable() );
1182 readBlock( s.data(), bytesAvailable() ); 1183 readBlock( s.data(), bytesAvailable() );
1183 buf.writeBlock( s.data(), s.size() ); 1184 buf.writeBlock( s.data(), s.size() );
1184 } 1185 }
@@ -1192,7 +1193,7 @@ void ServerDTP::writeTargzBlock()
1192 if ( !createTargzProc->isRunning() ) { 1193 if ( !createTargzProc->isRunning() ) {
1193 qDebug("tar and gzip done"); 1194 qDebug("tar and gzip done");
1194 emit completed(); 1195 emit completed();
1195 mode = Idle; 1196 mode = Idle;
1196 disconnect( gzipProc, SIGNAL( readyReadStdout() ), 1197 disconnect( gzipProc, SIGNAL( readyReadStdout() ),
1197 this, SLOT( writeTargzBlock() ) ); 1198 this, SLOT( writeTargzBlock() ) );
1198 } 1199 }
@@ -1204,3 +1205,3 @@ void ServerDTP::targzDone()
1204 disconnect( createTargzProc, SIGNAL( readyReadStdout() ), 1205 disconnect( createTargzProc, SIGNAL( readyReadStdout() ),
1205 this, SLOT( gzipTarBlock() ) ); 1206 this, SLOT( gzipTarBlock() ) );
1206 gzipProc->closeStdin(); 1207 gzipProc->closeStdin();
@@ -1212,4 +1213,4 @@ void ServerDTP::gzipTarBlock()
1212 if ( !gzipProc->isRunning() ) { 1213 if ( !gzipProc->isRunning() ) {
1213 //qDebug("auto start gzip proc"); 1214 //qDebug("auto start gzip proc");
1214 gzipProc->start(); 1215 gzipProc->start();
1215 } 1216 }
@@ -1232,4 +1233,4 @@ void ServerDTP::sendFile( const QString fn )
1232void ServerDTP::sendGzipFile( const QString &fn, 1233void ServerDTP::sendGzipFile( const QString &fn,
1233 const QStringList &archiveTargets, 1234 const QStringList &archiveTargets,
1234 const QHostAddress& host, Q_UINT16 port ) 1235 const QHostAddress& host, Q_UINT16 port )
1235{ 1236{
@@ -1240,3 +1241,3 @@ void ServerDTP::sendGzipFile( const QString &fn,
1240void ServerDTP::sendGzipFile( const QString &fn, 1241void ServerDTP::sendGzipFile( const QString &fn,
1241 const QStringList &archiveTargets ) 1242 const QStringList &archiveTargets )
1242{ 1243{
@@ -1251,7 +1252,7 @@ void ServerDTP::sendGzipFile( const QString &fn,
1251 connect( createTargzProc, 1252 connect( createTargzProc,
1252 SIGNAL( readyReadStdout() ), SLOT( gzipTarBlock() ) ); 1253 SIGNAL( readyReadStdout() ), SLOT( gzipTarBlock() ) );
1253 1254
1254 gzipProc->setArguments( "gzip" ); 1255 gzipProc->setArguments( "gzip" );
1255 connect( gzipProc, SIGNAL( readyReadStdout() ), 1256 connect( gzipProc, SIGNAL( readyReadStdout() ),
1256 SLOT( writeTargzBlock() ) ); 1257 SLOT( writeTargzBlock() ) );
1257} 1258}
@@ -1262,6 +1263,6 @@ void ServerDTP::gunzipDone()
1262 disconnect( gzipProc, SIGNAL( processExited() ), 1263 disconnect( gzipProc, SIGNAL( processExited() ),
1263 this, SLOT( gunzipDone() ) ); 1264 this, SLOT( gunzipDone() ) );
1264 retrieveTargzProc->closeStdin(); 1265 retrieveTargzProc->closeStdin();
1265 disconnect( gzipProc, SIGNAL( readyReadStdout() ), 1266 disconnect( gzipProc, SIGNAL( readyReadStdout() ),
1266 this, SLOT( tarExtractBlock() ) ); 1267 this, SLOT( tarExtractBlock() ) );
1267} 1268}
@@ -1272,5 +1273,5 @@ void ServerDTP::tarExtractBlock()
1272 if ( !retrieveTargzProc->isRunning() ) { 1273 if ( !retrieveTargzProc->isRunning() ) {
1273 qDebug("auto start ungzip proc"); 1274 qDebug("auto start ungzip proc");
1274 if ( !retrieveTargzProc->start() ) 1275 if ( !retrieveTargzProc->start() )
1275 qWarning(" failed to start tar -x process"); 1276 qWarning(" failed to start tar -x process");
1276 } 1277 }
@@ -1299,7 +1300,7 @@ void ServerDTP::retrieveGzipFile( const QString &fn )
1299 1300
1300 gzipProc->setArguments( "gunzip" ); 1301 gzipProc->setArguments( "gunzip" );
1301 connect( gzipProc, SIGNAL( readyReadStdout() ), 1302 connect( gzipProc, SIGNAL( readyReadStdout() ),
1302 SLOT( tarExtractBlock() ) ); 1303 SLOT( tarExtractBlock() ) );
1303 connect( gzipProc, SIGNAL( processExited() ), 1304 connect( gzipProc, SIGNAL( processExited() ),
1304 SLOT( gunzipDone() ) ); 1305 SLOT( gunzipDone() ) );
1305} 1306}