summaryrefslogtreecommitdiff
path: root/core/qws/transferserver.cpp
Side-by-side diff
Diffstat (limited to 'core/qws/transferserver.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/qws/transferserver.cpp82
1 files changed, 43 insertions, 39 deletions
diff --git a/core/qws/transferserver.cpp b/core/qws/transferserver.cpp
index d0fec89..777c384 100644
--- a/core/qws/transferserver.cpp
+++ b/core/qws/transferserver.cpp
@@ -16,8 +16,12 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+
+/* OPIE */
+#include <opie2/odebug.h>
+
#define _XOPEN_SOURCE
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
@@ -73,9 +77,9 @@ TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
const char* name )
: QServerSocket( port, 1, parent, name )
{
if ( !ok() )
- qWarning( "Failed to bind to port %d", port );
+ owarn << "Failed to bind to port " << port << "" << oendl;
}
TransferServer::~TransferServer()
{
@@ -316,17 +320,17 @@ ServerPI::~ServerPI()
}
void ServerPI::connectionClosed()
{
- // qDebug( "Debug: Connection closed" );
+ // odebug << "Debug: Connection closed" << oendl;
delete this;
}
void ServerPI::send( const QString& msg )
{
QTextStream os( this );
os << msg << endl;
- //qDebug( "Reply: %s", msg.latin1() );
+ //odebug << "Reply: " << msg << "" << oendl;
}
void ServerPI::read()
{
@@ -365,9 +369,9 @@ bool ServerPI::checkWriteFile( const QString& file )
}
void ServerPI::process( const QString& message )
{
- //qDebug( "Command: %s", message.latin1() );
+ //odebug << "Command: " << message << "" << oendl;
// split message using "," as separator
QStringList msg = QStringList::split( " ", message );
if ( msg.isEmpty() )
@@ -390,9 +394,9 @@ void ServerPI::process( const QString& message )
copy.remove( copy.begin() );
args = copy.join( " " );
}
- //qDebug( "args: %s", args.latin1() );
+ //odebug << "args: " << args << "" << oendl;
// we always respond to QUIT, regardless of state
if ( cmd == "QUIT" ) {
send( "211 Good bye!" );
@@ -526,9 +530,9 @@ void ServerPI::process( const QString& message )
send( "150 File status okay" );
sendFile( absFilePath( args ) );
}
else {
- qDebug("550 Requested action not taken");
+ odebug << "550 Requested action not taken" << oendl;
send( "550 Requested action not taken" );
}
// store (STOR)
@@ -632,9 +636,9 @@ void ServerPI::process( const QString& message )
// make directory (MKD)
else if ( cmd == "MKD" ) {
if ( args.isEmpty() ) {
- qDebug(" Error: no arg");
+ odebug << " Error: no arg" << oendl;
send( "500 Syntax error, command unrecognized" );
}
else {
QDir dir;
@@ -672,17 +676,17 @@ void ServerPI::process( const QString& message )
Process duproc( QString("du") );
duproc.addArgument("-s");
QString in, out;
if ( !duproc.exec(in, out) ) {
- qDebug("du process failed; just sending back 1K");
+ odebug << "du process failed; just sending back 1K" << oendl;
send( "213 1024");
}
else {
QString size = out.left( out.find("\t") );
int guess = size.toInt() / 5;
if ( filePath.contains("doc") )
guess *= 1000;
- qDebug("sending back gzip guess of %d", guess);
+ odebug << "sending back gzip guess of " << guess << "" << oendl;
send( "213 " + QString::number(guess) );
}
}
}
@@ -735,10 +739,10 @@ bool ServerPI::backupRestoreGzip( const QString &file, QStringList &targets )
if ( file.find( "backup" ) != -1 &&
file.findRev( ".tgz" ) == (int)file.length() - 4 ) {
QFileInfo info( file );
targets = info.dirPath( TRUE );
- qDebug("ServerPI::backupRestoreGzip for %s = %s", file.latin1(),
- targets.join(" ").latin1() );
+ odebug << "ServerPI::backupRestoreGzip for " << file.latin1() << " = "
+ << targets.join(" ").latin1() << oendl;
return true;
}
return false;
}
@@ -983,9 +987,9 @@ QString ServerPI::permissionString( QFileInfo *info )
}
void ServerPI::newConnection( int socket )
{
- //qDebug( "New incomming connection" );
+ //odebug << "New incomming connection" << oendl;
if ( !passiv )
return ;
@@ -997,9 +1001,9 @@ void ServerPI::newConnection( int socket )
dtp->sendFile( waitfile );
dtp->setSocket( socket );
}
else if ( wait[RetrieveFile] ) {
- qDebug("check retrieve file");
+ odebug << "check retrieve file" << oendl;
if ( backupRestoreGzip( waitfile ) )
dtp->retrieveGzipFile( waitfile );
else
dtp->retrieveFile( waitfile );
@@ -1009,9 +1013,9 @@ void ServerPI::newConnection( int socket )
dtp->sendByteArray( waitarray );
dtp->setSocket( socket );
}
else if ( wait[RetrieveByteArray] ) {
- qDebug("retrieve byte array");
+ odebug << "retrieve byte array" << oendl;
dtp->retrieveByteArray();
dtp->setSocket( socket );
}
else
@@ -1074,9 +1078,9 @@ ServerDTP::~ServerDTP()
}
void ServerDTP::extractTarDone()
{
- qDebug("extract done");
+ odebug << "extract done" << oendl;
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" );
e << file.name();
@@ -1093,9 +1097,9 @@ void ServerDTP::connected()
mode = Idle;
return ;
}
- //qDebug( "Debug: Sending file '%s'", file.name().latin1() );
+ //odebug << "Debug: Sending file '" << file.name() << "'" << oendl;
bytes_written = 0;
if ( file.size() == 0 ) {
//make sure it doesn't hang on empty files
@@ -1115,14 +1119,14 @@ void ServerDTP::connected()
break;
case SendGzipFile:
if ( createTargzProc->isRunning() ) {
// SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY
- qWarning("Previous tar --gzip process is still running; killing it...");
+ owarn << "Previous tar --gzip process is still running; killing it..." << oendl;
createTargzProc->kill();
}
bytes_written = 0;
- qDebug("==>start send tar process");
+ odebug << "==>start send tar process" << oendl;
if ( !createTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdout) )
qWarning("Error starting %s or %s",
createTargzProc->args()[0].data(),
gzipProc->args()[0].data());
@@ -1133,9 +1137,9 @@ void ServerDTP::connected()
mode = Idle;
return ;
}
- // qDebug( "Debug: Sending byte array" );
+ // odebug << "Debug: Sending byte array" << oendl;
bytes_written = 0;
while ( !buf.atEnd() )
putch( buf.getch() );
buf.close();
@@ -1152,31 +1156,31 @@ void ServerDTP::connected()
emit failed();
mode = Idle;
return ;
}
- // qDebug( "Debug: Retrieving file %s", file.name().latin1() );
+ // odebug << "Debug: Retrieving file " << file.name() << "" << oendl;
break;
case RetrieveGzipFile:
- qDebug("=-> starting tar process to receive .tgz file");
+ odebug << "=-> starting tar process to receive .tgz file" << oendl;
break;
case RetrieveBuffer:
// retrieve buffer mode
if ( !buf.open( IO_WriteOnly) ) {
emit failed();
mode = Idle;
return ;
}
- // qDebug( "Debug: Retrieving byte array" );
+ // odebug << "Debug: Retrieving byte array" << oendl;
break;
case Idle:
- qDebug("connection established but mode set to Idle; BUG!");
+ odebug << "connection established but mode set to Idle; BUG!" << oendl;
break;
}
}
void ServerDTP::connectionClosed()
{
- //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written );
+ //odebug << "Debug: Data connection closed " << bytes_written << " bytes written" << oendl;
// send file mode
if ( SendFile == mode ) {
if ( bytes_written == file.size() )
@@ -1199,9 +1203,9 @@ void ServerDTP::connectionClosed()
emit completed();
}
else if ( RetrieveGzipFile == mode ) {
- qDebug("Done writing ungzip file; closing input");
+ odebug << "Done writing ungzip file; closing input" << oendl;
gzipProc->flushStdin();
gzipProc->closeStdin();
}
@@ -1221,9 +1225,9 @@ void ServerDTP::bytesWritten( int bytes )
// send file mode
if ( SendFile == mode ) {
if ( bytes_written == file.size() ) {
- // qDebug( "Debug: Sending complete: %d bytes", file.size() );
+ // odebug << "Debug: Sending complete: " << file.size() << " bytes" << oendl;
file.close();
emit completed();
mode = Idle;
}
@@ -1238,9 +1242,9 @@ void ServerDTP::bytesWritten( int bytes )
// send buffer mode
if ( SendBuffer == mode ) {
if ( bytes_written == buf.size() ) {
- // qDebug( "Debug: Sending complete: %d bytes", buf.size() );
+ // odebug << "Debug: Sending complete: " << buf.size() << " bytes" << oendl;
emit completed();
mode = Idle;
}
}
@@ -1262,9 +1266,9 @@ void ServerDTP::readyRead()
QByteArray s;
s.resize( bytesAvailable() );
readBlock( s.data(), bytesAvailable() );
gzipProc->writeStdin( s.data(), s.size() );
- qDebug("wrote %d bytes to ungzip ", s.size() );
+ odebug << "wrote " << s.size() << " bytes to ungzip " << oendl;
}
// retrieve buffer mode
else if ( RetrieveBuffer == mode ) {
QCString s;
@@ -1276,11 +1280,11 @@ void ServerDTP::readyRead()
void ServerDTP::writeTargzBlock(Opie::Core::OProcess *, char *buffer, int buflen)
{
writeBlock( buffer, buflen );
- qDebug("writeTargzBlock %d", buflen);
+ odebug << "writeTargzBlock " << buflen << "" << oendl;
if ( !createTargzProc->isRunning() ) {
- qDebug("tar and gzip done");
+ odebug << "tar and gzip done" << oendl;
emit completed();
mode = Idle;
disconnect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
this, SLOT( writeTargzBlock(Opie::Core::OProcess*,char*,int) ) );
@@ -1288,19 +1292,19 @@ void ServerDTP::writeTargzBlock(Opie::Core::OProcess *, char *buffer, int buflen
}
void ServerDTP::targzDone()
{
- //qDebug("targz done");
+ //odebug << "targz done" << oendl;
disconnect( createTargzProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
this, SLOT( gzipTarBlock(Opie::Core::OProcess*,char*,int) ) );
gzipProc->closeStdin();
}
void ServerDTP::gzipTarBlock(Opie::Core::OProcess *, char *buffer, int buflen)
{
- //qDebug("gzipTarBlock");
+ //odebug << "gzipTarBlock" << oendl;
if ( !gzipProc->isRunning() ) {
- //qDebug("auto start gzip proc");
+ //odebug << "auto start gzip proc" << oendl;
gzipProc->start(Opie::Core::OProcess::NotifyOnExit, (Opie::Core::OProcess::Communication) ( Opie::Core::OProcess::Stdin | Opie::Core::OProcess::Stdout ));
}
gzipProc->writeStdin( buffer, buflen );
}
@@ -1334,9 +1338,9 @@ void ServerDTP::sendGzipFile( const QString &fn,
QStringList args = "tar";
args += "-cv";
args += archiveTargets;
- qDebug("sendGzipFile %s", args.join(" ").latin1() );
+ odebug << "sendGzipFile " << args.join(" ") << "" << oendl;
createTargzProc->clearArguments( );
*createTargzProc << args;
connect( createTargzProc,
SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ), SLOT( gzipTarBlock(Opie::Core::OProcess*,char*,int) ) );
@@ -1348,9 +1352,9 @@ void ServerDTP::sendGzipFile( const QString &fn,
}
void ServerDTP::gunzipDone()
{
- qDebug("gunzipDone");
+ odebug << "gunzipDone" << oendl;
disconnect( gzipProc, SIGNAL( processExited() ),
this, SLOT( gunzipDone() ) );
retrieveTargzProc->closeStdin();
disconnect( gzipProc, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
@@ -1358,13 +1362,13 @@ void ServerDTP::gunzipDone()
}
void ServerDTP::tarExtractBlock(Opie::Core::OProcess *, char *buffer, int buflen)
{
- qDebug("tarExtractBlock");
+ odebug << "tarExtractBlock" << oendl;
if ( !retrieveTargzProc->isRunning() ) {
- qDebug("auto start ungzip proc");
+ odebug << "auto start ungzip proc" << oendl;
if ( !retrieveTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdin) )
- qWarning(" failed to start tar -x process");
+ owarn << " failed to start tar -x process" << oendl;
}
retrieveTargzProc->writeStdin( buffer, buflen );
}
@@ -1383,9 +1387,9 @@ void ServerDTP::retrieveFile( const QString fn )
}
void ServerDTP::retrieveGzipFile( const QString &fn )
{
- qDebug("retrieveGzipFile %s", fn.latin1());
+ odebug << "retrieveGzipFile " << fn << "" << oendl;
file.setName( fn );
mode = RetrieveGzipFile;
gzipProc->clearArguments();