-rw-r--r-- | libkdepim/ksyncmanager.cpp | 51 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 8 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 6 |
3 files changed, 50 insertions, 15 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index d71264f..a64eb34 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -198,2 +198,3 @@ void KSyncManager::slotSyncMenu( int action ) qDebug("KSM::syncaction %d ", action); + mCurrentResourceLocal = ""; if ( action == 5000 ) @@ -315,3 +316,4 @@ void KSyncManager::slotSyncMenu( int action ) syncPhone(); - } else if ( temp->getIsPiSync() ) { + } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { + mSpecificResources.clear(); if ( mTargetApp == KAPI ) { @@ -321,2 +323,4 @@ void KSyncManager::slotSyncMenu( int action ) } else if ( mTargetApp == KOPI ) { + if ( temp->getIsPiSyncSpec() ) + mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); mPassWordPiSync = temp->getRemotePw(); @@ -505,3 +509,3 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) //qDebug("Now sycing ... "); - if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) + if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); @@ -529,2 +533,3 @@ void KSyncManager::multiSync( bool askforPrefs ) setBlockSave(true); + mCurrentResourceLocal = ""; if ( askforPrefs ) { @@ -574,2 +579,3 @@ int KSyncManager::ringSync() mAskForPreferences = false; + mCurrentResourceLocal = ""; for ( i = 0; i < syncProfileNames.count(); ++i ) { @@ -651,3 +657,4 @@ int KSyncManager::ringSync() syncPhone(); - } else if ( temp->getIsPiSync() ) { + } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { + mSpecificResources.clear(); if ( mTargetApp == KAPI ) { @@ -657,2 +664,3 @@ int KSyncManager::ringSync() } else if ( mTargetApp == KOPI ) { + mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() ); mPassWordPiSync = temp->getRemotePw(); @@ -1129,5 +1137,25 @@ void KSyncManager::syncPi() } - KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); - connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); - commandSocket->readFile( syncFileName() ); + mCurrentResourceLocal = ""; + mCurrentResourceRemote = ""; + if ( mSpecificResources.count() ) { + int startLocal = 0; + int startRemote = mSpecificResources.count()/2; + while ( startLocal < mSpecificResources.count()/2 ) { + mPisyncFinished = false; + mCurrentResourceLocal = mSpecificResources[ startLocal ]; + mCurrentResourceRemote = mSpecificResources[ startRemote ]; + 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() ); + while ( !mPisyncFinished ) { + //qDebug("waiting "); + qApp->processEvents(); + } + ++startLocal; + } + } else { + KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); + connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); + commandSocket->readFile( syncFileName() ); + } } @@ -1156,3 +1184,3 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) if ( state == KCommandSocket::errorR ) { - KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); + KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); @@ -1193,3 +1221,3 @@ void KSyncManager::readFileFromSocket() } - KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); + KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); @@ -1464,4 +1492,7 @@ void KServerSocket::readBackFileFromSocket() -KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) +KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) { + mRemoteResource = remres; + if ( mRemoteResource.isEmpty() ) + mRemoteResource = "ALL"; mPassWord = password; @@ -1492,3 +1523,3 @@ void KCommandSocket::sendFileRequest() QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); - os << "GET " << mPassWord << curDt <<"\r\n\r\n"; + os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n"; } diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index d3734da..f4654ce 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -83,3 +83,3 @@ class KCommandSocket : public QObject enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; - KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); + KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); void readFile( QString ); @@ -100,2 +100,3 @@ class KCommandSocket : public QObject private : + QString mRemoteResource; int mConnectCount; @@ -204,2 +205,5 @@ class KSyncManager : public QObject bool mPisyncFinished; + QStringList mSpecificResources; + QString mCurrentResourceLocal; + QString mCurrentResourceRemote; bool mBlockSaveFlag; @@ -224,3 +228,3 @@ class KSyncInterface virtual void removeSyncInfo( QString syncProfile) = 0; - virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; + virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; virtual bool syncExternal(KSyncManager* manager, QString resource) diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index 292cde1..27f7932 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp @@ -594,4 +594,4 @@ void KSyncPrefsDialog::profileChanged( int item ) QStringList res = QStringList::split( ":",prof->getResSpecKopi()); - int i; - for ( i = 0;i < res.count(); ++i ) { + int i= res.count()/2; + for ( ;i < res.count(); ++i ) { mResTableKopi->setText( i, 0, res[i] ); @@ -754,3 +754,3 @@ void KSyncPrefsDialog::saveProfile() - QStringList res; + QStringList res = mResourcesKopi; int i; |