summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-11-25 15:49:13 (UTC)
committer zautrix <zautrix>2005-11-25 15:49:13 (UTC)
commit794a5204686ad9bfc16172b01db35f1f3b7683e5 (patch) (unidiff)
tree29da2cb35a4d6a0cd6885436087fe0659b58a9f4 /libkdepim
parent90b62d1158d00f162a258541e24aaed4c967480b (diff)
downloadkdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.zip
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.gz
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.bz2
sync
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp51
-rw-r--r--libkdepim/ksyncmanager.h8
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
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
@@ -175,48 +175,49 @@ void KSyncManager::slotClearMenu( int action )
175{ 175{
176 QString syncDevice; 176 QString syncDevice;
177 if ( action > 999 ) { 177 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 179 }
180 180
181 181
182 182
183 int result = 0; 183 int result = 0;
184 QString sd; 184 QString sd;
185 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 187 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 189
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 191 0, 1 );
192 if ( result ) 192 if ( result )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
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;
202 if ( action == 0 ) { 203 if ( action == 0 ) {
203 204
204 // seems to be a Qt2 event handling bug 205 // seems to be a Qt2 event handling bug
205 // syncmenu.clear causes a segfault at first time 206 // syncmenu.clear causes a segfault at first time
206 // when we call it after the main event loop, it is ok 207 // when we call it after the main event loop, it is ok
207 // same behaviour when calling OM/Pi via QCOP for the first time 208 // same behaviour when calling OM/Pi via QCOP for the first time
208 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 209 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
209 //confSync(); 210 //confSync();
210 211
211 return; 212 return;
212 } 213 }
213 if ( action == 1 ) { 214 if ( action == 1 ) {
214 multiSync( true ); 215 multiSync( true );
215 return; 216 return;
216 } 217 }
217 if ( action == 2 ) { 218 if ( action == 2 ) {
218 enableQuick(); 219 enableQuick();
219 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 220 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
220 return; 221 return;
221 } 222 }
222 if ( action == 3 ) { 223 if ( action == 3 ) {
@@ -292,54 +293,57 @@ void KSyncManager::slotSyncMenu( int action )
292 { 293 {
293 case (KAPI): 294 case (KAPI):
294 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 295 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
295 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 296 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
296 break; 297 break;
297 case (KOPI): 298 case (KOPI):
298 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 299 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
299 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 300 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
300 break; 301 break;
301 case (PWMPI): 302 case (PWMPI):
302 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 303 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
303 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 304 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
304 break; 305 break;
305 default: 306 default:
306 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 307 qDebug("KSM::slotSyncMenu: invalid apptype selected");
307 break; 308 break;
308 309
309 } 310 }
310 } else { 311 } else {
311 if ( temp->getIsPhoneSync() ) { 312 if ( temp->getIsPhoneSync() ) {
312 mPhoneDevice = temp->getPhoneDevice( ) ; 313 mPhoneDevice = temp->getPhoneDevice( ) ;
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();
325 } else { 329 } else {
326 mPassWordPiSync = temp->getRemotePwPWM(); 330 mPassWordPiSync = temp->getRemotePwPWM();
327 mActiveSyncPort = temp->getRemotePortPWM(); 331 mActiveSyncPort = temp->getRemotePortPWM();
328 mActiveSyncIP = temp->getRemoteIPPWM(); 332 mActiveSyncIP = temp->getRemoteIPPWM();
329 } 333 }
330 syncPi(); 334 syncPi();
331 while ( !mPisyncFinished ) { 335 while ( !mPisyncFinished ) {
332 //qDebug("waiting "); 336 //qDebug("waiting ");
333 qApp->processEvents(); 337 qApp->processEvents();
334 } 338 }
335 } else 339 } else
336 syncRemote( temp ); 340 syncRemote( temp );
337 341
338 } 342 }
339 } 343 }
340 delete temp; 344 delete temp;
341 setBlockSave(false); 345 setBlockSave(false);
342} 346}
343 347
344void KSyncManager::enableQuick( bool ask ) 348void KSyncManager::enableQuick( bool ask )
345{ 349{
@@ -482,117 +486,119 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
482 QString mess; 486 QString mess;
483 if ( !info. exists() ) { 487 if ( !info. exists() ) {
484 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 488 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
485 QMessageBox::warning( mParent, i18n("Warning!"), 489 QMessageBox::warning( mParent, i18n("Warning!"),
486 mess ); 490 mess );
487 return ret; 491 return ret;
488 } 492 }
489 int result = 0; 493 int result = 0;
490 if ( !quick ) { 494 if ( !quick ) {
491 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 495 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
492 result = QMessageBox::warning( mParent, i18n("Warning!"), 496 result = QMessageBox::warning( mParent, i18n("Warning!"),
493 mess, 497 mess,
494 i18n("Sync"), i18n("Cancel"), 0, 498 i18n("Sync"), i18n("Cancel"), 0,
495 0, 1 ); 499 0, 1 );
496 if ( result ) 500 if ( result )
497 return false; 501 return false;
498 } 502 }
499 if ( mAskForPreferences ) 503 if ( mAskForPreferences )
500 if ( !edit_sync_options()) { 504 if ( !edit_sync_options()) {
501 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 505 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
502 return false; 506 return false;
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.") );
510 if ( ! quick ) 514 if ( ! quick )
511 mPrefs->mLastSyncedLocalFile = fn; 515 mPrefs->mLastSyncedLocalFile = fn;
512 } 516 }
513 return ret; 517 return ret;
514} 518}
515 519
516void KSyncManager::quickSyncLocalFile() 520void KSyncManager::quickSyncLocalFile()
517{ 521{
518 522
519 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 523 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
520 qDebug("KSM::quick syncLocalFile() successful "); 524 qDebug("KSM::quick syncLocalFile() successful ");
521 525
522 } 526 }
523} 527}
524 528
525void KSyncManager::multiSync( bool askforPrefs ) 529void KSyncManager::multiSync( bool askforPrefs )
526{ 530{
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"),
533 question, 538 question,
534 i18n("Yes"), i18n("No"), 539 i18n("Yes"), i18n("No"),
535 0, 0 ) != 0 ) { 540 0, 0 ) != 0 ) {
536 setBlockSave(false); 541 setBlockSave(false);
537 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 542 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
538 return; 543 return;
539 } 544 }
540 } 545 }
541 mCurrentSyncDevice = i18n("Multiple profiles") ; 546 mCurrentSyncDevice = i18n("Multiple profiles") ;
542 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 547 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
543 if ( askforPrefs ) { 548 if ( askforPrefs ) {
544 if ( !edit_sync_options()) { 549 if ( !edit_sync_options()) {
545 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 550 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
546 return; 551 return;
547 } 552 }
548 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 553 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
549 } 554 }
550 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 555 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
551 qApp->processEvents(); 556 qApp->processEvents();
552 int num = ringSync() ; 557 int num = ringSync() ;
553 if ( num > 1 ) 558 if ( num > 1 )
554 ringSync(); 559 ringSync();
555 setBlockSave(false); 560 setBlockSave(false);
556 if ( num ) 561 if ( num )
557 emit save(); 562 emit save();
558 if ( num ) 563 if ( num )
559 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 564 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
560 else 565 else
561 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 566 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
562 return; 567 return;
563} 568}
564 569
565int KSyncManager::ringSync() 570int KSyncManager::ringSync()
566{ 571{
567 572
568 int syncedProfiles = 0; 573 int syncedProfiles = 0;
569 unsigned int i; 574 unsigned int i;
570 QTime timer; 575 QTime timer;
571 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 576 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
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]);
578 temp->readConfig(&config); 584 temp->readConfig(&config);
579 585
580 bool includeInRingSync = false; 586 bool includeInRingSync = false;
581 switch(mTargetApp) 587 switch(mTargetApp)
582 { 588 {
583 case (KAPI): 589 case (KAPI):
584 includeInRingSync = temp->getIncludeInRingSyncAB(); 590 includeInRingSync = temp->getIncludeInRingSyncAB();
585 break; 591 break;
586 case (KOPI): 592 case (KOPI):
587 includeInRingSync = temp->getIncludeInRingSync(); 593 includeInRingSync = temp->getIncludeInRingSync();
588 break; 594 break;
589 case (PWMPI): 595 case (PWMPI):
590 includeInRingSync = temp->getIncludeInRingSyncPWM(); 596 includeInRingSync = temp->getIncludeInRingSyncPWM();
591 break; 597 break;
592 default: 598 default:
593 qDebug("KSM::ringSync: invalid apptype selected"); 599 qDebug("KSM::ringSync: invalid apptype selected");
594 break; 600 break;
595 601
596 } 602 }
597 603
598 604
@@ -628,54 +634,56 @@ int KSyncManager::ringSync()
628 switch(mTargetApp) 634 switch(mTargetApp)
629 { 635 {
630 case (KAPI): 636 case (KAPI):
631 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 637 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
632 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 638 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
633 break; 639 break;
634 case (KOPI): 640 case (KOPI):
635 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 641 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
636 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
637 break; 643 break;
638 case (PWMPI): 644 case (PWMPI):
639 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 645 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
640 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
641 break; 647 break;
642 default: 648 default:
643 qDebug("KSM: invalid apptype selected"); 649 qDebug("KSM: invalid apptype selected");
644 break; 650 break;
645 } 651 }
646 } else { 652 } else {
647 if ( temp->getIsPhoneSync() ) { 653 if ( temp->getIsPhoneSync() ) {
648 mPhoneDevice = temp->getPhoneDevice( ) ; 654 mPhoneDevice = temp->getPhoneDevice( ) ;
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();
661 } else { 669 } else {
662 mPassWordPiSync = temp->getRemotePwPWM(); 670 mPassWordPiSync = temp->getRemotePwPWM();
663 mActiveSyncPort = temp->getRemotePortPWM(); 671 mActiveSyncPort = temp->getRemotePortPWM();
664 mActiveSyncIP = temp->getRemoteIPPWM(); 672 mActiveSyncIP = temp->getRemoteIPPWM();
665 } 673 }
666 syncPi(); 674 syncPi();
667 while ( !mPisyncFinished ) { 675 while ( !mPisyncFinished ) {
668 //qDebug("waiting "); 676 //qDebug("waiting ");
669 qApp->processEvents(); 677 qApp->processEvents();
670 } 678 }
671 timer.start(); 679 timer.start();
672 while ( timer.elapsed () < 2000 ) { 680 while ( timer.elapsed () < 2000 ) {
673 qApp->processEvents(); 681 qApp->processEvents();
674 } 682 }
675 } else 683 } else
676 syncRemote( temp, false ); 684 syncRemote( temp, false );
677 685
678 } 686 }
679 } 687 }
680 timer.start(); 688 timer.start();
681 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 689 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
@@ -1106,113 +1114,133 @@ QString KSyncManager::syncFileName()
1106 return locateLocal( "tmp", fn ); 1114 return locateLocal( "tmp", fn );
1107#else 1115#else
1108 return (QString( "/tmp/" )+ fn ); 1116 return (QString( "/tmp/" )+ fn );
1109#endif 1117#endif
1110} 1118}
1111 1119
1112void KSyncManager::syncPi() 1120void KSyncManager::syncPi()
1113{ 1121{
1114 mIsKapiFile = true; 1122 mIsKapiFile = true;
1115 mPisyncFinished = false; 1123 mPisyncFinished = false;
1116 qApp->processEvents(); 1124 qApp->processEvents();
1117 if ( mAskForPreferences ) 1125 if ( mAskForPreferences )
1118 if ( !edit_pisync_options()) { 1126 if ( !edit_pisync_options()) {
1119 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1127 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1120 mPisyncFinished = true; 1128 mPisyncFinished = true;
1121 return; 1129 return;
1122 } 1130 }
1123 bool ok; 1131 bool ok;
1124 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1132 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1125 if ( ! ok ) { 1133 if ( ! ok ) {
1126 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1134 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
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 = "";
1131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1139 mCurrentResourceRemote = "";
1132 commandSocket->readFile( syncFileName() ); 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() );
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1159 commandSocket->readFile( syncFileName() );
1160 }
1133} 1161}
1134 1162
1135void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1163void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1136{ 1164{
1137 //enum { success, errorW, errorR, quiet }; 1165 //enum { success, errorW, errorR, quiet };
1138 1166
1139 1167
1140 1168
1141 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1169 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1142 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1170 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1143 if ( state == KCommandSocket::errorPW ) 1171 if ( state == KCommandSocket::errorPW )
1144 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1172 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1145 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1173 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1146 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1174 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1147 else if ( state == KCommandSocket::errorCA ) 1175 else if ( state == KCommandSocket::errorCA )
1148 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1176 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1149 else if ( state == KCommandSocket::errorFI ) 1177 else if ( state == KCommandSocket::errorFI )
1150 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1178 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1151 else if ( state == KCommandSocket::errorED ) 1179 else if ( state == KCommandSocket::errorED )
1152 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1180 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1153 else if ( state == KCommandSocket::errorUN ) 1181 else if ( state == KCommandSocket::errorUN )
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 }
1161 mPisyncFinished = true; 1189 mPisyncFinished = true;
1162 return; 1190 return;
1163 1191
1164 } else if ( state == KCommandSocket::errorW ) { 1192 } else if ( state == KCommandSocket::errorW ) {
1165 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1193 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1166 mPisyncFinished = true; 1194 mPisyncFinished = true;
1167 1195
1168 } else if ( state == KCommandSocket::successR ) { 1196 } else if ( state == KCommandSocket::successR ) {
1169 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1197 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1170 1198
1171 } else if ( state == KCommandSocket::successW ) { 1199 } else if ( state == KCommandSocket::successW ) {
1172 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1200 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1173 mPisyncFinished = true; 1201 mPisyncFinished = true;
1174 } else if ( state == KCommandSocket::quiet ){ 1202 } else if ( state == KCommandSocket::quiet ){
1175 qDebug("KSS: quiet "); 1203 qDebug("KSS: quiet ");
1176 mPisyncFinished = true; 1204 mPisyncFinished = true;
1177 } else { 1205 } else {
1178 qDebug("KSS: Error: unknown state: %d ", state); 1206 qDebug("KSS: Error: unknown state: %d ", state);
1179 mPisyncFinished = true; 1207 mPisyncFinished = true;
1180 } 1208 }
1181 1209
1182 delete s; 1210 delete s;
1183} 1211}
1184 1212
1185void KSyncManager::readFileFromSocket() 1213void KSyncManager::readFileFromSocket()
1186{ 1214{
1187 QString fileName = syncFileName(); 1215 QString fileName = syncFileName();
1188 bool syncOK = true; 1216 bool syncOK = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1217 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1190 if ( ! syncWithFile( fileName , true ) ) { 1218 if ( ! syncWithFile( fileName , true ) ) {
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 ...") );
1198 commandSocket->writeFile( fileName ); 1226 commandSocket->writeFile( fileName );
1199 } 1227 }
1200 else { 1228 else {
1201 commandSocket->sendStop(); 1229 commandSocket->sendStop();
1202 if ( syncOK ) 1230 if ( syncOK )
1203 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1231 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1204 mPisyncFinished = true; 1232 mPisyncFinished = true;
1205 } 1233 }
1206} 1234}
1207 1235
1208KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1236KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1209{ 1237{
1210 mPassWord = pw; 1238 mPassWord = pw;
1211 mSocket = 0; 1239 mSocket = 0;
1212 mSyncActionDialog = 0; 1240 mSyncActionDialog = 0;
1213 blockRC = false; 1241 blockRC = false;
1214 mErrorMessage = 0; 1242 mErrorMessage = 0;
1215} 1243}
1216 1244
1217void KServerSocket::newConnection ( int socket ) 1245void KServerSocket::newConnection ( int socket )
1218{ 1246{
@@ -1441,77 +1469,80 @@ void KServerSocket::readBackFileFromSocket()
1441 piFileString = ""; 1469 piFileString = "";
1442 emit file_received( false ); 1470 emit file_received( false );
1443 blockRC = false; 1471 blockRC = false;
1444 return ; 1472 return ;
1445 1473
1446 } 1474 }
1447 1475
1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1476 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1449 QTextStream ts ( &file ); 1477 QTextStream ts ( &file );
1450 ts.setEncoding( QTextStream::Latin1 ); 1478 ts.setEncoding( QTextStream::Latin1 );
1451 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1479 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1452 ts << piFileString; 1480 ts << piFileString;
1453 mSocket->close(); 1481 mSocket->close();
1454 if ( mSocket->state() == QSocket::Idle ) 1482 if ( mSocket->state() == QSocket::Idle )
1455 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1483 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1456 file.close(); 1484 file.close();
1457 piFileString = ""; 1485 piFileString = "";
1458 emit file_received( true ); 1486 emit file_received( true );
1459 delete mSyncActionDialog; 1487 delete mSyncActionDialog;
1460 mSyncActionDialog = 0; 1488 mSyncActionDialog = 0;
1461 blockRC = false; 1489 blockRC = false;
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;
1470 mFirstLine = true; 1501 mFirstLine = true;
1471 mPort = port; 1502 mPort = port;
1472 mHost = host; 1503 mHost = host;
1473 tlw = cap; 1504 tlw = cap;
1474 mRetVal = quiet; 1505 mRetVal = quiet;
1475 mTimerSocket = new QTimer ( this ); 1506 mTimerSocket = new QTimer ( this );
1476 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1507 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1477 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1508 mConnectProgress.setCaption( i18n("Pi-Sync") );
1478 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1509 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1479 mConnectCount = -1; 1510 mConnectCount = -1;
1480} 1511}
1481void KCommandSocket::sendFileRequest() 1512void KCommandSocket::sendFileRequest()
1482{ 1513{
1483 if ( tlw ) 1514 if ( tlw )
1484 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1515 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1485 mConnectProgress.hide(); 1516 mConnectProgress.hide();
1486 mConnectCount = 300;mConnectMax = 300; 1517 mConnectCount = 300;mConnectMax = 300;
1487 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1518 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1488 mTimerSocket->start( 100, true ); 1519 mTimerSocket->start( 100, true );
1489 QTextStream os( mSocket ); 1520 QTextStream os( mSocket );
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 )
1497{ 1528{
1498 if ( !mSocket ) { 1529 if ( !mSocket ) {
1499 mSocket = new QSocket( this ); 1530 mSocket = new QSocket( this );
1500 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1531 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1501 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1532 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1502 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1533 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1503 } 1534 }
1504 mFileString = ""; 1535 mFileString = "";
1505 mFileName = fn; 1536 mFileName = fn;
1506 mFirst = true; 1537 mFirst = true;
1507 if ( tlw ) 1538 if ( tlw )
1508 tlw->setCaption( i18n("Trying to connect to remote...") ); 1539 tlw->setCaption( i18n("Trying to connect to remote...") );
1509 mConnectCount = 30;mConnectMax = 30; 1540 mConnectCount = 30;mConnectMax = 30;
1510 mTimerSocket->start( 1000, true ); 1541 mTimerSocket->start( 1000, true );
1511 mSocket->connectToHost( mHost, mPort ); 1542 mSocket->connectToHost( mHost, mPort );
1512 qDebug("KSS: Waiting for connection"); 1543 qDebug("KSS: Waiting for connection");
1513} 1544}
1514void KCommandSocket::updateConnectDialog() 1545void KCommandSocket::updateConnectDialog()
1515{ 1546{
1516 1547
1517 if ( mConnectCount == mConnectMax ) { 1548 if ( mConnectCount == mConnectMax ) {
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d3734da..f4654ce 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -60,65 +60,66 @@ class KServerSocket : public QServerSocket
60 void deleteSocket(); 60 void deleteSocket();
61 void readClient(); 61 void readClient();
62 void displayErrorMessage(); 62 void displayErrorMessage();
63 void readBackFileFromSocket(); 63 void readBackFileFromSocket();
64 private : 64 private :
65 int mErrorMessage; 65 int mErrorMessage;
66 bool blockRC; 66 bool blockRC;
67 void send_file(); 67 void send_file();
68 void get_file(); 68 void get_file();
69 void end_connect(); 69 void end_connect();
70 void error_connect( QString ); 70 void error_connect( QString );
71 QDialog* mSyncActionDialog; 71 QDialog* mSyncActionDialog;
72 QSocket* mSocket; 72 QSocket* mSocket;
73 QString mPassWord; 73 QString mPassWord;
74 QString mFileName; 74 QString mFileName;
75 QTime piTime; 75 QTime piTime;
76 QString piFileString; 76 QString piFileString;
77}; 77};
78 78
79class KCommandSocket : public QObject 79class KCommandSocket : public QObject
80{ 80{
81 Q_OBJECT 81 Q_OBJECT
82 public: 82 public:
83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; 83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
84 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 84 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
85 void readFile( QString ); 85 void readFile( QString );
86 void writeFile( QString ); 86 void writeFile( QString );
87 void sendStop(); 87 void sendStop();
88 88
89 private slots : 89 private slots :
90 void sendFileRequest(); 90 void sendFileRequest();
91 void updateConnectDialog(); 91 void updateConnectDialog();
92 92
93 signals: 93 signals:
94 void commandFinished( KCommandSocket*, int ); 94 void commandFinished( KCommandSocket*, int );
95 private slots: 95 private slots:
96 void startReadFileFromSocket(); 96 void startReadFileFromSocket();
97 void readFileFromSocket(); 97 void readFileFromSocket();
98 void deleteSocket(); 98 void deleteSocket();
99 void writeFileToSocket(); 99 void writeFileToSocket();
100 private : 100 private :
101 QString mRemoteResource;
101 int mConnectCount; 102 int mConnectCount;
102 int mConnectMax; 103 int mConnectMax;
103 KProgressDialog mConnectProgress; 104 KProgressDialog mConnectProgress;
104 QWidget* tlw; 105 QWidget* tlw;
105 QSocket* mSocket; 106 QSocket* mSocket;
106 QString mPassWord; 107 QString mPassWord;
107 Q_UINT16 mPort; 108 Q_UINT16 mPort;
108 QString mHost; 109 QString mHost;
109 QString mFileName; 110 QString mFileName;
110 QTimer* mTimerSocket; 111 QTimer* mTimerSocket;
111 int mRetVal; 112 int mRetVal;
112 QTime mTime; 113 QTime mTime;
113 QString mFileString; 114 QString mFileString;
114 bool mFirst; 115 bool mFirst;
115 bool mFirstLine; 116 bool mFirstLine;
116}; 117};
117 118
118 119
119class KSyncManager : public QObject 120class KSyncManager : public QObject
120{ 121{
121 Q_OBJECT 122 Q_OBJECT
122 123
123 public: 124 public:
124 enum TargetApp { 125 enum TargetApp {
@@ -181,57 +182,60 @@ class KSyncManager : public QObject
181 void readFileFromSocket(); 182 void readFileFromSocket();
182 void fillSyncMenu(); 183 void fillSyncMenu();
183 184
184 private: 185 private:
185 void syncPi(); 186 void syncPi();
186 KServerSocket * mServerSocket; 187 KServerSocket * mServerSocket;
187 KPimPrefs* mPrefs; 188 KPimPrefs* mPrefs;
188 QString mDefFileName; 189 QString mDefFileName;
189 QString mCurrentSyncDevice; 190 QString mCurrentSyncDevice;
190 QString mCurrentSyncName; 191 QString mCurrentSyncName;
191 void quickSyncLocalFile(); 192 void quickSyncLocalFile();
192 bool syncWithFile( QString fn , bool quick ); 193 bool syncWithFile( QString fn , bool quick );
193 void syncLocalFile(); 194 void syncLocalFile();
194 void syncPhone(); 195 void syncPhone();
195 void syncSharp(); 196 void syncSharp();
196 void syncKDE(); 197 void syncKDE();
197 bool syncExternalApplication(QString); 198 bool syncExternalApplication(QString);
198 int mCurrentSyncProfile ; 199 int mCurrentSyncProfile ;
199 void syncRemote( KSyncProfile* prof, bool ask = true); 200 void syncRemote( KSyncProfile* prof, bool ask = true);
200 bool edit_sync_options(); 201 bool edit_sync_options();
201 bool edit_pisync_options(); 202 bool edit_pisync_options();
202 int ringSync(); 203 int ringSync();
203 QString getPassword( ); 204 QString getPassword( );
204 bool mPisyncFinished; 205 bool mPisyncFinished;
206 QStringList mSpecificResources;
207 QString mCurrentResourceLocal;
208 QString mCurrentResourceRemote;
205 bool mBlockSaveFlag; 209 bool mBlockSaveFlag;
206 QWidget* mParent; 210 QWidget* mParent;
207 KSyncInterface* mImplementation; 211 KSyncInterface* mImplementation;
208 TargetApp mTargetApp; 212 TargetApp mTargetApp;
209 QPopupMenu* mSyncMenu; 213 QPopupMenu* mSyncMenu;
210 QProgressBar* bar; 214 QProgressBar* bar;
211 bool mSyncWithDesktop; 215 bool mSyncWithDesktop;
212 216
213private slots: 217private slots:
214 void displayErrorPort(); 218 void displayErrorPort();
215 void confSync(); 219 void confSync();
216 220
217 221
218}; 222};
219 223
220 224
221class KSyncInterface 225class KSyncInterface
222{ 226{
223 public : 227 public :
224 virtual void removeSyncInfo( QString syncProfile) = 0; 228 virtual void removeSyncInfo( QString syncProfile) = 0;
225 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 229 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
226 virtual bool syncExternal(KSyncManager* manager, QString resource) 230 virtual bool syncExternal(KSyncManager* manager, QString resource)
227 { 231 {
228 // empty implementation, because some syncable applications do not 232 // empty implementation, because some syncable applications do not
229 // have an external(sharpdtm) syncmode, like pwmanager. 233 // have an external(sharpdtm) syncmode, like pwmanager.
230 return false; 234 return false;
231 } 235 }
232 236
233 237
234}; 238};
235 239
236 240
237#endif 241#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 292cde1..27f7932 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -571,50 +571,50 @@ void KSyncPrefsDialog::profileChanged( int item )
571 case 3: 571 case 3:
572 ask->setChecked( true); 572 ask->setChecked( true);
573 break; 573 break;
574 case 4: 574 case 4:
575 f_loc->setChecked( true); 575 f_loc->setChecked( true);
576 break; 576 break;
577 case 5: 577 case 5:
578 f_rem->setChecked( true); 578 f_rem->setChecked( true);
579 break; 579 break;
580 case 6: 580 case 6:
581 //both->setChecked( true); 581 //both->setChecked( true);
582 break; 582 break;
583 default: 583 default:
584 break; 584 break;
585 } 585 }
586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
587 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 587 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
588 mIsPi->setChecked(prof->getIsPiSync()) ; 588 mIsPi->setChecked(prof->getIsPiSync()) ;
589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; 589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; 590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; 591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
592 592
593 593
594 QStringList res = QStringList::split( ":",prof->getResSpecKopi()); 594 QStringList res = QStringList::split( ":",prof->getResSpecKopi());
595 int i; 595 int i= res.count()/2;
596 for ( i = 0;i < res.count(); ++i ) { 596 for ( ;i < res.count(); ++i ) {
597 mResTableKopi->setText( i, 0, res[i] ); 597 mResTableKopi->setText( i, 0, res[i] );
598 } 598 }
599 res = QStringList::split( ":",prof->getResSpecKapi()); 599 res = QStringList::split( ":",prof->getResSpecKapi());
600 for ( i = 0;i < res.count(); ++i ) { 600 for ( i = 0;i < res.count(); ++i ) {
601 mResTableKapi->setText( i, 0, res[i] ); 601 mResTableKapi->setText( i, 0, res[i] );
602 } 602 }
603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); 603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec());
604 proGr->setEnabled( item > 2 ); 604 proGr->setEnabled( item > 2 );
605 if ( item < 3 ) { 605 if ( item < 3 ) {
606 localFileWidget->hide(); 606 localFileWidget->hide();
607 remoteFileWidget->hide(); 607 remoteFileWidget->hide();
608 phoneWidget->hide(); 608 phoneWidget->hide();
609 piWidget->hide(); 609 piWidget->hide();
610 610
611 } else 611 } else
612 kindChanged( prof->getIsLocalFileSync() ); 612 kindChanged( prof->getIsLocalFileSync() );
613} 613}
614 614
615void KSyncPrefsDialog::fillSSH() 615void KSyncPrefsDialog::fillSSH()
616{ 616{
617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
618 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 618 mLocalTempFile->setText("/tmp/mycalendar.ics" );
619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
@@ -731,49 +731,49 @@ void KSyncPrefsDialog::saveProfile()
731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
735 prof->setSyncPrefs( syncprefs); 735 prof->setSyncPrefs( syncprefs);
736 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 736 prof->setIsLocalFileSync( mIsLocal->isChecked() );
737 prof->setIsPhoneSync( mIsPhone->isChecked() ); 737 prof->setIsPhoneSync( mIsPhone->isChecked() );
738 prof->setIsPiSync( mIsPi->isChecked() ); 738 prof->setIsPiSync( mIsPi->isChecked() );
739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); 739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() );
740 prof->setIsKapiFile( mIsKapiFileL->isChecked() ); 740 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
741 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 741 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); 743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
744 if ( mWriteContactToSIM ) 744 if ( mWriteContactToSIM )
745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
746 prof->setPhoneDevice( mPhoneDevice->text() ); 746 prof->setPhoneDevice( mPhoneDevice->text() );
747 prof->setPhoneConnection( mPhoneConnection->text() ); 747 prof->setPhoneConnection( mPhoneConnection->text() );
748 prof->setPhoneModel( mPhoneModel->text() ); 748 prof->setPhoneModel( mPhoneModel->text() );
749 prof->setFilterInCal ( mFilterInCal->currentText ()); 749 prof->setFilterInCal ( mFilterInCal->currentText ());
750 prof->setFilterOutCal ( mFilterOutCal ->currentText ()); 750 prof->setFilterOutCal ( mFilterOutCal ->currentText ());
751 prof->setFilterInAB ( mFilterInAB ->currentText ()); 751 prof->setFilterInAB ( mFilterInAB ->currentText ());
752 prof->setFilterOutAB ( mFilterOutAB ->currentText ()); 752 prof->setFilterOutAB ( mFilterOutAB ->currentText ());
753 if ( mIsPiSpecific->isChecked() ) { 753 if ( mIsPiSpecific->isChecked() ) {
754 754
755 QStringList res; 755 QStringList res = mResourcesKopi;
756 int i; 756 int i;
757 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 757 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
758 res.append( mResTableKopi->text( i, 0 )); 758 res.append( mResTableKopi->text( i, 0 ));
759 } 759 }
760 prof->setResSpecKopi( res.join(":")); 760 prof->setResSpecKopi( res.join(":"));
761 } 761 }
762 } 762 }
763} 763}
764 764
765void KSyncPrefsDialog::insertProfiles() 765void KSyncPrefsDialog::insertProfiles()
766{ 766{
767 int curItem = mProfileBox->currentItem(); 767 int curItem = mProfileBox->currentItem();
768 mProfileBox->blockSignals( true ); 768 mProfileBox->blockSignals( true );
769 mProfileBox->clear(); 769 mProfileBox->clear();
770 mProfileBox->insertStringList (mSyncProfileNames ); 770 mProfileBox->insertStringList (mSyncProfileNames );
771 int item = mSyncProfileNames.count() -1; 771 int item = mSyncProfileNames.count() -1;
772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
773 mProfileBox->setCurrentItem( curItem ); 773 mProfileBox->setCurrentItem( curItem );
774 else if ( item >= 0 ) { 774 else if ( item >= 0 ) {
775 mProfileBox->setCurrentItem( item ); 775 mProfileBox->setCurrentItem( item );
776 } 776 }
777 currentSelection = -1; 777 currentSelection = -1;
778 if ( mSyncProfileNames.count() > 0 ) { 778 if ( mSyncProfileNames.count() > 0 ) {
779 //qDebug(" profileChanged( mProfileBox->currentItem() "); 779 //qDebug(" profileChanged( mProfileBox->currentItem() ");