-rw-r--r-- | libkdepim/ksyncmanager.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index f2ee0ab..2a75bfb 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -1505,133 +1505,139 @@ void KCommandSocket::readFile( QString fn ) mFileName = fn; mFirst = true; if ( tlw ) tlw->setCaption( i18n("Trying to connect to remote...") ); mConnectCount = 30;mConnectMax = 30; mTimerSocket->start( 1000, true ); mSocket->connectToHost( mHost, mPort ); qDebug("KSS: Waiting for connection"); } void KCommandSocket::updateConnectDialog() { if ( mConnectCount == mConnectMax ) { //qDebug("MAXX %d", mConnectMax); mConnectProgress.setTotalSteps ( 30 ); mConnectProgress.show(); mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); } //qDebug("updateConnectDialog() %d", mConnectCount); mConnectProgress.raise(); mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); --mConnectCount; if ( mConnectCount > 0 ) mTimerSocket->start( 1000, true ); else deleteSocket(); } void KCommandSocket::writeFile( QString fileName ) { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); } mFileName = fileName ; mConnectCount = 30;mConnectMax = 30; mTimerSocket->start( 1000, true ); mSocket->connectToHost( mHost, mPort ); } void KCommandSocket::writeFileToSocket() { mTimerSocket->stop(); QFile file2( mFileName ); if (!file2.open( IO_ReadOnly ) ) { mConnectProgress.hide(); mConnectCount = -1; mRetVal= errorW; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); return ; } mConnectProgress.setTotalSteps ( file2.size() ); mConnectProgress.show(); int count = 0; mConnectProgress.setLabelText( i18n("Sending back synced file...") ); mConnectProgress.setProgress( count ); mConnectProgress.blockSignals( true ); QTextStream ts2( &file2 ); ts2.setEncoding( QTextStream::Latin1 ); QTextStream os2( mSocket ); os2.setEncoding( QTextStream::Latin1 ); os2 << "PUT " << mPassWord << "\r\n\r\n";; + int byteCount = 0; + int byteMax = file2.size()/53; while ( ! ts2.atEnd() ) { qApp->processEvents(); - mConnectProgress.setProgress( count ); + if ( byteCount > byteMax ) { + byteCount = 0; + mConnectProgress.setProgress( count ); + } QString temp = ts2.readLine(); count += temp.length(); + byteCount += temp.length(); os2 << temp << "\r\n"; } file2.close(); mConnectProgress.hide(); mConnectCount = -1; os2 << "\r\n"; mRetVal= successW; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); mConnectProgress.blockSignals( false ); } void KCommandSocket::sendStop() { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } mSocket->connectToHost( mHost, mPort ); QTextStream os2( mSocket ); os2.setEncoding( QTextStream::Latin1 ); os2 << "STOP\r\n\r\n"; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KCommandSocket::startReadFileFromSocket() { if ( ! mFirst ) return; mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); mFirst = false; mFileString = ""; mTime.start(); mFirstLine = true; QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); } void KCommandSocket::readFileFromSocket() { //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); while ( mSocket->canReadLine () ) { mTime.restart(); QString line = mSocket->readLine (); if ( mFirstLine ) { mFirstLine = false; if ( line.left( 6 ) == "ERROR_" ) { mTimerSocket->stop(); mConnectCount = -1; if ( line.left( 8 ) == "ERROR_PW" ) { mRetVal = errorPW; deleteSocket(); return ; } if ( line.left( 8 ) == "ERROR_CA" ) { mRetVal = errorCA; deleteSocket(); return ; } if ( line.left( 8 ) == "ERROR_FI" ) { mRetVal = errorFI; deleteSocket(); return ; |