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
@@ -1497,14 +1497,14 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
return 2;
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;
if ( lastSync > remoteMod )
return 1;
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 )
getEventViewerDialog()->setColorMode( 1 );
@@ -1541,8 +1541,10 @@ 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 );
QString sum = "";
@@ -1555,7 +1557,8 @@ Event* CalendarView::getLastSyncEvent()
lse->setReadOnly( true );
lse->setCalID( 1 );
mCalendar->addEvent( lse );
- }
+ } else
+ qDebug("KO: Last Syncevent on local found");
return lse;
@@ -1633,7 +1636,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
eventLSync = getLastSyncEvent();
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
@@ -1160,16 +1160,27 @@ void KSyncManager::syncPi()
//qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
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;
} else {
@@ -1254,21 +1265,42 @@ 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;
mSyncActionDialog = 0;
blockRC = false;
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()) );
connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
@@ -1543,6 +1575,7 @@ void KCommandSocket::sendFileRequest()
mConnectProgress.hide();
mConnectCount = 300;mConnectMax = 300;
mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
+ mConnectProgress.setLabelText( i18n("Waiting for remote file...") );
mTimerSocket->start( 100, true );
QTextStream os( mSocket );
os.setEncoding( QTextStream::Latin1 );
@@ -1554,7 +1587,8 @@ void KCommandSocket::sendFileRequest()
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()) );
connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
@@ -1567,18 +1601,18 @@ void KCommandSocket::readFile( QString fn )
mConnectCount = 30;mConnectMax = 30;
mTimerSocket->start( 1000, true );
mSocket->connectToHost( mHost, mPort );
- qDebug("KSS: Waiting for connection");
+ qDebug("KCS: Waiting for connection");
}
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 );
--mConnectCount;
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 53c611d..604adb8 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -58,12 +58,14 @@ class KServerSocket : public QServerSocket
void saveFile();
void endConnect();
private slots:
+ void waitForSocketFinish();
void discardClient();
void deleteSocket();
void readClient();
void displayErrorMessage();
void readBackFileFromSocket();
private :
+ int mPendingConnect;
QString mResource;
int mErrorMessage;
bool blockRC;