author | zautrix <zautrix> | 2004-10-07 11:44:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-07 11:44:35 (UTC) |
commit | 43c82cc5393522d2c34f34a4339cb6a1d1c6c555 (patch) (unidiff) | |
tree | 49916cfb6f12c846fa52f9697f9b0285c2902772 /libkdepim/ksyncmanager.cpp | |
parent | f0e8b8f36bccda952fa662e4faf2d58fcee67262 (diff) | |
download | kdepimpi-43c82cc5393522d2c34f34a4339cb6a1d1c6c555.zip kdepimpi-43c82cc5393522d2c34f34a4339cb6a1d1c6c555.tar.gz kdepimpi-43c82cc5393522d2c34f34a4339cb6a1d1c6c555.tar.bz2 |
sync fixes
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 75 |
1 files changed, 27 insertions, 48 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index b360644..a663427 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -228,13 +228,13 @@ void KSyncManager::slotSyncMenu( int action ) | |||
228 | } else { | 228 | } else { |
229 | mPassWordPiSync = temp->getRemotePwPWM(); | 229 | mPassWordPiSync = temp->getRemotePwPWM(); |
230 | mActiveSyncPort = temp->getRemotePortPWM(); | 230 | mActiveSyncPort = temp->getRemotePortPWM(); |
231 | mActiveSyncIP = temp->getRemoteIPPWM(); | 231 | mActiveSyncIP = temp->getRemoteIPPWM(); |
232 | } | 232 | } |
233 | syncPi(); | 233 | syncPi(); |
234 | } | 234 | } else |
235 | syncRemote( temp ); | 235 | syncRemote( temp ); |
236 | 236 | ||
237 | } | 237 | } |
238 | } | 238 | } |
239 | delete temp; | 239 | delete temp; |
240 | setBlockSave(false); | 240 | setBlockSave(false); |
@@ -346,15 +346,15 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) | |||
346 | } | 346 | } |
347 | if ( mAskForPreferences ) | 347 | if ( mAskForPreferences ) |
348 | edit_sync_options(); | 348 | edit_sync_options(); |
349 | if ( result == 0 ) { | 349 | if ( result == 0 ) { |
350 | //qDebug("Now sycing ... "); | 350 | //qDebug("Now sycing ... "); |
351 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 351 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
352 | mParent->setCaption( i18n("Synchronization successful") ); | 352 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
353 | else | 353 | else |
354 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 354 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
355 | if ( ! quick ) | 355 | if ( ! quick ) |
356 | mLastSyncedLocalFile = fn; | 356 | mLastSyncedLocalFile = fn; |
357 | } | 357 | } |
358 | return ret; | 358 | return ret; |
359 | } | 359 | } |
360 | void KSyncManager::quickSyncLocalFile() | 360 | void KSyncManager::quickSyncLocalFile() |
@@ -373,33 +373,33 @@ void KSyncManager::multiSync( bool askforPrefs ) | |||
373 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 373 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
374 | if ( QMessageBox::information( mParent, i18n("Sync"), | 374 | if ( QMessageBox::information( mParent, i18n("Sync"), |
375 | question, | 375 | question, |
376 | i18n("Yes"), i18n("No"), | 376 | i18n("Yes"), i18n("No"), |
377 | 0, 0 ) != 0 ) { | 377 | 0, 0 ) != 0 ) { |
378 | setBlockSave(false); | 378 | setBlockSave(false); |
379 | mParent->setCaption(i18n("Aborted! Nothing synced!")); | 379 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
380 | return; | 380 | return; |
381 | } | 381 | } |
382 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 382 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
383 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; | 383 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; |
384 | if ( askforPrefs ) { | 384 | if ( askforPrefs ) { |
385 | edit_sync_options(); | 385 | edit_sync_options(); |
386 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 386 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
387 | } | 387 | } |
388 | mParent->setCaption(i18n("Multiple sync started.") ); | 388 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
389 | qApp->processEvents(); | 389 | qApp->processEvents(); |
390 | int num = ringSync() ; | 390 | int num = ringSync() ; |
391 | if ( num > 1 ) | 391 | if ( num > 1 ) |
392 | ringSync(); | 392 | ringSync(); |
393 | setBlockSave(false); | 393 | setBlockSave(false); |
394 | if ( num ) | 394 | if ( num ) |
395 | emit save(); | 395 | emit save(); |
396 | if ( num ) | 396 | if ( num ) |
397 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 397 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
398 | else | 398 | else |
399 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 399 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
400 | return; | 400 | return; |
401 | } | 401 | } |
402 | int KSyncManager::ringSync() | 402 | int KSyncManager::ringSync() |
403 | { | 403 | { |
404 | int syncedProfiles = 0; | 404 | int syncedProfiles = 0; |
405 | unsigned int i; | 405 | unsigned int i; |
@@ -430,13 +430,13 @@ int KSyncManager::ringSync() | |||
430 | break; | 430 | break; |
431 | 431 | ||
432 | } | 432 | } |
433 | 433 | ||
434 | 434 | ||
435 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 435 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
436 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 436 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
437 | ++syncedProfiles; | 437 | ++syncedProfiles; |
438 | // mAskForPreferences = temp->getAskForPreferences(); | 438 | // mAskForPreferences = temp->getAskForPreferences(); |
439 | mWriteBackFile = temp->getWriteBackFile(); | 439 | mWriteBackFile = temp->getWriteBackFile(); |
440 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 440 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
441 | mWriteBackInFuture = 0; | 441 | mWriteBackInFuture = 0; |
442 | if ( temp->getWriteBackFuture() ) | 442 | if ( temp->getWriteBackFuture() ) |
@@ -475,13 +475,13 @@ int KSyncManager::ringSync() | |||
475 | } else | 475 | } else |
476 | syncRemote( temp, false ); | 476 | syncRemote( temp, false ); |
477 | 477 | ||
478 | } | 478 | } |
479 | } | 479 | } |
480 | timer.start(); | 480 | timer.start(); |
481 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 481 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
482 | while ( timer.elapsed () < 2000 ) { | 482 | while ( timer.elapsed () < 2000 ) { |
483 | qApp->processEvents(); | 483 | qApp->processEvents(); |
484 | #ifndef _WIN32_ | 484 | #ifndef _WIN32_ |
485 | sleep (1); | 485 | sleep (1); |
486 | #endif | 486 | #endif |
487 | } | 487 | } |
@@ -538,13 +538,13 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | |||
538 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 538 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
539 | 539 | ||
540 | } | 540 | } |
541 | int maxlen = 30; | 541 | int maxlen = 30; |
542 | if ( QApplication::desktop()->width() > 320 ) | 542 | if ( QApplication::desktop()->width() > 320 ) |
543 | maxlen += 25; | 543 | maxlen += 25; |
544 | mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 544 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
545 | int fileSize = 0; | 545 | int fileSize = 0; |
546 | int result = system ( preCommand ); | 546 | int result = system ( preCommand ); |
547 | // 0 : okay | 547 | // 0 : okay |
548 | // 256: no such file or dir | 548 | // 256: no such file or dir |
549 | // | 549 | // |
550 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 550 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
@@ -555,16 +555,16 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | |||
555 | len += maxlen +2; | 555 | len += maxlen +2; |
556 | } | 556 | } |
557 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 557 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
558 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 558 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
559 | question, | 559 | question, |
560 | i18n("Okay!")) ; | 560 | i18n("Okay!")) ; |
561 | mParent->setCaption (""); | 561 | mParent->topLevelWidget()->setCaption (""); |
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | mParent->setCaption ( i18n( "Copying succeed." ) ); | 564 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
565 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 565 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
566 | 566 | ||
567 | 567 | ||
568 | 568 | ||
569 | if ( syncWithFile( localTempFile, true ) ) { | 569 | if ( syncWithFile( localTempFile, true ) ) { |
570 | // Event* e = mView->getLastSyncEvent(); | 570 | // Event* e = mView->getLastSyncEvent(); |
@@ -575,20 +575,20 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | |||
575 | int fi; | 575 | int fi; |
576 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 576 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
577 | QString pwd = getPassword(); | 577 | QString pwd = getPassword(); |
578 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 578 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
579 | 579 | ||
580 | } | 580 | } |
581 | mParent->setCaption ( i18n( "Writing back file ..." ) ); | 581 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
582 | result = system ( postCommand ); | 582 | result = system ( postCommand ); |
583 | qDebug("Writing back file result: %d ", result); | 583 | qDebug("Writing back file result: %d ", result); |
584 | if ( result != 0 ) { | 584 | if ( result != 0 ) { |
585 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 585 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
586 | return; | 586 | return; |
587 | } else { | 587 | } else { |
588 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 588 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
589 | } | 589 | } |
590 | } | 590 | } |
591 | } | 591 | } |
592 | return; | 592 | return; |
593 | } | 593 | } |
594 | 594 | ||
@@ -746,19 +746,19 @@ QString KSyncManager::syncFileName() | |||
746 | { | 746 | { |
747 | 747 | ||
748 | QString fn = "tempfile"; | 748 | QString fn = "tempfile"; |
749 | switch(mTargetApp) | 749 | switch(mTargetApp) |
750 | { | 750 | { |
751 | case (KAPI): | 751 | case (KAPI): |
752 | fn = "addressbook.vcf"; | 752 | fn = "tempsyncab.vcf"; |
753 | break; | 753 | break; |
754 | case (KOPI): | 754 | case (KOPI): |
755 | fn = "synccalendar.ics"; | 755 | fn = "tempsynccal.ics"; |
756 | break; | 756 | break; |
757 | case (PWMPI): | 757 | case (PWMPI): |
758 | fn = "manager.pwm"; | 758 | fn = "tempsyncpw.pwm"; |
759 | break; | 759 | break; |
760 | default: | 760 | default: |
761 | break; | 761 | break; |
762 | } | 762 | } |
763 | #ifdef _WIN32_ | 763 | #ifdef _WIN32_ |
764 | return locateLocal( "tmp", fn ); | 764 | return locateLocal( "tmp", fn ); |
@@ -770,88 +770,66 @@ QString KSyncManager::syncFileName() | |||
770 | void KSyncManager::syncPi() | 770 | void KSyncManager::syncPi() |
771 | { | 771 | { |
772 | qApp->processEvents(); | 772 | qApp->processEvents(); |
773 | bool ok; | 773 | bool ok; |
774 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 774 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
775 | if ( ! ok ) { | 775 | if ( ! ok ) { |
776 | mParent->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 776 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
777 | return; | 777 | return; |
778 | } | 778 | } |
779 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 779 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
780 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 780 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
781 | mParent->setCaption( i18n("Sending request for remote file ...") ); | 781 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
782 | commandSocket->readFile( syncFileName() ); | 782 | commandSocket->readFile( syncFileName() ); |
783 | } | 783 | } |
784 | 784 | ||
785 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 785 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
786 | { | 786 | { |
787 | qDebug("MainWindow::deleteCommandSocket %d", state); | 787 | qDebug("MainWindow::deleteCommandSocket %d", state); |
788 | 788 | ||
789 | //enum { success, errorW, errorR, quiet }; | 789 | //enum { success, errorW, errorR, quiet }; |
790 | if ( state == KCommandSocket::errorR ) { | 790 | if ( state == KCommandSocket::errorR ) { |
791 | mParent->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 791 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
792 | delete s; | 792 | delete s; |
793 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 793 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
794 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 794 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
795 | commandSocket->sendStop(); | 795 | commandSocket->sendStop(); |
796 | return; | 796 | return; |
797 | 797 | ||
798 | } else if ( state == KCommandSocket::errorW ) { | 798 | } else if ( state == KCommandSocket::errorW ) { |
799 | mParent->setCaption( i18n("ERROR:Writing back file failed.") ); | 799 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
800 | 800 | ||
801 | } else if ( state == KCommandSocket::successR ) { | 801 | } else if ( state == KCommandSocket::successR ) { |
802 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 802 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
803 | 803 | ||
804 | } else if ( state == KCommandSocket::successW ) { | 804 | } else if ( state == KCommandSocket::successW ) { |
805 | mParent->setCaption( i18n("Pi-Sync succesful!") ); | 805 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
806 | } | 806 | } |
807 | 807 | ||
808 | delete s; | 808 | delete s; |
809 | } | 809 | } |
810 | 810 | ||
811 | void KSyncManager::readFileFromSocket() | 811 | void KSyncManager::readFileFromSocket() |
812 | { | 812 | { |
813 | QString fileName = syncFileName(); | 813 | QString fileName = syncFileName(); |
814 | mParent->setCaption( i18n("Remote file saved to temp file.") ); | 814 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
815 | if ( ! syncWithFile( fileName , true ) ) { | 815 | if ( ! syncWithFile( fileName , true ) ) { |
816 | mParent->setCaption( i18n("Syncing failed.") ); | 816 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
817 | qDebug("Syncing failed "); | 817 | qDebug("Syncing failed "); |
818 | return; | 818 | return; |
819 | } | 819 | } |
820 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 820 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
821 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 821 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
822 | if ( mWriteBackFile ) | 822 | if ( mWriteBackFile ) |
823 | commandSocket->writeFile( fileName ); | 823 | commandSocket->writeFile( fileName ); |
824 | else { | 824 | else { |
825 | commandSocket->sendStop(); | 825 | commandSocket->sendStop(); |
826 | mParent->setCaption( i18n("Pi-Sync succesful!") ); | 826 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | |||
831 | |||
832 | |||
833 | |||
834 | |||
835 | |||
836 | |||
837 | |||
838 | |||
839 | |||
840 | |||
841 | |||
842 | |||
843 | |||
844 | |||
845 | |||
846 | |||
847 | |||
848 | |||
849 | |||
850 | |||
851 | |||
852 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 830 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
853 | { | 831 | { |
854 | mPassWord = pw; | 832 | mPassWord = pw; |
855 | mSocket = 0; | 833 | mSocket = 0; |
856 | mSyncActionDialog = 0; | 834 | mSyncActionDialog = 0; |
857 | blockRC = false; | 835 | blockRC = false; |
@@ -935,12 +913,13 @@ void KServerSocket::send_file() | |||
935 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 913 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
936 | lay->addWidget( label); | 914 | lay->addWidget( label); |
937 | lay->setMargin(7); | 915 | lay->setMargin(7); |
938 | lay->setSpacing(7); | 916 | lay->setSpacing(7); |
939 | mSyncActionDialog->setFixedSize( 230, 120); | 917 | mSyncActionDialog->setFixedSize( 230, 120); |
940 | mSyncActionDialog->show(); | 918 | mSyncActionDialog->show(); |
919 | mSyncActionDialog->raise(); | ||
941 | qDebug("KSS::saving ... "); | 920 | qDebug("KSS::saving ... "); |
942 | emit request_file(); | 921 | emit request_file(); |
943 | qApp->processEvents(); | 922 | qApp->processEvents(); |
944 | QString fileName = mFileName; | 923 | QString fileName = mFileName; |
945 | QFile file( fileName ); | 924 | QFile file( fileName ); |
946 | if (!file.open( IO_ReadOnly ) ) { | 925 | if (!file.open( IO_ReadOnly ) ) { |