summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-11-25 22:16:50 (UTC)
committer zautrix <zautrix>2005-11-25 22:16:50 (UTC)
commitb71ee5442df23bb9900d3db6e6244773ee34ef13 (patch) (side-by-side diff)
tree221ac1af78b4fcbf741a48687f28570216f89049 /libkdepim
parent81d012860ea3d5d17d0e9cf16ec992baa83efbbf (diff)
downloadkdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.zip
kdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.tar.gz
kdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.tar.bz2
sync
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp48
-rw-r--r--libkdepim/ksyncmanager.h2
2 files changed, 43 insertions, 7 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index e1b15d2..8bf0d27 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1161,14 +1161,25 @@ void KSyncManager::syncPi()
if ( !mCurrentResourceRemote.isEmpty() ) {
qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
+
KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
- commandSocket->readFile( syncFileName() );
+ commandSocket->readFile( syncFileName() );
+ mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) );
while ( !mPisyncFinished ) {
//qDebug("waiting ");
qApp->processEvents();
}
+ if ( startLocal+1 < mSpecificResources.count()/2 ) {
+ mParent->topLevelWidget()->setCaption( i18n("Waiting 2 secs before syncing next resource...") );
+ QTime timer;
+ timer.start();
+ while ( timer.elapsed () < 2000 ) {
+ qApp->processEvents();
+ }
+ }
}
++startRemote;
- ++startLocal;
+ ++startLocal;
+
}
mPisyncFinished = true;
@@ -1255,4 +1266,5 @@ void KSyncManager::readFileFromSocket()
KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
{
+ mPendingConnect = 0;
mPassWord = pw;
mSocket = 0;
@@ -1261,13 +1273,33 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject
mErrorMessage = 0;
}
-
+void KServerSocket::waitForSocketFinish()
+{
+ if ( mSocket ) {
+ qDebug("KSS:: waiting for finish operation");
+ QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
+ return;
+ }
+ mSocket = new QSocket( this );
+ connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
+ connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
+ mSocket->setSocket( mPendingConnect );
+ mPendingConnect = 0;
+}
void KServerSocket::newConnection ( int socket )
{
// qDebug("KServerSocket:New connection %d ", socket);
+ if ( mPendingConnect ) {
+ qDebug("KSS::Error : new Connection");
+ return;
+ }
if ( mSocket ) {
+ mPendingConnect = socket;
+ QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
+ return;
qDebug("KSS::newConnection Socket deleted! ");
delete mSocket;
mSocket = 0;
}
+ mPendingConnect = 0;
mSocket = new QSocket( this );
connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
@@ -1544,4 +1576,5 @@ void KCommandSocket::sendFileRequest()
mConnectCount = 300;mConnectMax = 300;
mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
+ mConnectProgress.setLabelText( i18n("Waiting for remote file...") );
mTimerSocket->start( 100, true );
QTextStream os( mSocket );
@@ -1555,5 +1588,6 @@ void KCommandSocket::readFile( QString fn )
{
if ( !mSocket ) {
- mSocket = new QSocket( this );
+ mSocket = new QSocket( this );
+ qDebug("KCS: read file - new socket");
connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
@@ -1568,5 +1602,5 @@ void KCommandSocket::readFile( QString fn )
mTimerSocket->start( 1000, true );
mSocket->connectToHost( mHost, mPort );
- qDebug("KSS: Waiting for connection");
+ qDebug("KCS: Waiting for connection");
}
void KCommandSocket::updateConnectDialog()
@@ -1574,10 +1608,10 @@ void KCommandSocket::updateConnectDialog()
if ( mConnectCount == mConnectMax ) {
- //qDebug("MAXX %d", mConnectMax);
+ qDebug("MAXX %d", mConnectMax);
mConnectProgress.setTotalSteps ( 30 );
mConnectProgress.show();
mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
}
- //qDebug("updateConnectDialog() %d", mConnectCount);
+ qDebug("updateConnectDialog() %d", mConnectCount);
mConnectProgress.raise();
mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 53c611d..604adb8 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -59,4 +59,5 @@ class KServerSocket : public QServerSocket
void endConnect();
private slots:
+ void waitForSocketFinish();
void discardClient();
void deleteSocket();
@@ -65,4 +66,5 @@ class KServerSocket : public QServerSocket
void readBackFileFromSocket();
private :
+ int mPendingConnect;
QString mResource;
int mErrorMessage;