summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
-rw-r--r--libkdepim/ksyncmanager.cpp48
-rw-r--r--libkdepim/ksyncmanager.h2
3 files changed, 50 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e45240a..6128137 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1498,5 +1498,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
break;
case SYNC_PREF_ASK:
- qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
+ //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
if ( lastSync > remoteMod && lastSync > localMod)
return 0;
@@ -1505,5 +1505,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
if ( lastSync > localMod )
return 2;
- qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
+ //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
localIsNew = localMod >= remoteMod;
if ( localIsNew )
@@ -1542,6 +1542,8 @@ Event* CalendarView::getLastSyncEvent()
Event* lse;
//qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
+ mCalendar->setSyncEventsEnabled();
lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
if (!lse) {
+ qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() );
lse = new Event();
lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
@@ -1556,5 +1558,6 @@ Event* CalendarView::getLastSyncEvent()
lse->setCalID( 1 );
mCalendar->addEvent( lse );
- }
+ } else
+ qDebug("KO: Last Syncevent on local found");
return lse;
@@ -1634,5 +1637,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
if ( eventR ) {
- qDebug("last-syncEvent on remote found ");
+ qDebug("KO: Last-syncEvent on remote found ");
eventRSync = (Event*) eventR->clone();
remote->deleteEvent(eventR );
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;