summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/transferserver.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index eea9f3a..9519d11 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -300,97 +300,99 @@ ServerPI::ServerPI( int socket, QObject *parent, const char* name )
300 storFileSize(-1) 300 storFileSize(-1)
301{ 301{
302 state = Connected; 302 state = Connected;
303 303
304 setSocket( socket ); 304 setSocket( socket );
305 305
306 peerport = peerPort(); 306 peerport = peerPort();
307 peeraddress = peerAddress(); 307 peeraddress = peerAddress();
308 308
309#ifndef INSECURE 309#ifndef INSECURE
310 if ( !SyncAuthentication::isAuthorized(peeraddress) ) { 310 if ( !SyncAuthentication::isAuthorized(peeraddress) ) {
311 state = Forbidden; 311 state = Forbidden;
312 startTimer( 0 ); 312 startTimer( 0 );
313 } else 313 } else
314#endif 314#endif
315 { 315 {
316 connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); 316 connect( this, SIGNAL( readyRead() ), SLOT( read() ) );
317 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 317 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
318 318
319 passiv = FALSE; 319 passiv = FALSE;
320 for( int i = 0; i < 4; i++ ) 320 for( int i = 0; i < 4; i++ )
321 wait[i] = FALSE; 321 wait[i] = FALSE;
322 322
323 send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr 323 send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr
324 state = Wait_USER; 324 state = Wait_USER;
325 325
326 dtp = new ServerDTP( this ); 326 dtp = new ServerDTP( this );
327 connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); 327 connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) );
328 connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); 328 connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) );
329 connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); 329 connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) );
330 330
331 331
332 directory = QDir::currentDirPath(); 332 directory = QDir::currentDirPath();
333 333
334 static int p = 1024; 334 static int p = 1024;
335 335
336 while ( !serversocket || !serversocket->ok() ) { 336 while ( !serversocket || !serversocket->ok() ) {
337 delete serversocket; 337 delete serversocket;
338 serversocket = new ServerSocket( ++p, this ); 338 serversocket = new ServerSocket( ++p, this );
339 } 339 }
340 connect( serversocket, SIGNAL( newIncomming( int ) ), 340 connect( serversocket, SIGNAL( newIncomming( int ) ),
341 SLOT( newConnection( int ) ) ); 341 SLOT( newConnection( int ) ) );
342 } 342 }
343} 343}
344 344
345ServerPI::~ServerPI() 345ServerPI::~ServerPI()
346{ 346{
347 close(); 347 close();
348 dtp->close(); 348
349 if ( dtp )
350 dtp->close();
349 delete dtp; 351 delete dtp;
350 delete serversocket; 352 delete serversocket;
351} 353}
352 354
353bool ServerPI::verifyAuthorised() 355bool ServerPI::verifyAuthorised()
354{ 356{
355 if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { 357 if ( !SyncAuthentication::isAuthorized(peerAddress()) ) {
356 state = Forbidden; 358 state = Forbidden;
357 return FALSE; 359 return FALSE;
358 } 360 }
359 return TRUE; 361 return TRUE;
360} 362}
361 363
362void ServerPI::connectionClosed() 364void ServerPI::connectionClosed()
363{ 365{
364 // qDebug( "Debug: Connection closed" ); 366 // qDebug( "Debug: Connection closed" );
365 emit connectionClosed(this); 367 emit connectionClosed(this);
366} 368}
367 369
368void ServerPI::send( const QString& msg ) 370void ServerPI::send( const QString& msg )
369{ 371{
370 QTextStream os( this ); 372 QTextStream os( this );
371 os << msg << endl; 373 os << msg << endl;
372 //qDebug( "Reply: %s", msg.latin1() ); 374 //qDebug( "Reply: %s", msg.latin1() );
373} 375}
374 376
375void ServerPI::read() 377void ServerPI::read()
376{ 378{
377 while ( canReadLine() ) 379 while ( canReadLine() )
378 process( readLine().stripWhiteSpace() ); 380 process( readLine().stripWhiteSpace() );
379} 381}
380 382
381bool ServerPI::checkReadFile( const QString& file ) 383bool ServerPI::checkReadFile( const QString& file )
382{ 384{
383 QString filename; 385 QString filename;
384 386
385 if ( file[0] != "/" ) 387 if ( file[0] != "/" )
386 filename = directory.path() + "/" + file; 388 filename = directory.path() + "/" + file;
387 else 389 else
388 filename = file; 390 filename = file;
389 391
390 QFileInfo fi( filename ); 392 QFileInfo fi( filename );
391 return ( fi.exists() && fi.isReadable() ); 393 return ( fi.exists() && fi.isReadable() );
392} 394}
393 395
394bool ServerPI::checkWriteFile( const QString& file ) 396bool ServerPI::checkWriteFile( const QString& file )
395{ 397{
396 QString filename; 398 QString filename;