summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-13 03:05:35 (UTC)
committer zautrix <zautrix>2004-10-13 03:05:35 (UTC)
commit8f852fddc2dc5b63511d6ad1c85a1e74141969ff (patch) (unidiff)
tree123c7e845e1520a4dcd50dd2361252cc6ab7a76a
parente7833b80c28e38bfe6316ee5fce150635cdebe03 (diff)
downloadkdepimpi-8f852fddc2dc5b63511d6ad1c85a1e74141969ff.zip
kdepimpi-8f852fddc2dc5b63511d6ad1c85a1e74141969ff.tar.gz
kdepimpi-8f852fddc2dc5b63511d6ad1c85a1e74141969ff.tar.bz2
fixed one syncing problem
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp17
-rw-r--r--libkdepim/ksyncmanager.cpp1
-rw-r--r--libkdepim/ksyncmanager.h1
-rw-r--r--libkdepim/ksyncprefsdialog.cpp14
-rw-r--r--libkdepim/ksyncprefsdialog.h2
-rw-r--r--libkdepim/ksyncprofile.cpp4
-rw-r--r--libkdepim/ksyncprofile.h3
7 files changed, 25 insertions, 17 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 282560f..205dbc8 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -689,2202 +689,2187 @@ void KABCore::export2phone()
689 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 689 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
690 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 690 KPimGlobalPrefs::instance()->mEx2PhoneModel );
691 691
692 QStringList uids = mViewManager->selectedUids(); 692 QStringList uids = mViewManager->selectedUids();
693 if ( uids.isEmpty() ) 693 if ( uids.isEmpty() )
694 return; 694 return;
695 695
696#ifdef _WIN32_ 696#ifdef _WIN32_
697 QString fileName = locateLocal("tmp", "phonefile.vcf"); 697 QString fileName = locateLocal("tmp", "phonefile.vcf");
698#else 698#else
699 QString fileName = "/tmp/phonefile.vcf"; 699 QString fileName = "/tmp/phonefile.vcf";
700#endif 700#endif
701 701
702 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 702 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
703 return; 703 return;
704 704
705 if ( PhoneAccess::writeToPhone( fileName ) ) 705 if ( PhoneAccess::writeToPhone( fileName ) )
706 qDebug("Export okay "); 706 qDebug("Export okay ");
707 else 707 else
708 qDebug("Error export contacts "); 708 qDebug("Error export contacts ");
709 709
710 710
711#if 0 711#if 0
712 712
713 setCaption( i18n("Writing to phone...")); 713 setCaption( i18n("Writing to phone..."));
714 if ( PhoneFormat::writeToPhone( cal ) ) 714 if ( PhoneFormat::writeToPhone( cal ) )
715 setCaption( i18n("Export to phone successful!")); 715 setCaption( i18n("Export to phone successful!"));
716 else 716 else
717 setCaption( i18n("Error exporting to phone!")); 717 setCaption( i18n("Error exporting to phone!"));
718#endif 718#endif
719 719
720 720
721} 721}
722void KABCore::beamVCard() 722void KABCore::beamVCard()
723{ 723{
724 QStringList uids = mViewManager->selectedUids(); 724 QStringList uids = mViewManager->selectedUids();
725 if ( !uids.isEmpty() ) 725 if ( !uids.isEmpty() )
726 beamVCard( uids ); 726 beamVCard( uids );
727} 727}
728 728
729 729
730void KABCore::beamVCard(const QStringList& uids) 730void KABCore::beamVCard(const QStringList& uids)
731{ 731{
732/*US 732/*US
733 QString beamFilename; 733 QString beamFilename;
734 Opie::OPimContact c; 734 Opie::OPimContact c;
735 if ( actionPersonal->isOn() ) { 735 if ( actionPersonal->isOn() ) {
736 beamFilename = addressbookPersonalVCardName(); 736 beamFilename = addressbookPersonalVCardName();
737 if ( !QFile::exists( beamFilename ) ) 737 if ( !QFile::exists( beamFilename ) )
738 return; // can't beam a non-existent file 738 return; // can't beam a non-existent file
739 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 739 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
740 beamFilename ); 740 beamFilename );
741 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 741 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
742 Opie::OPimContactAccess::List allList = access->allRecords(); 742 Opie::OPimContactAccess::List allList = access->allRecords();
743 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 743 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
744 c = *it; 744 c = *it;
745 745
746 delete access; 746 delete access;
747 } else { 747 } else {
748 unlink( beamfile ); // delete if exists 748 unlink( beamfile ); // delete if exists
749 mkdir("/tmp/obex/", 0755); 749 mkdir("/tmp/obex/", 0755);
750 c = m_abView -> currentEntry(); 750 c = m_abView -> currentEntry();
751 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 751 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
752 beamfile ); 752 beamfile );
753 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 753 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
754 access->add( c ); 754 access->add( c );
755 access->save(); 755 access->save();
756 delete access; 756 delete access;
757 757
758 beamFilename = beamfile; 758 beamFilename = beamfile;
759 } 759 }
760 760
761 owarn << "Beaming: " << beamFilename << oendl; 761 owarn << "Beaming: " << beamFilename << oendl;
762*/ 762*/
763 763
764#if 0 764#if 0
765 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 765 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
766 766
767 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 767 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
768 768
769 QString name = "contact.vcf"; 769 QString name = "contact.vcf";
770 770
771 QString fileName = dirName + "/" + name; 771 QString fileName = dirName + "/" + name;
772#endif 772#endif
773 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 773 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
774 // 774 //
775 QString fileName = "/tmp/kapibeamfile.vcf"; 775 QString fileName = "/tmp/kapibeamfile.vcf";
776 776
777 777
778 //QDir().mkdir( dirName, true ); 778 //QDir().mkdir( dirName, true );
779 779
780 780
781 KABC::VCardConverter converter; 781 KABC::VCardConverter converter;
782 QString description; 782 QString description;
783 QString datastream; 783 QString datastream;
784 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 784 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
785 KABC::Addressee a = mAddressBook->findByUid( *it ); 785 KABC::Addressee a = mAddressBook->findByUid( *it );
786 786
787 if ( a.isEmpty() ) 787 if ( a.isEmpty() )
788 continue; 788 continue;
789 789
790 if (description.isEmpty()) 790 if (description.isEmpty())
791 description = a.formattedName(); 791 description = a.formattedName();
792 792
793 QString vcard; 793 QString vcard;
794 converter.addresseeToVCard( a, vcard ); 794 converter.addresseeToVCard( a, vcard );
795 int start = 0; 795 int start = 0;
796 int next; 796 int next;
797 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 797 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
798 int semi = vcard.find(";", next); 798 int semi = vcard.find(";", next);
799 int dopp = vcard.find(":", next); 799 int dopp = vcard.find(":", next);
800 int sep; 800 int sep;
801 if ( semi < dopp && semi >= 0 ) 801 if ( semi < dopp && semi >= 0 )
802 sep = semi ; 802 sep = semi ;
803 else 803 else
804 sep = dopp; 804 sep = dopp;
805 datastream +=vcard.mid( start, next - start); 805 datastream +=vcard.mid( start, next - start);
806 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 806 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
807 start = sep; 807 start = sep;
808 } 808 }
809 datastream += vcard.mid( start,vcard.length() ); 809 datastream += vcard.mid( start,vcard.length() );
810 } 810 }
811#ifndef DESKTOP_VERSION 811#ifndef DESKTOP_VERSION
812 QFile outFile(fileName); 812 QFile outFile(fileName);
813 if ( outFile.open(IO_WriteOnly) ) { 813 if ( outFile.open(IO_WriteOnly) ) {
814 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 814 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
815 QTextStream t( &outFile ); // use a text stream 815 QTextStream t( &outFile ); // use a text stream
816 t.setEncoding( QTextStream::UnicodeUTF8 ); 816 t.setEncoding( QTextStream::UnicodeUTF8 );
817 t <<datastream; 817 t <<datastream;
818 outFile.close(); 818 outFile.close();
819 Ir *ir = new Ir( this ); 819 Ir *ir = new Ir( this );
820 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 820 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
821 ir->send( fileName, description, "text/x-vCard" ); 821 ir->send( fileName, description, "text/x-vCard" );
822 } else { 822 } else {
823 qDebug("Error open temp beam file "); 823 qDebug("Error open temp beam file ");
824 return; 824 return;
825 } 825 }
826#endif 826#endif
827 827
828} 828}
829 829
830void KABCore::beamDone( Ir *ir ) 830void KABCore::beamDone( Ir *ir )
831{ 831{
832#ifndef DESKTOP_VERSION 832#ifndef DESKTOP_VERSION
833 delete ir; 833 delete ir;
834#endif 834#endif
835} 835}
836 836
837 837
838void KABCore::browse( const QString& url ) 838void KABCore::browse( const QString& url )
839{ 839{
840#ifndef KAB_EMBEDDED 840#ifndef KAB_EMBEDDED
841 kapp->invokeBrowser( url ); 841 kapp->invokeBrowser( url );
842#else //KAB_EMBEDDED 842#else //KAB_EMBEDDED
843 qDebug("KABCore::browse must be fixed"); 843 qDebug("KABCore::browse must be fixed");
844#endif //KAB_EMBEDDED 844#endif //KAB_EMBEDDED
845} 845}
846 846
847void KABCore::selectAllContacts() 847void KABCore::selectAllContacts()
848{ 848{
849 mViewManager->setSelected( QString::null, true ); 849 mViewManager->setSelected( QString::null, true );
850} 850}
851 851
852void KABCore::deleteContacts() 852void KABCore::deleteContacts()
853{ 853{
854 QStringList uidList = mViewManager->selectedUids(); 854 QStringList uidList = mViewManager->selectedUids();
855 deleteContacts( uidList ); 855 deleteContacts( uidList );
856} 856}
857 857
858void KABCore::deleteContacts( const QStringList &uids ) 858void KABCore::deleteContacts( const QStringList &uids )
859{ 859{
860 if ( uids.count() > 0 ) { 860 if ( uids.count() > 0 ) {
861 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 861 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
862 UndoStack::instance()->push( command ); 862 UndoStack::instance()->push( command );
863 RedoStack::instance()->clear(); 863 RedoStack::instance()->clear();
864 864
865 // now if we deleted anything, refresh 865 // now if we deleted anything, refresh
866 setContactSelected( QString::null ); 866 setContactSelected( QString::null );
867 setModified( true ); 867 setModified( true );
868 } 868 }
869} 869}
870 870
871void KABCore::copyContacts() 871void KABCore::copyContacts()
872{ 872{
873 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 873 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
874 874
875 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 875 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
876 876
877 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 877 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
878 878
879 QClipboard *cb = QApplication::clipboard(); 879 QClipboard *cb = QApplication::clipboard();
880 cb->setText( clipText ); 880 cb->setText( clipText );
881} 881}
882 882
883void KABCore::cutContacts() 883void KABCore::cutContacts()
884{ 884{
885 QStringList uidList = mViewManager->selectedUids(); 885 QStringList uidList = mViewManager->selectedUids();
886 886
887//US if ( uidList.size() > 0 ) { 887//US if ( uidList.size() > 0 ) {
888 if ( uidList.count() > 0 ) { 888 if ( uidList.count() > 0 ) {
889 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 889 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
890 UndoStack::instance()->push( command ); 890 UndoStack::instance()->push( command );
891 RedoStack::instance()->clear(); 891 RedoStack::instance()->clear();
892 892
893 setModified( true ); 893 setModified( true );
894 } 894 }
895} 895}
896 896
897void KABCore::pasteContacts() 897void KABCore::pasteContacts()
898{ 898{
899 QClipboard *cb = QApplication::clipboard(); 899 QClipboard *cb = QApplication::clipboard();
900 900
901 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 901 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
902 902
903 pasteContacts( list ); 903 pasteContacts( list );
904} 904}
905 905
906void KABCore::pasteContacts( KABC::Addressee::List &list ) 906void KABCore::pasteContacts( KABC::Addressee::List &list )
907{ 907{
908 KABC::Resource *resource = requestResource( this ); 908 KABC::Resource *resource = requestResource( this );
909 KABC::Addressee::List::Iterator it; 909 KABC::Addressee::List::Iterator it;
910 for ( it = list.begin(); it != list.end(); ++it ) 910 for ( it = list.begin(); it != list.end(); ++it )
911 (*it).setResource( resource ); 911 (*it).setResource( resource );
912 912
913 PwPasteCommand *command = new PwPasteCommand( this, list ); 913 PwPasteCommand *command = new PwPasteCommand( this, list );
914 UndoStack::instance()->push( command ); 914 UndoStack::instance()->push( command );
915 RedoStack::instance()->clear(); 915 RedoStack::instance()->clear();
916 916
917 setModified( true ); 917 setModified( true );
918} 918}
919 919
920void KABCore::setWhoAmI() 920void KABCore::setWhoAmI()
921{ 921{
922 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 922 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
923 923
924 if ( addrList.count() > 1 ) { 924 if ( addrList.count() > 1 ) {
925 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 925 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
926 return; 926 return;
927 } 927 }
928 928
929 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 929 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
930 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 930 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
931 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 931 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
932} 932}
933 933
934void KABCore::setCategories() 934void KABCore::setCategories()
935{ 935{
936 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 936 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
937 if ( !dlg.exec() ) 937 if ( !dlg.exec() )
938 return; 938 return;
939 939
940 bool merge = false; 940 bool merge = false;
941 QString msg = i18n( "Merge with existing categories?" ); 941 QString msg = i18n( "Merge with existing categories?" );
942 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 942 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
943 merge = true; 943 merge = true;
944 944
945 QStringList categories = dlg.selectedCategories(); 945 QStringList categories = dlg.selectedCategories();
946 946
947 QStringList uids = mViewManager->selectedUids(); 947 QStringList uids = mViewManager->selectedUids();
948 QStringList::Iterator it; 948 QStringList::Iterator it;
949 for ( it = uids.begin(); it != uids.end(); ++it ) { 949 for ( it = uids.begin(); it != uids.end(); ++it ) {
950 KABC::Addressee addr = mAddressBook->findByUid( *it ); 950 KABC::Addressee addr = mAddressBook->findByUid( *it );
951 if ( !addr.isEmpty() ) { 951 if ( !addr.isEmpty() ) {
952 if ( !merge ) 952 if ( !merge )
953 addr.setCategories( categories ); 953 addr.setCategories( categories );
954 else { 954 else {
955 QStringList addrCategories = addr.categories(); 955 QStringList addrCategories = addr.categories();
956 QStringList::Iterator catIt; 956 QStringList::Iterator catIt;
957 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 957 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
958 if ( !addrCategories.contains( *catIt ) ) 958 if ( !addrCategories.contains( *catIt ) )
959 addrCategories.append( *catIt ); 959 addrCategories.append( *catIt );
960 } 960 }
961 addr.setCategories( addrCategories ); 961 addr.setCategories( addrCategories );
962 } 962 }
963 963
964 mAddressBook->insertAddressee( addr ); 964 mAddressBook->insertAddressee( addr );
965 } 965 }
966 } 966 }
967 967
968 if ( uids.count() > 0 ) 968 if ( uids.count() > 0 )
969 setModified( true ); 969 setModified( true );
970} 970}
971 971
972void KABCore::setSearchFields( const KABC::Field::List &fields ) 972void KABCore::setSearchFields( const KABC::Field::List &fields )
973{ 973{
974 mIncSearchWidget->setFields( fields ); 974 mIncSearchWidget->setFields( fields );
975} 975}
976 976
977void KABCore::incrementalSearch( const QString& text ) 977void KABCore::incrementalSearch( const QString& text )
978{ 978{
979 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 979 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
980} 980}
981 981
982void KABCore::setModified() 982void KABCore::setModified()
983{ 983{
984 setModified( true ); 984 setModified( true );
985} 985}
986 986
987void KABCore::setModifiedWOrefresh() 987void KABCore::setModifiedWOrefresh()
988{ 988{
989 // qDebug("KABCore::setModifiedWOrefresh() "); 989 // qDebug("KABCore::setModifiedWOrefresh() ");
990 mModified = true; 990 mModified = true;
991 mActionSave->setEnabled( mModified ); 991 mActionSave->setEnabled( mModified );
992#ifdef DESKTOP_VERSION 992#ifdef DESKTOP_VERSION
993 mDetails->refreshView(); 993 mDetails->refreshView();
994#endif 994#endif
995 995
996} 996}
997void KABCore::setModified( bool modified ) 997void KABCore::setModified( bool modified )
998{ 998{
999 mModified = modified; 999 mModified = modified;
1000 mActionSave->setEnabled( mModified ); 1000 mActionSave->setEnabled( mModified );
1001 1001
1002 if ( modified ) 1002 if ( modified )
1003 mJumpButtonBar->recreateButtons(); 1003 mJumpButtonBar->recreateButtons();
1004 1004
1005 mViewManager->refreshView(); 1005 mViewManager->refreshView();
1006 mDetails->refreshView(); 1006 mDetails->refreshView();
1007 1007
1008} 1008}
1009 1009
1010bool KABCore::modified() const 1010bool KABCore::modified() const
1011{ 1011{
1012 return mModified; 1012 return mModified;
1013} 1013}
1014 1014
1015void KABCore::contactModified( const KABC::Addressee &addr ) 1015void KABCore::contactModified( const KABC::Addressee &addr )
1016{ 1016{
1017 1017
1018 Command *command = 0; 1018 Command *command = 0;
1019 QString uid; 1019 QString uid;
1020 1020
1021 // check if it exists already 1021 // check if it exists already
1022 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1022 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1023 if ( origAddr.isEmpty() ) 1023 if ( origAddr.isEmpty() )
1024 command = new PwNewCommand( mAddressBook, addr ); 1024 command = new PwNewCommand( mAddressBook, addr );
1025 else { 1025 else {
1026 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1026 command = new PwEditCommand( mAddressBook, origAddr, addr );
1027 uid = addr.uid(); 1027 uid = addr.uid();
1028 } 1028 }
1029 1029
1030 UndoStack::instance()->push( command ); 1030 UndoStack::instance()->push( command );
1031 RedoStack::instance()->clear(); 1031 RedoStack::instance()->clear();
1032 1032
1033 setModified( true ); 1033 setModified( true );
1034} 1034}
1035 1035
1036void KABCore::newContact() 1036void KABCore::newContact()
1037{ 1037{
1038 1038
1039 1039
1040 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1040 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1041 1041
1042 QPtrList<KRES::Resource> kresResources; 1042 QPtrList<KRES::Resource> kresResources;
1043 QPtrListIterator<KABC::Resource> it( kabcResources ); 1043 QPtrListIterator<KABC::Resource> it( kabcResources );
1044 KABC::Resource *resource; 1044 KABC::Resource *resource;
1045 while ( ( resource = it.current() ) != 0 ) { 1045 while ( ( resource = it.current() ) != 0 ) {
1046 ++it; 1046 ++it;
1047 if ( !resource->readOnly() ) { 1047 if ( !resource->readOnly() ) {
1048 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1048 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1049 if ( res ) 1049 if ( res )
1050 kresResources.append( res ); 1050 kresResources.append( res );
1051 } 1051 }
1052 } 1052 }
1053 1053
1054 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1054 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1055 resource = static_cast<KABC::Resource*>( res ); 1055 resource = static_cast<KABC::Resource*>( res );
1056 1056
1057 if ( resource ) { 1057 if ( resource ) {
1058 KABC::Addressee addr; 1058 KABC::Addressee addr;
1059 addr.setResource( resource ); 1059 addr.setResource( resource );
1060 mEditorDialog->setAddressee( addr ); 1060 mEditorDialog->setAddressee( addr );
1061 KApplication::execDialog ( mEditorDialog ); 1061 KApplication::execDialog ( mEditorDialog );
1062 1062
1063 } else 1063 } else
1064 return; 1064 return;
1065 1065
1066 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1066 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1067 1067
1068 1068
1069} 1069}
1070 1070
1071void KABCore::addEmail( QString aStr ) 1071void KABCore::addEmail( QString aStr )
1072{ 1072{
1073#ifndef KAB_EMBEDDED 1073#ifndef KAB_EMBEDDED
1074 QString fullName, email; 1074 QString fullName, email;
1075 1075
1076 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1076 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1077 1077
1078 // Try to lookup the addressee matching the email address 1078 // Try to lookup the addressee matching the email address
1079 bool found = false; 1079 bool found = false;
1080 QStringList emailList; 1080 QStringList emailList;
1081 KABC::AddressBook::Iterator it; 1081 KABC::AddressBook::Iterator it;
1082 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1082 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1083 emailList = (*it).emails(); 1083 emailList = (*it).emails();
1084 if ( emailList.contains( email ) > 0 ) { 1084 if ( emailList.contains( email ) > 0 ) {
1085 found = true; 1085 found = true;
1086 (*it).setNameFromString( fullName ); 1086 (*it).setNameFromString( fullName );
1087 editContact( (*it).uid() ); 1087 editContact( (*it).uid() );
1088 } 1088 }
1089 } 1089 }
1090 1090
1091 if ( !found ) { 1091 if ( !found ) {
1092 KABC::Addressee addr; 1092 KABC::Addressee addr;
1093 addr.setNameFromString( fullName ); 1093 addr.setNameFromString( fullName );
1094 addr.insertEmail( email, true ); 1094 addr.insertEmail( email, true );
1095 1095
1096 mAddressBook->insertAddressee( addr ); 1096 mAddressBook->insertAddressee( addr );
1097 mViewManager->refreshView( addr.uid() ); 1097 mViewManager->refreshView( addr.uid() );
1098 editContact( addr.uid() ); 1098 editContact( addr.uid() );
1099 } 1099 }
1100#else //KAB_EMBEDDED 1100#else //KAB_EMBEDDED
1101 qDebug("KABCore::addEmail finsih method"); 1101 qDebug("KABCore::addEmail finsih method");
1102#endif //KAB_EMBEDDED 1102#endif //KAB_EMBEDDED
1103} 1103}
1104 1104
1105void KABCore::importVCard( const KURL &url, bool showPreview ) 1105void KABCore::importVCard( const KURL &url, bool showPreview )
1106{ 1106{
1107 mXXPortManager->importVCard( url, showPreview ); 1107 mXXPortManager->importVCard( url, showPreview );
1108} 1108}
1109void KABCore::importFromOL() 1109void KABCore::importFromOL()
1110{ 1110{
1111#ifdef _WIN32_ 1111#ifdef _WIN32_
1112 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1112 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1113 idgl->exec(); 1113 idgl->exec();
1114 KABC::Addressee::List list = idgl->getAddressList(); 1114 KABC::Addressee::List list = idgl->getAddressList();
1115 if ( list.count() > 0 ) { 1115 if ( list.count() > 0 ) {
1116 KABC::Addressee::List listNew; 1116 KABC::Addressee::List listNew;
1117 KABC::Addressee::List listExisting; 1117 KABC::Addressee::List listExisting;
1118 KABC::Addressee::List::Iterator it; 1118 KABC::Addressee::List::Iterator it;
1119 KABC::AddressBook::Iterator iter; 1119 KABC::AddressBook::Iterator iter;
1120 for ( it = list.begin(); it != list.end(); ++it ) { 1120 for ( it = list.begin(); it != list.end(); ++it ) {
1121 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1121 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1122 listNew.append( (*it) ); 1122 listNew.append( (*it) );
1123 else 1123 else
1124 listExisting.append( (*it) ); 1124 listExisting.append( (*it) );
1125 } 1125 }
1126 if ( listExisting.count() > 0 ) 1126 if ( listExisting.count() > 0 )
1127 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1127 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1128 if ( listNew.count() > 0 ) { 1128 if ( listNew.count() > 0 ) {
1129 pasteWithNewUid = false; 1129 pasteWithNewUid = false;
1130 pasteContacts( listNew ); 1130 pasteContacts( listNew );
1131 pasteWithNewUid = true; 1131 pasteWithNewUid = true;
1132 } 1132 }
1133 } 1133 }
1134 delete idgl; 1134 delete idgl;
1135#endif 1135#endif
1136} 1136}
1137 1137
1138void KABCore::importVCard( const QString &vCard, bool showPreview ) 1138void KABCore::importVCard( const QString &vCard, bool showPreview )
1139{ 1139{
1140 mXXPortManager->importVCard( vCard, showPreview ); 1140 mXXPortManager->importVCard( vCard, showPreview );
1141} 1141}
1142 1142
1143//US added a second method without defaultparameter 1143//US added a second method without defaultparameter
1144void KABCore::editContact2() { 1144void KABCore::editContact2() {
1145 editContact( QString::null ); 1145 editContact( QString::null );
1146} 1146}
1147 1147
1148void KABCore::editContact( const QString &uid ) 1148void KABCore::editContact( const QString &uid )
1149{ 1149{
1150 1150
1151 if ( mExtensionManager->isQuickEditVisible() ) 1151 if ( mExtensionManager->isQuickEditVisible() )
1152 return; 1152 return;
1153 1153
1154 // First, locate the contact entry 1154 // First, locate the contact entry
1155 QString localUID = uid; 1155 QString localUID = uid;
1156 if ( localUID.isNull() ) { 1156 if ( localUID.isNull() ) {
1157 QStringList uidList = mViewManager->selectedUids(); 1157 QStringList uidList = mViewManager->selectedUids();
1158 if ( uidList.count() > 0 ) 1158 if ( uidList.count() > 0 )
1159 localUID = *( uidList.at( 0 ) ); 1159 localUID = *( uidList.at( 0 ) );
1160 } 1160 }
1161 1161
1162 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1162 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1163 if ( !addr.isEmpty() ) { 1163 if ( !addr.isEmpty() ) {
1164 mEditorDialog->setAddressee( addr ); 1164 mEditorDialog->setAddressee( addr );
1165 KApplication::execDialog ( mEditorDialog ); 1165 KApplication::execDialog ( mEditorDialog );
1166 } 1166 }
1167} 1167}
1168 1168
1169/** 1169/**
1170 Shows or edits the detail view for the given uid. If the uid is QString::null, 1170 Shows or edits the detail view for the given uid. If the uid is QString::null,
1171 the method will try to find a selected addressee in the view. 1171 the method will try to find a selected addressee in the view.
1172 */ 1172 */
1173void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1173void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1174{ 1174{
1175 if ( mMultipleViewsAtOnce ) 1175 if ( mMultipleViewsAtOnce )
1176 { 1176 {
1177 editContact( uid ); 1177 editContact( uid );
1178 } 1178 }
1179 else 1179 else
1180 { 1180 {
1181 setDetailsVisible( true ); 1181 setDetailsVisible( true );
1182 mActionDetails->setChecked(true); 1182 mActionDetails->setChecked(true);
1183 } 1183 }
1184 1184
1185} 1185}
1186 1186
1187void KABCore::save() 1187void KABCore::save()
1188{ 1188{
1189 if (syncManager->blockSave()) 1189 if (syncManager->blockSave())
1190 return; 1190 return;
1191 if ( !mModified ) 1191 if ( !mModified )
1192 return; 1192 return;
1193 1193
1194 syncManager->setBlockSave(true); 1194 syncManager->setBlockSave(true);
1195 QString text = i18n( "There was an error while attempting to save\n the " 1195 QString text = i18n( "There was an error while attempting to save\n the "
1196 "address book. Please check that some \nother application is " 1196 "address book. Please check that some \nother application is "
1197 "not using it. " ); 1197 "not using it. " );
1198 statusMessage(i18n("Saving addressbook ... ")); 1198 statusMessage(i18n("Saving addressbook ... "));
1199#ifndef KAB_EMBEDDED 1199#ifndef KAB_EMBEDDED
1200 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1200 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1201 if ( !b || !b->save() ) { 1201 if ( !b || !b->save() ) {
1202 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1202 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1203 } 1203 }
1204#else //KAB_EMBEDDED 1204#else //KAB_EMBEDDED
1205 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1205 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1206 if ( !b || !b->save() ) { 1206 if ( !b || !b->save() ) {
1207 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1207 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1208 } 1208 }
1209#endif //KAB_EMBEDDED 1209#endif //KAB_EMBEDDED
1210 1210
1211 statusMessage(i18n("Addressbook saved!")); 1211 statusMessage(i18n("Addressbook saved!"));
1212 setModified( false ); 1212 setModified( false );
1213 syncManager->setBlockSave(false); 1213 syncManager->setBlockSave(false);
1214} 1214}
1215 1215
1216void KABCore::statusMessage(QString mess , int time ) 1216void KABCore::statusMessage(QString mess , int time )
1217{ 1217{
1218 //topLevelWidget()->setCaption( mess ); 1218 //topLevelWidget()->setCaption( mess );
1219 // pending setting timer to revome message 1219 // pending setting timer to revome message
1220} 1220}
1221void KABCore::undo() 1221void KABCore::undo()
1222{ 1222{
1223 UndoStack::instance()->undo(); 1223 UndoStack::instance()->undo();
1224 1224
1225 // Refresh the view 1225 // Refresh the view
1226 mViewManager->refreshView(); 1226 mViewManager->refreshView();
1227} 1227}
1228 1228
1229void KABCore::redo() 1229void KABCore::redo()
1230{ 1230{
1231 RedoStack::instance()->redo(); 1231 RedoStack::instance()->redo();
1232 1232
1233 // Refresh the view 1233 // Refresh the view
1234 mViewManager->refreshView(); 1234 mViewManager->refreshView();
1235} 1235}
1236 1236
1237void KABCore::setJumpButtonBarVisible( bool visible ) 1237void KABCore::setJumpButtonBarVisible( bool visible )
1238{ 1238{
1239 if (mMultipleViewsAtOnce) 1239 if (mMultipleViewsAtOnce)
1240 { 1240 {
1241 if ( visible ) 1241 if ( visible )
1242 mJumpButtonBar->show(); 1242 mJumpButtonBar->show();
1243 else 1243 else
1244 mJumpButtonBar->hide(); 1244 mJumpButtonBar->hide();
1245 } 1245 }
1246 else 1246 else
1247 { 1247 {
1248 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1248 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1249 if (mViewManager->isVisible()) 1249 if (mViewManager->isVisible())
1250 { 1250 {
1251 if ( visible ) 1251 if ( visible )
1252 mJumpButtonBar->show(); 1252 mJumpButtonBar->show();
1253 else 1253 else
1254 mJumpButtonBar->hide(); 1254 mJumpButtonBar->hide();
1255 } 1255 }
1256 else 1256 else
1257 { 1257 {
1258 mJumpButtonBar->hide(); 1258 mJumpButtonBar->hide();
1259 } 1259 }
1260 } 1260 }
1261} 1261}
1262 1262
1263 1263
1264void KABCore::setDetailsToState() 1264void KABCore::setDetailsToState()
1265{ 1265{
1266 setDetailsVisible( mActionDetails->isChecked() ); 1266 setDetailsVisible( mActionDetails->isChecked() );
1267} 1267}
1268 1268
1269 1269
1270 1270
1271void KABCore::setDetailsVisible( bool visible ) 1271void KABCore::setDetailsVisible( bool visible )
1272{ 1272{
1273 if (visible && mDetails->isHidden()) 1273 if (visible && mDetails->isHidden())
1274 { 1274 {
1275 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1275 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1276 if ( addrList.count() > 0 ) 1276 if ( addrList.count() > 0 )
1277 mDetails->setAddressee( addrList[ 0 ] ); 1277 mDetails->setAddressee( addrList[ 0 ] );
1278 } 1278 }
1279 1279
1280 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1280 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1281 // the listview and the detailview. We do that by changing the splitbar size. 1281 // the listview and the detailview. We do that by changing the splitbar size.
1282 if (mMultipleViewsAtOnce) 1282 if (mMultipleViewsAtOnce)
1283 { 1283 {
1284 if ( visible ) 1284 if ( visible )
1285 mDetails->show(); 1285 mDetails->show();
1286 else 1286 else
1287 mDetails->hide(); 1287 mDetails->hide();
1288 } 1288 }
1289 else 1289 else
1290 { 1290 {
1291 if ( visible ) { 1291 if ( visible ) {
1292 mViewManager->hide(); 1292 mViewManager->hide();
1293 mDetails->show(); 1293 mDetails->show();
1294 } 1294 }
1295 else { 1295 else {
1296 mViewManager->show(); 1296 mViewManager->show();
1297 mDetails->hide(); 1297 mDetails->hide();
1298 } 1298 }
1299 setJumpButtonBarVisible( !visible ); 1299 setJumpButtonBarVisible( !visible );
1300 } 1300 }
1301 1301
1302} 1302}
1303 1303
1304void KABCore::extensionChanged( int id ) 1304void KABCore::extensionChanged( int id )
1305{ 1305{
1306 //change the details view only for non desktop systems 1306 //change the details view only for non desktop systems
1307#ifndef DESKTOP_VERSION 1307#ifndef DESKTOP_VERSION
1308 1308
1309 if (id == 0) 1309 if (id == 0)
1310 { 1310 {
1311 //the user disabled the extension. 1311 //the user disabled the extension.
1312 1312
1313 if (mMultipleViewsAtOnce) 1313 if (mMultipleViewsAtOnce)
1314 { // enable detailsview again 1314 { // enable detailsview again
1315 setDetailsVisible( true ); 1315 setDetailsVisible( true );
1316 mActionDetails->setChecked( true ); 1316 mActionDetails->setChecked( true );
1317 } 1317 }
1318 else 1318 else
1319 { //go back to the listview 1319 { //go back to the listview
1320 setDetailsVisible( false ); 1320 setDetailsVisible( false );
1321 mActionDetails->setChecked( false ); 1321 mActionDetails->setChecked( false );
1322 mActionDetails->setEnabled(true); 1322 mActionDetails->setEnabled(true);
1323 } 1323 }
1324 1324
1325 } 1325 }
1326 else 1326 else
1327 { 1327 {
1328 //the user enabled the extension. 1328 //the user enabled the extension.
1329 setDetailsVisible( false ); 1329 setDetailsVisible( false );
1330 mActionDetails->setChecked( false ); 1330 mActionDetails->setChecked( false );
1331 1331
1332 if (!mMultipleViewsAtOnce) 1332 if (!mMultipleViewsAtOnce)
1333 { 1333 {
1334 mActionDetails->setEnabled(false); 1334 mActionDetails->setEnabled(false);
1335 } 1335 }
1336 1336
1337 mExtensionManager->setSelectionChanged(); 1337 mExtensionManager->setSelectionChanged();
1338 1338
1339 } 1339 }
1340 1340
1341#endif// DESKTOP_VERSION 1341#endif// DESKTOP_VERSION
1342 1342
1343} 1343}
1344 1344
1345 1345
1346void KABCore::extensionModified( const KABC::Addressee::List &list ) 1346void KABCore::extensionModified( const KABC::Addressee::List &list )
1347{ 1347{
1348 1348
1349 if ( list.count() != 0 ) { 1349 if ( list.count() != 0 ) {
1350 KABC::Addressee::List::ConstIterator it; 1350 KABC::Addressee::List::ConstIterator it;
1351 for ( it = list.begin(); it != list.end(); ++it ) 1351 for ( it = list.begin(); it != list.end(); ++it )
1352 mAddressBook->insertAddressee( *it ); 1352 mAddressBook->insertAddressee( *it );
1353 if ( list.count() > 1 ) 1353 if ( list.count() > 1 )
1354 setModified(); 1354 setModified();
1355 else 1355 else
1356 setModifiedWOrefresh(); 1356 setModifiedWOrefresh();
1357 } 1357 }
1358 if ( list.count() == 0 ) 1358 if ( list.count() == 0 )
1359 mViewManager->refreshView(); 1359 mViewManager->refreshView();
1360 else 1360 else
1361 mViewManager->refreshView( list[ 0 ].uid() ); 1361 mViewManager->refreshView( list[ 0 ].uid() );
1362 1362
1363 1363
1364 1364
1365} 1365}
1366 1366
1367QString KABCore::getNameByPhone( const QString &phone ) 1367QString KABCore::getNameByPhone( const QString &phone )
1368{ 1368{
1369#ifndef KAB_EMBEDDED 1369#ifndef KAB_EMBEDDED
1370 QRegExp r( "[/*/-/ ]" ); 1370 QRegExp r( "[/*/-/ ]" );
1371 QString localPhone( phone ); 1371 QString localPhone( phone );
1372 1372
1373 bool found = false; 1373 bool found = false;
1374 QString ownerName = ""; 1374 QString ownerName = "";
1375 KABC::AddressBook::Iterator iter; 1375 KABC::AddressBook::Iterator iter;
1376 KABC::PhoneNumber::List::Iterator phoneIter; 1376 KABC::PhoneNumber::List::Iterator phoneIter;
1377 KABC::PhoneNumber::List phoneList; 1377 KABC::PhoneNumber::List phoneList;
1378 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1378 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1379 phoneList = (*iter).phoneNumbers(); 1379 phoneList = (*iter).phoneNumbers();
1380 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1380 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1381 ++phoneIter) { 1381 ++phoneIter) {
1382 // Get rid of separator chars so just the numbers are compared. 1382 // Get rid of separator chars so just the numbers are compared.
1383 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1383 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1384 ownerName = (*iter).formattedName(); 1384 ownerName = (*iter).formattedName();
1385 found = true; 1385 found = true;
1386 } 1386 }
1387 } 1387 }
1388 } 1388 }
1389 1389
1390 return ownerName; 1390 return ownerName;
1391#else //KAB_EMBEDDED 1391#else //KAB_EMBEDDED
1392 qDebug("KABCore::getNameByPhone finsih method"); 1392 qDebug("KABCore::getNameByPhone finsih method");
1393 return ""; 1393 return "";
1394#endif //KAB_EMBEDDED 1394#endif //KAB_EMBEDDED
1395 1395
1396} 1396}
1397 1397
1398void KABCore::openConfigDialog() 1398void KABCore::openConfigDialog()
1399{ 1399{
1400 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1400 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1401 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1401 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1402 ConfigureDialog->addModule(kabcfg ); 1402 ConfigureDialog->addModule(kabcfg );
1403 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1403 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1404 ConfigureDialog->addModule(kdelibcfg ); 1404 ConfigureDialog->addModule(kdelibcfg );
1405 1405
1406 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1406 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1407 this, SLOT( configurationChanged() ) ); 1407 this, SLOT( configurationChanged() ) );
1408 connect( ConfigureDialog, SIGNAL( okClicked() ), 1408 connect( ConfigureDialog, SIGNAL( okClicked() ),
1409 this, SLOT( configurationChanged() ) ); 1409 this, SLOT( configurationChanged() ) );
1410 saveSettings(); 1410 saveSettings();
1411#ifndef DESKTOP_VERSION 1411#ifndef DESKTOP_VERSION
1412 ConfigureDialog->showMaximized(); 1412 ConfigureDialog->showMaximized();
1413#endif 1413#endif
1414 if ( ConfigureDialog->exec() ) 1414 if ( ConfigureDialog->exec() )
1415 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1415 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1416 delete ConfigureDialog; 1416 delete ConfigureDialog;
1417} 1417}
1418 1418
1419void KABCore::openLDAPDialog() 1419void KABCore::openLDAPDialog()
1420{ 1420{
1421#ifndef KAB_EMBEDDED 1421#ifndef KAB_EMBEDDED
1422 if ( !mLdapSearchDialog ) { 1422 if ( !mLdapSearchDialog ) {
1423 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1423 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1424 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1424 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1425 SLOT( refreshView() ) ); 1425 SLOT( refreshView() ) );
1426 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1426 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1427 SLOT( setModified() ) ); 1427 SLOT( setModified() ) );
1428 } else 1428 } else
1429 mLdapSearchDialog->restoreSettings(); 1429 mLdapSearchDialog->restoreSettings();
1430 1430
1431 if ( mLdapSearchDialog->isOK() ) 1431 if ( mLdapSearchDialog->isOK() )
1432 mLdapSearchDialog->exec(); 1432 mLdapSearchDialog->exec();
1433#else //KAB_EMBEDDED 1433#else //KAB_EMBEDDED
1434 qDebug("KABCore::openLDAPDialog() finsih method"); 1434 qDebug("KABCore::openLDAPDialog() finsih method");
1435#endif //KAB_EMBEDDED 1435#endif //KAB_EMBEDDED
1436} 1436}
1437 1437
1438void KABCore::print() 1438void KABCore::print()
1439{ 1439{
1440#ifndef KAB_EMBEDDED 1440#ifndef KAB_EMBEDDED
1441 KPrinter printer; 1441 KPrinter printer;
1442 if ( !printer.setup( this ) ) 1442 if ( !printer.setup( this ) )
1443 return; 1443 return;
1444 1444
1445 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1445 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1446 mViewManager->selectedUids(), this ); 1446 mViewManager->selectedUids(), this );
1447 1447
1448 wizard.exec(); 1448 wizard.exec();
1449#else //KAB_EMBEDDED 1449#else //KAB_EMBEDDED
1450 qDebug("KABCore::print() finsih method"); 1450 qDebug("KABCore::print() finsih method");
1451#endif //KAB_EMBEDDED 1451#endif //KAB_EMBEDDED
1452 1452
1453} 1453}
1454 1454
1455 1455
1456void KABCore::addGUIClient( KXMLGUIClient *client ) 1456void KABCore::addGUIClient( KXMLGUIClient *client )
1457{ 1457{
1458 if ( mGUIClient ) 1458 if ( mGUIClient )
1459 mGUIClient->insertChildClient( client ); 1459 mGUIClient->insertChildClient( client );
1460 else 1460 else
1461 KMessageBox::error( this, "no KXMLGUICLient"); 1461 KMessageBox::error( this, "no KXMLGUICLient");
1462} 1462}
1463 1463
1464 1464
1465void KABCore::configurationChanged() 1465void KABCore::configurationChanged()
1466{ 1466{
1467 mExtensionManager->reconfigure(); 1467 mExtensionManager->reconfigure();
1468} 1468}
1469 1469
1470void KABCore::addressBookChanged() 1470void KABCore::addressBookChanged()
1471{ 1471{
1472/*US 1472/*US
1473 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1473 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1474 while ( it.current() ) { 1474 while ( it.current() ) {
1475 if ( it.current()->dirty() ) { 1475 if ( it.current()->dirty() ) {
1476 QString text = i18n( "Data has been changed externally. Unsaved " 1476 QString text = i18n( "Data has been changed externally. Unsaved "
1477 "changes will be lost." ); 1477 "changes will be lost." );
1478 KMessageBox::information( this, text ); 1478 KMessageBox::information( this, text );
1479 } 1479 }
1480 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1480 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1481 ++it; 1481 ++it;
1482 } 1482 }
1483*/ 1483*/
1484 if (mEditorDialog) 1484 if (mEditorDialog)
1485 { 1485 {
1486 if (mEditorDialog->dirty()) 1486 if (mEditorDialog->dirty())
1487 { 1487 {
1488 QString text = i18n( "Data has been changed externally. Unsaved " 1488 QString text = i18n( "Data has been changed externally. Unsaved "
1489 "changes will be lost." ); 1489 "changes will be lost." );
1490 KMessageBox::information( this, text ); 1490 KMessageBox::information( this, text );
1491 } 1491 }
1492 QString currentuid = mEditorDialog->addressee().uid(); 1492 QString currentuid = mEditorDialog->addressee().uid();
1493 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1493 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1494 } 1494 }
1495 mViewManager->refreshView(); 1495 mViewManager->refreshView();
1496// mDetails->refreshView(); 1496// mDetails->refreshView();
1497 1497
1498 1498
1499} 1499}
1500 1500
1501AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1501AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1502 const char *name ) 1502 const char *name )
1503{ 1503{
1504 1504
1505 if ( mEditorDialog == 0 ) { 1505 if ( mEditorDialog == 0 ) {
1506 mEditorDialog = new AddresseeEditorDialog( this, parent, 1506 mEditorDialog = new AddresseeEditorDialog( this, parent,
1507 name ? name : "editorDialog" ); 1507 name ? name : "editorDialog" );
1508 1508
1509 1509
1510 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1510 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1511 SLOT( contactModified( const KABC::Addressee& ) ) ); 1511 SLOT( contactModified( const KABC::Addressee& ) ) );
1512 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1512 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1513 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1513 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1514 } 1514 }
1515 1515
1516 return mEditorDialog; 1516 return mEditorDialog;
1517} 1517}
1518 1518
1519void KABCore::slotEditorDestroyed( const QString &uid ) 1519void KABCore::slotEditorDestroyed( const QString &uid )
1520{ 1520{
1521 //mEditorDict.remove( uid ); 1521 //mEditorDict.remove( uid );
1522} 1522}
1523 1523
1524void KABCore::initGUI() 1524void KABCore::initGUI()
1525{ 1525{
1526#ifndef KAB_EMBEDDED 1526#ifndef KAB_EMBEDDED
1527 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1527 QHBoxLayout *topLayout = new QHBoxLayout( this );
1528 topLayout->setSpacing( KDialogBase::spacingHint() ); 1528 topLayout->setSpacing( KDialogBase::spacingHint() );
1529 1529
1530 mExtensionBarSplitter = new QSplitter( this ); 1530 mExtensionBarSplitter = new QSplitter( this );
1531 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1531 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1532 1532
1533 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1533 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1534 1534
1535 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1535 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1536 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1536 mIncSearchWidget = new IncSearchWidget( viewSpace );
1537 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1537 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1538 SLOT( incrementalSearch( const QString& ) ) ); 1538 SLOT( incrementalSearch( const QString& ) ) );
1539 1539
1540 mViewManager = new ViewManager( this, viewSpace ); 1540 mViewManager = new ViewManager( this, viewSpace );
1541 viewSpace->setStretchFactor( mViewManager, 1 ); 1541 viewSpace->setStretchFactor( mViewManager, 1 );
1542 1542
1543 mDetails = new ViewContainer( mDetailsSplitter ); 1543 mDetails = new ViewContainer( mDetailsSplitter );
1544 1544
1545 mJumpButtonBar = new JumpButtonBar( this, this ); 1545 mJumpButtonBar = new JumpButtonBar( this, this );
1546 1546
1547 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1547 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1548 1548
1549 topLayout->addWidget( mExtensionBarSplitter ); 1549 topLayout->addWidget( mExtensionBarSplitter );
1550 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1550 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1551 topLayout->addWidget( mJumpButtonBar ); 1551 topLayout->addWidget( mJumpButtonBar );
1552 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1552 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1553 1553
1554 mXXPortManager = new XXPortManager( this, this ); 1554 mXXPortManager = new XXPortManager( this, this );
1555 1555
1556#else //KAB_EMBEDDED 1556#else //KAB_EMBEDDED
1557 //US initialize viewMenu before settingup viewmanager. 1557 //US initialize viewMenu before settingup viewmanager.
1558 // Viewmanager needs this menu to plugin submenues. 1558 // Viewmanager needs this menu to plugin submenues.
1559 viewMenu = new QPopupMenu( this ); 1559 viewMenu = new QPopupMenu( this );
1560 settingsMenu = new QPopupMenu( this ); 1560 settingsMenu = new QPopupMenu( this );
1561 //filterMenu = new QPopupMenu( this ); 1561 //filterMenu = new QPopupMenu( this );
1562 ImportMenu = new QPopupMenu( this ); 1562 ImportMenu = new QPopupMenu( this );
1563 ExportMenu = new QPopupMenu( this ); 1563 ExportMenu = new QPopupMenu( this );
1564 syncMenu = new QPopupMenu( this ); 1564 syncMenu = new QPopupMenu( this );
1565 changeMenu= new QPopupMenu( this ); 1565 changeMenu= new QPopupMenu( this );
1566 1566
1567//US since we have no splitter for the embedded system, setup 1567//US since we have no splitter for the embedded system, setup
1568// a layout with two frames. One left and one right. 1568// a layout with two frames. One left and one right.
1569 1569
1570 QBoxLayout *topLayout; 1570 QBoxLayout *topLayout;
1571 1571
1572 // = new QHBoxLayout( this ); 1572 // = new QHBoxLayout( this );
1573// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1573// QBoxLayout *topLayout = (QBoxLayout*)layout();
1574 1574
1575// QWidget *mainBox = new QWidget( this ); 1575// QWidget *mainBox = new QWidget( this );
1576// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1576// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1577 1577
1578#ifdef DESKTOP_VERSION 1578#ifdef DESKTOP_VERSION
1579 topLayout = new QHBoxLayout( this ); 1579 topLayout = new QHBoxLayout( this );
1580 1580
1581 1581
1582 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1582 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1583 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1583 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1584 1584
1585 topLayout->addWidget(mMiniSplitter ); 1585 topLayout->addWidget(mMiniSplitter );
1586 1586
1587 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1587 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1588 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1588 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1589 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1589 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1590 mDetails = new ViewContainer( mMiniSplitter ); 1590 mDetails = new ViewContainer( mMiniSplitter );
1591 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1591 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1592#else 1592#else
1593 if ( QApplication::desktop()->width() > 480 ) { 1593 if ( QApplication::desktop()->width() > 480 ) {
1594 topLayout = new QHBoxLayout( this ); 1594 topLayout = new QHBoxLayout( this );
1595 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1595 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1596 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1596 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1597 } else { 1597 } else {
1598 1598
1599 topLayout = new QHBoxLayout( this ); 1599 topLayout = new QHBoxLayout( this );
1600 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1600 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1601 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1601 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1602 } 1602 }
1603 1603
1604 topLayout->addWidget(mMiniSplitter ); 1604 topLayout->addWidget(mMiniSplitter );
1605 mViewManager = new ViewManager( this, mMiniSplitter ); 1605 mViewManager = new ViewManager( this, mMiniSplitter );
1606 mDetails = new ViewContainer( mMiniSplitter ); 1606 mDetails = new ViewContainer( mMiniSplitter );
1607 1607
1608 1608
1609 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1609 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1610#endif 1610#endif
1611 //eh->hide(); 1611 //eh->hide();
1612 // topLayout->addWidget(mExtensionManager ); 1612 // topLayout->addWidget(mExtensionManager );
1613 1613
1614 1614
1615/*US 1615/*US
1616#ifndef KAB_NOSPLITTER 1616#ifndef KAB_NOSPLITTER
1617 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1617 QHBoxLayout *topLayout = new QHBoxLayout( this );
1618//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1618//US topLayout->setSpacing( KDialogBase::spacingHint() );
1619 topLayout->setSpacing( 10 ); 1619 topLayout->setSpacing( 10 );
1620 1620
1621 mDetailsSplitter = new QSplitter( this ); 1621 mDetailsSplitter = new QSplitter( this );
1622 1622
1623 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1623 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1624 1624
1625 mViewManager = new ViewManager( this, viewSpace ); 1625 mViewManager = new ViewManager( this, viewSpace );
1626 viewSpace->setStretchFactor( mViewManager, 1 ); 1626 viewSpace->setStretchFactor( mViewManager, 1 );
1627 1627
1628 mDetails = new ViewContainer( mDetailsSplitter ); 1628 mDetails = new ViewContainer( mDetailsSplitter );
1629 1629
1630 topLayout->addWidget( mDetailsSplitter ); 1630 topLayout->addWidget( mDetailsSplitter );
1631 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1631 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1632#else //KAB_NOSPLITTER 1632#else //KAB_NOSPLITTER
1633 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1633 QHBoxLayout *topLayout = new QHBoxLayout( this );
1634//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1634//US topLayout->setSpacing( KDialogBase::spacingHint() );
1635 topLayout->setSpacing( 10 ); 1635 topLayout->setSpacing( 10 );
1636 1636
1637// mDetailsSplitter = new QSplitter( this ); 1637// mDetailsSplitter = new QSplitter( this );
1638 1638
1639 QVBox *viewSpace = new QVBox( this ); 1639 QVBox *viewSpace = new QVBox( this );
1640 1640
1641 mViewManager = new ViewManager( this, viewSpace ); 1641 mViewManager = new ViewManager( this, viewSpace );
1642 viewSpace->setStretchFactor( mViewManager, 1 ); 1642 viewSpace->setStretchFactor( mViewManager, 1 );
1643 1643
1644 mDetails = new ViewContainer( this ); 1644 mDetails = new ViewContainer( this );
1645 1645
1646 topLayout->addWidget( viewSpace ); 1646 topLayout->addWidget( viewSpace );
1647// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1647// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1648 topLayout->addWidget( mDetails ); 1648 topLayout->addWidget( mDetails );
1649#endif //KAB_NOSPLITTER 1649#endif //KAB_NOSPLITTER
1650*/ 1650*/
1651 1651
1652 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1652 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1653 syncManager->setBlockSave(false); 1653 syncManager->setBlockSave(false);
1654 1654
1655 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1655 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1656 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1656 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1657 syncManager->setDefaultFileName( sentSyncFile()); 1657 syncManager->setDefaultFileName( sentSyncFile());
1658 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1658 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1659 1659
1660#endif //KAB_EMBEDDED 1660#endif //KAB_EMBEDDED
1661 initActions(); 1661 initActions();
1662 1662
1663#ifdef KAB_EMBEDDED 1663#ifdef KAB_EMBEDDED
1664 addActionsManually(); 1664 addActionsManually();
1665 //US make sure the export and import menues are initialized before creating the xxPortManager. 1665 //US make sure the export and import menues are initialized before creating the xxPortManager.
1666 mXXPortManager = new XXPortManager( this, this ); 1666 mXXPortManager = new XXPortManager( this, this );
1667 1667
1668 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1668 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1669 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1669 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1670 // mActionQuit->plug ( mMainWindow->toolBar()); 1670 // mActionQuit->plug ( mMainWindow->toolBar());
1671 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1671 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1672 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1672 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1673 // mIncSearchWidget->hide(); 1673 // mIncSearchWidget->hide();
1674 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1674 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1675 SLOT( incrementalSearch( const QString& ) ) ); 1675 SLOT( incrementalSearch( const QString& ) ) );
1676 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1676 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1677 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1677 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1678 1678
1679 mJumpButtonBar = new JumpButtonBar( this, this ); 1679 mJumpButtonBar = new JumpButtonBar( this, this );
1680 1680
1681 topLayout->addWidget( mJumpButtonBar ); 1681 topLayout->addWidget( mJumpButtonBar );
1682//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1682//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1683 1683
1684// mMainWindow->getIconToolBar()->raise(); 1684// mMainWindow->getIconToolBar()->raise();
1685 1685
1686#endif //KAB_EMBEDDED 1686#endif //KAB_EMBEDDED
1687 1687
1688} 1688}
1689void KABCore::initActions() 1689void KABCore::initActions()
1690{ 1690{
1691//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1691//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1692 1692
1693#ifndef KAB_EMBEDDED 1693#ifndef KAB_EMBEDDED
1694 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1694 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1695 SLOT( clipboardDataChanged() ) ); 1695 SLOT( clipboardDataChanged() ) );
1696#endif //KAB_EMBEDDED 1696#endif //KAB_EMBEDDED
1697 1697
1698 // file menu 1698 // file menu
1699 if ( mIsPart ) { 1699 if ( mIsPart ) {
1700 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1700 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1701 SLOT( sendMail() ), actionCollection(), 1701 SLOT( sendMail() ), actionCollection(),
1702 "kaddressbook_mail" ); 1702 "kaddressbook_mail" );
1703 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1703 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1704 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1704 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1705 1705
1706 } else { 1706 } else {
1707 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1707 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1708 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1708 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1709 } 1709 }
1710 1710
1711 1711
1712 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1712 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1713 SLOT( save() ), actionCollection(), "file_sync" ); 1713 SLOT( save() ), actionCollection(), "file_sync" );
1714 1714
1715 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1715 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1716 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1716 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1717 1717
1718 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1718 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1719 this, SLOT( mailVCard() ), 1719 this, SLOT( mailVCard() ),
1720 actionCollection(), "file_mail_vcard"); 1720 actionCollection(), "file_mail_vcard");
1721 1721
1722 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1722 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1723 SLOT( export2phone() ), actionCollection(), 1723 SLOT( export2phone() ), actionCollection(),
1724 "kaddressbook_ex2phone" ); 1724 "kaddressbook_ex2phone" );
1725 1725
1726 mActionBeamVCard = 0; 1726 mActionBeamVCard = 0;
1727 mActionBeam = 0; 1727 mActionBeam = 0;
1728 1728
1729#ifndef DESKTOP_VERSION 1729#ifndef DESKTOP_VERSION
1730 if ( Ir::supported() ) { 1730 if ( Ir::supported() ) {
1731 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1731 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1732 SLOT( beamVCard() ), actionCollection(), 1732 SLOT( beamVCard() ), actionCollection(),
1733 "kaddressbook_beam_vcard" ); 1733 "kaddressbook_beam_vcard" );
1734 1734
1735 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1735 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1736 SLOT( beamMySelf() ), actionCollection(), 1736 SLOT( beamMySelf() ), actionCollection(),
1737 "kaddressbook_beam_myself" ); 1737 "kaddressbook_beam_myself" );
1738 } 1738 }
1739#endif 1739#endif
1740 1740
1741 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1741 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1742 this, SLOT( editContact2() ), 1742 this, SLOT( editContact2() ),
1743 actionCollection(), "file_properties" ); 1743 actionCollection(), "file_properties" );
1744 1744
1745#ifdef KAB_EMBEDDED 1745#ifdef KAB_EMBEDDED
1746 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1746 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1747 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1747 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1748 mMainWindow, SLOT( exit() ), 1748 mMainWindow, SLOT( exit() ),
1749 actionCollection(), "quit" ); 1749 actionCollection(), "quit" );
1750#endif //KAB_EMBEDDED 1750#endif //KAB_EMBEDDED
1751 1751
1752 // edit menu 1752 // edit menu
1753 if ( mIsPart ) { 1753 if ( mIsPart ) {
1754 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1754 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1755 SLOT( copyContacts() ), actionCollection(), 1755 SLOT( copyContacts() ), actionCollection(),
1756 "kaddressbook_copy" ); 1756 "kaddressbook_copy" );
1757 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1757 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1758 SLOT( cutContacts() ), actionCollection(), 1758 SLOT( cutContacts() ), actionCollection(),
1759 "kaddressbook_cut" ); 1759 "kaddressbook_cut" );
1760 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1760 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1761 SLOT( pasteContacts() ), actionCollection(), 1761 SLOT( pasteContacts() ), actionCollection(),
1762 "kaddressbook_paste" ); 1762 "kaddressbook_paste" );
1763 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1763 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1764 SLOT( selectAllContacts() ), actionCollection(), 1764 SLOT( selectAllContacts() ), actionCollection(),
1765 "kaddressbook_select_all" ); 1765 "kaddressbook_select_all" );
1766 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1766 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1767 SLOT( undo() ), actionCollection(), 1767 SLOT( undo() ), actionCollection(),
1768 "kaddressbook_undo" ); 1768 "kaddressbook_undo" );
1769 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1769 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1770 this, SLOT( redo() ), actionCollection(), 1770 this, SLOT( redo() ), actionCollection(),
1771 "kaddressbook_redo" ); 1771 "kaddressbook_redo" );
1772 } else { 1772 } else {
1773 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1773 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1774 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1774 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1775 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1775 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1776 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1776 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1777 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1777 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1778 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1778 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1779 } 1779 }
1780 1780
1781 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1781 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1782 Key_Delete, this, SLOT( deleteContacts() ), 1782 Key_Delete, this, SLOT( deleteContacts() ),
1783 actionCollection(), "edit_delete" ); 1783 actionCollection(), "edit_delete" );
1784 1784
1785 mActionUndo->setEnabled( false ); 1785 mActionUndo->setEnabled( false );
1786 mActionRedo->setEnabled( false ); 1786 mActionRedo->setEnabled( false );
1787 1787
1788 // settings menu 1788 // settings menu
1789#ifdef KAB_EMBEDDED 1789#ifdef KAB_EMBEDDED
1790//US special menuentry to configure the addressbook resources. On KDE 1790//US special menuentry to configure the addressbook resources. On KDE
1791// you do that through the control center !!! 1791// you do that through the control center !!!
1792 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1792 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1793 SLOT( configureResources() ), actionCollection(), 1793 SLOT( configureResources() ), actionCollection(),
1794 "kaddressbook_configure_resources" ); 1794 "kaddressbook_configure_resources" );
1795#endif //KAB_EMBEDDED 1795#endif //KAB_EMBEDDED
1796 1796
1797 if ( mIsPart ) { 1797 if ( mIsPart ) {
1798 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1798 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1799 SLOT( openConfigDialog() ), actionCollection(), 1799 SLOT( openConfigDialog() ), actionCollection(),
1800 "kaddressbook_configure" ); 1800 "kaddressbook_configure" );
1801 1801
1802 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1802 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1803 this, SLOT( configureKeyBindings() ), actionCollection(), 1803 this, SLOT( configureKeyBindings() ), actionCollection(),
1804 "kaddressbook_configure_shortcuts" ); 1804 "kaddressbook_configure_shortcuts" );
1805#ifdef KAB_EMBEDDED 1805#ifdef KAB_EMBEDDED
1806 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1806 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1807 mActionConfigureToolbars->setEnabled( false ); 1807 mActionConfigureToolbars->setEnabled( false );
1808#endif //KAB_EMBEDDED 1808#endif //KAB_EMBEDDED
1809 1809
1810 } else { 1810 } else {
1811 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1811 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1812 1812
1813 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1813 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1814 } 1814 }
1815 1815
1816 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1816 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1817 actionCollection(), "options_show_jump_bar" ); 1817 actionCollection(), "options_show_jump_bar" );
1818 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1818 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1819 1819
1820 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1820 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1821 actionCollection(), "options_show_details" ); 1821 actionCollection(), "options_show_details" );
1822 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1822 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1823 1823
1824 // misc 1824 // misc
1825 // only enable LDAP lookup if we can handle the protocol 1825 // only enable LDAP lookup if we can handle the protocol
1826#ifndef KAB_EMBEDDED 1826#ifndef KAB_EMBEDDED
1827 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1827 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1828 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1828 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1829 this, SLOT( openLDAPDialog() ), actionCollection(), 1829 this, SLOT( openLDAPDialog() ), actionCollection(),
1830 "ldap_lookup" ); 1830 "ldap_lookup" );
1831 } 1831 }
1832#else //KAB_EMBEDDED 1832#else //KAB_EMBEDDED
1833 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1833 //qDebug("KABCore::initActions() LDAP has to be implemented");
1834#endif //KAB_EMBEDDED 1834#endif //KAB_EMBEDDED
1835 1835
1836 1836
1837 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1837 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1838 SLOT( setWhoAmI() ), actionCollection(), 1838 SLOT( setWhoAmI() ), actionCollection(),
1839 "set_personal" ); 1839 "set_personal" );
1840 1840
1841 1841
1842 1842
1843 1843
1844 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1844 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1845 SLOT( setCategories() ), actionCollection(), 1845 SLOT( setCategories() ), actionCollection(),
1846 "edit_set_categories" ); 1846 "edit_set_categories" );
1847 1847
1848 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1848 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1849 SLOT( removeVoice() ), actionCollection(), 1849 SLOT( removeVoice() ), actionCollection(),
1850 "remove_voice" ); 1850 "remove_voice" );
1851 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1851 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1852 SLOT( importFromOL() ), actionCollection(), 1852 SLOT( importFromOL() ), actionCollection(),
1853 "import_OL" ); 1853 "import_OL" );
1854#ifdef KAB_EMBEDDED 1854#ifdef KAB_EMBEDDED
1855 mActionLicence = new KAction( i18n( "Licence" ), 0, 1855 mActionLicence = new KAction( i18n( "Licence" ), 0,
1856 this, SLOT( showLicence() ), actionCollection(), 1856 this, SLOT( showLicence() ), actionCollection(),
1857 "licence_about_data" ); 1857 "licence_about_data" );
1858 mActionFaq = new KAction( i18n( "Faq" ), 0, 1858 mActionFaq = new KAction( i18n( "Faq" ), 0,
1859 this, SLOT( faq() ), actionCollection(), 1859 this, SLOT( faq() ), actionCollection(),
1860 "faq_about_data" ); 1860 "faq_about_data" );
1861 mActionWN = new KAction( i18n( "What's New?" ), 0, 1861 mActionWN = new KAction( i18n( "What's New?" ), 0,
1862 this, SLOT( whatsnew() ), actionCollection(), 1862 this, SLOT( whatsnew() ), actionCollection(),
1863 "wn" ); 1863 "wn" );
1864 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1864 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1865 this, SLOT( synchowto() ), actionCollection(), 1865 this, SLOT( synchowto() ), actionCollection(),
1866 "sync" ); 1866 "sync" );
1867 1867
1868 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1868 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1869 this, SLOT( createAboutData() ), actionCollection(), 1869 this, SLOT( createAboutData() ), actionCollection(),
1870 "kaddressbook_about_data" ); 1870 "kaddressbook_about_data" );
1871#endif //KAB_EMBEDDED 1871#endif //KAB_EMBEDDED
1872 1872
1873 clipboardDataChanged(); 1873 clipboardDataChanged();
1874 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1874 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1875 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1875 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1876} 1876}
1877 1877
1878//US we need this function, to plug all actions into the correct menues. 1878//US we need this function, to plug all actions into the correct menues.
1879// KDE uses a XML format to plug the actions, but we work her without this overhead. 1879// KDE uses a XML format to plug the actions, but we work her without this overhead.
1880void KABCore::addActionsManually() 1880void KABCore::addActionsManually()
1881{ 1881{
1882//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1882//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1883 1883
1884#ifdef KAB_EMBEDDED 1884#ifdef KAB_EMBEDDED
1885 QPopupMenu *fileMenu = new QPopupMenu( this ); 1885 QPopupMenu *fileMenu = new QPopupMenu( this );
1886 QPopupMenu *editMenu = new QPopupMenu( this ); 1886 QPopupMenu *editMenu = new QPopupMenu( this );
1887 QPopupMenu *helpMenu = new QPopupMenu( this ); 1887 QPopupMenu *helpMenu = new QPopupMenu( this );
1888 1888
1889 KToolBar* tb = mMainWindow->toolBar(); 1889 KToolBar* tb = mMainWindow->toolBar();
1890 1890
1891#ifdef DESKTOP_VERSION 1891#ifdef DESKTOP_VERSION
1892 QMenuBar* mb = mMainWindow->menuBar(); 1892 QMenuBar* mb = mMainWindow->menuBar();
1893 1893
1894 //US setup menubar. 1894 //US setup menubar.
1895 //Disable the following block if you do not want to have a menubar. 1895 //Disable the following block if you do not want to have a menubar.
1896 mb->insertItem( "&File", fileMenu ); 1896 mb->insertItem( "&File", fileMenu );
1897 mb->insertItem( "&Edit", editMenu ); 1897 mb->insertItem( "&Edit", editMenu );
1898 mb->insertItem( "&View", viewMenu ); 1898 mb->insertItem( "&View", viewMenu );
1899 mb->insertItem( "&Settings", settingsMenu ); 1899 mb->insertItem( "&Settings", settingsMenu );
1900 mb->insertItem( i18n("Synchronize"), syncMenu ); 1900 mb->insertItem( i18n("Synchronize"), syncMenu );
1901 mb->insertItem( "&Change selected", changeMenu ); 1901 mb->insertItem( "&Change selected", changeMenu );
1902 mb->insertItem( "&Help", helpMenu ); 1902 mb->insertItem( "&Help", helpMenu );
1903 mIncSearchWidget = new IncSearchWidget( tb ); 1903 mIncSearchWidget = new IncSearchWidget( tb );
1904 // tb->insertWidget(-1, 0, mIncSearchWidget); 1904 // tb->insertWidget(-1, 0, mIncSearchWidget);
1905 1905
1906#else 1906#else
1907 //US setup toolbar 1907 //US setup toolbar
1908 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1908 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1909 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1909 QPopupMenu *popupBarTB = new QPopupMenu( this );
1910 menuBarTB->insertItem( "ME", popupBarTB); 1910 menuBarTB->insertItem( "ME", popupBarTB);
1911 tb->insertWidget(-1, 0, menuBarTB); 1911 tb->insertWidget(-1, 0, menuBarTB);
1912 mIncSearchWidget = new IncSearchWidget( tb ); 1912 mIncSearchWidget = new IncSearchWidget( tb );
1913 1913
1914 tb->enableMoving(false); 1914 tb->enableMoving(false);
1915 popupBarTB->insertItem( "&File", fileMenu ); 1915 popupBarTB->insertItem( "&File", fileMenu );
1916 popupBarTB->insertItem( "&Edit", editMenu ); 1916 popupBarTB->insertItem( "&Edit", editMenu );
1917 popupBarTB->insertItem( "&View", viewMenu ); 1917 popupBarTB->insertItem( "&View", viewMenu );
1918 popupBarTB->insertItem( "&Settings", settingsMenu ); 1918 popupBarTB->insertItem( "&Settings", settingsMenu );
1919 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1919 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1920 mViewManager->getFilterAction()->plug ( popupBarTB); 1920 mViewManager->getFilterAction()->plug ( popupBarTB);
1921 popupBarTB->insertItem( "&Change selected", changeMenu ); 1921 popupBarTB->insertItem( "&Change selected", changeMenu );
1922 popupBarTB->insertItem( "&Help", helpMenu ); 1922 popupBarTB->insertItem( "&Help", helpMenu );
1923 if (QApplication::desktop()->width() > 320 ) { 1923 if (QApplication::desktop()->width() > 320 ) {
1924 // mViewManager->getFilterAction()->plug ( tb); 1924 // mViewManager->getFilterAction()->plug ( tb);
1925 } 1925 }
1926#endif 1926#endif
1927 // mActionQuit->plug ( mMainWindow->toolBar()); 1927 // mActionQuit->plug ( mMainWindow->toolBar());
1928 1928
1929 1929
1930 1930
1931 //US Now connect the actions with the menue entries. 1931 //US Now connect the actions with the menue entries.
1932 mActionPrint->plug( fileMenu ); 1932 mActionPrint->plug( fileMenu );
1933 mActionMail->plug( fileMenu ); 1933 mActionMail->plug( fileMenu );
1934 fileMenu->insertSeparator(); 1934 fileMenu->insertSeparator();
1935 1935
1936 mActionNewContact->plug( fileMenu ); 1936 mActionNewContact->plug( fileMenu );
1937 mActionNewContact->plug( tb ); 1937 mActionNewContact->plug( tb );
1938 1938
1939 mActionEditAddressee->plug( fileMenu ); 1939 mActionEditAddressee->plug( fileMenu );
1940 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1940 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1941 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1941 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1942 mActionEditAddressee->plug( tb ); 1942 mActionEditAddressee->plug( tb );
1943 1943
1944 fileMenu->insertSeparator(); 1944 fileMenu->insertSeparator();
1945 mActionSave->plug( fileMenu ); 1945 mActionSave->plug( fileMenu );
1946 fileMenu->insertItem( "&Import", ImportMenu ); 1946 fileMenu->insertItem( "&Import", ImportMenu );
1947 fileMenu->insertItem( "&Export", ExportMenu ); 1947 fileMenu->insertItem( "&Export", ExportMenu );
1948 fileMenu->insertSeparator(); 1948 fileMenu->insertSeparator();
1949 mActionMailVCard->plug( fileMenu ); 1949 mActionMailVCard->plug( fileMenu );
1950#ifndef DESKTOP_VERSION 1950#ifndef DESKTOP_VERSION
1951 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1951 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1952 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1952 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1953#endif 1953#endif
1954 fileMenu->insertSeparator(); 1954 fileMenu->insertSeparator();
1955 mActionQuit->plug( fileMenu ); 1955 mActionQuit->plug( fileMenu );
1956#ifdef _WIN32_ 1956#ifdef _WIN32_
1957 mActionImportOL->plug( ImportMenu ); 1957 mActionImportOL->plug( ImportMenu );
1958#endif 1958#endif
1959 // edit menu 1959 // edit menu
1960 mActionUndo->plug( editMenu ); 1960 mActionUndo->plug( editMenu );
1961 mActionRedo->plug( editMenu ); 1961 mActionRedo->plug( editMenu );
1962 editMenu->insertSeparator(); 1962 editMenu->insertSeparator();
1963 mActionCut->plug( editMenu ); 1963 mActionCut->plug( editMenu );
1964 mActionCopy->plug( editMenu ); 1964 mActionCopy->plug( editMenu );
1965 mActionPaste->plug( editMenu ); 1965 mActionPaste->plug( editMenu );
1966 mActionDelete->plug( editMenu ); 1966 mActionDelete->plug( editMenu );
1967 editMenu->insertSeparator(); 1967 editMenu->insertSeparator();
1968 mActionSelectAll->plug( editMenu ); 1968 mActionSelectAll->plug( editMenu );
1969 1969
1970 mActionRemoveVoice->plug( changeMenu ); 1970 mActionRemoveVoice->plug( changeMenu );
1971 // settings menu 1971 // settings menu
1972//US special menuentry to configure the addressbook resources. On KDE 1972//US special menuentry to configure the addressbook resources. On KDE
1973// you do that through the control center !!! 1973// you do that through the control center !!!
1974 mActionConfigResources->plug( settingsMenu ); 1974 mActionConfigResources->plug( settingsMenu );
1975 settingsMenu->insertSeparator(); 1975 settingsMenu->insertSeparator();
1976 1976
1977 mActionConfigKAddressbook->plug( settingsMenu ); 1977 mActionConfigKAddressbook->plug( settingsMenu );
1978 1978
1979 if ( mIsPart ) { 1979 if ( mIsPart ) {
1980 mActionConfigShortcuts->plug( settingsMenu ); 1980 mActionConfigShortcuts->plug( settingsMenu );
1981 mActionConfigureToolbars->plug( settingsMenu ); 1981 mActionConfigureToolbars->plug( settingsMenu );
1982 1982
1983 } else { 1983 } else {
1984 mActionKeyBindings->plug( settingsMenu ); 1984 mActionKeyBindings->plug( settingsMenu );
1985 } 1985 }
1986 1986
1987 settingsMenu->insertSeparator(); 1987 settingsMenu->insertSeparator();
1988 1988
1989 mActionJumpBar->plug( settingsMenu ); 1989 mActionJumpBar->plug( settingsMenu );
1990 mActionDetails->plug( settingsMenu ); 1990 mActionDetails->plug( settingsMenu );
1991 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1991 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1992 mActionDetails->plug( tb ); 1992 mActionDetails->plug( tb );
1993 settingsMenu->insertSeparator(); 1993 settingsMenu->insertSeparator();
1994 1994
1995 mActionWhoAmI->plug( settingsMenu ); 1995 mActionWhoAmI->plug( settingsMenu );
1996 mActionCategories->plug( settingsMenu ); 1996 mActionCategories->plug( settingsMenu );
1997 1997
1998 1998
1999 mActionWN->plug( helpMenu ); 1999 mActionWN->plug( helpMenu );
2000 mActionSyncHowto->plug( helpMenu ); 2000 mActionSyncHowto->plug( helpMenu );
2001 mActionLicence->plug( helpMenu ); 2001 mActionLicence->plug( helpMenu );
2002 mActionFaq->plug( helpMenu ); 2002 mActionFaq->plug( helpMenu );
2003 mActionAboutKAddressbook->plug( helpMenu ); 2003 mActionAboutKAddressbook->plug( helpMenu );
2004 2004
2005 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2005 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2006 2006
2007 mActionSave->plug( tb ); 2007 mActionSave->plug( tb );
2008 mViewManager->getFilterAction()->plug ( tb); 2008 mViewManager->getFilterAction()->plug ( tb);
2009 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2009 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2010 mActionUndo->plug( tb ); 2010 mActionUndo->plug( tb );
2011 mActionDelete->plug( tb ); 2011 mActionDelete->plug( tb );
2012 mActionRedo->plug( tb ); 2012 mActionRedo->plug( tb );
2013 } 2013 }
2014 } 2014 }
2015 //mActionQuit->plug ( tb ); 2015 //mActionQuit->plug ( tb );
2016 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2016 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2017 2017
2018 //US link the searchwidget first to this. 2018 //US link the searchwidget first to this.
2019 // The real linkage to the toolbar happens later. 2019 // The real linkage to the toolbar happens later.
2020//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2020//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2021//US tb->insertItem( mIncSearchWidget ); 2021//US tb->insertItem( mIncSearchWidget );
2022/*US 2022/*US
2023 mIncSearchWidget = new IncSearchWidget( tb ); 2023 mIncSearchWidget = new IncSearchWidget( tb );
2024 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2024 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2025 SLOT( incrementalSearch( const QString& ) ) ); 2025 SLOT( incrementalSearch( const QString& ) ) );
2026 2026
2027 mJumpButtonBar = new JumpButtonBar( this, this ); 2027 mJumpButtonBar = new JumpButtonBar( this, this );
2028 2028
2029//US topLayout->addWidget( mJumpButtonBar ); 2029//US topLayout->addWidget( mJumpButtonBar );
2030 this->layout()->add( mJumpButtonBar ); 2030 this->layout()->add( mJumpButtonBar );
2031*/ 2031*/
2032 2032
2033#endif //KAB_EMBEDDED 2033#endif //KAB_EMBEDDED
2034 2034
2035 mActionExport2phone->plug( ExportMenu ); 2035 mActionExport2phone->plug( ExportMenu );
2036 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2036 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2037 syncManager->fillSyncMenu(); 2037 syncManager->fillSyncMenu();
2038 2038
2039} 2039}
2040void KABCore::showLicence() 2040void KABCore::showLicence()
2041{ 2041{
2042 KApplication::showLicence(); 2042 KApplication::showLicence();
2043} 2043}
2044void KABCore::removeVoice() 2044void KABCore::removeVoice()
2045{ 2045{
2046 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2046 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2047 return; 2047 return;
2048 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2048 KABC::Addressee::List list = mViewManager->selectedAddressees();
2049 KABC::Addressee::List::Iterator it; 2049 KABC::Addressee::List::Iterator it;
2050 for ( it = list.begin(); it != list.end(); ++it ) { 2050 for ( it = list.begin(); it != list.end(); ++it ) {
2051 2051
2052 if ( (*it).removeVoice() ) 2052 if ( (*it).removeVoice() )
2053 contactModified((*it) ); 2053 contactModified((*it) );
2054 } 2054 }
2055} 2055}
2056 2056
2057 2057
2058 2058
2059void KABCore::clipboardDataChanged() 2059void KABCore::clipboardDataChanged()
2060{ 2060{
2061 2061
2062 if ( mReadWrite ) 2062 if ( mReadWrite )
2063 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2063 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2064 2064
2065} 2065}
2066 2066
2067void KABCore::updateActionMenu() 2067void KABCore::updateActionMenu()
2068{ 2068{
2069 UndoStack *undo = UndoStack::instance(); 2069 UndoStack *undo = UndoStack::instance();
2070 RedoStack *redo = RedoStack::instance(); 2070 RedoStack *redo = RedoStack::instance();
2071 2071
2072 if ( undo->isEmpty() ) 2072 if ( undo->isEmpty() )
2073 mActionUndo->setText( i18n( "Undo" ) ); 2073 mActionUndo->setText( i18n( "Undo" ) );
2074 else 2074 else
2075 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2075 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2076 2076
2077 mActionUndo->setEnabled( !undo->isEmpty() ); 2077 mActionUndo->setEnabled( !undo->isEmpty() );
2078 2078
2079 if ( !redo->top() ) 2079 if ( !redo->top() )
2080 mActionRedo->setText( i18n( "Redo" ) ); 2080 mActionRedo->setText( i18n( "Redo" ) );
2081 else 2081 else
2082 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2082 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2083 2083
2084 mActionRedo->setEnabled( !redo->isEmpty() ); 2084 mActionRedo->setEnabled( !redo->isEmpty() );
2085} 2085}
2086 2086
2087void KABCore::configureKeyBindings() 2087void KABCore::configureKeyBindings()
2088{ 2088{
2089#ifndef KAB_EMBEDDED 2089#ifndef KAB_EMBEDDED
2090 KKeyDialog::configure( actionCollection(), true ); 2090 KKeyDialog::configure( actionCollection(), true );
2091#else //KAB_EMBEDDED 2091#else //KAB_EMBEDDED
2092 qDebug("KABCore::configureKeyBindings() not implemented"); 2092 qDebug("KABCore::configureKeyBindings() not implemented");
2093#endif //KAB_EMBEDDED 2093#endif //KAB_EMBEDDED
2094} 2094}
2095 2095
2096#ifdef KAB_EMBEDDED 2096#ifdef KAB_EMBEDDED
2097void KABCore::configureResources() 2097void KABCore::configureResources()
2098{ 2098{
2099 KRES::KCMKResources dlg( this, "" , 0 ); 2099 KRES::KCMKResources dlg( this, "" , 0 );
2100 2100
2101 if ( !dlg.exec() ) 2101 if ( !dlg.exec() )
2102 return; 2102 return;
2103 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2103 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2104} 2104}
2105#endif //KAB_EMBEDDED 2105#endif //KAB_EMBEDDED
2106 2106
2107 2107
2108/* this method will be called through the QCop interface from Ko/Pi to select addresses 2108/* this method will be called through the QCop interface from Ko/Pi to select addresses
2109 * for the attendees list of an event. 2109 * for the attendees list of an event.
2110 */ 2110 */
2111void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2111void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2112{ 2112{
2113 QStringList nameList; 2113 QStringList nameList;
2114 QStringList emailList; 2114 QStringList emailList;
2115 QStringList uidList; 2115 QStringList uidList;
2116 2116
2117 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2117 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2118 uint i=0; 2118 uint i=0;
2119 for (i=0; i < list.count(); i++) 2119 for (i=0; i < list.count(); i++)
2120 { 2120 {
2121 nameList.append(list[i].realName()); 2121 nameList.append(list[i].realName());
2122 emailList.append(list[i].preferredEmail()); 2122 emailList.append(list[i].preferredEmail());
2123 uidList.append(list[i].uid()); 2123 uidList.append(list[i].uid());
2124 } 2124 }
2125 2125
2126 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2126 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2127 2127
2128} 2128}
2129 2129
2130/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2130/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2131 * to put them into the calendar. 2131 * to put them into the calendar.
2132 */ 2132 */
2133void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2133void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2134{ 2134{
2135 // qDebug("KABCore::requestForBirthdayList"); 2135 // qDebug("KABCore::requestForBirthdayList");
2136 QStringList birthdayList; 2136 QStringList birthdayList;
2137 QStringList anniversaryList; 2137 QStringList anniversaryList;
2138 QStringList realNameList; 2138 QStringList realNameList;
2139 QStringList preferredEmailList; 2139 QStringList preferredEmailList;
2140 QStringList assembledNameList; 2140 QStringList assembledNameList;
2141 QStringList uidList; 2141 QStringList uidList;
2142 2142
2143 KABC::AddressBook::Iterator it; 2143 KABC::AddressBook::Iterator it;
2144 2144
2145 int count = 0; 2145 int count = 0;
2146 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2146 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2147 ++count; 2147 ++count;
2148 } 2148 }
2149 QProgressBar bar(count,0 ); 2149 QProgressBar bar(count,0 );
2150 int w = 300; 2150 int w = 300;
2151 if ( QApplication::desktop()->width() < 320 ) 2151 if ( QApplication::desktop()->width() < 320 )
2152 w = 220; 2152 w = 220;
2153 int h = bar.sizeHint().height() ; 2153 int h = bar.sizeHint().height() ;
2154 int dw = QApplication::desktop()->width(); 2154 int dw = QApplication::desktop()->width();
2155 int dh = QApplication::desktop()->height(); 2155 int dh = QApplication::desktop()->height();
2156 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2156 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2157 bar.show(); 2157 bar.show();
2158 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2158 bar.setCaption (i18n("collecting birthdays - close to abort!") );
2159 qApp->processEvents(); 2159 qApp->processEvents();
2160 2160
2161 QDate bday; 2161 QDate bday;
2162 QString anni; 2162 QString anni;
2163 QString formattedbday; 2163 QString formattedbday;
2164 2164
2165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2166 { 2166 {
2167 if ( ! bar.isVisible() ) 2167 if ( ! bar.isVisible() )
2168 return; 2168 return;
2169 bar.setProgress( count++ ); 2169 bar.setProgress( count++ );
2170 qApp->processEvents(); 2170 qApp->processEvents();
2171 bday = (*it).birthday().date(); 2171 bday = (*it).birthday().date();
2172 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2172 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2173 2173
2174 if ( bday.isValid() || !anni.isEmpty()) 2174 if ( bday.isValid() || !anni.isEmpty())
2175 { 2175 {
2176 if (bday.isValid()) 2176 if (bday.isValid())
2177 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2177 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2178 else 2178 else
2179 formattedbday = "NOTVALID"; 2179 formattedbday = "NOTVALID";
2180 if (anni.isEmpty()) 2180 if (anni.isEmpty())
2181 anni = "INVALID"; 2181 anni = "INVALID";
2182 2182
2183 birthdayList.append(formattedbday); 2183 birthdayList.append(formattedbday);
2184 anniversaryList.append(anni); //should be ISODate 2184 anniversaryList.append(anni); //should be ISODate
2185 realNameList.append((*it).realName()); 2185 realNameList.append((*it).realName());
2186 preferredEmailList.append((*it).preferredEmail()); 2186 preferredEmailList.append((*it).preferredEmail());
2187 assembledNameList.append((*it).assembledName()); 2187 assembledNameList.append((*it).assembledName());
2188 uidList.append((*it).uid()); 2188 uidList.append((*it).uid());
2189 2189
2190 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2190 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2191 } 2191 }
2192 } 2192 }
2193 2193
2194 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2194 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2195 2195
2196} 2196}
2197 2197
2198/* this method will be called through the QCop interface from other apps to show details of a contact. 2198/* this method will be called through the QCop interface from other apps to show details of a contact.
2199 */ 2199 */
2200void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2200void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2201{ 2201{
2202 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2202 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2203 2203
2204 QString foundUid = QString::null; 2204 QString foundUid = QString::null;
2205 if ( ! uid.isEmpty() ) { 2205 if ( ! uid.isEmpty() ) {
2206 Addressee adrr = mAddressBook->findByUid( uid ); 2206 Addressee adrr = mAddressBook->findByUid( uid );
2207 if ( !adrr.isEmpty() ) { 2207 if ( !adrr.isEmpty() ) {
2208 foundUid = uid; 2208 foundUid = uid;
2209 } 2209 }
2210 if ( email == "sendbacklist" ) { 2210 if ( email == "sendbacklist" ) {
2211 //qDebug("ssssssssssssssssssssssend "); 2211 //qDebug("ssssssssssssssssssssssend ");
2212 QStringList nameList; 2212 QStringList nameList;
2213 QStringList emailList; 2213 QStringList emailList;
2214 QStringList uidList; 2214 QStringList uidList;
2215 nameList.append(adrr.realName()); 2215 nameList.append(adrr.realName());
2216 emailList = adrr.emails(); 2216 emailList = adrr.emails();
2217 uidList.append( adrr.preferredEmail()); 2217 uidList.append( adrr.preferredEmail());
2218 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2218 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2219 return; 2219 return;
2220 } 2220 }
2221 2221
2222 } 2222 }
2223 2223
2224 if ( email == "sendbacklist" ) 2224 if ( email == "sendbacklist" )
2225 return; 2225 return;
2226 if (foundUid.isEmpty()) 2226 if (foundUid.isEmpty())
2227 { 2227 {
2228 //find the uid of the person first 2228 //find the uid of the person first
2229 Addressee::List namelist; 2229 Addressee::List namelist;
2230 Addressee::List emaillist; 2230 Addressee::List emaillist;
2231 2231
2232 if (!name.isEmpty()) 2232 if (!name.isEmpty())
2233 namelist = mAddressBook->findByName( name ); 2233 namelist = mAddressBook->findByName( name );
2234 2234
2235 if (!email.isEmpty()) 2235 if (!email.isEmpty())
2236 emaillist = mAddressBook->findByEmail( email ); 2236 emaillist = mAddressBook->findByEmail( email );
2237 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2237 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2238 //check if we have a match in Namelist and Emaillist 2238 //check if we have a match in Namelist and Emaillist
2239 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2239 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2240 foundUid = emaillist[0].uid(); 2240 foundUid = emaillist[0].uid();
2241 } 2241 }
2242 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2242 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2243 foundUid = namelist[0].uid(); 2243 foundUid = namelist[0].uid();
2244 else 2244 else
2245 { 2245 {
2246 for (int i = 0; i < namelist.count(); i++) 2246 for (int i = 0; i < namelist.count(); i++)
2247 { 2247 {
2248 for (int j = 0; j < emaillist.count(); j++) 2248 for (int j = 0; j < emaillist.count(); j++)
2249 { 2249 {
2250 if (namelist[i] == emaillist[j]) 2250 if (namelist[i] == emaillist[j])
2251 { 2251 {
2252 foundUid = namelist[i].uid(); 2252 foundUid = namelist[i].uid();
2253 } 2253 }
2254 } 2254 }
2255 } 2255 }
2256 } 2256 }
2257 } 2257 }
2258 else 2258 else
2259 { 2259 {
2260 foundUid = uid; 2260 foundUid = uid;
2261 } 2261 }
2262 2262
2263 if (!foundUid.isEmpty()) 2263 if (!foundUid.isEmpty())
2264 { 2264 {
2265 2265
2266 // raise Ka/Pi if it is in the background 2266 // raise Ka/Pi if it is in the background
2267#ifndef DESKTOP_VERSION 2267#ifndef DESKTOP_VERSION
2268#ifndef KORG_NODCOP 2268#ifndef KORG_NODCOP
2269 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2269 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2270#endif 2270#endif
2271#endif 2271#endif
2272 2272
2273 mMainWindow->showMaximized(); 2273 mMainWindow->showMaximized();
2274 mMainWindow-> raise(); 2274 mMainWindow-> raise();
2275 2275
2276 mViewManager->setSelected( "", false); 2276 mViewManager->setSelected( "", false);
2277 mViewManager->refreshView( "" ); 2277 mViewManager->refreshView( "" );
2278 mViewManager->setSelected( foundUid, true ); 2278 mViewManager->setSelected( foundUid, true );
2279 mViewManager->refreshView( foundUid ); 2279 mViewManager->refreshView( foundUid );
2280 2280
2281 if ( !mMultipleViewsAtOnce ) 2281 if ( !mMultipleViewsAtOnce )
2282 { 2282 {
2283 setDetailsVisible( true ); 2283 setDetailsVisible( true );
2284 mActionDetails->setChecked(true); 2284 mActionDetails->setChecked(true);
2285 } 2285 }
2286 } 2286 }
2287} 2287}
2288 2288
2289void KABCore::whatsnew() 2289void KABCore::whatsnew()
2290{ 2290{
2291 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2291 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2292} 2292}
2293void KABCore::synchowto() 2293void KABCore::synchowto()
2294{ 2294{
2295 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2295 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2296} 2296}
2297 2297
2298void KABCore::faq() 2298void KABCore::faq()
2299{ 2299{
2300 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2300 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2301} 2301}
2302 2302
2303#include <libkcal/syncdefines.h> 2303#include <libkcal/syncdefines.h>
2304 2304
2305KABC::Addressee KABCore::getLastSyncAddressee() 2305KABC::Addressee KABCore::getLastSyncAddressee()
2306{ 2306{
2307 Addressee lse; 2307 Addressee lse;
2308 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2308 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2309 2309
2310 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2310 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2311 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2311 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2312 if (lse.isEmpty()) { 2312 if (lse.isEmpty()) {
2313 qDebug("Creating new last-syncAddressee "); 2313 qDebug("Creating new last-syncAddressee ");
2314 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2314 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2315 QString sum = ""; 2315 QString sum = "";
2316 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2316 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2317 sum = "E: "; 2317 sum = "E: ";
2318 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2318 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2319 lse.setRevision( mLastAddressbookSync ); 2319 lse.setRevision( mLastAddressbookSync );
2320 lse.setCategories( i18n("SyncEvent") ); 2320 lse.setCategories( i18n("SyncEvent") );
2321 mAddressBook->insertAddressee( lse ); 2321 mAddressBook->insertAddressee( lse );
2322 } 2322 }
2323 return lse; 2323 return lse;
2324} 2324}
2325int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2325int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2326{ 2326{
2327 2327
2328 //void setZaurusId(int id); 2328 //void setZaurusId(int id);
2329 // int zaurusId() const; 2329 // int zaurusId() const;
2330 // void setZaurusUid(int id); 2330 // void setZaurusUid(int id);
2331 // int zaurusUid() const; 2331 // int zaurusUid() const;
2332 // void setZaurusStat(int id); 2332 // void setZaurusStat(int id);
2333 // int zaurusStat() const; 2333 // int zaurusStat() const;
2334 // 0 equal 2334 // 0 equal
2335 // 1 take local 2335 // 1 take local
2336 // 2 take remote 2336 // 2 take remote
2337 // 3 cancel 2337 // 3 cancel
2338 QDateTime lastSync = mLastAddressbookSync; 2338 QDateTime lastSync = mLastAddressbookSync;
2339 QDateTime localMod = local->revision(); 2339 QDateTime localMod = local->revision();
2340 QDateTime remoteMod = remote->revision(); 2340 QDateTime remoteMod = remote->revision();
2341 2341
2342 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2342 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2343 2343
2344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2345 bool remCh, locCh; 2345 bool remCh, locCh;
2346 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2346 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2347 2347
2348 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2348 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2349 locCh = ( localMod > mLastAddressbookSync ); 2349 locCh = ( localMod > mLastAddressbookSync );
2350 if ( !remCh && ! locCh ) { 2350 if ( !remCh && ! locCh ) {
2351 //qDebug("both not changed "); 2351 //qDebug("both not changed ");
2352 lastSync = localMod.addDays(1); 2352 lastSync = localMod.addDays(1);
2353 if ( mode <= SYNC_PREF_ASK ) 2353 if ( mode <= SYNC_PREF_ASK )
2354 return 0; 2354 return 0;
2355 } else { 2355 } else {
2356 if ( locCh ) { 2356 if ( locCh ) {
2357 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2357 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2358 lastSync = localMod.addDays( -1 ); 2358 lastSync = localMod.addDays( -1 );
2359 if ( !remCh ) 2359 if ( !remCh )
2360 remoteMod =( lastSync.addDays( -1 ) ); 2360 remoteMod =( lastSync.addDays( -1 ) );
2361 } else { 2361 } else {
2362 //qDebug(" not loc changed "); 2362 //qDebug(" not loc changed ");
2363 lastSync = localMod.addDays( 1 ); 2363 lastSync = localMod.addDays( 1 );
2364 if ( remCh ) 2364 if ( remCh )
2365 remoteMod =( lastSync.addDays( 1 ) ); 2365 remoteMod =( lastSync.addDays( 1 ) );
2366 2366
2367 } 2367 }
2368 } 2368 }
2369 full = true; 2369 full = true;
2370 if ( mode < SYNC_PREF_ASK ) 2370 if ( mode < SYNC_PREF_ASK )
2371 mode = SYNC_PREF_ASK; 2371 mode = SYNC_PREF_ASK;
2372 } else { 2372 } else {
2373 if ( localMod == remoteMod ) 2373 if ( localMod == remoteMod )
2374 return 0; 2374 return 0;
2375 2375
2376 } 2376 }
2377 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2377 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2378 2378
2379 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2379 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2380 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2380 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2381 //full = true; //debug only 2381 //full = true; //debug only
2382 if ( full ) { 2382 if ( full ) {
2383 bool equ = ( (*local) == (*remote) ); 2383 bool equ = ( (*local) == (*remote) );
2384 if ( equ ) { 2384 if ( equ ) {
2385 //qDebug("equal "); 2385 //qDebug("equal ");
2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2387 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2387 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2388 } 2388 }
2389 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2389 if ( mode < SYNC_PREF_FORCE_LOCAL )
2390 return 0; 2390 return 0;
2391 2391
2392 }//else //debug only 2392 }//else //debug only
2393 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2393 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2394 } 2394 }
2395 int result; 2395 int result;
2396 bool localIsNew; 2396 bool localIsNew;
2397 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2397 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2398 2398
2399 if ( full && mode < SYNC_PREF_NEWEST ) 2399 if ( full && mode < SYNC_PREF_NEWEST )
2400 mode = SYNC_PREF_ASK; 2400 mode = SYNC_PREF_ASK;
2401 2401
2402 switch( mode ) { 2402 switch( mode ) {
2403 case SYNC_PREF_LOCAL: 2403 case SYNC_PREF_LOCAL:
2404 if ( lastSync > remoteMod ) 2404 if ( lastSync > remoteMod )
2405 return 1; 2405 return 1;
2406 if ( lastSync > localMod ) 2406 if ( lastSync > localMod )
2407 return 2; 2407 return 2;
2408 return 1; 2408 return 1;
2409 break; 2409 break;
2410 case SYNC_PREF_REMOTE: 2410 case SYNC_PREF_REMOTE:
2411 if ( lastSync > remoteMod ) 2411 if ( lastSync > remoteMod )
2412 return 1; 2412 return 1;
2413 if ( lastSync > localMod ) 2413 if ( lastSync > localMod )
2414 return 2; 2414 return 2;
2415 return 2; 2415 return 2;
2416 break; 2416 break;
2417 case SYNC_PREF_NEWEST: 2417 case SYNC_PREF_NEWEST:
2418 if ( localMod > remoteMod ) 2418 if ( localMod > remoteMod )
2419 return 1; 2419 return 1;
2420 else 2420 else
2421 return 2; 2421 return 2;
2422 break; 2422 break;
2423 case SYNC_PREF_ASK: 2423 case SYNC_PREF_ASK:
2424 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2424 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2425 if ( lastSync > remoteMod ) 2425 if ( lastSync > remoteMod )
2426 return 1; 2426 return 1;
2427 if ( lastSync > localMod ) 2427 if ( lastSync > localMod )
2428 return 2; 2428 return 2;
2429 localIsNew = localMod >= remoteMod; 2429 localIsNew = localMod >= remoteMod;
2430 //qDebug("conflict! ************************************** "); 2430 //qDebug("conflict! ************************************** ");
2431 { 2431 {
2432 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2432 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2433 result = acd.executeD(localIsNew); 2433 result = acd.executeD(localIsNew);
2434 return result; 2434 return result;
2435 } 2435 }
2436 break; 2436 break;
2437 case SYNC_PREF_FORCE_LOCAL: 2437 case SYNC_PREF_FORCE_LOCAL:
2438 return 1; 2438 return 1;
2439 break; 2439 break;
2440 case SYNC_PREF_FORCE_REMOTE: 2440 case SYNC_PREF_FORCE_REMOTE:
2441 return 2; 2441 return 2;
2442 break; 2442 break;
2443 2443
2444 default: 2444 default:
2445 // SYNC_PREF_TAKE_BOTH not implemented 2445 // SYNC_PREF_TAKE_BOTH not implemented
2446 break; 2446 break;
2447 } 2447 }
2448 return 0; 2448 return 0;
2449} 2449}
2450 2450
2451 2451
2452bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2452bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2453{ 2453{
2454 bool syncOK = true; 2454 bool syncOK = true;
2455 int addedAddressee = 0; 2455 int addedAddressee = 0;
2456 int addedAddresseeR = 0; 2456 int addedAddresseeR = 0;
2457 int deletedAddresseeR = 0; 2457 int deletedAddresseeR = 0;
2458 int deletedAddresseeL = 0; 2458 int deletedAddresseeL = 0;
2459 int changedLocal = 0; 2459 int changedLocal = 0;
2460 int changedRemote = 0; 2460 int changedRemote = 0;
2461 2461
2462 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2462 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2463 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2463 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2464 2464
2465 //QPtrList<Addressee> el = local->rawAddressees(); 2465 //QPtrList<Addressee> el = local->rawAddressees();
2466 Addressee addresseeR; 2466 Addressee addresseeR;
2467 QString uid; 2467 QString uid;
2468 int take; 2468 int take;
2469 Addressee addresseeL; 2469 Addressee addresseeL;
2470 Addressee addresseeRSync; 2470 Addressee addresseeRSync;
2471 Addressee addresseeLSync; 2471 Addressee addresseeLSync;
2472 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2472 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2473 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2473 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2474 bool fullDateRange = false; 2474 bool fullDateRange = false;
2475 local->resetTempSyncStat(); 2475 local->resetTempSyncStat();
2476 mLastAddressbookSync = QDateTime::currentDateTime(); 2476 mLastAddressbookSync = QDateTime::currentDateTime();
2477 QDateTime modifiedCalendar = mLastAddressbookSync;; 2477 QDateTime modifiedCalendar = mLastAddressbookSync;;
2478 addresseeLSync = getLastSyncAddressee(); 2478 addresseeLSync = getLastSyncAddressee();
2479 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2479 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2480 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2480 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2481 if ( !addresseeR.isEmpty() ) { 2481 if ( !addresseeR.isEmpty() ) {
2482 addresseeRSync = addresseeR; 2482 addresseeRSync = addresseeR;
2483 remote->removeAddressee(addresseeR ); 2483 remote->removeAddressee(addresseeR );
2484 2484
2485 } else { 2485 } else {
2486 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2486 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2487 addresseeRSync = addresseeLSync ; 2487 addresseeRSync = addresseeLSync ;
2488 } else { 2488 } else {
2489 qDebug("FULLDATE 1"); 2489 qDebug("FULLDATE 1");
2490 fullDateRange = true; 2490 fullDateRange = true;
2491 Addressee newAdd; 2491 Addressee newAdd;
2492 addresseeRSync = newAdd; 2492 addresseeRSync = newAdd;
2493 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2493 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2494 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2494 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2495 addresseeRSync.setRevision( mLastAddressbookSync ); 2495 addresseeRSync.setRevision( mLastAddressbookSync );
2496 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2496 addresseeRSync.setCategories( i18n("SyncAddressee") );
2497 } 2497 }
2498 } 2498 }
2499 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2499 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2500 qDebug("FULLDATE 2"); 2500 qDebug("FULLDATE 2");
2501 fullDateRange = true; 2501 fullDateRange = true;
2502 } 2502 }
2503 if ( ! fullDateRange ) { 2503 if ( ! fullDateRange ) {
2504 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2504 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2505 2505
2506 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2506 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2507 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2507 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2508 fullDateRange = true; 2508 fullDateRange = true;
2509 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2509 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2510 } 2510 }
2511 } 2511 }
2512 // fullDateRange = true; // debug only! 2512 // fullDateRange = true; // debug only!
2513 if ( fullDateRange ) 2513 if ( fullDateRange )
2514 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2514 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2515 else 2515 else
2516 mLastAddressbookSync = addresseeLSync.revision(); 2516 mLastAddressbookSync = addresseeLSync.revision();
2517 // for resyncing if own file has changed 2517 // for resyncing if own file has changed
2518 // PENDING fixme later when implemented 2518 // PENDING fixme later when implemented
2519#if 0 2519#if 0
2520 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2520 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2521 mLastAddressbookSync = loadedFileVersion; 2521 mLastAddressbookSync = loadedFileVersion;
2522 qDebug("setting mLastAddressbookSync "); 2522 qDebug("setting mLastAddressbookSync ");
2523 } 2523 }
2524#endif 2524#endif
2525 2525
2526 //qDebug("*************************** "); 2526 //qDebug("*************************** ");
2527 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2527 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2528 QStringList er = remote->uidList(); 2528 QStringList er = remote->uidList();
2529 Addressee inR ;//= er.first(); 2529 Addressee inR ;//= er.first();
2530 Addressee inL; 2530 Addressee inL;
2531 2531
2532 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2532 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2533 2533
2534 int modulo = (er.count()/10)+1; 2534 int modulo = (er.count()/10)+1;
2535 int incCounter = 0; 2535 int incCounter = 0;
2536 while ( incCounter < er.count()) { 2536 while ( incCounter < er.count()) {
2537 if (syncManager->isProgressBarCanceled()) 2537 if (syncManager->isProgressBarCanceled())
2538 return false; 2538 return false;
2539 if ( incCounter % modulo == 0 ) 2539 if ( incCounter % modulo == 0 )
2540 syncManager->showProgressBar(incCounter); 2540 syncManager->showProgressBar(incCounter);
2541 2541
2542 uid = er[ incCounter ]; 2542 uid = er[ incCounter ];
2543 bool skipIncidence = false; 2543 bool skipIncidence = false;
2544 if ( uid.left(19) == QString("last-syncAddressee-") ) 2544 if ( uid.left(19) == QString("last-syncAddressee-") )
2545 skipIncidence = true; 2545 skipIncidence = true;
2546 QString idS,OidS; 2546 QString idS,OidS;
2547 qApp->processEvents(); 2547 qApp->processEvents();
2548 if ( !skipIncidence ) { 2548 if ( !skipIncidence ) {
2549 inL = local->findByUid( uid ); 2549 inL = local->findByUid( uid );
2550 inR = remote->findByUid( uid ); 2550 inR = remote->findByUid( uid );
2551 //inL.setResource( 0 ); 2551 //inL.setResource( 0 );
2552 //inR.setResource( 0 ); 2552 //inR.setResource( 0 );
2553 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2553 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2554 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2554 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2555 //qDebug("take %d %s ", take, inL.summary().latin1()); 2555 //qDebug("take %d %s ", take, inL.summary().latin1());
2556 if ( take == 3 ) 2556 if ( take == 3 )
2557 return false; 2557 return false;
2558 if ( take == 1 ) {// take local 2558 if ( take == 1 ) {// take local
2559 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2559 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2560 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2560 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2561 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2561 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2562 local->insertAddressee( inL, false ); 2562 local->insertAddressee( inL, false );
2563 idS = inR.externalUID(); 2563 idS = inR.externalUID();
2564 OidS = inR.originalExternalUID(); 2564 OidS = inR.originalExternalUID();
2565 } 2565 }
2566 else 2566 else
2567 idS = inR.IDStr(); 2567 idS = inR.IDStr();
2568 remote->removeAddressee( inR ); 2568 remote->removeAddressee( inR );
2569 inR = inL; 2569 inR = inL;
2570 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2570 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2571 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2571 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2572 inR.setOriginalExternalUID( OidS ); 2572 inR.setOriginalExternalUID( OidS );
2573 inR.setExternalUID( idS ); 2573 inR.setExternalUID( idS );
2574 } else { 2574 } else {
2575 inR.setIDStr( idS ); 2575 inR.setIDStr( idS );
2576 } 2576 }
2577 inR.setResource( 0 ); 2577 inR.setResource( 0 );
2578 remote->insertAddressee( inR , false); 2578 remote->insertAddressee( inR , false);
2579 ++changedRemote; 2579 ++changedRemote;
2580 } else { // take == 2 take remote 2580 } else { // take == 2 take remote
2581 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2581 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2582 if ( inR.revision().date().year() < 2004 ) 2582 if ( inR.revision().date().year() < 2004 )
2583 inR.setRevision( modifiedCalendar ); 2583 inR.setRevision( modifiedCalendar );
2584 } 2584 }
2585 idS = inL.IDStr(); 2585 idS = inL.IDStr();
2586 local->removeAddressee( inL ); 2586 local->removeAddressee( inL );
2587 inL = inR; 2587 inL = inR;
2588 inL.setIDStr( idS ); 2588 inL.setIDStr( idS );
2589 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2589 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2590 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2590 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2591 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2591 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2592 } 2592 }
2593 inL.setResource( 0 ); 2593 inL.setResource( 0 );
2594 local->insertAddressee( inL , false ); 2594 local->insertAddressee( inL , false );
2595 ++changedLocal; 2595 ++changedLocal;
2596 } 2596 }
2597 } 2597 }
2598 } else { // no conflict 2598 } else { // no conflict
2599 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2599 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2600 QString des = addresseeLSync.note(); 2600 QString des = addresseeLSync.note();
2601 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2601 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2602 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2602 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2603 remote->insertAddressee( inR, false ); 2603 remote->insertAddressee( inR, false );
2604 ++deletedAddresseeR; 2604 ++deletedAddresseeR;
2605 } else { 2605 } else {
2606 inR.setRevision( modifiedCalendar ); 2606 inR.setRevision( modifiedCalendar );
2607 remote->insertAddressee( inR, false ); 2607 remote->insertAddressee( inR, false );
2608 inL = inR; 2608 inL = inR;
2609 inL.setResource( 0 ); 2609 inL.setResource( 0 );
2610 local->insertAddressee( inL , false); 2610 local->insertAddressee( inL , false);
2611 ++addedAddressee; 2611 ++addedAddressee;
2612 } 2612 }
2613 } else { 2613 } else {
2614 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2614 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2615 inR.setRevision( modifiedCalendar ); 2615 inR.setRevision( modifiedCalendar );
2616 remote->insertAddressee( inR, false ); 2616 remote->insertAddressee( inR, false );
2617 inR.setResource( 0 ); 2617 inR.setResource( 0 );
2618 local->insertAddressee( inR, false ); 2618 local->insertAddressee( inR, false );
2619 ++addedAddressee; 2619 ++addedAddressee;
2620 } else { 2620 } else {
2621 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2621 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2622 remote->removeAddressee( inR ); 2622 remote->removeAddressee( inR );
2623 ++deletedAddresseeR; 2623 ++deletedAddresseeR;
2624 } 2624 }
2625 } 2625 }
2626 } 2626 }
2627 } 2627 }
2628 ++incCounter; 2628 ++incCounter;
2629 } 2629 }
2630 er.clear(); 2630 er.clear();
2631 QStringList el = local->uidList(); 2631 QStringList el = local->uidList();
2632 modulo = (el.count()/10)+1; 2632 modulo = (el.count()/10)+1;
2633 2633
2634 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2634 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2635 incCounter = 0; 2635 incCounter = 0;
2636 while ( incCounter < el.count()) { 2636 while ( incCounter < el.count()) {
2637 qApp->processEvents(); 2637 qApp->processEvents();
2638 if (syncManager->isProgressBarCanceled()) 2638 if (syncManager->isProgressBarCanceled())
2639 return false; 2639 return false;
2640 if ( incCounter % modulo == 0 ) 2640 if ( incCounter % modulo == 0 )
2641 syncManager->showProgressBar(incCounter); 2641 syncManager->showProgressBar(incCounter);
2642 uid = el[ incCounter ]; 2642 uid = el[ incCounter ];
2643 bool skipIncidence = false; 2643 bool skipIncidence = false;
2644 if ( uid.left(19) == QString("last-syncAddressee-") ) 2644 if ( uid.left(19) == QString("last-syncAddressee-") )
2645 skipIncidence = true; 2645 skipIncidence = true;
2646 if ( !skipIncidence ) { 2646 if ( !skipIncidence ) {
2647 inL = local->findByUid( uid ); 2647 inL = local->findByUid( uid );
2648 inR = remote->findByUid( uid ); 2648 inR = remote->findByUid( uid );
2649 if ( inR.isEmpty() ) { 2649 if ( inR.isEmpty() ) {
2650 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2650 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2651 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2651 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2652 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2652 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2653 local->removeAddressee( inL ); 2653 local->removeAddressee( inL );
2654 ++deletedAddresseeL; 2654 ++deletedAddresseeL;
2655 } else { 2655 } else {
2656 if ( ! syncManager->mWriteBackExistingOnly ) { 2656 if ( ! syncManager->mWriteBackExistingOnly ) {
2657 inL.removeID(mCurrentSyncDevice ); 2657 inL.removeID(mCurrentSyncDevice );
2658 ++addedAddresseeR; 2658 ++addedAddresseeR;
2659 inL.setRevision( modifiedCalendar ); 2659 inL.setRevision( modifiedCalendar );
2660 local->insertAddressee( inL, false ); 2660 local->insertAddressee( inL, false );
2661 inR = inL; 2661 inR = inL;
2662 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2662 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2663 inR.setResource( 0 ); 2663 inR.setResource( 0 );
2664 remote->insertAddressee( inR, false ); 2664 remote->insertAddressee( inR, false );
2665 } 2665 }
2666 } 2666 }
2667 } else { 2667 } else {
2668 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2668 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2669 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2669 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2670 local->removeAddressee( inL ); 2670 local->removeAddressee( inL );
2671 ++deletedAddresseeL; 2671 ++deletedAddresseeL;
2672 } else { 2672 } else {
2673 if ( ! syncManager->mWriteBackExistingOnly ) { 2673 if ( ! syncManager->mWriteBackExistingOnly ) {
2674 ++addedAddresseeR; 2674 ++addedAddresseeR;
2675 inL.setRevision( modifiedCalendar ); 2675 inL.setRevision( modifiedCalendar );
2676 local->insertAddressee( inL, false ); 2676 local->insertAddressee( inL, false );
2677 inR = inL; 2677 inR = inL;
2678 inR.setResource( 0 ); 2678 inR.setResource( 0 );
2679 remote->insertAddressee( inR, false ); 2679 remote->insertAddressee( inR, false );
2680 } 2680 }
2681 } 2681 }
2682 } 2682 }
2683 } 2683 }
2684 } 2684 }
2685 ++incCounter; 2685 ++incCounter;
2686 } 2686 }
2687 el.clear(); 2687 el.clear();
2688 syncManager->hideProgressBar(); 2688 syncManager->hideProgressBar();
2689 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2689 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2690 // get rid of micro seconds 2690 // get rid of micro seconds
2691 QTime t = mLastAddressbookSync.time(); 2691 QTime t = mLastAddressbookSync.time();
2692 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2692 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2693 addresseeLSync.setRevision( mLastAddressbookSync ); 2693 addresseeLSync.setRevision( mLastAddressbookSync );
2694 addresseeRSync.setRevision( mLastAddressbookSync ); 2694 addresseeRSync.setRevision( mLastAddressbookSync );
2695 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2695 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2696 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2696 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2697 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2697 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2698 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2698 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2699 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2699 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2700 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2700 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2701 addresseeRSync.setNote( "" ) ; 2701 addresseeRSync.setNote( "" ) ;
2702 addresseeLSync.setNote( "" ); 2702 addresseeLSync.setNote( "" );
2703 2703
2704 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2704 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2705 remote->insertAddressee( addresseeRSync, false ); 2705 remote->insertAddressee( addresseeRSync, false );
2706 local->insertAddressee( addresseeLSync, false ); 2706 local->insertAddressee( addresseeLSync, false );
2707 QString mes; 2707 QString mes;
2708 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2708 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2709 if ( syncManager->mShowSyncSummary ) { 2709 if ( syncManager->mShowSyncSummary ) {
2710 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2710 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2711 } 2711 }
2712 qDebug( mes ); 2712 qDebug( mes );
2713 return syncOK; 2713 return syncOK;
2714} 2714}
2715 2715
2716 2716
2717//this is a overwritten callbackmethods from the syncinterface 2717//this is a overwritten callbackmethods from the syncinterface
2718bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2718bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2719{ 2719{
2720 2720
2721 //pending prepare addresseeview for output 2721 //pending prepare addresseeview for output
2722 //pending detect, if remote file has REV field. if not switch to external sync 2722 //pending detect, if remote file has REV field. if not switch to external sync
2723 mGlobalSyncMode = SYNC_MODE_NORMAL; 2723 mGlobalSyncMode = SYNC_MODE_NORMAL;
2724 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2724 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2725 2725
2726 AddressBook abLocal(filename,"syncContact"); 2726 AddressBook abLocal(filename,"syncContact");
2727 bool syncOK = false; 2727 bool syncOK = false;
2728 if ( abLocal.load() ) { 2728 if ( abLocal.load() ) {
2729 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2729 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2730 bool external = false; 2730 bool external = false;
2731 bool isXML = false; 2731 bool isXML = false;
2732 if ( filename.right(4) == ".xml") { 2732 if ( filename.right(4) == ".xml") {
2733 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2733 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2734 isXML = true; 2734 isXML = true;
2735 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2735 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2736 } else { 2736 } else {
2737 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2737 external = !manager->mIsKapiFile;
2738 if ( ! lse.isEmpty() ) {
2739 if ( lse.familyName().left(4) == "!E: " )
2740 external = true;
2741 } else {
2742 bool found = false;
2743 AddressBook::Iterator it;
2744 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2745 if ( (*it).revision().date().year() > 2003 ) {
2746 found = true;
2747 break;
2748 }
2749 }
2750 external = ! found;
2751 }
2752
2753 if ( external ) { 2738 if ( external ) {
2754 qDebug("Setting vcf mode to external "); 2739 qDebug("Setting vcf mode to external ");
2755 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2740 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2756 AddressBook::Iterator it; 2741 AddressBook::Iterator it;
2757 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2742 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2758 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2743 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2759 (*it).computeCsum( mCurrentSyncDevice ); 2744 (*it).computeCsum( mCurrentSyncDevice );
2760 } 2745 }
2761 } 2746 }
2762 } 2747 }
2763 //AddressBook::Iterator it; 2748 //AddressBook::Iterator it;
2764 //QStringList vcards; 2749 //QStringList vcards;
2765 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2750 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2766 // qDebug("Name %s ", (*it).familyName().latin1()); 2751 // qDebug("Name %s ", (*it).familyName().latin1());
2767 //} 2752 //}
2768 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2753 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2769 if ( syncOK ) { 2754 if ( syncOK ) {
2770 if ( syncManager->mWriteBackFile ) 2755 if ( syncManager->mWriteBackFile )
2771 { 2756 {
2772 if ( external ) 2757 if ( external )
2773 abLocal.removeSyncAddressees( !isXML); 2758 abLocal.removeSyncAddressees( !isXML);
2774 qDebug("Saving remote AB "); 2759 qDebug("Saving remote AB ");
2775 if ( ! abLocal.saveAB()) 2760 if ( ! abLocal.saveAB())
2776 qDebug("Error writing back AB to file "); 2761 qDebug("Error writing back AB to file ");
2777 if ( isXML ) { 2762 if ( isXML ) {
2778 // afterwrite processing 2763 // afterwrite processing
2779 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2764 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2780 } 2765 }
2781 } 2766 }
2782 } 2767 }
2783 setModified(); 2768 setModified();
2784 2769
2785 } 2770 }
2786 if ( syncOK ) 2771 if ( syncOK )
2787 mViewManager->refreshView(); 2772 mViewManager->refreshView();
2788 return syncOK; 2773 return syncOK;
2789 2774
2790} 2775}
2791 2776
2792 2777
2793//this is a overwritten callbackmethods from the syncinterface 2778//this is a overwritten callbackmethods from the syncinterface
2794bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2779bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2795{ 2780{
2796 if ( resource == "phone" ) 2781 if ( resource == "phone" )
2797 return syncPhone(); 2782 return syncPhone();
2798 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2783 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2799 2784
2800 AddressBook abLocal( resource,"syncContact"); 2785 AddressBook abLocal( resource,"syncContact");
2801 bool syncOK = false; 2786 bool syncOK = false;
2802 if ( abLocal.load() ) { 2787 if ( abLocal.load() ) {
2803 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2788 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2804 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2789 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2805 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2790 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2806 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2791 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2807 if ( syncOK ) { 2792 if ( syncOK ) {
2808 if ( syncManager->mWriteBackFile ) { 2793 if ( syncManager->mWriteBackFile ) {
2809 abLocal.removeSyncAddressees( false ); 2794 abLocal.removeSyncAddressees( false );
2810 abLocal.saveAB(); 2795 abLocal.saveAB();
2811 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2796 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2812 } 2797 }
2813 } 2798 }
2814 setModified(); 2799 setModified();
2815 } 2800 }
2816 if ( syncOK ) 2801 if ( syncOK )
2817 mViewManager->refreshView(); 2802 mViewManager->refreshView();
2818 return syncOK; 2803 return syncOK;
2819 2804
2820} 2805}
2821void KABCore::message( QString m ) 2806void KABCore::message( QString m )
2822{ 2807{
2823 2808
2824 topLevelWidget()->setCaption( m ); 2809 topLevelWidget()->setCaption( m );
2825 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2810 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2826} 2811}
2827bool KABCore::syncPhone() 2812bool KABCore::syncPhone()
2828{ 2813{
2829 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2814 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2830 QString fileName; 2815 QString fileName;
2831#ifdef _WIN32_ 2816#ifdef _WIN32_
2832 fileName = locateLocal("tmp", "phonefile.vcf"); 2817 fileName = locateLocal("tmp", "phonefile.vcf");
2833#else 2818#else
2834 fileName = "/tmp/phonefile.vcf"; 2819 fileName = "/tmp/phonefile.vcf";
2835#endif 2820#endif
2836 if ( !PhoneAccess::readFromPhone( fileName) ) { 2821 if ( !PhoneAccess::readFromPhone( fileName) ) {
2837 message(i18n("Phone access failed!")); 2822 message(i18n("Phone access failed!"));
2838 return false; 2823 return false;
2839 } 2824 }
2840 AddressBook abLocal( fileName,"syncContact"); 2825 AddressBook abLocal( fileName,"syncContact");
2841 bool syncOK = false; 2826 bool syncOK = false;
2842 { 2827 {
2843 abLocal.importFromFile( fileName ); 2828 abLocal.importFromFile( fileName );
2844 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2829 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2845 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2830 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2846 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2831 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2847 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2832 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2848 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2833 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2849 if ( syncOK ) { 2834 if ( syncOK ) {
2850 if ( syncManager->mWriteBackFile ) { 2835 if ( syncManager->mWriteBackFile ) {
2851 abLocal.removeSyncAddressees( true ); 2836 abLocal.removeSyncAddressees( true );
2852 abLocal.saveABphone( fileName ); 2837 abLocal.saveABphone( fileName );
2853 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2838 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2854 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2839 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2855 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2840 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2856 } 2841 }
2857 } 2842 }
2858 setModified(); 2843 setModified();
2859 } 2844 }
2860 if ( syncOK ) 2845 if ( syncOK )
2861 mViewManager->refreshView(); 2846 mViewManager->refreshView();
2862 return syncOK; 2847 return syncOK;
2863} 2848}
2864void KABCore::getFile( bool success ) 2849void KABCore::getFile( bool success )
2865{ 2850{
2866 if ( ! success ) { 2851 if ( ! success ) {
2867 message( i18n("Error receiving file. Nothing changed!") ); 2852 message( i18n("Error receiving file. Nothing changed!") );
2868 return; 2853 return;
2869 } 2854 }
2870 mAddressBook->importFromFile( sentSyncFile() , false, true ); 2855 mAddressBook->importFromFile( sentSyncFile() , false, true );
2871 message( i18n("Pi-Sync successful!") ); 2856 message( i18n("Pi-Sync successful!") );
2872 mViewManager->refreshView(); 2857 mViewManager->refreshView();
2873} 2858}
2874void KABCore::syncFileRequest() 2859void KABCore::syncFileRequest()
2875{ 2860{
2876 mAddressBook->export2File( sentSyncFile() ); 2861 mAddressBook->export2File( sentSyncFile() );
2877} 2862}
2878QString KABCore::sentSyncFile() 2863QString KABCore::sentSyncFile()
2879{ 2864{
2880#ifdef _WIN32_ 2865#ifdef _WIN32_
2881 return locateLocal( "tmp", "copysyncab.vcf" ); 2866 return locateLocal( "tmp", "copysyncab.vcf" );
2882#else 2867#else
2883 return QString( "/tmp/copysyncab.vcf" ); 2868 return QString( "/tmp/copysyncab.vcf" );
2884#endif 2869#endif
2885} 2870}
2886 2871
2887void KABCore::setCaptionBack() 2872void KABCore::setCaptionBack()
2888{ 2873{
2889 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2874 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2890} 2875}
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 6baa2ee..5175f94 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1210 +1,1211 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51 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 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 prof << i18n("Last_file");
105 KSyncProfile* temp = new KSyncProfile (); 105 KSyncProfile* temp = new KSyncProfile ();
106 temp->setName( prof[0] ); 106 temp->setName( prof[0] );
107 temp->writeConfig(&config); 107 temp->writeConfig(&config);
108 temp->setName( prof[1] ); 108 temp->setName( prof[1] );
109 temp->writeConfig(&config); 109 temp->writeConfig(&config);
110 temp->setName( prof[2] ); 110 temp->setName( prof[2] );
111 temp->writeConfig(&config); 111 temp->writeConfig(&config);
112 config.setGroup("General"); 112 config.setGroup("General");
113 config.writeEntry("SyncProfileNames",prof); 113 config.writeEntry("SyncProfileNames",prof);
114 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 114 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
115 config.sync(); 115 config.sync();
116 delete temp; 116 delete temp;
117 } 117 }
118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
119 mSyncProfileNames = prof; 119 mSyncProfileNames = prof;
120 unsigned int i; 120 unsigned int i;
121 for ( i = 0; i < prof.count(); ++i ) { 121 for ( i = 0; i < prof.count(); ++i ) {
122 mSyncMenu->insertItem( prof[i], 1000+i ); 122 mSyncMenu->insertItem( prof[i], 1000+i );
123 if ( i == 2 ) 123 if ( i == 2 )
124 mSyncMenu->insertSeparator(); 124 mSyncMenu->insertSeparator();
125 } 125 }
126 QDir app_dir; 126 QDir app_dir;
127 //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
128 if ( mTargetApp == PWMPI) { 128 if ( mTargetApp == PWMPI) {
129 mSyncMenu->removeItem( 1000 ); 129 mSyncMenu->removeItem( 1000 );
130 } 130 }
131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
132 mSyncMenu->removeItem( 1000 ); 132 mSyncMenu->removeItem( 1000 );
133 } 133 }
134 mSyncMenu->removeItem( 1002 ); 134 mSyncMenu->removeItem( 1002 );
135} 135}
136 136
137void KSyncManager::slotSyncMenu( int action ) 137void KSyncManager::slotSyncMenu( int action )
138{ 138{
139 //qDebug("syncaction %d ", action); 139 //qDebug("syncaction %d ", action);
140 if ( action == 0 ) { 140 if ( action == 0 ) {
141 141
142 // seems to be a Qt2 event handling bug 142 // seems to be a Qt2 event handling bug
143 // syncmenu.clear causes a segfault at first time 143 // syncmenu.clear causes a segfault at first time
144 // 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
145 // 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
146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
147 //confSync(); 147 //confSync();
148 148
149 return; 149 return;
150 } 150 }
151 if ( action == 1 ) { 151 if ( action == 1 ) {
152 multiSync( true ); 152 multiSync( true );
153 return; 153 return;
154 } 154 }
155 if ( action == 2 ) { 155 if ( action == 2 ) {
156 enableQuick(); 156 enableQuick();
157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
158 return; 158 return;
159 } 159 }
160 if ( action == 3 ) { 160 if ( action == 3 ) {
161 delete mServerSocket; 161 delete mServerSocket;
162 mServerSocket = 0; 162 mServerSocket = 0;
163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
164 return; 164 return;
165 } 165 }
166 166
167 if (blockSave()) 167 if (blockSave())
168 return; 168 return;
169 169
170 setBlockSave(true); 170 setBlockSave(true);
171 171
172 mCurrentSyncProfile = action - 1000 ; 172 mCurrentSyncProfile = action - 1000 ;
173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
174 mCurrentSyncName = mLocalMachineName ; 174 mCurrentSyncName = mLocalMachineName ;
175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
176 KSyncProfile* temp = new KSyncProfile (); 176 KSyncProfile* temp = new KSyncProfile ();
177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
178 temp->readConfig(&config); 178 temp->readConfig(&config);
179 mAskForPreferences = temp->getAskForPreferences(); 179 mAskForPreferences = temp->getAskForPreferences();
180 mSyncAlgoPrefs = temp->getSyncPrefs(); 180 mSyncAlgoPrefs = temp->getSyncPrefs();
181 mWriteBackFile = temp->getWriteBackFile(); 181 mWriteBackFile = temp->getWriteBackFile();
182 mWriteBackExistingOnly = temp->getWriteBackExisting(); 182 mWriteBackExistingOnly = temp->getWriteBackExisting();
183 mIsKapiFile = temp->getIsKapiFile();
183 mWriteBackInFuture = 0; 184 mWriteBackInFuture = 0;
184 if ( temp->getWriteBackFuture() ) 185 if ( temp->getWriteBackFuture() )
185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 186 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
186 mShowSyncSummary = temp->getShowSummaryAfterSync(); 187 mShowSyncSummary = temp->getShowSummaryAfterSync();
187 if ( action == 1000 ) { 188 if ( action == 1000 ) {
188 syncSharp(); 189 syncSharp();
189 190
190 } else if ( action == 1001 ) { 191 } else if ( action == 1001 ) {
191 syncLocalFile(); 192 syncLocalFile();
192 193
193 } else if ( action == 1002 ) { 194 } else if ( action == 1002 ) {
194 mWriteBackFile = false; 195 mWriteBackFile = false;
195 mAskForPreferences = false; 196 mAskForPreferences = false;
196 mShowSyncSummary = false; 197 mShowSyncSummary = false;
197 mSyncAlgoPrefs = 3; 198 mSyncAlgoPrefs = 3;
198 quickSyncLocalFile(); 199 quickSyncLocalFile();
199 200
200 } else if ( action >= 1003 ) { 201 } else if ( action >= 1003 ) {
201 if ( temp->getIsLocalFileSync() ) { 202 if ( temp->getIsLocalFileSync() ) {
202 switch(mTargetApp) 203 switch(mTargetApp)
203 { 204 {
204 case (KAPI): 205 case (KAPI):
205 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 206 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 207 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
207 break; 208 break;
208 case (KOPI): 209 case (KOPI):
209 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 210 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 211 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
211 break; 212 break;
212 case (PWMPI): 213 case (PWMPI):
213 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 214 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
214 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 215 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
215 break; 216 break;
216 default: 217 default:
217 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 218 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
218 break; 219 break;
219 220
220 } 221 }
221 } else { 222 } else {
222 if ( temp->getIsPhoneSync() ) { 223 if ( temp->getIsPhoneSync() ) {
223 mPhoneDevice = temp->getPhoneDevice( ) ; 224 mPhoneDevice = temp->getPhoneDevice( ) ;
224 mPhoneConnection = temp->getPhoneConnection( ); 225 mPhoneConnection = temp->getPhoneConnection( );
225 mPhoneModel = temp->getPhoneModel( ); 226 mPhoneModel = temp->getPhoneModel( );
226 syncPhone(); 227 syncPhone();
227 } else if ( temp->getIsPiSync() ) { 228 } else if ( temp->getIsPiSync() ) {
228 if ( mTargetApp == KAPI ) { 229 if ( mTargetApp == KAPI ) {
229 mPassWordPiSync = temp->getRemotePwAB(); 230 mPassWordPiSync = temp->getRemotePwAB();
230 mActiveSyncPort = temp->getRemotePortAB(); 231 mActiveSyncPort = temp->getRemotePortAB();
231 mActiveSyncIP = temp->getRemoteIPAB(); 232 mActiveSyncIP = temp->getRemoteIPAB();
232 } else if ( mTargetApp == KOPI ) { 233 } else if ( mTargetApp == KOPI ) {
233 mPassWordPiSync = temp->getRemotePw(); 234 mPassWordPiSync = temp->getRemotePw();
234 mActiveSyncPort = temp->getRemotePort(); 235 mActiveSyncPort = temp->getRemotePort();
235 mActiveSyncIP = temp->getRemoteIP(); 236 mActiveSyncIP = temp->getRemoteIP();
236 } else { 237 } else {
237 mPassWordPiSync = temp->getRemotePwPWM(); 238 mPassWordPiSync = temp->getRemotePwPWM();
238 mActiveSyncPort = temp->getRemotePortPWM(); 239 mActiveSyncPort = temp->getRemotePortPWM();
239 mActiveSyncIP = temp->getRemoteIPPWM(); 240 mActiveSyncIP = temp->getRemoteIPPWM();
240 } 241 }
241 syncPi(); 242 syncPi();
242 } else 243 } else
243 syncRemote( temp ); 244 syncRemote( temp );
244 245
245 } 246 }
246 } 247 }
247 delete temp; 248 delete temp;
248 setBlockSave(false); 249 setBlockSave(false);
249} 250}
250 251
251void KSyncManager::enableQuick() 252void KSyncManager::enableQuick()
252{ 253{
253 QDialog dia ( 0, "input-dialog", true ); 254 QDialog dia ( 0, "input-dialog", true );
254 QLineEdit lab ( &dia ); 255 QLineEdit lab ( &dia );
255 QVBoxLayout lay( &dia ); 256 QVBoxLayout lay( &dia );
256 lab.setText( mPrefs->mPassiveSyncPort ); 257 lab.setText( mPrefs->mPassiveSyncPort );
257 lay.setMargin(7); 258 lay.setMargin(7);
258 lay.setSpacing(7); 259 lay.setSpacing(7);
259 int po = 9197+mTargetApp; 260 int po = 9197+mTargetApp;
260 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 261 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
261 lay.addWidget( &label); 262 lay.addWidget( &label);
262 lay.addWidget( &lab); 263 lay.addWidget( &lab);
263 264
264 QLineEdit lepw ( &dia ); 265 QLineEdit lepw ( &dia );
265 lepw.setText( mPrefs->mPassiveSyncPw ); 266 lepw.setText( mPrefs->mPassiveSyncPw );
266 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 267 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
267 lay.addWidget( &label2); 268 lay.addWidget( &label2);
268 lay.addWidget( &lepw); 269 lay.addWidget( &lepw);
269 dia.setFixedSize( 230,80 ); 270 dia.setFixedSize( 230,80 );
270 dia.setCaption( i18n("Enter port for Pi-Sync") ); 271 dia.setCaption( i18n("Enter port for Pi-Sync") );
271 QPushButton pb ( "OK", &dia); 272 QPushButton pb ( "OK", &dia);
272 lay.addWidget( &pb ); 273 lay.addWidget( &pb );
273 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 274 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
274 dia.show(); 275 dia.show();
275 if ( ! dia.exec() ) 276 if ( ! dia.exec() )
276 return; 277 return;
277 dia.hide(); 278 dia.hide();
278 qApp->processEvents(); 279 qApp->processEvents();
279 mPrefs->mPassiveSyncPw = lepw.text(); 280 mPrefs->mPassiveSyncPw = lepw.text();
280 mPrefs->mPassiveSyncPort = lab.text(); 281 mPrefs->mPassiveSyncPort = lab.text();
281 bool ok; 282 bool ok;
282 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 283 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
283 if ( ! ok ) { 284 if ( ! ok ) {
284 KMessageBox::information( 0, i18n("No valid port")); 285 KMessageBox::information( 0, i18n("No valid port"));
285 return; 286 return;
286 } 287 }
287 //qDebug("port %d ", port); 288 //qDebug("port %d ", port);
288 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 289 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
289 mServerSocket->setFileName( defaultFileName() ); 290 mServerSocket->setFileName( defaultFileName() );
290 //qDebug("connected "); 291 //qDebug("connected ");
291 if ( !mServerSocket->ok() ) { 292 if ( !mServerSocket->ok() ) {
292 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 293 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
293 delete mServerSocket; 294 delete mServerSocket;
294 mServerSocket = 0; 295 mServerSocket = 0;
295 return; 296 return;
296 } 297 }
297 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 298 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
298 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 299 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
299} 300}
300 301
301void KSyncManager::syncLocalFile() 302void KSyncManager::syncLocalFile()
302{ 303{
303 304
304 QString fn =mPrefs->mLastSyncedLocalFile; 305 QString fn =mPrefs->mLastSyncedLocalFile;
305 QString ext; 306 QString ext;
306 307
307 switch(mTargetApp) 308 switch(mTargetApp)
308 { 309 {
309 case (KAPI): 310 case (KAPI):
310 ext = "(*.vcf)"; 311 ext = "(*.vcf)";
311 break; 312 break;
312 case (KOPI): 313 case (KOPI):
313 ext = "(*.ics/*.vcs)"; 314 ext = "(*.ics/*.vcs)";
314 break; 315 break;
315 case (PWMPI): 316 case (PWMPI):
316 ext = "(*.pwm)"; 317 ext = "(*.pwm)";
317 break; 318 break;
318 default: 319 default:
319 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 320 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
320 break; 321 break;
321 322
322 } 323 }
323 324
324 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 325 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
325 if ( fn == "" ) 326 if ( fn == "" )
326 return; 327 return;
327 if ( syncWithFile( fn, false ) ) { 328 if ( syncWithFile( fn, false ) ) {
328 qDebug("syncLocalFile() successful "); 329 qDebug("syncLocalFile() successful ");
329 } 330 }
330 331
331} 332}
332 333
333bool KSyncManager::syncWithFile( QString fn , bool quick ) 334bool KSyncManager::syncWithFile( QString fn , bool quick )
334{ 335{
335 bool ret = false; 336 bool ret = false;
336 QFileInfo info; 337 QFileInfo info;
337 info.setFile( fn ); 338 info.setFile( fn );
338 QString mess; 339 QString mess;
339 bool loadbup = true; 340 bool loadbup = true;
340 if ( !info. exists() ) { 341 if ( !info. exists() ) {
341 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 342 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
342 int result = QMessageBox::warning( mParent, i18n("Warning!"), 343 int result = QMessageBox::warning( mParent, i18n("Warning!"),
343 mess ); 344 mess );
344 return ret; 345 return ret;
345 } 346 }
346 int result = 0; 347 int result = 0;
347 if ( !quick ) { 348 if ( !quick ) {
348 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 349 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
349 result = QMessageBox::warning( mParent, i18n("Warning!"), 350 result = QMessageBox::warning( mParent, i18n("Warning!"),
350 mess, 351 mess,
351 i18n("Sync"), i18n("Cancel"), 0, 352 i18n("Sync"), i18n("Cancel"), 0,
352 0, 1 ); 353 0, 1 );
353 if ( result ) 354 if ( result )
354 return false; 355 return false;
355 } 356 }
356 if ( mAskForPreferences ) 357 if ( mAskForPreferences )
357 edit_sync_options(); 358 edit_sync_options();
358 if ( result == 0 ) { 359 if ( result == 0 ) {
359 //qDebug("Now sycing ... "); 360 //qDebug("Now sycing ... ");
360 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 361 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
361 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 362 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
362 else 363 else
363 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 364 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
364 if ( ! quick ) 365 if ( ! quick )
365 mPrefs->mLastSyncedLocalFile = fn; 366 mPrefs->mLastSyncedLocalFile = fn;
366 } 367 }
367 return ret; 368 return ret;
368} 369}
369 370
370void KSyncManager::quickSyncLocalFile() 371void KSyncManager::quickSyncLocalFile()
371{ 372{
372 373
373 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 374 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
374 qDebug("quick syncLocalFile() successful "); 375 qDebug("quick syncLocalFile() successful ");
375 376
376 } 377 }
377} 378}
378 379
379void KSyncManager::multiSync( bool askforPrefs ) 380void KSyncManager::multiSync( bool askforPrefs )
380{ 381{
381 if (blockSave()) 382 if (blockSave())
382 return; 383 return;
383 setBlockSave(true); 384 setBlockSave(true);
384 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 385 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
385 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 386 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
386 question, 387 question,
387 i18n("Yes"), i18n("No"), 388 i18n("Yes"), i18n("No"),
388 0, 0 ) != 0 ) { 389 0, 0 ) != 0 ) {
389 setBlockSave(false); 390 setBlockSave(false);
390 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 391 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
391 return; 392 return;
392 } 393 }
393 mCurrentSyncDevice = i18n("Multiple profiles") ; 394 mCurrentSyncDevice = i18n("Multiple profiles") ;
394 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 395 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
395 if ( askforPrefs ) { 396 if ( askforPrefs ) {
396 edit_sync_options(); 397 edit_sync_options();
397 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 398 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
398 } 399 }
399 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 400 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
400 qApp->processEvents(); 401 qApp->processEvents();
401 int num = ringSync() ; 402 int num = ringSync() ;
402 if ( num > 1 ) 403 if ( num > 1 )
403 ringSync(); 404 ringSync();
404 setBlockSave(false); 405 setBlockSave(false);
405 if ( num ) 406 if ( num )
406 emit save(); 407 emit save();
407 if ( num ) 408 if ( num )
408 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 409 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
409 else 410 else
410 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 411 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
411 return; 412 return;
412} 413}
413 414
414int KSyncManager::ringSync() 415int KSyncManager::ringSync()
415{ 416{
416 int syncedProfiles = 0; 417 int syncedProfiles = 0;
417 unsigned int i; 418 unsigned int i;
418 QTime timer; 419 QTime timer;
419 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 420 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
420 QStringList syncProfileNames = mSyncProfileNames; 421 QStringList syncProfileNames = mSyncProfileNames;
421 KSyncProfile* temp = new KSyncProfile (); 422 KSyncProfile* temp = new KSyncProfile ();
422 mAskForPreferences = false; 423 mAskForPreferences = false;
423 for ( i = 0; i < syncProfileNames.count(); ++i ) { 424 for ( i = 0; i < syncProfileNames.count(); ++i ) {
424 mCurrentSyncProfile = i; 425 mCurrentSyncProfile = i;
425 temp->setName(syncProfileNames[mCurrentSyncProfile]); 426 temp->setName(syncProfileNames[mCurrentSyncProfile]);
426 temp->readConfig(&config); 427 temp->readConfig(&config);
427 428
428 bool includeInRingSync; 429 bool includeInRingSync;
429 switch(mTargetApp) 430 switch(mTargetApp)
430 { 431 {
431 case (KAPI): 432 case (KAPI):
432 includeInRingSync = temp->getIncludeInRingSyncAB(); 433 includeInRingSync = temp->getIncludeInRingSyncAB();
433 break; 434 break;
434 case (KOPI): 435 case (KOPI):
435 includeInRingSync = temp->getIncludeInRingSync(); 436 includeInRingSync = temp->getIncludeInRingSync();
436 break; 437 break;
437 case (PWMPI): 438 case (PWMPI):
438 includeInRingSync = temp->getIncludeInRingSyncPWM(); 439 includeInRingSync = temp->getIncludeInRingSyncPWM();
439 break; 440 break;
440 default: 441 default:
441 qDebug("KSyncManager::ringSync: invalid apptype selected"); 442 qDebug("KSyncManager::ringSync: invalid apptype selected");
442 break; 443 break;
443 444
444 } 445 }
445 446
446 447
447 if ( includeInRingSync && ( i < 1 || i > 2 )) { 448 if ( includeInRingSync && ( i < 1 || i > 2 )) {
448 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 449 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
449 ++syncedProfiles; 450 ++syncedProfiles;
450 // mAskForPreferences = temp->getAskForPreferences(); 451 // mAskForPreferences = temp->getAskForPreferences();
451 mWriteBackFile = temp->getWriteBackFile(); 452 mWriteBackFile = temp->getWriteBackFile();
452 mWriteBackExistingOnly = temp->getWriteBackExisting(); 453 mWriteBackExistingOnly = temp->getWriteBackExisting();
453 mWriteBackInFuture = 0; 454 mWriteBackInFuture = 0;
454 if ( temp->getWriteBackFuture() ) 455 if ( temp->getWriteBackFuture() )
455 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 456 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
456 mShowSyncSummary = false; 457 mShowSyncSummary = false;
457 mCurrentSyncDevice = syncProfileNames[i] ; 458 mCurrentSyncDevice = syncProfileNames[i] ;
458 mCurrentSyncName = mLocalMachineName; 459 mCurrentSyncName = mLocalMachineName;
459 if ( i == 0 ) { 460 if ( i == 0 ) {
460 syncSharp(); 461 syncSharp();
461 } else { 462 } else {
462 if ( temp->getIsLocalFileSync() ) { 463 if ( temp->getIsLocalFileSync() ) {
463 switch(mTargetApp) 464 switch(mTargetApp)
464 { 465 {
465 case (KAPI): 466 case (KAPI):
466 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 467 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 468 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
468 break; 469 break;
469 case (KOPI): 470 case (KOPI):
470 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 471 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 472 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
472 break; 473 break;
473 case (PWMPI): 474 case (PWMPI):
474 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 475 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
475 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 476 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
476 break; 477 break;
477 default: 478 default:
478 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 479 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
479 break; 480 break;
480 } 481 }
481 } else { 482 } else {
482 if ( temp->getIsPhoneSync() ) { 483 if ( temp->getIsPhoneSync() ) {
483 mPhoneDevice = temp->getPhoneDevice( ) ; 484 mPhoneDevice = temp->getPhoneDevice( ) ;
484 mPhoneConnection = temp->getPhoneConnection( ); 485 mPhoneConnection = temp->getPhoneConnection( );
485 mPhoneModel = temp->getPhoneModel( ); 486 mPhoneModel = temp->getPhoneModel( );
486 syncPhone(); 487 syncPhone();
487 } else if ( temp->getIsPiSync() ) { 488 } else if ( temp->getIsPiSync() ) {
488 if ( mTargetApp == KAPI ) { 489 if ( mTargetApp == KAPI ) {
489 mPassWordPiSync = temp->getRemotePwAB(); 490 mPassWordPiSync = temp->getRemotePwAB();
490 mActiveSyncPort = temp->getRemotePortAB(); 491 mActiveSyncPort = temp->getRemotePortAB();
491 mActiveSyncIP = temp->getRemoteIPAB(); 492 mActiveSyncIP = temp->getRemoteIPAB();
492 } else if ( mTargetApp == KOPI ) { 493 } else if ( mTargetApp == KOPI ) {
493 mPassWordPiSync = temp->getRemotePw(); 494 mPassWordPiSync = temp->getRemotePw();
494 mActiveSyncPort = temp->getRemotePort(); 495 mActiveSyncPort = temp->getRemotePort();
495 mActiveSyncIP = temp->getRemoteIP(); 496 mActiveSyncIP = temp->getRemoteIP();
496 } else { 497 } else {
497 mPassWordPiSync = temp->getRemotePwPWM(); 498 mPassWordPiSync = temp->getRemotePwPWM();
498 mActiveSyncPort = temp->getRemotePortPWM(); 499 mActiveSyncPort = temp->getRemotePortPWM();
499 mActiveSyncIP = temp->getRemoteIPPWM(); 500 mActiveSyncIP = temp->getRemoteIPPWM();
500 } 501 }
501 syncPi(); 502 syncPi();
502 } else 503 } else
503 syncRemote( temp, false ); 504 syncRemote( temp, false );
504 505
505 } 506 }
506 } 507 }
507 timer.start(); 508 timer.start();
508 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 509 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
509 while ( timer.elapsed () < 2000 ) { 510 while ( timer.elapsed () < 2000 ) {
510 qApp->processEvents(); 511 qApp->processEvents();
511#ifndef _WIN32_ 512#ifndef _WIN32_
512 sleep (1); 513 sleep (1);
513#endif 514#endif
514 } 515 }
515 516
516 } 517 }
517 518
518 } 519 }
519 delete temp; 520 delete temp;
520 return syncedProfiles; 521 return syncedProfiles;
521} 522}
522 523
523void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 524void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
524{ 525{
525 QString question; 526 QString question;
526 if ( ask ) { 527 if ( ask ) {
527 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 528 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
528 if ( QMessageBox::information( mParent, i18n("Sync"), 529 if ( QMessageBox::information( mParent, i18n("Sync"),
529 question, 530 question,
530 i18n("Yes"), i18n("No"), 531 i18n("Yes"), i18n("No"),
531 0, 0 ) != 0 ) 532 0, 0 ) != 0 )
532 return; 533 return;
533 } 534 }
534 535
535 QString preCommand; 536 QString preCommand;
536 QString localTempFile; 537 QString localTempFile;
537 QString postCommand; 538 QString postCommand;
538 539
539 switch(mTargetApp) 540 switch(mTargetApp)
540 { 541 {
541 case (KAPI): 542 case (KAPI):
542 preCommand = prof->getPreSyncCommandAB(); 543 preCommand = prof->getPreSyncCommandAB();
543 postCommand = prof->getPostSyncCommandAB(); 544 postCommand = prof->getPostSyncCommandAB();
544 localTempFile = prof->getLocalTempFileAB(); 545 localTempFile = prof->getLocalTempFileAB();
545 break; 546 break;
546 case (KOPI): 547 case (KOPI):
547 preCommand = prof->getPreSyncCommand(); 548 preCommand = prof->getPreSyncCommand();
548 postCommand = prof->getPostSyncCommand(); 549 postCommand = prof->getPostSyncCommand();
549 localTempFile = prof->getLocalTempFile(); 550 localTempFile = prof->getLocalTempFile();
550 break; 551 break;
551 case (PWMPI): 552 case (PWMPI):
552 preCommand = prof->getPreSyncCommandPWM(); 553 preCommand = prof->getPreSyncCommandPWM();
553 postCommand = prof->getPostSyncCommandPWM(); 554 postCommand = prof->getPostSyncCommandPWM();
554 localTempFile = prof->getLocalTempFilePWM(); 555 localTempFile = prof->getLocalTempFilePWM();
555 break; 556 break;
556 default: 557 default:
557 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 558 qDebug("KSyncManager::syncRemote: invalid apptype selected");
558 break; 559 break;
559 } 560 }
560 561
561 562
562 int fi; 563 int fi;
563 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 564 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
564 QString pwd = getPassword(); 565 QString pwd = getPassword();
565 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 566 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
566 567
567 } 568 }
568 int maxlen = 30; 569 int maxlen = 30;
569 if ( QApplication::desktop()->width() > 320 ) 570 if ( QApplication::desktop()->width() > 320 )
570 maxlen += 25; 571 maxlen += 25;
571 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 572 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
572 int fileSize = 0; 573 int fileSize = 0;
573 int result = system ( preCommand ); 574 int result = system ( preCommand );
574 // 0 : okay 575 // 0 : okay
575 // 256: no such file or dir 576 // 256: no such file or dir
576 // 577 //
577 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 578 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
578 if ( result != 0 ) { 579 if ( result != 0 ) {
579 unsigned int len = maxlen; 580 unsigned int len = maxlen;
580 while ( len < preCommand.length() ) { 581 while ( len < preCommand.length() ) {
581 preCommand.insert( len , "\n" ); 582 preCommand.insert( len , "\n" );
582 len += maxlen +2; 583 len += maxlen +2;
583 } 584 }
584 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) ; 585 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) ;
585 QMessageBox::information( mParent, i18n("Sync - ERROR"), 586 QMessageBox::information( mParent, i18n("Sync - ERROR"),
586 question, 587 question,
587 i18n("Okay!")) ; 588 i18n("Okay!")) ;
588 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 589 mParent->topLevelWidget()->setCaption ("KDE-Pim");
589 return; 590 return;
590 } 591 }
591 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 592 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
592 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 593 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
593 594
594 if ( syncWithFile( localTempFile, true ) ) { 595 if ( syncWithFile( localTempFile, true ) ) {
595 596
596 if ( mWriteBackFile ) { 597 if ( mWriteBackFile ) {
597 int fi; 598 int fi;
598 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 599 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
599 QString pwd = getPassword(); 600 QString pwd = getPassword();
600 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 601 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
601 602
602 } 603 }
603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 604 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
604 result = system ( postCommand ); 605 result = system ( postCommand );
605 qDebug("Sync:Writing back file result: %d ", result); 606 qDebug("Sync:Writing back file result: %d ", result);
606 if ( result != 0 ) { 607 if ( result != 0 ) {
607 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 608 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
608 return; 609 return;
609 } else { 610 } else {
610 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 611 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
611 } 612 }
612 } 613 }
613 } 614 }
614 return; 615 return;
615} 616}
616void KSyncManager::edit_pisync_options() 617void KSyncManager::edit_pisync_options()
617{ 618{
618 QDialog dia( mParent, "dia", true ); 619 QDialog dia( mParent, "dia", true );
619 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 620 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
620 QVBoxLayout lay ( &dia ); 621 QVBoxLayout lay ( &dia );
621 lay.setSpacing( 5 ); 622 lay.setSpacing( 5 );
622 lay.setMargin( 3 ); 623 lay.setMargin( 3 );
623 QLabel lab1 ( i18n("Password for remote access:"), &dia); 624 QLabel lab1 ( i18n("Password for remote access:"), &dia);
624 lay.addWidget( &lab1 ); 625 lay.addWidget( &lab1 );
625 QLineEdit le1 (&dia ); 626 QLineEdit le1 (&dia );
626 lay.addWidget( &le1 ); 627 lay.addWidget( &le1 );
627 QLabel lab2 ( i18n("Remote IP address:"), &dia); 628 QLabel lab2 ( i18n("Remote IP address:"), &dia);
628 lay.addWidget( &lab2 ); 629 lay.addWidget( &lab2 );
629 QLineEdit le2 (&dia ); 630 QLineEdit le2 (&dia );
630 lay.addWidget( &le2 ); 631 lay.addWidget( &le2 );
631 QLabel lab3 ( i18n("Remote port number:"), &dia); 632 QLabel lab3 ( i18n("Remote port number:"), &dia);
632 lay.addWidget( &lab3 ); 633 lay.addWidget( &lab3 );
633 QLineEdit le3 (&dia ); 634 QLineEdit le3 (&dia );
634 lay.addWidget( &le3 ); 635 lay.addWidget( &le3 );
635 QPushButton pb ( "OK", &dia); 636 QPushButton pb ( "OK", &dia);
636 lay.addWidget( &pb ); 637 lay.addWidget( &pb );
637 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 638 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
638 le1.setText( mPassWordPiSync ); 639 le1.setText( mPassWordPiSync );
639 le2.setText( mActiveSyncIP ); 640 le2.setText( mActiveSyncIP );
640 le3.setText( mActiveSyncPort ); 641 le3.setText( mActiveSyncPort );
641 if ( dia.exec() ) { 642 if ( dia.exec() ) {
642 mPassWordPiSync = le1.text(); 643 mPassWordPiSync = le1.text();
643 mActiveSyncPort = le3.text(); 644 mActiveSyncPort = le3.text();
644 mActiveSyncIP = le2.text(); 645 mActiveSyncIP = le2.text();
645 } 646 }
646 647
647} 648}
648void KSyncManager::edit_sync_options() 649void KSyncManager::edit_sync_options()
649{ 650{
650 651
651 QDialog dia( mParent, "dia", true ); 652 QDialog dia( mParent, "dia", true );
652 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 653 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
653 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 654 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
654 QVBoxLayout lay ( &dia ); 655 QVBoxLayout lay ( &dia );
655 lay.setSpacing( 2 ); 656 lay.setSpacing( 2 );
656 lay.setMargin( 3 ); 657 lay.setMargin( 3 );
657 lay.addWidget(&gr); 658 lay.addWidget(&gr);
658 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 659 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
659 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 660 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
660 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 661 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
661 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 662 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
662 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 663 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
663 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 664 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
664 //QRadioButton both( i18n("Take both on conflict"), &gr ); 665 //QRadioButton both( i18n("Take both on conflict"), &gr );
665 QPushButton pb ( "OK", &dia); 666 QPushButton pb ( "OK", &dia);
666 lay.addWidget( &pb ); 667 lay.addWidget( &pb );
667 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 668 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
668 switch ( mSyncAlgoPrefs ) { 669 switch ( mSyncAlgoPrefs ) {
669 case 0: 670 case 0:
670 loc.setChecked( true); 671 loc.setChecked( true);
671 break; 672 break;
672 case 1: 673 case 1:
673 rem.setChecked( true ); 674 rem.setChecked( true );
674 break; 675 break;
675 case 2: 676 case 2:
676 newest.setChecked( true); 677 newest.setChecked( true);
677 break; 678 break;
678 case 3: 679 case 3:
679 ask.setChecked( true); 680 ask.setChecked( true);
680 break; 681 break;
681 case 4: 682 case 4:
682 f_loc.setChecked( true); 683 f_loc.setChecked( true);
683 break; 684 break;
684 case 5: 685 case 5:
685 f_rem.setChecked( true); 686 f_rem.setChecked( true);
686 break; 687 break;
687 case 6: 688 case 6:
688 // both.setChecked( true); 689 // both.setChecked( true);
689 break; 690 break;
690 default: 691 default:
691 break; 692 break;
692 } 693 }
693 if ( dia.exec() ) { 694 if ( dia.exec() ) {
694 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 695 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
695 } 696 }
696 697
697 698
698} 699}
699 700
700QString KSyncManager::getPassword( ) 701QString KSyncManager::getPassword( )
701{ 702{
702 QString retfile = ""; 703 QString retfile = "";
703 QDialog dia ( mParent, "input-dialog", true ); 704 QDialog dia ( mParent, "input-dialog", true );
704 QLineEdit lab ( &dia ); 705 QLineEdit lab ( &dia );
705 lab.setEchoMode( QLineEdit::Password ); 706 lab.setEchoMode( QLineEdit::Password );
706 QVBoxLayout lay( &dia ); 707 QVBoxLayout lay( &dia );
707 lay.setMargin(7); 708 lay.setMargin(7);
708 lay.setSpacing(7); 709 lay.setSpacing(7);
709 lay.addWidget( &lab); 710 lay.addWidget( &lab);
710 dia.setFixedSize( 230,50 ); 711 dia.setFixedSize( 230,50 );
711 dia.setCaption( i18n("Enter password") ); 712 dia.setCaption( i18n("Enter password") );
712 QPushButton pb ( "OK", &dia); 713 QPushButton pb ( "OK", &dia);
713 lay.addWidget( &pb ); 714 lay.addWidget( &pb );
714 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 715 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
715 dia.show(); 716 dia.show();
716 int res = dia.exec(); 717 int res = dia.exec();
717 if ( res ) 718 if ( res )
718 retfile = lab.text(); 719 retfile = lab.text();
719 dia.hide(); 720 dia.hide();
720 qApp->processEvents(); 721 qApp->processEvents();
721 return retfile; 722 return retfile;
722 723
723} 724}
724 725
725 726
726void KSyncManager::confSync() 727void KSyncManager::confSync()
727{ 728{
728 static KSyncPrefsDialog* sp = 0; 729 static KSyncPrefsDialog* sp = 0;
729 if ( ! sp ) { 730 if ( ! sp ) {
730 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 731 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
731 } 732 }
732 sp->usrReadConfig(); 733 sp->usrReadConfig();
733#ifndef DESKTOP_VERSION 734#ifndef DESKTOP_VERSION
734 sp->showMaximized(); 735 sp->showMaximized();
735#else 736#else
736 sp->show(); 737 sp->show();
737#endif 738#endif
738 sp->exec(); 739 sp->exec();
739 mSyncProfileNames = sp->getSyncProfileNames(); 740 mSyncProfileNames = sp->getSyncProfileNames();
740 mLocalMachineName = sp->getLocalMachineName (); 741 mLocalMachineName = sp->getLocalMachineName ();
741 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 742 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
742} 743}
743 744
744void KSyncManager::syncSharp() 745void KSyncManager::syncSharp()
745{ 746{
746 747
747 if ( ! syncExternalApplication("sharp") ) 748 if ( ! syncExternalApplication("sharp") )
748 qDebug("ERROR sync sharp "); 749 qDebug("ERROR sync sharp ");
749} 750}
750 751
751bool KSyncManager::syncExternalApplication(QString resource) 752bool KSyncManager::syncExternalApplication(QString resource)
752{ 753{
753 754
754 emit save(); 755 emit save();
755 756
756 if ( mAskForPreferences ) 757 if ( mAskForPreferences )
757 edit_sync_options(); 758 edit_sync_options();
758 759
759 qDebug("Sync extern %s", resource.latin1()); 760 qDebug("Sync extern %s", resource.latin1());
760 761
761 bool syncOK = mImplementation->syncExternal(this, resource); 762 bool syncOK = mImplementation->syncExternal(this, resource);
762 763
763 return syncOK; 764 return syncOK;
764 765
765} 766}
766 767
767void KSyncManager::syncPhone() 768void KSyncManager::syncPhone()
768{ 769{
769 770
770 syncExternalApplication("phone"); 771 syncExternalApplication("phone");
771 772
772} 773}
773 774
774void KSyncManager::showProgressBar(int percentage, QString caption, int total) 775void KSyncManager::showProgressBar(int percentage, QString caption, int total)
775{ 776{
776 if (!bar->isVisible()) 777 if (!bar->isVisible())
777 { 778 {
778 bar->setCaption (caption); 779 bar->setCaption (caption);
779 bar->setTotalSteps ( total ) ; 780 bar->setTotalSteps ( total ) ;
780 781
781 bar->show(); 782 bar->show();
782 } 783 }
783 784
784 bar->setProgress( percentage ); 785 bar->setProgress( percentage );
785} 786}
786 787
787void KSyncManager::hideProgressBar() 788void KSyncManager::hideProgressBar()
788{ 789{
789 bar->hide(); 790 bar->hide();
790} 791}
791 792
792bool KSyncManager::isProgressBarCanceled() 793bool KSyncManager::isProgressBarCanceled()
793{ 794{
794 return !bar->isVisible(); 795 return !bar->isVisible();
795} 796}
796 797
797QString KSyncManager::syncFileName() 798QString KSyncManager::syncFileName()
798{ 799{
799 800
800 QString fn = "tempfile"; 801 QString fn = "tempfile";
801 switch(mTargetApp) 802 switch(mTargetApp)
802 { 803 {
803 case (KAPI): 804 case (KAPI):
804 fn = "tempsyncab.vcf"; 805 fn = "tempsyncab.vcf";
805 break; 806 break;
806 case (KOPI): 807 case (KOPI):
807 fn = "tempsynccal.ics"; 808 fn = "tempsynccal.ics";
808 break; 809 break;
809 case (PWMPI): 810 case (PWMPI):
810 fn = "tempsyncpw.pwm"; 811 fn = "tempsyncpw.pwm";
811 break; 812 break;
812 default: 813 default:
813 break; 814 break;
814 } 815 }
815#ifdef _WIN32_ 816#ifdef _WIN32_
816 return locateLocal( "tmp", fn ); 817 return locateLocal( "tmp", fn );
817#else 818#else
818 return (QString( "/tmp/" )+ fn ); 819 return (QString( "/tmp/" )+ fn );
819#endif 820#endif
820} 821}
821 822
822void KSyncManager::syncPi() 823void KSyncManager::syncPi()
823{ 824{
824 qApp->processEvents(); 825 qApp->processEvents();
825 if ( mAskForPreferences ) 826 if ( mAskForPreferences )
826 edit_pisync_options(); 827 edit_pisync_options();
827 bool ok; 828 bool ok;
828 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 829 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
829 if ( ! ok ) { 830 if ( ! ok ) {
830 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 831 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
831 return; 832 return;
832 } 833 }
833 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 834 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
834 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 835 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
835 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 836 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
836 commandSocket->readFile( syncFileName() ); 837 commandSocket->readFile( syncFileName() );
837} 838}
838 839
839void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 840void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
840{ 841{
841 //enum { success, errorW, errorR, quiet }; 842 //enum { success, errorW, errorR, quiet };
842 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 843 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
843 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 844 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
844 delete s; 845 delete s;
845 if ( state == KCommandSocket::errorR ) { 846 if ( state == KCommandSocket::errorR ) {
846 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 847 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
847 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 848 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
848 commandSocket->sendStop(); 849 commandSocket->sendStop();
849 } 850 }
850 return; 851 return;
851 852
852 } else if ( state == KCommandSocket::errorW ) { 853 } else if ( state == KCommandSocket::errorW ) {
853 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 854 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
854 855
855 } else if ( state == KCommandSocket::successR ) { 856 } else if ( state == KCommandSocket::successR ) {
856 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 857 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
857 858
858 } else if ( state == KCommandSocket::successW ) { 859 } else if ( state == KCommandSocket::successW ) {
859 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 860 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
860 } 861 }
861 862
862 delete s; 863 delete s;
863} 864}
864 865
865void KSyncManager::readFileFromSocket() 866void KSyncManager::readFileFromSocket()
866{ 867{
867 QString fileName = syncFileName(); 868 QString fileName = syncFileName();
868 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 869 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
869 if ( ! syncWithFile( fileName , true ) ) { 870 if ( ! syncWithFile( fileName , true ) ) {
870 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 871 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
871 return; 872 return;
872 } 873 }
873 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 874 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
874 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 875 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
875 if ( mWriteBackFile ) 876 if ( mWriteBackFile )
876 commandSocket->writeFile( fileName ); 877 commandSocket->writeFile( fileName );
877 else { 878 else {
878 commandSocket->sendStop(); 879 commandSocket->sendStop();
879 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 880 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
880 } 881 }
881} 882}
882 883
883KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 884KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
884{ 885{
885 mPassWord = pw; 886 mPassWord = pw;
886 mSocket = 0; 887 mSocket = 0;
887 mSyncActionDialog = 0; 888 mSyncActionDialog = 0;
888 blockRC = false; 889 blockRC = false;
889}; 890};
890 891
891void KServerSocket::newConnection ( int socket ) 892void KServerSocket::newConnection ( int socket )
892{ 893{
893 // qDebug("KServerSocket:New connection %d ", socket); 894 // qDebug("KServerSocket:New connection %d ", socket);
894 if ( mSocket ) { 895 if ( mSocket ) {
895 qDebug("KServerSocket::newConnection Socket deleted! "); 896 qDebug("KServerSocket::newConnection Socket deleted! ");
896 delete mSocket; 897 delete mSocket;
897 mSocket = 0; 898 mSocket = 0;
898 } 899 }
899 mSocket = new QSocket( this ); 900 mSocket = new QSocket( this );
900 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 901 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
901 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 902 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
902 mSocket->setSocket( socket ); 903 mSocket->setSocket( socket );
903} 904}
904 905
905void KServerSocket::discardClient() 906void KServerSocket::discardClient()
906{ 907{
907 //qDebug(" KServerSocket::discardClient()"); 908 //qDebug(" KServerSocket::discardClient()");
908 if ( mSocket ) { 909 if ( mSocket ) {
909 delete mSocket; 910 delete mSocket;
910 mSocket = 0; 911 mSocket = 0;
911 } 912 }
912 //emit endConnect(); 913 //emit endConnect();
913} 914}
914void KServerSocket::readClient() 915void KServerSocket::readClient()
915{ 916{
916 if ( blockRC ) 917 if ( blockRC )
917 return; 918 return;
918 if ( mSocket == 0 ) { 919 if ( mSocket == 0 ) {
919 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 920 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
920 return; 921 return;
921 } 922 }
922 //qDebug("KServerSocket::readClient()"); 923 //qDebug("KServerSocket::readClient()");
923 if ( mSocket->canReadLine() ) { 924 if ( mSocket->canReadLine() ) {
924 QString line = mSocket->readLine(); 925 QString line = mSocket->readLine();
925 //qDebug("KServerSocket readline: %s ", line.latin1()); 926 //qDebug("KServerSocket readline: %s ", line.latin1());
926 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 927 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
927 if ( tokens[0] == "GET" ) { 928 if ( tokens[0] == "GET" ) {
928 if ( tokens[1] == mPassWord ) 929 if ( tokens[1] == mPassWord )
929 //emit sendFile( mSocket ); 930 //emit sendFile( mSocket );
930 send_file(); 931 send_file();
931 else { 932 else {
932 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 933 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
933 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 934 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
934 } 935 }
935 } 936 }
936 if ( tokens[0] == "PUT" ) { 937 if ( tokens[0] == "PUT" ) {
937 if ( tokens[1] == mPassWord ) { 938 if ( tokens[1] == mPassWord ) {
938 //emit getFile( mSocket ); 939 //emit getFile( mSocket );
939 blockRC = true; 940 blockRC = true;
940 get_file(); 941 get_file();
941 } 942 }
942 else { 943 else {
943 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 944 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
944 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 945 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
945 } 946 }
946 } 947 }
947 if ( tokens[0] == "STOP" ) { 948 if ( tokens[0] == "STOP" ) {
948 //emit endConnect(); 949 //emit endConnect();
949 end_connect(); 950 end_connect();
950 } 951 }
951 } 952 }
952} 953}
953void KServerSocket::end_connect() 954void KServerSocket::end_connect()
954{ 955{
955 delete mSyncActionDialog; 956 delete mSyncActionDialog;
956 mSyncActionDialog = 0; 957 mSyncActionDialog = 0;
957} 958}
958void KServerSocket::send_file() 959void KServerSocket::send_file()
959{ 960{
960 //qDebug("MainWindow::sendFile(QSocket* s) "); 961 //qDebug("MainWindow::sendFile(QSocket* s) ");
961 if ( mSyncActionDialog ) 962 if ( mSyncActionDialog )
962 delete mSyncActionDialog; 963 delete mSyncActionDialog;
963 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 964 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
964 mSyncActionDialog->setCaption(i18n("Received sync request")); 965 mSyncActionDialog->setCaption(i18n("Received sync request"));
965 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 966 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
966 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 967 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
967 lay->addWidget( label); 968 lay->addWidget( label);
968 lay->setMargin(7); 969 lay->setMargin(7);
969 lay->setSpacing(7); 970 lay->setSpacing(7);
970 mSyncActionDialog->setFixedSize( 230, 120); 971 mSyncActionDialog->setFixedSize( 230, 120);
971 mSyncActionDialog->show(); 972 mSyncActionDialog->show();
972 mSyncActionDialog->raise(); 973 mSyncActionDialog->raise();
973 emit request_file(); 974 emit request_file();
974 qApp->processEvents(); 975 qApp->processEvents();
975 QString fileName = mFileName; 976 QString fileName = mFileName;
976 QFile file( fileName ); 977 QFile file( fileName );
977 if (!file.open( IO_ReadOnly ) ) { 978 if (!file.open( IO_ReadOnly ) ) {
978 delete mSyncActionDialog; 979 delete mSyncActionDialog;
979 mSyncActionDialog = 0; 980 mSyncActionDialog = 0;
980 qDebug("KSS::error open file "); 981 qDebug("KSS::error open file ");
981 mSocket->close(); 982 mSocket->close();
982 if ( mSocket->state() == QSocket::Idle ) 983 if ( mSocket->state() == QSocket::Idle )
983 QTimer::singleShot( 10, this , SLOT ( discardClient())); 984 QTimer::singleShot( 10, this , SLOT ( discardClient()));
984 return ; 985 return ;
985 986
986 } 987 }
987 mSyncActionDialog->setCaption( i18n("Sending file...") ); 988 mSyncActionDialog->setCaption( i18n("Sending file...") );
988 QTextStream ts( &file ); 989 QTextStream ts( &file );
989 ts.setEncoding( QTextStream::Latin1 ); 990 ts.setEncoding( QTextStream::Latin1 );
990 991
991 QTextStream os( mSocket ); 992 QTextStream os( mSocket );
992 os.setEncoding( QTextStream::Latin1 ); 993 os.setEncoding( QTextStream::Latin1 );
993 while ( ! ts.atEnd() ) { 994 while ( ! ts.atEnd() ) {
994 os << ts.readLine() << "\r\n"; 995 os << ts.readLine() << "\r\n";
995 } 996 }
996 //os << ts.read(); 997 //os << ts.read();
997 file.close(); 998 file.close();
998 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 999 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
999 mSocket->close(); 1000 mSocket->close();
1000 if ( mSocket->state() == QSocket::Idle ) 1001 if ( mSocket->state() == QSocket::Idle )
1001 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1002 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1002} 1003}
1003void KServerSocket::get_file() 1004void KServerSocket::get_file()
1004{ 1005{
1005 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1006 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1006 1007
1007 piTime.start(); 1008 piTime.start();
1008 piFileString = ""; 1009 piFileString = "";
1009 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1010 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1010} 1011}
1011 1012
1012 1013
1013void KServerSocket::readBackFileFromSocket() 1014void KServerSocket::readBackFileFromSocket()
1014{ 1015{
1015 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1016 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1016 while ( mSocket->canReadLine () ) { 1017 while ( mSocket->canReadLine () ) {
1017 piTime.restart(); 1018 piTime.restart();
1018 QString line = mSocket->readLine (); 1019 QString line = mSocket->readLine ();
1019 piFileString += line; 1020 piFileString += line;
1020 //qDebug("readline: %s ", line.latin1()); 1021 //qDebug("readline: %s ", line.latin1());
1021 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1022 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1022 1023
1023 } 1024 }
1024 if ( piTime.elapsed () < 3000 ) { 1025 if ( piTime.elapsed () < 3000 ) {
1025 // wait for more 1026 // wait for more
1026 //qDebug("waitformore "); 1027 //qDebug("waitformore ");
1027 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1028 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1028 return; 1029 return;
1029 } 1030 }
1030 QString fileName = mFileName; 1031 QString fileName = mFileName;
1031 QFile file ( fileName ); 1032 QFile file ( fileName );
1032 if (!file.open( IO_WriteOnly ) ) { 1033 if (!file.open( IO_WriteOnly ) ) {
1033 delete mSyncActionDialog; 1034 delete mSyncActionDialog;
1034 mSyncActionDialog = 0; 1035 mSyncActionDialog = 0;
1035 qDebug("KSS:Error open read back file "); 1036 qDebug("KSS:Error open read back file ");
1036 piFileString = ""; 1037 piFileString = "";
1037 emit file_received( false ); 1038 emit file_received( false );
1038 blockRC = false; 1039 blockRC = false;
1039 return ; 1040 return ;
1040 1041
1041 } 1042 }
1042 1043
1043 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1044 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1044 QTextStream ts ( &file ); 1045 QTextStream ts ( &file );
1045 ts.setEncoding( QTextStream::Latin1 ); 1046 ts.setEncoding( QTextStream::Latin1 );
1046 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1047 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1047 ts << piFileString; 1048 ts << piFileString;
1048 mSocket->close(); 1049 mSocket->close();
1049 if ( mSocket->state() == QSocket::Idle ) 1050 if ( mSocket->state() == QSocket::Idle )
1050 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1051 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1051 file.close(); 1052 file.close();
1052 delete mSyncActionDialog; 1053 delete mSyncActionDialog;
1053 mSyncActionDialog = 0; 1054 mSyncActionDialog = 0;
1054 piFileString = ""; 1055 piFileString = "";
1055 blockRC = false; 1056 blockRC = false;
1056 emit file_received( true ); 1057 emit file_received( true );
1057 1058
1058} 1059}
1059 1060
1060KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1061KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1061{ 1062{
1062 mPassWord = password; 1063 mPassWord = password;
1063 mSocket = 0; 1064 mSocket = 0;
1064 mPort = port; 1065 mPort = port;
1065 mHost = host; 1066 mHost = host;
1066 1067
1067 mRetVal = quiet; 1068 mRetVal = quiet;
1068 mTimerSocket = new QTimer ( this ); 1069 mTimerSocket = new QTimer ( this );
1069 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1070 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1070} 1071}
1071void KCommandSocket::readFile( QString fn ) 1072void KCommandSocket::readFile( QString fn )
1072{ 1073{
1073 if ( !mSocket ) { 1074 if ( !mSocket ) {
1074 mSocket = new QSocket( this ); 1075 mSocket = new QSocket( this );
1075 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1076 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1076 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1077 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1077 } 1078 }
1078 mFileString = ""; 1079 mFileString = "";
1079 mFileName = fn; 1080 mFileName = fn;
1080 mFirst = true; 1081 mFirst = true;
1081 mSocket->connectToHost( mHost, mPort ); 1082 mSocket->connectToHost( mHost, mPort );
1082 QTextStream os( mSocket ); 1083 QTextStream os( mSocket );
1083 os.setEncoding( QTextStream::Latin1 ); 1084 os.setEncoding( QTextStream::Latin1 );
1084 os << "GET " << mPassWord << "\r\n"; 1085 os << "GET " << mPassWord << "\r\n";
1085 mTimerSocket->start( 10000 ); 1086 mTimerSocket->start( 10000 );
1086} 1087}
1087 1088
1088void KCommandSocket::writeFile( QString fileName ) 1089void KCommandSocket::writeFile( QString fileName )
1089{ 1090{
1090 if ( !mSocket ) { 1091 if ( !mSocket ) {
1091 mSocket = new QSocket( this ); 1092 mSocket = new QSocket( this );
1092 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1093 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1093 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1094 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1094 } 1095 }
1095 mFileName = fileName ; 1096 mFileName = fileName ;
1096 mSocket->connectToHost( mHost, mPort ); 1097 mSocket->connectToHost( mHost, mPort );
1097} 1098}
1098void KCommandSocket::writeFileToSocket() 1099void KCommandSocket::writeFileToSocket()
1099{ 1100{
1100 QFile file2( mFileName ); 1101 QFile file2( mFileName );
1101 if (!file2.open( IO_ReadOnly ) ) { 1102 if (!file2.open( IO_ReadOnly ) ) {
1102 mRetVal= errorW; 1103 mRetVal= errorW;
1103 mSocket->close(); 1104 mSocket->close();
1104 if ( mSocket->state() == QSocket::Idle ) 1105 if ( mSocket->state() == QSocket::Idle )
1105 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1106 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1106 return ; 1107 return ;
1107 } 1108 }
1108 QTextStream ts2( &file2 ); 1109 QTextStream ts2( &file2 );
1109 ts2.setEncoding( QTextStream::Latin1 ); 1110 ts2.setEncoding( QTextStream::Latin1 );
1110 QTextStream os2( mSocket ); 1111 QTextStream os2( mSocket );
1111 os2.setEncoding( QTextStream::Latin1 ); 1112 os2.setEncoding( QTextStream::Latin1 );
1112 os2 << "PUT " << mPassWord << "\r\n";; 1113 os2 << "PUT " << mPassWord << "\r\n";;
1113 while ( ! ts2.atEnd() ) { 1114 while ( ! ts2.atEnd() ) {
1114 os2 << ts2.readLine() << "\r\n"; 1115 os2 << ts2.readLine() << "\r\n";
1115 } 1116 }
1116 mRetVal= successW; 1117 mRetVal= successW;
1117 file2.close(); 1118 file2.close();
1118 mSocket->close(); 1119 mSocket->close();
1119 if ( mSocket->state() == QSocket::Idle ) 1120 if ( mSocket->state() == QSocket::Idle )
1120 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1121 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1121} 1122}
1122void KCommandSocket::sendStop() 1123void KCommandSocket::sendStop()
1123{ 1124{
1124 if ( !mSocket ) { 1125 if ( !mSocket ) {
1125 mSocket = new QSocket( this ); 1126 mSocket = new QSocket( this );
1126 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1127 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1127 } 1128 }
1128 mSocket->connectToHost( mHost, mPort ); 1129 mSocket->connectToHost( mHost, mPort );
1129 QTextStream os2( mSocket ); 1130 QTextStream os2( mSocket );
1130 os2.setEncoding( QTextStream::Latin1 ); 1131 os2.setEncoding( QTextStream::Latin1 );
1131 os2 << "STOP\r\n"; 1132 os2 << "STOP\r\n";
1132 mSocket->close(); 1133 mSocket->close();
1133 if ( mSocket->state() == QSocket::Idle ) 1134 if ( mSocket->state() == QSocket::Idle )
1134 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1135 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1135} 1136}
1136 1137
1137void KCommandSocket::startReadFileFromSocket() 1138void KCommandSocket::startReadFileFromSocket()
1138{ 1139{
1139 if ( ! mFirst ) 1140 if ( ! mFirst )
1140 return; 1141 return;
1141 mFirst = false; 1142 mFirst = false;
1142 mTimerSocket->stop(); 1143 mTimerSocket->stop();
1143 mFileString = ""; 1144 mFileString = "";
1144 mTime.start(); 1145 mTime.start();
1145 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1146 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1146 1147
1147} 1148}
1148void KCommandSocket::readFileFromSocket() 1149void KCommandSocket::readFileFromSocket()
1149{ 1150{
1150 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1151 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1151 while ( mSocket->canReadLine () ) { 1152 while ( mSocket->canReadLine () ) {
1152 mTime.restart(); 1153 mTime.restart();
1153 QString line = mSocket->readLine (); 1154 QString line = mSocket->readLine ();
1154 mFileString += line; 1155 mFileString += line;
1155 //qDebug("readline: %s ", line.latin1()); 1156 //qDebug("readline: %s ", line.latin1());
1156 } 1157 }
1157 if ( mTime.elapsed () < 3000 ) { 1158 if ( mTime.elapsed () < 3000 ) {
1158 // wait for more 1159 // wait for more
1159 //qDebug("waitformore "); 1160 //qDebug("waitformore ");
1160 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1161 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1161 return; 1162 return;
1162 } 1163 }
1163 QString fileName = mFileName; 1164 QString fileName = mFileName;
1164 QFile file ( fileName ); 1165 QFile file ( fileName );
1165 if (!file.open( IO_WriteOnly ) ) { 1166 if (!file.open( IO_WriteOnly ) ) {
1166 mFileString = ""; 1167 mFileString = "";
1167 mRetVal = errorR; 1168 mRetVal = errorR;
1168 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1169 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1169 deleteSocket(); 1170 deleteSocket();
1170 return ; 1171 return ;
1171 1172
1172 } 1173 }
1173 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1174 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1174 QTextStream ts ( &file ); 1175 QTextStream ts ( &file );
1175 ts.setEncoding( QTextStream::Latin1 ); 1176 ts.setEncoding( QTextStream::Latin1 );
1176 ts << mFileString; 1177 ts << mFileString;
1177 file.close(); 1178 file.close();
1178 mFileString = ""; 1179 mFileString = "";
1179 mRetVal = successR; 1180 mRetVal = successR;
1180 mSocket->close(); 1181 mSocket->close();
1181 // if state is not idle, deleteSocket(); is called via 1182 // if state is not idle, deleteSocket(); is called via
1182 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1183 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1183 if ( mSocket->state() == QSocket::Idle ) 1184 if ( mSocket->state() == QSocket::Idle )
1184 deleteSocket(); 1185 deleteSocket();
1185} 1186}
1186 1187
1187void KCommandSocket::deleteSocket() 1188void KCommandSocket::deleteSocket()
1188{ 1189{
1189 //qDebug("KCommandSocket::deleteSocket() "); 1190 //qDebug("KCommandSocket::deleteSocket() ");
1190 if ( mTimerSocket->isActive () ) { 1191 if ( mTimerSocket->isActive () ) {
1191 mTimerSocket->stop(); 1192 mTimerSocket->stop();
1192 mRetVal = errorTO; 1193 mRetVal = errorTO;
1193 qDebug("Connection to remote host timed out"); 1194 qDebug("Connection to remote host timed out");
1194 if ( mSocket ) { 1195 if ( mSocket ) {
1195 mSocket->close(); 1196 mSocket->close();
1196 //if ( mSocket->state() == QSocket::Idle ) 1197 //if ( mSocket->state() == QSocket::Idle )
1197 // deleteSocket(); 1198 // deleteSocket();
1198 delete mSocket; 1199 delete mSocket;
1199 mSocket = 0; 1200 mSocket = 0;
1200 } 1201 }
1201 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1202 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1202 emit commandFinished( this, mRetVal ); 1203 emit commandFinished( this, mRetVal );
1203 return; 1204 return;
1204 } 1205 }
1205 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1206 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1206 if ( mSocket) 1207 if ( mSocket)
1207 delete mSocket; 1208 delete mSocket;
1208 mSocket = 0; 1209 mSocket = 0;
1209 emit commandFinished( this, mRetVal ); 1210 emit commandFinished( this, mRetVal );
1210} 1211}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 5b05383..9094aac 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,208 +1,209 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 signals: 51 signals:
52 void file_received( bool ); 52 void file_received( bool );
53 void request_file(); 53 void request_file();
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 signals: 83 signals:
84 void commandFinished( KCommandSocket*, int ); 84 void commandFinished( KCommandSocket*, int );
85 private slots: 85 private slots:
86 void startReadFileFromSocket(); 86 void startReadFileFromSocket();
87 void readFileFromSocket(); 87 void readFileFromSocket();
88 void deleteSocket(); 88 void deleteSocket();
89 void writeFileToSocket(); 89 void writeFileToSocket();
90 private : 90 private :
91 QSocket* mSocket; 91 QSocket* mSocket;
92 QString mPassWord; 92 QString mPassWord;
93 Q_UINT16 mPort; 93 Q_UINT16 mPort;
94 QString mHost; 94 QString mHost;
95 QString mFileName; 95 QString mFileName;
96 QTimer* mTimerSocket; 96 QTimer* mTimerSocket;
97 int mRetVal; 97 int mRetVal;
98 QTime mTime; 98 QTime mTime;
99 QString mFileString; 99 QString mFileString;
100 bool mFirst; 100 bool mFirst;
101}; 101};
102 102
103 103
104class KSyncManager : public QObject 104class KSyncManager : public QObject
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 107
108 public: 108 public:
109 enum TargetApp { 109 enum TargetApp {
110 KOPI = 0, 110 KOPI = 0,
111 KAPI = 1, 111 KAPI = 1,
112 PWMPI = 2 }; 112 PWMPI = 2 };
113 113
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
115 ~KSyncManager() ; 115 ~KSyncManager() ;
116 116
117 void multiSync( bool askforPrefs ); 117 void multiSync( bool askforPrefs );
118 bool blockSave() { return mBlockSaveFlag; } 118 bool blockSave() { return mBlockSaveFlag; }
119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
120 void setDefaultFileName( QString s) { mDefFileName = s ;} 120 void setDefaultFileName( QString s) { mDefFileName = s ;}
121 QString defaultFileName() { return mDefFileName ;} 121 QString defaultFileName() { return mDefFileName ;}
122 QString syncFileName(); 122 QString syncFileName();
123 123
124 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 124 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
125 QString getCurrentSyncName() { return mCurrentSyncName; } 125 QString getCurrentSyncName() { return mCurrentSyncName; }
126 126
127 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 127 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
128 void hideProgressBar(); 128 void hideProgressBar();
129 bool isProgressBarCanceled(); 129 bool isProgressBarCanceled();
130 130
131 // sync stuff 131 // sync stuff
132 QString mLocalMachineName; 132 QString mLocalMachineName;
133 QStringList mExternSyncProfiles; 133 QStringList mExternSyncProfiles;
134 QStringList mSyncProfileNames; 134 QStringList mSyncProfileNames;
135 bool mAskForPreferences; 135 bool mAskForPreferences;
136 bool mShowSyncSummary; 136 bool mShowSyncSummary;
137 bool mIsKapiFile;
137 bool mWriteBackExistingOnly; 138 bool mWriteBackExistingOnly;
138 int mSyncAlgoPrefs; 139 int mSyncAlgoPrefs;
139 bool mWriteBackFile; 140 bool mWriteBackFile;
140 int mWriteBackInFuture; 141 int mWriteBackInFuture;
141 QString mPhoneDevice; 142 QString mPhoneDevice;
142 QString mPhoneConnection; 143 QString mPhoneConnection;
143 QString mPhoneModel; 144 QString mPhoneModel;
144 QString mPassWordPiSync; 145 QString mPassWordPiSync;
145 QString mActiveSyncPort; 146 QString mActiveSyncPort;
146 QString mActiveSyncIP ; 147 QString mActiveSyncIP ;
147 148
148 signals: 149 signals:
149 void save(); 150 void save();
150 void request_file(); 151 void request_file();
151 void getFile( bool ); 152 void getFile( bool );
152 153
153 public slots: 154 public slots:
154 void slotSyncMenu( int ); 155 void slotSyncMenu( int );
155 void deleteCommandSocket(KCommandSocket*s, int state); 156 void deleteCommandSocket(KCommandSocket*s, int state);
156 void readFileFromSocket(); 157 void readFileFromSocket();
157 void fillSyncMenu(); 158 void fillSyncMenu();
158 159
159 private: 160 private:
160 void syncPi(); 161 void syncPi();
161 KServerSocket * mServerSocket; 162 KServerSocket * mServerSocket;
162 void enableQuick(); 163 void enableQuick();
163 KPimPrefs* mPrefs; 164 KPimPrefs* mPrefs;
164 QString mDefFileName; 165 QString mDefFileName;
165 QString mCurrentSyncDevice; 166 QString mCurrentSyncDevice;
166 QString mCurrentSyncName; 167 QString mCurrentSyncName;
167 void quickSyncLocalFile(); 168 void quickSyncLocalFile();
168 bool syncWithFile( QString fn , bool quick ); 169 bool syncWithFile( QString fn , bool quick );
169 void syncLocalFile(); 170 void syncLocalFile();
170 void syncPhone(); 171 void syncPhone();
171 void syncSharp(); 172 void syncSharp();
172 bool syncExternalApplication(QString); 173 bool syncExternalApplication(QString);
173 int mCurrentSyncProfile ; 174 int mCurrentSyncProfile ;
174 void syncRemote( KSyncProfile* prof, bool ask = true); 175 void syncRemote( KSyncProfile* prof, bool ask = true);
175 void edit_sync_options(); 176 void edit_sync_options();
176 void edit_pisync_options(); 177 void edit_pisync_options();
177 int ringSync(); 178 int ringSync();
178 QString getPassword( ); 179 QString getPassword( );
179 180
180 private slots: 181 private slots:
181 void confSync(); 182 void confSync();
182 private: 183 private:
183 bool mBlockSaveFlag; 184 bool mBlockSaveFlag;
184 QWidget* mParent; 185 QWidget* mParent;
185 KSyncInterface* mImplementation; 186 KSyncInterface* mImplementation;
186 TargetApp mTargetApp; 187 TargetApp mTargetApp;
187 QPopupMenu* mSyncMenu; 188 QPopupMenu* mSyncMenu;
188 QProgressBar* bar; 189 QProgressBar* bar;
189 190
190}; 191};
191 192
192 193
193class KSyncInterface 194class KSyncInterface
194{ 195{
195 public : 196 public :
196 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 197 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
197 virtual bool syncExternal(KSyncManager* manager, QString resource) 198 virtual bool syncExternal(KSyncManager* manager, QString resource)
198 { 199 {
199 // empty implementation, because some syncable applications do not 200 // empty implementation, because some syncable applications do not
200 // have an external(sharpdtm) syncmode, like pwmanager. 201 // have an external(sharpdtm) syncmode, like pwmanager.
201 return false; 202 return false;
202 } 203 }
203 204
204 205
205}; 206};
206 207
207 208
208#endif 209#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index cf8f996..03265d2 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,732 +1,744 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@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#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46 46
47#include <kcolorbutton.h> 47#include <kcolorbutton.h>
48#include <kdebug.h> 48#include <kdebug.h>
49#include <klocale.h> 49#include <klocale.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <kfontdialog.h> 51#include <kfontdialog.h>
52#include <kmessagebox.h> 52#include <kmessagebox.h>
53#include <kcolordialog.h> 53#include <kcolordialog.h>
54#include <kiconloader.h> 54#include <kiconloader.h>
55#include <kemailsettings.h> 55#include <kemailsettings.h>
56#include <kstandarddirs.h> 56#include <kstandarddirs.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58#include <kmessagebox.h> 58#include <kmessagebox.h>
59 59
60//#include <kurlrequester.h> 60//#include <kurlrequester.h>
61#include <klineedit.h> 61#include <klineedit.h>
62#include "ksyncprofile.h" 62#include "ksyncprofile.h"
63 63
64 64
65//#include "koprefs.h" 65//#include "koprefs.h"
66 66
67#include "ksyncprefsdialog.h" 67#include "ksyncprefsdialog.h"
68//#include "koglobals.h" 68//#include "koglobals.h"
69 69
70 70
71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
72 KDialog(parent,name,true) 72 KDialog(parent,name,true)
73{ 73{
74 74
75 setCaption( i18n("Synchronization Preferences")); 75 setCaption( i18n("Synchronization Preferences"));
76 76
77 mSyncProfiles.setAutoDelete( true ); 77 mSyncProfiles.setAutoDelete( true );
78 setupSyncAlgTab(); 78 setupSyncAlgTab();
79} 79}
80 80
81 81
82KSyncPrefsDialog::~KSyncPrefsDialog() 82KSyncPrefsDialog::~KSyncPrefsDialog()
83{ 83{
84} 84}
85 85
86void KSyncPrefsDialog::setupSyncAlgTab() 86void KSyncPrefsDialog::setupSyncAlgTab()
87{ 87{
88 QLabel * lab; 88 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this ); 90 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox ); 91 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this ); 92 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox ); 93 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox ); 94 QHBox * b_box = new QHBox( mainbox );
95 95
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box ); 98 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this ); 100 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv ); 101 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit ); 102 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv ); 103 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame ); 104 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame; 105 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
109 109
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0; 111 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 113 //++iii;
114 114
115 mMyMachineName = new QLineEdit(topFrame); 115 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 117 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 118 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 119 ++iii;
120 120
121 QHBox* buttonbox = new QHBox( topFrame); 121 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 123 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 124 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 126
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 127 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 129
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 130 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 132
133 mProfileBox = new QComboBox(topFrame); 133 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 134 mProfileBox->setEditable ( true );
135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
138 138
139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
140 topLayout->addWidget(lab ,iii,0); 140 topLayout->addWidget(lab ,iii,0);
141 topLayout->addWidget(mProfileBox, iii,1); 141 topLayout->addWidget(mProfileBox, iii,1);
142 ++iii; 142 ++iii;
143 143
144 QHBox *iims = new QHBox( topFrame ); 144 QHBox *iims = new QHBox( topFrame );
145 new QLabel( i18n("Include in multiple "), iims ); 145 new QLabel( i18n("Include in multiple "), iims );
146 mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); 146 mIncludeInRing = new QCheckBox( i18n("calendar "), iims );
147 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); 147 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims );
148 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); 148 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims );
149 new QLabel( i18n(" sync"), iims ); 149 new QLabel( i18n(" sync"), iims );
150 topLayout->addMultiCellWidget(iims, iii,iii,0,1); 150 topLayout->addMultiCellWidget(iims, iii,iii,0,1);
151 ++iii; 151 ++iii;
152 152
153 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 153 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
154 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 154 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
155 ++iii; 155 ++iii;
156 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 156 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
157 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 157 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
158 ++iii; 158 ++iii;
159 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 159 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
160 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 160 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
161 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 161 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
162 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 162 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
163 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 163 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
164 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 164 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
165 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 165 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
166 166
167 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 167 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
168 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 168 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
169 ++iii; 169 ++iii;
170 170
171 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 171 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
172 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 172 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
173 ++iii; 173 ++iii;
174 174
175 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame ); 175 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame );
176 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 176 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
177 ++iii; 177 ++iii;
178 178
179 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame ); 179 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame );
180 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 180 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
181 ++iii; 181 ++iii;
182 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0); 182 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0);
183 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame); 183 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame);
184 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 184 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
185 ++iii; 185 ++iii;
186 186
187 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 187 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
188 gr = proGr; 188 gr = proGr;
189 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 189 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
190 ++iii; 190 ++iii;
191 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 191 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
192 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); 192 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr );
193 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 193 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
194 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 194 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
195 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 195 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
196 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 196 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
197 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 197 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
198 198
199 199
200 phoneWidget = new QVBox( topFrame); 200 phoneWidget = new QVBox( topFrame);
201 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 201 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
202 ++iii; 202 ++iii;
203 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 203 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
204 QHBox* temphb = new QHBox( phoneWidget ); 204 QHBox* temphb = new QHBox( phoneWidget );
205 new QLabel( i18n("I/O device: "), temphb ); 205 new QLabel( i18n("I/O device: "), temphb );
206 mPhoneDevice = new QLineEdit( temphb); 206 mPhoneDevice = new QLineEdit( temphb);
207 button = new QPushButton( i18n("Help..."), temphb ); 207 button = new QPushButton( i18n("Help..."), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 208 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
209 209
210 210
211 temphb = new QHBox( phoneWidget ); 211 temphb = new QHBox( phoneWidget );
212 new QLabel( i18n("Connection: "), temphb ); 212 new QLabel( i18n("Connection: "), temphb );
213 mPhoneConnection = new QLineEdit( temphb); 213 mPhoneConnection = new QLineEdit( temphb);
214 button = new QPushButton( i18n("Help..."), temphb ); 214 button = new QPushButton( i18n("Help..."), temphb );
215 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 215 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
216 216
217 217
218 temphb = new QHBox( phoneWidget ); 218 temphb = new QHBox( phoneWidget );
219 new QLabel( i18n("Model(opt.): "), temphb ); 219 new QLabel( i18n("Model(opt.): "), temphb );
220 mPhoneModel = new QLineEdit( temphb); 220 mPhoneModel = new QLineEdit( temphb);
221 button = new QPushButton( i18n("Help..."), temphb ); 221 button = new QPushButton( i18n("Help..."), temphb );
222 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 222 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
223 223
224 // *** local 224 // *** local
225 localFileWidget = new QVBox( topFrame); 225 localFileWidget = new QVBox( topFrame);
226 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 226 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
227 ++iii; 227 ++iii;
228 temphb = new QHBox( localFileWidget ); 228 temphb = new QHBox( localFileWidget );
229 229
230 lab = new QLabel( i18n("Local file Cal:"), temphb ); 230 lab = new QLabel( i18n("Local file Cal:"), temphb );
231 lab = new QLabel( i18n("Local file ABook:"), temphb ); 231 lab = new QLabel( i18n("Local file ABook:"), temphb );
232 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 232 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
233 temphb = new QHBox( localFileWidget ); 233 temphb = new QHBox( localFileWidget );
234 button = new QPushButton( i18n("Choose..."), temphb ); 234 button = new QPushButton( i18n("Choose..."), temphb );
235 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 235 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
236 button = new QPushButton( i18n("Choose..."), temphb ); 236 button = new QPushButton( i18n("Choose..."), temphb );
237 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 237 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
238 button = new QPushButton( i18n("Choose..."), temphb ); 238 button = new QPushButton( i18n("Choose..."), temphb );
239 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 239 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
240 temphb = new QHBox( localFileWidget ); 240 temphb = new QHBox( localFileWidget );
241 241
242 mRemoteFile = new QLineEdit( temphb); 242 mRemoteFile = new QLineEdit( temphb);
243 mRemoteFileAB = new QLineEdit( temphb); 243 mRemoteFileAB = new QLineEdit( temphb);
244 mRemoteFilePWM = new QLineEdit( temphb); 244 mRemoteFilePWM = new QLineEdit( temphb);
245 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget );
246
245 247
246 // *** remote 248 // *** remote
247 remoteFileWidget = new QVBox( topFrame); 249 remoteFileWidget = new QVBox( topFrame);
248 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 250 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
249 ++iii; 251 ++iii;
250 temphb = new QHBox( remoteFileWidget ); 252 temphb = new QHBox( remoteFileWidget );
251 new QLabel( i18n("Calendar:"), temphb); 253 new QLabel( i18n("Calendar:"), temphb);
252 new QLabel( i18n("AddressBook:"), temphb); 254 new QLabel( i18n("AddressBook:"), temphb);
253 new QLabel( i18n("PWManager:"), temphb); 255 new QLabel( i18n("PWManager:"), temphb);
254 256
255 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 257 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
256 temphb = new QHBox( remoteFileWidget ); 258 temphb = new QHBox( remoteFileWidget );
257 mRemotePrecommand = new QLineEdit(temphb); 259 mRemotePrecommand = new QLineEdit(temphb);
258 mRemotePrecommandAB = new QLineEdit(temphb); 260 mRemotePrecommandAB = new QLineEdit(temphb);
259 mRemotePrecommandPWM = new QLineEdit(temphb); 261 mRemotePrecommandPWM = new QLineEdit(temphb);
260 262
261 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 263 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
262 temphb = new QHBox( remoteFileWidget ); 264 temphb = new QHBox( remoteFileWidget );
263 mLocalTempFile = new QLineEdit(temphb); 265 mLocalTempFile = new QLineEdit(temphb);
264 mLocalTempFileAB = new QLineEdit(temphb); 266 mLocalTempFileAB = new QLineEdit(temphb);
265 mLocalTempFilePWM = new QLineEdit(temphb); 267 mLocalTempFilePWM = new QLineEdit(temphb);
266 268
267 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 269 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
268 temphb = new QHBox( remoteFileWidget ); 270 temphb = new QHBox( remoteFileWidget );
269 mRemotePostcommand = new QLineEdit(temphb ); 271 mRemotePostcommand = new QLineEdit(temphb );
270 mRemotePostcommandAB = new QLineEdit(temphb ); 272 mRemotePostcommandAB = new QLineEdit(temphb );
271 mRemotePostcommandPWM = new QLineEdit(temphb ); 273 mRemotePostcommandPWM = new QLineEdit(temphb );
272 274 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget );
273 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 275 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
274 temphb = new QHBox( remoteFileWidget ); 276 temphb = new QHBox( remoteFileWidget );
275 button = new QPushButton( i18n("ssh/scp"), temphb ); 277 button = new QPushButton( i18n("ssh/scp"), temphb );
276 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 278 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
277 button = new QPushButton( i18n("ftp"), temphb ); 279 button = new QPushButton( i18n("ftp"), temphb );
278 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 280 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
279 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 281 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
280 282
281 // *** pi-sync 283 // *** pi-sync
282 piWidget = new QVBox( topFrame); 284 piWidget = new QVBox( topFrame);
283 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 285 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
284 ++iii; 286 ++iii;
285 temphb = new QHBox( piWidget ); 287 temphb = new QHBox( piWidget );
286 new QLabel( i18n("Calendar:"), temphb); 288 new QLabel( i18n("Calendar:"), temphb);
287 new QLabel( i18n("AddressBook:"), temphb); 289 new QLabel( i18n("AddressBook:"), temphb);
288 new QLabel( i18n("PWManager:"), temphb); 290 new QLabel( i18n("PWManager:"), temphb);
289 291
290 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); 292 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
291 temphb = new QHBox( piWidget ); 293 temphb = new QHBox( piWidget );
292 mRemotePw = new QLineEdit(temphb); 294 mRemotePw = new QLineEdit(temphb);
293 mRemotePwAB = new QLineEdit(temphb); 295 mRemotePwAB = new QLineEdit(temphb);
294 mRemotePwPWM = new QLineEdit(temphb); 296 mRemotePwPWM = new QLineEdit(temphb);
295 297
296 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); 298 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
297 temphb = new QHBox( piWidget ); 299 temphb = new QHBox( piWidget );
298 mRemoteIP = new QLineEdit(temphb); 300 mRemoteIP = new QLineEdit(temphb);
299 mRemoteIPAB = new QLineEdit(temphb); 301 mRemoteIPAB = new QLineEdit(temphb);
300 mRemoteIPPWM = new QLineEdit(temphb); 302 mRemoteIPPWM = new QLineEdit(temphb);
301 303
302 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); 304 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
303 temphb = new QHBox( piWidget ); 305 temphb = new QHBox( piWidget );
304 mRemotePort = new QLineEdit(temphb); 306 mRemotePort = new QLineEdit(temphb);
305 mRemotePortAB = new QLineEdit(temphb); 307 mRemotePortAB = new QLineEdit(temphb);
306 mRemotePortPWM = new QLineEdit(temphb); 308 mRemotePortPWM = new QLineEdit(temphb);
307 309
308} 310}
309 311
310 312
311 313
312 314
313 315
314void KSyncPrefsDialog::slotOK() 316void KSyncPrefsDialog::slotOK()
315{ 317{
316 if ( mMyMachineName->text() == "undefined" ) { 318 if ( mMyMachineName->text() == "undefined" ) {
317 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 319 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
318 return; 320 return;
319 } 321 }
320 int i; 322 int i;
321 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 323 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
322 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 324 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
323 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 325 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
324 return; 326 return;
325 } 327 }
326 } 328 }
327 usrWriteConfig(); 329 usrWriteConfig();
328 QDialog::accept(); 330 QDialog::accept();
329} 331}
330void KSyncPrefsDialog::accept() 332void KSyncPrefsDialog::accept()
331{ 333{
332 slotOK(); 334 slotOK();
333} 335}
334void KSyncPrefsDialog::chooseFile() 336void KSyncPrefsDialog::chooseFile()
335{ 337{
336 QString fn = QDir::homeDirPath(); 338 QString fn = QDir::homeDirPath();
337 339
338 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 340 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
339 if ( fn == "" ) 341 if ( fn == "" )
340 return; 342 return;
341 mRemoteFile->setText( fn ); 343 mRemoteFile->setText( fn );
342} 344}
343 345
344void KSyncPrefsDialog::chooseFileAB() 346void KSyncPrefsDialog::chooseFileAB()
345{ 347{
346 QString fn = QDir::homeDirPath(); 348 QString fn = QDir::homeDirPath();
347 349
348 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 350 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
349 if ( fn == "" ) 351 if ( fn == "" )
350 return; 352 return;
351 mRemoteFileAB->setText( fn ); 353 mRemoteFileAB->setText( fn );
352} 354}
353 355
354void KSyncPrefsDialog::chooseFilePWM() 356void KSyncPrefsDialog::chooseFilePWM()
355{ 357{
356 QString fn = QDir::homeDirPath(); 358 QString fn = QDir::homeDirPath();
357 359
358 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 360 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
359 if ( fn == "" ) 361 if ( fn == "" )
360 return; 362 return;
361 mRemoteFilePWM->setText( fn ); 363 mRemoteFilePWM->setText( fn );
362} 364}
363 365
364void KSyncPrefsDialog::textChanged( const QString & s ) 366void KSyncPrefsDialog::textChanged( const QString & s )
365{ 367{
366 if ( mProfileBox->count() == 0 ) 368 if ( mProfileBox->count() == 0 )
367 return; 369 return;
368 if ( currentSelection < 3 ) { 370 if ( currentSelection < 3 ) {
369 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 371 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
370 mProfileBox->blockSignals( true ); 372 mProfileBox->blockSignals( true );
371 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 373 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
372 mProfileBox->blockSignals( false ); 374 mProfileBox->blockSignals( false );
373 return; 375 return;
374 } 376 }
375 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 377 //qDebug("cur i %d ",mProfileBox-> currentItem () );
376 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 378 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
377 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 379 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
378 prof->setName( s ); 380 prof->setName( s );
379 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 381 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
380} 382}
381void KSyncPrefsDialog::profileChanged( int item ) 383void KSyncPrefsDialog::profileChanged( int item )
382{ 384{
383 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 385 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
384 KSyncProfile* prof; 386 KSyncProfile* prof;
385 saveProfile(); 387 saveProfile();
386 currentSelection = item; 388 currentSelection = item;
387 prof = mSyncProfiles.at(item) ; 389 prof = mSyncProfiles.at(item) ;
388 390
389 mRemotePw->setText(prof->getRemotePw()); 391 mRemotePw->setText(prof->getRemotePw());
390 mRemoteIP->setText(prof->getRemoteIP()); 392 mRemoteIP->setText(prof->getRemoteIP());
391 mRemotePort->setText(prof->getRemotePort()); 393 mRemotePort->setText(prof->getRemotePort());
392 394
393 mRemotePwAB->setText(prof->getRemotePwAB()); 395 mRemotePwAB->setText(prof->getRemotePwAB());
394 mRemoteIPAB->setText(prof->getRemoteIPAB()); 396 mRemoteIPAB->setText(prof->getRemoteIPAB());
395 mRemotePortAB->setText(prof->getRemotePortAB()); 397 mRemotePortAB->setText(prof->getRemotePortAB());
396 398
397 mRemotePwPWM->setText(prof->getRemotePwPWM()); 399 mRemotePwPWM->setText(prof->getRemotePwPWM());
398 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 400 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
399 mRemotePortPWM->setText(prof->getRemotePortPWM()); 401 mRemotePortPWM->setText(prof->getRemotePortPWM());
400 402
401 mRemotePrecommand->setText(prof->getPreSyncCommand()); 403 mRemotePrecommand->setText(prof->getPreSyncCommand());
402 mRemotePostcommand->setText(prof->getPostSyncCommand()); 404 mRemotePostcommand->setText(prof->getPostSyncCommand());
403 mLocalTempFile->setText(prof->getLocalTempFile()); 405 mLocalTempFile->setText(prof->getLocalTempFile());
404 mRemoteFile->setText(prof->getRemoteFileName()) ; 406 mRemoteFile->setText(prof->getRemoteFileName()) ;
405 407
406 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 408 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
407 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 409 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
408 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 410 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
409 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 411 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
410 412
411 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 413 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
412 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 414 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
413 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 415 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
414 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 416 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
415 417
416 if ( mWriteContactToSIM ) 418 if ( mWriteContactToSIM )
417 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 419 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
418 mPhoneDevice->setText(prof->getPhoneDevice()); 420 mPhoneDevice->setText(prof->getPhoneDevice());
419 mPhoneConnection->setText(prof->getPhoneConnection()); 421 mPhoneConnection->setText(prof->getPhoneConnection());
420 mPhoneModel->setText(prof->getPhoneModel()); 422 mPhoneModel->setText(prof->getPhoneModel());
421 423
422 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 424 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
423 mAskForPreferences->setChecked( prof->getAskForPreferences()); 425 mAskForPreferences->setChecked( prof->getAskForPreferences());
424 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 426 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
425 mWriteBackFile->setChecked( prof->getWriteBackFile()); 427 mWriteBackFile->setChecked( prof->getWriteBackFile());
426 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 428 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
427 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 429 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
428 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 430 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
429 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 431 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
430 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 432 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
431 433
432 switch ( prof->getSyncPrefs() ) { 434 switch ( prof->getSyncPrefs() ) {
433 case 0: 435 case 0:
434 loc->setChecked( true); 436 loc->setChecked( true);
435 break; 437 break;
436 case 1: 438 case 1:
437 rem->setChecked( true ); 439 rem->setChecked( true );
438 break; 440 break;
439 case 2: 441 case 2:
440 newest->setChecked( true); 442 newest->setChecked( true);
441 break; 443 break;
442 case 3: 444 case 3:
443 ask->setChecked( true); 445 ask->setChecked( true);
444 break; 446 break;
445 case 4: 447 case 4:
446 f_loc->setChecked( true); 448 f_loc->setChecked( true);
447 break; 449 break;
448 case 5: 450 case 5:
449 f_rem->setChecked( true); 451 f_rem->setChecked( true);
450 break; 452 break;
451 case 6: 453 case 6:
452 //both->setChecked( true); 454 //both->setChecked( true);
453 break; 455 break;
454 default: 456 default:
455 break; 457 break;
456 } 458 }
457 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 459 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
458 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 460 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
459 mIsPi->setChecked(prof->getIsPiSync()) ; 461 mIsPi->setChecked(prof->getIsPiSync()) ;
462 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
463 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
464
460 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); 465 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() );
461 proGr->setEnabled( item > 2 ); 466 proGr->setEnabled( item > 2 );
462 if ( item < 3 ) { 467 if ( item < 3 ) {
463 localFileWidget->hide(); 468 localFileWidget->hide();
464 remoteFileWidget->hide(); 469 remoteFileWidget->hide();
465 phoneWidget->hide(); 470 phoneWidget->hide();
466 piWidget->hide(); 471 piWidget->hide();
467 472
468 } else 473 } else
469 kindChanged( prof->getIsLocalFileSync() ); 474 kindChanged( prof->getIsLocalFileSync() );
470} 475}
471 476
472void KSyncPrefsDialog::fillSSH() 477void KSyncPrefsDialog::fillSSH()
473{ 478{
474 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 479 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
475 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 480 mLocalTempFile->setText("/tmp/mycalendar.ics" );
476 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 481 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
477 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 482 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
478 mLocalTempFileAB->setText("/tmp/std.vcf" ); 483 mLocalTempFileAB->setText("/tmp/std.vcf" );
479 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 484 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
480 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 485 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
481 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 486 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
482 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 487 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
483} 488}
484void KSyncPrefsDialog::fillFTP() 489void KSyncPrefsDialog::fillFTP()
485{ 490{
486 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 491 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
487 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 492 mLocalTempFile->setText("/tmp/mycalendar.ics" );
488 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 493 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
489 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 494 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
490 mLocalTempFileAB->setText("/tmp/std.vcf" ); 495 mLocalTempFileAB->setText("/tmp/std.vcf" );
491 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 496 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
492 497
493 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 498 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
494 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 499 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
495 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 500 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
496 501
497} 502}
498void KSyncPrefsDialog::kindChanged( bool b ) 503void KSyncPrefsDialog::kindChanged( bool b )
499{ 504{
505
506 if ( mIsLocal->isChecked () ) {
507 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
508 } else {
509 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
510 }
500 511
501 if ( mIsLocal->isChecked () ) 512 if ( mIsLocal->isChecked () )
502 localFileWidget->show(); 513 localFileWidget->show();
503 else 514 else
504 localFileWidget->hide(); 515 localFileWidget->hide();
505 516
506 if ( mIsNotLocal->isChecked () ) 517 if ( mIsNotLocal->isChecked () )
507 remoteFileWidget->show(); 518 remoteFileWidget->show();
508 else 519 else
509 remoteFileWidget->hide(); 520 remoteFileWidget->hide();
510 521
511 if ( mIsPhone->isChecked () ) { 522 if ( mIsPhone->isChecked () ) {
512 phoneWidget->show(); 523 phoneWidget->show();
513 } 524 }
514 else { 525 else {
515 phoneWidget->hide(); 526 phoneWidget->hide();
516 } 527 }
517 if ( mIsPi->isChecked () ) { 528 if ( mIsPi->isChecked () ) {
518 piWidget->show(); 529 piWidget->show();
519 } 530 }
520 else { 531 else {
521 piWidget->hide(); 532 piWidget->hide();
522 } 533 }
523 534
524} 535}
525void KSyncPrefsDialog::deleteProfile() 536void KSyncPrefsDialog::deleteProfile()
526{ 537{
527 //qDebug("KSyncPrefsDialog::deleteProfile() "); 538 //qDebug("KSyncPrefsDialog::deleteProfile() ");
528 if ( currentSelection >= 0 ) { 539 if ( currentSelection >= 0 ) {
529 if ( currentSelection < 3 ) { 540 if ( currentSelection < 3 ) {
530 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 541 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
531 return; 542 return;
532 } 543 }
533 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 544 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
534 mSyncProfiles.remove( temp ); 545 mSyncProfiles.remove( temp );
535 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 546 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
536 insertProfiles(); 547 insertProfiles();
537 } 548 }
538} 549}
539 550
540void KSyncPrefsDialog::saveProfile() 551void KSyncPrefsDialog::saveProfile()
541{ 552{
542 KSyncProfile* prof; 553 KSyncProfile* prof;
543 if ( currentSelection >= 0 ) { 554 if ( currentSelection >= 0 ) {
544 prof = mSyncProfiles.at(currentSelection) ; 555 prof = mSyncProfiles.at(currentSelection) ;
545 556
546 prof->setRemotePw( mRemotePw->text()); 557 prof->setRemotePw( mRemotePw->text());
547 prof->setRemoteIP( mRemoteIP->text()); 558 prof->setRemoteIP( mRemoteIP->text());
548 prof->setRemotePort( mRemotePort->text()); 559 prof->setRemotePort( mRemotePort->text());
549 560
550 prof->setRemotePwAB( mRemotePwAB->text()); 561 prof->setRemotePwAB( mRemotePwAB->text());
551 prof->setRemoteIPAB( mRemoteIPAB->text()); 562 prof->setRemoteIPAB( mRemoteIPAB->text());
552 prof->setRemotePortAB( mRemotePortAB->text()); 563 prof->setRemotePortAB( mRemotePortAB->text());
553 564
554 prof->setRemotePwPWM( mRemotePwPWM->text()); 565 prof->setRemotePwPWM( mRemotePwPWM->text());
555 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 566 prof->setRemoteIPPWM( mRemoteIPPWM->text());
556 prof->setRemotePortPWM( mRemotePortPWM->text()); 567 prof->setRemotePortPWM( mRemotePortPWM->text());
557 568
558 prof->setPreSyncCommand( mRemotePrecommand->text()); 569 prof->setPreSyncCommand( mRemotePrecommand->text());
559 prof->setPostSyncCommand( mRemotePostcommand->text() ); 570 prof->setPostSyncCommand( mRemotePostcommand->text() );
560 prof->setLocalTempFile( mLocalTempFile->text()); 571 prof->setLocalTempFile( mLocalTempFile->text());
561 prof->setRemoteFileName( mRemoteFile->text() ); 572 prof->setRemoteFileName( mRemoteFile->text() );
562 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 573 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
563 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 574 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
564 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 575 prof->setLocalTempFileAB( mLocalTempFileAB->text());
565 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 576 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
566 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 577 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
567 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 578 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
568 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 579 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
569 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 580 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
570 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 581 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
571 prof->setAskForPreferences( mAskForPreferences->isChecked()); 582 prof->setAskForPreferences( mAskForPreferences->isChecked());
572 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 583 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
573 prof->setWriteBackFile( mWriteBackFile->isChecked()); 584 prof->setWriteBackFile( mWriteBackFile->isChecked());
574 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 585 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
575 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 586 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
576 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 587 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
577 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 588 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
578 prof->setSyncPrefs( syncprefs); 589 prof->setSyncPrefs( syncprefs);
579 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 590 prof->setIsLocalFileSync( mIsLocal->isChecked() );
580 prof->setIsPhoneSync( mIsPhone->isChecked() ); 591 prof->setIsPhoneSync( mIsPhone->isChecked() );
581 prof->setIsPiSync( mIsPi->isChecked() ); 592 prof->setIsPiSync( mIsPi->isChecked() );
593 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
582 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 594 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
583 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 595 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
584 if ( mWriteContactToSIM ) 596 if ( mWriteContactToSIM )
585 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 597 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
586 prof->setPhoneDevice( mPhoneDevice->text() ); 598 prof->setPhoneDevice( mPhoneDevice->text() );
587 prof->setPhoneConnection( mPhoneConnection->text() ); 599 prof->setPhoneConnection( mPhoneConnection->text() );
588 prof->setPhoneModel( mPhoneModel->text() ); 600 prof->setPhoneModel( mPhoneModel->text() );
589 601
590 } 602 }
591 603
592} 604}
593 605
594void KSyncPrefsDialog::insertProfiles() 606void KSyncPrefsDialog::insertProfiles()
595{ 607{
596 int curItem = mProfileBox->currentItem(); 608 int curItem = mProfileBox->currentItem();
597 mProfileBox->blockSignals( true ); 609 mProfileBox->blockSignals( true );
598 mProfileBox->clear(); 610 mProfileBox->clear();
599 mProfileBox->insertStringList (mSyncProfileNames ); 611 mProfileBox->insertStringList (mSyncProfileNames );
600 int item = mSyncProfileNames.count() -1; 612 int item = mSyncProfileNames.count() -1;
601 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 613 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
602 mProfileBox->setCurrentItem( curItem ); 614 mProfileBox->setCurrentItem( curItem );
603 else if ( item >= 0 ) { 615 else if ( item >= 0 ) {
604 mProfileBox->setCurrentItem( item ); 616 mProfileBox->setCurrentItem( item );
605 } 617 }
606 currentSelection = -1; 618 currentSelection = -1;
607 if ( mSyncProfileNames.count() > 0 ) { 619 if ( mSyncProfileNames.count() > 0 ) {
608 //qDebug(" profileChanged( mProfileBox->currentItem() "); 620 //qDebug(" profileChanged( mProfileBox->currentItem() ");
609 profileChanged( mProfileBox->currentItem() ); 621 profileChanged( mProfileBox->currentItem() );
610 currentSelection = mProfileBox->currentItem(); 622 currentSelection = mProfileBox->currentItem();
611 } 623 }
612 mProfileBox->blockSignals( false ); 624 mProfileBox->blockSignals( false );
613} 625}
614 626
615void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 627void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
616{ 628{
617 saveProfile(); 629 saveProfile();
618 mSyncProfiles.append( temp ); 630 mSyncProfiles.append( temp );
619 mSyncProfileNames << temp->getName(); 631 mSyncProfileNames << temp->getName();
620 insertProfiles(); 632 insertProfiles();
621 int last = mProfileBox->count() -1; 633 int last = mProfileBox->count() -1;
622 mProfileBox->blockSignals( true ); 634 mProfileBox->blockSignals( true );
623 mProfileBox->setCurrentItem( last ); 635 mProfileBox->setCurrentItem( last );
624 mProfileBox->blockSignals( false ); 636 mProfileBox->blockSignals( false );
625 profileChanged(last); 637 profileChanged(last);
626} 638}
627void KSyncPrefsDialog::newProfile() 639void KSyncPrefsDialog::newProfile()
628{ 640{
629 addProfile ( new KSyncProfile () ); 641 addProfile ( new KSyncProfile () );
630} 642}
631 643
632void KSyncPrefsDialog::cloneProfile() 644void KSyncPrefsDialog::cloneProfile()
633{ 645{
634 if ( currentSelection >= 0 ) 646 if ( currentSelection >= 0 )
635 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 647 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
636 else 648 else
637 newProfile(); 649 newProfile();
638} 650}
639 651
640void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 652void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
641{ 653{
642 mMyMachineName->setText( name ); 654 mMyMachineName->setText( name );
643 655
644} 656}
645QString KSyncPrefsDialog::getLocalMachineName ( ) 657QString KSyncPrefsDialog::getLocalMachineName ( )
646{ 658{
647 return mMyMachineName->text(); 659 return mMyMachineName->text();
648} 660}
649 661
650QStringList KSyncPrefsDialog::getSyncProfileNames() 662QStringList KSyncPrefsDialog::getSyncProfileNames()
651{ 663{
652 return mSyncProfileNames; 664 return mSyncProfileNames;
653} 665}
654void KSyncPrefsDialog::usrReadConfig() 666void KSyncPrefsDialog::usrReadConfig()
655{ 667{
656 //KConfig *config = KOGlobals::config(); 668 //KConfig *config = KOGlobals::config();
657 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 669 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
658 config.setGroup("General"); 670 config.setGroup("General");
659 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 671 mSyncProfileNames =config.readListEntry("SyncProfileNames");
660 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 672 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
661 int i; 673 int i;
662 KSyncProfile* temp ; 674 KSyncProfile* temp ;
663 mSyncProfiles.clear(); 675 mSyncProfiles.clear();
664 for ( i = 0; i < mSyncProfileNames.count();++i ) { 676 for ( i = 0; i < mSyncProfileNames.count();++i ) {
665 temp = new KSyncProfile (); 677 temp = new KSyncProfile ();
666 temp->setName( mSyncProfileNames[i] ); 678 temp->setName( mSyncProfileNames[i] );
667 temp->readConfig( &config ); 679 temp->readConfig( &config );
668 mSyncProfiles.append( temp ); 680 mSyncProfiles.append( temp );
669 } 681 }
670 insertProfiles(); 682 insertProfiles();
671 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 683 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
672} 684}
673 685
674 686
675void KSyncPrefsDialog::usrWriteConfig() 687void KSyncPrefsDialog::usrWriteConfig()
676{ 688{
677 saveProfile(); 689 saveProfile();
678 if ( currentSelection >= 0 ) 690 if ( currentSelection >= 0 )
679 profileChanged(currentSelection); 691 profileChanged(currentSelection);
680 //KConfig *config = KOGlobals::config(); 692 //KConfig *config = KOGlobals::config();
681 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 693 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
682 KSyncProfile* prof = mSyncProfiles.first(); 694 KSyncProfile* prof = mSyncProfiles.first();
683 QStringList externalSyncProfileNames; 695 QStringList externalSyncProfileNames;
684 externalSyncProfileNames.append("Sharp_DTM");; 696 externalSyncProfileNames.append("Sharp_DTM");;
685 while ( prof ) { 697 while ( prof ) {
686 prof->writeConfig(&config); 698 prof->writeConfig(&config);
687 if ( prof->getIsPhoneSync( ) ) 699 if ( prof->getIsPhoneSync( ) )
688 externalSyncProfileNames.append(prof->getName( ) ); 700 externalSyncProfileNames.append(prof->getName( ) );
689 prof = mSyncProfiles.next(); 701 prof = mSyncProfiles.next();
690 } 702 }
691 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 703 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
692 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 704 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
693 config.setGroup("General"); 705 config.setGroup("General");
694 config.writeEntry("SyncProfileNames",mSyncProfileNames); 706 config.writeEntry("SyncProfileNames",mSyncProfileNames);
695 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 707 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
696 config.writeEntry("LocalMachineName",mMyMachineName->text()); 708 config.writeEntry("LocalMachineName",mMyMachineName->text());
697 config.sync(); 709 config.sync();
698} 710}
699 711
700void KSyncPrefsDialog::helpDevice() 712void KSyncPrefsDialog::helpDevice()
701{ 713{
702 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 714 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
703#ifdef _WIN32_ 715#ifdef _WIN32_
704 hint += "Leave empty for Irda.\n" 716 hint += "Leave empty for Irda.\n"
705 "com1:\n(first serial port)\n" 717 "com1:\n(first serial port)\n"
706 "usb not supported\n" 718 "usb not supported\n"
707 "???\n(bluetooth device address)\n"; 719 "???\n(bluetooth device address)\n";
708 720
709#else 721#else
710 hint += "/dev/ircomm\n(Irda)\n" 722 hint += "/dev/ircomm\n(Irda)\n"
711 "/dev/ttyS0\n(first serial port)\n" 723 "/dev/ttyS0\n(first serial port)\n"
712 "/dev/ttyUSB0\n(first device usb port)\n" 724 "/dev/ttyUSB0\n(first device usb port)\n"
713 "???\n(bluetooth device address)\n"; 725 "???\n(bluetooth device address)\n";
714#endif 726#endif
715 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 727 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
716} 728}
717void KSyncPrefsDialog::helpModel() 729void KSyncPrefsDialog::helpModel()
718{ 730{
719 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); 731 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
720 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 732 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
721 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 733 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
722 734
723} 735}
724void KSyncPrefsDialog::helpConnection() 736void KSyncPrefsDialog::helpConnection()
725{ 737{
726 QString hint = i18n("Insert kind of connection,e.g.:\n"); 738 QString hint = i18n("Insert kind of connection,e.g.:\n");
727 hint += "irda | Nokia FBUS over infrared\n" 739 hint += "irda | Nokia FBUS over infrared\n"
728 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 740 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
729 "irdaobex | set also model as obex\n" 741 "irdaobex | set also model as obex\n"
730 "fbus | Nokia FBUS2 serial\n"; 742 "fbus | Nokia FBUS2 serial\n";
731 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 743 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
732} 744}
diff --git a/libkdepim/ksyncprefsdialog.h b/libkdepim/ksyncprefsdialog.h
index d3f8f4c..c601a58 100644
--- a/libkdepim/ksyncprefsdialog.h
+++ b/libkdepim/ksyncprefsdialog.h
@@ -1,151 +1,153 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 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#ifndef _KSYNCPREFSDIALOG_H 23#ifndef _KSYNCPREFSDIALOG_H
24#define _KSYNCPREFSDIALOG_H 24#define _KSYNCPREFSDIALOG_H
25 25
26 26
27#include <kdialogbase.h> 27#include <kdialogbase.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29 29
30//#include <libkdepim/kprefsdialog.h> 30//#include <libkdepim/kprefsdialog.h>
31 31
32class KColorButton; 32class KColorButton;
33class QSpinBox;; 33class QSpinBox;;
34class QRadioButton; 34class QRadioButton;
35class QCheckBox; 35class QCheckBox;
36class QSlider; 36class QSlider;
37class KURLRequester; 37class KURLRequester;
38class QComboBox; 38class QComboBox;
39class QButtonGroup; 39class QButtonGroup;
40class QLineEdit; 40class QLineEdit;
41class QVBox; 41class QVBox;
42class QStringList; 42class QStringList;
43class KSyncProfile; 43class KSyncProfile;
44 44
45/** Dialog to change the korganizer configuration. 45/** Dialog to change the korganizer configuration.
46 */ 46 */
47class KSyncPrefsDialog : public KDialog 47class KSyncPrefsDialog : public KDialog
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 /** Initialize dialog and pages */ 51 /** Initialize dialog and pages */
52 KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); 52 KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
53 ~KSyncPrefsDialog(); 53 ~KSyncPrefsDialog();
54 void usrReadConfig(); 54 void usrReadConfig();
55 void setLocalMachineName ( const QString& name ); 55 void setLocalMachineName ( const QString& name );
56 QString getLocalMachineName ( ); 56 QString getLocalMachineName ( );
57 57
58 QStringList getSyncProfileNames(); 58 QStringList getSyncProfileNames();
59 59
60 public slots: 60 public slots:
61 protected slots: 61 protected slots:
62 void accept(); 62 void accept();
63 void deleteProfile(); 63 void deleteProfile();
64 void newProfile(); 64 void newProfile();
65 void cloneProfile(); 65 void cloneProfile();
66 void kindChanged(bool); 66 void kindChanged(bool);
67 void fillSSH(); 67 void fillSSH();
68 void fillFTP(); 68 void fillFTP();
69 void textChanged( const QString & ); 69 void textChanged( const QString & );
70 void profileChanged( int ); 70 void profileChanged( int );
71 void chooseFile(); 71 void chooseFile();
72 void chooseFileAB(); 72 void chooseFileAB();
73 void chooseFilePWM(); 73 void chooseFilePWM();
74 void slotOK(); 74 void slotOK();
75 void helpDevice(); 75 void helpDevice();
76 void helpModel(); 76 void helpModel();
77 void helpConnection(); 77 void helpConnection();
78 78
79 protected: 79 protected:
80 void usrWriteConfig(); 80 void usrWriteConfig();
81 81
82 void setupSyncAlgTab(); 82 void setupSyncAlgTab();
83 83
84 private: 84 private:
85 int currentSelection; 85 int currentSelection;
86 QPtrList<KSyncProfile> mSyncProfiles; 86 QPtrList<KSyncProfile> mSyncProfiles;
87 QStringList mSyncProfileNames; 87 QStringList mSyncProfileNames;
88 QLineEdit * mMyMachineName; 88 QLineEdit * mMyMachineName;
89 QComboBox * mProfileBox; 89 QComboBox * mProfileBox;
90 QRadioButton* mIsLocal; 90 QRadioButton* mIsLocal;
91 QRadioButton* mIsNotLocal; 91 QRadioButton* mIsNotLocal;
92 QRadioButton* mIsPhone; 92 QRadioButton* mIsPhone;
93 QRadioButton* mIsPi; 93 QRadioButton* mIsPi;
94 QCheckBox* mIncludeInRing; 94 QCheckBox* mIncludeInRing;
95 QCheckBox* mIncludeInRingAB; 95 QCheckBox* mIncludeInRingAB;
96 QCheckBox* mIncludeInRingPWM; 96 QCheckBox* mIncludeInRingPWM;
97 void addProfile ( KSyncProfile* ); 97 void addProfile ( KSyncProfile* );
98 void insertProfiles(); 98 void insertProfiles();
99 void saveProfile(); 99 void saveProfile();
100 QButtonGroup* proGr; 100 QButtonGroup* proGr;
101 101
102 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; 102 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
103 103
104 104
105 QLineEdit * mRemotePostcommand; 105 QLineEdit * mRemotePostcommand;
106 QLineEdit * mRemotePrecommand; 106 QLineEdit * mRemotePrecommand;
107 QLineEdit * mRemoteFile; 107 QLineEdit * mRemoteFile;
108 QLineEdit * mLocalTempFile; 108 QLineEdit * mLocalTempFile;
109 109
110 QLineEdit * mRemotePostcommandAB; 110 QLineEdit * mRemotePostcommandAB;
111 QLineEdit * mRemotePrecommandAB; 111 QLineEdit * mRemotePrecommandAB;
112 QLineEdit * mRemoteFileAB; 112 QLineEdit * mRemoteFileAB;
113 QLineEdit * mLocalTempFileAB; 113 QLineEdit * mLocalTempFileAB;
114 114
115 QLineEdit * mRemotePostcommandPWM; 115 QLineEdit * mRemotePostcommandPWM;
116 QLineEdit * mRemotePrecommandPWM; 116 QLineEdit * mRemotePrecommandPWM;
117 QLineEdit * mRemoteFilePWM; 117 QLineEdit * mRemoteFilePWM;
118 QLineEdit * mLocalTempFilePWM; 118 QLineEdit * mLocalTempFilePWM;
119 119
120 120
121 QLineEdit * mRemotePw; 121 QLineEdit * mRemotePw;
122 QLineEdit * mRemoteIP; 122 QLineEdit * mRemoteIP;
123 QLineEdit * mRemotePort; 123 QLineEdit * mRemotePort;
124 124
125 QLineEdit * mRemotePwAB; 125 QLineEdit * mRemotePwAB;
126 QLineEdit * mRemoteIPAB; 126 QLineEdit * mRemoteIPAB;
127 QLineEdit * mRemotePortAB; 127 QLineEdit * mRemotePortAB;
128 128
129 QLineEdit * mRemotePwPWM; 129 QLineEdit * mRemotePwPWM;
130 QLineEdit * mRemoteIPPWM; 130 QLineEdit * mRemoteIPPWM;
131 QLineEdit * mRemotePortPWM; 131 QLineEdit * mRemotePortPWM;
132 132
133 QLineEdit * mPhoneDevice; 133 QLineEdit * mPhoneDevice;
134 QLineEdit * mPhoneConnection; 134 QLineEdit * mPhoneConnection;
135 QLineEdit * mPhoneModel; 135 QLineEdit * mPhoneModel;
136 136
137 QWidget* mSetupSyncAlgTab; 137 QWidget* mSetupSyncAlgTab;
138 QVBox* localFileWidget; 138 QVBox* localFileWidget;
139 QVBox* remoteFileWidget; 139 QVBox* remoteFileWidget;
140 QVBox* phoneWidget; 140 QVBox* phoneWidget;
141 QVBox* piWidget; 141 QVBox* piWidget;
142 QCheckBox* mWriteBackFile; 142 QCheckBox* mWriteBackFile;
143 QCheckBox* mWriteBackFuture; 143 QCheckBox* mWriteBackFuture;
144 QSpinBox* mWriteBackFutureWeeks; 144 QSpinBox* mWriteBackFutureWeeks;
145 QCheckBox* mWriteBackExisting; 145 QCheckBox* mWriteBackExisting;
146 QCheckBox* mAskForPreferences; 146 QCheckBox* mAskForPreferences;
147 QCheckBox* mShowSummaryAfterSync; 147 QCheckBox* mShowSummaryAfterSync;
148 QCheckBox* mWriteContactToSIM; 148 QCheckBox* mWriteContactToSIM;
149 QCheckBox* mIsKapiFileL;
150 QCheckBox* mIsKapiFileR;
149}; 151};
150 152
151#endif 153#endif
diff --git a/libkdepim/ksyncprofile.cpp b/libkdepim/ksyncprofile.cpp
index 76dfe00..029b70b 100644
--- a/libkdepim/ksyncprofile.cpp
+++ b/libkdepim/ksyncprofile.cpp
@@ -1,248 +1,252 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include <qcolor.h> 23#include <qcolor.h>
24 24
25#include <kconfig.h> 25#include <kconfig.h>
26#include <kstandarddirs.h> 26#include <kstandarddirs.h>
27#include <kglobal.h> 27#include <kglobal.h>
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include "ksyncprofile.h" 30#include "ksyncprofile.h"
31 31
32 32
33KSyncProfile::KSyncProfile(): QObject () 33KSyncProfile::KSyncProfile(): QObject ()
34{ 34{
35 setDefault(); 35 setDefault();
36} 36}
37KSyncProfile::~KSyncProfile() 37KSyncProfile::~KSyncProfile()
38{ 38{
39 39
40} 40}
41 41
42 42
43KSyncProfile* KSyncProfile::clone() 43KSyncProfile* KSyncProfile::clone()
44{ 44{
45 KSyncProfile* myClone = new KSyncProfile(); 45 KSyncProfile* myClone = new KSyncProfile();
46 myClone->setRemotePw(mRemotePw); 46 myClone->setRemotePw(mRemotePw);
47 myClone->setRemoteIP(mRemoteIP); 47 myClone->setRemoteIP(mRemoteIP);
48 myClone->setRemotePort(mRemotePort); 48 myClone->setRemotePort(mRemotePort);
49 myClone->setRemotePwAB(mRemotePwAB); 49 myClone->setRemotePwAB(mRemotePwAB);
50 myClone->setRemoteIPAB(mRemoteIPAB); 50 myClone->setRemoteIPAB(mRemoteIPAB);
51 myClone->setRemotePortAB(mRemotePortAB); 51 myClone->setRemotePortAB(mRemotePortAB);
52 myClone->setRemotePwPWM(mRemotePwPWM); 52 myClone->setRemotePwPWM(mRemotePwPWM);
53 myClone->setRemoteIPPWM(mRemoteIPPWM); 53 myClone->setRemoteIPPWM(mRemoteIPPWM);
54 myClone->setRemotePortPWM (mRemotePortPWM); 54 myClone->setRemotePortPWM (mRemotePortPWM);
55 myClone->setPreSyncCommand( mPreSyncCommand ); 55 myClone->setPreSyncCommand( mPreSyncCommand );
56 myClone->setPostSyncCommand( mPostSyncCommand ); 56 myClone->setPostSyncCommand( mPostSyncCommand );
57 myClone->setLocalTempFile( mLocalTempFile); 57 myClone->setLocalTempFile( mLocalTempFile);
58 myClone->setRemoteFileName( mRemoteFileName ); 58 myClone->setRemoteFileName( mRemoteFileName );
59 myClone->setPreSyncCommandAB( mPreSyncCommandAB ); 59 myClone->setPreSyncCommandAB( mPreSyncCommandAB );
60 myClone->setPostSyncCommandAB( mPostSyncCommandAB ); 60 myClone->setPostSyncCommandAB( mPostSyncCommandAB );
61 myClone->setLocalTempFileAB( mLocalTempFileAB); 61 myClone->setLocalTempFileAB( mLocalTempFileAB);
62 myClone->setRemoteFileNameAB( mRemoteFileNameAB ); 62 myClone->setRemoteFileNameAB( mRemoteFileNameAB );
63 myClone->setPreSyncCommandPWM( mPreSyncCommandPWM ); 63 myClone->setPreSyncCommandPWM( mPreSyncCommandPWM );
64 myClone->setPostSyncCommandPWM( mPostSyncCommandPWM ); 64 myClone->setPostSyncCommandPWM( mPostSyncCommandPWM );
65 myClone->setLocalTempFilePWM( mLocalTempFilePWM); 65 myClone->setLocalTempFilePWM( mLocalTempFilePWM);
66 myClone->setRemoteFileNamePWM( mRemoteFileNamePWM ); 66 myClone->setRemoteFileNamePWM( mRemoteFileNamePWM );
67 myClone->setShowSummaryAfterSync( mShowSummaryAfterSync ); 67 myClone->setShowSummaryAfterSync( mShowSummaryAfterSync );
68 myClone->setAskForPreferences( mAskForPreferences); 68 myClone->setAskForPreferences( mAskForPreferences);
69 myClone->setWriteBackExisting(mWriteBackExisting ); 69 myClone->setWriteBackExisting(mWriteBackExisting );
70 myClone->setWriteBackFile( mWriteBackFile); 70 myClone->setWriteBackFile( mWriteBackFile);
71 myClone->setWriteBackFuture( mWriteBackFuture ); 71 myClone->setWriteBackFuture( mWriteBackFuture );
72 myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks ); 72 myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks );
73 myClone->setIncludeInRingSync( mIncludeInRingSync ); 73 myClone->setIncludeInRingSync( mIncludeInRingSync );
74 myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB ); 74 myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB );
75 myClone->setIncludeInRingSyncPWM( mIncludeInRingSyncPWM ); 75 myClone->setIncludeInRingSyncPWM( mIncludeInRingSyncPWM );
76 myClone->setSyncPrefs( mSyncPrefs); 76 myClone->setSyncPrefs( mSyncPrefs);
77 myClone->setIsLocalFileSync( mIsLocalFileSync ); 77 myClone->setIsLocalFileSync( mIsLocalFileSync );
78 myClone->setIsPhoneSync( mIsPhoneSync ); 78 myClone->setIsPhoneSync( mIsPhoneSync );
79 myClone->setIsKapiFile( mIsKapiFile );
79 myClone->setIsPiSync( mIsPiSync ); 80 myClone->setIsPiSync( mIsPiSync );
80 myClone->setWriteContactToSIM( mWriteContactToSIM ); 81 myClone->setWriteContactToSIM( mWriteContactToSIM );
81 myClone->setName( "noName" ); 82 myClone->setName( "noName" );
82 //myClone->setIdentifier( "noID" ); 83 //myClone->setIdentifier( "noID" );
83 return myClone; 84 return myClone;
84} 85}
85 86
86 87
87void KSyncProfile::setDefault() 88void KSyncProfile::setDefault()
88{ 89{
89 mPreSyncCommand = i18n("command for downloading remote file to local device"); 90 mPreSyncCommand = i18n("command for downloading remote file to local device");
90 mPostSyncCommand = i18n("command for uploading local temp file to remote device"); 91 mPostSyncCommand = i18n("command for uploading local temp file to remote device");
91 mLocalTempFile = "/tmp/mycalendar.ics"; 92 mLocalTempFile = "/tmp/mycalendar.ics";
92 mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics"; 93 mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics";
93 mPreSyncCommandAB = i18n("command for downloading remote file to local device"); 94 mPreSyncCommandAB = i18n("command for downloading remote file to local device");
94 mPostSyncCommandAB = i18n("command for uploading local temp file to remote device"); 95 mPostSyncCommandAB = i18n("command for uploading local temp file to remote device");
95 mLocalTempFileAB = "/tmp/std.vcf"; 96 mLocalTempFileAB = "/tmp/std.vcf";
96 mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf"; 97 mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf";
97 mPreSyncCommandPWM = i18n("command for downloading remote file to local device"); 98 mPreSyncCommandPWM = i18n("command for downloading remote file to local device");
98 mPostSyncCommandPWM = i18n("command for uploading local temp file to remote device"); 99 mPostSyncCommandPWM = i18n("command for uploading local temp file to remote device");
99 mLocalTempFilePWM = "/tmp/passwords.pwm"; 100 mLocalTempFilePWM = "/tmp/passwords.pwm";
100 mRemoteFileNamePWM = "/home/polo/kdepim/apps/pwmanager/localfile.pwm"; 101 mRemoteFileNamePWM = "/home/polo/kdepim/apps/pwmanager/localfile.pwm";
101 102
102 mRemotePw = "abc"; 103 mRemotePw = "abc";
103 mRemoteIP = "192.168.0.99"; 104 mRemoteIP = "192.168.0.99";
104 mRemotePort = "9197"; 105 mRemotePort = "9197";
105 106
106 mRemotePwAB = "abc"; 107 mRemotePwAB = "abc";
107 mRemoteIPAB = "192.168.0.99"; 108 mRemoteIPAB = "192.168.0.99";
108 mRemotePortAB = "9198"; 109 mRemotePortAB = "9198";
109 110
110 mRemotePwPWM = "abc"; 111 mRemotePwPWM = "abc";
111 mRemoteIPPWM = "192.168.0.99"; 112 mRemoteIPPWM = "192.168.0.99";
112 mRemotePortPWM = "9199"; 113 mRemotePortPWM = "9199";
113 114
114 mShowSummaryAfterSync = true; 115 mShowSummaryAfterSync = true;
115 mAskForPreferences = true; 116 mAskForPreferences = true;
116 mWriteBackExisting = false; 117 mWriteBackExisting = false;
117 mWriteBackFuture = false; 118 mWriteBackFuture = false;
118 mWriteBackFutureWeeks = 12; 119 mWriteBackFutureWeeks = 12;
119 mWriteBackFile = true; 120 mWriteBackFile = true;
120 mIncludeInRingSync = false; 121 mIncludeInRingSync = false;
121 mIncludeInRingSyncAB = false; 122 mIncludeInRingSyncAB = false;
122 mIncludeInRingSyncPWM = false; 123 mIncludeInRingSyncPWM = false;
123 mSyncPrefs = SYNC_PREF_ASK; 124 mSyncPrefs = SYNC_PREF_ASK;
124 mIsLocalFileSync = true; 125 mIsLocalFileSync = true;
125 mName = "noName"; 126 mName = "noName";
126 mIsPhoneSync = false; 127 mIsPhoneSync = false;
127 mIsPiSync = false; 128 mIsPiSync = false;
129 mIsKapiFile = false;
128 mWriteContactToSIM = false; 130 mWriteContactToSIM = false;
129 mPhoneDevice = "/dev/ircomm"; 131 mPhoneDevice = "/dev/ircomm";
130 mPhoneConnection = "irda"; 132 mPhoneConnection = "irda";
131 mPhoneModel = "6310i"; 133 mPhoneModel = "6310i";
132} 134}
133void KSyncProfile::readConfig(KConfig *config ) 135void KSyncProfile::readConfig(KConfig *config )
134{ 136{
135 if (config) 137 if (config)
136 { 138 {
137 139
138 config->setGroup( mName ); 140 config->setGroup( mName );
139 141
140 mName = config->readEntry( "Name", mName ); 142 mName = config->readEntry( "Name", mName );
141 143
142 mRemotePw = config->readEntry( "RemotePw",mRemotePw ); 144 mRemotePw = config->readEntry( "RemotePw",mRemotePw );
143 mRemoteIP = config->readEntry( "RemoteIP",mRemoteIP ); 145 mRemoteIP = config->readEntry( "RemoteIP",mRemoteIP );
144 mRemotePort = config->readEntry( "RemotePort", mRemotePort ); 146 mRemotePort = config->readEntry( "RemotePort", mRemotePort );
145 mRemotePwAB = config->readEntry( "RemotePwAB", mRemotePwAB ); 147 mRemotePwAB = config->readEntry( "RemotePwAB", mRemotePwAB );
146 mRemoteIPAB = config->readEntry( "RemoteIPAB", mRemoteIPAB ); 148 mRemoteIPAB = config->readEntry( "RemoteIPAB", mRemoteIPAB );
147 mRemotePortAB = config->readEntry( "RemotePortAB", mRemotePortAB ); 149 mRemotePortAB = config->readEntry( "RemotePortAB", mRemotePortAB );
148 mRemotePwPWM = config->readEntry( "RemotePwPWM", mRemotePwPWM ); 150 mRemotePwPWM = config->readEntry( "RemotePwPWM", mRemotePwPWM );
149 mRemoteIPPWM = config->readEntry( "RemoteIPPWM", mRemoteIPPWM ); 151 mRemoteIPPWM = config->readEntry( "RemoteIPPWM", mRemoteIPPWM );
150 mRemotePortPWM = config->readEntry( "RemotePortPWM", mRemotePortPWM ); 152 mRemotePortPWM = config->readEntry( "RemotePortPWM", mRemotePortPWM );
151 153
152 mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand ); 154 mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand );
153 mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand ); 155 mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand );
154 mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile ); 156 mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile );
155 mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName ); 157 mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName );
156 158
157 mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB ); 159 mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB );
158 mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB ); 160 mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB );
159 mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB ); 161 mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB );
160 mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB ); 162 mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB );
161 163
162 mPreSyncCommandPWM = config->readEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); 164 mPreSyncCommandPWM = config->readEntry( "PreSyncCommandPWM",mPreSyncCommandPWM );
163 mPostSyncCommandPWM = config->readEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); 165 mPostSyncCommandPWM = config->readEntry( "PostSyncCommandPWM", mPostSyncCommandPWM );
164 mLocalTempFilePWM = config->readEntry( "LocalTempFilePWM", mLocalTempFilePWM ); 166 mLocalTempFilePWM = config->readEntry( "LocalTempFilePWM", mLocalTempFilePWM );
165 mRemoteFileNamePWM = config->readEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); 167 mRemoteFileNamePWM = config->readEntry( "RemoteFileNamePWM", mRemoteFileNamePWM );
166 168
167 mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice ); 169 mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice );
168 mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection ); 170 mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection );
169 mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel ); 171 mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel );
170 172
171 mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync ); 173 mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync );
172 mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); 174 mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB );
173 mIncludeInRingSyncPWM = config->readBoolEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); 175 mIncludeInRingSyncPWM = config->readBoolEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM );
174 mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); 176 mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync );
175 mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences ); 177 mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences );
176 mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting ); 178 mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting );
177 mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture ); 179 mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture );
178 mWriteBackFile = config->readBoolEntry( "WriteBackFile",mWriteBackFile ); 180 mWriteBackFile = config->readBoolEntry( "WriteBackFile",mWriteBackFile );
179 mWriteContactToSIM = config->readBoolEntry( "WriteContactToSIM",mWriteContactToSIM ); 181 mWriteContactToSIM = config->readBoolEntry( "WriteContactToSIM",mWriteContactToSIM );
180 mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs ); 182 mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs );
181 mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks ); 183 mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks );
182 mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync ); 184 mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync );
183 mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync ); 185 mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync );
184 mIsPiSync= config->readBoolEntry( "IsPiSync", mIsPiSync ); 186 mIsPiSync= config->readBoolEntry( "IsPiSync", mIsPiSync );
187 mIsKapiFile = config->readBoolEntry( "IsKapiFile", mIsKapiFile );
185 } 188 }
186 else 189 else
187 { 190 {
188 setDefault(); 191 setDefault();
189 } 192 }
190} 193}
191 194
192void KSyncProfile::deleteConfig(KConfig *config ) 195void KSyncProfile::deleteConfig(KConfig *config )
193{ 196{
194 config->deleteGroup( mName ); 197 config->deleteGroup( mName );
195} 198}
196 199
197void KSyncProfile::writeConfig( KConfig * config ) 200void KSyncProfile::writeConfig( KConfig * config )
198{ 201{
199 config->setGroup(mName); 202 config->setGroup(mName);
200 203
201 config->writeEntry( "RemotePw", mRemotePw); 204 config->writeEntry( "RemotePw", mRemotePw);
202 config->writeEntry( "RemoteIP", mRemoteIP); 205 config->writeEntry( "RemoteIP", mRemoteIP);
203 config->writeEntry( "RemotePort", mRemotePort); 206 config->writeEntry( "RemotePort", mRemotePort);
204 207
205 config->writeEntry( "RemotePwAB", mRemotePwAB); 208 config->writeEntry( "RemotePwAB", mRemotePwAB);
206 config->writeEntry( "RemoteIPAB", mRemoteIPAB); 209 config->writeEntry( "RemoteIPAB", mRemoteIPAB);
207 config->writeEntry( "RemotePortAB", mRemotePortAB); 210 config->writeEntry( "RemotePortAB", mRemotePortAB);
208 211
209 config->writeEntry( "RemotePwPWM", mRemotePwPWM); 212 config->writeEntry( "RemotePwPWM", mRemotePwPWM);
210 config->writeEntry( "RemoteIPPWM", mRemoteIPPWM); 213 config->writeEntry( "RemoteIPPWM", mRemoteIPPWM);
211 config->writeEntry( "RemotePortPWM", mRemotePortPWM); 214 config->writeEntry( "RemotePortPWM", mRemotePortPWM);
212 215
213 config->writeEntry( "Name", mName ); 216 config->writeEntry( "Name", mName );
214 config->writeEntry( "PreSyncCommand",mPreSyncCommand ); 217 config->writeEntry( "PreSyncCommand",mPreSyncCommand );
215 config->writeEntry( "PostSyncCommand", mPostSyncCommand ); 218 config->writeEntry( "PostSyncCommand", mPostSyncCommand );
216 config->writeEntry( "LocalTempFile", mLocalTempFile ); 219 config->writeEntry( "LocalTempFile", mLocalTempFile );
217 config->writeEntry( "RemoteFileName", mRemoteFileName ); 220 config->writeEntry( "RemoteFileName", mRemoteFileName );
218 221
219 config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB ); 222 config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB );
220 config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB ); 223 config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB );
221 config->writeEntry( "LocalTempFileAB", mLocalTempFileAB ); 224 config->writeEntry( "LocalTempFileAB", mLocalTempFileAB );
222 config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB ); 225 config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB );
223 226
224 config->writeEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); 227 config->writeEntry( "PreSyncCommandPWM",mPreSyncCommandPWM );
225 config->writeEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); 228 config->writeEntry( "PostSyncCommandPWM", mPostSyncCommandPWM );
226 config->writeEntry( "LocalTempFilePWM", mLocalTempFilePWM ); 229 config->writeEntry( "LocalTempFilePWM", mLocalTempFilePWM );
227 config->writeEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); 230 config->writeEntry( "RemoteFileNamePWM", mRemoteFileNamePWM );
228 231
229 config->writeEntry( "PhoneDevice", mPhoneDevice ); 232 config->writeEntry( "PhoneDevice", mPhoneDevice );
230 config->writeEntry( "PhoneConnection", mPhoneConnection ); 233 config->writeEntry( "PhoneConnection", mPhoneConnection );
231 config->writeEntry( "PhoneModel", mPhoneModel ); 234 config->writeEntry( "PhoneModel", mPhoneModel );
232 235
233 config->writeEntry( "IncludeInRingSync",mIncludeInRingSync ); 236 config->writeEntry( "IncludeInRingSync",mIncludeInRingSync );
234 config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); 237 config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB );
235 config->writeEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); 238 config->writeEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM );
236 config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); 239 config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync );
237 config->writeEntry( "AskForPreferences",mAskForPreferences ); 240 config->writeEntry( "AskForPreferences",mAskForPreferences );
238 config->writeEntry( "WriteBackExisting",mWriteBackExisting ); 241 config->writeEntry( "WriteBackExisting",mWriteBackExisting );
239 config->writeEntry( "WriteBackFuture",mWriteBackFuture ); 242 config->writeEntry( "WriteBackFuture",mWriteBackFuture );
240 config->writeEntry( "WriteBackFile",mWriteBackFile ); 243 config->writeEntry( "WriteBackFile",mWriteBackFile );
241 config->writeEntry( "WriteContactToSIM",mWriteContactToSIM ); 244 config->writeEntry( "WriteContactToSIM",mWriteContactToSIM );
242 config->writeEntry( "SyncPrefs", mSyncPrefs ); 245 config->writeEntry( "SyncPrefs", mSyncPrefs );
243 config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks); 246 config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks);
244 config->writeEntry( "IsLocalFileSync", mIsLocalFileSync ); 247 config->writeEntry( "IsLocalFileSync", mIsLocalFileSync );
245 config->writeEntry( "IsPhoneSync", mIsPhoneSync ); 248 config->writeEntry( "IsPhoneSync", mIsPhoneSync );
246 config->writeEntry( "IsPiSync", mIsPiSync ); 249 config->writeEntry( "IsPiSync", mIsPiSync );
250 config->writeEntry( "IsKapiFile", mIsKapiFile );
247} 251}
248 252
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h
index 6a68bd7..0a59111 100644
--- a/libkdepim/ksyncprofile.h
+++ b/libkdepim/ksyncprofile.h
@@ -1,185 +1,188 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef _KSYNCPROFILE_H 20#ifndef _KSYNCPROFILE_H
21#define _KSYNCPROFILE_H 21#define _KSYNCPROFILE_H
22 22
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qfont.h> 25#include <qfont.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qobject.h> 27#include <qobject.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <libkcal/syncdefines.h> 30#include <libkcal/syncdefines.h>
31 31
32 32
33 33
34class KConfig; 34class KConfig;
35 35
36 36
37class KSyncProfile : public QObject { 37class KSyncProfile : public QObject {
38 public: 38 public:
39 KSyncProfile(); 39 KSyncProfile();
40 ~KSyncProfile() ; 40 ~KSyncProfile() ;
41 41
42 KSyncProfile* clone(); 42 KSyncProfile* clone();
43 void setDefault(); 43 void setDefault();
44 void readConfig(KConfig *); 44 void readConfig(KConfig *);
45 void writeConfig(KConfig *); 45 void writeConfig(KConfig *);
46 void deleteConfig(KConfig *); 46 void deleteConfig(KConfig *);
47 47
48 void setRemotePw( const QString& n ) {mRemotePw = n;} 48 void setRemotePw( const QString& n ) {mRemotePw = n;}
49 QString getRemotePw( ) { return mRemotePw; } 49 QString getRemotePw( ) { return mRemotePw; }
50 void setRemotePwAB( const QString& n ) {mRemotePwAB = n;} 50 void setRemotePwAB( const QString& n ) {mRemotePwAB = n;}
51 QString getRemotePwAB( ) { return mRemotePwAB; } 51 QString getRemotePwAB( ) { return mRemotePwAB; }
52 void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;} 52 void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;}
53 QString getRemotePwPWM( ) { return mRemotePwPWM; } 53 QString getRemotePwPWM( ) { return mRemotePwPWM; }
54 54
55 void setRemoteIP( const QString& n ) {mRemoteIP = n;} 55 void setRemoteIP( const QString& n ) {mRemoteIP = n;}
56 QString getRemoteIP( ) { return mRemoteIP; } 56 QString getRemoteIP( ) { return mRemoteIP; }
57 void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;} 57 void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;}
58 QString getRemoteIPAB( ) { return mRemoteIPAB; } 58 QString getRemoteIPAB( ) { return mRemoteIPAB; }
59 void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;} 59 void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;}
60 QString getRemoteIPPWM( ) { return mRemoteIPPWM; } 60 QString getRemoteIPPWM( ) { return mRemoteIPPWM; }
61 61
62 void setRemotePort( const QString& n ) {mRemotePort = n;} 62 void setRemotePort( const QString& n ) {mRemotePort = n;}
63 QString getRemotePort( ) { return mRemotePort; } 63 QString getRemotePort( ) { return mRemotePort; }
64 void setRemotePortAB( const QString& n ) {mRemotePortAB = n;} 64 void setRemotePortAB( const QString& n ) {mRemotePortAB = n;}
65 QString getRemotePortAB( ) { return mRemotePortAB; } 65 QString getRemotePortAB( ) { return mRemotePortAB; }
66 void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;} 66 void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;}
67 QString getRemotePortPWM( ) { return mRemotePortPWM; } 67 QString getRemotePortPWM( ) { return mRemotePortPWM; }
68 68
69 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} 69 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;}
70 QString getPreSyncCommand( ) { return mPreSyncCommand; } 70 QString getPreSyncCommand( ) { return mPreSyncCommand; }
71 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} 71 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;}
72 QString getPostSyncCommand( ) { return mPostSyncCommand;} 72 QString getPostSyncCommand( ) { return mPostSyncCommand;}
73 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} 73 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;}
74 QString getLocalTempFile( ) { return mLocalTempFile;} 74 QString getLocalTempFile( ) { return mLocalTempFile;}
75 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} 75 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;}
76 QString getRemoteFileName( ) { return mRemoteFileName;} 76 QString getRemoteFileName( ) { return mRemoteFileName;}
77 77
78 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;} 78 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;}
79 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; } 79 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; }
80 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;} 80 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;}
81 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;} 81 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;}
82 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;} 82 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;}
83 QString getLocalTempFileAB( ) { return mLocalTempFileAB;} 83 QString getLocalTempFileAB( ) { return mLocalTempFileAB;}
84 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;} 84 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;}
85 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;} 85 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;}
86 86
87 void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;} 87 void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;}
88 QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; } 88 QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; }
89 void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;} 89 void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;}
90 QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;} 90 QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;}
91 void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;} 91 void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;}
92 QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;} 92 QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;}
93 void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;} 93 void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;}
94 QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;} 94 QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;}
95 95
96 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;} 96 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;}
97 QString getPhoneDevice( ) { return mPhoneDevice;} 97 QString getPhoneDevice( ) { return mPhoneDevice;}
98 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;} 98 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;}
99 QString getPhoneConnection( ) { return mPhoneConnection;} 99 QString getPhoneConnection( ) { return mPhoneConnection;}
100 void setPhoneModel( const QString& n ) { mPhoneModel = n;} 100 void setPhoneModel( const QString& n ) { mPhoneModel = n;}
101 QString getPhoneModel( ) { return mPhoneModel;} 101 QString getPhoneModel( ) { return mPhoneModel;}
102 /* 102 /*
103 void set( const QString& n ) { = n;} 103 void set( const QString& n ) { = n;}
104 QString get( ) { return ;} 104 QString get( ) { return ;}
105 */ 105 */
106 106
107 void setName( const QString& n ) {mName = n;} 107 void setName( const QString& n ) {mName = n;}
108 QString getName( ) { return mName;} 108 QString getName( ) { return mName;}
109 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} 109 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;}
110 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} 110 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;}
111 void setAskForPreferences( bool b ) { mAskForPreferences= b;} 111 void setAskForPreferences( bool b ) { mAskForPreferences= b;}
112 bool getAskForPreferences( ) { return mAskForPreferences;} 112 bool getAskForPreferences( ) { return mAskForPreferences;}
113 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;} 113 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;}
114 bool getWriteBackExisting( ) { return mWriteBackExisting;} 114 bool getWriteBackExisting( ) { return mWriteBackExisting;}
115 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;} 115 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;}
116 bool getWriteBackFuture( ) { return mWriteBackFuture;} 116 bool getWriteBackFuture( ) { return mWriteBackFuture;}
117 void setWriteBackFile( bool b ) { mWriteBackFile= b;} 117 void setWriteBackFile( bool b ) { mWriteBackFile= b;}
118 bool getWriteBackFile( ) { return mWriteBackFile;} 118 bool getWriteBackFile( ) { return mWriteBackFile;}
119 void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;} 119 void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;}
120 bool getWriteContactToSIM( ) { return mWriteContactToSIM;} 120 bool getWriteContactToSIM( ) { return mWriteContactToSIM;}
121 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;} 121 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;}
122 bool getIncludeInRingSync( ) { return mIncludeInRingSync;} 122 bool getIncludeInRingSync( ) { return mIncludeInRingSync;}
123 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;} 123 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;}
124 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;} 124 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;}
125 void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;} 125 void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;}
126 bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;} 126 bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;}
127 void setSyncPrefs( int n ) { mSyncPrefs= n;} 127 void setSyncPrefs( int n ) { mSyncPrefs= n;}
128 int getSyncPrefs( ) { return mSyncPrefs;} 128 int getSyncPrefs( ) { return mSyncPrefs;}
129 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;} 129 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;}
130 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;} 130 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;}
131 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;} 131 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;}
132 bool getIsLocalFileSync( ) { return mIsLocalFileSync;} 132 bool getIsLocalFileSync( ) { return mIsLocalFileSync;}
133 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;} 133 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;}
134 bool getIsPhoneSync( ) { return mIsPhoneSync;} 134 bool getIsPhoneSync( ) { return mIsPhoneSync;}
135 void setIsPiSync( bool b ) { mIsPiSync= b;} 135 void setIsPiSync( bool b ) { mIsPiSync= b;}
136 bool getIsPiSync( ) { return mIsPiSync;} 136 bool getIsPiSync( ) { return mIsPiSync;}
137 void setIsKapiFile( bool b ) { mIsKapiFile= b;}
138 bool getIsKapiFile( ) { return mIsKapiFile;}
137 private: 139 private:
138 QString mName; 140 QString mName;
139 QString mPreSyncCommand; 141 QString mPreSyncCommand;
140 QString mPostSyncCommand; 142 QString mPostSyncCommand;
141 QString mLocalTempFile; 143 QString mLocalTempFile;
142 QString mRemoteFileName; 144 QString mRemoteFileName;
143 QString mPreSyncCommandAB; 145 QString mPreSyncCommandAB;
144 QString mPostSyncCommandAB; 146 QString mPostSyncCommandAB;
145 QString mLocalTempFileAB; 147 QString mLocalTempFileAB;
146 QString mRemoteFileNameAB; 148 QString mRemoteFileNameAB;
147 QString mPreSyncCommandPWM; 149 QString mPreSyncCommandPWM;
148 QString mPostSyncCommandPWM; 150 QString mPostSyncCommandPWM;
149 QString mLocalTempFilePWM; 151 QString mLocalTempFilePWM;
150 QString mRemoteFileNamePWM; 152 QString mRemoteFileNamePWM;
151 153
152 QString mRemotePw; 154 QString mRemotePw;
153 QString mRemoteIP; 155 QString mRemoteIP;
154 QString mRemotePort; 156 QString mRemotePort;
155 157
156 QString mRemotePwAB; 158 QString mRemotePwAB;
157 QString mRemoteIPAB; 159 QString mRemoteIPAB;
158 QString mRemotePortAB; 160 QString mRemotePortAB;
159 161
160 QString mRemotePwPWM; 162 QString mRemotePwPWM;
161 QString mRemoteIPPWM; 163 QString mRemoteIPPWM;
162 QString mRemotePortPWM; 164 QString mRemotePortPWM;
163 165
164 QString mPhoneDevice; 166 QString mPhoneDevice;
165 QString mPhoneConnection; 167 QString mPhoneConnection;
166 QString mPhoneModel; 168 QString mPhoneModel;
167 169
168 bool mIncludeInRingSync; 170 bool mIncludeInRingSync;
169 bool mIncludeInRingSyncAB; 171 bool mIncludeInRingSyncAB;
170 bool mIncludeInRingSyncPWM; 172 bool mIncludeInRingSyncPWM;
171 int mSyncPrefs; 173 int mSyncPrefs;
172 bool mWriteBackFile; 174 bool mWriteBackFile;
173 bool mWriteBackExisting; 175 bool mWriteBackExisting;
174 bool mWriteBackFuture; 176 bool mWriteBackFuture;
175 int mWriteBackFutureWeeks; 177 int mWriteBackFutureWeeks;
176 bool mAskForPreferences; 178 bool mAskForPreferences;
177 bool mShowSummaryAfterSync; 179 bool mShowSummaryAfterSync;
178 bool mIsLocalFileSync; 180 bool mIsLocalFileSync;
179 bool mIsPhoneSync; 181 bool mIsPhoneSync;
180 bool mWriteContactToSIM; 182 bool mWriteContactToSIM;
181 183
182 bool mIsPiSync; 184 bool mIsPiSync;
185 bool mIsKapiFile;
183}; 186};
184 187
185#endif 188#endif