-rw-r--r-- | libkdepim/ksyncmanager.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 3adbf61..df5a0d9 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -30,65 +30,65 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | QDateTime KSyncManager::mRequestedSyncEvent; | 58 | QDateTime KSyncManager::mRequestedSyncEvent; |
59 | 59 | ||
60 | 60 | ||
61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 62 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | mWriteBackInPast = 2; | 67 | mWriteBackInPast = 2; |
68 | int w = 300; | 68 | int w = 300; |
69 | if ( QApplication::desktop()->width() < 320 ) | 69 | if ( QApplication::desktop()->width() < 320 ) |
70 | w = 220; | 70 | w = 220; |
71 | int h = bar->sizeHint().height() ; | 71 | int h = bar->sizeHint().height() ; |
72 | int dw = QApplication::desktop()->width(); | 72 | int dw = QApplication::desktop()->width(); |
73 | int dh = QApplication::desktop()->height(); | 73 | int dh = QApplication::desktop()->height(); |
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
75 | if ( mPrefs->mPassiveSyncAutoStart ) | 75 | if ( mPrefs->mPassiveSyncAutoStart ) |
76 | enableQuick( false ); | 76 | enableQuick( false ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | KSyncManager::~KSyncManager() | 80 | KSyncManager::~KSyncManager() |
81 | { | 81 | { |
82 | delete bar; | 82 | delete bar; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void KSyncManager::fillSyncMenu() | 86 | void KSyncManager::fillSyncMenu() |
87 | { | 87 | { |
88 | if ( mSyncMenu->count() ) | 88 | if ( mSyncMenu->count() ) |
89 | mSyncMenu->clear(); | 89 | mSyncMenu->clear(); |
90 | 90 | ||
91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
@@ -431,68 +431,67 @@ void KSyncManager::syncLocalFile() | |||
431 | switch(mTargetApp) | 431 | switch(mTargetApp) |
432 | { | 432 | { |
433 | case (KAPI): | 433 | case (KAPI): |
434 | ext = "(*.vcf)"; | 434 | ext = "(*.vcf)"; |
435 | break; | 435 | break; |
436 | case (KOPI): | 436 | case (KOPI): |
437 | ext = "(*.ics/*.vcs)"; | 437 | ext = "(*.ics/*.vcs)"; |
438 | break; | 438 | break; |
439 | case (PWMPI): | 439 | case (PWMPI): |
440 | ext = "(*.pwm)"; | 440 | ext = "(*.pwm)"; |
441 | break; | 441 | break; |
442 | default: | 442 | default: |
443 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 443 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
444 | break; | 444 | break; |
445 | 445 | ||
446 | } | 446 | } |
447 | 447 | ||
448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
449 | if ( fn == "" ) | 449 | if ( fn == "" ) |
450 | return; | 450 | return; |
451 | if ( syncWithFile( fn, false ) ) { | 451 | if ( syncWithFile( fn, false ) ) { |
452 | qDebug("KSM::syncLocalFile() successful "); | 452 | qDebug("KSM::syncLocalFile() successful "); |
453 | } | 453 | } |
454 | 454 | ||
455 | } | 455 | } |
456 | 456 | ||
457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
458 | { | 458 | { |
459 | bool ret = false; | 459 | bool ret = false; |
460 | QFileInfo info; | 460 | QFileInfo info; |
461 | info.setFile( fn ); | 461 | info.setFile( fn ); |
462 | QString mess; | 462 | QString mess; |
463 | bool loadbup = true; | ||
464 | if ( !info. exists() ) { | 463 | if ( !info. exists() ) { |
465 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 464 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
466 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 465 | QMessageBox::warning( mParent, i18n("Warning!"), |
467 | mess ); | 466 | mess ); |
468 | return ret; | 467 | return ret; |
469 | } | 468 | } |
470 | int result = 0; | 469 | int result = 0; |
471 | if ( !quick ) { | 470 | if ( !quick ) { |
472 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 471 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
473 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 472 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
474 | mess, | 473 | mess, |
475 | i18n("Sync"), i18n("Cancel"), 0, | 474 | i18n("Sync"), i18n("Cancel"), 0, |
476 | 0, 1 ); | 475 | 0, 1 ); |
477 | if ( result ) | 476 | if ( result ) |
478 | return false; | 477 | return false; |
479 | } | 478 | } |
480 | if ( mAskForPreferences ) | 479 | if ( mAskForPreferences ) |
481 | if ( !edit_sync_options()) { | 480 | if ( !edit_sync_options()) { |
482 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 481 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
483 | return false; | 482 | return false; |
484 | } | 483 | } |
485 | if ( result == 0 ) { | 484 | if ( result == 0 ) { |
486 | //qDebug("Now sycing ... "); | 485 | //qDebug("Now sycing ... "); |
487 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 486 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
488 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 487 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
489 | else | 488 | else |
490 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 489 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
491 | if ( ! quick ) | 490 | if ( ! quick ) |
492 | mPrefs->mLastSyncedLocalFile = fn; | 491 | mPrefs->mLastSyncedLocalFile = fn; |
493 | } | 492 | } |
494 | return ret; | 493 | return ret; |
495 | } | 494 | } |
496 | 495 | ||
497 | void KSyncManager::quickSyncLocalFile() | 496 | void KSyncManager::quickSyncLocalFile() |
498 | { | 497 | { |
@@ -527,65 +526,65 @@ void KSyncManager::multiSync( bool askforPrefs ) | |||
527 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 526 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
528 | } | 527 | } |
529 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 528 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
530 | qApp->processEvents(); | 529 | qApp->processEvents(); |
531 | int num = ringSync() ; | 530 | int num = ringSync() ; |
532 | if ( num > 1 ) | 531 | if ( num > 1 ) |
533 | ringSync(); | 532 | ringSync(); |
534 | setBlockSave(false); | 533 | setBlockSave(false); |
535 | if ( num ) | 534 | if ( num ) |
536 | emit save(); | 535 | emit save(); |
537 | if ( num ) | 536 | if ( num ) |
538 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 537 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
539 | else | 538 | else |
540 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 539 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
541 | return; | 540 | return; |
542 | } | 541 | } |
543 | 542 | ||
544 | int KSyncManager::ringSync() | 543 | int KSyncManager::ringSync() |
545 | { | 544 | { |
546 | 545 | ||
547 | int syncedProfiles = 0; | 546 | int syncedProfiles = 0; |
548 | unsigned int i; | 547 | unsigned int i; |
549 | QTime timer; | 548 | QTime timer; |
550 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 549 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
551 | QStringList syncProfileNames = mSyncProfileNames; | 550 | QStringList syncProfileNames = mSyncProfileNames; |
552 | KSyncProfile* temp = new KSyncProfile (); | 551 | KSyncProfile* temp = new KSyncProfile (); |
553 | mAskForPreferences = false; | 552 | mAskForPreferences = false; |
554 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 553 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
555 | mCurrentSyncProfile = i; | 554 | mCurrentSyncProfile = i; |
556 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 555 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
557 | temp->readConfig(&config); | 556 | temp->readConfig(&config); |
558 | 557 | ||
559 | bool includeInRingSync; | 558 | bool includeInRingSync = false; |
560 | switch(mTargetApp) | 559 | switch(mTargetApp) |
561 | { | 560 | { |
562 | case (KAPI): | 561 | case (KAPI): |
563 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 562 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
564 | break; | 563 | break; |
565 | case (KOPI): | 564 | case (KOPI): |
566 | includeInRingSync = temp->getIncludeInRingSync(); | 565 | includeInRingSync = temp->getIncludeInRingSync(); |
567 | break; | 566 | break; |
568 | case (PWMPI): | 567 | case (PWMPI): |
569 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 568 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
570 | break; | 569 | break; |
571 | default: | 570 | default: |
572 | qDebug("KSM::ringSync: invalid apptype selected"); | 571 | qDebug("KSM::ringSync: invalid apptype selected"); |
573 | break; | 572 | break; |
574 | 573 | ||
575 | } | 574 | } |
576 | 575 | ||
577 | 576 | ||
578 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 577 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
579 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 578 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
580 | ++syncedProfiles; | 579 | ++syncedProfiles; |
581 | mSyncWithDesktop = false; | 580 | mSyncWithDesktop = false; |
582 | // mAskForPreferences = temp->getAskForPreferences(); | 581 | // mAskForPreferences = temp->getAskForPreferences(); |
583 | mWriteBackFile = temp->getWriteBackFile(); | 582 | mWriteBackFile = temp->getWriteBackFile(); |
584 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 583 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
585 | mIsKapiFile = temp->getIsKapiFile(); | 584 | mIsKapiFile = temp->getIsKapiFile(); |
586 | mWriteBackInFuture = 0; | 585 | mWriteBackInFuture = 0; |
587 | if ( temp->getWriteBackFuture() ) { | 586 | if ( temp->getWriteBackFuture() ) { |
588 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 587 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
589 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 588 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
590 | } | 589 | } |
591 | mFilterInCal = temp->getFilterInCal(); | 590 | mFilterInCal = temp->getFilterInCal(); |