summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Side-by-side diff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp51
1 files changed, 41 insertions, 10 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d71264f..a64eb34 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -196,6 +196,7 @@ void KSyncManager::slotClearMenu( int action )
void KSyncManager::slotSyncMenu( int action )
{
qDebug("KSM::syncaction %d ", action);
+ mCurrentResourceLocal = "";
if ( action == 5000 )
return;
mSyncWithDesktop = false;
@@ -313,12 +314,15 @@ void KSyncManager::slotSyncMenu( int action )
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
mActiveSyncPort = temp->getRemotePortAB();
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
+ if ( temp->getIsPiSyncSpec() )
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
@@ -503,7 +507,7 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
}
if ( result == 0 ) {
//qDebug("Now sycing ... ");
- if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
+ if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
else
mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
@@ -527,6 +531,7 @@ void KSyncManager::multiSync( bool askforPrefs )
if (blockSave())
return;
setBlockSave(true);
+ mCurrentResourceLocal = "";
if ( askforPrefs ) {
QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
@@ -572,6 +577,7 @@ int KSyncManager::ringSync()
QStringList syncProfileNames = mSyncProfileNames;
KSyncProfile* temp = new KSyncProfile ();
mAskForPreferences = false;
+ mCurrentResourceLocal = "";
for ( i = 0; i < syncProfileNames.count(); ++i ) {
mCurrentSyncProfile = i;
temp->setName(syncProfileNames[mCurrentSyncProfile]);
@@ -649,12 +655,14 @@ int KSyncManager::ringSync()
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
mActiveSyncPort = temp->getRemotePortAB();
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
@@ -1127,9 +1135,29 @@ void KSyncManager::syncPi()
mPisyncFinished = true;
return;
}
- 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() );
+ }
}
void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
@@ -1154,7 +1182,7 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
delete s;
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 )) );
commandSocket->sendStop();
}
@@ -1191,7 +1219,7 @@ void KSyncManager::readFileFromSocket()
mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
syncOK = false;
}
- 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 )) );
if ( mWriteBackFile && syncOK ) {
mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
@@ -1462,8 +1490,11 @@ 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;
mSocket = 0;
mFirst = false;
@@ -1490,7 +1521,7 @@ void KCommandSocket::sendFileRequest()
os.setEncoding( QTextStream::Latin1 );
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";
}
void KCommandSocket::readFile( QString fn )