summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kde2file/abdump/main.cpp5
-rw-r--r--libkdepim/ksyncmanager.cpp14
2 files changed, 16 insertions, 3 deletions
diff --git a/kde2file/abdump/main.cpp b/kde2file/abdump/main.cpp
index 9ad78e5..b359cfe 100644
--- a/kde2file/abdump/main.cpp
+++ b/kde2file/abdump/main.cpp
@@ -91,103 +91,106 @@ int main( int argc, char *argv[] )
91 qDebug("read "); 91 qDebug("read ");
92 } 92 }
93 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 93 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
94 94
95 KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self(); 95 KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self();
96 standardAddressBook->setAutomaticSave( false ); 96 standardAddressBook->setAutomaticSave( false );
97 qDebug("************************************* "); 97 qDebug("************************************* ");
98 qDebug("***************kdeABdump************* "); 98 qDebug("***************kdeABdump************* ");
99 qDebug("************************************* "); 99 qDebug("************************************* ");
100 if ( !read ) { 100 if ( !read ) {
101 KABC::AddressBook::Iterator it; 101 KABC::AddressBook::Iterator it;
102 KABC::VCardConverter converter; 102 KABC::VCardConverter converter;
103 QString datastream; 103 QString datastream;
104 for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) { 104 for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) {
105 if ( (*it).isEmpty() || ! (*it).resource() ) 105 if ( (*it).isEmpty() || ! (*it).resource() )
106 continue; 106 continue;
107 KABC::Addressee a = ( *it ); 107 KABC::Addressee a = ( *it );
108 QString vcard = converter.createVCard( a ); 108 QString vcard = converter.createVCard( a );
109 vcard += QString("\r\n"); 109 vcard += QString("\r\n");
110 datastream += vcard; 110 datastream += vcard;
111 } 111 }
112 QFile outFile(fileName); 112 QFile outFile(fileName);
113 if ( outFile.open(IO_WriteOnly) ) { 113 if ( outFile.open(IO_WriteOnly) ) {
114 QTextStream t( &outFile ); // use a text stream 114 QTextStream t( &outFile ); // use a text stream
115 t.setEncoding( QTextStream::UnicodeUTF8 ); 115 t.setEncoding( QTextStream::UnicodeUTF8 );
116 t <<datastream; 116 t <<datastream;
117 t << "\r\n\r\n"; 117 t << "\r\n\r\n";
118 outFile.close(); 118 outFile.close();
119 } 119 }
120 } else { 120 } else {
121 //Addressee::List aList;//parseVCards( const QString& vcard ); 121 //Addressee::List aList;//parseVCards( const QString& vcard );
122 KABC::Addressee::List list; 122 KABC::Addressee::List list;
123 int added = 0, changedC = 0, deleted = 0; 123 int added = 0, changedC = 0, deleted = 0;
124 QFile file( fileName ); 124 QFile file( fileName );
125 if ( file.open( IO_ReadOnly ) ) { 125 if ( file.open( IO_ReadOnly ) ) {
126 QTextStream t( &file ); // use a text stream 126 QTextStream t( &file ); // use a text stream
127 t.setEncoding( QTextStream::UnicodeUTF8 ); 127 t.setEncoding( QTextStream::UnicodeUTF8 );
128 QString data; 128 QString data;
129 data = t.read(); 129 data = t.read();
130 file.close(); 130 file.close();
131 KABC::VCardConverter converter; 131 KABC::VCardConverter converter;
132 list = converter.parseVCards( data ); 132 list = converter.parseVCards( data );
133 qDebug("kdeABdump::file has %d entries", list.count()); 133 qDebug("kdeABdump::file has %d entries", list.count());
134 134
135 KABC::Addressee::List::Iterator it; 135 KABC::Addressee::List::Iterator it;
136 for ( it = list.begin();it != list.end();++it) { 136 for ( it = list.begin();it != list.end();++it) {
137 (*it).setChanged( true ); 137 (*it).setChanged( true );
138 bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); 138 bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed");
139 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 139 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
140 //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); 140 //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1());
141 if ( changed ) { 141 if ( changed ) {
142 //qDebug("changed Addressee found! "); 142 //qDebug("changed Addressee found! ");
143 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); 143 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() );
144 if ( ! std.isEmpty() ) 144 if ( ! std.isEmpty() )
145 (*it).setResource(std.resource()); 145 (*it).setResource(std.resource());
146 standardAddressBook->insertAddressee( (*it) ); 146 standardAddressBook->insertAddressee( (*it) );
147 ++changedC; 147 ++changedC;
148 } else { 148 } else {
149 //maybe added? 149 //maybe added?
150 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); 150 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() );
151 if ( std.isEmpty() ) { 151 if ( std.isEmpty() ) {
152 standardAddressBook->insertAddressee( (*it) ); 152 standardAddressBook->insertAddressee( (*it) );
153 ++added; 153 ++added;
154 } 154 }
155 } 155 }
156 } 156 }
157 KABC::AddressBook::Iterator itA = standardAddressBook->begin(); 157 KABC::AddressBook::Iterator itA = standardAddressBook->begin();
158 KABC::AddressBook::Iterator it2 ; 158 KABC::AddressBook::Iterator it2 ;
159 while ( itA != standardAddressBook->end() ) { 159 while ( itA != standardAddressBook->end() ) {
160 bool found = false; 160 bool found = false;
161 KABC::Addressee::List::Iterator itL; 161 KABC::Addressee::List::Iterator itL;
162 for ( itL = list.begin();itL != list.end();++itL) { 162 for ( itL = list.begin();itL != list.end();++itL) {
163 if ( (*itL).uid() == (*itA).uid() ) { 163 if ( (*itL).uid() == (*itA).uid() ) {
164 found = true; 164 found = true;
165 break; 165 break;
166 } 166 }
167 } 167 }
168 if ( !found ) { 168 if ( !found ) {
169 it2 = itA; 169 it2 = itA;
170 ++itA; 170 ++itA;
171 standardAddressBook->removeAddressee( it2 ); 171 standardAddressBook->removeAddressee( it2 );
172 ++deleted; 172 ++deleted;
173 } else { 173 } else {
174 ++itA; 174 ++itA;
175 } 175 }
176 } 176 }
177 177
178 //standardAddressBook->saveAll(); 178 //standardAddressBook->saveAll();
179 standardAddressBook->setAutomaticSave( true ); 179 standardAddressBook->setAutomaticSave( true );
180 qDebug("************************************* "); 180 qDebug("************************************* ");
181 qDebug("*************kdeABdump*************** "); 181 qDebug("*************kdeABdump*************** ");
182 qDebug("************************************* "); 182 qDebug("************************************* ");
183 qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1()); 183 qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1());
184 } else 184 } else
185 qDebug("error open file "); 185 qDebug("error open file ");
186 } 186 }
187 standardAddressBook->close();
188 // line not needed by KDE 3.4:
189 // delete standardAddressBook;
190
187 191
188 delete standardAddressBook;
189 //KABC::StdAddressBook::close(); 192 //KABC::StdAddressBook::close();
190 //StdAddressBook::mSelf = 0; 193 //StdAddressBook::mSelf = 0;
191 qDebug("ente "); 194 qDebug("ente ");
192 return 0; 195 return 0;
193} 196}
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d59f4a4..7319285 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -829,213 +829,223 @@ bool KSyncManager::edit_sync_options()
829 case 0: 829 case 0:
830 loc.setChecked( true); 830 loc.setChecked( true);
831 break; 831 break;
832 case 1: 832 case 1:
833 rem.setChecked( true ); 833 rem.setChecked( true );
834 break; 834 break;
835 case 2: 835 case 2:
836 newest.setChecked( true); 836 newest.setChecked( true);
837 break; 837 break;
838 case 3: 838 case 3:
839 ask.setChecked( true); 839 ask.setChecked( true);
840 break; 840 break;
841 case 4: 841 case 4:
842 f_loc.setChecked( true); 842 f_loc.setChecked( true);
843 break; 843 break;
844 case 5: 844 case 5:
845 f_rem.setChecked( true); 845 f_rem.setChecked( true);
846 break; 846 break;
847 case 6: 847 case 6:
848 // both.setChecked( true); 848 // both.setChecked( true);
849 break; 849 break;
850 default: 850 default:
851 break; 851 break;
852 } 852 }
853 if ( dia.exec() ) { 853 if ( dia.exec() ) {
854 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 854 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
855 return true; 855 return true;
856 } 856 }
857 return false; 857 return false;
858} 858}
859 859
860QString KSyncManager::getPassword( ) 860QString KSyncManager::getPassword( )
861{ 861{
862 QString retfile = ""; 862 QString retfile = "";
863 QDialog dia ( mParent, "input-dialog", true ); 863 QDialog dia ( mParent, "input-dialog", true );
864 QLineEdit lab ( &dia ); 864 QLineEdit lab ( &dia );
865 lab.setEchoMode( QLineEdit::Password ); 865 lab.setEchoMode( QLineEdit::Password );
866 QVBoxLayout lay( &dia ); 866 QVBoxLayout lay( &dia );
867 lay.setMargin(7); 867 lay.setMargin(7);
868 lay.setSpacing(7); 868 lay.setSpacing(7);
869 lay.addWidget( &lab); 869 lay.addWidget( &lab);
870 dia.setFixedSize( 230,50 ); 870 dia.setFixedSize( 230,50 );
871 dia.setCaption( i18n("Enter password") ); 871 dia.setCaption( i18n("Enter password") );
872 QPushButton pb ( "OK", &dia); 872 QPushButton pb ( "OK", &dia);
873 lay.addWidget( &pb ); 873 lay.addWidget( &pb );
874 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 874 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
875 dia.show(); 875 dia.show();
876 int res = dia.exec(); 876 int res = dia.exec();
877 if ( res ) 877 if ( res )
878 retfile = lab.text(); 878 retfile = lab.text();
879 dia.hide(); 879 dia.hide();
880 qApp->processEvents(); 880 qApp->processEvents();
881 return retfile; 881 return retfile;
882 882
883} 883}
884 884
885 885
886void KSyncManager::confSync() 886void KSyncManager::confSync()
887{ 887{
888 static KSyncPrefsDialog* sp = 0; 888 static KSyncPrefsDialog* sp = 0;
889 if ( ! sp ) { 889 if ( ! sp ) {
890 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 890 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
891 } 891 }
892 sp->usrReadConfig(); 892 sp->usrReadConfig();
893#ifndef DESKTOP_VERSION 893#ifndef DESKTOP_VERSION
894 sp->showMaximized(); 894 sp->showMaximized();
895#else 895#else
896 sp->show(); 896 sp->show();
897#endif 897#endif
898 sp->exec(); 898 sp->exec();
899 QStringList oldSyncProfileNames = mSyncProfileNames; 899 QStringList oldSyncProfileNames = mSyncProfileNames;
900 mSyncProfileNames = sp->getSyncProfileNames(); 900 mSyncProfileNames = sp->getSyncProfileNames();
901 mLocalMachineName = sp->getLocalMachineName (); 901 mLocalMachineName = sp->getLocalMachineName ();
902 int ii; 902 int ii;
903 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 903 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
904 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 904 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
905 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 905 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
906 } 906 }
907 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 907 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
908} 908}
909void KSyncManager::syncKDE() 909void KSyncManager::syncKDE()
910{ 910{
911 mSyncWithDesktop = true; 911 mSyncWithDesktop = true;
912 emit save(); 912 emit save();
913 switch(mTargetApp) 913 switch(mTargetApp)
914 { 914 {
915 case (KAPI): 915 case (KAPI):
916 { 916 {
917#ifdef DESKTOP_VERSION 917#ifdef DESKTOP_VERSION
918 QString command = qApp->applicationDirPath () + "/kdeabdump"; 918 QString command = qApp->applicationDirPath () + "/kdeabdump";
919#else 919#else
920 QString command = "kdeabdump"; 920 QString command = "kdeabdump";
921#endif 921#endif
922 if ( ! QFile::exists ( command ) ) 922 if ( ! QFile::exists ( command ) )
923 command = "kdeabdump"; 923 command = "kdeabdump";
924 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 924 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
925 system ( command.latin1()); 925 int result = system ( command.latin1());
926 qDebug("AB dump command call result: %d ", result);
927 if ( result != 0 ) {
928 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n/opt/kdepimpi/kdeabdump\nexists.The standard version of this file\nis for syncing with KDE 3.4.x.\nIf you are running KDE 3.3.x please\ndownload the KDE 3.3.x version of this file\nat http://sourceforge.net/projects/kdepimpi/\nsection: general files for KDE/Pim."));
929 return;
930 }
926 if ( syncWithFile( fileName,true ) ) { 931 if ( syncWithFile( fileName,true ) ) {
927 if ( mWriteBackFile ) { 932 if ( mWriteBackFile ) {
928 command += " --read"; 933 command += " --read";
929 system ( command.latin1()); 934 system ( command.latin1());
930 } 935 }
931 } 936 }
932 937
933 } 938 }
934 break; 939 break;
935 case (KOPI): 940 case (KOPI):
936 { 941 {
937#ifdef DESKTOP_VERSION 942#ifdef DESKTOP_VERSION
938 QString command = qApp->applicationDirPath () + "/kdecaldump"; 943 QString command = qApp->applicationDirPath () + "/kdecaldump";
939#else 944#else
940 QString command = "kdecaldump"; 945 QString command = "kdecaldump";
941#endif 946#endif
942 if ( ! QFile::exists ( command ) ) 947 if ( ! QFile::exists ( command ) )
943 command = "kdecaldump"; 948 command = "kdecaldump";
944 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 949 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
945 system ( command.latin1()); 950 int result = system ( command.latin1());
951 qDebug("Cal dump command call result result: %d ", result);
952 if ( result != 0 ) {
953 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n/opt/kdepimpi/kdecaldump\nexists.The standard version of this file\nis for syncing with KDE 3.4.x.\nIf you are running KDE 3.3.x please\ndownload the KDE 3.3.x version of this file\nat http://sourceforge.net/projects/kdepimpi/\nsection: general files for KDE/Pim."));
954 return;
955 }
946 if ( syncWithFile( fileName,true ) ) { 956 if ( syncWithFile( fileName,true ) ) {
947 if ( mWriteBackFile ) { 957 if ( mWriteBackFile ) {
948 command += " --read"; 958 command += " --read";
949 system ( command.latin1()); 959 system ( command.latin1());
950 } 960 }
951 } 961 }
952 962
953 } 963 }
954 break; 964 break;
955 case (PWMPI): 965 case (PWMPI):
956 966
957 break; 967 break;
958 default: 968 default:
959 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 969 qDebug("KSM::slotSyncMenu: invalid apptype selected");
960 break; 970 break;
961 971
962 } 972 }
963} 973}
964 974
965void KSyncManager::syncSharp() 975void KSyncManager::syncSharp()
966{ 976{
967 977
968 if ( ! syncExternalApplication("sharp") ) 978 if ( ! syncExternalApplication("sharp") )
969 qDebug("KSM::ERROR sync sharp "); 979 qDebug("KSM::ERROR sync sharp ");
970} 980}
971 981
972bool KSyncManager::syncExternalApplication(QString resource) 982bool KSyncManager::syncExternalApplication(QString resource)
973{ 983{
974 984
975 emit save(); 985 emit save();
976 986
977 if ( mAskForPreferences ) 987 if ( mAskForPreferences )
978 if ( !edit_sync_options()) { 988 if ( !edit_sync_options()) {
979 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 989 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
980 return false; 990 return false;
981 } 991 }
982 992
983 qDebug("KSM::Sync extern %s", resource.latin1()); 993 qDebug("KSM::Sync extern %s", resource.latin1());
984 994
985 bool syncOK = mImplementation->syncExternal(this, resource); 995 bool syncOK = mImplementation->syncExternal(this, resource);
986 996
987 return syncOK; 997 return syncOK;
988 998
989} 999}
990 1000
991void KSyncManager::syncPhone() 1001void KSyncManager::syncPhone()
992{ 1002{
993 1003
994 syncExternalApplication("phone"); 1004 syncExternalApplication("phone");
995 1005
996} 1006}
997 1007
998void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1008void KSyncManager::showProgressBar(int percentage, QString caption, int total)
999{ 1009{
1000 if (!bar->isVisible()) 1010 if (!bar->isVisible())
1001 { 1011 {
1002 bar->setCaption (caption); 1012 bar->setCaption (caption);
1003 bar->setTotalSteps ( total ) ; 1013 bar->setTotalSteps ( total ) ;
1004 bar->show(); 1014 bar->show();
1005 } 1015 }
1006 bar->raise(); 1016 bar->raise();
1007 bar->setProgress( percentage ); 1017 bar->setProgress( percentage );
1008 qApp->processEvents(); 1018 qApp->processEvents();
1009} 1019}
1010 1020
1011void KSyncManager::hideProgressBar() 1021void KSyncManager::hideProgressBar()
1012{ 1022{
1013 bar->hide(); 1023 bar->hide();
1014 qApp->processEvents(); 1024 qApp->processEvents();
1015} 1025}
1016 1026
1017bool KSyncManager::isProgressBarCanceled() 1027bool KSyncManager::isProgressBarCanceled()
1018{ 1028{
1019 return !bar->isVisible(); 1029 return !bar->isVisible();
1020} 1030}
1021 1031
1022QString KSyncManager::syncFileName() 1032QString KSyncManager::syncFileName()
1023{ 1033{
1024 1034
1025 QString fn = "tempfile"; 1035 QString fn = "tempfile";
1026 switch(mTargetApp) 1036 switch(mTargetApp)
1027 { 1037 {
1028 case (KAPI): 1038 case (KAPI):
1029 fn = "tempsyncab.vcf"; 1039 fn = "tempsyncab.vcf";
1030 break; 1040 break;
1031 case (KOPI): 1041 case (KOPI):
1032 fn = "tempsynccal.ics"; 1042 fn = "tempsynccal.ics";
1033 break; 1043 break;
1034 case (PWMPI): 1044 case (PWMPI):
1035 fn = "tempsyncpw.pwm"; 1045 fn = "tempsyncpw.pwm";
1036 break; 1046 break;
1037 default: 1047 default:
1038 break; 1048 break;
1039 } 1049 }
1040#ifdef _WIN32_ 1050#ifdef _WIN32_
1041 return locateLocal( "tmp", fn ); 1051 return locateLocal( "tmp", fn );