summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp47
1 files changed, 39 insertions, 8 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 )
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = "";
199 if ( action == 5000 ) 200 if ( action == 5000 )
200 return; 201 return;
201 mSyncWithDesktop = false; 202 mSyncWithDesktop = false;
@@ -313,12 +314,15 @@ void KSyncManager::slotSyncMenu( int action )
313 mPhoneConnection = temp->getPhoneConnection( ); 314 mPhoneConnection = temp->getPhoneConnection( );
314 mPhoneModel = temp->getPhoneModel( ); 315 mPhoneModel = temp->getPhoneModel( );
315 syncPhone(); 316 syncPhone();
316 } else if ( temp->getIsPiSync() ) { 317 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
318 mSpecificResources.clear();
317 if ( mTargetApp == KAPI ) { 319 if ( mTargetApp == KAPI ) {
318 mPassWordPiSync = temp->getRemotePwAB(); 320 mPassWordPiSync = temp->getRemotePwAB();
319 mActiveSyncPort = temp->getRemotePortAB(); 321 mActiveSyncPort = temp->getRemotePortAB();
320 mActiveSyncIP = temp->getRemoteIPAB(); 322 mActiveSyncIP = temp->getRemoteIPAB();
321 } else if ( mTargetApp == KOPI ) { 323 } else if ( mTargetApp == KOPI ) {
324 if ( temp->getIsPiSyncSpec() )
325 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
322 mPassWordPiSync = temp->getRemotePw(); 326 mPassWordPiSync = temp->getRemotePw();
323 mActiveSyncPort = temp->getRemotePort(); 327 mActiveSyncPort = temp->getRemotePort();
324 mActiveSyncIP = temp->getRemoteIP(); 328 mActiveSyncIP = temp->getRemoteIP();
@@ -503,7 +507,7 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
503 } 507 }
504 if ( result == 0 ) { 508 if ( result == 0 ) {
505 //qDebug("Now sycing ... "); 509 //qDebug("Now sycing ... ");
506 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 510 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
507 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 511 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
508 else 512 else
509 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 513 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
@@ -527,6 +531,7 @@ void KSyncManager::multiSync( bool askforPrefs )
527 if (blockSave()) 531 if (blockSave())
528 return; 532 return;
529 setBlockSave(true); 533 setBlockSave(true);
534 mCurrentResourceLocal = "";
530 if ( askforPrefs ) { 535 if ( askforPrefs ) {
531 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 536 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
532 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 537 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
@@ -572,6 +577,7 @@ int KSyncManager::ringSync()
572 QStringList syncProfileNames = mSyncProfileNames; 577 QStringList syncProfileNames = mSyncProfileNames;
573 KSyncProfile* temp = new KSyncProfile (); 578 KSyncProfile* temp = new KSyncProfile ();
574 mAskForPreferences = false; 579 mAskForPreferences = false;
580 mCurrentResourceLocal = "";
575 for ( i = 0; i < syncProfileNames.count(); ++i ) { 581 for ( i = 0; i < syncProfileNames.count(); ++i ) {
576 mCurrentSyncProfile = i; 582 mCurrentSyncProfile = i;
577 temp->setName(syncProfileNames[mCurrentSyncProfile]); 583 temp->setName(syncProfileNames[mCurrentSyncProfile]);
@@ -649,12 +655,14 @@ int KSyncManager::ringSync()
649 mPhoneConnection = temp->getPhoneConnection( ); 655 mPhoneConnection = temp->getPhoneConnection( );
650 mPhoneModel = temp->getPhoneModel( ); 656 mPhoneModel = temp->getPhoneModel( );
651 syncPhone(); 657 syncPhone();
652 } else if ( temp->getIsPiSync() ) { 658 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
659 mSpecificResources.clear();
653 if ( mTargetApp == KAPI ) { 660 if ( mTargetApp == KAPI ) {
654 mPassWordPiSync = temp->getRemotePwAB(); 661 mPassWordPiSync = temp->getRemotePwAB();
655 mActiveSyncPort = temp->getRemotePortAB(); 662 mActiveSyncPort = temp->getRemotePortAB();
656 mActiveSyncIP = temp->getRemoteIPAB(); 663 mActiveSyncIP = temp->getRemoteIPAB();
657 } else if ( mTargetApp == KOPI ) { 664 } else if ( mTargetApp == KOPI ) {
665 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
658 mPassWordPiSync = temp->getRemotePw(); 666 mPassWordPiSync = temp->getRemotePw();
659 mActiveSyncPort = temp->getRemotePort(); 667 mActiveSyncPort = temp->getRemotePort();
660 mActiveSyncIP = temp->getRemoteIP(); 668 mActiveSyncIP = temp->getRemoteIP();
@@ -1127,10 +1135,30 @@ void KSyncManager::syncPi()
1127 mPisyncFinished = true; 1135 mPisyncFinished = true;
1128 return; 1136 return;
1129 } 1137 }
1130 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1138 mCurrentResourceLocal = "";
1139 mCurrentResourceRemote = "";
1140 if ( mSpecificResources.count() ) {
1141 int startLocal = 0;
1142 int startRemote = mSpecificResources.count()/2;
1143 while ( startLocal < mSpecificResources.count()/2 ) {
1144 mPisyncFinished = false;
1145 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1146 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1147 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1148 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1149 commandSocket->readFile( syncFileName() );
1150 while ( !mPisyncFinished ) {
1151 //qDebug("waiting ");
1152 qApp->processEvents();
1153 }
1154 ++startLocal;
1155 }
1156 } else {
1157 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1132 commandSocket->readFile( syncFileName() ); 1159 commandSocket->readFile( syncFileName() );
1133} 1160}
1161}
1134 1162
1135void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1163void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1136{ 1164{
@@ -1154,7 +1182,7 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1154 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1182 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1155 delete s; 1183 delete s;
1156 if ( state == KCommandSocket::errorR ) { 1184 if ( state == KCommandSocket::errorR ) {
1157 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1185 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1186 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1159 commandSocket->sendStop(); 1187 commandSocket->sendStop();
1160 } 1188 }
@@ -1191,7 +1219,7 @@ void KSyncManager::readFileFromSocket()
1191 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1219 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1192 syncOK = false; 1220 syncOK = false;
1193 } 1221 }
1194 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1222 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1195 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1223 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1196 if ( mWriteBackFile && syncOK ) { 1224 if ( mWriteBackFile && syncOK ) {
1197 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1225 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
@@ -1462,8 +1490,11 @@ void KServerSocket::readBackFileFromSocket()
1462 1490
1463} 1491}
1464 1492
1465KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1493KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1466{ 1494{
1495 mRemoteResource = remres;
1496 if ( mRemoteResource.isEmpty() )
1497 mRemoteResource = "ALL";
1467 mPassWord = password; 1498 mPassWord = password;
1468 mSocket = 0; 1499 mSocket = 0;
1469 mFirst = false; 1500 mFirst = false;
@@ -1490,7 +1521,7 @@ void KCommandSocket::sendFileRequest()
1490 os.setEncoding( QTextStream::Latin1 ); 1521 os.setEncoding( QTextStream::Latin1 );
1491 1522
1492 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1523 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1493 os << "GET " << mPassWord << curDt <<"\r\n\r\n"; 1524 os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n";
1494} 1525}
1495 1526
1496void KCommandSocket::readFile( QString fn ) 1527void KCommandSocket::readFile( QString fn )