author | zautrix <zautrix> | 2004-10-11 09:37:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-11 09:37:01 (UTC) |
commit | ff475669e0cb65677168d4a29928a6c1d984aa10 (patch) (unidiff) | |
tree | 02dd4b6ff9f9c1e1eb177d149d127ac90b693031 /libkdepim/ksyncmanager.cpp | |
parent | 5ec2ee22f69f6b3d78b505a4a44b6b0deff29645 (diff) | |
download | kdepimpi-ff475669e0cb65677168d4a29928a6c1d984aa10.zip kdepimpi-ff475669e0cb65677168d4a29928a6c1d984aa10.tar.gz kdepimpi-ff475669e0cb65677168d4a29928a6c1d984aa10.tar.bz2 |
fix file transmission with sockets
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index df53235..6baa2ee 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -978,33 +978,33 @@ void KServerSocket::send_file() | |||
978 | delete mSyncActionDialog; | 978 | delete mSyncActionDialog; |
979 | mSyncActionDialog = 0; | 979 | mSyncActionDialog = 0; |
980 | qDebug("KSS::error open file "); | 980 | qDebug("KSS::error open file "); |
981 | mSocket->close(); | 981 | mSocket->close(); |
982 | if ( mSocket->state() == QSocket::Idle ) | 982 | if ( mSocket->state() == QSocket::Idle ) |
983 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 983 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
984 | return ; | 984 | return ; |
985 | 985 | ||
986 | } | 986 | } |
987 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 987 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
988 | QTextStream ts( &file ); | 988 | QTextStream ts( &file ); |
989 | ts.setEncoding( QTextStream::Latin1 ); | 989 | ts.setEncoding( QTextStream::Latin1 ); |
990 | 990 | ||
991 | QTextStream os( mSocket ); | 991 | QTextStream os( mSocket ); |
992 | os.setEncoding( QTextStream::Latin1 ); | 992 | os.setEncoding( QTextStream::Latin1 ); |
993 | while ( ! ts.atEnd() ) { | 993 | while ( ! ts.atEnd() ) { |
994 | os << ts.readLine() << "\n"; | 994 | os << ts.readLine() << "\r\n"; |
995 | } | 995 | } |
996 | //os << ts.read(); | 996 | //os << ts.read(); |
997 | file.close(); | 997 | file.close(); |
998 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 998 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
999 | mSocket->close(); | 999 | mSocket->close(); |
1000 | if ( mSocket->state() == QSocket::Idle ) | 1000 | if ( mSocket->state() == QSocket::Idle ) |
1001 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1001 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1002 | } | 1002 | } |
1003 | void KServerSocket::get_file() | 1003 | void KServerSocket::get_file() |
1004 | { | 1004 | { |
1005 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1005 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1006 | 1006 | ||
1007 | piTime.start(); | 1007 | piTime.start(); |
1008 | piFileString = ""; | 1008 | piFileString = ""; |
1009 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1009 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1010 | } | 1010 | } |
@@ -1098,33 +1098,33 @@ void KCommandSocket::writeFile( QString fileName ) | |||
1098 | void KCommandSocket::writeFileToSocket() | 1098 | void KCommandSocket::writeFileToSocket() |
1099 | { | 1099 | { |
1100 | QFile file2( mFileName ); | 1100 | QFile file2( mFileName ); |
1101 | if (!file2.open( IO_ReadOnly ) ) { | 1101 | if (!file2.open( IO_ReadOnly ) ) { |
1102 | mRetVal= errorW; | 1102 | mRetVal= errorW; |
1103 | mSocket->close(); | 1103 | mSocket->close(); |
1104 | if ( mSocket->state() == QSocket::Idle ) | 1104 | if ( mSocket->state() == QSocket::Idle ) |
1105 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1105 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1106 | return ; | 1106 | return ; |
1107 | } | 1107 | } |
1108 | QTextStream ts2( &file2 ); | 1108 | QTextStream ts2( &file2 ); |
1109 | ts2.setEncoding( QTextStream::Latin1 ); | 1109 | ts2.setEncoding( QTextStream::Latin1 ); |
1110 | QTextStream os2( mSocket ); | 1110 | QTextStream os2( mSocket ); |
1111 | os2.setEncoding( QTextStream::Latin1 ); | 1111 | os2.setEncoding( QTextStream::Latin1 ); |
1112 | os2 << "PUT " << mPassWord << "\r\n";; | 1112 | os2 << "PUT " << mPassWord << "\r\n";; |
1113 | while ( ! ts2.atEnd() ) { | 1113 | while ( ! ts2.atEnd() ) { |
1114 | os2 << ts2.readLine() << "\n"; | 1114 | os2 << ts2.readLine() << "\r\n"; |
1115 | } | 1115 | } |
1116 | mRetVal= successW; | 1116 | mRetVal= successW; |
1117 | file2.close(); | 1117 | file2.close(); |
1118 | mSocket->close(); | 1118 | mSocket->close(); |
1119 | if ( mSocket->state() == QSocket::Idle ) | 1119 | if ( mSocket->state() == QSocket::Idle ) |
1120 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1120 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1121 | } | 1121 | } |
1122 | void KCommandSocket::sendStop() | 1122 | void KCommandSocket::sendStop() |
1123 | { | 1123 | { |
1124 | if ( !mSocket ) { | 1124 | if ( !mSocket ) { |
1125 | mSocket = new QSocket( this ); | 1125 | mSocket = new QSocket( this ); |
1126 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1126 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1127 | } | 1127 | } |
1128 | mSocket->connectToHost( mHost, mPort ); | 1128 | mSocket->connectToHost( mHost, mPort ); |
1129 | QTextStream os2( mSocket ); | 1129 | QTextStream os2( mSocket ); |
1130 | os2.setEncoding( QTextStream::Latin1 ); | 1130 | os2.setEncoding( QTextStream::Latin1 ); |