summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 17:51:17 (UTC)
committer zautrix <zautrix>2004-10-07 17:51:17 (UTC)
commit1f1538e5707b59bfcff2014901f29a65589229e3 (patch) (unidiff)
tree0d91a303524e6ac9f7c954f01a0e1d09d0e305e7
parentbb8293c794d82a57bc93af85ccd89b601356d577 (diff)
downloadkdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.zip
kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.gz
kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.bz2
many cleanups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp1
-rw-r--r--korganizer/calendarview.cpp136
-rw-r--r--korganizer/calendarview.h11
-rw-r--r--korganizer/koprefs.cpp3
-rw-r--r--korganizer/koprefs.h20
-rw-r--r--korganizer/mainwindow.cpp556
-rw-r--r--korganizer/mainwindow.h24
-rw-r--r--libkdepim/kpimprefs.cpp9
-rw-r--r--libkdepim/kpimprefs.h3
-rw-r--r--libkdepim/ksyncmanager.cpp166
-rw-r--r--libkdepim/ksyncmanager.h3
11 files changed, 186 insertions, 746 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 12502b0..c5406bf 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2839,49 +2839,48 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2839 bool syncOK = false; 2839 bool syncOK = false;
2840 if ( abLocal.load() ) { 2840 if ( abLocal.load() ) {
2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2845 if ( syncOK ) { 2845 if ( syncOK ) {
2846 if ( syncManager->mWriteBackFile ) { 2846 if ( syncManager->mWriteBackFile ) {
2847 abLocal.saveAB(); 2847 abLocal.saveAB();
2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2849 } 2849 }
2850 } 2850 }
2851 setModified(); 2851 setModified();
2852 } 2852 }
2853 if ( syncOK ) 2853 if ( syncOK )
2854 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2855 return syncOK; 2855 return syncOK;
2856 2856
2857} 2857}
2858 2858
2859void KABCore::getFile( bool success ) 2859void KABCore::getFile( bool success )
2860{ 2860{
2861 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2861 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2862 if ( ! success ) { 2862 if ( ! success ) {
2863 setCaption( i18n("Error receiving file. Nothing changed!") ); 2863 setCaption( i18n("Error receiving file. Nothing changed!") );
2864 return; 2864 return;
2865 } 2865 }
2866 mAddressBook->importFromFile( sentSyncFile() ); 2866 mAddressBook->importFromFile( sentSyncFile() );
2867 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 2867 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2868 mViewManager->refreshView(); 2868 mViewManager->refreshView();
2869} 2869}
2870void KABCore::syncFileRequest() 2870void KABCore::syncFileRequest()
2871{ 2871{
2872 mAddressBook->export2File( sentSyncFile() ); 2872 mAddressBook->export2File( sentSyncFile() );
2873} 2873}
2874QString KABCore::sentSyncFile() 2874QString KABCore::sentSyncFile()
2875{ 2875{
2876#ifdef _WIN32_ 2876#ifdef _WIN32_
2877 return locateLocal( "tmp", "copysyncab.vcf" ); 2877 return locateLocal( "tmp", "copysyncab.vcf" );
2878#else 2878#else
2879 return QString( "/tmp/copysyncab.vcf" ); 2879 return QString( "/tmp/copysyncab.vcf" );
2880#endif 2880#endif
2881} 2881}
2882 2882
2883void KABCore::setCaptionBack() 2883void KABCore::setCaptionBack()
2884{ 2884{
2885 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2885 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2886} 2886}
2887
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index ea9607d..b56f1f9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -655,109 +655,97 @@ void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
656#endif 656#endif
657 return; 657 return;
658 } 658 }
659 mAlarmTimer->stop(); 659 mAlarmTimer->stop();
660} 660}
661void CalendarView::selectWeekNum ( int num ) 661void CalendarView::selectWeekNum ( int num )
662{ 662{
663 dateNavigator()->selectWeek( num ); 663 dateNavigator()->selectWeek( num );
664 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
665} 665}
666KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
667{ 667{
668 return mViewManager; 668 return mViewManager;
669} 669}
670 670
671KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
672{ 672{
673 return mDialogManager; 673 return mDialogManager;
674} 674}
675 675
676QDate CalendarView::startDate() 676QDate CalendarView::startDate()
677{ 677{
678 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
679 679
680 return dates.first(); 680 return dates.first();
681} 681}
682 682
683QDate CalendarView::endDate() 683QDate CalendarView::endDate()
684{ 684{
685 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
686 686
687 return dates.last(); 687 return dates.last();
688} 688}
689 689
690 690
691void CalendarView::createPrinter() 691void CalendarView::createPrinter()
692{ 692{
693#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 694 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 697 }
698#endif 698#endif
699} 699}
700 700
701void CalendarView::confSync() 701void CalendarView::confSync()
702{ 702{
703 static KSyncPrefsDialog* sp = 0; 703 //DELETE
704 if ( ! sp ) {
705 sp = new KSyncPrefsDialog( this, "syncprefs", true );
706 }
707 sp->usrReadConfig();
708#ifndef DESKTOP_VERSION
709 sp->showMaximized();
710#else
711 sp->show();
712#endif
713 sp->exec();
714 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
715 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
716} 704}
717 705
718 706
719//KOPrefs::instance()->mWriteBackFile 707//KOPrefs::instance()->mWriteBackFile
720//KOPrefs::instance()->mWriteBackExistingOnly 708//KOPrefs::instance()->mWriteBackExistingOnly
721 709
722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 710// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 711// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 712// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 713// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 714// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 715// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
728 716
729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 717int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
730{ 718{
731 719
732 //void setZaurusId(int id); 720 //void setZaurusId(int id);
733 // int zaurusId() const; 721 // int zaurusId() const;
734 // void setZaurusUid(int id); 722 // void setZaurusUid(int id);
735 // int zaurusUid() const; 723 // int zaurusUid() const;
736 // void setZaurusStat(int id); 724 // void setZaurusStat(int id);
737 // int zaurusStat() const; 725 // int zaurusStat() const;
738 // 0 equal 726 // 0 equal
739 // 1 take local 727 // 1 take local
740 // 2 take remote 728 // 2 take remote
741 // 3 cancel 729 // 3 cancel
742 QDateTime lastSync = mLastCalendarSync; 730 QDateTime lastSync = mLastCalendarSync;
743 QDateTime localMod = local->lastModified(); 731 QDateTime localMod = local->lastModified();
744 QDateTime remoteMod = remote->lastModified(); 732 QDateTime remoteMod = remote->lastModified();
745 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
746 bool remCh, locCh; 734 bool remCh, locCh;
747 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
748 //if ( remCh ) 736 //if ( remCh )
749 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
750 locCh = ( localMod > mLastCalendarSync ); 738 locCh = ( localMod > mLastCalendarSync );
751 if ( !remCh && ! locCh ) { 739 if ( !remCh && ! locCh ) {
752 //qDebug("both not changed "); 740 //qDebug("both not changed ");
753 lastSync = localMod.addDays(1); 741 lastSync = localMod.addDays(1);
754 if ( mode <= SYNC_PREF_ASK ) 742 if ( mode <= SYNC_PREF_ASK )
755 return 0; 743 return 0;
756 } else { 744 } else {
757 if ( locCh ) { 745 if ( locCh ) {
758 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
759 lastSync = localMod.addDays( -1 ); 747 lastSync = localMod.addDays( -1 );
760 if ( !remCh ) 748 if ( !remCh )
761 remoteMod = ( lastSync.addDays( -1 ) ); 749 remoteMod = ( lastSync.addDays( -1 ) );
762 } else { 750 } else {
763 //qDebug(" not loc changed "); 751 //qDebug(" not loc changed ");
@@ -832,97 +820,97 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
832 case SYNC_PREF_ASK: 820 case SYNC_PREF_ASK:
833 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
834 if ( lastSync > remoteMod ) 822 if ( lastSync > remoteMod )
835 return 1; 823 return 1;
836 if ( lastSync > localMod ) 824 if ( lastSync > localMod )
837 return 2; 825 return 2;
838 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
839 localIsNew = localMod >= remoteMod; 827 localIsNew = localMod >= remoteMod;
840 if ( localIsNew ) 828 if ( localIsNew )
841 getEventViewerDialog()->setColorMode( 1 ); 829 getEventViewerDialog()->setColorMode( 1 );
842 else 830 else
843 getEventViewerDialog()->setColorMode( 2 ); 831 getEventViewerDialog()->setColorMode( 2 );
844 getEventViewerDialog()->setIncidence(local); 832 getEventViewerDialog()->setIncidence(local);
845 if ( localIsNew ) 833 if ( localIsNew )
846 getEventViewerDialog()->setColorMode( 2 ); 834 getEventViewerDialog()->setColorMode( 2 );
847 else 835 else
848 getEventViewerDialog()->setColorMode( 1 ); 836 getEventViewerDialog()->setColorMode( 1 );
849 getEventViewerDialog()->addIncidence(remote); 837 getEventViewerDialog()->addIncidence(remote);
850 getEventViewerDialog()->setColorMode( 0 ); 838 getEventViewerDialog()->setColorMode( 0 );
851 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
852 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
853 getEventViewerDialog()->showMe(); 841 getEventViewerDialog()->showMe();
854 result = getEventViewerDialog()->executeS( localIsNew ); 842 result = getEventViewerDialog()->executeS( localIsNew );
855 return result; 843 return result;
856 844
857 break; 845 break;
858 case SYNC_PREF_FORCE_LOCAL: 846 case SYNC_PREF_FORCE_LOCAL:
859 return 1; 847 return 1;
860 break; 848 break;
861 case SYNC_PREF_FORCE_REMOTE: 849 case SYNC_PREF_FORCE_REMOTE:
862 return 2; 850 return 2;
863 break; 851 break;
864 852
865 default: 853 default:
866 // SYNC_PREF_TAKE_BOTH not implemented 854 // SYNC_PREF_TAKE_BOTH not implemented
867 break; 855 break;
868 } 856 }
869 return 0; 857 return 0;
870} 858}
871Event* CalendarView::getLastSyncEvent() 859Event* CalendarView::getLastSyncEvent()
872{ 860{
873 Event* lse; 861 Event* lse;
874 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
875 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
876 if (!lse) { 864 if (!lse) {
877 lse = new Event(); 865 lse = new Event();
878 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
879 QString sum = ""; 867 QString sum = "";
880 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
881 sum = "E: "; 869 sum = "E: ";
882 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
883 lse->setDtStart( mLastCalendarSync ); 871 lse->setDtStart( mLastCalendarSync );
884 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
885 lse->setCategories( i18n("SyncEvent") ); 873 lse->setCategories( i18n("SyncEvent") );
886 lse->setReadOnly( true ); 874 lse->setReadOnly( true );
887 mCalendar->addEvent( lse ); 875 mCalendar->addEvent( lse );
888 } 876 }
889 877
890 return lse; 878 return lse;
891 879
892} 880}
893 881
894// we check, if the to delete event has a id for a profile 882// we check, if the to delete event has a id for a profile
895// if yes, we set this id in the profile to delete 883// if yes, we set this id in the profile to delete
896void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
897{ 885{
898 if ( lastSync.count() == 0 ) { 886 if ( lastSync.count() == 0 ) {
899 //qDebug(" lastSync.count() == 0"); 887 //qDebug(" lastSync.count() == 0");
900 return; 888 return;
901 } 889 }
902 if ( toDelete->type() == "Journal" ) 890 if ( toDelete->type() == "Journal" )
903 return; 891 return;
904 892
905 Event* eve = lastSync.first(); 893 Event* eve = lastSync.first();
906 894
907 while ( eve ) { 895 while ( eve ) {
908 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
909 if ( !id.isEmpty() ) { 897 if ( !id.isEmpty() ) {
910 QString des = eve->description(); 898 QString des = eve->description();
911 QString pref = "e"; 899 QString pref = "e";
912 if ( toDelete->type() == "Todo" ) 900 if ( toDelete->type() == "Todo" )
913 pref = "t"; 901 pref = "t";
914 des += pref+ id + ","; 902 des += pref+ id + ",";
915 eve->setReadOnly( false ); 903 eve->setReadOnly( false );
916 eve->setDescription( des ); 904 eve->setDescription( des );
917 //qDebug("setdes %s ", des.latin1()); 905 //qDebug("setdes %s ", des.latin1());
918 eve->setReadOnly( true ); 906 eve->setReadOnly( true );
919 } 907 }
920 eve = lastSync.next(); 908 eve = lastSync.next();
921 } 909 }
922 910
923} 911}
924void CalendarView::checkExternalId( Incidence * inc ) 912void CalendarView::checkExternalId( Incidence * inc )
925{ 913{
926 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
927 checkExternSyncEvent( lastSync, inc ); 915 checkExternSyncEvent( lastSync, inc );
928 916
@@ -1074,307 +1062,305 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1074 ++addedEvent; 1062 ++addedEvent;
1075 } 1063 }
1076 } else { 1064 } else {
1077 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1065 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1078 inR->setLastModified( modifiedCalendar ); 1066 inR->setLastModified( modifiedCalendar );
1079 local->addIncidence( inR->clone() ); 1067 local->addIncidence( inR->clone() );
1080 ++addedEvent; 1068 ++addedEvent;
1081 } else { 1069 } else {
1082 checkExternSyncEvent(eventRSyncSharp, inR); 1070 checkExternSyncEvent(eventRSyncSharp, inR);
1083 remote->deleteIncidence( inR ); 1071 remote->deleteIncidence( inR );
1084 ++deletedEventR; 1072 ++deletedEventR;
1085 } 1073 }
1086 } 1074 }
1087 } 1075 }
1088 } 1076 }
1089 inR = er.next(); 1077 inR = er.next();
1090 } 1078 }
1091 QPtrList<Incidence> el = local->rawIncidences(); 1079 QPtrList<Incidence> el = local->rawIncidences();
1092 inL = el.first(); 1080 inL = el.first();
1093 modulo = (el.count()/10)+1; 1081 modulo = (el.count()/10)+1;
1094 bar.setCaption (i18n("Add / remove events") ); 1082 bar.setCaption (i18n("Add / remove events") );
1095 bar.setTotalSteps ( el.count() ) ; 1083 bar.setTotalSteps ( el.count() ) ;
1096 bar.show(); 1084 bar.show();
1097 incCounter = 0; 1085 incCounter = 0;
1098 1086
1099 while ( inL ) { 1087 while ( inL ) {
1100 1088
1101 qApp->processEvents(); 1089 qApp->processEvents();
1102 if ( ! bar.isVisible() ) 1090 if ( ! bar.isVisible() )
1103 return false; 1091 return false;
1104 if ( incCounter % modulo == 0 ) 1092 if ( incCounter % modulo == 0 )
1105 bar.setProgress( incCounter ); 1093 bar.setProgress( incCounter );
1106 ++incCounter; 1094 ++incCounter;
1107 uid = inL->uid(); 1095 uid = inL->uid();
1108 bool skipIncidence = false; 1096 bool skipIncidence = false;
1109 if ( uid.left(15) == QString("last-syncEvent-") ) 1097 if ( uid.left(15) == QString("last-syncEvent-") )
1110 skipIncidence = true; 1098 skipIncidence = true;
1111 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1112 skipIncidence = true; 1100 skipIncidence = true;
1113 if ( !skipIncidence ) { 1101 if ( !skipIncidence ) {
1114 inR = remote->incidence( uid ); 1102 inR = remote->incidence( uid );
1115 if ( ! inR ) { 1103 if ( ! inR ) {
1116 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1104 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1117 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1105 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1118 checkExternSyncEvent(eventLSyncSharp, inL); 1106 checkExternSyncEvent(eventLSyncSharp, inL);
1119 local->deleteIncidence( inL ); 1107 local->deleteIncidence( inL );
1120 ++deletedEventL; 1108 ++deletedEventL;
1121 } else { 1109 } else {
1122 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1110 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1123 inL->removeID(mCurrentSyncDevice ); 1111 inL->removeID(mCurrentSyncDevice );
1124 ++addedEventR; 1112 ++addedEventR;
1125 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1113 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1126 inL->setLastModified( modifiedCalendar ); 1114 inL->setLastModified( modifiedCalendar );
1127 inR = inL->clone(); 1115 inR = inL->clone();
1128 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1116 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1129 remote->addIncidence( inR ); 1117 remote->addIncidence( inR );
1130 } 1118 }
1131 } 1119 }
1132 } else { 1120 } else {
1133 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1121 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1134 checkExternSyncEvent(eventLSyncSharp, inL); 1122 checkExternSyncEvent(eventLSyncSharp, inL);
1135 local->deleteIncidence( inL ); 1123 local->deleteIncidence( inL );
1136 ++deletedEventL; 1124 ++deletedEventL;
1137 } else { 1125 } else {
1138 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1126 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1139 ++addedEventR; 1127 ++addedEventR;
1140 inL->setLastModified( modifiedCalendar ); 1128 inL->setLastModified( modifiedCalendar );
1141 remote->addIncidence( inL->clone() ); 1129 remote->addIncidence( inL->clone() );
1142 } 1130 }
1143 } 1131 }
1144 } 1132 }
1145 } 1133 }
1146 } 1134 }
1147 inL = el.next(); 1135 inL = el.next();
1148 } 1136 }
1149 int delFut = 0; 1137 int delFut = 0;
1150 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1138 if ( mSyncManager->mWriteBackInFuture ) {
1151 er = remote->rawIncidences(); 1139 er = remote->rawIncidences();
1152 inR = er.first(); 1140 inR = er.first();
1153 QDateTime dt; 1141 QDateTime dt;
1154 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1142 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1155 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); 1143 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1156 while ( inR ) { 1144 while ( inR ) {
1157 if ( inR->type() == "Todo" ) { 1145 if ( inR->type() == "Todo" ) {
1158 Todo * t = (Todo*)inR; 1146 Todo * t = (Todo*)inR;
1159 if ( t->hasDueDate() ) 1147 if ( t->hasDueDate() )
1160 dt = t->dtDue(); 1148 dt = t->dtDue();
1161 else 1149 else
1162 dt = cur.addSecs( 62 ); 1150 dt = cur.addSecs( 62 );
1163 } 1151 }
1164 else if (inR->type() == "Event" ) { 1152 else if (inR->type() == "Event" ) {
1165 bool ok; 1153 bool ok;
1166 dt = inR->getNextOccurence( cur, &ok ); 1154 dt = inR->getNextOccurence( cur, &ok );
1167 if ( !ok ) 1155 if ( !ok )
1168 dt = cur.addSecs( -62 ); 1156 dt = cur.addSecs( -62 );
1169 } 1157 }
1170 else 1158 else
1171 dt = inR->dtStart(); 1159 dt = inR->dtStart();
1172 if ( dt < cur || dt > end ) { 1160 if ( dt < cur || dt > end ) {
1173 remote->deleteIncidence( inR ); 1161 remote->deleteIncidence( inR );
1174 ++delFut; 1162 ++delFut;
1175 } 1163 }
1176 inR = er.next(); 1164 inR = er.next();
1177 } 1165 }
1178 } 1166 }
1179 bar.hide(); 1167 bar.hide();
1180 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1168 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1181 eventLSync->setReadOnly( false ); 1169 eventLSync->setReadOnly( false );
1182 eventLSync->setDtStart( mLastCalendarSync ); 1170 eventLSync->setDtStart( mLastCalendarSync );
1183 eventRSync->setDtStart( mLastCalendarSync ); 1171 eventRSync->setDtStart( mLastCalendarSync );
1184 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1172 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1185 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1173 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1186 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1174 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1187 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1175 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1188 eventLSync->setReadOnly( true ); 1176 eventLSync->setReadOnly( true );
1189 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1177 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1190 remote->addEvent( eventRSync ); 1178 remote->addEvent( eventRSync );
1191 QString mes; 1179 QString mes;
1192 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1180 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1193 QString delmess; 1181 QString delmess;
1194 if ( delFut ) { 1182 if ( delFut ) {
1195 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); 1183 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture );
1196 mes += delmess; 1184 mes += delmess;
1197 } 1185 }
1198 if ( KOPrefs::instance()->mShowSyncSummary ) { 1186 if ( mSyncManager->mShowSyncSummary ) {
1199 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1187 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1200 } 1188 }
1201 qDebug( mes ); 1189 qDebug( mes );
1202 mCalendar->checkAlarmForIncidence( 0, true ); 1190 mCalendar->checkAlarmForIncidence( 0, true );
1203 return syncOK; 1191 return syncOK;
1204} 1192}
1205 1193
1206void CalendarView::setSyncDevice( QString s ) 1194void CalendarView::setSyncDevice( QString s )
1207{ 1195{
1208 mCurrentSyncDevice= s; 1196 mCurrentSyncDevice= s;
1209} 1197}
1210void CalendarView::setSyncName( QString s ) 1198void CalendarView::setSyncName( QString s )
1211{ 1199{
1212 mCurrentSyncName= s; 1200 mCurrentSyncName= s;
1213} 1201}
1214bool CalendarView::syncCalendar(QString filename, int mode) 1202bool CalendarView::syncCalendar(QString filename, int mode)
1215{ 1203{
1216 mGlobalSyncMode = SYNC_MODE_NORMAL; 1204 mGlobalSyncMode = SYNC_MODE_NORMAL;
1217 CalendarLocal* calendar = new CalendarLocal(); 1205 CalendarLocal* calendar = new CalendarLocal();
1218 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1206 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1219 FileStorage* storage = new FileStorage( calendar ); 1207 FileStorage* storage = new FileStorage( calendar );
1220 bool syncOK = false; 1208 bool syncOK = false;
1221 storage->setFileName( filename ); 1209 storage->setFileName( filename );
1222 // qDebug("loading ... "); 1210 // qDebug("loading ... ");
1223 if ( storage->load() ) { 1211 if ( storage->load() ) {
1224 getEventViewerDialog()->setSyncMode( true ); 1212 getEventViewerDialog()->setSyncMode( true );
1225 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1213 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1226 getEventViewerDialog()->setSyncMode( false ); 1214 getEventViewerDialog()->setSyncMode( false );
1227 if ( syncOK ) { 1215 if ( syncOK ) {
1228 if ( KOPrefs::instance()->mWriteBackFile ) 1216 if ( mSyncManager->mWriteBackFile )
1229 { 1217 {
1230 storage->setSaveFormat( new ICalFormat() ); 1218 storage->setSaveFormat( new ICalFormat() );
1231 storage->save(); 1219 storage->save();
1232 } 1220 }
1233 } 1221 }
1234 setModified( true ); 1222 setModified( true );
1235 } 1223 }
1236 delete storage; 1224 delete storage;
1237 delete calendar; 1225 delete calendar;
1238 if ( syncOK ) 1226 if ( syncOK )
1239 updateView(); 1227 updateView();
1240 return syncOK; 1228 return syncOK;
1241} 1229}
1242void CalendarView::syncPhone() 1230void CalendarView::syncPhone()
1243{ 1231{
1244 syncExternal( 1 ); 1232 //DELETE
1245} 1233}
1246void CalendarView::syncExternal( int mode ) 1234void CalendarView::syncExternal( int mode )
1247{ 1235{
1248 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1236 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1249 //mCurrentSyncDevice = "sharp-DTM"; 1237
1250 if ( KOPrefs::instance()->mAskForPreferences )
1251 edit_sync_options();
1252 qApp->processEvents(); 1238 qApp->processEvents();
1253 CalendarLocal* calendar = new CalendarLocal(); 1239 CalendarLocal* calendar = new CalendarLocal();
1254 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1240 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1255 bool syncOK = false; 1241 bool syncOK = false;
1256 bool loadSuccess = false; 1242 bool loadSuccess = false;
1257 PhoneFormat* phoneFormat = 0; 1243 PhoneFormat* phoneFormat = 0;
1258#ifndef DESKTOP_VERSION 1244#ifndef DESKTOP_VERSION
1259 SharpFormat* sharpFormat = 0; 1245 SharpFormat* sharpFormat = 0;
1260 if ( mode == 0 ) { // sharp 1246 if ( mode == 0 ) { // sharp
1261 sharpFormat = new SharpFormat () ; 1247 sharpFormat = new SharpFormat () ;
1262 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1248 loadSuccess = sharpFormat->load( calendar, mCalendar );
1263 1249
1264 } else 1250 } else
1265#endif 1251#endif
1266 if ( mode == 1 ) { // phone 1252 if ( mode == 1 ) { // phone
1267 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1253 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1268 KOPrefs::instance()->mPhoneDevice, 1254 mSyncManager->mPhoneDevice,
1269 KOPrefs::instance()->mPhoneConnection, 1255 mSyncManager->mPhoneConnection,
1270 KOPrefs::instance()->mPhoneModel); 1256 mSyncManager->mPhoneModel);
1271 loadSuccess = phoneFormat->load( calendar,mCalendar); 1257 loadSuccess = phoneFormat->load( calendar,mCalendar);
1272 1258
1273 } else 1259 } else
1274 return; 1260 return;
1275 if ( loadSuccess ) { 1261 if ( loadSuccess ) {
1276 getEventViewerDialog()->setSyncMode( true ); 1262 getEventViewerDialog()->setSyncMode( true );
1277 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1263 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1278 getEventViewerDialog()->setSyncMode( false ); 1264 getEventViewerDialog()->setSyncMode( false );
1279 qApp->processEvents(); 1265 qApp->processEvents();
1280 if ( syncOK ) { 1266 if ( syncOK ) {
1281 if ( KOPrefs::instance()->mWriteBackFile ) 1267 if ( mSyncManager->mWriteBackFile )
1282 { 1268 {
1283 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1269 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1284 Incidence* inc = iL.first(); 1270 Incidence* inc = iL.first();
1285 if ( phoneFormat ) { 1271 if ( phoneFormat ) {
1286 while ( inc ) { 1272 while ( inc ) {
1287 inc->removeID(mCurrentSyncDevice); 1273 inc->removeID(mCurrentSyncDevice);
1288 inc = iL.next(); 1274 inc = iL.next();
1289 } 1275 }
1290 } 1276 }
1291#ifndef DESKTOP_VERSION 1277#ifndef DESKTOP_VERSION
1292 if ( sharpFormat ) 1278 if ( sharpFormat )
1293 sharpFormat->save(calendar); 1279 sharpFormat->save(calendar);
1294#endif 1280#endif
1295 if ( phoneFormat ) 1281 if ( phoneFormat )
1296 phoneFormat->save(calendar); 1282 phoneFormat->save(calendar);
1297 iL = calendar->rawIncidences(); 1283 iL = calendar->rawIncidences();
1298 inc = iL.first(); 1284 inc = iL.first();
1299 Incidence* loc; 1285 Incidence* loc;
1300 while ( inc ) { 1286 while ( inc ) {
1301 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1287 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1302 loc = mCalendar->incidence(inc->uid() ); 1288 loc = mCalendar->incidence(inc->uid() );
1303 if ( loc ) { 1289 if ( loc ) {
1304 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1290 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1305 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1291 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1306 } 1292 }
1307 } 1293 }
1308 inc = iL.next(); 1294 inc = iL.next();
1309 } 1295 }
1310 Incidence* lse = getLastSyncEvent(); 1296 Incidence* lse = getLastSyncEvent();
1311 if ( lse ) { 1297 if ( lse ) {
1312 lse->setReadOnly( false ); 1298 lse->setReadOnly( false );
1313 lse->setDescription( "" ); 1299 lse->setDescription( "" );
1314 lse->setReadOnly( true ); 1300 lse->setReadOnly( true );
1315 } 1301 }
1316 } 1302 }
1317 } 1303 }
1318 setModified( true ); 1304 setModified( true );
1319 } else { 1305 } else {
1320 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1306 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1321 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1307 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1322 question, i18n("Ok")) ; 1308 question, i18n("Ok")) ;
1323 1309
1324 } 1310 }
1325 delete calendar; 1311 delete calendar;
1326 updateView(); 1312 updateView();
1327 return ;//syncOK; 1313 return ;//syncOK;
1328 1314
1329} 1315}
1330void CalendarView::syncSharp() 1316void CalendarView::syncSharp()
1331{ 1317{
1332 syncExternal( 0 ); 1318 //DELETE
1333 1319
1334} 1320}
1335 1321
1336 1322
1337bool CalendarView::importBday() 1323bool CalendarView::importBday()
1338{ 1324{
1339#ifndef KORG_NOKABC 1325#ifndef KORG_NOKABC
1340 1326
1341#ifdef DESKTOP_VERSION 1327#ifdef DESKTOP_VERSION
1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1328 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1343 KABC::AddressBook::Iterator it; 1329 KABC::AddressBook::Iterator it;
1344 int count = 0; 1330 int count = 0;
1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1331 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1346 ++count; 1332 ++count;
1347 } 1333 }
1348 QProgressBar bar(count,0 ); 1334 QProgressBar bar(count,0 );
1349 int w = 300; 1335 int w = 300;
1350 if ( QApplication::desktop()->width() < 320 ) 1336 if ( QApplication::desktop()->width() < 320 )
1351 w = 220; 1337 w = 220;
1352 int h = bar.sizeHint().height() ; 1338 int h = bar.sizeHint().height() ;
1353 int dw = QApplication::desktop()->width(); 1339 int dw = QApplication::desktop()->width();
1354 int dh = QApplication::desktop()->height(); 1340 int dh = QApplication::desktop()->height();
1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1341 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1356 bar.show(); 1342 bar.show();
1357 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1343 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1358 qApp->processEvents(); 1344 qApp->processEvents();
1359 count = 0; 1345 count = 0;
1360 int addCount = 0; 1346 int addCount = 0;
1361 KCal::Attendee* a = 0; 1347 KCal::Attendee* a = 0;
1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1363 if ( ! bar.isVisible() ) 1349 if ( ! bar.isVisible() )
1364 return false; 1350 return false;
1365 bar.setProgress( count++ ); 1351 bar.setProgress( count++ );
1366 qApp->processEvents(); 1352 qApp->processEvents();
1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1353 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1368 if ( (*it).birthday().date().isValid() ){ 1354 if ( (*it).birthday().date().isValid() ){
1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1355 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1356 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1371 ++addCount; 1357 ++addCount;
1372 } 1358 }
1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1359 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1374 if ( anni.isValid() ){ 1360 if ( anni.isValid() ){
1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1361 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1362 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1377 ++addCount; 1363 ++addCount;
1378 } 1364 }
1379 } 1365 }
1380 updateView(); 1366 updateView();
@@ -1472,119 +1458,119 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
1472 1458
1473 1459
1474 1460
1475bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1461bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1476{ 1462{
1477 //qDebug("addAnni "); 1463 //qDebug("addAnni ");
1478 Event * ev = new Event(); 1464 Event * ev = new Event();
1479 if ( a ) { 1465 if ( a ) {
1480 ev->addAttendee( a ); 1466 ev->addAttendee( a );
1481 } 1467 }
1482 QString kind; 1468 QString kind;
1483 if ( birthday ) 1469 if ( birthday )
1484 kind = i18n( "Birthday" ); 1470 kind = i18n( "Birthday" );
1485 else 1471 else
1486 kind = i18n( "Anniversary" ); 1472 kind = i18n( "Anniversary" );
1487 ev->setSummary( name + " - " + kind ); 1473 ev->setSummary( name + " - " + kind );
1488 ev->setOrganizer( "nobody@nowhere" ); 1474 ev->setOrganizer( "nobody@nowhere" );
1489 ev->setCategories( kind ); 1475 ev->setCategories( kind );
1490 ev->setDtStart( QDateTime(date) ); 1476 ev->setDtStart( QDateTime(date) );
1491 ev->setDtEnd( QDateTime(date) ); 1477 ev->setDtEnd( QDateTime(date) );
1492 ev->setFloats( true ); 1478 ev->setFloats( true );
1493 Recurrence * rec = ev->recurrence(); 1479 Recurrence * rec = ev->recurrence();
1494 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1480 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1495 rec->addYearlyNum( date.month() ); 1481 rec->addYearlyNum( date.month() );
1496 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1482 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1497 delete ev; 1483 delete ev;
1498 return false; 1484 return false;
1499 } 1485 }
1500 return true; 1486 return true;
1501 1487
1502} 1488}
1503bool CalendarView::importQtopia( const QString &categories, 1489bool CalendarView::importQtopia( const QString &categories,
1504 const QString &datebook, 1490 const QString &datebook,
1505 const QString &todolist ) 1491 const QString &todolist )
1506{ 1492{
1507 1493
1508 QtopiaFormat qtopiaFormat; 1494 QtopiaFormat qtopiaFormat;
1509 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1495 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1510 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1496 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1511 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1497 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1512 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1498 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1513 1499
1514 updateView(); 1500 updateView();
1515 return true; 1501 return true;
1516 1502
1517#if 0 1503#if 0
1518 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1504 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1519 mCurrentSyncDevice = "qtopia-XML"; 1505 mCurrentSyncDevice = "qtopia-XML";
1520 if ( KOPrefs::instance()->mAskForPreferences ) 1506 if ( mSyncManager->mAskForPreferences )
1521 edit_sync_options(); 1507 edit_sync_options();
1522 qApp->processEvents(); 1508 qApp->processEvents();
1523 CalendarLocal* calendar = new CalendarLocal(); 1509 CalendarLocal* calendar = new CalendarLocal();
1524 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1510 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1525 bool syncOK = false; 1511 bool syncOK = false;
1526 QtopiaFormat qtopiaFormat; 1512 QtopiaFormat qtopiaFormat;
1527 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1513 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1528 bool loadOk = true; 1514 bool loadOk = true;
1529 if ( !categories.isEmpty() ) 1515 if ( !categories.isEmpty() )
1530 loadOk = qtopiaFormat.load( calendar, categories ); 1516 loadOk = qtopiaFormat.load( calendar, categories );
1531 if ( loadOk && !datebook.isEmpty() ) 1517 if ( loadOk && !datebook.isEmpty() )
1532 loadOk = qtopiaFormat.load( calendar, datebook ); 1518 loadOk = qtopiaFormat.load( calendar, datebook );
1533 if ( loadOk && !todolist.isEmpty() ) 1519 if ( loadOk && !todolist.isEmpty() )
1534 loadOk = qtopiaFormat.load( calendar, todolist ); 1520 loadOk = qtopiaFormat.load( calendar, todolist );
1535 1521
1536 if ( loadOk ) { 1522 if ( loadOk ) {
1537 getEventViewerDialog()->setSyncMode( true ); 1523 getEventViewerDialog()->setSyncMode( true );
1538 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1524 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1539 getEventViewerDialog()->setSyncMode( false ); 1525 getEventViewerDialog()->setSyncMode( false );
1540 qApp->processEvents(); 1526 qApp->processEvents();
1541 if ( syncOK ) { 1527 if ( syncOK ) {
1542 if ( KOPrefs::instance()->mWriteBackFile ) 1528 if ( mSyncManager->mWriteBackFile )
1543 { 1529 {
1544 // write back XML file 1530 // write back XML file
1545 1531
1546 } 1532 }
1547 setModified( true ); 1533 setModified( true );
1548 } 1534 }
1549 } else { 1535 } else {
1550 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1536 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1551 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1537 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1552 question, i18n("Ok")) ; 1538 question, i18n("Ok")) ;
1553 } 1539 }
1554 delete calendar; 1540 delete calendar;
1555 updateView(); 1541 updateView();
1556 return syncOK; 1542 return syncOK;
1557 1543
1558 1544
1559#endif 1545#endif
1560 1546
1561} 1547}
1562 1548
1563void CalendarView::setSyncEventsReadOnly() 1549void CalendarView::setSyncEventsReadOnly()
1564{ 1550{
1565 Event * ev; 1551 Event * ev;
1566 QPtrList<Event> eL = mCalendar->rawEvents(); 1552 QPtrList<Event> eL = mCalendar->rawEvents();
1567 ev = eL.first(); 1553 ev = eL.first();
1568 while ( ev ) { 1554 while ( ev ) {
1569 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1555 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1570 ev->setReadOnly( true ); 1556 ev->setReadOnly( true );
1571 ev = eL.next(); 1557 ev = eL.next();
1572 } 1558 }
1573} 1559}
1574bool CalendarView::openCalendar(QString filename, bool merge) 1560bool CalendarView::openCalendar(QString filename, bool merge)
1575{ 1561{
1576 1562
1577 if (filename.isEmpty()) { 1563 if (filename.isEmpty()) {
1578 return false; 1564 return false;
1579 } 1565 }
1580 1566
1581 if (!QFile::exists(filename)) { 1567 if (!QFile::exists(filename)) {
1582 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1568 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1583 return false; 1569 return false;
1584 } 1570 }
1585 1571
1586 globalFlagBlockAgenda = 1; 1572 globalFlagBlockAgenda = 1;
1587 if (!merge) mCalendar->close(); 1573 if (!merge) mCalendar->close();
1588 1574
1589 mStorage->setFileName( filename ); 1575 mStorage->setFileName( filename );
1590 1576
@@ -1638,101 +1624,101 @@ void CalendarView::setLoadedFileVersion(QDateTime dt)
1638{ 1624{
1639 loadedFileVersion = dt; 1625 loadedFileVersion = dt;
1640} 1626}
1641bool CalendarView::checkFileChanged(QString fn) 1627bool CalendarView::checkFileChanged(QString fn)
1642{ 1628{
1643 QFileInfo finf ( fn ); 1629 QFileInfo finf ( fn );
1644 if ( !finf.exists() ) 1630 if ( !finf.exists() )
1645 return true; 1631 return true;
1646 QDateTime dt = finf.lastModified (); 1632 QDateTime dt = finf.lastModified ();
1647 if ( dt <= loadedFileVersion ) 1633 if ( dt <= loadedFileVersion )
1648 return false; 1634 return false;
1649 return true; 1635 return true;
1650 1636
1651} 1637}
1652void CalendarView::watchSavedFile() 1638void CalendarView::watchSavedFile()
1653{ 1639{
1654 QFileInfo finf ( MainWindow::defaultFileName()); 1640 QFileInfo finf ( MainWindow::defaultFileName());
1655 if ( !finf.exists() ) 1641 if ( !finf.exists() )
1656 return; 1642 return;
1657 QDateTime dt = finf.lastModified (); 1643 QDateTime dt = finf.lastModified ();
1658 if ( dt < loadedFileVersion ) { 1644 if ( dt < loadedFileVersion ) {
1659 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1645 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1660 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1646 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1661 return; 1647 return;
1662 } 1648 }
1663 loadedFileVersion = dt; 1649 loadedFileVersion = dt;
1664} 1650}
1665 1651
1666bool CalendarView::checkFileVersion(QString fn) 1652bool CalendarView::checkFileVersion(QString fn)
1667{ 1653{
1668 QFileInfo finf ( fn ); 1654 QFileInfo finf ( fn );
1669 if ( !finf.exists() ) 1655 if ( !finf.exists() )
1670 return true; 1656 return true;
1671 QDateTime dt = finf.lastModified (); 1657 QDateTime dt = finf.lastModified ();
1672 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1658 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1673 //qDebug("file on disk version %s",dt.toString().latin1()); 1659 //qDebug("file on disk version %s",dt.toString().latin1());
1674 if ( dt <= loadedFileVersion ) 1660 if ( dt <= loadedFileVersion )
1675 return true; 1661 return true;
1676 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1662 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1677 i18n("KO/Pi Warning"),i18n("Overwrite"), 1663 i18n("KO/Pi Warning"),i18n("Overwrite"),
1678 i18n("Sync+save")); 1664 i18n("Sync+save"));
1679 1665
1680 if ( km == KMessageBox::Cancel ) 1666 if ( km == KMessageBox::Cancel )
1681 return false; 1667 return false;
1682 if ( km == KMessageBox::Yes ) 1668 if ( km == KMessageBox::Yes )
1683 return true; 1669 return true;
1684 1670
1685 setSyncDevice("deleteaftersync" ); 1671 setSyncDevice("deleteaftersync" );
1686 KOPrefs::instance()->mAskForPreferences = true; 1672 mSyncManager->mAskForPreferences = true;
1687 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1673 mSyncManager->mSyncAlgoPrefs = 3;
1688 KOPrefs::instance()->mWriteBackFile = false; 1674 mSyncManager->mWriteBackFile = false;
1689 KOPrefs::instance()->mWriteBackExistingOnly = false; 1675 mSyncManager->mWriteBackExistingOnly = false;
1690 KOPrefs::instance()->mShowSyncSummary = false; 1676 mSyncManager->mShowSyncSummary = false;
1691 syncCalendar( fn, 3 ); 1677 syncCalendar( fn, 3 );
1692 Event * e = getLastSyncEvent(); 1678 Event * e = getLastSyncEvent();
1693 mCalendar->deleteEvent ( e ); 1679 mCalendar->deleteEvent ( e );
1694 updateView(); 1680 updateView();
1695 return true; 1681 return true;
1696} 1682}
1697 1683
1698bool CalendarView::saveCalendar( QString filename ) 1684bool CalendarView::saveCalendar( QString filename )
1699{ 1685{
1700 1686
1701 // Store back all unsaved data into calendar object 1687 // Store back all unsaved data into calendar object
1702 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1688 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1703 if ( mViewManager->currentView() ) 1689 if ( mViewManager->currentView() )
1704 mViewManager->currentView()->flushView(); 1690 mViewManager->currentView()->flushView();
1705 1691
1706 //mStorage->setFileName( filename ); 1692 //mStorage->setFileName( filename );
1707 1693
1708 mStorage->setSaveFormat( new ICalFormat() ); 1694 mStorage->setSaveFormat( new ICalFormat() );
1709 mStorage->setFileName( filename ); 1695 mStorage->setFileName( filename );
1710 bool success; 1696 bool success;
1711 success = mStorage->save(); 1697 success = mStorage->save();
1712 if ( !success ) { 1698 if ( !success ) {
1713 return false; 1699 return false;
1714 } 1700 }
1715 1701
1716 return true; 1702 return true;
1717} 1703}
1718 1704
1719void CalendarView::closeCalendar() 1705void CalendarView::closeCalendar()
1720{ 1706{
1721 1707
1722 // child windows no longer valid 1708 // child windows no longer valid
1723 emit closingDown(); 1709 emit closingDown();
1724 1710
1725 mCalendar->close(); 1711 mCalendar->close();
1726 setModified(false); 1712 setModified(false);
1727 updateView(); 1713 updateView();
1728} 1714}
1729 1715
1730void CalendarView::archiveCalendar() 1716void CalendarView::archiveCalendar()
1731{ 1717{
1732 mDialogManager->showArchiveDialog(); 1718 mDialogManager->showArchiveDialog();
1733} 1719}
1734 1720
1735 1721
1736void CalendarView::readSettings() 1722void CalendarView::readSettings()
1737{ 1723{
1738 1724
@@ -2153,143 +2139,97 @@ void CalendarView::edit_cut()
2153 } 2139 }
2154 2140
2155 if (!anEvent) { 2141 if (!anEvent) {
2156 KNotifyClient::beep(); 2142 KNotifyClient::beep();
2157 return; 2143 return;
2158 } 2144 }
2159 DndFactory factory( mCalendar ); 2145 DndFactory factory( mCalendar );
2160 factory.cutEvent(anEvent); 2146 factory.cutEvent(anEvent);
2161 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2147 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2162} 2148}
2163 2149
2164void CalendarView::edit_copy() 2150void CalendarView::edit_copy()
2165{ 2151{
2166 Event *anEvent=0; 2152 Event *anEvent=0;
2167 2153
2168 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2154 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2169 2155
2170 if (mViewManager->currentView()->isEventView()) { 2156 if (mViewManager->currentView()->isEventView()) {
2171 if ( incidence && incidence->type() == "Event" ) { 2157 if ( incidence && incidence->type() == "Event" ) {
2172 anEvent = static_cast<Event *>(incidence); 2158 anEvent = static_cast<Event *>(incidence);
2173 } 2159 }
2174 } 2160 }
2175 2161
2176 if (!anEvent) { 2162 if (!anEvent) {
2177 KNotifyClient::beep(); 2163 KNotifyClient::beep();
2178 return; 2164 return;
2179 } 2165 }
2180 DndFactory factory( mCalendar ); 2166 DndFactory factory( mCalendar );
2181 factory.copyEvent(anEvent); 2167 factory.copyEvent(anEvent);
2182} 2168}
2183 2169
2184void CalendarView::edit_paste() 2170void CalendarView::edit_paste()
2185{ 2171{
2186 QDate date = mNavigator->selectedDates().first(); 2172 QDate date = mNavigator->selectedDates().first();
2187 2173
2188 DndFactory factory( mCalendar ); 2174 DndFactory factory( mCalendar );
2189 Event *pastedEvent = factory.pasteEvent( date ); 2175 Event *pastedEvent = factory.pasteEvent( date );
2190 2176
2191 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2177 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2192} 2178}
2193 2179
2194void CalendarView::edit_options() 2180void CalendarView::edit_options()
2195{ 2181{
2196 mDialogManager->showOptionsDialog(); 2182 mDialogManager->showOptionsDialog();
2197 //writeSettings(); 2183 //writeSettings();
2198} 2184}
2199void CalendarView::edit_sync_options() 2185void CalendarView::edit_sync_options()
2200{ 2186{
2201 //mDialogManager->showSyncOptions(); 2187 // DELETE
2202 //KOPrefs::instance()->mSyncAlgoPrefs
2203 QDialog dia( this, "dia", true );
2204 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2205 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2206 QVBoxLayout lay ( &dia );
2207 lay.setSpacing( 2 );
2208 lay.setMargin( 3 );
2209 lay.addWidget(&gr);
2210 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2211 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2212 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2213 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2214 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2215 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2216 //QRadioButton both( i18n("Take both on conflict"), &gr );
2217 QPushButton pb ( "OK", &dia);
2218 lay.addWidget( &pb );
2219 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2220 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2221 case 0:
2222 loc.setChecked( true);
2223 break;
2224 case 1:
2225 rem.setChecked( true );
2226 break;
2227 case 2:
2228 newest.setChecked( true);
2229 break;
2230 case 3:
2231 ask.setChecked( true);
2232 break;
2233 case 4:
2234 f_loc.setChecked( true);
2235 break;
2236 case 5:
2237 f_rem.setChecked( true);
2238 break;
2239 case 6:
2240 // both.setChecked( true);
2241 break;
2242 default:
2243 break;
2244 }
2245 if ( dia.exec() ) {
2246 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2247 }
2248 2188
2249} 2189}
2250 2190
2251void CalendarView::slotSelectPickerDate( QDate d) 2191void CalendarView::slotSelectPickerDate( QDate d)
2252{ 2192{
2253 mDateFrame->hide(); 2193 mDateFrame->hide();
2254 if ( mDatePickerMode == 1 ) { 2194 if ( mDatePickerMode == 1 ) {
2255 mNavigator->slotDaySelect( d ); 2195 mNavigator->slotDaySelect( d );
2256 } else if ( mDatePickerMode == 2 ) { 2196 } else if ( mDatePickerMode == 2 ) {
2257 if ( mMoveIncidence->type() == "Todo" ) { 2197 if ( mMoveIncidence->type() == "Todo" ) {
2258 Todo * to = (Todo *) mMoveIncidence; 2198 Todo * to = (Todo *) mMoveIncidence;
2259 QTime tim; 2199 QTime tim;
2260 if ( to->hasDueDate() ) 2200 if ( to->hasDueDate() )
2261 tim = to->dtDue().time(); 2201 tim = to->dtDue().time();
2262 else { 2202 else {
2263 tim = QTime ( 0,0,0 ); 2203 tim = QTime ( 0,0,0 );
2264 to->setFloats( true ); 2204 to->setFloats( true );
2265 to->setHasDueDate( true ); 2205 to->setHasDueDate( true );
2266 } 2206 }
2267 QDateTime dt ( d,tim ); 2207 QDateTime dt ( d,tim );
2268 to->setDtDue( dt ); 2208 to->setDtDue( dt );
2269 todoChanged( to ); 2209 todoChanged( to );
2270 } else { 2210 } else {
2271 QTime tim = mMoveIncidence->dtStart().time(); 2211 QTime tim = mMoveIncidence->dtStart().time();
2272 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2212 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2273 QDateTime dt ( d,tim ); 2213 QDateTime dt ( d,tim );
2274 mMoveIncidence->setDtStart( dt ); 2214 mMoveIncidence->setDtStart( dt );
2275 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2215 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2276 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2216 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2277 } 2217 }
2278 2218
2279 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2219 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2280 } 2220 }
2281} 2221}
2282 2222
2283void CalendarView::removeCategories() 2223void CalendarView::removeCategories()
2284{ 2224{
2285 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2225 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2286 QStringList catList = KOPrefs::instance()->mCustomCategories; 2226 QStringList catList = KOPrefs::instance()->mCustomCategories;
2287 QStringList catIncList; 2227 QStringList catIncList;
2288 QStringList newCatList; 2228 QStringList newCatList;
2289 Incidence* inc = incList.first(); 2229 Incidence* inc = incList.first();
2290 int i; 2230 int i;
2291 int count = 0; 2231 int count = 0;
2292 while ( inc ) { 2232 while ( inc ) {
2293 newCatList.clear(); 2233 newCatList.clear();
2294 catIncList = inc->categories() ; 2234 catIncList = inc->categories() ;
2295 for( i = 0; i< catIncList.count(); ++i ) { 2235 for( i = 0; i< catIncList.count(); ++i ) {
@@ -3723,51 +3663,71 @@ bool CalendarView::removeCompletedSubTodos( Todo* t )
3723 return deleteTodo; 3663 return deleteTodo;
3724 3664
3725} 3665}
3726void CalendarView::purgeCompleted() 3666void CalendarView::purgeCompleted()
3727{ 3667{
3728 int result = KMessageBox::warningContinueCancel(this, 3668 int result = KMessageBox::warningContinueCancel(this,
3729 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3669 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3730 3670
3731 if (result == KMessageBox::Continue) { 3671 if (result == KMessageBox::Continue) {
3732 3672
3733 QPtrList<Todo> todoCal; 3673 QPtrList<Todo> todoCal;
3734 QPtrList<Todo> rootTodos; 3674 QPtrList<Todo> rootTodos;
3735 //QPtrList<Incidence> rel; 3675 //QPtrList<Incidence> rel;
3736 Todo *aTodo;//, *rTodo; 3676 Todo *aTodo;//, *rTodo;
3737 Incidence *rIncidence; 3677 Incidence *rIncidence;
3738 bool childDelete = false; 3678 bool childDelete = false;
3739 bool deletedOne = true; 3679 bool deletedOne = true;
3740 todoCal = calendar()->todos(); 3680 todoCal = calendar()->todos();
3741 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3681 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3742 if ( !aTodo->relatedTo() ) 3682 if ( !aTodo->relatedTo() )
3743 rootTodos.append( aTodo ); 3683 rootTodos.append( aTodo );
3744 } 3684 }
3745 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3685 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3746 removeCompletedSubTodos( aTodo ); 3686 removeCompletedSubTodos( aTodo );
3747 } 3687 }
3748 3688
3749 updateView(); 3689 updateView();
3750 } 3690 }
3751} 3691}
3752 3692
3753void CalendarView::slotCalendarChanged() 3693void CalendarView::slotCalendarChanged()
3754{ 3694{
3755 ; 3695 ;
3756} 3696}
3757 3697
3758NavigatorBar *CalendarView::navigatorBar() 3698NavigatorBar *CalendarView::navigatorBar()
3759{ 3699{
3760 return mNavigatorBar; 3700 return mNavigatorBar;
3761} 3701}
3762 3702
3763 3703
3764 3704
3765void CalendarView::keyPressEvent ( QKeyEvent *e) 3705void CalendarView::keyPressEvent ( QKeyEvent *e)
3766{ 3706{
3767 //qDebug(" alendarView::keyPressEvent "); 3707 //qDebug(" alendarView::keyPressEvent ");
3768 e->ignore(); 3708 e->ignore();
3769} 3709}
3770 3710
3771//#include "calendarview.moc"
3772 3711
3773//#include "calendarviewbase.moc" 3712bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3713{
3714 // mSyncManager = manager;
3715 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3716 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3717 return syncCalendar( filename, mode );
3718}
3719bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3720{
3721 //mSyncManager = manager;
3722 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3723 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3724 if ( resource == "sharp" )
3725 syncExternal( 0 );
3726 if ( resource == "phone" )
3727 syncExternal( 1 );
3728 // pending setmodified
3729}
3730void CalendarView::setSyncManager(KSyncManager* manager)
3731{
3732 mSyncManager = manager;
3733}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 8d329a9..751b8d9 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,128 +1,130 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h>
46
45class QWidgetStack; 47class QWidgetStack;
46class QSplitter; 48class QSplitter;
47 49
48class CalPrinter; 50class CalPrinter;
49class KOFilterView; 51class KOFilterView;
50class KOViewManager; 52class KOViewManager;
51class KODialogManager; 53class KODialogManager;
52class KOTodoView; 54class KOTodoView;
53class KDateNavigator; 55class KDateNavigator;
54class DateNavigator; 56class DateNavigator;
55class KOIncidenceEditor; 57class KOIncidenceEditor;
56class KDatePicker; 58class KDatePicker;
57class ResourceView; 59class ResourceView;
58class NavigatorBar; 60class NavigatorBar;
59class KOEventEditor; 61class KOEventEditor;
60class KOTodoEditor ; 62class KOTodoEditor ;
61class KOEventViewerDialog; 63class KOEventViewerDialog;
62class KOBeamPrefs; 64class KOBeamPrefs;
63class KSyncProfile; 65class KSyncProfile;
64class AlarmDialog; 66class AlarmDialog;
65class KCal::Attendee; 67class KCal::Attendee;
66 68
67namespace KCal { class FileStorage; } 69namespace KCal { class FileStorage; }
68 70
69using namespace KCal; 71using namespace KCal;
70 72
71/** 73/**
72 This is the main calendar widget. It provides the different vies on t he 74 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation 75 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences, 76 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc. 77 event editor, search dialog etc.
76 78
77 @short main calendar view widget 79 @short main calendar view widget
78 @author Cornelius Schumacher 80 @author Cornelius Schumacher
79*/ 81*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer 82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
81{ 83{
82 Q_OBJECT 84 Q_OBJECT
83 public: 85 public:
84 /** 86 /**
85 Constructs a new calendar view widget. 87 Constructs a new calendar view widget.
86 88
87 @param calendar calendar document 89 @param calendar calendar document
88 @param parent parent window 90 @param parent parent window
89 @param name Qt internal widget object name 91 @param name Qt internal widget object name
90 */ 92 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 93 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 ); 94 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0, 95 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 96 const char *name = 0 );
95 virtual ~CalendarView(); 97 virtual ~CalendarView();
96 98
97 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
98 100
99 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
100 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
101 103
102 QDate startDate(); 104 QDate startDate();
103 QDate endDate(); 105 QDate endDate();
104 106
105 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
106 QWidget *leftFrame(); 108 QWidget *leftFrame();
107 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
108 110
109 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
111 113
112 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 117 Incidence *currentSelection();
116 118
117 signals: 119 signals:
118 /** This todo has been modified */ 120 /** This todo has been modified */
119 void todoModified(Todo *, int); 121 void todoModified(Todo *, int);
120 122
121 /** when change is made to options dialog, the topwidget will catch this 123 /** when change is made to options dialog, the topwidget will catch this
122 * and emit this signal which notifies all widgets which have registered 124 * and emit this signal which notifies all widgets which have registered
123 * for notification to update their settings. */ 125 * for notification to update their settings. */
124 void configChanged(); 126 void configChanged();
125 /** emitted when the topwidget is closing down, so that any attached 127 /** emitted when the topwidget is closing down, so that any attached
126 child windows can also close. */ 128 child windows can also close. */
127 void closingDown(); 129 void closingDown();
128 /** emitted right before we die */ 130 /** emitted right before we die */
@@ -415,120 +417,125 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
415 void toggleDateNavigatorWidget(); 417 void toggleDateNavigatorWidget();
416 void toggleAllDaySize(); 418 void toggleAllDaySize();
417 void dialogClosing(Incidence *); 419 void dialogClosing(Incidence *);
418 420
419 /** Look for new messages in the inbox */ 421 /** Look for new messages in the inbox */
420 void lookForIncomingMessages(); 422 void lookForIncomingMessages();
421 /** Look for new messages in the outbox */ 423 /** Look for new messages in the outbox */
422 void lookForOutgoingMessages(); 424 void lookForOutgoingMessages();
423 425
424 void processMainViewSelection( Incidence * ); 426 void processMainViewSelection( Incidence * );
425 void processTodoListSelection( Incidence * ); 427 void processTodoListSelection( Incidence * );
426 428
427 void processIncidenceSelection( Incidence * ); 429 void processIncidenceSelection( Incidence * );
428 430
429 void purgeCompleted(); 431 void purgeCompleted();
430 bool removeCompletedSubTodos( Todo* ); 432 bool removeCompletedSubTodos( Todo* );
431 void slotCalendarChanged(); 433 void slotCalendarChanged();
432 bool importBday(); 434 bool importBday();
433 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 435 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
434 bool importQtopia( const QString &categoriesFile, 436 bool importQtopia( const QString &categoriesFile,
435 const QString &datebookFile, 437 const QString &datebookFile,
436 const QString &tasklistFile ); 438 const QString &tasklistFile );
437 void syncSharp( ); 439 void syncSharp( );
438 void syncPhone( ); 440 void syncPhone( );
439 void syncExternal( int mode ); 441 void syncExternal( int mode );
440 void slotSelectPickerDate( QDate ) ; 442 void slotSelectPickerDate( QDate ) ;
441 void showDatePicker( ) ; 443 void showDatePicker( ) ;
442 void moveIncidence(Incidence *) ; 444 void moveIncidence(Incidence *) ;
443 void beamIncidence(Incidence *) ; 445 void beamIncidence(Incidence *) ;
444 void beamCalendar() ; 446 void beamCalendar() ;
445 void beamFilteredCalendar() ; 447 void beamFilteredCalendar() ;
446 void beamIncidenceList(QPtrList<Incidence>) ; 448 void beamIncidenceList(QPtrList<Incidence>) ;
447 void manageCategories(); 449 void manageCategories();
448 int addCategories(); 450 int addCategories();
449 void removeCategories(); 451 void removeCategories();
450 void setSyncDevice( QString ); 452 void setSyncDevice( QString );
451 void setSyncName( QString ); 453 void setSyncName( QString );
452 protected slots: 454 protected slots:
453 void timerAlarm(); 455 void timerAlarm();
454 void suspendAlarm(); 456 void suspendAlarm();
455 void beamDone( Ir *ir ); 457 void beamDone( Ir *ir );
456 /** Select a view or adapt the current view to display the specified dates. */ 458 /** Select a view or adapt the current view to display the specified dates. */
457 void showDates( const KCal::DateList & ); 459 void showDates( const KCal::DateList & );
458 void selectWeekNum ( int ); 460 void selectWeekNum ( int );
459 461
460 public: 462 public:
461 // show a standard warning 463 // show a standard warning
462 // returns KMsgBox::yesNoCancel() 464 // returns KMsgBox::yesNoCancel()
463 int msgCalModified(); 465 int msgCalModified();
466 virtual bool sync(KSyncManager* manager, QString filename, int mode);
467
468 virtual bool syncExternal(KSyncManager* manager, QString resource);
464 void confSync(); 469 void confSync();
470 void setSyncManager(KSyncManager* manager);
465 void setLoadedFileVersion(QDateTime); 471 void setLoadedFileVersion(QDateTime);
466 bool checkFileVersion(QString fn); 472 bool checkFileVersion(QString fn);
467 bool checkFileChanged(QString fn); 473 bool checkFileChanged(QString fn);
468 Event* getLastSyncEvent(); 474 Event* getLastSyncEvent();
469 /** Adapt navigation units correpsonding to step size of navigation of the 475 /** Adapt navigation units correpsonding to step size of navigation of the
470 * current view. 476 * current view.
471 */ 477 */
472 void adaptNavigationUnits(); 478 void adaptNavigationUnits();
473 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 479 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
474 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 480 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
475 //Attendee* getYourAttendee(Event *event); 481 //Attendee* getYourAttendee(Event *event);
476 protected: 482 protected:
477 void schedule(Scheduler::Method, Incidence *incidence = 0); 483 void schedule(Scheduler::Method, Incidence *incidence = 0);
478 484
479 // returns KMsgBox::OKCandel() 485 // returns KMsgBox::OKCandel()
480 int msgItemDelete(); 486 int msgItemDelete();
481 void showEventEditor(); 487 void showEventEditor();
482 void showTodoEditor(); 488 void showTodoEditor();
483 void writeLocale(); 489 void writeLocale();
484 Todo *selectedTodo(); 490 Todo *selectedTodo();
485 491
486 private: 492 private:
493 KSyncManager* mSyncManager;
487 AlarmDialog * mAlarmDialog; 494 AlarmDialog * mAlarmDialog;
488 QString mAlarmNotification; 495 QString mAlarmNotification;
489 QString mSuspendAlarmNotification; 496 QString mSuspendAlarmNotification;
490 QTimer* mSuspendTimer; 497 QTimer* mSuspendTimer;
491 QTimer* mAlarmTimer; 498 QTimer* mAlarmTimer;
492 QTimer* mRecheckAlarmTimer; 499 QTimer* mRecheckAlarmTimer;
493 void computeAlarm( QString ); 500 void computeAlarm( QString );
494 void startAlarm( QString, QString ); 501 void startAlarm( QString, QString );
495 void setSyncEventsReadOnly(); 502 void setSyncEventsReadOnly();
496 503
497 QDateTime loadedFileVersion; 504 QDateTime loadedFileVersion;
498 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 505 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
499 void checkExternalId( Incidence * inc ); 506 void checkExternalId( Incidence * inc );
500 int mGlobalSyncMode; 507 int mGlobalSyncMode;
501 QString mCurrentSyncDevice; 508 QString mCurrentSyncDevice;
502 QString mCurrentSyncName; 509 QString mCurrentSyncName;
503 KOBeamPrefs* beamDialog; 510 KOBeamPrefs* beamDialog;
504 void init(); 511 void init();
505 int mDatePickerMode; 512 int mDatePickerMode;
506 bool mFlagEditDescription; 513 bool mFlagEditDescription;
507 QDateTime mLastCalendarSync; 514 QDateTime mLastCalendarSync;
508 void createPrinter(); 515 void createPrinter();
509 516
510 void calendarModified( bool, Calendar * ); 517 void calendarModified( bool, Calendar * );
511 518
512 CalPrinter *mCalPrinter; 519 CalPrinter *mCalPrinter;
513 520
514 QSplitter *mPanner; 521 QSplitter *mPanner;
515 QSplitter *mLeftSplitter; 522 QSplitter *mLeftSplitter;
516 QWidget *mLeftFrame; 523 QWidget *mLeftFrame;
517 QWidgetStack *mRightFrame; 524 QWidgetStack *mRightFrame;
518 525
519 KDatePicker* mDatePicker; 526 KDatePicker* mDatePicker;
520 QVBox* mDateFrame; 527 QVBox* mDateFrame;
521 NavigatorBar *mNavigatorBar; 528 NavigatorBar *mNavigatorBar;
522 529
523 KDateNavigator *mDateNavigator; // widget showing small month view. 530 KDateNavigator *mDateNavigator; // widget showing small month view.
524 531
525 KOFilterView *mFilterView; 532 KOFilterView *mFilterView;
526 533
527 ResourceView *mResourceView; 534 ResourceView *mResourceView;
528 535
529 // calendar object for this viewing instance 536 // calendar object for this viewing instance
530 Calendar *mCalendar; 537 Calendar *mCalendar;
531 538
532 CalendarResourceManager *mResourceManager; 539 CalendarResourceManager *mResourceManager;
533 540
534 FileStorage *mStorage; 541 FileStorage *mStorage;
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 1210094..13035e0 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -151,118 +151,115 @@ KOPrefs::KOPrefs() :
151 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 151 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 addItemInt("Daylight Savings",&mDaylightSavings,0); 157 addItemInt("Daylight Savings",&mDaylightSavings,0);
158 KPrefs::setCurrentGroup("AlarmSettings"); 158 KPrefs::setCurrentGroup("AlarmSettings");
159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
163 163
164 164
165 KPrefs::setCurrentGroup("Calendar"); 165 KPrefs::setCurrentGroup("Calendar");
166 166
167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
168 168
169 KPrefs::setCurrentGroup("Fonts"); 169 KPrefs::setCurrentGroup("Fonts");
170 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 170 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
171 addItemFont("TimeBar Font",&mTimeBarFont); 171 addItemFont("TimeBar Font",&mTimeBarFont);
172 addItemFont("MonthView Font",&mMonthViewFont); 172 addItemFont("MonthView Font",&mMonthViewFont);
173 addItemFont("AgendaView Font",&mAgendaViewFont); 173 addItemFont("AgendaView Font",&mAgendaViewFont);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont);
176 addItemFont("TodoView Font",&mTodoViewFont); 176 addItemFont("TodoView Font",&mTodoViewFont);
177 addItemFont("ListView Font",&mListViewFont); 177 addItemFont("ListView Font",&mListViewFont);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont);
179 addItemFont("EditBox Font",&mEditBoxFont); 179 addItemFont("EditBox Font",&mEditBoxFont);
180 addItemFont("JournalView Font",&mJornalViewFont); 180 addItemFont("JournalView Font",&mJornalViewFont);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont);
182 addItemFont("EventView Font",&mEventViewFont); 182 addItemFont("EventView Font",&mEventViewFont);
183 183
184// KPrefs::setCurrentGroup("SyncProfiles"); 184// KPrefs::setCurrentGroup("SyncProfiles");
185// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 185// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
186// addItemStringList("SyncProfileNames",&mSyncProfileNames); 186// addItemStringList("SyncProfileNames",&mSyncProfileNames);
187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
188 188
189 KPrefs::setCurrentGroup("RemoteSyncing"); 189 KPrefs::setCurrentGroup("RemoteSyncing");
190// addItemBool("UsePasswd",&mUsePassWd,false); 190// addItemBool("UsePasswd",&mUsePassWd,false);
191// addItemBool("WriteBackFile",&mWriteBackFile,true); 191// addItemBool("WriteBackFile",&mWriteBackFile,true);
192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
193// addItemBool("AskForPreferences",&mAskForPreferences,true); 193// addItemBool("AskForPreferences",&mAskForPreferences,true);
194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
198 addItemInt("LastSyncTime",&mLastSyncTime,0); 198 addItemInt("LastSyncTime",&mLastSyncTime,0);
199 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
200 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
201 199
202#ifdef _WIN32_ 200#ifdef _WIN32_
203 QString hdp= locateLocal("data","korganizer")+"\\\\"; 201 QString hdp= locateLocal("data","korganizer")+"\\\\";
204#else 202#else
205 QString hdp= locateLocal("data","korganizer")+"/"; 203 QString hdp= locateLocal("data","korganizer")+"/";
206#endif 204#endif
207// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 205// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
208// addItemString("RemoteUser",&mRemoteUser, "zaurus"); 206// addItemString("RemoteUser",&mRemoteUser, "zaurus");
209// addItemString("RemotePassWd",&mRemotePassWd, ""); 207// addItemString("RemotePassWd",&mRemotePassWd, "");
210// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 208// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
211// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 209// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
212 210
213 211
214 KPrefs::setCurrentGroup("LoadSaveFileNames"); 212 KPrefs::setCurrentGroup("LoadSaveFileNames");
215 213
216 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 214 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
217 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 215 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
218 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 216 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
219 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 217 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
220 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
221 218
222 219
223 KPrefs::setCurrentGroup("Locale"); 220 KPrefs::setCurrentGroup("Locale");
224 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 221 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
225 addItemInt("PreferredTime",&mPreferredTime,0); 222 addItemInt("PreferredTime",&mPreferredTime,0);
226 addItemInt("PreferredDate",&mPreferredDate,0); 223 addItemInt("PreferredDate",&mPreferredDate,0);
227 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 224 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
228 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 225 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
229 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 226 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
230 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 227 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
231 228
232 229
233 KPrefs::setCurrentGroup("Colors"); 230 KPrefs::setCurrentGroup("Colors");
234 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 231 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
235 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 232 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
236 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 233 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
237 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 234 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
238 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 235 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
239 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 236 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
240 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 237 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
241 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 238 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
242 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 239 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
243 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 240 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
244 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 241 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
245 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 242 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
246 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 243 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
247 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 244 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
248 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 245 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
249 addItemBool("UseAppColors",&mUseAppColors,false); 246 addItemBool("UseAppColors",&mUseAppColors,false);
250 247
251 248
252 249
253 KPrefs::setCurrentGroup("Views"); 250 KPrefs::setCurrentGroup("Views");
254 addItemInt("Hour Size",&mHourSize,8); 251 addItemInt("Hour Size",&mHourSize,8);
255 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 252 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
256 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 253 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
257 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 254 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
258 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 255 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
259 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 256 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
260 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 257 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
261 addItemBool("Enable ToolTips",&mEnableToolTips,false); 258 addItemBool("Enable ToolTips",&mEnableToolTips,false);
262 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 259 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
263 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 260 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
264 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 261 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
265 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 262 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
266 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 263 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
267 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 264 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
268 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 265 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index ff09e19..03df59b 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -149,133 +149,113 @@ class KOPrefs : public KPimPrefs
149 bool mWeeklyRecur; 149 bool mWeeklyRecur;
150 bool mMonthDailyRecur; 150 bool mMonthDailyRecur;
151 bool mMonthWeeklyRecur; 151 bool mMonthWeeklyRecur;
152 bool mMonthShowIcons; 152 bool mMonthShowIcons;
153 bool mMonthShowShort; 153 bool mMonthShowShort;
154 bool mEnableToolTips; 154 bool mEnableToolTips;
155 bool mEnableMonthScroll; 155 bool mEnableMonthScroll;
156 bool mFullViewMonth; 156 bool mFullViewMonth;
157 bool mMonthViewUsesCategoryColor; 157 bool mMonthViewUsesCategoryColor;
158 bool mFullViewTodo; 158 bool mFullViewTodo;
159 bool mShowCompletedTodo; 159 bool mShowCompletedTodo;
160 bool mMarcusBainsEnabled; 160 bool mMarcusBainsEnabled;
161 int mNextXDays; 161 int mNextXDays;
162 int mWhatsNextDays; 162 int mWhatsNextDays;
163 int mWhatsNextPrios; 163 int mWhatsNextPrios;
164 bool mEnableQuickTodo; 164 bool mEnableQuickTodo;
165 bool mLanguageChanged; 165 bool mLanguageChanged;
166 166
167 bool mCompactDialogs; 167 bool mCompactDialogs;
168 bool mVerticalScreen; 168 bool mVerticalScreen;
169 169
170 bool mShowIconNewTodo; 170 bool mShowIconNewTodo;
171 bool mShowIconNewEvent; 171 bool mShowIconNewEvent;
172 bool mShowIconSearch; 172 bool mShowIconSearch;
173 bool mShowIconList; 173 bool mShowIconList;
174 bool mShowIconDay1; 174 bool mShowIconDay1;
175 bool mShowIconDay5; 175 bool mShowIconDay5;
176 bool mShowIconDay7; 176 bool mShowIconDay7;
177 bool mShowIconMonth; 177 bool mShowIconMonth;
178 bool mShowIconTodoview; 178 bool mShowIconTodoview;
179 bool mShowIconBackFast; 179 bool mShowIconBackFast;
180 bool mShowIconBack; 180 bool mShowIconBack;
181 bool mShowIconToday; 181 bool mShowIconToday;
182 bool mShowIconForward; 182 bool mShowIconForward;
183 bool mShowIconForwardFast; 183 bool mShowIconForwardFast;
184 bool mShowIconWhatsThis; 184 bool mShowIconWhatsThis;
185 bool mShowIconNextDays; 185 bool mShowIconNextDays;
186 bool mShowIconNext; 186 bool mShowIconNext;
187 bool mShowIconJournal; 187 bool mShowIconJournal;
188 188
189 bool mShowIconStretch; 189 bool mShowIconStretch;
190 190
191 bool mToolBarHor; 191 bool mToolBarHor;
192 bool mToolBarUp; 192 bool mToolBarUp;
193 bool mToolBarMiniIcons; 193 bool mToolBarMiniIcons;
194 194
195 bool mAskForQuit; 195 bool mAskForQuit;
196 bool mUsePassWd; 196 bool mUsePassWd;
197 bool mWriteBackFile;
198 int mWriteBackInFuture;
199 bool mAskForPreferences;
200 bool mShowSyncSummary;
201 bool mShowSyncEvents; 197 bool mShowSyncEvents;
202 bool mShowTodoInAgenda; 198 bool mShowTodoInAgenda;
203 bool mWriteBackExistingOnly;
204
205 QString mRemoteIP;
206 QString mRemoteUser;
207 QString mRemotePassWd;
208 QString mRemoteFile;
209 QString mLocalTempFile;
210 QString mPhoneDevice;
211 QString mPhoneConnection;
212 QString mPhoneModel;
213 199
214 int mLastSyncTime; 200 int mLastSyncTime;
215 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles;
219 QString mLocalMachineName;
220 void setCategoryColor(QString cat,const QColor & color); 201 void setCategoryColor(QString cat,const QColor & color);
221 QColor *categoryColor(QString cat); 202 QColor *categoryColor(QString cat);
222 203
223 QString mArchiveFile; 204 QString mArchiveFile;
224 QString mHtmlExportFile; 205 QString mHtmlExportFile;
225 bool mHtmlWithSave; 206 bool mHtmlWithSave;
226 207
227 QStringList mSelectedPlugins; 208 QStringList mSelectedPlugins;
228 209
229 QString mLastImportFile; 210 QString mLastImportFile;
230 QString mLastVcalFile; 211 QString mLastVcalFile;
231 QString mLastSaveFile; 212 QString mLastSaveFile;
232 QString mLastLoadFile; 213 QString mLastLoadFile;
233 QString mLastSyncedLocalFile;
234 214
235 215
236 QString mDefaultAlarmFile; 216 QString mDefaultAlarmFile;
237 int mIMIPScheduler; 217 int mIMIPScheduler;
238 int mIMIPSend; 218 int mIMIPSend;
239 QStringList mAdditionalMails; 219 QStringList mAdditionalMails;
240 int mIMIPAutoRefresh; 220 int mIMIPAutoRefresh;
241 int mIMIPAutoInsertReply; 221 int mIMIPAutoInsertReply;
242 int mIMIPAutoInsertRequest; 222 int mIMIPAutoInsertRequest;
243 int mIMIPAutoFreeBusy; 223 int mIMIPAutoFreeBusy;
244 int mIMIPAutoFreeBusyReply; 224 int mIMIPAutoFreeBusyReply;
245 225
246 QStringList mTodoTemplates; 226 QStringList mTodoTemplates;
247 QStringList mEventTemplates; 227 QStringList mEventTemplates;
248 228
249 int mDestination; 229 int mDestination;
250 230
251 231
252 bool mEditOnDoubleClick; 232 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 233 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 234 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 235 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 236 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 237 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 238 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 239 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 240 bool mWNViewShowsParents;
261 bool mWNViewShowLocation; 241 bool mWNViewShowLocation;
262 bool mTodoViewShowsPercentage; 242 bool mTodoViewShowsPercentage;
263 bool mTodoViewUsesCatColors; 243 bool mTodoViewUsesCatColors;
264 bool mTodoViewUsesSmallFont; 244 bool mTodoViewUsesSmallFont;
265 bool mTodoViewUsesForegroundColor; 245 bool mTodoViewUsesForegroundColor;
266 bool mMonthViewUsesForegroundColor; 246 bool mMonthViewUsesForegroundColor;
267 247
268 bool mHightlightDateTimeEdit; 248 bool mHightlightDateTimeEdit;
269 bool mShortDateInViewer; 249 bool mShortDateInViewer;
270 250
271 QStringList mLocationDefaults; 251 QStringList mLocationDefaults;
272 QStringList mEventSummaryUser; 252 QStringList mEventSummaryUser;
273 QStringList mTodoSummaryUser; 253 QStringList mTodoSummaryUser;
274 254
275 bool mUseInternalAlarmNotification; 255 bool mUseInternalAlarmNotification;
276 int mAlarmPlayBeeps; 256 int mAlarmPlayBeeps;
277 int mAlarmSuspendTime; 257 int mAlarmSuspendTime;
278 int mAlarmSuspendCount; 258 int mAlarmSuspendCount;
279 int mAlarmBeepInterval; 259 int mAlarmBeepInterval;
280 260
281 261
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index e3324ee..f7766f8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -81,223 +81,231 @@ class KOex2phonePrefs : public QDialog
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 mPassWordPiSync = "abc"; 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mServerSocket = 0; 133 mServerSocket = 0;
134 mClosed = false; 134 mClosed = false;
135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
136 QString confFile = locateLocal("config","korganizerrc"); 136 QString confFile = locateLocal("config","korganizerrc");
137 QFileInfo finf ( confFile ); 137 QFileInfo finf ( confFile );
138 bool showWarning = !finf.exists(); 138 bool showWarning = !finf.exists();
139 setIcon(SmallIcon( "ko24" ) ); 139 setIcon(SmallIcon( "ko24" ) );
140 mBlockAtStartup = true; 140 mBlockAtStartup = true;
141 mFlagKeyPressed = false; 141 mFlagKeyPressed = false;
142 setCaption("KOrganizer/Pi"); 142 setCaption("KOrganizer/Pi");
143 KOPrefs *p = KOPrefs::instance(); 143 KOPrefs *p = KOPrefs::instance();
144 KPimGlobalPrefs::instance()->setGlobalConfig(); 144 KPimGlobalPrefs::instance()->setGlobalConfig();
145 // if ( QApplication::desktop()->height() > 480 ) {
146// if ( p->mHourSize == 4 )
147// p->mHourSize = 6;
148// }
149 if ( p->mHourSize > 18 ) 145 if ( p->mHourSize > 18 )
150 p->mHourSize = 18; 146 p->mHourSize = 18;
151 QMainWindow::ToolBarDock tbd; 147 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 148 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 149 if ( p->mToolBarUp )
154 tbd = Bottom; 150 tbd = Bottom;
155 else 151 else
156 tbd = Top; 152 tbd = Top;
157 } 153 }
158 else { 154 else {
159 if ( p->mToolBarUp ) 155 if ( p->mToolBarUp )
160 tbd = Right; 156 tbd = Right;
161 else 157 else
162 tbd = Left; 158 tbd = Left;
163 } 159 }
164 if ( KOPrefs::instance()->mUseAppColors ) 160 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 161 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 162 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 163 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 164 addToolBar (iconToolBar , tbd );
169 mBlockSaveFlag = false;
170 mCalendarModifiedFlag = false; 165 mCalendarModifiedFlag = false;
171 166
172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 167 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
173 splash->setAlignment ( AlignCenter ); 168 splash->setAlignment ( AlignCenter );
174 setCentralWidget( splash ); 169 setCentralWidget( splash );
175#ifndef DESKTOP_VERSION 170#ifndef DESKTOP_VERSION
176 showMaximized(); 171 showMaximized();
177#endif 172#endif
178 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 173 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
179 setDefaultPreferences(); 174 setDefaultPreferences();
180 mCalendar = new CalendarLocal(); 175 mCalendar = new CalendarLocal();
181 mView = new CalendarView( mCalendar, this,"mCalendar " ); 176 mView = new CalendarView( mCalendar, this,"mCalendar " );
182 mView->hide(); 177 mView->hide();
183 //mView->resize(splash->size() ); 178 //mView->resize(splash->size() );
184 initActions(); 179 initActions();
180 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
181 mSyncManager->setBlockSave(false);
182 mView->setSyncManager(mSyncManager);
185#ifndef DESKTOP_VERSION 183#ifndef DESKTOP_VERSION
186 iconToolBar->show(); 184 iconToolBar->show();
187 qApp->processEvents(); 185 qApp->processEvents();
188#endif 186#endif
189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 187 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
190 int vh = height() ; 188 int vh = height() ;
191 int vw = width(); 189 int vw = width();
192 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 190 //qDebug("Toolbar hei %d ",iconToolBar->height() );
193 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 191 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
194 vh -= iconToolBar->height(); 192 vh -= iconToolBar->height();
195 } else { 193 } else {
196 vw -= iconToolBar->height(); 194 vw -= iconToolBar->height();
197 } 195 }
198 //mView->setMaximumSize( splash->size() ); 196 //mView->setMaximumSize( splash->size() );
199 //mView->resize( splash->size() ); 197 //mView->resize( splash->size() );
200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 198 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
201 mView->readSettings(); 199 mView->readSettings();
202 bool newFile = false; 200 bool newFile = false;
203 if( !QFile::exists( defaultFileName() ) ) { 201 if( !QFile::exists( defaultFileName() ) ) {
204 QFileInfo finfo ( defaultFileName() ); 202 QFileInfo finfo ( defaultFileName() );
205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 203 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
206 qDebug("oldfile %s ", oldFile.latin1()); 204 qDebug("oldfile %s ", oldFile.latin1());
207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 205 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
208 finfo.setFile( oldFile ); 206 finfo.setFile( oldFile );
209 if (finfo.exists() ) { 207 if (finfo.exists() ) {
210 KMessageBox::information( this, message); 208 KMessageBox::information( this, message);
211 mView->openCalendar( oldFile ); 209 mView->openCalendar( oldFile );
212 qApp->processEvents(); 210 qApp->processEvents();
213 } else { 211 } else {
214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 212 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
215 finfo.setFile( oldFile ); 213 finfo.setFile( oldFile );
216 if (finfo.exists() ) { 214 if (finfo.exists() ) {
217 KMessageBox::information( this, message); 215 KMessageBox::information( this, message);
218 mView->openCalendar( oldFile ); 216 mView->openCalendar( oldFile );
219 qApp->processEvents(); 217 qApp->processEvents();
220 } 218 }
221 } 219 }
222 mView->saveCalendar( defaultFileName() ); 220 mView->saveCalendar( defaultFileName() );
223 newFile = true; 221 newFile = true;
224 } 222 }
225 223
226 QTime neededSaveTime = QDateTime::currentDateTime().time(); 224 QTime neededSaveTime = QDateTime::currentDateTime().time();
227 mView->openCalendar( defaultFileName() ); 225 mView->openCalendar( defaultFileName() );
228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 226 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
229 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 227 qDebug("KO: Calendar loading time: %d ms",msNeeded );
230 228
231 if ( KOPrefs::instance()->mLanguageChanged ) { 229 if ( KOPrefs::instance()->mLanguageChanged ) {
232 KOPrefs::instance()->setCategoryDefaults(); 230 KOPrefs::instance()->setCategoryDefaults();
233 int count = mView->addCategories(); 231 int count = mView->addCategories();
234 KOPrefs::instance()->mLanguageChanged = false; 232 KOPrefs::instance()->mLanguageChanged = false;
235 } 233 }
236 processIncidenceSelection( 0 ); 234 processIncidenceSelection( 0 );
237 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 235 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
238 SLOT( processIncidenceSelection( Incidence * ) ) ); 236 SLOT( processIncidenceSelection( Incidence * ) ) );
239 connect( mView, SIGNAL( modifiedChanged( bool ) ), 237 connect( mView, SIGNAL( modifiedChanged( bool ) ),
240 SLOT( slotModifiedChanged( bool ) ) ); 238 SLOT( slotModifiedChanged( bool ) ) );
241 239
242 240
243 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
244 mView->setModified( false ); 242 mView->setModified( false );
245 mBlockAtStartup = false; 243 mBlockAtStartup = false;
246 mView->setModified( false ); 244 mView->setModified( false );
247 setCentralWidget( mView ); 245 setCentralWidget( mView );
248 globalFlagBlockStartup = 0; 246 globalFlagBlockStartup = 0;
249 mView->show(); 247 mView->show();
250 delete splash; 248 delete splash;
251 if ( newFile ) 249 if ( newFile )
252 mView->updateConfig(); 250 mView->updateConfig();
253 // qApp->processEvents(); 251 // qApp->processEvents();
254 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
255 fillSyncMenu(); 253 //fillSyncMenu();
254
255
256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
259 mSyncManager->setDefaultFileName( defaultFileName());
260 mSyncManager->fillSyncMenu();
261
262
263
256 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
257 if ( showWarning ) { 265 if ( showWarning ) {
258 KMessageBox::information( this, 266 KMessageBox::information( this,
259 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 267 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
260 qApp->processEvents(); 268 qApp->processEvents();
261 mView->dialogManager()->showSyncOptions(); 269 mView->dialogManager()->showSyncOptions();
262 } 270 }
263 271
264 //US listen for result adressed from Ka/Pi 272 //US listen for result adressed from Ka/Pi
265#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
266 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
267#endif 275#endif
268} 276}
269MainWindow::~MainWindow() 277MainWindow::~MainWindow()
270{ 278{
271 //qDebug("MainWindow::~MainWindow() "); 279 //qDebug("MainWindow::~MainWindow() ");
272 //save toolbar location 280 //save toolbar location
273 delete mServerSocket; 281 delete mServerSocket;
274 delete mCalendar; 282 delete mCalendar;
275 delete KOPrefs::instance(); 283 delete KOPrefs::instance();
276 delete KIncidenceFormatter::instance(); 284 delete KIncidenceFormatter::instance();
277 285
278 286
279} 287}
280void MainWindow::showMaximized () 288void MainWindow::showMaximized ()
281{ 289{
282#ifndef DESKTOP_VERSION 290#ifndef DESKTOP_VERSION
283 if ( ! globalFlagBlockStartup ) 291 if ( ! globalFlagBlockStartup )
284 if ( mClosed ) 292 if ( mClosed )
285 mView->goToday(); 293 mView->goToday();
286#endif 294#endif
287 QWidget::showMaximized () ; 295 QWidget::showMaximized () ;
288 mClosed = false; 296 mClosed = false;
289} 297}
290void MainWindow::closeEvent( QCloseEvent* ce ) 298void MainWindow::closeEvent( QCloseEvent* ce )
291{ 299{
292 300
293 301
294 302
295 if ( ! KOPrefs::instance()->mAskForQuit ) { 303 if ( ! KOPrefs::instance()->mAskForQuit ) {
296 saveOnClose(); 304 saveOnClose();
297 mClosed = true; 305 mClosed = true;
298 ce->accept(); 306 ce->accept();
299 return; 307 return;
300 308
301 } 309 }
302 310
303 switch( QMessageBox::information( this, "KO/Pi", 311 switch( QMessageBox::information( this, "KO/Pi",
@@ -350,97 +358,97 @@ void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
350 if ( cmsg == "-writeFileSilent" ) { 358 if ( cmsg == "-writeFileSilent" ) {
351 // I made from the "-writeFile" an "-writeAlarm" 359 // I made from the "-writeFile" an "-writeAlarm"
352 // mView->viewManager()->showWhatsNextView(); 360 // mView->viewManager()->showWhatsNextView();
353 mCalendar->checkAlarmForIncidence( 0, true); 361 mCalendar->checkAlarmForIncidence( 0, true);
354 //showMaximized(); 362 //showMaximized();
355 //raise(); 363 //raise();
356 hide(); 364 hide();
357 return; 365 return;
358 } 366 }
359 if ( cmsg == "-newCountdown" ) { 367 if ( cmsg == "-newCountdown" ) {
360 qDebug("newCountdown "); 368 qDebug("newCountdown ");
361 369
362 } 370 }
363 QString msg ; 371 QString msg ;
364 QString allmsg = cmsg; 372 QString allmsg = cmsg;
365 while ( allmsg.length() > 0 ) { 373 while ( allmsg.length() > 0 ) {
366 int nextC = allmsg.find( "-", 1 ); 374 int nextC = allmsg.find( "-", 1 );
367 if ( nextC == -1 ) { 375 if ( nextC == -1 ) {
368 msg = allmsg; 376 msg = allmsg;
369 allmsg = ""; 377 allmsg = "";
370 } else{ 378 } else{
371 msg = allmsg.left( nextC ); 379 msg = allmsg.left( nextC );
372 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 380 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
373 } 381 }
374 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 382 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
375 if ( msg == "-newEvent" ) { 383 if ( msg == "-newEvent" ) {
376 mView->newEvent(); 384 mView->newEvent();
377 } 385 }
378 if ( msg == "-newTodo" ) { 386 if ( msg == "-newTodo" ) {
379 mView->newTodo(); 387 mView->newTodo();
380 388
381 } 389 }
382 if ( msg == "-showWN" ) { 390 if ( msg == "-showWN" ) {
383 mView->viewManager()->showWhatsNextView(); 391 mView->viewManager()->showWhatsNextView();
384 } 392 }
385 if ( msg == "-showTodo" ) { 393 if ( msg == "-showTodo" ) {
386 mView->viewManager()->showTodoView(); 394 mView->viewManager()->showTodoView();
387 } 395 }
388 if ( msg == "-showList" ) { 396 if ( msg == "-showList" ) {
389 mView->viewManager()->showListView(); 397 mView->viewManager()->showListView();
390 } 398 }
391 else if ( msg == "-showDay" ) { 399 else if ( msg == "-showDay" ) {
392 mView->viewManager()->showDayView(); 400 mView->viewManager()->showDayView();
393 } 401 }
394 else if ( msg == "-showWWeek" ) { 402 else if ( msg == "-showWWeek" ) {
395 mView->viewManager()->showWorkWeekView(); 403 mView->viewManager()->showWorkWeekView();
396 } 404 }
397 else if ( msg == "-ringSync" ) { 405 else if ( msg == "-ringSync" ) {
398 multiSync( false ); 406 mSyncManager->multiSync( false );
399 } 407 }
400 else if ( msg == "-showWeek" ) { 408 else if ( msg == "-showWeek" ) {
401 mView->viewManager()->showWeekView(); 409 mView->viewManager()->showWeekView();
402 } 410 }
403 else if ( msg == "-showTodo" ) { 411 else if ( msg == "-showTodo" ) {
404 mView->viewManager()->showTodoView(); 412 mView->viewManager()->showTodoView();
405 } 413 }
406 else if ( msg == "-showJournal" ) { 414 else if ( msg == "-showJournal" ) {
407 mView->dateNavigator()->selectDates( 1 ); 415 mView->dateNavigator()->selectDates( 1 );
408 mView->dateNavigator()->selectToday(); 416 mView->dateNavigator()->selectToday();
409 mView->viewManager()->showJournalView(); 417 mView->viewManager()->showJournalView();
410 } 418 }
411 else if ( msg == "-showKO" ) { 419 else if ( msg == "-showKO" ) {
412 mView->viewManager()->showNextXView(); 420 mView->viewManager()->showNextXView();
413 } 421 }
414 else if ( msg == "-showWNext" || msg == "nextView()" ) { 422 else if ( msg == "-showWNext" || msg == "nextView()" ) {
415 mView->viewManager()->showWhatsNextView(); 423 mView->viewManager()->showWhatsNextView();
416 } 424 }
417 else if ( msg == "-showNextXView" ) { 425 else if ( msg == "-showNextXView" ) {
418 mView->viewManager()->showNextXView(); 426 mView->viewManager()->showNextXView();
419 } 427 }
420 428
421 429
422 } 430 }
423 431
424 showMaximized(); 432 showMaximized();
425 raise(); 433 raise();
426} 434}
427 435
428QPixmap MainWindow::loadPixmap( QString name ) 436QPixmap MainWindow::loadPixmap( QString name )
429{ 437{
430 return SmallIcon( name ); 438 return SmallIcon( name );
431 439
432} 440}
433void MainWindow::initActions() 441void MainWindow::initActions()
434{ 442{
435 //KOPrefs::instance()->mShowFullMenu 443 //KOPrefs::instance()->mShowFullMenu
436 iconToolBar->clear(); 444 iconToolBar->clear();
437 KOPrefs *p = KOPrefs::instance(); 445 KOPrefs *p = KOPrefs::instance();
438 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 446 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
439 447
440 QPopupMenu *viewMenu = new QPopupMenu( this ); 448 QPopupMenu *viewMenu = new QPopupMenu( this );
441 QPopupMenu *actionMenu = new QPopupMenu( this ); 449 QPopupMenu *actionMenu = new QPopupMenu( this );
442 QPopupMenu *importMenu = new QPopupMenu( this ); 450 QPopupMenu *importMenu = new QPopupMenu( this );
443 selectFilterMenu = new QPopupMenu( this ); 451 selectFilterMenu = new QPopupMenu( this );
444 selectFilterMenu->setCheckable( true ); 452 selectFilterMenu->setCheckable( true );
445 syncMenu = new QPopupMenu( this ); 453 syncMenu = new QPopupMenu( this );
446 configureAgendaMenu = new QPopupMenu( this ); 454 configureAgendaMenu = new QPopupMenu( this );
@@ -895,324 +903,97 @@ void MainWindow::initActions()
895 configureToolBarMenu->setItemChecked( 10, true ); 903 configureToolBarMenu->setItemChecked( 10, true );
896 if (p->mShowIconNewTodo ) 904 if (p->mShowIconNewTodo )
897 configureToolBarMenu->setItemChecked( 20, true ); 905 configureToolBarMenu->setItemChecked( 20, true );
898 if (p-> mShowIconSearch) 906 if (p-> mShowIconSearch)
899 configureToolBarMenu->setItemChecked( 120, true ); 907 configureToolBarMenu->setItemChecked( 120, true );
900 if (p-> mShowIconList) 908 if (p-> mShowIconList)
901 configureToolBarMenu->setItemChecked( 30, true ); 909 configureToolBarMenu->setItemChecked( 30, true );
902 if (p-> mShowIconDay1) 910 if (p-> mShowIconDay1)
903 configureToolBarMenu->setItemChecked( 40, true ); 911 configureToolBarMenu->setItemChecked( 40, true );
904 if (p-> mShowIconDay5) 912 if (p-> mShowIconDay5)
905 configureToolBarMenu->setItemChecked( 50, true ); 913 configureToolBarMenu->setItemChecked( 50, true );
906 if (p-> mShowIconDay7) 914 if (p-> mShowIconDay7)
907 configureToolBarMenu->setItemChecked( 60, true ); 915 configureToolBarMenu->setItemChecked( 60, true );
908 if (p-> mShowIconMonth) 916 if (p-> mShowIconMonth)
909 configureToolBarMenu->setItemChecked( 70, true ); 917 configureToolBarMenu->setItemChecked( 70, true );
910 if (p-> mShowIconTodoview) 918 if (p-> mShowIconTodoview)
911 configureToolBarMenu->setItemChecked( 80, true ); 919 configureToolBarMenu->setItemChecked( 80, true );
912 if (p-> mShowIconBackFast) 920 if (p-> mShowIconBackFast)
913 configureToolBarMenu->setItemChecked( 200, true ); 921 configureToolBarMenu->setItemChecked( 200, true );
914 if (p-> mShowIconBack) 922 if (p-> mShowIconBack)
915 configureToolBarMenu->setItemChecked( 210, true ); 923 configureToolBarMenu->setItemChecked( 210, true );
916 if (p-> mShowIconToday) 924 if (p-> mShowIconToday)
917 configureToolBarMenu->setItemChecked( 130, true ); 925 configureToolBarMenu->setItemChecked( 130, true );
918 if (p-> mShowIconForward) 926 if (p-> mShowIconForward)
919 configureToolBarMenu->setItemChecked( 220, true ); 927 configureToolBarMenu->setItemChecked( 220, true );
920 if (p-> mShowIconForwardFast) 928 if (p-> mShowIconForwardFast)
921 configureToolBarMenu->setItemChecked( 230, true ); 929 configureToolBarMenu->setItemChecked( 230, true );
922 if (p-> mShowIconNextDays) 930 if (p-> mShowIconNextDays)
923 configureToolBarMenu->setItemChecked( 100, true ); 931 configureToolBarMenu->setItemChecked( 100, true );
924 if (p-> mShowIconNext) 932 if (p-> mShowIconNext)
925 configureToolBarMenu->setItemChecked( 110, true ); 933 configureToolBarMenu->setItemChecked( 110, true );
926 if (p-> mShowIconJournal) 934 if (p-> mShowIconJournal)
927 configureToolBarMenu->setItemChecked( 90, true ); 935 configureToolBarMenu->setItemChecked( 90, true );
928 if (p-> mShowIconWhatsThis) 936 if (p-> mShowIconWhatsThis)
929 configureToolBarMenu->setItemChecked( 300, true ); 937 configureToolBarMenu->setItemChecked( 300, true );
930 938
931 QLabel* dummy = new QLabel( iconToolBar ); 939 QLabel* dummy = new QLabel( iconToolBar );
932 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 940 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
933 if (!p-> mShowIconStretch) 941 if (!p-> mShowIconStretch)
934 iconToolBar->setStretchableWidget ( dummy ) ; 942 iconToolBar->setStretchableWidget ( dummy ) ;
935 else 943 else
936 configureToolBarMenu->setItemChecked( 5, true ); 944 configureToolBarMenu->setItemChecked( 5, true );
937 if (p-> mShowIconWhatsThis) 945 if (p-> mShowIconWhatsThis)
938 QWhatsThis::whatsThisButton ( iconToolBar ); 946 QWhatsThis::whatsThisButton ( iconToolBar );
939 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 947 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
940 configureAgenda( p->mHourSize ); 948 configureAgenda( p->mHourSize );
941 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 949 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
942} 950}
943void MainWindow::fillSyncMenu()
944{
945 if ( syncMenu->count() )
946 syncMenu->clear();
947 syncMenu->insertItem( i18n("Configure..."), 0 );
948 syncMenu->insertSeparator();
949 if ( mServerSocket == 0 ) {
950 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
951 } else {
952 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
953 }
954 syncMenu->insertSeparator();
955 syncMenu->insertItem( i18n("Multiple sync"), 1 );
956 syncMenu->insertSeparator();
957 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
958 config.setGroup("General");
959 QStringList prof = config.readListEntry("SyncProfileNames");
960 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
961 if ( prof.count() < 3 ) {
962 prof.clear();
963 prof << i18n("Sharp_DTM");
964 prof << i18n("Local_file");
965 prof << i18n("Last_file");
966 KSyncProfile* temp = new KSyncProfile ();
967 temp->setName( prof[0] );
968 temp->writeConfig(&config);
969 temp->setName( prof[1] );
970 temp->writeConfig(&config);
971 temp->setName( prof[2] );
972 temp->writeConfig(&config);
973 config.setGroup("General");
974 config.writeEntry("SyncProfileNames",prof);
975 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
976 config.sync();
977 delete temp;
978 }
979 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
980 KOPrefs::instance()->mSyncProfileNames = prof;
981 int i;
982 for ( i = 0; i < prof.count(); ++i ) {
983
984 syncMenu->insertItem( prof[i], 1000+i );
985 if ( i == 2 )
986 syncMenu->insertSeparator();
987 }
988 QDir app_dir;
989 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
990 syncMenu->setItemEnabled( false , 1000 );
991 }
992}
993
994int MainWindow::ringSync()
995{
996 int syncedProfiles = 0;
997 int i;
998 QTime timer;
999 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1000 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
1001 KSyncProfile* temp = new KSyncProfile ();
1002 KOPrefs::instance()->mAskForPreferences = false;
1003 for ( i = 0; i < syncProfileNames.count(); ++i ) {
1004 mCurrentSyncProfile = i;
1005 temp->setName(syncProfileNames[mCurrentSyncProfile]);
1006 temp->readConfig(&config);
1007 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
1008 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
1009 ++syncedProfiles;
1010 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1011 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1012 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1013 KOPrefs::instance()->mWriteBackInFuture = 0;
1014 if ( temp->getWriteBackFuture() )
1015 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1016 KOPrefs::instance()->mShowSyncSummary = false;
1017 mView->setSyncDevice(syncProfileNames[i] );
1018 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1019 if ( i == 0 ) {
1020 syncSharp();
1021 } else {
1022 if ( temp->getIsLocalFileSync() ) {
1023 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
1024 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1025 } else {
1026 if ( temp->getIsPhoneSync() ) {
1027 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1028 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1029 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1030 syncPhone();
1031 } else if ( temp->getIsPiSync() ) {
1032 mPassWordPiSync = temp->getRemotePw();
1033 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1034 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1035 syncPi();
1036 } else
1037 syncRemote( temp, false );
1038
1039 }
1040 }
1041 timer.start();
1042 setCaption(i18n("Multiple sync in progress ... please wait!") );
1043 while ( timer.elapsed () < 2000 ) {
1044 qApp->processEvents();
1045#ifndef _WIN32_
1046 sleep (1);
1047#endif
1048 }
1049
1050 }
1051
1052 }
1053 delete temp;
1054 return syncedProfiles;
1055}
1056
1057void MainWindow::multiSync( bool askforPrefs )
1058{
1059 if (mBlockSaveFlag)
1060 return;
1061 mBlockSaveFlag = true;
1062 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
1063 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1064 question,
1065 i18n("Yes"), i18n("No"),
1066 0, 0 ) != 0 ) {
1067 mBlockSaveFlag = false;
1068 setCaption(i18n("Aborted! Nothing synced!"));
1069 return;
1070 }
1071 mView->setSyncDevice(i18n("Multiple profiles") );
1072 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
1073 if ( askforPrefs ) {
1074 mView->edit_sync_options();
1075 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
1076 }
1077 setCaption(i18n("Multiple sync started.") );
1078 qApp->processEvents();
1079 int num = ringSync() ;
1080 if ( num > 1 )
1081 ringSync();
1082 mBlockSaveFlag = false;
1083 if ( num )
1084 save();
1085 if ( num )
1086 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1087 else
1088 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1089 return;
1090}
1091void MainWindow::slotSyncMenu( int action )
1092{
1093 qDebug("syncaction %d ", action);
1094 if ( action == 0 ) {
1095
1096 // seems to be a Qt2 event handling bug
1097 // syncmenu.clear causes a segfault at first time
1098 // when we call it after the main event loop, it is ok
1099 // same behaviour when calling OM/Pi via QCOP for the first time
1100 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1101 //confSync();
1102 951
1103 return;
1104 }
1105 if ( action == 1 ) {
1106 multiSync( true );
1107 return;
1108 }
1109 if ( action == 2 ) {
1110 enableQuick();
1111 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1112 return;
1113 }
1114 if ( action == 3 ) {
1115 delete mServerSocket;
1116 mServerSocket = 0;
1117 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1118 return;
1119 }
1120
1121 if (mBlockSaveFlag)
1122 return;
1123 mBlockSaveFlag = true;
1124 mCurrentSyncProfile = action - 1000 ;
1125 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1126 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1127 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1128 KSyncProfile* temp = new KSyncProfile ();
1129 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1130 temp->readConfig(&config);
1131 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1132 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1133 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1134 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1135 KOPrefs::instance()->mWriteBackInFuture = 0;
1136 if ( temp->getWriteBackFuture() )
1137 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1138 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1139 if ( action == 1000 ) {
1140 syncSharp();
1141
1142 } else if ( action == 1001 ) {
1143 syncLocalFile();
1144
1145 } else if ( action == 1002 ) {
1146 quickSyncLocalFile();
1147
1148 } else if ( action >= 1003 ) {
1149 if ( temp->getIsLocalFileSync() ) {
1150 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1151 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1152 } else {
1153 if ( temp->getIsPhoneSync() ) {
1154 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1155 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1156 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1157 syncPhone();
1158 } else if ( temp->getIsPiSync() ) {
1159 mPassWordPiSync = temp->getRemotePw();
1160 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1161 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1162 syncPi();
1163 } else
1164 syncRemote( temp );
1165
1166 }
1167 }
1168 delete temp;
1169 mBlockSaveFlag = false;
1170}
1171void MainWindow::exportToPhone( int mode ) 952void MainWindow::exportToPhone( int mode )
1172{ 953{
1173 954
1174 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 955 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1175 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 956 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1176 KOex2phonePrefs ex2phone; 957 KOex2phonePrefs ex2phone;
1177 958
1178 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 959 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1179 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 960 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1180 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 961 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1181 if ( mode == 1 ) 962 if ( mode == 1 )
1182 ex2phone.setCaption(i18n("Export complete calendar")); 963 ex2phone.setCaption(i18n("Export complete calendar"));
1183 if ( mode == 2 ) 964 if ( mode == 2 )
1184 ex2phone.setCaption(i18n("Export filtered calendar")); 965 ex2phone.setCaption(i18n("Export filtered calendar"));
1185 966
1186 if ( !ex2phone.exec() ) { 967 if ( !ex2phone.exec() ) {
1187 return; 968 return;
1188 } 969 }
1189 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 970 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1190 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 971 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1191 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 972 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1192 973
1193 int inFuture = 0; 974 int inFuture = 0;
1194 if ( ex2phone.mWriteBackFuture->isChecked() ) 975 if ( ex2phone.mWriteBackFuture->isChecked() )
1195 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 976 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1196 QPtrList<Incidence> delSel; 977 QPtrList<Incidence> delSel;
1197 if ( mode == 1 ) 978 if ( mode == 1 )
1198 delSel = mCalendar->rawIncidences(); 979 delSel = mCalendar->rawIncidences();
1199 if ( mode == 2 ) 980 if ( mode == 2 )
1200 delSel = mCalendar->incidences(); 981 delSel = mCalendar->incidences();
1201 CalendarLocal* cal = new CalendarLocal(); 982 CalendarLocal* cal = new CalendarLocal();
1202 cal->setLocalTime(); 983 cal->setLocalTime();
1203 Incidence *incidence = delSel.first(); 984 Incidence *incidence = delSel.first();
1204 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 985 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1205 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 986 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1206 while ( incidence ) { 987 while ( incidence ) {
1207 if ( incidence->type() != "Journal" ) { 988 if ( incidence->type() != "Journal" ) {
1208 bool add = true; 989 bool add = true;
1209 if ( inFuture ) { 990 if ( inFuture ) {
1210 QDateTime dt; 991 QDateTime dt;
1211 if ( incidence->type() == "Todo" ) { 992 if ( incidence->type() == "Todo" ) {
1212 Todo * t = (Todo*)incidence; 993 Todo * t = (Todo*)incidence;
1213 if ( t->hasDueDate() ) 994 if ( t->hasDueDate() )
1214 dt = t->dtDue(); 995 dt = t->dtDue();
1215 else 996 else
1216 dt = cur.addSecs( 62 ); 997 dt = cur.addSecs( 62 );
1217 } 998 }
1218 else { 999 else {
@@ -1539,128 +1320,127 @@ void MainWindow::importBday()
1539 i18n("Import!"), i18n("Cancel"), 0, 1320 i18n("Import!"), i18n("Cancel"), 0,
1540 0, 1 ); 1321 0, 1 );
1541 if ( result == 0 ) { 1322 if ( result == 0 ) {
1542 mView->importBday(); 1323 mView->importBday();
1543 1324
1544 } 1325 }
1545 1326
1546 1327
1547} 1328}
1548void MainWindow::importQtopia() 1329void MainWindow::importQtopia()
1549{ 1330{
1550#ifndef DESKTOP_VERSION 1331#ifndef DESKTOP_VERSION
1551 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1332 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1552 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1333 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1553 i18n("Import!"), i18n("Cancel"), 0, 1334 i18n("Import!"), i18n("Cancel"), 0,
1554 0, 1 ); 1335 0, 1 );
1555 if ( result == 0 ) { 1336 if ( result == 0 ) {
1556 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1337 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1557 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1338 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1558 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1339 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1559 mView->importQtopia( categories, datebook, todolist ); 1340 mView->importQtopia( categories, datebook, todolist );
1560 } 1341 }
1561#else 1342#else
1562 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1343 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1563 i18n("Not supported \non desktop!\n"), 1344 i18n("Not supported \non desktop!\n"),
1564 i18n("Ok"), i18n("Cancel"), 0, 1345 i18n("Ok"), i18n("Cancel"), 0,
1565 0, 1 ); 1346 0, 1 );
1566 1347
1567#endif 1348#endif
1568} 1349}
1569 1350
1570void MainWindow::saveOnClose() 1351void MainWindow::saveOnClose()
1571{ 1352{
1572 KOPrefs *p = KOPrefs::instance(); 1353 KOPrefs *p = KOPrefs::instance();
1573 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1354 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1574 p->mToolBarUp = iconToolBar->x() > width()/2 || 1355 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1575 iconToolBar->y() > height()/2; 1356 iconToolBar->y() > height()/2;
1576 mView->writeSettings(); 1357 mView->writeSettings();
1577 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1358 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1578 save(); 1359 save();
1579} 1360}
1580void MainWindow::slotModifiedChanged( bool changed ) 1361void MainWindow::slotModifiedChanged( bool changed )
1581{ 1362{
1582 if ( mBlockAtStartup ) 1363 if ( mBlockAtStartup )
1583 return; 1364 return;
1584 int msec; 1365 int msec;
1585 // we store the changes after 1 minute, 1366 // we store the changes after 1 minute,
1586 // and for safety reasons after 10 minutes again 1367 // and for safety reasons after 10 minutes again
1587 if ( !mBlockSaveFlag ) 1368 if ( !mSyncManager->blockSave() )
1588 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1369 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1589 else 1370 else
1590 msec = 1000 * 600; 1371 msec = 1000 * 600;
1591 mSaveTimer.start( msec, true ); // 1 minute 1372 mSaveTimer.start( msec, true ); // 1 minute
1592 qDebug("KO: Saving File in %d secs!", msec/1000); 1373 qDebug("KO: Saving File in %d secs!", msec/1000);
1593 mCalendarModifiedFlag = true; 1374 mCalendarModifiedFlag = true;
1594} 1375}
1595void MainWindow::save() 1376void MainWindow::save()
1596{ 1377{
1597 if ( mBlockSaveFlag ) 1378 if ( mSyncManager->blockSave() )
1598 return; 1379 return;
1599 bool store = mBlockSaveFlag; 1380 mSyncManager->setBlockSave(true);
1600 mBlockSaveFlag = true;
1601 if ( mView->checkFileVersion( defaultFileName()) ) { 1381 if ( mView->checkFileVersion( defaultFileName()) ) {
1602 1382
1603 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1383 QTime neededSaveTime = QDateTime::currentDateTime().time();
1604 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1384 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1605 qDebug("KO: Start saving data to file!"); 1385 qDebug("KO: Start saving data to file!");
1606 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1386 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1607 mView->saveCalendar( defaultFileName() ); 1387 mView->saveCalendar( defaultFileName() );
1608 1388
1609 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1389 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1610 mView->watchSavedFile(); 1390 mView->watchSavedFile();
1611 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1391 qDebug("KO: Needed %d ms for saving.",msNeeded );
1612 QString savemes; 1392 QString savemes;
1613 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1393 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1614 setCaption(savemes); 1394 setCaption(savemes);
1615 } else 1395 } else
1616 setCaption(i18n("Saving cancelled!")); 1396 setCaption(i18n("Saving cancelled!"));
1617 mCalendarModifiedFlag = false; 1397 mCalendarModifiedFlag = false;
1618 mBlockSaveFlag = store; 1398 mSyncManager->setBlockSave( false );
1619} 1399}
1620 1400
1621void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1401void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1622{ 1402{
1623 if ( !e->isAutoRepeat() ) { 1403 if ( !e->isAutoRepeat() ) {
1624 mFlagKeyPressed = false; 1404 mFlagKeyPressed = false;
1625 } 1405 }
1626} 1406}
1627void MainWindow::keyPressEvent ( QKeyEvent * e ) 1407void MainWindow::keyPressEvent ( QKeyEvent * e )
1628{ 1408{
1629 qApp->processEvents(); 1409 qApp->processEvents();
1630 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1410 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1631 e->ignore(); 1411 e->ignore();
1632 // qDebug(" ignore %d",e->isAutoRepeat() ); 1412 // qDebug(" ignore %d",e->isAutoRepeat() );
1633 return; 1413 return;
1634 } 1414 }
1635 if (! e->isAutoRepeat() ) 1415 if (! e->isAutoRepeat() )
1636 mFlagKeyPressed = true; 1416 mFlagKeyPressed = true;
1637 KOPrefs *p = KOPrefs::instance(); 1417 KOPrefs *p = KOPrefs::instance();
1638 bool showSelectedDates = false; 1418 bool showSelectedDates = false;
1639 int size; 1419 int size;
1640 int pro = 0; 1420 int pro = 0;
1641 //qDebug("MainWindow::keyPressEvent "); 1421 //qDebug("MainWindow::keyPressEvent ");
1642 switch ( e->key() ) { 1422 switch ( e->key() ) {
1643 case Qt::Key_Right: 1423 case Qt::Key_Right:
1644 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1424 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1645 mView->goNextMonth(); 1425 mView->goNextMonth();
1646 else 1426 else
1647 mView->goNext(); 1427 mView->goNext();
1648 showSelectedDates = true; 1428 showSelectedDates = true;
1649 break; 1429 break;
1650 case Qt::Key_Left: 1430 case Qt::Key_Left:
1651 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1431 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1652 mView->goPreviousMonth(); 1432 mView->goPreviousMonth();
1653 else 1433 else
1654 mView->goPrevious(); 1434 mView->goPrevious();
1655 showSelectedDates = true; 1435 showSelectedDates = true;
1656 break; 1436 break;
1657 case Qt::Key_Down: 1437 case Qt::Key_Down:
1658 mView->viewManager()->agendaView()->scrollOneHourDown(); 1438 mView->viewManager()->agendaView()->scrollOneHourDown();
1659 break; 1439 break;
1660 case Qt::Key_Up: 1440 case Qt::Key_Up:
1661 mView->viewManager()->agendaView()->scrollOneHourUp(); 1441 mView->viewManager()->agendaView()->scrollOneHourUp();
1662 break; 1442 break;
1663 case Qt::Key_I: 1443 case Qt::Key_I:
1664 mView->showIncidence(); 1444 mView->showIncidence();
1665 break; 1445 break;
1666 case Qt::Key_Delete: 1446 case Qt::Key_Delete:
@@ -1984,365 +1764,75 @@ void MainWindow::importFile( QString fn, bool quick )
1984 setCaption(i18n("Error importing file")); 1764 setCaption(i18n("Error importing file"));
1985 } 1765 }
1986 } 1766 }
1987} 1767}
1988 1768
1989void MainWindow::importIcal() 1769void MainWindow::importIcal()
1990{ 1770{
1991 1771
1992 QString fn =KOPrefs::instance()->mLastImportFile; 1772 QString fn =KOPrefs::instance()->mLastImportFile;
1993 1773
1994 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1774 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1995 if ( fn == "" ) 1775 if ( fn == "" )
1996 return; 1776 return;
1997 importFile( fn, true ); 1777 importFile( fn, true );
1998 1778
1999} 1779}
2000 1780
2001void MainWindow::exportVCalendar() 1781void MainWindow::exportVCalendar()
2002{ 1782{
2003 QString fn = KOPrefs::instance()->mLastVcalFile; 1783 QString fn = KOPrefs::instance()->mLastVcalFile;
2004 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1784 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2005 if ( fn == "" ) 1785 if ( fn == "" )
2006 return; 1786 return;
2007 QFileInfo info; 1787 QFileInfo info;
2008 info.setFile( fn ); 1788 info.setFile( fn );
2009 QString mes; 1789 QString mes;
2010 bool createbup = true; 1790 bool createbup = true;
2011 if ( info. exists() ) { 1791 if ( info. exists() ) {
2012 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1792 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2013 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1793 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2014 i18n("Overwrite!"), i18n("Cancel"), 0, 1794 i18n("Overwrite!"), i18n("Cancel"), 0,
2015 0, 1 ); 1795 0, 1 );
2016 if ( result != 0 ) { 1796 if ( result != 0 ) {
2017 createbup = false; 1797 createbup = false;
2018 } 1798 }
2019 } 1799 }
2020 if ( createbup ) { 1800 if ( createbup ) {
2021 if ( mView->exportVCalendar( fn ) ) { 1801 if ( mView->exportVCalendar( fn ) ) {
2022 KOPrefs::instance()->mLastVcalFile = fn; 1802 KOPrefs::instance()->mLastVcalFile = fn;
2023 if ( fn.length() > 20 ) 1803 if ( fn.length() > 20 )
2024 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1804 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2025 else 1805 else
2026 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1806 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2027 setCaption(mes); 1807 setCaption(mes);
2028 } 1808 }
2029 } 1809 }
2030 1810
2031} 1811}
2032QString MainWindow::getPassword( )
2033{
2034 QString retfile = "";
2035 QDialog dia ( this, "input-dialog", true );
2036 QLineEdit lab ( &dia );
2037 lab.setEchoMode( QLineEdit::Password );
2038 QVBoxLayout lay( &dia );
2039 lay.setMargin(7);
2040 lay.setSpacing(7);
2041 lay.addWidget( &lab);
2042 dia.setFixedSize( 230,50 );
2043 dia.setCaption( i18n("Enter password") );
2044 QPushButton pb ( "OK", &dia);
2045 lay.addWidget( &pb );
2046 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2047 dia.show();
2048 int res = dia.exec();
2049 if ( res )
2050 retfile = lab.text();
2051 dia.hide();
2052 qApp->processEvents();
2053 return retfile;
2054
2055}
2056 1812
2057void MainWindow::enableQuick() 1813void MainWindow::syncFileRequest()
2058{ 1814{
2059 QDialog dia ( this, "input-dialog", true ); 1815 save();
2060 QLineEdit lab ( &dia );
2061 QVBoxLayout lay( &dia );
2062 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
2063 lay.setMargin(7);
2064 lay.setSpacing(7);
2065 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
2066 lay.addWidget( &label);
2067 lay.addWidget( &lab);
2068
2069 QLineEdit lepw ( &dia );
2070 lepw.setText( KOPrefs::instance()->mPassiveSyncPw );
2071 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
2072 lay.addWidget( &label2);
2073 lay.addWidget( &lepw);
2074 dia.setFixedSize( 230,80 );
2075 dia.setCaption( i18n("Enter port for Pi-Sync") );
2076 QPushButton pb ( "OK", &dia);
2077 lay.addWidget( &pb );
2078 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2079 dia.show();
2080 if ( ! dia.exec() )
2081 return;
2082 dia.hide();
2083 qApp->processEvents();
2084 KOPrefs::instance()->mPassiveSyncPw = lepw.text();
2085 KOPrefs::instance()->mPassiveSyncPort = lab.text();
2086 bool ok;
2087 Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok);
2088 if ( ! ok ) {
2089 KMessageBox::information( this, i18n("No valid port"));
2090 return;
2091 }
2092 //qDebug("port %d ", port);
2093 mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 );
2094 mServerSocket->setFileName( defaultFileName() );
2095 //qDebug("connected ");
2096 if ( !mServerSocket->ok() ) {
2097 KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!"));
2098 delete mServerSocket;
2099 mServerSocket = 0;
2100 return;
2101 }
2102 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
2103 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
2104} 1816}
2105
2106void MainWindow::getFile( bool success ) 1817void MainWindow::getFile( bool success )
2107{ 1818{
2108 if ( ! success ) { 1819 if ( ! success ) {
2109 setCaption( i18n("Error receiving file. Nothing changed!") ); 1820 setCaption( i18n("Error receiving file. Nothing changed!") );
2110 return; 1821 return;
2111 } 1822 }
2112 mView->watchSavedFile(); 1823 mView->watchSavedFile();
2113 mView->openCalendar( defaultFileName() ); 1824 mView->openCalendar( defaultFileName() );
2114 setCaption( i18n("Pi-Sync successful!") ); 1825 setCaption( i18n("Pi-Sync successful!") );
2115 1826
2116} 1827}
2117 1828
2118
2119void MainWindow::syncPi()
2120{
2121 qApp->processEvents();
2122 bool ok;
2123 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2124 if ( ! ok ) {
2125 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2126 return;
2127 }
2128 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
2129 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
2130 setCaption( i18n("Sending request for remote file ...") );
2131 commandSocket->readFile( syncFileName() );
2132}
2133
2134void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
2135{
2136 qDebug("MainWindow::deleteCommandSocket %d", state);
2137
2138 //enum { success, errorW, errorR, quiet };
2139 if ( state == KCommandSocket::errorR ) {
2140 setCaption( i18n("ERROR: Receiving remote file failed.") );
2141 delete s;
2142 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2143 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2144 commandSocket->sendStop();
2145 return;
2146
2147 } else if ( state == KCommandSocket::errorW ) {
2148 setCaption( i18n("ERROR:Writing back file failed.") );
2149
2150 } else if ( state == KCommandSocket::successR ) {
2151 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
2152
2153 } else if ( state == KCommandSocket::successW ) {
2154 setCaption( i18n("Pi-Sync succesful!") );
2155 }
2156
2157 delete s;
2158}
2159
2160void MainWindow::readFileFromSocket()
2161{
2162 QString fileName = syncFileName();
2163 setCaption( i18n("Remote file saved to temp file.") );
2164 if ( ! syncWithFile( fileName , true ) ) {
2165 setCaption( i18n("Syncing failed.") );
2166 qDebug("Syncing failed ");
2167 return;
2168 }
2169 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2170 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2171 if ( KOPrefs::instance()->mWriteBackFile )
2172 commandSocket->writeFile( fileName );
2173 else {
2174 commandSocket->sendStop();
2175 setCaption( i18n("Pi-Sync succesful!") );
2176 }
2177}
2178
2179void MainWindow::syncLocalFile()
2180{
2181
2182 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2183
2184 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2185 if ( fn == "" )
2186 return;
2187 //mView->setSyncDevice("local-file" );
2188 if ( syncWithFile( fn, false ) ) {
2189 // Event* e = mView->getLastSyncEvent();
2190// e->setReadOnly( false );
2191// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2192// e->setReadOnly( true );
2193 }
2194
2195}
2196
2197bool MainWindow::syncWithFile( QString fn , bool quick )
2198{
2199 bool ret = false;
2200 QFileInfo info;
2201 info.setFile( fn );
2202 QString mess;
2203 bool loadbup = true;
2204 if ( !info. exists() ) {
2205 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2206 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2207 mess );
2208 return ret;
2209 }
2210 int result = 0;
2211 if ( !quick ) {
2212 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2213 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2214 mess,
2215 i18n("Sync"), i18n("Cancel"), 0,
2216 0, 1 );
2217 if ( result )
2218 return false;
2219 }
2220 if ( KOPrefs::instance()->mAskForPreferences )
2221 mView->edit_sync_options();
2222 if ( result == 0 ) {
2223 //qDebug("Now sycing ... ");
2224 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2225 setCaption( i18n("Synchronization successful") );
2226 else
2227 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2228 if ( ! quick )
2229 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2230 slotModifiedChanged( true );
2231 }
2232 return ret;
2233}
2234void MainWindow::quickSyncLocalFile()
2235{
2236 //mView->setSyncDevice("local-file" );
2237 //qDebug("quickSyncLocalFile() ");
2238 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2239 // Event* e = mView->getLastSyncEvent();
2240// e->setReadOnly( false );
2241// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2242// e->setReadOnly( true );
2243
2244 }
2245}
2246
2247void MainWindow::confSync()
2248{
2249 mView->confSync();
2250 fillSyncMenu();
2251}
2252void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2253{
2254 QString question;
2255 if ( ask ) {
2256 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2257 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2258 question,
2259 i18n("Yes"), i18n("No"),
2260 0, 0 ) != 0 )
2261 return;
2262 }
2263 QString command = prof->getPreSyncCommand();
2264 int fi;
2265 if ( (fi = command.find("$PWD$")) > 0 ) {
2266 QString pwd = getPassword();
2267 command = command.left( fi )+ pwd + command.mid( fi+5 );
2268
2269 }
2270 int maxlen = 30;
2271 if ( QApplication::desktop()->width() > 320 )
2272 maxlen += 25;
2273 setCaption ( i18n( "Copy remote file to local machine..." ) );
2274 int fileSize = 0;
2275 int result = system ( command );
2276 // 0 : okay
2277 // 256: no such file or dir
2278 //
2279 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2280 if ( result != 0 ) {
2281 int len = maxlen;
2282 while ( len < command.length() ) {
2283 command.insert( len , "\n" );
2284 len += maxlen +2;
2285 }
2286 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 (command) ;
2287 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2288 question,
2289 i18n("Okay!")) ;
2290 setCaption ("KO/Pi");
2291 return;
2292 }
2293 setCaption ( i18n( "Copying succeed." ) );
2294 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2295 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2296// Event* e = mView->getLastSyncEvent();
2297// e->setReadOnly( false );
2298// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2299// e->setReadOnly( true );
2300 if ( KOPrefs::instance()->mWriteBackFile ) {
2301 command = prof->getPostSyncCommand();
2302 int fi;
2303 if ( (fi = command.find("$PWD$")) > 0 ) {
2304 QString pwd = getPassword();
2305 command = command.left( fi )+ pwd + command.mid( fi+5 );
2306
2307 }
2308 setCaption ( i18n( "Writing back file ..." ) );
2309 result = system ( command );
2310 qDebug("KO: Writing back file result: %d ", result);
2311 if ( result != 0 ) {
2312 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2313 return;
2314 } else {
2315 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2316 }
2317 }
2318 }
2319 return;
2320}
2321
2322void MainWindow::syncSharp()
2323{
2324 if ( mCalendarModifiedFlag )
2325 save();
2326 mView->syncSharp();
2327 slotModifiedChanged( true );
2328
2329}
2330void MainWindow::syncPhone()
2331{
2332 if ( mCalendarModifiedFlag )
2333 save();
2334 mView->syncPhone();
2335 slotModifiedChanged( true );
2336
2337}
2338
2339void MainWindow::printSel( ) 1829void MainWindow::printSel( )
2340{ 1830{
2341 mView->viewManager()->agendaView()->agenda()->printSelection(); 1831 mView->viewManager()->agendaView()->agenda()->printSelection();
2342} 1832}
2343 1833
2344void MainWindow::printCal() 1834void MainWindow::printCal()
2345{ 1835{
2346 mView->print();//mCp->showDialog(); 1836 mView->print();//mCp->showDialog();
2347} 1837}
2348 1838
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 0da0be0..ee7bd87 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,148 +1,130 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qtextstream.h> 8#include <qtextstream.h>
9#include <qregexp.h> 9#include <qregexp.h>
10 10
11#include <libkcal/incidence.h> 11#include <libkcal/incidence.h>
12#include "simplealarmclient.h" 12#include "simplealarmclient.h"
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class KSyncProfile;
18#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
19 19
20#define QPEToolBar QToolBar 20#define QPEToolBar QToolBar
21#define QPEMenuBar QMenuBar 21#define QPEMenuBar QMenuBar
22#endif 22#endif
23class QPEToolBar; 23class QPEToolBar;
24 24
25 25
26namespace KCal { 26namespace KCal {
27class CalendarLocal; 27class CalendarLocal;
28} 28}
29 29
30using namespace KCal; 30using namespace KCal;
31 31
32class MainWindow : public QMainWindow 32class MainWindow : public QMainWindow
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 public: 35 public:
36 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 36 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
37 ~MainWindow(); 37 ~MainWindow();
38 public slots: 38 public slots:
39 virtual void showMaximized (); 39 virtual void showMaximized ();
40 void configureAgenda( int ); 40 void configureAgenda( int );
41 void recieve( const QCString& msg, const QByteArray& data ); 41 void recieve( const QCString& msg, const QByteArray& data );
42 static QString defaultFileName(); 42 static QString defaultFileName();
43 static QString syncFileName(); 43 static QString syncFileName();
44 static QString resourcePath(); 44 static QString resourcePath();
45 protected slots: 45 protected slots:
46 void setCaptionToDates(); 46 void setCaptionToDates();
47 int ringSync();
48 void multiSync( bool askforPrefs = false );
49 void about(); 47 void about();
50 void licence(); 48 void licence();
51 void faq(); 49 void faq();
52 void usertrans(); 50 void usertrans();
53 void features(); 51 void features();
54 void synchowto(); 52 void synchowto();
55 void whatsNew(); 53 void whatsNew();
56 void keyBindings(); 54 void keyBindings();
57 void aboutAutoSaving();; 55 void aboutAutoSaving();;
58 void aboutKnownBugs(); 56 void aboutKnownBugs();
59 57
60 void processIncidenceSelection( Incidence * ); 58 void processIncidenceSelection( Incidence * );
61 59
62 void importQtopia(); 60 void importQtopia();
63 void importBday(); 61 void importBday();
64 void importOL(); 62 void importOL();
65 void importIcal(); 63 void importIcal();
66 void importFile( QString, bool ); 64 void importFile( QString, bool );
67 void quickImportIcal(); 65 void quickImportIcal();
68 66
69 void slotModifiedChanged( bool ); 67 void slotModifiedChanged( bool );
70 68
71 void save(); 69 void save();
72 void configureToolBar( int ); 70 void configureToolBar( int );
73 void printSel(); 71 void printSel();
74 void printCal(); 72 void printCal();
75 void saveCalendar(); 73 void saveCalendar();
76 void loadCalendar(); 74 void loadCalendar();
77 void exportVCalendar(); 75 void exportVCalendar();
78 void fillFilterMenu(); 76 void fillFilterMenu();
79 void selectFilter( int ); 77 void selectFilter( int );
80 void exportToPhone( int ); 78 void exportToPhone( int );
81 79
82 void slotSyncMenu( int );
83 void confSync();
84 void syncSharp();
85 void syncPhone();
86 void syncPi();
87 void syncLocalFile();
88 bool syncWithFile( QString, bool );
89 void quickSyncLocalFile();
90
91 80
92 protected: 81 protected:
93 void displayText( QString, QString); 82 void displayText( QString, QString);
94 void displayFile( QString, QString); 83 void displayFile( QString, QString);
95 84
96 void enableIncidenceActions( bool ); 85 void enableIncidenceActions( bool );
97 86
98 private slots: 87 private slots:
99 QSocket* piSocket; 88 QSocket* piSocket;
100 QString piFileString; 89 QString piFileString;
101 QTime piTime; 90 QTime piTime;
102 void deleteCommandSocket(KCommandSocket* s, int state );
103 void fillSyncMenu();
104 void getFile( bool ); 91 void getFile( bool );
105 void readFileFromSocket(); 92 void syncFileRequest();
106 private: 93 private:
94 KSyncManager* mSyncManager;
107 //QTimer* mTimerCommandSocket; 95 //QTimer* mTimerCommandSocket;
108 QString mPassWordPiSync;
109 KServerSocket * mServerSocket; 96 KServerSocket * mServerSocket;
110 bool mClosed; 97 bool mClosed;
111 void saveOnClose(); 98 void saveOnClose();
112 int mCurrentSyncProfile;
113 void enableQuick();
114 void syncRemote( KSyncProfile* , bool ask = true);
115 bool mFlagKeyPressed; 99 bool mFlagKeyPressed;
116 bool mBlockAtStartup; 100 bool mBlockAtStartup;
117 QPEToolBar *iconToolBar; 101 QPEToolBar *iconToolBar;
118 void initActions(); 102 void initActions();
119 void setDefaultPreferences(); 103 void setDefaultPreferences();
120 void keyPressEvent ( QKeyEvent * ) ; 104 void keyPressEvent ( QKeyEvent * ) ;
121 void keyReleaseEvent ( QKeyEvent * ) ; 105 void keyReleaseEvent ( QKeyEvent * ) ;
122 QPopupMenu *configureToolBarMenu; 106 QPopupMenu *configureToolBarMenu;
123 QPopupMenu *selectFilterMenu; 107 QPopupMenu *selectFilterMenu;
124 QPopupMenu *configureAgendaMenu, *syncMenu; 108 QPopupMenu *configureAgendaMenu, *syncMenu;
125 CalendarLocal *mCalendar; 109 CalendarLocal *mCalendar;
126 CalendarView *mView; 110 CalendarView *mView;
127 QString getPassword();
128 QAction *mNewSubTodoAction; 111 QAction *mNewSubTodoAction;
129 112
130 QAction *mShowAction; 113 QAction *mShowAction;
131 QAction *mEditAction; 114 QAction *mEditAction;
132 QAction *mDeleteAction; 115 QAction *mDeleteAction;
133 QAction *mCloneAction; 116 QAction *mCloneAction;
134 QAction *mMoveAction; 117 QAction *mMoveAction;
135 QAction *mBeamAction; 118 QAction *mBeamAction;
136 QAction *mCancelAction; 119 QAction *mCancelAction;
137 120
138
139 void closeEvent( QCloseEvent* ce ); 121 void closeEvent( QCloseEvent* ce );
140 SimpleAlarmClient mAlarmClient; 122 SimpleAlarmClient mAlarmClient;
141 QTimer mSaveTimer; 123 QTimer mSaveTimer;
142 bool mBlockSaveFlag; 124 //bool mBlockSaveFlag;
143 bool mCalendarModifiedFlag; 125 bool mCalendarModifiedFlag;
144 QPixmap loadPixmap( QString ); 126 QPixmap loadPixmap( QString );
145}; 127};
146 128
147 129
148#endif 130#endif
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index 0a2f5f1..c21ebaa 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -1,75 +1,82 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35 35
36#include "kpimprefs.h" 36#include "kpimprefs.h"
37 37
38KPimPrefs::KPimPrefs( const QString &name ) : 38KPimPrefs::KPimPrefs( const QString &name ) :
39 KPrefs( name ) 39 KPrefs( name )
40{ 40{
41 config()->setGroup("General"); 41#ifdef _WIN32_
42 QString hdp= locateLocal("data","korganizer")+"\\\\";
43#else
44 QString hdp= locateLocal("data","korganizer")+"/";
45#endif
46 config()->setGroup("SyncOptions");
42 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 47 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
43 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); 48 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
49 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
50 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
44} 51}
45 52
46KPimPrefs::~KPimPrefs() 53KPimPrefs::~KPimPrefs()
47{ 54{
48} 55}
49 56
50void KPimPrefs::usrSetDefaults() 57void KPimPrefs::usrSetDefaults()
51{ 58{
52 setCategoryDefaults(); 59 setCategoryDefaults();
53} 60}
54 61
55void KPimPrefs::usrReadConfig() 62void KPimPrefs::usrReadConfig()
56{ 63{
57 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; 64 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl;
58 65
59 config()->setGroup("General"); 66 config()->setGroup("General");
60 mCustomCategories = config()->readListEntry("Custom Categories"); 67 mCustomCategories = config()->readListEntry("Custom Categories");
61 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 68 if (mCustomCategories.isEmpty()) setCategoryDefaults();
62} 69}
63 70
64 71
65void KPimPrefs::usrWriteConfig() 72void KPimPrefs::usrWriteConfig()
66{ 73{
67 config()->setGroup("General"); 74 config()->setGroup("General");
68 config()->writeEntry("Custom Categories",mCustomCategories); 75 config()->writeEntry("Custom Categories",mCustomCategories);
69} 76}
70 77
71void KPimPrefs::setCategoryDefaults() 78void KPimPrefs::setCategoryDefaults()
72{ 79{
73 // empty implementation 80 // empty implementation
74} 81}
75 82
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index fde8093..9346f7d 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -12,59 +12,60 @@
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KPIMPREFS_H 31#ifndef KPIMPREFS_H
32#define KPIMPREFS_H 32#define KPIMPREFS_H
33 33
34#include <qstringlist.h> 34#include <qstringlist.h>
35 35
36#include "kprefs.h" 36#include "kprefs.h"
37 37
38class KPimPrefs : public KPrefs 38class KPimPrefs : public KPrefs
39{ 39{
40 public: 40 public:
41 41
42 KPimPrefs( const QString &name = QString::null ); 42 KPimPrefs( const QString &name = QString::null );
43 43
44 virtual ~KPimPrefs(); 44 virtual ~KPimPrefs();
45 45
46 /** Set preferences to default values */ 46 /** Set preferences to default values */
47 void usrSetDefaults(); 47 void usrSetDefaults();
48 48
49 /** Read preferences from config file */ 49 /** Read preferences from config file */
50 void usrReadConfig(); 50 void usrReadConfig();
51 51
52 /** Write preferences to config file */ 52 /** Write preferences to config file */
53 void usrWriteConfig(); 53 void usrWriteConfig();
54 54
55 55
56 public: 56 public:
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 QString mPassiveSyncPort; 58 QString mPassiveSyncPort;
59 QString mPassiveSyncPw; 59 QString mPassiveSyncPw;
60 60 int mRingSyncAlgoPrefs;
61 QString mLastSyncedLocalFile;
61 62
62 63
63 protected: 64 protected:
64 virtual void setCategoryDefaults(); 65 virtual void setCategoryDefaults();
65 66
66 67
67 68
68}; 69};
69 70
70#endif 71#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index fad9a76..568c2a9 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -31,787 +31,806 @@
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 51
52#include <klocale.h> 52#include <klocale.h>
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kconfig.h> 54#include <kconfig.h>
55#include <kfiledialog.h> 55#include <kfiledialog.h>
56 56
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 59{
60 mServerSocket = 0; 60 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 62 bar->setCaption ("");
63 63
64 int w = 300; 64 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 66 w = 220;
67 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
71 71
72} 72}
73 73
74KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
75{ 75{
76 delete bar; 76 delete bar;
77} 77}
78 78
79//LR ok 79
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 83 mSyncMenu->clear();
84 84
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 91 }
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
95 95
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 97 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
103 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
104 prof << i18n("Last_file");
104 KSyncProfile* temp = new KSyncProfile (); 105 KSyncProfile* temp = new KSyncProfile ();
105 temp->setName( prof[0] ); 106 temp->setName( prof[0] );
106 temp->writeConfig(&config); 107 temp->writeConfig(&config);
107 temp->setName( prof[1] ); 108 temp->setName( prof[1] );
108 temp->writeConfig(&config); 109 temp->writeConfig(&config);
110 temp->setName( prof[2] );
111 temp->writeConfig(&config);
109 config.setGroup("General"); 112 config.setGroup("General");
110 config.writeEntry("SyncProfileNames",prof); 113 config.writeEntry("SyncProfileNames",prof);
111 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 114 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
112 config.sync(); 115 config.sync();
113 delete temp; 116 delete temp;
114 } 117 }
115 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
116 mSyncProfileNames = prof; 119 mSyncProfileNames = prof;
117 unsigned int i; 120 unsigned int i;
118 for ( i = 0; i < prof.count(); ++i ) { 121 for ( i = 0; i < prof.count(); ++i ) {
119 mSyncMenu->insertItem( prof[i], 1000+i ); 122 mSyncMenu->insertItem( prof[i], 1000+i );
120 if ( i == 2 ) 123 if ( i == 2 )
121 mSyncMenu->insertSeparator(); 124 mSyncMenu->insertSeparator();
122 } 125 }
123 QDir app_dir; 126 QDir app_dir;
124 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
125 if ( mTargetApp == PWMPI) { 128 if ( mTargetApp == PWMPI) {
126 mSyncMenu->removeItem( 1000 ); 129 mSyncMenu->removeItem( 1000 );
127 } 130 }
128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
129 mSyncMenu->setItemEnabled( 1000, false ); 132 mSyncMenu->removeItem( 1000 );
130 } 133 }
134 mSyncMenu->removeItem( 1002 );
131} 135}
132 136
133void KSyncManager::slotSyncMenu( int action ) 137void KSyncManager::slotSyncMenu( int action )
134{ 138{
135 //qDebug("syncaction %d ", action); 139 //qDebug("syncaction %d ", action);
136 if ( action == 0 ) { 140 if ( action == 0 ) {
137 141
138 // seems to be a Qt2 event handling bug 142 // seems to be a Qt2 event handling bug
139 // syncmenu.clear causes a segfault at first time 143 // syncmenu.clear causes a segfault at first time
140 // when we call it after the main event loop, it is ok 144 // when we call it after the main event loop, it is ok
141 // same behaviour when calling OM/Pi via QCOP for the first time 145 // same behaviour when calling OM/Pi via QCOP for the first time
142 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
143 //confSync(); 147 //confSync();
144 148
145 return; 149 return;
146 } 150 }
147 if ( action == 1 ) { 151 if ( action == 1 ) {
148 multiSync( true ); 152 multiSync( true );
149 return; 153 return;
150 } 154 }
151 if ( action == 2 ) { 155 if ( action == 2 ) {
152 enableQuick(); 156 enableQuick();
153 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
154 return; 158 return;
155 } 159 }
156 if ( action == 3 ) { 160 if ( action == 3 ) {
157 delete mServerSocket; 161 delete mServerSocket;
158 mServerSocket = 0; 162 mServerSocket = 0;
159 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
160 return; 164 return;
161 } 165 }
162 166
163 if (blockSave()) 167 if (blockSave())
164 return; 168 return;
165 169
166 setBlockSave(true); 170 setBlockSave(true);
167 171
168 mCurrentSyncProfile = action - 1000 ; 172 mCurrentSyncProfile = action - 1000 ;
169 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
170 mCurrentSyncName = mLocalMachineName ; 174 mCurrentSyncName = mLocalMachineName ;
171 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
172 KSyncProfile* temp = new KSyncProfile (); 176 KSyncProfile* temp = new KSyncProfile ();
173 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
174 temp->readConfig(&config); 178 temp->readConfig(&config);
175 mAskForPreferences = temp->getAskForPreferences(); 179 mAskForPreferences = temp->getAskForPreferences();
176 mSyncAlgoPrefs = temp->getSyncPrefs(); 180 mSyncAlgoPrefs = temp->getSyncPrefs();
177 mWriteBackFile = temp->getWriteBackFile(); 181 mWriteBackFile = temp->getWriteBackFile();
178 mWriteBackExistingOnly = temp->getWriteBackExisting(); 182 mWriteBackExistingOnly = temp->getWriteBackExisting();
179 mWriteBackInFuture = 0; 183 mWriteBackInFuture = 0;
180 if ( temp->getWriteBackFuture() ) 184 if ( temp->getWriteBackFuture() )
181 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
182 mShowSyncSummary = temp->getShowSummaryAfterSync(); 186 mShowSyncSummary = temp->getShowSummaryAfterSync();
183 if ( action == 1000 ) { 187 if ( action == 1000 ) {
184 syncSharp(); 188 syncSharp();
185 189
186 } else if ( action == 1001 ) { 190 } else if ( action == 1001 ) {
187 syncLocalFile(); 191 syncLocalFile();
188 192
189 } else if ( action == 1002 ) { 193 } else if ( action == 1002 ) {
190 quickSyncLocalFile(); 194 quickSyncLocalFile();
191 195
192 } else if ( action >= 1003 ) { 196 } else if ( action >= 1003 ) {
193 if ( temp->getIsLocalFileSync() ) { 197 if ( temp->getIsLocalFileSync() ) {
194 switch(mTargetApp) 198 switch(mTargetApp)
195 { 199 {
196 case (KAPI): 200 case (KAPI):
197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
198 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 202 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
199 break; 203 break;
200 case (KOPI): 204 case (KOPI):
201 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
202 mLastSyncedLocalFile = temp->getRemoteFileName(); 206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
203 break; 207 break;
204 case (PWMPI): 208 case (PWMPI):
205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 209 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
207 break; 211 break;
208 default: 212 default:
209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 213 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
210 break; 214 break;
211 215
212 } 216 }
213 } else { 217 } else {
214 if ( temp->getIsPhoneSync() ) { 218 if ( temp->getIsPhoneSync() ) {
215 mPhoneDevice = temp->getPhoneDevice( ) ; 219 mPhoneDevice = temp->getPhoneDevice( ) ;
216 mPhoneConnection = temp->getPhoneConnection( ); 220 mPhoneConnection = temp->getPhoneConnection( );
217 mPhoneModel = temp->getPhoneModel( ); 221 mPhoneModel = temp->getPhoneModel( );
218 syncPhone(); 222 syncPhone();
219 } else if ( temp->getIsPiSync() ) { 223 } else if ( temp->getIsPiSync() ) {
220 if ( mTargetApp == KAPI ) { 224 if ( mTargetApp == KAPI ) {
221 mPassWordPiSync = temp->getRemotePwAB(); 225 mPassWordPiSync = temp->getRemotePwAB();
222 mActiveSyncPort = temp->getRemotePortAB(); 226 mActiveSyncPort = temp->getRemotePortAB();
223 mActiveSyncIP = temp->getRemoteIPAB(); 227 mActiveSyncIP = temp->getRemoteIPAB();
224 } else if ( mTargetApp == KOPI ) { 228 } else if ( mTargetApp == KOPI ) {
225 mPassWordPiSync = temp->getRemotePw(); 229 mPassWordPiSync = temp->getRemotePw();
226 mActiveSyncPort = temp->getRemotePort(); 230 mActiveSyncPort = temp->getRemotePort();
227 mActiveSyncIP = temp->getRemoteIP(); 231 mActiveSyncIP = temp->getRemoteIP();
228 } else { 232 } else {
229 mPassWordPiSync = temp->getRemotePwPWM(); 233 mPassWordPiSync = temp->getRemotePwPWM();
230 mActiveSyncPort = temp->getRemotePortPWM(); 234 mActiveSyncPort = temp->getRemotePortPWM();
231 mActiveSyncIP = temp->getRemoteIPPWM(); 235 mActiveSyncIP = temp->getRemoteIPPWM();
232 } 236 }
233 syncPi(); 237 syncPi();
234 } else 238 } else
235 syncRemote( temp ); 239 syncRemote( temp );
236 240
237 } 241 }
238 } 242 }
239 delete temp; 243 delete temp;
240 setBlockSave(false); 244 setBlockSave(false);
241} 245}
246
242void KSyncManager::enableQuick() 247void KSyncManager::enableQuick()
243{ 248{
244 QDialog dia ( 0, "input-dialog", true ); 249 QDialog dia ( 0, "input-dialog", true );
245 QLineEdit lab ( &dia ); 250 QLineEdit lab ( &dia );
246 QVBoxLayout lay( &dia ); 251 QVBoxLayout lay( &dia );
247 lab.setText( mPrefs->mPassiveSyncPort ); 252 lab.setText( mPrefs->mPassiveSyncPort );
248 lay.setMargin(7); 253 lay.setMargin(7);
249 lay.setSpacing(7); 254 lay.setSpacing(7);
250 int po = 9197+mTargetApp; 255 int po = 9197+mTargetApp;
251 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 256 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
252 lay.addWidget( &label); 257 lay.addWidget( &label);
253 lay.addWidget( &lab); 258 lay.addWidget( &lab);
254 259
255 QLineEdit lepw ( &dia ); 260 QLineEdit lepw ( &dia );
256 lepw.setText( mPrefs->mPassiveSyncPw ); 261 lepw.setText( mPrefs->mPassiveSyncPw );
257 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 262 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
258 lay.addWidget( &label2); 263 lay.addWidget( &label2);
259 lay.addWidget( &lepw); 264 lay.addWidget( &lepw);
260 dia.setFixedSize( 230,80 ); 265 dia.setFixedSize( 230,80 );
261 dia.setCaption( i18n("Enter port for Pi-Sync") ); 266 dia.setCaption( i18n("Enter port for Pi-Sync") );
262 QPushButton pb ( "OK", &dia); 267 QPushButton pb ( "OK", &dia);
263 lay.addWidget( &pb ); 268 lay.addWidget( &pb );
264 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 269 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
265 dia.show(); 270 dia.show();
266 if ( ! dia.exec() ) 271 if ( ! dia.exec() )
267 return; 272 return;
268 dia.hide(); 273 dia.hide();
269 qApp->processEvents(); 274 qApp->processEvents();
270 mPrefs->mPassiveSyncPw = lepw.text(); 275 mPrefs->mPassiveSyncPw = lepw.text();
271 mPrefs->mPassiveSyncPort = lab.text(); 276 mPrefs->mPassiveSyncPort = lab.text();
272 bool ok; 277 bool ok;
273 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 278 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
274 if ( ! ok ) { 279 if ( ! ok ) {
275 KMessageBox::information( 0, i18n("No valid port")); 280 KMessageBox::information( 0, i18n("No valid port"));
276 return; 281 return;
277 } 282 }
278 //qDebug("port %d ", port); 283 //qDebug("port %d ", port);
279 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 284 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
280 mServerSocket->setFileName( defaultFileName() ); 285 mServerSocket->setFileName( defaultFileName() );
281 //qDebug("connected "); 286 //qDebug("connected ");
282 if ( !mServerSocket->ok() ) { 287 if ( !mServerSocket->ok() ) {
283 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 288 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
284 delete mServerSocket; 289 delete mServerSocket;
285 mServerSocket = 0; 290 mServerSocket = 0;
286 return; 291 return;
287 } 292 }
288 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
289 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 293 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
290 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 294 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
291} 295}
292 296
293void KSyncManager::syncLocalFile() 297void KSyncManager::syncLocalFile()
294{ 298{
295 299
296 QString fn =mLastSyncedLocalFile; 300 QString fn =mPrefs->mLastSyncedLocalFile;
297 QString ext; 301 QString ext;
298 302
299 switch(mTargetApp) 303 switch(mTargetApp)
300 { 304 {
301 case (KAPI): 305 case (KAPI):
302 ext = "(*.vcf)"; 306 ext = "(*.vcf)";
303 break; 307 break;
304 case (KOPI): 308 case (KOPI):
305 ext = "(*.ics/*.vcs)"; 309 ext = "(*.ics/*.vcs)";
306 break; 310 break;
307 case (PWMPI): 311 case (PWMPI):
308 ext = "(*.pwm)"; 312 ext = "(*.pwm)";
309 break; 313 break;
310 default: 314 default:
311 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 315 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
312 break; 316 break;
313 317
314 } 318 }
315 319
316 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 320 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
317 if ( fn == "" ) 321 if ( fn == "" )
318 return; 322 return;
319 if ( syncWithFile( fn, false ) ) { 323 if ( syncWithFile( fn, false ) ) {
320 qDebug("syncLocalFile() successful "); 324 qDebug("syncLocalFile() successful ");
321 } 325 }
322 326
323} 327}
328
324bool KSyncManager::syncWithFile( QString fn , bool quick ) 329bool KSyncManager::syncWithFile( QString fn , bool quick )
325{ 330{
326 bool ret = false; 331 bool ret = false;
327 QFileInfo info; 332 QFileInfo info;
328 info.setFile( fn ); 333 info.setFile( fn );
329 QString mess; 334 QString mess;
330 bool loadbup = true; 335 bool loadbup = true;
331 if ( !info. exists() ) { 336 if ( !info. exists() ) {
332 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 337 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
333 int result = QMessageBox::warning( mParent, i18n("Warning!"), 338 int result = QMessageBox::warning( mParent, i18n("Warning!"),
334 mess ); 339 mess );
335 return ret; 340 return ret;
336 } 341 }
337 int result = 0; 342 int result = 0;
338 if ( !quick ) { 343 if ( !quick ) {
339 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 344 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
340 result = QMessageBox::warning( mParent, i18n("Warning!"), 345 result = QMessageBox::warning( mParent, i18n("Warning!"),
341 mess, 346 mess,
342 i18n("Sync"), i18n("Cancel"), 0, 347 i18n("Sync"), i18n("Cancel"), 0,
343 0, 1 ); 348 0, 1 );
344 if ( result ) 349 if ( result )
345 return false; 350 return false;
346 } 351 }
347 if ( mAskForPreferences ) 352 if ( mAskForPreferences )
348 edit_sync_options(); 353 edit_sync_options();
349 if ( result == 0 ) { 354 if ( result == 0 ) {
350 //qDebug("Now sycing ... "); 355 //qDebug("Now sycing ... ");
351 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 356 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
352 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 357 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
353 else 358 else
354 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 359 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
355 if ( ! quick ) 360 if ( ! quick )
356 mLastSyncedLocalFile = fn; 361 mPrefs->mLastSyncedLocalFile = fn;
357 } 362 }
358 return ret; 363 return ret;
359} 364}
365
360void KSyncManager::quickSyncLocalFile() 366void KSyncManager::quickSyncLocalFile()
361{ 367{
362 368
363 if ( syncWithFile( mLastSyncedLocalFile, false ) ) { 369 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) {
364 qDebug("quick syncLocalFile() successful "); 370 qDebug("quick syncLocalFile() successful ");
365 371
366 } 372 }
367} 373}
374
368void KSyncManager::multiSync( bool askforPrefs ) 375void KSyncManager::multiSync( bool askforPrefs )
369{ 376{
370 if (blockSave()) 377 if (blockSave())
371 return; 378 return;
372 setBlockSave(true); 379 setBlockSave(true);
373 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 380 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"), 381 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
375 question, 382 question,
376 i18n("Yes"), i18n("No"), 383 i18n("Yes"), i18n("No"),
377 0, 0 ) != 0 ) { 384 0, 0 ) != 0 ) {
378 setBlockSave(false); 385 setBlockSave(false);
379 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 386 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
380 return; 387 return;
381 } 388 }
382 mCurrentSyncDevice = i18n("Multiple profiles") ; 389 mCurrentSyncDevice = i18n("Multiple profiles") ;
383 mSyncAlgoPrefs = mRingSyncAlgoPrefs; 390 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
384 if ( askforPrefs ) { 391 if ( askforPrefs ) {
385 edit_sync_options(); 392 edit_sync_options();
386 mRingSyncAlgoPrefs = mSyncAlgoPrefs; 393 mRingSyncAlgoPrefs = mSyncAlgoPrefs;
387 } 394 }
388 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 395 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
389 qApp->processEvents(); 396 qApp->processEvents();
390 int num = ringSync() ; 397 int num = ringSync() ;
391 if ( num > 1 ) 398 if ( num > 1 )
392 ringSync(); 399 ringSync();
393 setBlockSave(false); 400 setBlockSave(false);
394 if ( num ) 401 if ( num )
395 emit save(); 402 emit save();
396 if ( num ) 403 if ( num )
397 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 404 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
398 else 405 else
399 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 406 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
400 return; 407 return;
401} 408}
409
402int KSyncManager::ringSync() 410int KSyncManager::ringSync()
403{ 411{
404 int syncedProfiles = 0; 412 int syncedProfiles = 0;
405 unsigned int i; 413 unsigned int i;
406 QTime timer; 414 QTime timer;
407 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 415 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
408 QStringList syncProfileNames = mSyncProfileNames; 416 QStringList syncProfileNames = mSyncProfileNames;
409 KSyncProfile* temp = new KSyncProfile (); 417 KSyncProfile* temp = new KSyncProfile ();
410 mAskForPreferences = false; 418 mAskForPreferences = false;
411 for ( i = 0; i < syncProfileNames.count(); ++i ) { 419 for ( i = 0; i < syncProfileNames.count(); ++i ) {
412 mCurrentSyncProfile = i; 420 mCurrentSyncProfile = i;
413 temp->setName(syncProfileNames[mCurrentSyncProfile]); 421 temp->setName(syncProfileNames[mCurrentSyncProfile]);
414 temp->readConfig(&config); 422 temp->readConfig(&config);
415 423
416 QString includeInRingSync; 424 QString includeInRingSync;
417 switch(mTargetApp) 425 switch(mTargetApp)
418 { 426 {
419 case (KAPI): 427 case (KAPI):
420 includeInRingSync = temp->getIncludeInRingSyncAB(); 428 includeInRingSync = temp->getIncludeInRingSyncAB();
421 break; 429 break;
422 case (KOPI): 430 case (KOPI):
423 includeInRingSync = temp->getIncludeInRingSync(); 431 includeInRingSync = temp->getIncludeInRingSync();
424 break; 432 break;
425 case (PWMPI): 433 case (PWMPI):
426 includeInRingSync = temp->getIncludeInRingSyncPWM(); 434 includeInRingSync = temp->getIncludeInRingSyncPWM();
427 break; 435 break;
428 default: 436 default:
429 qDebug("KSyncManager::ringSync: invalid apptype selected"); 437 qDebug("KSyncManager::ringSync: invalid apptype selected");
430 break; 438 break;
431 439
432 } 440 }
433 441
434 442
435 if ( includeInRingSync && ( i < 1 || i > 2 )) { 443 if ( includeInRingSync && ( i < 1 || i > 2 )) {
436 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 444 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
437 ++syncedProfiles; 445 ++syncedProfiles;
438 // mAskForPreferences = temp->getAskForPreferences(); 446 // mAskForPreferences = temp->getAskForPreferences();
439 mWriteBackFile = temp->getWriteBackFile(); 447 mWriteBackFile = temp->getWriteBackFile();
440 mWriteBackExistingOnly = temp->getWriteBackExisting(); 448 mWriteBackExistingOnly = temp->getWriteBackExisting();
441 mWriteBackInFuture = 0; 449 mWriteBackInFuture = 0;
442 if ( temp->getWriteBackFuture() ) 450 if ( temp->getWriteBackFuture() )
443 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 451 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
444 mShowSyncSummary = false; 452 mShowSyncSummary = false;
445 mCurrentSyncDevice = syncProfileNames[i] ; 453 mCurrentSyncDevice = syncProfileNames[i] ;
446 mCurrentSyncName = mLocalMachineName; 454 mCurrentSyncName = mLocalMachineName;
447 if ( i == 0 ) { 455 if ( i == 0 ) {
448 syncSharp(); 456 syncSharp();
449 } else { 457 } else {
450 if ( temp->getIsLocalFileSync() ) { 458 if ( temp->getIsLocalFileSync() ) {
451 switch(mTargetApp) 459 switch(mTargetApp)
452 { 460 {
453 case (KAPI): 461 case (KAPI):
454 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 462 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
455 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 463 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
456 break; 464 break;
457 case (KOPI): 465 case (KOPI):
458 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 466 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
459 mLastSyncedLocalFile = temp->getRemoteFileName(); 467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
460 break; 468 break;
461 case (PWMPI): 469 case (PWMPI):
462 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 470 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
463 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
464 break; 472 break;
465 default: 473 default:
466 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 474 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
467 break; 475 break;
468 } 476 }
469 } else { 477 } else {
470 if ( temp->getIsPhoneSync() ) { 478 if ( temp->getIsPhoneSync() ) {
471 mPhoneDevice = temp->getPhoneDevice( ) ; 479 mPhoneDevice = temp->getPhoneDevice( ) ;
472 mPhoneConnection = temp->getPhoneConnection( ); 480 mPhoneConnection = temp->getPhoneConnection( );
473 mPhoneModel = temp->getPhoneModel( ); 481 mPhoneModel = temp->getPhoneModel( );
474 syncPhone(); 482 syncPhone();
483 } else if ( temp->getIsPiSync() ) {
484 if ( mTargetApp == KAPI ) {
485 mPassWordPiSync = temp->getRemotePwAB();
486 mActiveSyncPort = temp->getRemotePortAB();
487 mActiveSyncIP = temp->getRemoteIPAB();
488 } else if ( mTargetApp == KOPI ) {
489 mPassWordPiSync = temp->getRemotePw();
490 mActiveSyncPort = temp->getRemotePort();
491 mActiveSyncIP = temp->getRemoteIP();
492 } else {
493 mPassWordPiSync = temp->getRemotePwPWM();
494 mActiveSyncPort = temp->getRemotePortPWM();
495 mActiveSyncIP = temp->getRemoteIPPWM();
496 }
497 syncPi();
475 } else 498 } else
476 syncRemote( temp, false ); 499 syncRemote( temp, false );
477 500
478 } 501 }
479 } 502 }
480 timer.start(); 503 timer.start();
481 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 504 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
482 while ( timer.elapsed () < 2000 ) { 505 while ( timer.elapsed () < 2000 ) {
483 qApp->processEvents(); 506 qApp->processEvents();
484#ifndef _WIN32_ 507#ifndef _WIN32_
485 sleep (1); 508 sleep (1);
486#endif 509#endif
487 } 510 }
488 511
489 } 512 }
490 513
491 } 514 }
492 delete temp; 515 delete temp;
493 return syncedProfiles; 516 return syncedProfiles;
494} 517}
495 518
496void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 519void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
497{ 520{
498 QString question; 521 QString question;
499 if ( ask ) { 522 if ( ask ) {
500 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 523 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
501 if ( QMessageBox::information( mParent, i18n("Sync"), 524 if ( QMessageBox::information( mParent, i18n("Sync"),
502 question, 525 question,
503 i18n("Yes"), i18n("No"), 526 i18n("Yes"), i18n("No"),
504 0, 0 ) != 0 ) 527 0, 0 ) != 0 )
505 return; 528 return;
506 } 529 }
507 530
508 QString preCommand; 531 QString preCommand;
509 QString localTempFile; 532 QString localTempFile;
510 QString postCommand; 533 QString postCommand;
511 534
512 switch(mTargetApp) 535 switch(mTargetApp)
513 { 536 {
514 case (KAPI): 537 case (KAPI):
515 preCommand = prof->getPreSyncCommandAB(); 538 preCommand = prof->getPreSyncCommandAB();
516 postCommand = prof->getPostSyncCommandAB(); 539 postCommand = prof->getPostSyncCommandAB();
517 localTempFile = prof->getLocalTempFileAB(); 540 localTempFile = prof->getLocalTempFileAB();
518 break; 541 break;
519 case (KOPI): 542 case (KOPI):
520 preCommand = prof->getPreSyncCommand(); 543 preCommand = prof->getPreSyncCommand();
521 postCommand = prof->getPostSyncCommand(); 544 postCommand = prof->getPostSyncCommand();
522 localTempFile = prof->getLocalTempFile(); 545 localTempFile = prof->getLocalTempFile();
523 break; 546 break;
524 case (PWMPI): 547 case (PWMPI):
525 preCommand = prof->getPreSyncCommandPWM(); 548 preCommand = prof->getPreSyncCommandPWM();
526 postCommand = prof->getPostSyncCommandPWM(); 549 postCommand = prof->getPostSyncCommandPWM();
527 localTempFile = prof->getLocalTempFilePWM(); 550 localTempFile = prof->getLocalTempFilePWM();
528 break; 551 break;
529 default: 552 default:
530 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 553 qDebug("KSyncManager::syncRemote: invalid apptype selected");
531 break; 554 break;
532 } 555 }
533 556
534 557
535 int fi; 558 int fi;
536 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 559 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
537 QString pwd = getPassword(); 560 QString pwd = getPassword();
538 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 561 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
539 562
540 } 563 }
541 int maxlen = 30; 564 int maxlen = 30;
542 if ( QApplication::desktop()->width() > 320 ) 565 if ( QApplication::desktop()->width() > 320 )
543 maxlen += 25; 566 maxlen += 25;
544 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 567 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
545 int fileSize = 0; 568 int fileSize = 0;
546 int result = system ( preCommand ); 569 int result = system ( preCommand );
547 // 0 : okay 570 // 0 : okay
548 // 256: no such file or dir 571 // 256: no such file or dir
549 // 572 //
550 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 573 qDebug("KO: Remote copy result(0 = okay): %d ",result );
551 if ( result != 0 ) { 574 if ( result != 0 ) {
552 unsigned int len = maxlen; 575 unsigned int len = maxlen;
553 while ( len < preCommand.length() ) { 576 while ( len < preCommand.length() ) {
554 preCommand.insert( len , "\n" ); 577 preCommand.insert( len , "\n" );
555 len += maxlen +2; 578 len += maxlen +2;
556 } 579 }
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) ; 580 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"), 581 QMessageBox::information( mParent, i18n("Sync - ERROR"),
559 question, 582 question,
560 i18n("Okay!")) ; 583 i18n("Okay!")) ;
561 mParent->topLevelWidget()->setCaption (""); 584 mParent->topLevelWidget()->setCaption ("KDE-Pim");
562 return; 585 return;
563 } 586 }
564 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 587 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
565 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 588 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
566 589
567
568
569 if ( syncWithFile( localTempFile, true ) ) { 590 if ( syncWithFile( localTempFile, true ) ) {
570// Event* e = mView->getLastSyncEvent(); 591
571// e->setReadOnly( false );
572// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
573// e->setReadOnly( true );
574 if ( mWriteBackFile ) { 592 if ( mWriteBackFile ) {
575 int fi; 593 int fi;
576 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 594 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
577 QString pwd = getPassword(); 595 QString pwd = getPassword();
578 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 596 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
579 597
580 } 598 }
581 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 599 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
582 result = system ( postCommand ); 600 result = system ( postCommand );
583 qDebug("Writing back file result: %d ", result); 601 qDebug("Writing back file result: %d ", result);
584 if ( result != 0 ) { 602 if ( result != 0 ) {
585 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
586 return; 604 return;
587 } else { 605 } else {
588 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 606 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
589 } 607 }
590 } 608 }
591 } 609 }
592 return; 610 return;
593} 611}
594 612
595void KSyncManager::edit_sync_options() 613void KSyncManager::edit_sync_options()
596{ 614{
597 //mDialogManager->showSyncOptions(); 615 //mDialogManager->showSyncOptions();
598 //mSyncAlgoPrefs 616 //mSyncAlgoPrefs
599 QDialog dia( mParent, "dia", true ); 617 QDialog dia( mParent, "dia", true );
600 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 618 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
601 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 619 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
602 QVBoxLayout lay ( &dia ); 620 QVBoxLayout lay ( &dia );
603 lay.setSpacing( 2 ); 621 lay.setSpacing( 2 );
604 lay.setMargin( 3 ); 622 lay.setMargin( 3 );
605 lay.addWidget(&gr); 623 lay.addWidget(&gr);
606 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 624 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
607 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 625 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
608 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 626 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
609 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 627 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
610 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 628 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
611 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 629 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
612 //QRadioButton both( i18n("Take both on conflict"), &gr ); 630 //QRadioButton both( i18n("Take both on conflict"), &gr );
613 QPushButton pb ( "OK", &dia); 631 QPushButton pb ( "OK", &dia);
614 lay.addWidget( &pb ); 632 lay.addWidget( &pb );
615 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 633 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
616 switch ( mSyncAlgoPrefs ) { 634 switch ( mSyncAlgoPrefs ) {
617 case 0: 635 case 0:
618 loc.setChecked( true); 636 loc.setChecked( true);
619 break; 637 break;
620 case 1: 638 case 1:
621 rem.setChecked( true ); 639 rem.setChecked( true );
622 break; 640 break;
623 case 2: 641 case 2:
624 newest.setChecked( true); 642 newest.setChecked( true);
625 break; 643 break;
626 case 3: 644 case 3:
627 ask.setChecked( true); 645 ask.setChecked( true);
628 break; 646 break;
629 case 4: 647 case 4:
630 f_loc.setChecked( true); 648 f_loc.setChecked( true);
631 break; 649 break;
632 case 5: 650 case 5:
633 f_rem.setChecked( true); 651 f_rem.setChecked( true);
634 break; 652 break;
635 case 6: 653 case 6:
636 // both.setChecked( true); 654 // both.setChecked( true);
637 break; 655 break;
638 default: 656 default:
639 break; 657 break;
640 } 658 }
641 if ( dia.exec() ) { 659 if ( dia.exec() ) {
642 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 660 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
643 } 661 }
644 662
645 663
646} 664}
665
647QString KSyncManager::getPassword( ) 666QString KSyncManager::getPassword( )
648{ 667{
649 QString retfile = ""; 668 QString retfile = "";
650 QDialog dia ( mParent, "input-dialog", true ); 669 QDialog dia ( mParent, "input-dialog", true );
651 QLineEdit lab ( &dia ); 670 QLineEdit lab ( &dia );
652 lab.setEchoMode( QLineEdit::Password ); 671 lab.setEchoMode( QLineEdit::Password );
653 QVBoxLayout lay( &dia ); 672 QVBoxLayout lay( &dia );
654 lay.setMargin(7); 673 lay.setMargin(7);
655 lay.setSpacing(7); 674 lay.setSpacing(7);
656 lay.addWidget( &lab); 675 lay.addWidget( &lab);
657 dia.setFixedSize( 230,50 ); 676 dia.setFixedSize( 230,50 );
658 dia.setCaption( i18n("Enter password") ); 677 dia.setCaption( i18n("Enter password") );
659 QPushButton pb ( "OK", &dia); 678 QPushButton pb ( "OK", &dia);
660 lay.addWidget( &pb ); 679 lay.addWidget( &pb );
661 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 680 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
662 dia.show(); 681 dia.show();
663 int res = dia.exec(); 682 int res = dia.exec();
664 if ( res ) 683 if ( res )
665 retfile = lab.text(); 684 retfile = lab.text();
666 dia.hide(); 685 dia.hide();
667 qApp->processEvents(); 686 qApp->processEvents();
668 return retfile; 687 return retfile;
669 688
670} 689}
671 690
672 691
673void KSyncManager::confSync() 692void KSyncManager::confSync()
674{ 693{
675 static KSyncPrefsDialog* sp = 0; 694 static KSyncPrefsDialog* sp = 0;
676 if ( ! sp ) { 695 if ( ! sp ) {
677 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 696 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
678 } 697 }
679 sp->usrReadConfig(); 698 sp->usrReadConfig();
680#ifndef DESKTOP_VERSION 699#ifndef DESKTOP_VERSION
681 sp->showMaximized(); 700 sp->showMaximized();
682#else 701#else
683 sp->show(); 702 sp->show();
684#endif 703#endif
685 sp->exec(); 704 sp->exec();
686 mSyncProfileNames = sp->getSyncProfileNames(); 705 mSyncProfileNames = sp->getSyncProfileNames();
687 mLocalMachineName = sp->getLocalMachineName (); 706 mLocalMachineName = sp->getLocalMachineName ();
688 fillSyncMenu(); 707 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
689} 708}
690 709
691void KSyncManager::syncSharp() 710void KSyncManager::syncSharp()
692{ 711{
712
693 if ( ! syncExternalApplication("sharp") ) 713 if ( ! syncExternalApplication("sharp") )
694 qDebug("ERROR sync sharp ");; 714 qDebug("ERROR sync sharp ");;
695} 715}
696 716
697bool KSyncManager::syncExternalApplication(QString resource) 717bool KSyncManager::syncExternalApplication(QString resource)
698{ 718{
699 719
700 emit save(); 720 emit save();
701 721
702 if ( mAskForPreferences ) 722 if ( mAskForPreferences )
703 edit_sync_options(); 723 edit_sync_options();
704 724
705 qDebug("sync %s", resource.latin1()); 725 qDebug("sync %s", resource.latin1());
706 726
707 bool syncOK = mImplementation->syncExternal(this, resource); 727 bool syncOK = mImplementation->syncExternal(this, resource);
708 728
709 return syncOK; 729 return syncOK;
710 730
711} 731}
712 732
713void KSyncManager::syncPhone() 733void KSyncManager::syncPhone()
714{ 734{
715 emit save();
716 735
717 qDebug("pending syncPhone(); "); 736 syncExternalApplication("phone");
718 //mView->syncPhone();
719 737
720} 738}
721 739
722void KSyncManager::showProgressBar(int percentage, QString caption, int total) 740void KSyncManager::showProgressBar(int percentage, QString caption, int total)
723{ 741{
724 if (!bar->isVisible()) 742 if (!bar->isVisible())
725 { 743 {
726 bar->setCaption (caption); 744 bar->setCaption (caption);
727 bar->setTotalSteps ( total ) ; 745 bar->setTotalSteps ( total ) ;
728 746
729 bar->show(); 747 bar->show();
730 } 748 }
731 749
732 bar->setProgress( percentage ); 750 bar->setProgress( percentage );
733} 751}
734 752
735void KSyncManager::hideProgressBar() 753void KSyncManager::hideProgressBar()
736{ 754{
737 bar->hide(); 755 bar->hide();
738} 756}
739 757
740bool KSyncManager::isProgressBarCanceled() 758bool KSyncManager::isProgressBarCanceled()
741{ 759{
742 return !bar->isVisible(); 760 return !bar->isVisible();
743} 761}
744 762
745QString KSyncManager::syncFileName() 763QString KSyncManager::syncFileName()
746{ 764{
747 765
748 QString fn = "tempfile"; 766 QString fn = "tempfile";
749 switch(mTargetApp) 767 switch(mTargetApp)
750 { 768 {
751 case (KAPI): 769 case (KAPI):
752 fn = "tempsyncab.vcf"; 770 fn = "tempsyncab.vcf";
753 break; 771 break;
754 case (KOPI): 772 case (KOPI):
755 fn = "tempsynccal.ics"; 773 fn = "tempsynccal.ics";
756 break; 774 break;
757 case (PWMPI): 775 case (PWMPI):
758 fn = "tempsyncpw.pwm"; 776 fn = "tempsyncpw.pwm";
759 break; 777 break;
760 default: 778 default:
761 break; 779 break;
762 } 780 }
763#ifdef _WIN32_ 781#ifdef _WIN32_
764 return locateLocal( "tmp", fn ); 782 return locateLocal( "tmp", fn );
765#else 783#else
766 return (QString( "/tmp/" )+ fn ); 784 return (QString( "/tmp/" )+ fn );
767#endif 785#endif
768} 786}
769 787
788
770void KSyncManager::syncPi() 789void KSyncManager::syncPi()
771{ 790{
772 qApp->processEvents(); 791 qApp->processEvents();
773 bool ok; 792 bool ok;
774 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 793 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
775 if ( ! ok ) { 794 if ( ! ok ) {
776 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 795 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
777 return; 796 return;
778 } 797 }
779 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 798 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
780 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 799 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
781 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 800 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
782 commandSocket->readFile( syncFileName() ); 801 commandSocket->readFile( syncFileName() );
783} 802}
784 803
785void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 804void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
786{ 805{
787 qDebug("MainWindow::deleteCommandSocket %d", state); 806 qDebug("MainWindow::deleteCommandSocket %d", state);
788 807
789 //enum { success, errorW, errorR, quiet }; 808 //enum { success, errorW, errorR, quiet };
790 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 809 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
791 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 810 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
792 delete s; 811 delete s;
793 if ( state == KCommandSocket::errorR ) { 812 if ( state == KCommandSocket::errorR ) {
794 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 813 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
795 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 814 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
796 commandSocket->sendStop(); 815 commandSocket->sendStop();
797 } 816 }
798 return; 817 return;
799 818
800 } else if ( state == KCommandSocket::errorW ) { 819 } else if ( state == KCommandSocket::errorW ) {
801 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 820 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
802 821
803 } else if ( state == KCommandSocket::successR ) { 822 } else if ( state == KCommandSocket::successR ) {
804 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 823 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
805 824
806 } else if ( state == KCommandSocket::successW ) { 825 } else if ( state == KCommandSocket::successW ) {
807 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 826 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
808 } 827 }
809 828
810 delete s; 829 delete s;
811} 830}
812 831
813void KSyncManager::readFileFromSocket() 832void KSyncManager::readFileFromSocket()
814{ 833{
815 QString fileName = syncFileName(); 834 QString fileName = syncFileName();
816 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 835 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
817 if ( ! syncWithFile( fileName , true ) ) { 836 if ( ! syncWithFile( fileName , true ) ) {
@@ -1108,49 +1127,48 @@ void KCommandSocket::readFileFromSocket()
1108 // wait for more 1127 // wait for more
1109 //qDebug("waitformore "); 1128 //qDebug("waitformore ");
1110 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1129 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1111 return; 1130 return;
1112 } 1131 }
1113 QString fileName = mFileName; 1132 QString fileName = mFileName;
1114 QFile file ( fileName ); 1133 QFile file ( fileName );
1115 if (!file.open( IO_WriteOnly ) ) { 1134 if (!file.open( IO_WriteOnly ) ) {
1116 mFileString = ""; 1135 mFileString = "";
1117 mRetVal = errorR; 1136 mRetVal = errorR;
1118 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 1137 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
1119 deleteSocket(); 1138 deleteSocket();
1120 return ; 1139 return ;
1121 1140
1122 } 1141 }
1123 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1142 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1124 QTextStream ts ( &file ); 1143 QTextStream ts ( &file );
1125 ts.setEncoding( QTextStream::Latin1 ); 1144 ts.setEncoding( QTextStream::Latin1 );
1126 ts << mFileString; 1145 ts << mFileString;
1127 file.close(); 1146 file.close();
1128 mFileString = ""; 1147 mFileString = "";
1129 mRetVal = successR; 1148 mRetVal = successR;
1130 mSocket->close(); 1149 mSocket->close();
1131 // if state is not idle, deleteSocket(); is called via 1150 // if state is not idle, deleteSocket(); is called via
1132 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1151 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1133 if ( mSocket->state() == QSocket::Idle ) 1152 if ( mSocket->state() == QSocket::Idle )
1134 deleteSocket(); 1153 deleteSocket();
1135} 1154}
1136 1155
1137void KCommandSocket::deleteSocket() 1156void KCommandSocket::deleteSocket()
1138{ 1157{
1139 if ( mTimerSocket->isActive () ) { 1158 if ( mTimerSocket->isActive () ) {
1140 mTimerSocket->stop(); 1159 mTimerSocket->stop();
1141 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1160 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1142 mRetVal = errorTO; 1161 mRetVal = errorTO;
1143 if ( mSocket ) { 1162 if ( mSocket ) {
1144 mSocket->close(); 1163 mSocket->close();
1145 if ( mSocket->state() == QSocket::Idle ) 1164 if ( mSocket->state() == QSocket::Idle )
1146 deleteSocket(); 1165 deleteSocket();
1147 return; 1166 return;
1148 } 1167 }
1149 } 1168 }
1150 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1169 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1151 if ( mSocket) 1170 if ( mSocket)
1152 delete mSocket; 1171 delete mSocket;
1153 mSocket = 0; 1172 mSocket = 0;
1154 emit commandFinished( this, mRetVal ); 1173 emit commandFinished( this, mRetVal );
1155} 1174}
1156
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 25892d8..7027894 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -72,156 +72,155 @@ private slots:
72}; 72};
73 73
74class KCommandSocket : public QObject 74class KCommandSocket : public QObject
75{ 75{
76 Q_OBJECT 76 Q_OBJECT
77public: 77public:
78 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 78 enum state { successR, errorR, successW, errorW, errorTO, quiet };
79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
80 void readFile( QString ); 80 void readFile( QString );
81 void writeFile( QString ); 81 void writeFile( QString );
82 void sendStop(); 82 void sendStop();
83 83
84 84
85signals: 85signals:
86 void commandFinished( KCommandSocket*, int ); 86 void commandFinished( KCommandSocket*, int );
87private slots: 87private slots:
88 void startReadFileFromSocket(); 88 void startReadFileFromSocket();
89 void readFileFromSocket(); 89 void readFileFromSocket();
90 void deleteSocket(); 90 void deleteSocket();
91 void writeFileToSocket(); 91 void writeFileToSocket();
92 private : 92 private :
93 QSocket* mSocket; 93 QSocket* mSocket;
94 QString mPassWord; 94 QString mPassWord;
95 Q_UINT16 mPort; 95 Q_UINT16 mPort;
96 QString mHost; 96 QString mHost;
97 QString mFileName; 97 QString mFileName;
98 QTimer* mTimerSocket; 98 QTimer* mTimerSocket;
99 int mRetVal; 99 int mRetVal;
100 QTime mTime; 100 QTime mTime;
101 QString mFileString; 101 QString mFileString;
102 bool mFirst; 102 bool mFirst;
103}; 103};
104 104
105 105
106class KSyncManager : public QObject 106class KSyncManager : public QObject
107{ 107{
108 Q_OBJECT 108 Q_OBJECT
109 109
110 public: 110 public:
111 enum TargetApp { 111 enum TargetApp {
112 KOPI = 0, 112 KOPI = 0,
113 KAPI = 1, 113 KAPI = 1,
114 PWMPI = 2 }; 114 PWMPI = 2 };
115 115
116 116
117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
118 ~KSyncManager() ; 118 ~KSyncManager() ;
119 119
120 void multiSync( bool askforPrefs );
120 bool blockSave() { return mBlockSaveFlag; } 121 bool blockSave() { return mBlockSaveFlag; }
121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 122 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
122 void setDefaultFileName( QString s) { mDefFileName = s ;} 123 void setDefaultFileName( QString s) { mDefFileName = s ;}
123 QString defaultFileName() { return mDefFileName ;} 124 QString defaultFileName() { return mDefFileName ;}
124 QString syncFileName(); 125 QString syncFileName();
125 void fillSyncMenu(); 126 void fillSyncMenu();
126 127
127 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 128 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
128 QString getCurrentSyncName() { return mCurrentSyncName; } 129 QString getCurrentSyncName() { return mCurrentSyncName; }
129 130
130 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 131 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
131 void hideProgressBar(); 132 void hideProgressBar();
132 bool isProgressBarCanceled(); 133 bool isProgressBarCanceled();
133 134
134 // sync stuff 135 // sync stuff
135 QString mLocalMachineName; 136 QString mLocalMachineName;
136 QStringList mExternSyncProfiles; 137 QStringList mExternSyncProfiles;
137 QStringList mSyncProfileNames; 138 QStringList mSyncProfileNames;
138 bool mAskForPreferences; 139 bool mAskForPreferences;
139 bool mShowSyncSummary; 140 bool mShowSyncSummary;
140 bool mShowSyncEvents; 141 bool mShowSyncEvents;
141 bool mShowTodoInAgenda; 142 bool mShowTodoInAgenda;
142 bool mWriteBackExistingOnly; 143 bool mWriteBackExistingOnly;
143 int mSyncAlgoPrefs; 144 int mSyncAlgoPrefs;
144 int mRingSyncAlgoPrefs; 145 int mRingSyncAlgoPrefs;
145 bool mWriteBackFile; 146 bool mWriteBackFile;
146 int mWriteBackInFuture; 147 int mWriteBackInFuture;
147 QString mPhoneDevice; 148 QString mPhoneDevice;
148 QString mPhoneConnection; 149 QString mPhoneConnection;
149 QString mPhoneModel; 150 QString mPhoneModel;
150 QString mLastSyncedLocalFile; // save!
151 QString mPassWordPiSync; 151 QString mPassWordPiSync;
152 QString mActiveSyncPort; 152 QString mActiveSyncPort;
153 QString mActiveSyncIP ; 153 QString mActiveSyncIP ;
154 154
155 signals: 155 signals:
156 void save(); 156 void save();
157 void request_file(); 157 void request_file();
158 void getFile( bool ); 158 void getFile( bool );
159 159
160 public slots: 160 public slots:
161 void slotSyncMenu( int ); 161 void slotSyncMenu( int );
162 void deleteCommandSocket(KCommandSocket*s, int state); 162 void deleteCommandSocket(KCommandSocket*s, int state);
163 void readFileFromSocket(); 163 void readFileFromSocket();
164 164
165 private: 165 private:
166 // LR ******************************* 166 // LR *******************************
167 // sync stuff! 167 // sync stuff!
168 void syncPi(); 168 void syncPi();
169 KServerSocket * mServerSocket; 169 KServerSocket * mServerSocket;
170 void enableQuick(); 170 void enableQuick();
171 KPimPrefs* mPrefs; 171 KPimPrefs* mPrefs;
172 QString mDefFileName; 172 QString mDefFileName;
173 QString mCurrentSyncDevice; 173 QString mCurrentSyncDevice;
174 QString mCurrentSyncName; 174 QString mCurrentSyncName;
175 void quickSyncLocalFile(); 175 void quickSyncLocalFile();
176 bool syncWithFile( QString fn , bool quick ); 176 bool syncWithFile( QString fn , bool quick );
177 void syncLocalFile(); 177 void syncLocalFile();
178 void syncPhone(); 178 void syncPhone();
179 void syncSharp(); 179 void syncSharp();
180 bool syncExternalApplication(QString); 180 bool syncExternalApplication(QString);
181 void multiSync( bool askforPrefs );
182 int mCurrentSyncProfile ; 181 int mCurrentSyncProfile ;
183 void syncRemote( KSyncProfile* prof, bool ask = true); 182 void syncRemote( KSyncProfile* prof, bool ask = true);
184 void edit_sync_options(); 183 void edit_sync_options();
185 int ringSync(); 184 int ringSync();
186 QString getPassword( ); 185 QString getPassword( );
187 186
188 private slots: 187 private slots:
189 void confSync(); 188 void confSync();
190 // ********************* 189 // *********************
191 190
192 private: 191 private:
193 bool mBlockSaveFlag; 192 bool mBlockSaveFlag;
194 193
195 194
196 QWidget* mParent; 195 QWidget* mParent;
197 KSyncInterface* mImplementation; 196 KSyncInterface* mImplementation;
198 TargetApp mTargetApp; 197 TargetApp mTargetApp;
199 QPopupMenu* mSyncMenu; 198 QPopupMenu* mSyncMenu;
200 199
201 QProgressBar* bar; 200 QProgressBar* bar;
202 201
203 202
204 203
205 204
206 205
207}; 206};
208 207
209 208
210class KSyncInterface 209class KSyncInterface
211{ 210{
212 211
213 212
214 public : 213 public :
215 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 214 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
216 215
217 virtual bool syncExternal(KSyncManager* manager, QString resource) 216 virtual bool syncExternal(KSyncManager* manager, QString resource)
218 { 217 {
219 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. 218 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager.
220 return false; 219 return false;
221 } 220 }
222 221
223 222
224}; 223};
225 224
226 225
227#endif 226#endif