author | zautrix <zautrix> | 2005-11-25 22:16:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-25 22:16:50 (UTC) |
commit | b71ee5442df23bb9900d3db6e6244773ee34ef13 (patch) (unidiff) | |
tree | 221ac1af78b4fcbf741a48687f28570216f89049 /libkdepim | |
parent | 81d012860ea3d5d17d0e9cf16ec992baa83efbbf (diff) | |
download | kdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.zip kdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.tar.gz kdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.tar.bz2 |
sync
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 48 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 2 |
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() | |||
1161 | if ( !mCurrentResourceRemote.isEmpty() ) { | 1161 | if ( !mCurrentResourceRemote.isEmpty() ) { |
1162 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1162 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1163 | |||
1163 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1164 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1164 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1165 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1165 | commandSocket->readFile( syncFileName() ); | 1166 | commandSocket->readFile( syncFileName() ); |
1167 | mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); | ||
1166 | while ( !mPisyncFinished ) { | 1168 | while ( !mPisyncFinished ) { |
1167 | //qDebug("waiting "); | 1169 | //qDebug("waiting "); |
1168 | qApp->processEvents(); | 1170 | qApp->processEvents(); |
1169 | } | 1171 | } |
1172 | if ( startLocal+1 < mSpecificResources.count()/2 ) { | ||
1173 | mParent->topLevelWidget()->setCaption( i18n("Waiting 2 secs before syncing next resource...") ); | ||
1174 | QTime timer; | ||
1175 | timer.start(); | ||
1176 | while ( timer.elapsed () < 2000 ) { | ||
1177 | qApp->processEvents(); | ||
1178 | } | ||
1179 | } | ||
1170 | } | 1180 | } |
1171 | ++startRemote; | 1181 | ++startRemote; |
1172 | ++startLocal; | 1182 | ++startLocal; |
1183 | |||
1173 | } | 1184 | } |
1174 | mPisyncFinished = true; | 1185 | mPisyncFinished = true; |
@@ -1255,4 +1266,5 @@ void KSyncManager::readFileFromSocket() | |||
1255 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1266 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1256 | { | 1267 | { |
1268 | mPendingConnect = 0; | ||
1257 | mPassWord = pw; | 1269 | mPassWord = pw; |
1258 | mSocket = 0; | 1270 | mSocket = 0; |
@@ -1261,13 +1273,33 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject | |||
1261 | mErrorMessage = 0; | 1273 | mErrorMessage = 0; |
1262 | } | 1274 | } |
1263 | 1275 | void KServerSocket::waitForSocketFinish() | |
1276 | { | ||
1277 | if ( mSocket ) { | ||
1278 | qDebug("KSS:: waiting for finish operation"); | ||
1279 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | ||
1280 | return; | ||
1281 | } | ||
1282 | mSocket = new QSocket( this ); | ||
1283 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
1284 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
1285 | mSocket->setSocket( mPendingConnect ); | ||
1286 | mPendingConnect = 0; | ||
1287 | } | ||
1264 | void KServerSocket::newConnection ( int socket ) | 1288 | void KServerSocket::newConnection ( int socket ) |
1265 | { | 1289 | { |
1266 | // qDebug("KServerSocket:New connection %d ", socket); | 1290 | // qDebug("KServerSocket:New connection %d ", socket); |
1291 | if ( mPendingConnect ) { | ||
1292 | qDebug("KSS::Error : new Connection"); | ||
1293 | return; | ||
1294 | } | ||
1267 | if ( mSocket ) { | 1295 | if ( mSocket ) { |
1296 | mPendingConnect = socket; | ||
1297 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | ||
1298 | return; | ||
1268 | qDebug("KSS::newConnection Socket deleted! "); | 1299 | qDebug("KSS::newConnection Socket deleted! "); |
1269 | delete mSocket; | 1300 | delete mSocket; |
1270 | mSocket = 0; | 1301 | mSocket = 0; |
1271 | } | 1302 | } |
1303 | mPendingConnect = 0; | ||
1272 | mSocket = new QSocket( this ); | 1304 | mSocket = new QSocket( this ); |
1273 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1305 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
@@ -1544,4 +1576,5 @@ void KCommandSocket::sendFileRequest() | |||
1544 | mConnectCount = 300;mConnectMax = 300; | 1576 | mConnectCount = 300;mConnectMax = 300; |
1545 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); | 1577 | mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); |
1578 | mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); | ||
1546 | mTimerSocket->start( 100, true ); | 1579 | mTimerSocket->start( 100, true ); |
1547 | QTextStream os( mSocket ); | 1580 | QTextStream os( mSocket ); |
@@ -1555,5 +1588,6 @@ void KCommandSocket::readFile( QString fn ) | |||
1555 | { | 1588 | { |
1556 | if ( !mSocket ) { | 1589 | if ( !mSocket ) { |
1557 | mSocket = new QSocket( this ); | 1590 | mSocket = new QSocket( this ); |
1591 | qDebug("KCS: read file - new socket"); | ||
1558 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1592 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1559 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1593 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
@@ -1568,5 +1602,5 @@ void KCommandSocket::readFile( QString fn ) | |||
1568 | mTimerSocket->start( 1000, true ); | 1602 | mTimerSocket->start( 1000, true ); |
1569 | mSocket->connectToHost( mHost, mPort ); | 1603 | mSocket->connectToHost( mHost, mPort ); |
1570 | qDebug("KSS: Waiting for connection"); | 1604 | qDebug("KCS: Waiting for connection"); |
1571 | } | 1605 | } |
1572 | void KCommandSocket::updateConnectDialog() | 1606 | void KCommandSocket::updateConnectDialog() |
@@ -1574,10 +1608,10 @@ void KCommandSocket::updateConnectDialog() | |||
1574 | 1608 | ||
1575 | if ( mConnectCount == mConnectMax ) { | 1609 | if ( mConnectCount == mConnectMax ) { |
1576 | //qDebug("MAXX %d", mConnectMax); | 1610 | qDebug("MAXX %d", mConnectMax); |
1577 | mConnectProgress.setTotalSteps ( 30 ); | 1611 | mConnectProgress.setTotalSteps ( 30 ); |
1578 | mConnectProgress.show(); | 1612 | mConnectProgress.show(); |
1579 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); | 1613 | mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); |
1580 | } | 1614 | } |
1581 | //qDebug("updateConnectDialog() %d", mConnectCount); | 1615 | qDebug("updateConnectDialog() %d", mConnectCount); |
1582 | mConnectProgress.raise(); | 1616 | mConnectProgress.raise(); |
1583 | mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); | 1617 | 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 | |||
59 | void endConnect(); | 59 | void endConnect(); |
60 | private slots: | 60 | private slots: |
61 | void waitForSocketFinish(); | ||
61 | void discardClient(); | 62 | void discardClient(); |
62 | void deleteSocket(); | 63 | void deleteSocket(); |
@@ -65,4 +66,5 @@ class KServerSocket : public QServerSocket | |||
65 | void readBackFileFromSocket(); | 66 | void readBackFileFromSocket(); |
66 | private : | 67 | private : |
68 | int mPendingConnect; | ||
67 | QString mResource; | 69 | QString mResource; |
68 | int mErrorMessage; | 70 | int mErrorMessage; |