author | mickeyl <mickeyl> | 2004-04-07 13:36:16 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-07 13:36:16 (UTC) |
commit | 4f1d28a25ce6180850c3d26bac9b638f0f25532b (patch) (unidiff) | |
tree | 59b4879b1065086c9a2e28f16f7d48540c8a9456 /core/launcher/transferserver.cpp | |
parent | 8af35b63a277ec14dcc4a0a6ca5bbe228e276b98 (diff) | |
download | opie-4f1d28a25ce6180850c3d26bac9b638f0f25532b.zip opie-4f1d28a25ce6180850c3d26bac9b638f0f25532b.tar.gz opie-4f1d28a25ce6180850c3d26bac9b638f0f25532b.tar.bz2 |
use Opie debugging framework
Diffstat (limited to 'core/launcher/transferserver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/transferserver.cpp | 107 |
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 | |||
@@ -14,62 +14,51 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | //#define _XOPEN_SOURCE | 20 | #include "transferserver.h" |
21 | 21 | ||
22 | /* OPIE */ | ||
23 | #include <opie2/odebug.h> | ||
22 | #include <opie2/oglobal.h> | 24 | #include <opie2/oglobal.h> |
25 | #include <qtopia/qprocess.h> | ||
26 | #include <qtopia/process.h> | ||
27 | #include <qtopia/private/contact.h> | ||
28 | #include <qtopia/version.h> | ||
29 | #ifdef Q_WS_QWS | ||
30 | #include <qtopia/qcopenvelope_qws.h> | ||
31 | #endif | ||
32 | using namespace Opie::Core; | ||
23 | 33 | ||
24 | #ifndef Q_OS_WIN32 | 34 | /* QT */ |
35 | #include <qtextstream.h> | ||
36 | #include <qmessagebox.h> | ||
37 | |||
38 | /* STD */ | ||
25 | #include <pwd.h> | 39 | #include <pwd.h> |
26 | #include <sys/types.h> | 40 | #include <sys/types.h> |
27 | #include <unistd.h> | 41 | #include <unistd.h> |
28 | #include <stdlib.h> | 42 | #include <stdlib.h> |
29 | #include <time.h> | 43 | #include <time.h> |
30 | 44 | ||
31 | #ifndef Q_OS_MACX | 45 | #ifndef Q_OS_MACX |
32 | #include <shadow.h> | 46 | #include <shadow.h> |
33 | #include <crypt.h> | 47 | #include <crypt.h> |
34 | #endif /* Q_OS_MACX */ | 48 | #endif /* Q_OS_MACX */ |
35 | 49 | ||
36 | #else | ||
37 | #include <stdlib.h> | ||
38 | #include <time.h> | ||
39 | #endif | ||
40 | |||
41 | |||
42 | #if defined(_OS_LINUX_) | ||
43 | #include <shadow.h> | ||
44 | #endif | ||
45 | |||
46 | #include <qtextstream.h> | ||
47 | #include <qmessagebox.h> | ||
48 | //#include <qtopia/qcopchannel_qws.h> | ||
49 | #include <qtopia/process.h> | ||
50 | #include <qtopia/private/contact.h> | ||
51 | #include <qtopia/version.h> | ||
52 | #ifdef Q_WS_QWS | ||
53 | #include <qtopia/qcopenvelope_qws.h> | ||
54 | #endif | ||
55 | |||
56 | |||
57 | #include "transferserver.h" | ||
58 | #include <qtopia/qprocess.h> | ||
59 | |||
60 | const int block_size = 51200; | 50 | const int block_size = 51200; |
61 | 51 | ||
62 | using namespace Opie::Core; | ||
63 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, | 52 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, |
64 | const char* name) | 53 | const char* name) |
65 | : QServerSocket( port, 1, parent, name ) | 54 | : QServerSocket( port, 1, parent, name ) |
66 | { | 55 | { |
67 | connections.setAutoDelete( TRUE ); | 56 | connections.setAutoDelete( TRUE ); |
68 | if ( !ok() ) | 57 | if ( !ok() ) |
69 | qWarning( "Failed to bind to port %d", port ); | 58 | owarn << "Failed to bind to port " << port << "" << oendl; |
70 | } | 59 | } |
71 | 60 | ||
72 | void TransferServer::authorizeConnections() | 61 | void TransferServer::authorizeConnections() |
73 | { | 62 | { |
74 | QListIterator<ServerPI> it(connections); | 63 | QListIterator<ServerPI> it(connections); |
75 | while ( it.current() ) { | 64 | while ( it.current() ) { |
@@ -368,21 +357,21 @@ bool ServerPI::verifyAuthorised() | |||
368 | } | 357 | } |
369 | return TRUE; | 358 | return TRUE; |
370 | } | 359 | } |
371 | 360 | ||
372 | void ServerPI::connectionClosed() | 361 | void ServerPI::connectionClosed() |
373 | { | 362 | { |
374 | // qDebug( "Debug: Connection closed" ); | 363 | // odebug << "Debug: Connection closed" << oendl; |
375 | emit connectionClosed(this); | 364 | emit connectionClosed(this); |
376 | } | 365 | } |
377 | 366 | ||
378 | void ServerPI::send( const QString& msg ) | 367 | void ServerPI::send( const QString& msg ) |
379 | { | 368 | { |
380 | QTextStream os( this ); | 369 | QTextStream os( this ); |
381 | os << msg << endl; | 370 | os << msg << endl; |
382 | //qDebug( "Reply: %s", msg.latin1() ); | 371 | //odebug << "Reply: " << msg << "" << oendl; |
383 | } | 372 | } |
384 | 373 | ||
385 | void ServerPI::read() | 374 | void ServerPI::read() |
386 | { | 375 | { |
387 | while ( canReadLine() ) | 376 | while ( canReadLine() ) |
388 | process( readLine().stripWhiteSpace() ); | 377 | process( readLine().stripWhiteSpace() ); |
@@ -417,13 +406,13 @@ bool ServerPI::checkWriteFile( const QString& file ) | |||
417 | return FALSE; | 406 | return FALSE; |
418 | return TRUE; | 407 | return TRUE; |
419 | } | 408 | } |
420 | 409 | ||
421 | void ServerPI::process( const QString& message ) | 410 | void ServerPI::process( const QString& message ) |
422 | { | 411 | { |
423 | //qDebug( "Command: %s", message.latin1() ); | 412 | //odebug << "Command: " << message << "" << oendl; |
424 | 413 | ||
425 | // split message using "," as separator | 414 | // split message using "," as separator |
426 | QStringList msg = QStringList::split( " ", message ); | 415 | QStringList msg = QStringList::split( " ", message ); |
427 | if ( msg.isEmpty() ) return; | 416 | if ( msg.isEmpty() ) return; |
428 | 417 | ||
429 | // command token | 418 | // command token |
@@ -441,13 +430,13 @@ void ServerPI::process( const QString& message ) | |||
441 | // FIXME: for Qt3 | 430 | // FIXME: for Qt3 |
442 | // copy.pop_front() | 431 | // copy.pop_front() |
443 | copy.remove( copy.begin() ); | 432 | copy.remove( copy.begin() ); |
444 | args = copy.join( " " ); | 433 | args = copy.join( " " ); |
445 | } | 434 | } |
446 | 435 | ||
447 | //qDebug( "args: %s", args.latin1() ); | 436 | //odebug << "args: " << args << "" << oendl; |
448 | 437 | ||
449 | // we always respond to QUIT, regardless of state | 438 | // we always respond to QUIT, regardless of state |
450 | if ( cmd == "QUIT" ) { | 439 | if ( cmd == "QUIT" ) { |
451 | send( "211 Good bye!" ); // No tr | 440 | send( "211 Good bye!" ); // No tr |
452 | close(); | 441 | close(); |
453 | return; | 442 | return; |
@@ -580,13 +569,13 @@ void ServerPI::process( const QString& message ) | |||
580 | if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) | 569 | if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) |
581 | || backupRestoreGzip( absFilePath( args ) ) ) { | 570 | || backupRestoreGzip( absFilePath( args ) ) ) { |
582 | send( "150 File status okay" ); // No tr | 571 | send( "150 File status okay" ); // No tr |
583 | sendFile( absFilePath( args ) ); | 572 | sendFile( absFilePath( args ) ); |
584 | } | 573 | } |
585 | else { | 574 | else { |
586 | qDebug("550 Requested action not taken"); | 575 | odebug << "550 Requested action not taken" << oendl; |
587 | send( "550 Requested action not taken" ); // No tr | 576 | send( "550 Requested action not taken" ); // No tr |
588 | } | 577 | } |
589 | 578 | ||
590 | // store (STOR) | 579 | // store (STOR) |
591 | else if ( cmd == "STOR" ) | 580 | else if ( cmd == "STOR" ) |
592 | if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { | 581 | if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { |
@@ -686,13 +675,13 @@ void ServerPI::process( const QString& message ) | |||
686 | } | 675 | } |
687 | } | 676 | } |
688 | 677 | ||
689 | // make directory (MKD) | 678 | // make directory (MKD) |
690 | else if ( cmd == "MKD" ) { | 679 | else if ( cmd == "MKD" ) { |
691 | if ( args.isEmpty() ) { | 680 | if ( args.isEmpty() ) { |
692 | qDebug(" Error: no arg"); | 681 | odebug << " Error: no arg" << oendl; |
693 | send( "500 Syntax error, command unrecognized" ); // No tr | 682 | send( "500 Syntax error, command unrecognized" ); // No tr |
694 | } | 683 | } |
695 | else { | 684 | else { |
696 | QDir dir; | 685 | QDir dir; |
697 | if ( dir.mkdir( absFilePath( args ), TRUE ) ) | 686 | if ( dir.mkdir( absFilePath( args ), TRUE ) ) |
698 | send( "250 Requested file action okay, completed." ); // No tr | 687 | send( "250 Requested file action okay, completed." ); // No tr |
@@ -726,21 +715,21 @@ void ServerPI::process( const QString& message ) | |||
726 | send( "213 " + QString::number( fi.size() ) ); | 715 | send( "213 " + QString::number( fi.size() ) ); |
727 | else { | 716 | else { |
728 | Process duproc( QString("du") ); | 717 | Process duproc( QString("du") ); |
729 | duproc.addArgument("-s"); | 718 | duproc.addArgument("-s"); |
730 | QString in, out; | 719 | QString in, out; |
731 | if ( !duproc.exec(in, out) ) { | 720 | if ( !duproc.exec(in, out) ) { |
732 | qDebug("du process failed; just sending back 1K"); | 721 | odebug << "du process failed; just sending back 1K" << oendl; |
733 | send( "213 1024"); | 722 | send( "213 1024"); |
734 | } | 723 | } |
735 | else { | 724 | else { |
736 | QString size = out.left( out.find("\t") ); | 725 | QString size = out.left( out.find("\t") ); |
737 | int guess = size.toInt()/5; | 726 | int guess = size.toInt()/5; |
738 | if ( filePath.contains("doc") ) // No tr | 727 | if ( filePath.contains("doc") ) // No tr |
739 | guess *= 1000; | 728 | guess *= 1000; |
740 | qDebug("sending back gzip guess of %d", guess); | 729 | odebug << "sending back gzip guess of " << guess << "" << oendl; |
741 | send( "213 " + QString::number(guess) ); | 730 | send( "213 " + QString::number(guess) ); |
742 | } | 731 | } |
743 | } | 732 | } |
744 | } | 733 | } |
745 | } | 734 | } |
746 | // name list (NLST) | 735 | // name list (NLST) |
@@ -1023,38 +1012,38 @@ QString ServerPI::permissionString( QFileInfo *info ) | |||
1023 | 1012 | ||
1024 | return s; | 1013 | return s; |
1025 | } | 1014 | } |
1026 | 1015 | ||
1027 | void ServerPI::newConnection( int socket ) | 1016 | void ServerPI::newConnection( int socket ) |
1028 | { | 1017 | { |
1029 | //qDebug( "New incomming connection" ); | 1018 | //odebug << "New incomming connection" << oendl; |
1030 | 1019 | ||
1031 | if ( !passiv ) return; | 1020 | if ( !passiv ) return; |
1032 | 1021 | ||
1033 | if ( wait[SendFile] ) { | 1022 | if ( wait[SendFile] ) { |
1034 | QStringList targets; | 1023 | QStringList targets; |
1035 | if ( backupRestoreGzip( waitfile, targets ) ) | 1024 | if ( backupRestoreGzip( waitfile, targets ) ) |
1036 | dtp->sendGzipFile( waitfile, targets ); | 1025 | dtp->sendGzipFile( waitfile, targets ); |
1037 | else | 1026 | else |
1038 | dtp->sendFile( waitfile ); | 1027 | dtp->sendFile( waitfile ); |
1039 | dtp->setSocket( socket ); | 1028 | dtp->setSocket( socket ); |
1040 | } | 1029 | } |
1041 | else if ( wait[RetrieveFile] ) { | 1030 | else if ( wait[RetrieveFile] ) { |
1042 | qDebug("check retrieve file"); | 1031 | odebug << "check retrieve file" << oendl; |
1043 | if ( backupRestoreGzip( waitfile ) ) | 1032 | if ( backupRestoreGzip( waitfile ) ) |
1044 | dtp->retrieveGzipFile( waitfile ); | 1033 | dtp->retrieveGzipFile( waitfile ); |
1045 | else | 1034 | else |
1046 | dtp->retrieveFile( waitfile, storFileSize ); | 1035 | dtp->retrieveFile( waitfile, storFileSize ); |
1047 | dtp->setSocket( socket ); | 1036 | dtp->setSocket( socket ); |
1048 | } | 1037 | } |
1049 | else if ( wait[SendByteArray] ) { | 1038 | else if ( wait[SendByteArray] ) { |
1050 | dtp->sendByteArray( waitarray ); | 1039 | dtp->sendByteArray( waitarray ); |
1051 | dtp->setSocket( socket ); | 1040 | dtp->setSocket( socket ); |
1052 | } | 1041 | } |
1053 | else if ( wait[RetrieveByteArray] ) { | 1042 | else if ( wait[RetrieveByteArray] ) { |
1054 | qDebug("retrieve byte array"); | 1043 | odebug << "retrieve byte array" << oendl; |
1055 | dtp->retrieveByteArray(); | 1044 | dtp->retrieveByteArray(); |
1056 | dtp->setSocket( socket ); | 1045 | dtp->setSocket( socket ); |
1057 | } | 1046 | } |
1058 | else | 1047 | else |
1059 | waitsocket = socket; | 1048 | waitsocket = socket; |
1060 | 1049 | ||
@@ -1108,24 +1097,24 @@ ServerDTP::~ServerDTP() | |||
1108 | { | 1097 | { |
1109 | buf.close(); | 1098 | buf.close(); |
1110 | if ( RetrieveFile == mode && file.isOpen() ) { | 1099 | if ( RetrieveFile == mode && file.isOpen() ) { |
1111 | // We're being shutdown before the client closed. | 1100 | // We're being shutdown before the client closed. |
1112 | file.close(); | 1101 | file.close(); |
1113 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { | 1102 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { |
1114 | qDebug( "STOR incomplete" ); | 1103 | odebug << "STOR incomplete" << oendl; |
1115 | file.remove(); | 1104 | file.remove(); |
1116 | } | 1105 | } |
1117 | } else { | 1106 | } else { |
1118 | file.close(); | 1107 | file.close(); |
1119 | } | 1108 | } |
1120 | createTargzProc->kill(); | 1109 | createTargzProc->kill(); |
1121 | } | 1110 | } |
1122 | 1111 | ||
1123 | void ServerDTP::extractTarDone() | 1112 | void ServerDTP::extractTarDone() |
1124 | { | 1113 | { |
1125 | qDebug("extract done"); | 1114 | odebug << "extract done" << oendl; |
1126 | #ifndef QT_NO_COP | 1115 | #ifndef QT_NO_COP |
1127 | QCopEnvelope e( "QPE/System", "restoreDone(QString)" ); | 1116 | QCopEnvelope e( "QPE/System", "restoreDone(QString)" ); |
1128 | e << file.name(); | 1117 | e << file.name(); |
1129 | #endif | 1118 | #endif |
1130 | } | 1119 | } |
1131 | 1120 | ||
@@ -1137,13 +1126,13 @@ void ServerDTP::connected() | |||
1137 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { | 1126 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { |
1138 | emit failed(); | 1127 | emit failed(); |
1139 | mode = Idle; | 1128 | mode = Idle; |
1140 | return; | 1129 | return; |
1141 | } | 1130 | } |
1142 | 1131 | ||
1143 | //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); | 1132 | //odebug << "Debug: Sending file '" << file.name() << "'" << oendl; |
1144 | 1133 | ||
1145 | bytes_written = 0; | 1134 | bytes_written = 0; |
1146 | if ( file.size() == 0 ) { | 1135 | if ( file.size() == 0 ) { |
1147 | //make sure it doesn't hang on empty files | 1136 | //make sure it doesn't hang on empty files |
1148 | file.close(); | 1137 | file.close(); |
1149 | emit completed(); | 1138 | emit completed(); |
@@ -1158,30 +1147,30 @@ void ServerDTP::connected() | |||
1158 | } | 1147 | } |
1159 | } | 1148 | } |
1160 | break; | 1149 | break; |
1161 | case SendGzipFile: | 1150 | case SendGzipFile: |
1162 | if ( createTargzProc->isRunning() ) { | 1151 | if ( createTargzProc->isRunning() ) { |
1163 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY | 1152 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY |
1164 | qWarning("Previous tar --gzip process is still running; killing it..."); | 1153 | owarn << "Previous tar --gzip process is still running; killing it..." << oendl; |
1165 | createTargzProc->kill(); | 1154 | createTargzProc->kill(); |
1166 | } | 1155 | } |
1167 | 1156 | ||
1168 | bytes_written = 0; | 1157 | bytes_written = 0; |
1169 | qDebug("==>start send tar process"); | 1158 | odebug << "==>start send tar process" << oendl; |
1170 | if ( !createTargzProc->start() ) | 1159 | if ( !createTargzProc->start() ) |
1171 | qWarning("Error starting %s", | 1160 | qWarning("Error starting %s", |
1172 | createTargzProc->arguments().join(" ").latin1()); | 1161 | createTargzProc->arguments().join(" ").latin1()); |
1173 | break; | 1162 | break; |
1174 | case SendBuffer: | 1163 | case SendBuffer: |
1175 | if ( !buf.open( IO_ReadOnly) ) { | 1164 | if ( !buf.open( IO_ReadOnly) ) { |
1176 | emit failed(); | 1165 | emit failed(); |
1177 | mode = Idle; | 1166 | mode = Idle; |
1178 | return; | 1167 | return; |
1179 | } | 1168 | } |
1180 | 1169 | ||
1181 | // qDebug( "Debug: Sending byte array" ); | 1170 | // odebug << "Debug: Sending byte array" << oendl; |
1182 | bytes_written = 0; | 1171 | bytes_written = 0; |
1183 | while( !buf.atEnd() ) | 1172 | while( !buf.atEnd() ) |
1184 | putch( buf.getch() ); | 1173 | putch( buf.getch() ); |
1185 | buf.close(); | 1174 | buf.close(); |
1186 | break; | 1175 | break; |
1187 | case RetrieveFile: | 1176 | case RetrieveFile: |
@@ -1194,35 +1183,35 @@ void ServerDTP::connected() | |||
1194 | 1183 | ||
1195 | if ( !file.open( IO_WriteOnly) ) { | 1184 | if ( !file.open( IO_WriteOnly) ) { |
1196 | emit failed(); | 1185 | emit failed(); |
1197 | mode = Idle; | 1186 | mode = Idle; |
1198 | return; | 1187 | return; |
1199 | } | 1188 | } |
1200 | // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); | 1189 | // odebug << "Debug: Retrieving file " << file.name() << "" << oendl; |
1201 | break; | 1190 | break; |
1202 | case RetrieveGzipFile: | 1191 | case RetrieveGzipFile: |
1203 | qDebug("=-> starting tar process to receive .tgz file"); | 1192 | odebug << "=-> starting tar process to receive .tgz file" << oendl; |
1204 | break; | 1193 | break; |
1205 | case RetrieveBuffer: | 1194 | case RetrieveBuffer: |
1206 | // retrieve buffer mode | 1195 | // retrieve buffer mode |
1207 | if ( !buf.open( IO_WriteOnly) ) { | 1196 | if ( !buf.open( IO_WriteOnly) ) { |
1208 | emit failed(); | 1197 | emit failed(); |
1209 | mode = Idle; | 1198 | mode = Idle; |
1210 | return; | 1199 | return; |
1211 | } | 1200 | } |
1212 | // qDebug( "Debug: Retrieving byte array" ); | 1201 | // odebug << "Debug: Retrieving byte array" << oendl; |
1213 | break; | 1202 | break; |
1214 | case Idle: | 1203 | case Idle: |
1215 | qDebug("connection established but mode set to Idle; BUG!"); | 1204 | odebug << "connection established but mode set to Idle; BUG!" << oendl; |
1216 | break; | 1205 | break; |
1217 | } | 1206 | } |
1218 | } | 1207 | } |
1219 | 1208 | ||
1220 | void ServerDTP::connectionClosed() | 1209 | void ServerDTP::connectionClosed() |
1221 | { | 1210 | { |
1222 | //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); | 1211 | //odebug << "Debug: Data connection closed " << bytes_written << " bytes written" << oendl; |
1223 | 1212 | ||
1224 | // send file mode | 1213 | // send file mode |
1225 | if ( SendFile == mode ) { | 1214 | if ( SendFile == mode ) { |
1226 | if ( bytes_written == file.size() ) | 1215 | if ( bytes_written == file.size() ) |
1227 | emit completed(); | 1216 | emit completed(); |
1228 | else | 1217 | else |
@@ -1238,22 +1227,22 @@ void ServerDTP::connectionClosed() | |||
1238 | } | 1227 | } |
1239 | 1228 | ||
1240 | // retrieve file mode | 1229 | // retrieve file mode |
1241 | else if ( RetrieveFile == mode ) { | 1230 | else if ( RetrieveFile == mode ) { |
1242 | file.close(); | 1231 | file.close(); |
1243 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { | 1232 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { |
1244 | qDebug( "STOR incomplete" ); | 1233 | odebug << "STOR incomplete" << oendl; |
1245 | file.remove(); | 1234 | file.remove(); |
1246 | emit failed(); | 1235 | emit failed(); |
1247 | } else { | 1236 | } else { |
1248 | emit completed(); | 1237 | emit completed(); |
1249 | } | 1238 | } |
1250 | } | 1239 | } |
1251 | 1240 | ||
1252 | else if ( RetrieveGzipFile == mode ) { | 1241 | else if ( RetrieveGzipFile == mode ) { |
1253 | qDebug("Done writing ungzip file; closing input"); | 1242 | odebug << "Done writing ungzip file; closing input" << oendl; |
1254 | retrieveTargzProc->flushStdin(); | 1243 | retrieveTargzProc->flushStdin(); |
1255 | retrieveTargzProc->closeStdin(); | 1244 | retrieveTargzProc->closeStdin(); |
1256 | } | 1245 | } |
1257 | 1246 | ||
1258 | // retrieve buffer mode | 1247 | // retrieve buffer mode |
1259 | else if ( RetrieveBuffer == mode ) { | 1248 | else if ( RetrieveBuffer == mode ) { |
@@ -1269,13 +1258,13 @@ void ServerDTP::bytesWritten( int bytes ) | |||
1269 | bytes_written += bytes; | 1258 | bytes_written += bytes; |
1270 | 1259 | ||
1271 | // send file mode | 1260 | // send file mode |
1272 | if ( SendFile == mode ) { | 1261 | if ( SendFile == mode ) { |
1273 | 1262 | ||
1274 | if ( bytes_written == file.size() ) { | 1263 | if ( bytes_written == file.size() ) { |
1275 | // qDebug( "Debug: Sending complete: %d bytes", file.size() ); | 1264 | // odebug << "Debug: Sending complete: " << file.size() << " bytes" << oendl; |
1276 | file.close(); | 1265 | file.close(); |
1277 | emit completed(); | 1266 | emit completed(); |
1278 | mode = Idle; | 1267 | mode = Idle; |
1279 | } | 1268 | } |
1280 | else if( !file.atEnd() ) { | 1269 | else if( !file.atEnd() ) { |
1281 | QCString s; | 1270 | QCString s; |
@@ -1286,13 +1275,13 @@ void ServerDTP::bytesWritten( int bytes ) | |||
1286 | } | 1275 | } |
1287 | 1276 | ||
1288 | // send buffer mode | 1277 | // send buffer mode |
1289 | if ( SendBuffer == mode ) { | 1278 | if ( SendBuffer == mode ) { |
1290 | 1279 | ||
1291 | if ( bytes_written == buf.size() ) { | 1280 | if ( bytes_written == buf.size() ) { |
1292 | // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); | 1281 | // odebug << "Debug: Sending complete: " << buf.size() << " bytes" << oendl; |
1293 | emit completed(); | 1282 | emit completed(); |
1294 | mode = Idle; | 1283 | mode = Idle; |
1295 | } | 1284 | } |
1296 | } | 1285 | } |
1297 | } | 1286 | } |
1298 | 1287 | ||
@@ -1310,13 +1299,13 @@ void ServerDTP::readyRead() | |||
1310 | retrieveTargzProc->start(); | 1299 | retrieveTargzProc->start(); |
1311 | 1300 | ||
1312 | QByteArray s; | 1301 | QByteArray s; |
1313 | s.resize( bytesAvailable() ); | 1302 | s.resize( bytesAvailable() ); |
1314 | readBlock( s.data(), bytesAvailable() ); | 1303 | readBlock( s.data(), bytesAvailable() ); |
1315 | retrieveTargzProc->writeToStdin( s ); | 1304 | retrieveTargzProc->writeToStdin( s ); |
1316 | qDebug("wrote %d bytes to ungzip ", s.size() ); | 1305 | odebug << "wrote " << s.size() << " bytes to ungzip " << oendl; |
1317 | } | 1306 | } |
1318 | // retrieve buffer mode | 1307 | // retrieve buffer mode |
1319 | else if ( RetrieveBuffer == mode ) { | 1308 | else if ( RetrieveBuffer == mode ) { |
1320 | QCString s; | 1309 | QCString s; |
1321 | s.resize( bytesAvailable() ); | 1310 | s.resize( bytesAvailable() ); |
1322 | readBlock( s.data(), bytesAvailable() ); | 1311 | readBlock( s.data(), bytesAvailable() ); |
@@ -1325,18 +1314,18 @@ void ServerDTP::readyRead() | |||
1325 | } | 1314 | } |
1326 | 1315 | ||
1327 | void ServerDTP::writeTargzBlock() | 1316 | void ServerDTP::writeTargzBlock() |
1328 | { | 1317 | { |
1329 | QByteArray block = createTargzProc->readStdout(); | 1318 | QByteArray block = createTargzProc->readStdout(); |
1330 | writeBlock( block.data(), block.size() ); | 1319 | writeBlock( block.data(), block.size() ); |
1331 | qDebug("writeTargzBlock %d", block.size()); | 1320 | odebug << "writeTargzBlock " << block.size() << "" << oendl; |
1332 | } | 1321 | } |
1333 | 1322 | ||
1334 | void ServerDTP::targzDone() | 1323 | void ServerDTP::targzDone() |
1335 | { | 1324 | { |
1336 | qDebug("tar and gzip done"); | 1325 | odebug << "tar and gzip done" << oendl; |
1337 | emit completed(); | 1326 | emit completed(); |
1338 | mode = Idle; | 1327 | mode = Idle; |
1339 | disconnect( createTargzProc, SIGNAL( readyReadStdout() ), | 1328 | disconnect( createTargzProc, SIGNAL( readyReadStdout() ), |
1340 | this, SLOT( writeTargzBlock() ) ); | 1329 | this, SLOT( writeTargzBlock() ) ); |
1341 | } | 1330 | } |
1342 | 1331 | ||
@@ -1367,13 +1356,13 @@ void ServerDTP::sendGzipFile( const QString &fn, | |||
1367 | mode = SendGzipFile; | 1356 | mode = SendGzipFile; |
1368 | file.setName( fn ); | 1357 | file.setName( fn ); |
1369 | 1358 | ||
1370 | QStringList args = "targzip"; | 1359 | QStringList args = "targzip"; |
1371 | //args += "-cv"; | 1360 | //args += "-cv"; |
1372 | args += archiveTargets; | 1361 | args += archiveTargets; |
1373 | qDebug("sendGzipFile %s", args.join(" ").latin1() ); | 1362 | odebug << "sendGzipFile " << args.join(" ") << "" << oendl; |
1374 | createTargzProc->setArguments( args ); | 1363 | createTargzProc->setArguments( args ); |
1375 | connect( createTargzProc, | 1364 | connect( createTargzProc, |
1376 | SIGNAL( readyReadStdout() ), SLOT( writeTargzBlock() ) ); | 1365 | SIGNAL( readyReadStdout() ), SLOT( writeTargzBlock() ) ); |
1377 | } | 1366 | } |
1378 | 1367 | ||
1379 | void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port, int fileSize ) | 1368 | void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port, int fileSize ) |
@@ -1390,13 +1379,13 @@ void ServerDTP::retrieveFile( const QString fn, int fileSize ) | |||
1390 | file.setName( fn ); | 1379 | file.setName( fn ); |
1391 | mode = RetrieveFile; | 1380 | mode = RetrieveFile; |
1392 | } | 1381 | } |
1393 | 1382 | ||
1394 | void ServerDTP::retrieveGzipFile( const QString &fn ) | 1383 | void ServerDTP::retrieveGzipFile( const QString &fn ) |
1395 | { | 1384 | { |
1396 | qDebug("retrieveGzipFile %s", fn.latin1()); | 1385 | odebug << "retrieveGzipFile " << fn << "" << oendl; |
1397 | file.setName( fn ); | 1386 | file.setName( fn ); |
1398 | mode = RetrieveGzipFile; | 1387 | mode = RetrieveGzipFile; |
1399 | 1388 | ||
1400 | retrieveTargzProc->setArguments( "targunzip" ); | 1389 | retrieveTargzProc->setArguments( "targunzip" ); |
1401 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 1390 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
1402 | SLOT( extractTarDone() ) ); | 1391 | SLOT( extractTarDone() ) ); |