-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 01309d5..b3e266a 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1096,79 +1096,81 @@ void KCommandSocket::sendStop() | |||
1096 | } | 1096 | } |
1097 | mSocket->connectToHost( mHost, mPort ); | 1097 | mSocket->connectToHost( mHost, mPort ); |
1098 | QTextStream os2( mSocket ); | 1098 | QTextStream os2( mSocket ); |
1099 | os2.setEncoding( QTextStream::Latin1 ); | 1099 | os2.setEncoding( QTextStream::Latin1 ); |
1100 | os2 << "STOP\r\n"; | 1100 | os2 << "STOP\r\n"; |
1101 | mSocket->close(); | 1101 | mSocket->close(); |
1102 | if ( mSocket->state() == QSocket::Idle ) | 1102 | if ( mSocket->state() == QSocket::Idle ) |
1103 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1103 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void KCommandSocket::startReadFileFromSocket() | 1106 | void KCommandSocket::startReadFileFromSocket() |
1107 | { | 1107 | { |
1108 | if ( ! mFirst ) | 1108 | if ( ! mFirst ) |
1109 | return; | 1109 | return; |
1110 | mFirst = false; | 1110 | mFirst = false; |
1111 | mTimerSocket->stop(); | 1111 | mTimerSocket->stop(); |
1112 | mFileString = ""; | 1112 | mFileString = ""; |
1113 | mTime.start(); | 1113 | mTime.start(); |
1114 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1114 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1115 | 1115 | ||
1116 | } | 1116 | } |
1117 | void KCommandSocket::readFileFromSocket() | 1117 | void KCommandSocket::readFileFromSocket() |
1118 | { | 1118 | { |
1119 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1119 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1120 | while ( mSocket->canReadLine () ) { | 1120 | while ( mSocket->canReadLine () ) { |
1121 | mTime.restart(); | 1121 | mTime.restart(); |
1122 | QString line = mSocket->readLine (); | 1122 | QString line = mSocket->readLine (); |
1123 | mFileString += line; | 1123 | mFileString += line; |
1124 | //qDebug("readline: %s ", line.latin1()); | 1124 | //qDebug("readline: %s ", line.latin1()); |
1125 | } | 1125 | } |
1126 | if ( mTime.elapsed () < 3000 ) { | 1126 | if ( mTime.elapsed () < 3000 ) { |
1127 | // wait for more | 1127 | // wait for more |
1128 | //qDebug("waitformore "); | 1128 | //qDebug("waitformore "); |
1129 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1129 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1130 | return; | 1130 | return; |
1131 | } | 1131 | } |
1132 | QString fileName = mFileName; | 1132 | QString fileName = mFileName; |
1133 | QFile file ( fileName ); | 1133 | QFile file ( fileName ); |
1134 | if (!file.open( IO_WriteOnly ) ) { | 1134 | if (!file.open( IO_WriteOnly ) ) { |
1135 | mFileString = ""; | 1135 | mFileString = ""; |
1136 | mRetVal = errorR; | 1136 | mRetVal = errorR; |
1137 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 1137 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
1138 | deleteSocket(); | 1138 | deleteSocket(); |
1139 | return ; | 1139 | return ; |
1140 | 1140 | ||
1141 | } | 1141 | } |
1142 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1142 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1143 | QTextStream ts ( &file ); | 1143 | QTextStream ts ( &file ); |
1144 | ts.setEncoding( QTextStream::Latin1 ); | 1144 | ts.setEncoding( QTextStream::Latin1 ); |
1145 | ts << mFileString; | 1145 | ts << mFileString; |
1146 | file.close(); | 1146 | file.close(); |
1147 | mFileString = ""; | 1147 | mFileString = ""; |
1148 | mRetVal = successR; | 1148 | mRetVal = successR; |
1149 | mSocket->close(); | 1149 | mSocket->close(); |
1150 | // if state is not idle, deleteSocket(); is called via | 1150 | // if state is not idle, deleteSocket(); is called via |
1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1151 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1152 | if ( mSocket->state() == QSocket::Idle ) | 1152 | if ( mSocket->state() == QSocket::Idle ) |
1153 | deleteSocket(); | 1153 | deleteSocket(); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void KCommandSocket::deleteSocket() | 1156 | void KCommandSocket::deleteSocket() |
1157 | { | 1157 | { |
1158 | if ( mTimerSocket->isActive () ) { | 1158 | if ( mTimerSocket->isActive () ) { |
1159 | mTimerSocket->stop(); | 1159 | mTimerSocket->stop(); |
1160 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
1161 | mRetVal = errorTO; | 1160 | mRetVal = errorTO; |
1162 | if ( mSocket ) { | 1161 | if ( mSocket ) { |
1163 | mSocket->close(); | 1162 | mSocket->close(); |
1164 | if ( mSocket->state() == QSocket::Idle ) | 1163 | if ( mSocket->state() == QSocket::Idle ) |
1165 | deleteSocket(); | 1164 | deleteSocket(); |
1166 | return; | 1165 | return; |
1167 | } | 1166 | } |
1168 | } | 1167 | } |
1169 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1168 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1170 | if ( mSocket) | 1169 | if ( mSocket) |
1171 | delete mSocket; | 1170 | delete mSocket; |
1172 | mSocket = 0; | 1171 | mSocket = 0; |
1172 | if ( mRetVal == errorTO) | ||
1173 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | ||
1174 | |||
1173 | emit commandFinished( this, mRetVal ); | 1175 | emit commandFinished( this, mRetVal ); |
1174 | } | 1176 | } |