summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-04 10:38:45 (UTC)
committer zautrix <zautrix>2004-10-04 10:38:45 (UTC)
commit01b5806c61deb8368f8f454fdec1c4767c73a840 (patch) (side-by-side diff)
treef2546296a50444d02d2a74f6bf55fd57b0504ebc
parent743f44c45534a6e1df17ddc7b5f3c62b73921455 (diff)
downloadkdepimpi-01b5806c61deb8368f8f454fdec1c4767c73a840.zip
kdepimpi-01b5806c61deb8368f8f454fdec1c4767c73a840.tar.gz
kdepimpi-01b5806c61deb8368f8f454fdec1c4767c73a840.tar.bz2
sync fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 8e2f956..10cb2a2 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -2103,43 +2103,44 @@ void MainWindow::performQuickQuick()
setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
return;
}
if ( !mCommandSocket ) {
mCommandSocket = new QSocket( this );
// delete mCommandSocket;
//mCommandSocket = new QSocket( this );
connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
connect( mCommandSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocket()) );
}
QString host = KOPrefs::instance()->mActiveSyncIP;
mCommandSocket->connectToHost( host, port );
QTextStream os( mCommandSocket );
os.setEncoding( QTextStream::UnicodeUTF8 );
os << "GET " << mPassWordPiSync << "\r\n";
setCaption( i18n("Sending request for remote file ...") );
- mTimerCommandSocket->start( 15000 );
+ mTimerCommandSocket->start( 10000 );
}
void MainWindow::deleteCommandSocket()
{
if ( !mCommandSocket)
return;
if ( mTimerCommandSocket->isActive () ) {
KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out "));
mTimerCommandSocket->stop();
}
+ //KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocket "));
qDebug("MainWindow::deletemCommandSocket() ");
delete mCommandSocket;
mCommandSocket = 0;
}
void MainWindow::deleteCommandSocketFinish()
{
if ( ! mCommandSocketFinish)
return;
//KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() "));
qDebug("MainWindow::deletemCommandSocketFinish() ");
delete mCommandSocketFinish;
mCommandSocketFinish = 0;
}
void MainWindow::readFileFromSocket()
{
mTimerCommandSocket->stop();
@@ -2158,33 +2159,33 @@ void MainWindow::readFileFromSocket()
return ;
}
//QTextStream os2( mCommandSocket );
//os2.setEncoding( QTextStream::UnicodeUTF8 );
QTextStream ts( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
bool first = true;
while ( mCommandSocket->canReadLine () || first) {
first = false;
while ( mCommandSocket->canReadLine () ) {
ts << mCommandSocket->readLine ();
}
QTime ti;
ti.start();
- while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) {
+ while ( ti.elapsed () < 3000 && !mCommandSocket->canReadLine () ) {
qApp->processEvents();
qDebug("waiting2 %d ",ti.elapsed () );
if ( !mCommandSocket->canReadLine () )
mCommandSocket->waitForMore ( 100 );
}
//mCommandSocket->waitForMore ( 5000 );
}
file.close();
mCommandSocket->close();
if ( mCommandSocket->state() == QSocket::Idle )
deleteCommandSocket();
// pending: deleting after signal SIGNAL(delayedCloseFinished())
//delete mCommandSocket;
setCaption( i18n("Remote file saved to temp file.") );
//mCommandSocket = 0;
mCurrentSyncProfile = 2 ; // last file
@@ -2212,53 +2213,54 @@ void MainWindow::readFileFromSocket()
if ( !mCommandSocketFinish ) {
mCommandSocketFinish = new QSocket( this );
connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) );
}
mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
// pending connect signals connected () and error to new slots
QString host = KOPrefs::instance()->mActiveSyncIP;
QFile file2( fileName );
if (!file2.open( IO_ReadOnly ) ) {
setCaption( i18n("Error: Cannot open temp file for read.") );
qDebug("error open cal file ");
return ;
}
- setCaption( i18n("Sending back synced file...") );
QTextStream ts2( &file2 );
ts2.setCodec( QTextCodec::codecForName("utf8") );
QTextStream os2( mCommandSocketFinish );
os2.setCodec( QTextCodec::codecForName("utf8") );
//os.setEncoding( QTextStream::UnicodeUTF8 );
if ( KOPrefs::instance()->mWriteBackFile ) {
+ setCaption( i18n("Sending back synced file...") );
os2 << "PUT " << mPassWordPiSync << "\r\n";;
while ( ! ts2.atEnd() ) {
os2 << ts2.readLine() << "\n";
}
} else {
os2 << "STOP\r\n";
}
mCommandSocketFinish->close();
if ( mCommandSocketFinish->state() == QSocket::Idle )
- deleteCommandSocketFinish();
+ QTimer::singleShot( 10, this , SLOT ( deleteCommandSocketFinish()));
file.close();
qDebug("Syncing succesful! ");
setCaption( i18n("Pi-Sync succesful!") );
+ // KMessageBox::information( 0, i18n(" Pi-Sync succesful! "));
}
void MainWindow::syncLocalFile()
{
QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
if ( fn == "" )
return;
//mView->setSyncDevice("local-file" );
if ( syncWithFile( fn, false ) ) {
// Event* e = mView->getLastSyncEvent();
// e->setReadOnly( false );
// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);