summaryrefslogtreecommitdiff
path: root/core/launcher/transferserver.cpp
Side-by-side diff
Diffstat (limited to 'core/launcher/transferserver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/transferserver.cpp107
1 files changed, 48 insertions, 59 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index e32cf41..4b764e3 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -18,9 +18,23 @@
**
**********************************************************************/
-//#define _XOPEN_SOURCE
+#include "transferserver.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <opie2/oglobal.h>
+#include <qtopia/qprocess.h>
+#include <qtopia/process.h>
+#include <qtopia/private/contact.h>
+#include <qtopia/version.h>
+#ifdef Q_WS_QWS
+#include <qtopia/qcopenvelope_qws.h>
+#endif
+using namespace Opie::Core;
-#ifndef Q_OS_WIN32
+/* QT */
+#include <qtextstream.h>
+#include <qmessagebox.h>
+
+/* STD */
#include <pwd.h>
#include <sys/types.h>
@@ -34,31 +48,6 @@
#endif /* Q_OS_MACX */
-#else
-#include <stdlib.h>
-#include <time.h>
-#endif
-
-
-#if defined(_OS_LINUX_)
-#include <shadow.h>
-#endif
-
-#include <qtextstream.h>
-#include <qmessagebox.h>
-//#include <qtopia/qcopchannel_qws.h>
-#include <qtopia/process.h>
-#include <qtopia/private/contact.h>
-#include <qtopia/version.h>
-#ifdef Q_WS_QWS
-#include <qtopia/qcopenvelope_qws.h>
-#endif
-
-
-#include "transferserver.h"
-#include <qtopia/qprocess.h>
-
const int block_size = 51200;
-using namespace Opie::Core;
TransferServer::TransferServer( Q_UINT16 port, QObject *parent,
const char* name)
@@ -67,5 +56,5 @@ TransferServer::TransferServer( Q_UINT16 port, QObject *parent,
connections.setAutoDelete( TRUE );
if ( !ok() )
- qWarning( "Failed to bind to port %d", port );
+ owarn << "Failed to bind to port " << port << "" << oendl;
}
@@ -372,5 +361,5 @@ bool ServerPI::verifyAuthorised()
void ServerPI::connectionClosed()
{
- // qDebug( "Debug: Connection closed" );
+ // odebug << "Debug: Connection closed" << oendl;
emit connectionClosed(this);
}
@@ -380,5 +369,5 @@ void ServerPI::send( const QString& msg )
QTextStream os( this );
os << msg << endl;
- //qDebug( "Reply: %s", msg.latin1() );
+ //odebug << "Reply: " << msg << "" << oendl;
}
@@ -421,5 +410,5 @@ 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
@@ -445,5 +434,5 @@ void ServerPI::process( const QString& message )
}
- //qDebug( "args: %s", args.latin1() );
+ //odebug << "args: " << args << "" << oendl;
// we always respond to QUIT, regardless of state
@@ -584,5 +573,5 @@ void ServerPI::process( const QString& message )
}
else {
- qDebug("550 Requested action not taken");
+ odebug << "550 Requested action not taken" << oendl;
send( "550 Requested action not taken" ); // No tr
}
@@ -690,5 +679,5 @@ void ServerPI::process( const QString& message )
else if ( cmd == "MKD" ) {
if ( args.isEmpty() ) {
- qDebug(" Error: no arg");
+ odebug << " Error: no arg" << oendl;
send( "500 Syntax error, command unrecognized" ); // No tr
}
@@ -730,5 +719,5 @@ void ServerPI::process( const QString& message )
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");
}
@@ -738,5 +727,5 @@ void ServerPI::process( const QString& message )
if ( filePath.contains("doc") ) // No tr
guess *= 1000;
- qDebug("sending back gzip guess of %d", guess);
+ odebug << "sending back gzip guess of " << guess << "" << oendl;
send( "213 " + QString::number(guess) );
}
@@ -1027,5 +1016,5 @@ QString ServerPI::permissionString( QFileInfo *info )
void ServerPI::newConnection( int socket )
{
- //qDebug( "New incomming connection" );
+ //odebug << "New incomming connection" << oendl;
if ( !passiv ) return;
@@ -1040,5 +1029,5 @@ void ServerPI::newConnection( int socket )
}
else if ( wait[RetrieveFile] ) {
- qDebug("check retrieve file");
+ odebug << "check retrieve file" << oendl;
if ( backupRestoreGzip( waitfile ) )
dtp->retrieveGzipFile( waitfile );
@@ -1052,5 +1041,5 @@ void ServerPI::newConnection( int socket )
}
else if ( wait[RetrieveByteArray] ) {
- qDebug("retrieve byte array");
+ odebug << "retrieve byte array" << oendl;
dtp->retrieveByteArray();
dtp->setSocket( socket );
@@ -1112,5 +1101,5 @@ ServerDTP::~ServerDTP()
file.close();
if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) {
- qDebug( "STOR incomplete" );
+ odebug << "STOR incomplete" << oendl;
file.remove();
}
@@ -1123,5 +1112,5 @@ ServerDTP::~ServerDTP()
void ServerDTP::extractTarDone()
{
- qDebug("extract done");
+ odebug << "extract done" << oendl;
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/System", "restoreDone(QString)" );
@@ -1141,5 +1130,5 @@ void ServerDTP::connected()
}
- //qDebug( "Debug: Sending file '%s'", file.name().latin1() );
+ //odebug << "Debug: Sending file '" << file.name() << "'" << oendl;
bytes_written = 0;
@@ -1162,10 +1151,10 @@ void ServerDTP::connected()
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() )
qWarning("Error starting %s",
@@ -1179,5 +1168,5 @@ void ServerDTP::connected()
}
- // qDebug( "Debug: Sending byte array" );
+ // odebug << "Debug: Sending byte array" << oendl;
bytes_written = 0;
while( !buf.atEnd() )
@@ -1198,8 +1187,8 @@ void ServerDTP::connected()
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:
@@ -1210,8 +1199,8 @@ void ServerDTP::connected()
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;
}
@@ -1220,5 +1209,5 @@ void ServerDTP::connected()
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
@@ -1242,5 +1231,5 @@ void ServerDTP::connectionClosed()
file.close();
if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) {
- qDebug( "STOR incomplete" );
+ odebug << "STOR incomplete" << oendl;
file.remove();
emit failed();
@@ -1251,5 +1240,5 @@ void ServerDTP::connectionClosed()
else if ( RetrieveGzipFile == mode ) {
- qDebug("Done writing ungzip file; closing input");
+ odebug << "Done writing ungzip file; closing input" << oendl;
retrieveTargzProc->flushStdin();
retrieveTargzProc->closeStdin();
@@ -1273,5 +1262,5 @@ void ServerDTP::bytesWritten( int bytes )
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();
@@ -1290,5 +1279,5 @@ void ServerDTP::bytesWritten( int bytes )
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;
@@ -1314,5 +1303,5 @@ void ServerDTP::readyRead()
readBlock( s.data(), bytesAvailable() );
retrieveTargzProc->writeToStdin( s );
- qDebug("wrote %d bytes to ungzip ", s.size() );
+ odebug << "wrote " << s.size() << " bytes to ungzip " << oendl;
}
// retrieve buffer mode
@@ -1329,10 +1318,10 @@ void ServerDTP::writeTargzBlock()
QByteArray block = createTargzProc->readStdout();
writeBlock( block.data(), block.size() );
- qDebug("writeTargzBlock %d", block.size());
+ odebug << "writeTargzBlock " << block.size() << "" << oendl;
}
void ServerDTP::targzDone()
{
- qDebug("tar and gzip done");
+ odebug << "tar and gzip done" << oendl;
emit completed();
mode = Idle;
@@ -1371,5 +1360,5 @@ void ServerDTP::sendGzipFile( const QString &fn,
//args += "-cv";
args += archiveTargets;
- qDebug("sendGzipFile %s", args.join(" ").latin1() );
+ odebug << "sendGzipFile " << args.join(" ") << "" << oendl;
createTargzProc->setArguments( args );
connect( createTargzProc,
@@ -1394,5 +1383,5 @@ void ServerDTP::retrieveFile( const QString fn, int fileSize )
void ServerDTP::retrieveGzipFile( const QString &fn )
{
- qDebug("retrieveGzipFile %s", fn.latin1());
+ odebug << "retrieveGzipFile " << fn << "" << oendl;
file.setName( fn );
mode = RetrieveGzipFile;