summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-25 22:16:50 (UTC)
committer zautrix <zautrix>2005-11-25 22:16:50 (UTC)
commitb71ee5442df23bb9900d3db6e6244773ee34ef13 (patch) (unidiff)
tree221ac1af78b4fcbf741a48687f28570216f89049
parent81d012860ea3d5d17d0e9cf16ec992baa83efbbf (diff)
downloadkdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.zip
kdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.tar.gz
kdepimpi-b71ee5442df23bb9900d3db6e6244773ee34ef13.tar.bz2
sync
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
@@ -1494,20 +1494,20 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
1494 if ( localMod >= remoteMod ) 1494 if ( localMod >= remoteMod )
1495 return 1; 1495 return 1;
1496 else 1496 else
1497 return 2; 1497 return 2;
1498 break; 1498 break;
1499 case SYNC_PREF_ASK: 1499 case SYNC_PREF_ASK:
1500 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1500 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1501 if ( lastSync > remoteMod && lastSync > localMod) 1501 if ( lastSync > remoteMod && lastSync > localMod)
1502 return 0; 1502 return 0;
1503 if ( lastSync > remoteMod ) 1503 if ( lastSync > remoteMod )
1504 return 1; 1504 return 1;
1505 if ( lastSync > localMod ) 1505 if ( lastSync > localMod )
1506 return 2; 1506 return 2;
1507 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1507 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1508 localIsNew = localMod >= remoteMod; 1508 localIsNew = localMod >= remoteMod;
1509 if ( localIsNew ) 1509 if ( localIsNew )
1510 getEventViewerDialog()->setColorMode( 1 ); 1510 getEventViewerDialog()->setColorMode( 1 );
1511 else 1511 else
1512 getEventViewerDialog()->setColorMode( 2 ); 1512 getEventViewerDialog()->setColorMode( 2 );
1513 getEventViewerDialog()->setIncidence(local); 1513 getEventViewerDialog()->setIncidence(local);
@@ -1538,27 +1538,30 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
1538 return 0; 1538 return 0;
1539} 1539}
1540Event* CalendarView::getLastSyncEvent() 1540Event* CalendarView::getLastSyncEvent()
1541{ 1541{
1542 Event* lse; 1542 Event* lse;
1543 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1543 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1544 mCalendar->setSyncEventsEnabled();
1544 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1545 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1545 if (!lse) { 1546 if (!lse) {
1547 qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() );
1546 lse = new Event(); 1548 lse = new Event();
1547 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1549 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1548 QString sum = ""; 1550 QString sum = "";
1549 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1551 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1550 sum = "E: "; 1552 sum = "E: ";
1551 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1553 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1552 lse->setDtStart( mLastCalendarSync ); 1554 lse->setDtStart( mLastCalendarSync );
1553 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1555 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1554 lse->setCategories( i18n("SyncEvent") ); 1556 lse->setCategories( i18n("SyncEvent") );
1555 lse->setReadOnly( true ); 1557 lse->setReadOnly( true );
1556 lse->setCalID( 1 ); 1558 lse->setCalID( 1 );
1557 mCalendar->addEvent( lse ); 1559 mCalendar->addEvent( lse );
1558 } 1560 } else
1561 qDebug("KO: Last Syncevent on local found");
1559 1562
1560 return lse; 1563 return lse;
1561 1564
1562} 1565}
1563 1566
1564// we check, if the to delete event has a id for a profile 1567// we check, if the to delete event has a id for a profile
@@ -1630,13 +1633,13 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1630 } 1633 }
1631 } 1634 }
1632 QDateTime modifiedCalendar = mLastCalendarSync; 1635 QDateTime modifiedCalendar = mLastCalendarSync;
1633 eventLSync = getLastSyncEvent(); 1636 eventLSync = getLastSyncEvent();
1634 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1637 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1635 if ( eventR ) { 1638 if ( eventR ) {
1636 qDebug("last-syncEvent on remote found "); 1639 qDebug("KO: Last-syncEvent on remote found ");
1637 eventRSync = (Event*) eventR->clone(); 1640 eventRSync = (Event*) eventR->clone();
1638 remote->deleteEvent(eventR ); 1641 remote->deleteEvent(eventR );
1639 1642
1640 } else { 1643 } else {
1641 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1644 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1642 eventRSync = (Event*)eventLSync->clone(); 1645 eventRSync = (Event*)eventLSync->clone();
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index e1b15d2..8bf0d27 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1157,22 +1157,33 @@ void KSyncManager::syncPi()
1157 mPisyncFinished = false; 1157 mPisyncFinished = false;
1158 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1158 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1159 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1159 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1160 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1160 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
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;
1175 } else { 1186 } else {
1176 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1187 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1177 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1188 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1178 commandSocket->readFile( syncFileName() ); 1189 commandSocket->readFile( syncFileName() );
@@ -1251,27 +1262,48 @@ void KSyncManager::readFileFromSocket()
1251 mPisyncFinished = true; 1262 mPisyncFinished = true;
1252 } 1263 }
1253} 1264}
1254 1265
1255KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1266KServerSocket:: 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;
1259 mSyncActionDialog = 0; 1271 mSyncActionDialog = 0;
1260 blockRC = false; 1272 blockRC = false;
1261 mErrorMessage = 0; 1273 mErrorMessage = 0;
1262} 1274}
1263 1275void 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}
1264void KServerSocket::newConnection ( int socket ) 1288void 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()) );
1274 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1306 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1275 mSocket->setSocket( socket ); 1307 mSocket->setSocket( socket );
1276} 1308}
1277 1309
@@ -1540,48 +1572,50 @@ void KCommandSocket::sendFileRequest()
1540{ 1572{
1541 if ( tlw ) 1573 if ( tlw )
1542 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1574 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1543 mConnectProgress.hide(); 1575 mConnectProgress.hide();
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 );
1548 os.setEncoding( QTextStream::Latin1 ); 1581 os.setEncoding( QTextStream::Latin1 );
1549 1582
1550 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1583 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1551 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; 1584 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n";
1552} 1585}
1553 1586
1554void KCommandSocket::readFile( QString fn ) 1587void 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()) );
1560 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1594 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1561 } 1595 }
1562 mFileString = ""; 1596 mFileString = "";
1563 mFileName = fn; 1597 mFileName = fn;
1564 mFirst = true; 1598 mFirst = true;
1565 if ( tlw ) 1599 if ( tlw )
1566 tlw->setCaption( i18n("Trying to connect to remote...") ); 1600 tlw->setCaption( i18n("Trying to connect to remote...") );
1567 mConnectCount = 30;mConnectMax = 30; 1601 mConnectCount = 30;mConnectMax = 30;
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}
1572void KCommandSocket::updateConnectDialog() 1606void KCommandSocket::updateConnectDialog()
1573{ 1607{
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 );
1584 --mConnectCount; 1618 --mConnectCount;
1585 if ( mConnectCount > 0 ) 1619 if ( mConnectCount > 0 )
1586 mTimerSocket->start( 1000, true ); 1620 mTimerSocket->start( 1000, true );
1587 else 1621 else
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 53c611d..604adb8 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -55,18 +55,20 @@ class KServerSocket : public QServerSocket
55 void request_file(); 55 void request_file();
56 void file_received( bool, const QString &); 56 void file_received( bool, const QString &);
57 void request_file(const QString &); 57 void request_file(const QString &);
58 void saveFile(); 58 void saveFile();
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();
63 void readClient(); 64 void readClient();
64 void displayErrorMessage(); 65 void displayErrorMessage();
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;
69 bool blockRC; 71 bool blockRC;
70 void send_file(); 72 void send_file();
71 void get_file(); 73 void get_file();
72 void end_connect(); 74 void end_connect();