author | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
commit | d7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (unidiff) | |
tree | d9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9 | |
parent | 987757f168bbae56100f2aff763b865e81ceec18 (diff) | |
download | kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2 |
kapi sync
-rw-r--r-- | kabc/addressbook.cpp | 22 | ||||
-rw-r--r-- | kabc/addressbook.h | 1 | ||||
-rw-r--r-- | kabc/addressee.cpp | 75 | ||||
-rw-r--r-- | kabc/addressee.h | 4 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 24 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 130 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 5 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 712 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.h | 63 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 11 | ||||
-rw-r--r-- | korganizer/journalentry.h | 1 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 9 | ||||
-rw-r--r-- | libkdepim/externalapphandler.cpp | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 71 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 3 | ||||
-rw-r--r-- | libkdepim/libkdepim.pro | 15 |
16 files changed, 337 insertions, 811 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index f9e4387..fe59fcb 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -853,212 +853,230 @@ void AddressBook::removeAddressee( const Addressee &a ) | |||
853 | Iterator it; | 853 | Iterator it; |
854 | Iterator it2; | 854 | Iterator it2; |
855 | bool found = false; | 855 | bool found = false; |
856 | for ( it = begin(); it != end(); ++it ) { | 856 | for ( it = begin(); it != end(); ++it ) { |
857 | if ( a.uid() == (*it).uid() ) { | 857 | if ( a.uid() == (*it).uid() ) { |
858 | found = true; | 858 | found = true; |
859 | it2 = it; | 859 | it2 = it; |
860 | } else { | 860 | } else { |
861 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 861 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
862 | QString name = (*it).uid().mid( 19 ); | 862 | QString name = (*it).uid().mid( 19 ); |
863 | Addressee b = a; | 863 | Addressee b = a; |
864 | QString id = b.getID( name ); | 864 | QString id = b.getID( name ); |
865 | if ( ! id.isEmpty() ) { | 865 | if ( ! id.isEmpty() ) { |
866 | QString des = (*it).note(); | 866 | QString des = (*it).note(); |
867 | if( des.find( id ) < 0 ) { | 867 | if( des.find( id ) < 0 ) { |
868 | des += id + ","; | 868 | des += id + ","; |
869 | (*it).setNote( des ); | 869 | (*it).setNote( des ); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | if ( found ) | 877 | if ( found ) |
878 | removeAddressee( it2 ); | 878 | removeAddressee( it2 ); |
879 | 879 | ||
880 | } | 880 | } |
881 | 881 | ||
882 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 882 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
883 | { | 883 | { |
884 | Iterator it = begin(); | 884 | Iterator it = begin(); |
885 | Iterator it2 ; | 885 | Iterator it2 ; |
886 | QDateTime dt ( QDate( 2003,1,1) ); | 886 | QDateTime dt ( QDate( 2003,1,1) ); |
887 | while ( it != end() ) { | 887 | while ( it != end() ) { |
888 | (*it).setRevision( dt ); | 888 | (*it).setRevision( dt ); |
889 | if (( *it).IDStr() != "changed" ) { | 889 | if (( *it).IDStr() != "changed" ) { |
890 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 890 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
891 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 891 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
892 | (*it).setIDStr(":"); | 892 | (*it).setIDStr(":"); |
893 | } | 893 | } |
894 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 894 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
895 | it2 = it; | 895 | it2 = it; |
896 | //qDebug("removing %s ",(*it).uid().latin1() ); | 896 | //qDebug("removing %s ",(*it).uid().latin1() ); |
897 | ++it; | 897 | ++it; |
898 | removeAddressee( it2 ); | 898 | removeAddressee( it2 ); |
899 | } else { | 899 | } else { |
900 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 900 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
901 | if ( removeDeleted ) { | 901 | if ( removeDeleted ) { |
902 | // we have no postprocessing in the resource, we have to do it here | 902 | // we have no postprocessing in the resource, we have to do it here |
903 | // we have to compute csum for all, because it could be the first sync | 903 | // we have to compute csum for all, because it could be the first sync |
904 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 904 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
905 | } | 905 | } |
906 | ++it; | 906 | ++it; |
907 | } | 907 | } |
908 | } | 908 | } |
909 | deleteRemovedAddressees(); | 909 | deleteRemovedAddressees(); |
910 | } | 910 | } |
911 | 911 | ||
912 | void AddressBook::removeAddressee( const Iterator &it ) | 912 | void AddressBook::removeAddressee( const Iterator &it ) |
913 | { | 913 | { |
914 | d->mRemovedAddressees.append( (*it) ); | 914 | d->mRemovedAddressees.append( (*it) ); |
915 | d->mAddressees.remove( it.d->mIt ); | 915 | d->mAddressees.remove( it.d->mIt ); |
916 | } | 916 | } |
917 | 917 | ||
918 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 918 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
919 | { | 919 | { |
920 | Iterator it; | 920 | Iterator it; |
921 | for ( it = begin(); it != end(); ++it ) { | 921 | for ( it = begin(); it != end(); ++it ) { |
922 | if ( a.uid() == (*it).uid() ) { | 922 | if ( a.uid() == (*it).uid() ) { |
923 | return it; | 923 | return it; |
924 | } | 924 | } |
925 | } | 925 | } |
926 | return end(); | 926 | return end(); |
927 | } | 927 | } |
928 | 928 | ||
929 | Addressee AddressBook::findByUid( const QString &uid ) | 929 | Addressee AddressBook::findByUid( const QString &uid ) |
930 | { | 930 | { |
931 | Iterator it; | 931 | Iterator it; |
932 | for ( it = begin(); it != end(); ++it ) { | 932 | for ( it = begin(); it != end(); ++it ) { |
933 | if ( uid == (*it).uid() ) { | 933 | if ( uid == (*it).uid() ) { |
934 | return *it; | 934 | return *it; |
935 | } | 935 | } |
936 | } | 936 | } |
937 | return Addressee(); | 937 | return Addressee(); |
938 | } | 938 | } |
939 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 939 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
940 | { | 940 | { |
941 | //qDebug("AddressBook::preExternSync "); | 941 | //qDebug("AddressBook::preExternSync "); |
942 | AddressBook::Iterator it; | 942 | AddressBook::Iterator it; |
943 | for ( it = begin(); it != end(); ++it ) { | 943 | for ( it = begin(); it != end(); ++it ) { |
944 | (*it).setID( csd, (*it).externalUID() ); | 944 | (*it).setID( csd, (*it).externalUID() ); |
945 | (*it).computeCsum( csd ); | 945 | (*it).computeCsum( csd ); |
946 | } | 946 | } |
947 | mergeAB( aBook ,csd, isSubset ); | 947 | mergeAB( aBook ,csd, isSubset ); |
948 | } | 948 | } |
949 | void AddressBook::preOLSync( AddressBook* aBook, const QString& csd ) | ||
950 | { | ||
951 | //qDebug("AddressBook::preExternSync "); | ||
952 | AddressBook::Iterator it; | ||
953 | for ( it = begin(); it != end(); ++it ) { | ||
954 | (*it).setID( csd, (*it).externalUID() ); | ||
955 | (*it).computeCsum( csd ); | ||
956 | } | ||
957 | |||
958 | Addressee ad; | ||
959 | for ( it = begin(); it != end(); ++it ) { | ||
960 | ad = aBook->findByExternUid( (*it).externalUID(), csd ); | ||
961 | if ( !ad.isEmpty() ) { | ||
962 | (*it).mergeOLContact( ad ); | ||
963 | } | ||
964 | } | ||
965 | } | ||
949 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) | 966 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
950 | { | 967 | { |
951 | //qDebug("AddressBook::postExternSync "); | 968 | //qDebug("AddressBook::postExternSync "); |
952 | AddressBook::Iterator it; | 969 | AddressBook::Iterator it; |
953 | int foundEmpty = 0; | 970 | int foundEmpty = 0; |
954 | for ( it = begin(); it != end(); ++it ) { | 971 | for ( it = begin(); it != end(); ++it ) { |
955 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 972 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
956 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 973 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
957 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || | 974 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
958 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | 975 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { |
959 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 976 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
960 | if ( ad.isEmpty() ) { | 977 | if ( ad.isEmpty() ) { |
961 | ++foundEmpty; | 978 | ++foundEmpty; |
962 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); | 979 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); |
963 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); | 980 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); |
964 | } else { | 981 | } else { |
965 | (*it).setIDStr(":"); | 982 | (*it).setIDStr(":"); |
966 | if ( setID ) { | 983 | if ( setID ) { |
967 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 984 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
968 | ad.setID( csd, (*it).externalUID() ); | 985 | ad.setID( csd, (*it).externalUID() );{ |
986 | } | ||
969 | } else | 987 | } else |
970 | ad.setID( csd, (*it).uid() ); | 988 | ad.setID( csd, (*it).uid() ); |
971 | (*it).computeCsum( csd ); | 989 | (*it).computeCsum( csd ); |
972 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 990 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
973 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); | 991 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
974 | aBook->insertAddressee( ad , false); | 992 | aBook->insertAddressee( ad , false); |
975 | } | 993 | } |
976 | } | 994 | } |
977 | } | 995 | } |
978 | if ( foundEmpty ) { | 996 | if ( foundEmpty ) { |
979 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); | 997 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); |
980 | } | 998 | } |
981 | 999 | ||
982 | } | 1000 | } |
983 | 1001 | ||
984 | bool AddressBook::containsExternalUid( const QString& uid ) | 1002 | bool AddressBook::containsExternalUid( const QString& uid ) |
985 | { | 1003 | { |
986 | Iterator it; | 1004 | Iterator it; |
987 | for ( it = begin(); it != end(); ++it ) { | 1005 | for ( it = begin(); it != end(); ++it ) { |
988 | if ( uid == (*it).externalUID( ) ) | 1006 | if ( uid == (*it).externalUID( ) ) |
989 | return true; | 1007 | return true; |
990 | } | 1008 | } |
991 | return false; | 1009 | return false; |
992 | } | 1010 | } |
993 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const | 1011 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const |
994 | { | 1012 | { |
995 | ConstIterator it; | 1013 | ConstIterator it; |
996 | for ( it = begin(); it != end(); ++it ) { | 1014 | for ( it = begin(); it != end(); ++it ) { |
997 | if ( uid == (*it).getID( profile ) ) | 1015 | if ( uid == (*it).getID( profile ) ) |
998 | return (*it); | 1016 | return (*it); |
999 | } | 1017 | } |
1000 | return Addressee(); | 1018 | return Addressee(); |
1001 | } | 1019 | } |
1002 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 1020 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
1003 | { | 1021 | { |
1004 | Iterator it; | 1022 | Iterator it; |
1005 | Addressee ad; | 1023 | Addressee ad; |
1006 | for ( it = begin(); it != end(); ++it ) { | 1024 | for ( it = begin(); it != end(); ++it ) { |
1007 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 1025 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
1008 | if ( !ad.isEmpty() ) { | 1026 | if ( !ad.isEmpty() ) { |
1009 | (*it).mergeContact( ad ,isSubset); | 1027 | (*it).mergeContact( ad ,isSubset); |
1010 | } | 1028 | } |
1011 | } | 1029 | } |
1012 | #if 0 | 1030 | #if 0 |
1013 | // test only | 1031 | // test only |
1014 | for ( it = begin(); it != end(); ++it ) { | 1032 | for ( it = begin(); it != end(); ++it ) { |
1015 | 1033 | ||
1016 | qDebug("uid %s ", (*it).uid().latin1()); | 1034 | qDebug("uid %s ", (*it).uid().latin1()); |
1017 | } | 1035 | } |
1018 | #endif | 1036 | #endif |
1019 | } | 1037 | } |
1020 | 1038 | ||
1021 | #if 0 | 1039 | #if 0 |
1022 | Addressee::List AddressBook::getExternLastSyncAddressees() | 1040 | Addressee::List AddressBook::getExternLastSyncAddressees() |
1023 | { | 1041 | { |
1024 | Addressee::List results; | 1042 | Addressee::List results; |
1025 | 1043 | ||
1026 | Iterator it; | 1044 | Iterator it; |
1027 | for ( it = begin(); it != end(); ++it ) { | 1045 | for ( it = begin(); it != end(); ++it ) { |
1028 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 1046 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
1029 | if ( (*it).familyName().left(4) == "!E: " ) | 1047 | if ( (*it).familyName().left(4) == "!E: " ) |
1030 | results.append( *it ); | 1048 | results.append( *it ); |
1031 | } | 1049 | } |
1032 | } | 1050 | } |
1033 | 1051 | ||
1034 | return results; | 1052 | return results; |
1035 | } | 1053 | } |
1036 | #endif | 1054 | #endif |
1037 | void AddressBook::resetTempSyncStat() | 1055 | void AddressBook::resetTempSyncStat() |
1038 | { | 1056 | { |
1039 | Iterator it; | 1057 | Iterator it; |
1040 | for ( it = begin(); it != end(); ++it ) { | 1058 | for ( it = begin(); it != end(); ++it ) { |
1041 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 1059 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
1042 | } | 1060 | } |
1043 | 1061 | ||
1044 | } | 1062 | } |
1045 | 1063 | ||
1046 | QStringList AddressBook:: uidList() | 1064 | QStringList AddressBook:: uidList() |
1047 | { | 1065 | { |
1048 | QStringList results; | 1066 | QStringList results; |
1049 | Iterator it; | 1067 | Iterator it; |
1050 | for ( it = begin(); it != end(); ++it ) { | 1068 | for ( it = begin(); it != end(); ++it ) { |
1051 | results.append( (*it).uid() ); | 1069 | results.append( (*it).uid() ); |
1052 | } | 1070 | } |
1053 | return results; | 1071 | return results; |
1054 | } | 1072 | } |
1055 | 1073 | ||
1056 | 1074 | ||
1057 | Addressee::List AddressBook::allAddressees() | 1075 | Addressee::List AddressBook::allAddressees() |
1058 | { | 1076 | { |
1059 | return d->mAddressees; | 1077 | return d->mAddressees; |
1060 | 1078 | ||
1061 | } | 1079 | } |
1062 | 1080 | ||
1063 | Addressee::List AddressBook::findByName( const QString &name ) | 1081 | Addressee::List AddressBook::findByName( const QString &name ) |
1064 | { | 1082 | { |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e6daa5e..a8a9fc1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -215,136 +215,137 @@ class AddressBook : public QObject | |||
215 | Addressee::List allAddressees(); | 215 | Addressee::List allAddressees(); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | Find all entries with the specified name in the address book. Returns | 218 | Find all entries with the specified name in the address book. Returns |
219 | an empty list, if no entries could be found. | 219 | an empty list, if no entries could be found. |
220 | */ | 220 | */ |
221 | Addressee::List findByName( const QString & ); | 221 | Addressee::List findByName( const QString & ); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | Find all entries with the specified email address in the address book. | 224 | Find all entries with the specified email address in the address book. |
225 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
226 | */ | 226 | */ |
227 | Addressee::List findByEmail( const QString & ); | 227 | Addressee::List findByEmail( const QString & ); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | Find all entries wich have the specified category in the address book. | 230 | Find all entries wich have the specified category in the address book. |
231 | Returns an empty list, if no entries could be found. | 231 | Returns an empty list, if no entries could be found. |
232 | */ | 232 | */ |
233 | Addressee::List findByCategory( const QString & ); | 233 | Addressee::List findByCategory( const QString & ); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return a string identifying this addressbook. | 236 | Return a string identifying this addressbook. |
237 | */ | 237 | */ |
238 | virtual QString identifier(); | 238 | virtual QString identifier(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Used for debug output. | 241 | Used for debug output. |
242 | */ | 242 | */ |
243 | void dump() const; | 243 | void dump() const; |
244 | 244 | ||
245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Return list of all Fields known to the address book which are associated | 250 | Return list of all Fields known to the address book which are associated |
251 | with the given field category. | 251 | with the given field category. |
252 | */ | 252 | */ |
253 | Field::List fields( int category = Field::All ); | 253 | Field::List fields( int category = Field::All ); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Add custom field to address book. | 256 | Add custom field to address book. |
257 | 257 | ||
258 | @param label User visible label of the field. | 258 | @param label User visible label of the field. |
259 | @param category Ored list of field categories. | 259 | @param category Ored list of field categories. |
260 | @param key Identifier used as key for reading and writing the field. | 260 | @param key Identifier used as key for reading and writing the field. |
261 | @param app String used as application key for reading and writing | 261 | @param app String used as application key for reading and writing |
262 | the field. | 262 | the field. |
263 | */ | 263 | */ |
264 | bool addCustomField( const QString &label, int category = Field::All, | 264 | bool addCustomField( const QString &label, int category = Field::All, |
265 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
266 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | Add address book resource. | 270 | Add address book resource. |
271 | */ | 271 | */ |
272 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Remove address book resource. | 275 | Remove address book resource. |
276 | */ | 276 | */ |
277 | void removeResources(); | 277 | void removeResources(); |
278 | bool removeResource( Resource * ); | 278 | bool removeResource( Resource * ); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return pointer list of all resources. | 281 | Return pointer list of all resources. |
282 | */ | 282 | */ |
283 | QPtrList<Resource> resources(); | 283 | QPtrList<Resource> resources(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Set the @p ErrorHandler, that is used by @ref error() to | 286 | Set the @p ErrorHandler, that is used by @ref error() to |
287 | provide gui-independend error messages. | 287 | provide gui-independend error messages. |
288 | */ | 288 | */ |
289 | void setErrorHandler( ErrorHandler * ); | 289 | void setErrorHandler( ErrorHandler * ); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Shows gui independend error messages. | 292 | Shows gui independend error messages. |
293 | */ | 293 | */ |
294 | void error( const QString& ); | 294 | void error( const QString& ); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Query all resources to clean up their lock files | 297 | Query all resources to clean up their lock files |
298 | */ | 298 | */ |
299 | void cleanUp(); | 299 | void cleanUp(); |
300 | 300 | ||
301 | // sync stuff | 301 | // sync stuff |
302 | //Addressee::List getExternLastSyncAddressees(); | 302 | //Addressee::List getExternLastSyncAddressees(); |
303 | void resetTempSyncStat(); | 303 | void resetTempSyncStat(); |
304 | QStringList uidList(); | 304 | QStringList uidList(); |
305 | void removeSyncAddressees( bool removeDeleted = false ); | 305 | void removeSyncAddressees( bool removeDeleted = false ); |
306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; | 307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; |
308 | bool containsExternalUid( const QString& uid ); | 308 | bool containsExternalUid( const QString& uid ); |
309 | 309 | ||
310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
311 | void preOLSync( AddressBook* aBook, const QString& csd); | ||
311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); | 312 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
312 | signals: | 313 | signals: |
313 | /** | 314 | /** |
314 | Emitted, when the address book has changed on disk. | 315 | Emitted, when the address book has changed on disk. |
315 | */ | 316 | */ |
316 | void addressBookChanged( AddressBook * ); | 317 | void addressBookChanged( AddressBook * ); |
317 | 318 | ||
318 | /** | 319 | /** |
319 | Emitted, when the address book has been locked for writing. | 320 | Emitted, when the address book has been locked for writing. |
320 | */ | 321 | */ |
321 | void addressBookLocked( AddressBook * ); | 322 | void addressBookLocked( AddressBook * ); |
322 | 323 | ||
323 | /** | 324 | /** |
324 | Emitted, when the address book has been unlocked. | 325 | Emitted, when the address book has been unlocked. |
325 | */ | 326 | */ |
326 | void addressBookUnlocked( AddressBook * ); | 327 | void addressBookUnlocked( AddressBook * ); |
327 | 328 | ||
328 | protected: | 329 | protected: |
329 | void deleteRemovedAddressees(); | 330 | void deleteRemovedAddressees(); |
330 | void setStandardResource( Resource * ); | 331 | void setStandardResource( Resource * ); |
331 | Resource *standardResource(); | 332 | Resource *standardResource(); |
332 | KRES::Manager<Resource> *resourceManager(); | 333 | KRES::Manager<Resource> *resourceManager(); |
333 | 334 | ||
334 | void init(const QString &config, const QString &family); | 335 | void init(const QString &config, const QString &family); |
335 | 336 | ||
336 | private: | 337 | private: |
337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 338 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
338 | 339 | ||
339 | 340 | ||
340 | struct AddressBookData; | 341 | struct AddressBookData; |
341 | AddressBookData *d; | 342 | AddressBookData *d; |
342 | bool blockLSEchange; | 343 | bool blockLSEchange; |
343 | }; | 344 | }; |
344 | 345 | ||
345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 346 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
346 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 347 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
347 | 348 | ||
348 | } | 349 | } |
349 | 350 | ||
350 | #endif | 351 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6cfac80..e8e440c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,430 +1,478 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kmessagebox.h> | ||
35 | #include <kidmanager.h> | 36 | #include <kidmanager.h> |
36 | //US | 37 | //US |
37 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 39 | #include <libkcal/syncdefines.h> |
39 | 40 | ||
40 | //US #include "resource.h" | 41 | //US #include "resource.h" |
41 | #include "addressee.h" | 42 | #include "addressee.h" |
42 | 43 | ||
43 | using namespace KABC; | 44 | using namespace KABC; |
44 | 45 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 46 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 47 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 48 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 49 | ||
49 | struct Addressee::AddresseeData : public KShared | 50 | struct Addressee::AddresseeData : public KShared |
50 | { | 51 | { |
51 | QString uid; | 52 | QString uid; |
52 | QString name; | 53 | QString name; |
53 | QString formattedName; | 54 | QString formattedName; |
54 | QString familyName; | 55 | QString familyName; |
55 | QString givenName; | 56 | QString givenName; |
56 | QString additionalName; | 57 | QString additionalName; |
57 | QString prefix; | 58 | QString prefix; |
58 | QString suffix; | 59 | QString suffix; |
59 | QString nickName; | 60 | QString nickName; |
60 | QDateTime birthday; | 61 | QDateTime birthday; |
61 | QString mailer; | 62 | QString mailer; |
62 | TimeZone timeZone; | 63 | TimeZone timeZone; |
63 | Geo geo; | 64 | Geo geo; |
64 | QString title; | 65 | QString title; |
65 | QString role; | 66 | QString role; |
66 | QString organization; | 67 | QString organization; |
67 | QString note; | 68 | QString note; |
68 | QString productId; | 69 | QString productId; |
69 | QDateTime revision; | 70 | QDateTime revision; |
70 | QString sortString; | 71 | QString sortString; |
71 | QString externalUID; | 72 | QString externalUID; |
72 | QString originalExternalUID; | 73 | QString originalExternalUID; |
73 | KURL url; | 74 | KURL url; |
74 | Secrecy secrecy; | 75 | Secrecy secrecy; |
75 | Picture logo; | 76 | Picture logo; |
76 | Picture photo; | 77 | Picture photo; |
77 | Sound sound; | 78 | Sound sound; |
78 | Agent agent; | 79 | Agent agent; |
79 | QString mExternalId; | 80 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 81 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 82 | Address::List addresses; |
82 | Key::List keys; | 83 | Key::List keys; |
83 | QStringList emails; | 84 | QStringList emails; |
84 | QStringList categories; | 85 | QStringList categories; |
85 | QStringList custom; | 86 | QStringList custom; |
86 | int mTempSyncStat; | 87 | int mTempSyncStat; |
87 | Resource *resource; | 88 | Resource *resource; |
88 | 89 | ||
89 | bool empty :1; | 90 | bool empty :1; |
90 | bool changed :1; | 91 | bool changed :1; |
91 | bool tagged :1; | 92 | bool tagged :1; |
92 | }; | 93 | }; |
93 | 94 | ||
94 | Addressee::Addressee() | 95 | Addressee::Addressee() |
95 | { | 96 | { |
96 | mData = new AddresseeData; | 97 | mData = new AddresseeData; |
97 | mData->empty = true; | 98 | mData->empty = true; |
98 | mData->changed = false; | 99 | mData->changed = false; |
99 | mData->resource = 0; | 100 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 101 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 102 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 103 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 104 | } |
104 | 105 | ||
105 | Addressee::~Addressee() | 106 | Addressee::~Addressee() |
106 | { | 107 | { |
107 | } | 108 | } |
108 | 109 | ||
109 | Addressee::Addressee( const Addressee &a ) | 110 | Addressee::Addressee( const Addressee &a ) |
110 | { | 111 | { |
111 | mData = a.mData; | 112 | mData = a.mData; |
112 | } | 113 | } |
113 | 114 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 115 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 116 | { |
116 | mData = a.mData; | 117 | mData = a.mData; |
117 | return (*this); | 118 | return (*this); |
118 | } | 119 | } |
119 | 120 | ||
120 | Addressee Addressee::copy() | 121 | Addressee Addressee::copy() |
121 | { | 122 | { |
122 | Addressee a; | 123 | Addressee a; |
123 | *(a.mData) = *mData; | 124 | *(a.mData) = *mData; |
124 | return a; | 125 | return a; |
125 | } | 126 | } |
126 | 127 | ||
127 | void Addressee::detach() | 128 | void Addressee::detach() |
128 | { | 129 | { |
129 | if ( mData.count() == 1 ) return; | 130 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 131 | *this = copy(); |
131 | } | 132 | } |
132 | 133 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 134 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 135 | { |
135 | if ( uid() != a.uid() ) return false; | 136 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 137 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 138 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 139 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 140 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 141 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 142 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 143 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 144 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 145 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 146 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 147 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 148 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 149 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 150 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 151 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 152 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 153 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 154 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 155 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 156 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 157 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 158 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 159 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 160 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 161 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 162 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 163 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 164 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 165 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 166 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 167 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 168 | if ( mData->custom != a.mData->custom ) return false; |
168 | 169 | ||
169 | return true; | 170 | return true; |
170 | } | 171 | } |
171 | 172 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 173 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 174 | { |
174 | return !( a == *this ); | 175 | return !( a == *this ); |
175 | } | 176 | } |
176 | 177 | ||
177 | bool Addressee::isEmpty() const | 178 | bool Addressee::isEmpty() const |
178 | { | 179 | { |
179 | return mData->empty; | 180 | return mData->empty; |
180 | } | 181 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 182 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 183 | { |
183 | int max = attList.count(); | 184 | int max = attList.count(); |
184 | ulong cSum = 0; | 185 | ulong cSum = 0; |
185 | int j,k,i; | 186 | int j,k,i; |
186 | int add; | 187 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 188 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 189 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 190 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 191 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 192 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 193 | int mul = k +1; |
193 | add = s[k].unicode (); | 194 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 195 | if ( k < 16 ) |
195 | mul = mul * mul; | 196 | mul = mul * mul; |
196 | int ii = i+1; | 197 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 198 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 199 | cSum += add; |
199 | //qDebug("csum: %d %d %d", i,k,cSum); | 200 | //qDebug("csum: %d %d %d", i,k,cSum); |
200 | } | 201 | } |
201 | } | 202 | } |
202 | 203 | ||
203 | } | 204 | } |
204 | //QString dump = attList.join(","); | 205 | //QString dump = attList.join(","); |
205 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 206 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
206 | 207 | ||
207 | return cSum; | 208 | return cSum; |
208 | 209 | ||
209 | } | 210 | } |
210 | void Addressee::computeCsum(const QString &dev) | 211 | void Addressee::computeCsum(const QString &dev) |
211 | { | 212 | { |
212 | QStringList l; | 213 | QStringList l; |
213 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 214 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
214 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 215 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
215 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 216 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
216 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 217 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
217 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 218 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
218 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 219 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
219 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 220 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
220 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 221 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
221 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 222 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
222 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 223 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
223 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 224 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
224 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 225 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
225 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 226 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
226 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 227 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
227 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 228 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
228 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 229 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
229 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 230 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
230 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 231 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
231 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 232 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
232 | if ( !mData->logo.undefined() ) { | 233 | if ( !mData->logo.undefined() ) { |
233 | if ( !mData->logo.isIntern() ) | 234 | if ( !mData->logo.isIntern() ) |
234 | l.append( mData->logo.url() ); | 235 | l.append( mData->logo.url() ); |
235 | else | 236 | else |
236 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); | 237 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); |
237 | } else { | 238 | } else { |
238 | l.append( "nologo"); | 239 | l.append( "nologo"); |
239 | } | 240 | } |
240 | if ( !mData->photo.undefined() ) { | 241 | if ( !mData->photo.undefined() ) { |
241 | if ( !mData->photo.isIntern() ) | 242 | if ( !mData->photo.isIntern() ) |
242 | l.append( mData->photo.url() ); | 243 | l.append( mData->photo.url() ); |
243 | else | 244 | else |
244 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); | 245 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); |
245 | } else { | 246 | } else { |
246 | l.append( "nophoto"); | 247 | l.append( "nophoto"); |
247 | } | 248 | } |
248 | #if 0 | 249 | #if 0 |
249 | if ( !mData->sound.undefined() ) { | 250 | if ( !mData->sound.undefined() ) { |
250 | if ( !mData->sound.isIntern() ) | 251 | if ( !mData->sound.isIntern() ) |
251 | l.append( mData->sound.url() ); | 252 | l.append( mData->sound.url() ); |
252 | else | 253 | else |
253 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); | 254 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); |
254 | } else { | 255 | } else { |
255 | l.append( "nosound"); | 256 | l.append( "nosound"); |
256 | } | 257 | } |
257 | #endif | 258 | #endif |
258 | //if ( !mData->agent.isEmpty() ) l.append( ); | 259 | //if ( !mData->agent.isEmpty() ) l.append( ); |
259 | if ( mData->url.isValid() ) | 260 | if ( mData->url.isValid() ) |
260 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 261 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
261 | KABC::PhoneNumber::List phoneNumbers; | 262 | KABC::PhoneNumber::List phoneNumbers; |
262 | KABC::PhoneNumber::List::Iterator phoneIter; | 263 | KABC::PhoneNumber::List::Iterator phoneIter; |
263 | 264 | ||
264 | QStringList t; | 265 | QStringList t; |
265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 266 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
266 | ++phoneIter ) | 267 | ++phoneIter ) |
267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 268 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
268 | t.sort(); | 269 | t.sort(); |
269 | uint iii; | 270 | uint iii; |
270 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
271 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
272 | t = mData->emails; | 273 | t = mData->emails; |
273 | t.sort(); | 274 | t.sort(); |
274 | for ( iii = 0; iii < t.count(); ++iii) | 275 | for ( iii = 0; iii < t.count(); ++iii) |
275 | l.append( t[iii] ); | 276 | l.append( t[iii] ); |
276 | t = mData->categories; | 277 | t = mData->categories; |
277 | t.sort(); | 278 | t.sort(); |
278 | for ( iii = 0; iii < t.count(); ++iii) | 279 | for ( iii = 0; iii < t.count(); ++iii) |
279 | l.append( t[iii] ); | 280 | l.append( t[iii] ); |
280 | t = mData->custom; | 281 | t = mData->custom; |
281 | t.sort(); | 282 | t.sort(); |
282 | for ( iii = 0; iii < t.count(); ++iii) | 283 | for ( iii = 0; iii < t.count(); ++iii) |
283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 284 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
284 | int find = t[iii].find (':')+1; | 285 | int find = t[iii].find (':')+1; |
285 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 286 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
286 | if ( find < t[iii].length()) | 287 | if ( find < t[iii].length()) |
287 | l.append( t[iii] ); | 288 | l.append( t[iii] ); |
288 | 289 | ||
289 | } | 290 | } |
290 | KABC::Address::List::Iterator addressIter; | 291 | KABC::Address::List::Iterator addressIter; |
291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 292 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
292 | ++addressIter ) { | 293 | ++addressIter ) { |
293 | t = (*addressIter).asList(); | 294 | t = (*addressIter).asList(); |
294 | t.sort(); | 295 | t.sort(); |
295 | for ( iii = 0; iii < t.count(); ++iii) | 296 | for ( iii = 0; iii < t.count(); ++iii) |
296 | l.append( t[iii] ); | 297 | l.append( t[iii] ); |
297 | } | 298 | } |
298 | uint cs = getCsum4List(l); | 299 | uint cs = getCsum4List(l); |
299 | 300 | ||
300 | #if 0 | 301 | #if 0 |
301 | for ( iii = 0; iii < l.count(); ++iii) | 302 | for ( iii = 0; iii < l.count(); ++iii) |
302 | qDebug("%d***%s***",iii,l[iii].latin1()); | 303 | qDebug("%d***%s***",iii,l[iii].latin1()); |
303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 304 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
304 | #endif | 305 | #endif |
305 | 306 | ||
306 | 307 | ||
307 | setCsum( dev, QString::number (cs )); | 308 | setCsum( dev, QString::number (cs )); |
308 | } | 309 | } |
309 | bool Addressee::matchAddress( QRegExp* re ) const | 310 | bool Addressee::matchAddress( QRegExp* re ) const |
310 | { | 311 | { |
311 | KABC::Address::List::Iterator addressIter; | 312 | KABC::Address::List::Iterator addressIter; |
312 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 313 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
313 | ++addressIter ) { | 314 | ++addressIter ) { |
314 | if ( (*addressIter).matchAddress( re ) ) | 315 | if ( (*addressIter).matchAddress( re ) ) |
315 | return true; | 316 | return true; |
316 | } | 317 | } |
317 | return false; | 318 | return false; |
318 | } | 319 | } |
319 | bool Addressee::matchPhoneNumber( QRegExp* re ) const | 320 | bool Addressee::matchPhoneNumber( QRegExp* re ) const |
320 | { | 321 | { |
321 | KABC::PhoneNumber::List::Iterator phoneIter; | 322 | KABC::PhoneNumber::List::Iterator phoneIter; |
322 | 323 | ||
323 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { | 324 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { |
324 | #if QT_VERSION >= 0x030000 | 325 | #if QT_VERSION >= 0x030000 |
325 | if (re->search( (*phoneIter).number() ) == 0) | 326 | if (re->search( (*phoneIter).number() ) == 0) |
326 | #else | 327 | #else |
327 | if (re->match( (*phoneIter).number() ) == 0) | 328 | if (re->match( (*phoneIter).number() ) == 0) |
328 | #endif | 329 | #endif |
329 | return true; | 330 | return true; |
330 | 331 | ||
331 | } | 332 | } |
332 | return false; | 333 | return false; |
333 | 334 | ||
334 | } | 335 | } |
336 | void Addressee::mergeOLContact( const Addressee& ad ) | ||
337 | { | ||
338 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | ||
339 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | ||
340 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | ||
341 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | ||
342 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | ||
343 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | ||
344 | if ( !mData->sound.isIntern() ) { | ||
345 | if ( mData->sound.url().isEmpty() ) { | ||
346 | mData->sound = ad.mData->sound; | ||
347 | } | ||
348 | } | ||
349 | if ( !mData->agent.isIntern() ) { | ||
350 | if ( mData->agent.url().isEmpty() ) { | ||
351 | mData->agent = ad.mData->agent; | ||
352 | } | ||
353 | } | ||
354 | { | ||
355 | Key::List::Iterator itA; | ||
356 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | ||
357 | bool found = false; | ||
358 | Key::List::Iterator it; | ||
359 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | ||
360 | if ( (*it) == (*itA)) { | ||
361 | found = true; | ||
362 | break; | ||
363 | |||
364 | } | ||
365 | } | ||
366 | if ( ! found ) { | ||
367 | mData->keys.append( *itA ); | ||
368 | } | ||
369 | } | ||
370 | } | ||
371 | |||
372 | KABC::Address addthis = otherAddress(); | ||
373 | KABC::Address addother = ad.otherAddress(); | ||
374 | if ( !addthis.isEmpty() && !addother.isEmpty() ) | ||
375 | addthis.setType( addother.type() ); | ||
376 | //qDebug("merge contact %s ", ad.uid().latin1()); | ||
377 | setUid( ad.uid() ); | ||
378 | setRevision( ad.revision() ); | ||
379 | |||
380 | |||
381 | } | ||
382 | |||
335 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 383 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
336 | { | 384 | { |
337 | // merge all standard non-outlook fields. | 385 | // merge all standard non-outlook fields. |
338 | //if isSubSet (e.g. mobile phone sync) merge all fields | 386 | //if isSubSet (e.g. mobile phone sync) merge all fields |
339 | 387 | ||
340 | detach(); | 388 | detach(); |
341 | if ( isSubSet ) { | 389 | if ( isSubSet ) { |
342 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 390 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
343 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 391 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
344 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 392 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
345 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 393 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
346 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 394 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
347 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 395 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
348 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 396 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
349 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 397 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
350 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 398 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
351 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 399 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
352 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 400 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
353 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 401 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
354 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 402 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
355 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 403 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
356 | if ( !mData->birthday.isValid() ) | 404 | if ( !mData->birthday.isValid() ) |
357 | if ( ad.mData->birthday.isValid()) | 405 | if ( ad.mData->birthday.isValid()) |
358 | mData->birthday = ad.mData->birthday; | 406 | mData->birthday = ad.mData->birthday; |
359 | 407 | ||
360 | } | 408 | } |
361 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 409 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
362 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 410 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
363 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 411 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
364 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 412 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
365 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 413 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
366 | QStringList t; | 414 | QStringList t; |
367 | QStringList tAD; | 415 | QStringList tAD; |
368 | uint iii; | 416 | uint iii; |
369 | 417 | ||
370 | // ********** phone numbers | 418 | // ********** phone numbers |
371 | if ( isSubSet ) { | 419 | if ( isSubSet ) { |
372 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 420 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
373 | PhoneNumber::List::Iterator phoneItAD; | 421 | PhoneNumber::List::Iterator phoneItAD; |
374 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 422 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
375 | bool found = false; | 423 | bool found = false; |
376 | PhoneNumber::List::Iterator it; | 424 | PhoneNumber::List::Iterator it; |
377 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 425 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
378 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 426 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
379 | found = true; | 427 | found = true; |
380 | (*it).setType( ( *phoneItAD ).type() ); | 428 | (*it).setType( ( *phoneItAD ).type() ); |
381 | (*it).setNumber( ( *phoneItAD ).number() ); | 429 | (*it).setNumber( ( *phoneItAD ).number() ); |
382 | break; | 430 | break; |
383 | } | 431 | } |
384 | } | 432 | } |
385 | // if ( isSubSet && ! found ) | 433 | // if ( isSubSet && ! found ) |
386 | if ( ! found ) // LR try this one... | 434 | if ( ! found ) // LR try this one... |
387 | mData->phoneNumbers.append( *phoneItAD ); | 435 | mData->phoneNumbers.append( *phoneItAD ); |
388 | } | 436 | } |
389 | } else { | 437 | } else { |
390 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 438 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
391 | PhoneNumber::List::Iterator phoneItAD; | 439 | PhoneNumber::List::Iterator phoneItAD; |
392 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 440 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
393 | bool found = false; | 441 | bool found = false; |
394 | PhoneNumber::List::Iterator it; | 442 | PhoneNumber::List::Iterator it; |
395 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 443 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
396 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 444 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
397 | found = true; | 445 | found = true; |
398 | (*it).setType( ( *phoneItAD ).type() ); | 446 | (*it).setType( ( *phoneItAD ).type() ); |
399 | (*it).setNumber( ( *phoneItAD ).number() ); | 447 | (*it).setNumber( ( *phoneItAD ).number() ); |
400 | break; | 448 | break; |
401 | } | 449 | } |
402 | } | 450 | } |
403 | if ( ! found ) { // append numbers which do not have work or home type | 451 | if ( ! found ) { // append numbers which do not have work or home type |
404 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) | 452 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) |
405 | mData->phoneNumbers.append( *phoneItAD ); | 453 | mData->phoneNumbers.append( *phoneItAD ); |
406 | } | 454 | } |
407 | } | 455 | } |
408 | } | 456 | } |
409 | if ( isSubSet ) { | 457 | if ( isSubSet ) { |
410 | // ************* emails; | 458 | // ************* emails; |
411 | t = mData->emails; | 459 | t = mData->emails; |
412 | tAD = ad.mData->emails; | 460 | tAD = ad.mData->emails; |
413 | for ( iii = 0; iii < tAD.count(); ++iii) | 461 | for ( iii = 0; iii < tAD.count(); ++iii) |
414 | if ( !t.contains(tAD[iii] ) ) | 462 | if ( !t.contains(tAD[iii] ) ) |
415 | mData->emails.append( tAD[iii] ); | 463 | mData->emails.append( tAD[iii] ); |
416 | } | 464 | } |
417 | 465 | ||
418 | // ************* categories; | 466 | // ************* categories; |
419 | if ( isSubSet ) { | 467 | if ( isSubSet ) { |
420 | t = mData->categories; | 468 | t = mData->categories; |
421 | tAD = ad.mData->categories; | 469 | tAD = ad.mData->categories; |
422 | for ( iii = 0; iii < tAD.count(); ++iii) | 470 | for ( iii = 0; iii < tAD.count(); ++iii) |
423 | if ( !t.contains(tAD[iii] ) ) | 471 | if ( !t.contains(tAD[iii] ) ) |
424 | mData->categories.append( tAD[iii] ); | 472 | mData->categories.append( tAD[iii] ); |
425 | } | 473 | } |
426 | QStringList::ConstIterator it; | 474 | QStringList::ConstIterator it; |
427 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 475 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
428 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 476 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
429 | bool found = false; | 477 | bool found = false; |
430 | QStringList::ConstIterator itL; | 478 | QStringList::ConstIterator itL; |
@@ -1560,259 +1608,269 @@ void Addressee::setNameFromString( const QString &str ) | |||
1560 | while ( leftOffset < rightOffset ) { | 1608 | while ( leftOffset < rightOffset ) { |
1561 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1609 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1562 | leftOffset++; | 1610 | leftOffset++; |
1563 | } | 1611 | } |
1564 | setAdditionalName( additionalName ); | 1612 | setAdditionalName( additionalName ); |
1565 | } | 1613 | } |
1566 | } | 1614 | } |
1567 | 1615 | ||
1568 | QString Addressee::realName() const | 1616 | QString Addressee::realName() const |
1569 | { | 1617 | { |
1570 | if ( !formattedName().isEmpty() ) | 1618 | if ( !formattedName().isEmpty() ) |
1571 | return formattedName(); | 1619 | return formattedName(); |
1572 | 1620 | ||
1573 | QString n = assembledName(); | 1621 | QString n = assembledName(); |
1574 | 1622 | ||
1575 | if ( n.isEmpty() ) | 1623 | if ( n.isEmpty() ) |
1576 | n = name(); | 1624 | n = name(); |
1577 | if ( n.isEmpty() ) | 1625 | if ( n.isEmpty() ) |
1578 | n = organization(); | 1626 | n = organization(); |
1579 | return n; | 1627 | return n; |
1580 | } | 1628 | } |
1581 | 1629 | ||
1582 | QString Addressee::assembledName() const | 1630 | QString Addressee::assembledName() const |
1583 | { | 1631 | { |
1584 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1632 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1585 | familyName() + " " + suffix(); | 1633 | familyName() + " " + suffix(); |
1586 | 1634 | ||
1587 | return name.simplifyWhiteSpace(); | 1635 | return name.simplifyWhiteSpace(); |
1588 | } | 1636 | } |
1589 | 1637 | ||
1590 | QString Addressee::fullEmail( const QString &email ) const | 1638 | QString Addressee::fullEmail( const QString &email ) const |
1591 | { | 1639 | { |
1592 | QString e; | 1640 | QString e; |
1593 | if ( email.isNull() ) { | 1641 | if ( email.isNull() ) { |
1594 | e = preferredEmail(); | 1642 | e = preferredEmail(); |
1595 | } else { | 1643 | } else { |
1596 | e = email; | 1644 | e = email; |
1597 | } | 1645 | } |
1598 | if ( e.isEmpty() ) return QString::null; | 1646 | if ( e.isEmpty() ) return QString::null; |
1599 | 1647 | ||
1600 | QString text; | 1648 | QString text; |
1601 | if ( realName().isEmpty() ) | 1649 | if ( realName().isEmpty() ) |
1602 | text = e; | 1650 | text = e; |
1603 | else | 1651 | else |
1604 | text = assembledName() + " <" + e + ">"; | 1652 | text = assembledName() + " <" + e + ">"; |
1605 | 1653 | ||
1606 | return text; | 1654 | return text; |
1607 | } | 1655 | } |
1608 | 1656 | ||
1609 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1657 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1610 | { | 1658 | { |
1611 | detach(); | 1659 | detach(); |
1612 | 1660 | ||
1613 | QStringList::Iterator it = mData->emails.find( email ); | 1661 | QStringList::Iterator it = mData->emails.find( email ); |
1614 | 1662 | ||
1615 | if ( it != mData->emails.end() ) { | 1663 | if ( it != mData->emails.end() ) { |
1616 | if ( !preferred || it == mData->emails.begin() ) return; | 1664 | if ( !preferred || it == mData->emails.begin() ) return; |
1617 | mData->emails.remove( it ); | 1665 | mData->emails.remove( it ); |
1618 | mData->emails.prepend( email ); | 1666 | mData->emails.prepend( email ); |
1619 | } else { | 1667 | } else { |
1620 | if ( preferred ) { | 1668 | if ( preferred ) { |
1621 | mData->emails.prepend( email ); | 1669 | mData->emails.prepend( email ); |
1622 | } else { | 1670 | } else { |
1623 | mData->emails.append( email ); | 1671 | mData->emails.append( email ); |
1624 | } | 1672 | } |
1625 | } | 1673 | } |
1626 | } | 1674 | } |
1627 | 1675 | ||
1628 | void Addressee::removeEmail( const QString &email ) | 1676 | void Addressee::removeEmail( const QString &email ) |
1629 | { | 1677 | { |
1630 | detach(); | 1678 | detach(); |
1631 | 1679 | ||
1632 | QStringList::Iterator it = mData->emails.find( email ); | 1680 | QStringList::Iterator it = mData->emails.find( email ); |
1633 | if ( it == mData->emails.end() ) return; | 1681 | if ( it == mData->emails.end() ) return; |
1634 | 1682 | ||
1635 | mData->emails.remove( it ); | 1683 | mData->emails.remove( it ); |
1636 | } | 1684 | } |
1637 | 1685 | ||
1638 | QString Addressee::preferredEmail() const | 1686 | QString Addressee::preferredEmail() const |
1639 | { | 1687 | { |
1640 | if ( mData->emails.count() == 0 ) return QString::null; | 1688 | if ( mData->emails.count() == 0 ) return QString::null; |
1641 | else return mData->emails.first(); | 1689 | else return mData->emails.first(); |
1642 | } | 1690 | } |
1643 | 1691 | ||
1644 | QStringList Addressee::emails() const | 1692 | QStringList Addressee::emails() const |
1645 | { | 1693 | { |
1646 | return mData->emails; | 1694 | return mData->emails; |
1647 | } | 1695 | } |
1648 | void Addressee::setEmails( const QStringList& emails ) { | 1696 | void Addressee::setEmails( const QStringList& emails ) { |
1649 | detach(); | 1697 | detach(); |
1650 | mData->emails = emails; | 1698 | mData->emails = emails; |
1651 | } | 1699 | } |
1652 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1700 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1653 | { | 1701 | { |
1654 | detach(); | 1702 | detach(); |
1655 | mData->empty = false; | 1703 | mData->empty = false; |
1656 | |||
1657 | PhoneNumber::List::Iterator it; | 1704 | PhoneNumber::List::Iterator it; |
1658 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1705 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1659 | if ( (*it).id() == phoneNumber.id() ) { | 1706 | if ( (*it).id() == phoneNumber.id() ) { |
1660 | *it = phoneNumber; | 1707 | *it = phoneNumber; |
1661 | return; | 1708 | return; |
1662 | } | 1709 | } |
1663 | } | 1710 | } |
1664 | mData->phoneNumbers.append( phoneNumber ); | 1711 | mData->phoneNumbers.append( phoneNumber ); |
1665 | } | 1712 | } |
1666 | 1713 | ||
1667 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1714 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1668 | { | 1715 | { |
1669 | detach(); | 1716 | detach(); |
1670 | 1717 | ||
1671 | PhoneNumber::List::Iterator it; | 1718 | PhoneNumber::List::Iterator it; |
1672 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1719 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1673 | if ( (*it).id() == phoneNumber.id() ) { | 1720 | if ( (*it).id() == phoneNumber.id() ) { |
1674 | mData->phoneNumbers.remove( it ); | 1721 | mData->phoneNumbers.remove( it ); |
1675 | return; | 1722 | return; |
1676 | } | 1723 | } |
1677 | } | 1724 | } |
1678 | } | 1725 | } |
1679 | 1726 | ||
1680 | PhoneNumber Addressee::phoneNumber( int type ) const | 1727 | PhoneNumber Addressee::phoneNumber( int type ) const |
1681 | { | 1728 | { |
1682 | PhoneNumber phoneNumber( "", type ); | 1729 | PhoneNumber phoneNumber( "", type ); |
1683 | PhoneNumber::List::ConstIterator it; | 1730 | PhoneNumber::List::ConstIterator it; |
1684 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1731 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1685 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1732 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1686 | if ( (*it).type() & PhoneNumber::Pref ) | 1733 | if ( (*it).type() & PhoneNumber::Pref ) |
1687 | return (*it); | 1734 | return (*it); |
1688 | else if ( phoneNumber.number().isEmpty() ) | 1735 | else if ( phoneNumber.number().isEmpty() ) |
1689 | phoneNumber = (*it); | 1736 | phoneNumber = (*it); |
1690 | } | 1737 | } |
1691 | } | 1738 | } |
1692 | 1739 | ||
1693 | return phoneNumber; | 1740 | return phoneNumber; |
1694 | } | 1741 | } |
1695 | 1742 | ||
1696 | PhoneNumber::List Addressee::phoneNumbers() const | 1743 | PhoneNumber::List Addressee::phoneNumbers() const |
1697 | { | 1744 | { |
1698 | return mData->phoneNumbers; | 1745 | return mData->phoneNumbers; |
1699 | } | 1746 | } |
1700 | 1747 | ||
1701 | int Addressee::hasPhoneNumberType( int type ) | 1748 | int Addressee::hasPhoneNumberType( int type ) |
1702 | { | 1749 | { |
1703 | int retval = 0; | 1750 | int retval = 0; |
1704 | PhoneNumber::List::ConstIterator it; | 1751 | PhoneNumber::List::ConstIterator it; |
1705 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1752 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1706 | if ( (*it).type() == type ) | 1753 | if ( (*it).type() == type ) |
1707 | ++retval; | 1754 | ++retval; |
1708 | } | 1755 | } |
1709 | return retval; | 1756 | return retval; |
1710 | } | 1757 | } |
1711 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1758 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1712 | { | 1759 | { |
1713 | PhoneNumber::List list; | 1760 | PhoneNumber::List list; |
1714 | 1761 | ||
1715 | PhoneNumber::List::ConstIterator it; | 1762 | PhoneNumber::List::ConstIterator it; |
1716 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1763 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1717 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1764 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1718 | list.append( *it ); | 1765 | list.append( *it ); |
1719 | } | 1766 | } |
1720 | } | 1767 | } |
1721 | return list; | 1768 | return list; |
1722 | } | 1769 | } |
1770 | QString Addressee::phoneNumberString( int type ) const | ||
1771 | { | ||
1772 | |||
1773 | PhoneNumber::List::ConstIterator it; | ||
1774 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | ||
1775 | if ((*it).type() == type ) { | ||
1776 | return ( *it ).number(); | ||
1777 | } | ||
1778 | } | ||
1779 | return ""; | ||
1780 | } | ||
1723 | 1781 | ||
1724 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1782 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1725 | { | 1783 | { |
1726 | PhoneNumber::List::ConstIterator it; | 1784 | PhoneNumber::List::ConstIterator it; |
1727 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1785 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1728 | if ( (*it).id() == id ) { | 1786 | if ( (*it).id() == id ) { |
1729 | return *it; | 1787 | return *it; |
1730 | } | 1788 | } |
1731 | } | 1789 | } |
1732 | return PhoneNumber(); | 1790 | return PhoneNumber(); |
1733 | } | 1791 | } |
1734 | 1792 | ||
1735 | void Addressee::insertKey( const Key &key ) | 1793 | void Addressee::insertKey( const Key &key ) |
1736 | { | 1794 | { |
1737 | detach(); | 1795 | detach(); |
1738 | mData->empty = false; | 1796 | mData->empty = false; |
1739 | 1797 | ||
1740 | Key::List::Iterator it; | 1798 | Key::List::Iterator it; |
1741 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1799 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1742 | if ( (*it).id() == key.id() ) { | 1800 | if ( (*it).id() == key.id() ) { |
1743 | *it = key; | 1801 | *it = key; |
1744 | return; | 1802 | return; |
1745 | } | 1803 | } |
1746 | } | 1804 | } |
1747 | mData->keys.append( key ); | 1805 | mData->keys.append( key ); |
1748 | } | 1806 | } |
1749 | 1807 | ||
1750 | void Addressee::removeKey( const Key &key ) | 1808 | void Addressee::removeKey( const Key &key ) |
1751 | { | 1809 | { |
1752 | detach(); | 1810 | detach(); |
1753 | 1811 | ||
1754 | Key::List::Iterator it; | 1812 | Key::List::Iterator it; |
1755 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1813 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1756 | if ( (*it).id() == key.id() ) { | 1814 | if ( (*it).id() == key.id() ) { |
1757 | mData->keys.remove( key ); | 1815 | mData->keys.remove( key ); |
1758 | return; | 1816 | return; |
1759 | } | 1817 | } |
1760 | } | 1818 | } |
1761 | } | 1819 | } |
1762 | 1820 | ||
1763 | Key Addressee::key( int type, QString customTypeString ) const | 1821 | Key Addressee::key( int type, QString customTypeString ) const |
1764 | { | 1822 | { |
1765 | Key::List::ConstIterator it; | 1823 | Key::List::ConstIterator it; |
1766 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1824 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1767 | if ( (*it).type() == type ) { | 1825 | if ( (*it).type() == type ) { |
1768 | if ( type == Key::Custom ) { | 1826 | if ( type == Key::Custom ) { |
1769 | if ( customTypeString.isEmpty() ) { | 1827 | if ( customTypeString.isEmpty() ) { |
1770 | return *it; | 1828 | return *it; |
1771 | } else { | 1829 | } else { |
1772 | if ( (*it).customTypeString() == customTypeString ) | 1830 | if ( (*it).customTypeString() == customTypeString ) |
1773 | return (*it); | 1831 | return (*it); |
1774 | } | 1832 | } |
1775 | } else { | 1833 | } else { |
1776 | return *it; | 1834 | return *it; |
1777 | } | 1835 | } |
1778 | } | 1836 | } |
1779 | } | 1837 | } |
1780 | return Key( QString(), type ); | 1838 | return Key( QString(), type ); |
1781 | } | 1839 | } |
1782 | void Addressee::setKeys( const Key::List& list ) { | 1840 | void Addressee::setKeys( const Key::List& list ) { |
1783 | detach(); | 1841 | detach(); |
1784 | mData->keys = list; | 1842 | mData->keys = list; |
1785 | } | 1843 | } |
1786 | 1844 | ||
1787 | Key::List Addressee::keys() const | 1845 | Key::List Addressee::keys() const |
1788 | { | 1846 | { |
1789 | return mData->keys; | 1847 | return mData->keys; |
1790 | } | 1848 | } |
1791 | 1849 | ||
1792 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1850 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1793 | { | 1851 | { |
1794 | Key::List list; | 1852 | Key::List list; |
1795 | 1853 | ||
1796 | Key::List::ConstIterator it; | 1854 | Key::List::ConstIterator it; |
1797 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1855 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1798 | if ( (*it).type() == type ) { | 1856 | if ( (*it).type() == type ) { |
1799 | if ( type == Key::Custom ) { | 1857 | if ( type == Key::Custom ) { |
1800 | if ( customTypeString.isEmpty() ) { | 1858 | if ( customTypeString.isEmpty() ) { |
1801 | list.append(*it); | 1859 | list.append(*it); |
1802 | } else { | 1860 | } else { |
1803 | if ( (*it).customTypeString() == customTypeString ) | 1861 | if ( (*it).customTypeString() == customTypeString ) |
1804 | list.append(*it); | 1862 | list.append(*it); |
1805 | } | 1863 | } |
1806 | } else { | 1864 | } else { |
1807 | list.append(*it); | 1865 | list.append(*it); |
1808 | } | 1866 | } |
1809 | } | 1867 | } |
1810 | } | 1868 | } |
1811 | return list; | 1869 | return list; |
1812 | } | 1870 | } |
1813 | 1871 | ||
1814 | Key Addressee::findKey( const QString &id ) const | 1872 | Key Addressee::findKey( const QString &id ) const |
1815 | { | 1873 | { |
1816 | Key::List::ConstIterator it; | 1874 | Key::List::ConstIterator it; |
1817 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1875 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1818 | if ( (*it).id() == id ) { | 1876 | if ( (*it).id() == id ) { |
@@ -1832,193 +1890,204 @@ void Addressee::dump() const | |||
1832 | return; | 1890 | return; |
1833 | #if 0 | 1891 | #if 0 |
1834 | kdDebug(5700) << "Addressee {" << endl; | 1892 | kdDebug(5700) << "Addressee {" << endl; |
1835 | 1893 | ||
1836 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1894 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1837 | 1895 | ||
1838 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1896 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1839 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1897 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1840 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1898 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1841 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1899 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1842 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1900 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1843 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1901 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1844 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1902 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1845 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1903 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1846 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1904 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1847 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1905 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1848 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1906 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1849 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1907 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1850 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1908 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1851 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1909 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1852 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1910 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1853 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1911 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1854 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1912 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1855 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1913 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1856 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1914 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1857 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1915 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1858 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1916 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1859 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1917 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1860 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1918 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1861 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1919 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1862 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1920 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1863 | 1921 | ||
1864 | kdDebug(5700) << " Emails {" << endl; | 1922 | kdDebug(5700) << " Emails {" << endl; |
1865 | QStringList e = emails(); | 1923 | QStringList e = emails(); |
1866 | QStringList::ConstIterator it; | 1924 | QStringList::ConstIterator it; |
1867 | for( it = e.begin(); it != e.end(); ++it ) { | 1925 | for( it = e.begin(); it != e.end(); ++it ) { |
1868 | kdDebug(5700) << " " << (*it) << endl; | 1926 | kdDebug(5700) << " " << (*it) << endl; |
1869 | } | 1927 | } |
1870 | kdDebug(5700) << " }" << endl; | 1928 | kdDebug(5700) << " }" << endl; |
1871 | 1929 | ||
1872 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1930 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1873 | PhoneNumber::List p = phoneNumbers(); | 1931 | PhoneNumber::List p = phoneNumbers(); |
1874 | PhoneNumber::List::ConstIterator it2; | 1932 | PhoneNumber::List::ConstIterator it2; |
1875 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1933 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1876 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1934 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1877 | } | 1935 | } |
1878 | kdDebug(5700) << " }" << endl; | 1936 | kdDebug(5700) << " }" << endl; |
1879 | 1937 | ||
1880 | Address::List a = addresses(); | 1938 | Address::List a = addresses(); |
1881 | Address::List::ConstIterator it3; | 1939 | Address::List::ConstIterator it3; |
1882 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1940 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1883 | (*it3).dump(); | 1941 | (*it3).dump(); |
1884 | } | 1942 | } |
1885 | 1943 | ||
1886 | kdDebug(5700) << " Keys {" << endl; | 1944 | kdDebug(5700) << " Keys {" << endl; |
1887 | Key::List k = keys(); | 1945 | Key::List k = keys(); |
1888 | Key::List::ConstIterator it4; | 1946 | Key::List::ConstIterator it4; |
1889 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1947 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1890 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1948 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1891 | " Key: " << (*it4).textData() << | 1949 | " Key: " << (*it4).textData() << |
1892 | " CustomString: " << (*it4).customTypeString() << endl; | 1950 | " CustomString: " << (*it4).customTypeString() << endl; |
1893 | } | 1951 | } |
1894 | kdDebug(5700) << " }" << endl; | 1952 | kdDebug(5700) << " }" << endl; |
1895 | 1953 | ||
1896 | kdDebug(5700) << "}" << endl; | 1954 | kdDebug(5700) << "}" << endl; |
1897 | #endif | 1955 | #endif |
1898 | } | 1956 | } |
1899 | 1957 | ||
1900 | 1958 | ||
1901 | void Addressee::insertAddress( const Address &address ) | 1959 | void Addressee::insertAddress( const Address &address ) |
1902 | { | 1960 | { |
1903 | detach(); | 1961 | detach(); |
1904 | mData->empty = false; | 1962 | mData->empty = false; |
1905 | 1963 | ||
1906 | Address::List::Iterator it; | 1964 | Address::List::Iterator it; |
1907 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1965 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1908 | if ( (*it).id() == address.id() ) { | 1966 | if ( (*it).id() == address.id() ) { |
1909 | *it = address; | 1967 | *it = address; |
1910 | return; | 1968 | return; |
1911 | } | 1969 | } |
1912 | } | 1970 | } |
1913 | mData->addresses.append( address ); | 1971 | mData->addresses.append( address ); |
1914 | } | 1972 | } |
1915 | 1973 | ||
1916 | void Addressee::removeAddress( const Address &address ) | 1974 | void Addressee::removeAddress( const Address &address ) |
1917 | { | 1975 | { |
1918 | detach(); | 1976 | detach(); |
1919 | 1977 | ||
1920 | Address::List::Iterator it; | 1978 | Address::List::Iterator it; |
1921 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1979 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1922 | if ( (*it).id() == address.id() ) { | 1980 | if ( (*it).id() == address.id() ) { |
1923 | mData->addresses.remove( it ); | 1981 | mData->addresses.remove( it ); |
1924 | return; | 1982 | return; |
1925 | } | 1983 | } |
1926 | } | 1984 | } |
1927 | } | 1985 | } |
1928 | 1986 | Address Addressee::otherAddress() const | |
1987 | { | ||
1988 | Address::List::ConstIterator it; | ||
1989 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | ||
1990 | if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) ) | ||
1991 | continue; | ||
1992 | if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) ) | ||
1993 | continue; | ||
1994 | return (*it); | ||
1995 | } | ||
1996 | return Address(); | ||
1997 | } | ||
1929 | Address Addressee::address( int type ) const | 1998 | Address Addressee::address( int type ) const |
1930 | { | 1999 | { |
1931 | Address address( type ); | 2000 | Address address( type ); |
1932 | Address::List::ConstIterator it; | 2001 | Address::List::ConstIterator it; |
1933 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2002 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1934 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 2003 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1935 | if ( (*it).type() & Address::Pref ) | 2004 | if ( (*it).type() & Address::Pref ) |
1936 | return (*it); | 2005 | return (*it); |
1937 | else if ( address.isEmpty() ) | 2006 | else if ( address.isEmpty() ) |
1938 | address = (*it); | 2007 | address = (*it); |
1939 | } | 2008 | } |
1940 | } | 2009 | } |
1941 | 2010 | ||
1942 | return address; | 2011 | return address; |
1943 | } | 2012 | } |
1944 | 2013 | ||
1945 | Address::List Addressee::addresses() const | 2014 | Address::List Addressee::addresses() const |
1946 | { | 2015 | { |
1947 | return mData->addresses; | 2016 | return mData->addresses; |
1948 | } | 2017 | } |
1949 | 2018 | ||
1950 | Address::List Addressee::addresses( int type ) const | 2019 | Address::List Addressee::addresses( int type ) const |
1951 | { | 2020 | { |
1952 | Address::List list; | 2021 | Address::List list; |
1953 | 2022 | ||
1954 | Address::List::ConstIterator it; | 2023 | Address::List::ConstIterator it; |
1955 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2024 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1956 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 2025 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1957 | list.append( *it ); | 2026 | list.append( *it ); |
1958 | } | 2027 | } |
1959 | } | 2028 | } |
1960 | 2029 | ||
1961 | return list; | 2030 | return list; |
1962 | } | 2031 | } |
1963 | 2032 | ||
1964 | Address Addressee::findAddress( const QString &id ) const | 2033 | Address Addressee::findAddress( const QString &id ) const |
1965 | { | 2034 | { |
1966 | Address::List::ConstIterator it; | 2035 | Address::List::ConstIterator it; |
1967 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2036 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1968 | if ( (*it).id() == id ) { | 2037 | if ( (*it).id() == id ) { |
1969 | return *it; | 2038 | return *it; |
1970 | } | 2039 | } |
1971 | } | 2040 | } |
1972 | return Address(); | 2041 | return Address(); |
1973 | } | 2042 | } |
1974 | 2043 | ||
1975 | void Addressee::insertCategory( const QString &c ) | 2044 | void Addressee::insertCategory( const QString &c ) |
1976 | { | 2045 | { |
1977 | detach(); | 2046 | detach(); |
1978 | mData->empty = false; | 2047 | mData->empty = false; |
1979 | 2048 | ||
1980 | if ( mData->categories.contains( c ) ) return; | 2049 | if ( mData->categories.contains( c ) ) return; |
1981 | 2050 | ||
1982 | mData->categories.append( c ); | 2051 | mData->categories.append( c ); |
1983 | } | 2052 | } |
1984 | 2053 | ||
1985 | void Addressee::removeCategory( const QString &c ) | 2054 | void Addressee::removeCategory( const QString &c ) |
1986 | { | 2055 | { |
1987 | detach(); | 2056 | detach(); |
1988 | 2057 | ||
1989 | QStringList::Iterator it = mData->categories.find( c ); | 2058 | QStringList::Iterator it = mData->categories.find( c ); |
1990 | if ( it == mData->categories.end() ) return; | 2059 | if ( it == mData->categories.end() ) return; |
1991 | 2060 | ||
1992 | mData->categories.remove( it ); | 2061 | mData->categories.remove( it ); |
1993 | } | 2062 | } |
1994 | 2063 | ||
1995 | bool Addressee::hasCategory( const QString &c ) const | 2064 | bool Addressee::hasCategory( const QString &c ) const |
1996 | { | 2065 | { |
1997 | return ( mData->categories.contains( c ) ); | 2066 | return ( mData->categories.contains( c ) ); |
1998 | } | 2067 | } |
1999 | 2068 | ||
2000 | void Addressee::setCategories( const QStringList &c ) | 2069 | void Addressee::setCategories( const QStringList &c ) |
2001 | { | 2070 | { |
2002 | detach(); | 2071 | detach(); |
2003 | mData->empty = false; | 2072 | mData->empty = false; |
2004 | 2073 | ||
2005 | mData->categories = c; | 2074 | mData->categories = c; |
2006 | } | 2075 | } |
2007 | 2076 | ||
2008 | QStringList Addressee::categories() const | 2077 | QStringList Addressee::categories() const |
2009 | { | 2078 | { |
2010 | return mData->categories; | 2079 | return mData->categories; |
2011 | } | 2080 | } |
2012 | 2081 | ||
2013 | void Addressee::insertCustom( const QString &app, const QString &name, | 2082 | void Addressee::insertCustom( const QString &app, const QString &name, |
2014 | const QString &value ) | 2083 | const QString &value ) |
2015 | { | 2084 | { |
2016 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 2085 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
2017 | 2086 | ||
2018 | detach(); | 2087 | detach(); |
2019 | mData->empty = false; | 2088 | mData->empty = false; |
2020 | 2089 | ||
2021 | QString qualifiedName = app + "-" + name + ":"; | 2090 | QString qualifiedName = app + "-" + name + ":"; |
2022 | 2091 | ||
2023 | QStringList::Iterator it; | 2092 | QStringList::Iterator it; |
2024 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 2093 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
diff --git a/kabc/addressee.h b/kabc/addressee.h index aac78dc..0ea1803 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -25,192 +25,193 @@ Copyright (c) 2004 Ulf Schenk | |||
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <qvaluelist.h> | 36 | #include <qvaluelist.h> |
37 | 37 | ||
38 | #include <ksharedptr.h> | 38 | #include <ksharedptr.h> |
39 | #include <kurl.h> | 39 | #include <kurl.h> |
40 | 40 | ||
41 | #include "address.h" | 41 | #include "address.h" |
42 | #include "agent.h" | 42 | #include "agent.h" |
43 | #include "geo.h" | 43 | #include "geo.h" |
44 | #include "key.h" | 44 | #include "key.h" |
45 | #include "phonenumber.h" | 45 | #include "phonenumber.h" |
46 | #include "picture.h" | 46 | #include "picture.h" |
47 | #include "secrecy.h" | 47 | #include "secrecy.h" |
48 | #include "sound.h" | 48 | #include "sound.h" |
49 | #include "timezone.h" | 49 | #include "timezone.h" |
50 | 50 | ||
51 | namespace KABC { | 51 | namespace KABC { |
52 | 52 | ||
53 | class Resource; | 53 | class Resource; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | @short address book entry | 56 | @short address book entry |
57 | 57 | ||
58 | This class represents an entry in the address book. | 58 | This class represents an entry in the address book. |
59 | 59 | ||
60 | The data of this class is implicitly shared. You can pass this class by value. | 60 | The data of this class is implicitly shared. You can pass this class by value. |
61 | 61 | ||
62 | If you need the name of a field for presenting it to the user you should use | 62 | If you need the name of a field for presenting it to the user you should use |
63 | the functions ending in Label(). They return a translated string which can be | 63 | the functions ending in Label(). They return a translated string which can be |
64 | used as label for the corresponding field. | 64 | used as label for the corresponding field. |
65 | 65 | ||
66 | About the name fields: | 66 | About the name fields: |
67 | 67 | ||
68 | givenName() is the first name and familyName() the last name. In some | 68 | givenName() is the first name and familyName() the last name. In some |
69 | countries the family name comes first, that's the reason for the | 69 | countries the family name comes first, that's the reason for the |
70 | naming. formattedName() is the full name with the correct formatting. | 70 | naming. formattedName() is the full name with the correct formatting. |
71 | It is used as an override, when the correct formatting can't be generated | 71 | It is used as an override, when the correct formatting can't be generated |
72 | from the other name fields automatically. | 72 | from the other name fields automatically. |
73 | 73 | ||
74 | realName() returns a fully formatted name(). It uses formattedName, if set, | 74 | realName() returns a fully formatted name(). It uses formattedName, if set, |
75 | otherwise it constucts the name from the name fields. As fallback, if | 75 | otherwise it constucts the name from the name fields. As fallback, if |
76 | nothing else is set it uses name(). | 76 | nothing else is set it uses name(). |
77 | 77 | ||
78 | name() is the NAME type of RFC2426. It can be used as internal name for the | 78 | name() is the NAME type of RFC2426. It can be used as internal name for the |
79 | data enty, but shouldn't be used for displaying the data to the user. | 79 | data enty, but shouldn't be used for displaying the data to the user. |
80 | */ | 80 | */ |
81 | class Addressee | 81 | class Addressee |
82 | { | 82 | { |
83 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 83 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
84 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 84 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
85 | 85 | ||
86 | public: | 86 | public: |
87 | typedef QValueList<Addressee> List; | 87 | typedef QValueList<Addressee> List; |
88 | 88 | ||
89 | /** | 89 | /** |
90 | Construct an empty address book entry. | 90 | Construct an empty address book entry. |
91 | */ | 91 | */ |
92 | Addressee(); | 92 | Addressee(); |
93 | ~Addressee(); | 93 | ~Addressee(); |
94 | 94 | ||
95 | Addressee( const Addressee & ); | 95 | Addressee( const Addressee & ); |
96 | Addressee &operator=( const Addressee & ); | 96 | Addressee &operator=( const Addressee & ); |
97 | 97 | ||
98 | bool operator==( const Addressee & ) const; | 98 | bool operator==( const Addressee & ) const; |
99 | bool operator!=( const Addressee & ) const; | 99 | bool operator!=( const Addressee & ) const; |
100 | // sync stuff | 100 | // sync stuff |
101 | void setTempSyncStat(int id); | 101 | void setTempSyncStat(int id); |
102 | int tempSyncStat() const; | 102 | int tempSyncStat() const; |
103 | void setIDStr( const QString & ); | 103 | void setIDStr( const QString & ); |
104 | const QString IDStr() const; | 104 | const QString IDStr() const; |
105 | void setID( const QString &, const QString & ); | 105 | void setID( const QString &, const QString & ); |
106 | const QString getID( const QString & ) const; | 106 | const QString getID( const QString & ) const; |
107 | void setCsum( const QString &, const QString & ); | 107 | void setCsum( const QString &, const QString & ); |
108 | const QString getCsum( const QString & ) const ; | 108 | const QString getCsum( const QString & ) const ; |
109 | void removeID(const QString &); | 109 | void removeID(const QString &); |
110 | void computeCsum(const QString &dev); | 110 | void computeCsum(const QString &dev); |
111 | ulong getCsum4List( const QStringList & attList); | 111 | ulong getCsum4List( const QStringList & attList); |
112 | /** | 112 | /** |
113 | Return, if the address book entry is empty. | 113 | Return, if the address book entry is empty. |
114 | */ | 114 | */ |
115 | bool isEmpty() const; | 115 | bool isEmpty() const; |
116 | void setExternalUID( const QString &id ); | 116 | void setExternalUID( const QString &id ); |
117 | const QString externalUID() const; | 117 | const QString externalUID() const; |
118 | void setOriginalExternalUID( const QString &id ); | 118 | void setOriginalExternalUID( const QString &id ); |
119 | QString originalExternalUID() const; | 119 | QString originalExternalUID() const; |
120 | void mergeContact( const Addressee& ad, bool isSubSet ); | 120 | void mergeContact( const Addressee& ad, bool isSubSet ); |
121 | void mergeOLContact( const Addressee& ad ); | ||
121 | void simplifyEmails(); | 122 | void simplifyEmails(); |
122 | void simplifyAddresses(); | 123 | void simplifyAddresses(); |
123 | void simplifyPhoneNumbers(); | 124 | void simplifyPhoneNumbers(); |
124 | void simplifyPhoneNumberTypes(); | 125 | void simplifyPhoneNumberTypes(); |
125 | void makePhoneNumbersOLcompatible(); | 126 | void makePhoneNumbersOLcompatible(); |
126 | int hasPhoneNumberType( int type ); | 127 | int hasPhoneNumberType( int type ); |
127 | bool removeVoice(); | 128 | bool removeVoice(); |
128 | bool containsAdr(const Addressee& addr ); | 129 | bool containsAdr(const Addressee& addr ); |
129 | 130 | ||
130 | /** | 131 | /** |
131 | Set unique identifier. | 132 | Set unique identifier. |
132 | */ | 133 | */ |
133 | void setUid( const QString &uid ); | 134 | void setUid( const QString &uid ); |
134 | /** | 135 | /** |
135 | Return unique identifier. | 136 | Return unique identifier. |
136 | */ | 137 | */ |
137 | const QString uid() const; | 138 | const QString uid() const; |
138 | /** | 139 | /** |
139 | Return translated label for uid field. | 140 | Return translated label for uid field. |
140 | */ | 141 | */ |
141 | static QString uidLabel(); | 142 | static QString uidLabel(); |
142 | 143 | ||
143 | /** | 144 | /** |
144 | Set name. | 145 | Set name. |
145 | */ | 146 | */ |
146 | void setName( const QString &name ); | 147 | void setName( const QString &name ); |
147 | /** | 148 | /** |
148 | Return name. | 149 | Return name. |
149 | */ | 150 | */ |
150 | QString name() const; | 151 | QString name() const; |
151 | /** | 152 | /** |
152 | Return translated label for name field. | 153 | Return translated label for name field. |
153 | */ | 154 | */ |
154 | static QString nameLabel(); | 155 | static QString nameLabel(); |
155 | 156 | ||
156 | /** | 157 | /** |
157 | Set formatted name. | 158 | Set formatted name. |
158 | */ | 159 | */ |
159 | void setFormattedName( const QString &formattedName ); | 160 | void setFormattedName( const QString &formattedName ); |
160 | /** | 161 | /** |
161 | Return formatted name. | 162 | Return formatted name. |
162 | */ | 163 | */ |
163 | QString formattedName() const; | 164 | QString formattedName() const; |
164 | /** | 165 | /** |
165 | Return translated label for formattedName field. | 166 | Return translated label for formattedName field. |
166 | */ | 167 | */ |
167 | static QString formattedNameLabel(); | 168 | static QString formattedNameLabel(); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | Set family name. | 171 | Set family name. |
171 | */ | 172 | */ |
172 | void setFamilyName( const QString &familyName ); | 173 | void setFamilyName( const QString &familyName ); |
173 | /** | 174 | /** |
174 | Return family name. | 175 | Return family name. |
175 | */ | 176 | */ |
176 | QString familyName() const; | 177 | QString familyName() const; |
177 | /** | 178 | /** |
178 | Return translated label for familyName field. | 179 | Return translated label for familyName field. |
179 | */ | 180 | */ |
180 | static QString familyNameLabel(); | 181 | static QString familyNameLabel(); |
181 | 182 | ||
182 | /** | 183 | /** |
183 | Set given name. | 184 | Set given name. |
184 | */ | 185 | */ |
185 | void setGivenName( const QString &givenName ); | 186 | void setGivenName( const QString &givenName ); |
186 | /** | 187 | /** |
187 | Return given name. | 188 | Return given name. |
188 | */ | 189 | */ |
189 | QString givenName() const; | 190 | QString givenName() const; |
190 | /** | 191 | /** |
191 | Return translated label for givenName field. | 192 | Return translated label for givenName field. |
192 | */ | 193 | */ |
193 | static QString givenNameLabel(); | 194 | static QString givenNameLabel(); |
194 | 195 | ||
195 | /** | 196 | /** |
196 | Set additional names. | 197 | Set additional names. |
197 | */ | 198 | */ |
198 | void setAdditionalName( const QString &additionalName ); | 199 | void setAdditionalName( const QString &additionalName ); |
199 | /** | 200 | /** |
200 | Return additional names. | 201 | Return additional names. |
201 | */ | 202 | */ |
202 | QString additionalName() const; | 203 | QString additionalName() const; |
203 | /** | 204 | /** |
204 | Return translated label for additionalName field. | 205 | Return translated label for additionalName field. |
205 | */ | 206 | */ |
206 | static QString additionalNameLabel(); | 207 | static QString additionalNameLabel(); |
207 | 208 | ||
208 | /** | 209 | /** |
209 | Set honorific prefixes. | 210 | Set honorific prefixes. |
210 | */ | 211 | */ |
211 | void setPrefix( const QString &prefix ); | 212 | void setPrefix( const QString &prefix ); |
212 | /** | 213 | /** |
213 | Return honorific prefixes. | 214 | Return honorific prefixes. |
214 | */ | 215 | */ |
215 | QString prefix() const; | 216 | QString prefix() const; |
216 | /** | 217 | /** |
@@ -554,277 +555,278 @@ class Addressee | |||
554 | Return sound. | 555 | Return sound. |
555 | */ | 556 | */ |
556 | Sound sound() const; | 557 | Sound sound() const; |
557 | /** | 558 | /** |
558 | Return translated label for sound field. | 559 | Return translated label for sound field. |
559 | */ | 560 | */ |
560 | static QString soundLabel(); | 561 | static QString soundLabel(); |
561 | 562 | ||
562 | /** | 563 | /** |
563 | Set agent. | 564 | Set agent. |
564 | */ | 565 | */ |
565 | void setAgent( const Agent &agent ); | 566 | void setAgent( const Agent &agent ); |
566 | /** | 567 | /** |
567 | Return agent. | 568 | Return agent. |
568 | */ | 569 | */ |
569 | Agent agent() const; | 570 | Agent agent() const; |
570 | /** | 571 | /** |
571 | Return translated label for agent field. | 572 | Return translated label for agent field. |
572 | */ | 573 | */ |
573 | static QString agentLabel(); | 574 | static QString agentLabel(); |
574 | 575 | ||
575 | /** | 576 | /** |
576 | Set name fields by parsing the given string and trying to associate the | 577 | Set name fields by parsing the given string and trying to associate the |
577 | parts of the string with according fields. This function should probably | 578 | parts of the string with according fields. This function should probably |
578 | be a bit more clever. | 579 | be a bit more clever. |
579 | */ | 580 | */ |
580 | void setNameFromString( const QString & ); | 581 | void setNameFromString( const QString & ); |
581 | 582 | ||
582 | /** | 583 | /** |
583 | Return the name of the addressee. This is calculated from all the name | 584 | Return the name of the addressee. This is calculated from all the name |
584 | fields. | 585 | fields. |
585 | */ | 586 | */ |
586 | QString realName() const; | 587 | QString realName() const; |
587 | 588 | ||
588 | /** | 589 | /** |
589 | Return the name that consists of all name parts. | 590 | Return the name that consists of all name parts. |
590 | */ | 591 | */ |
591 | QString assembledName() const; | 592 | QString assembledName() const; |
592 | 593 | ||
593 | /** | 594 | /** |
594 | Return email address including real name. | 595 | Return email address including real name. |
595 | 596 | ||
596 | @param email Email address to be used to construct the full email string. | 597 | @param email Email address to be used to construct the full email string. |
597 | If this is QString::null the preferred email address is used. | 598 | If this is QString::null the preferred email address is used. |
598 | */ | 599 | */ |
599 | QString fullEmail( const QString &email=QString::null ) const; | 600 | QString fullEmail( const QString &email=QString::null ) const; |
600 | 601 | ||
601 | /** | 602 | /** |
602 | Insert an email address. If the email address already exists in this | 603 | Insert an email address. If the email address already exists in this |
603 | addressee it is not duplicated. | 604 | addressee it is not duplicated. |
604 | 605 | ||
605 | @param email Email address | 606 | @param email Email address |
606 | @param preferred Set to true, if this is the preferred email address of | 607 | @param preferred Set to true, if this is the preferred email address of |
607 | the addressee. | 608 | the addressee. |
608 | */ | 609 | */ |
609 | void insertEmail( const QString &email, bool preferred=false ); | 610 | void insertEmail( const QString &email, bool preferred=false ); |
610 | 611 | ||
611 | /** | 612 | /** |
612 | Remove email address. If the email address doesn't exist, nothing happens. | 613 | Remove email address. If the email address doesn't exist, nothing happens. |
613 | */ | 614 | */ |
614 | void removeEmail( const QString &email ); | 615 | void removeEmail( const QString &email ); |
615 | 616 | ||
616 | /** | 617 | /** |
617 | Return preferred email address. This is the first email address or the | 618 | Return preferred email address. This is the first email address or the |
618 | last one added with @ref insertEmail() with a set preferred parameter. | 619 | last one added with @ref insertEmail() with a set preferred parameter. |
619 | */ | 620 | */ |
620 | QString preferredEmail() const; | 621 | QString preferredEmail() const; |
621 | 622 | ||
622 | /** | 623 | /** |
623 | Return list of all email addresses. | 624 | Return list of all email addresses. |
624 | */ | 625 | */ |
625 | QStringList emails() const; | 626 | QStringList emails() const; |
626 | 627 | ||
627 | /** | 628 | /** |
628 | Set the emails to @param. | 629 | Set the emails to @param. |
629 | The first email address gets the preferred one! | 630 | The first email address gets the preferred one! |
630 | @param list The list of email addresses. | 631 | @param list The list of email addresses. |
631 | */ | 632 | */ |
632 | void setEmails( const QStringList& list); | 633 | void setEmails( const QStringList& list); |
633 | 634 | ||
634 | /** | 635 | /** |
635 | Insert a phone number. If a phone number with the same id already exists | 636 | Insert a phone number. If a phone number with the same id already exists |
636 | in this addressee it is not duplicated. | 637 | in this addressee it is not duplicated. |
637 | */ | 638 | */ |
638 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 639 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
639 | 640 | ||
640 | /** | 641 | /** |
641 | Remove phone number. If no phone number with the given id exists for this | 642 | Remove phone number. If no phone number with the given id exists for this |
642 | addresse nothing happens. | 643 | addresse nothing happens. |
643 | */ | 644 | */ |
644 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 645 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
645 | 646 | ||
646 | /** | 647 | /** |
647 | Return phone number, which matches the given type. | 648 | Return phone number, which matches the given type. |
648 | */ | 649 | */ |
649 | PhoneNumber phoneNumber( int type ) const; | 650 | PhoneNumber phoneNumber( int type ) const; |
651 | QString phoneNumberString( int type ) const; | ||
650 | 652 | ||
651 | bool matchPhoneNumber( QRegExp* searchExp ) const; | 653 | bool matchPhoneNumber( QRegExp* searchExp ) const; |
652 | bool matchAddress( QRegExp* searchExp ) const; | 654 | bool matchAddress( QRegExp* searchExp ) const; |
653 | 655 | ||
654 | /** | 656 | /** |
655 | Return list of all phone numbers. | 657 | Return list of all phone numbers. |
656 | */ | 658 | */ |
657 | PhoneNumber::List phoneNumbers() const; | 659 | PhoneNumber::List phoneNumbers() const; |
658 | 660 | ||
659 | /** | 661 | /** |
660 | Return list of phone numbers with a special type. | 662 | Return list of phone numbers with a special type. |
661 | */ | 663 | */ |
662 | PhoneNumber::List phoneNumbers( int type ) const; | 664 | PhoneNumber::List phoneNumbers( int type ) const; |
663 | 665 | ||
664 | /** | 666 | /** |
665 | Return phone number with the given id. | 667 | Return phone number with the given id. |
666 | */ | 668 | */ |
667 | PhoneNumber findPhoneNumber( const QString &id ) const; | 669 | PhoneNumber findPhoneNumber( const QString &id ) const; |
668 | 670 | ||
669 | /** | 671 | /** |
670 | Insert a key. If a key with the same id already exists | 672 | Insert a key. If a key with the same id already exists |
671 | in this addressee it is not duplicated. | 673 | in this addressee it is not duplicated. |
672 | */ | 674 | */ |
673 | void insertKey( const Key &key ); | 675 | void insertKey( const Key &key ); |
674 | 676 | ||
675 | /** | 677 | /** |
676 | Remove a key. If no key with the given id exists for this | 678 | Remove a key. If no key with the given id exists for this |
677 | addresse nothing happens. | 679 | addresse nothing happens. |
678 | */ | 680 | */ |
679 | void removeKey( const Key &key ); | 681 | void removeKey( const Key &key ); |
680 | 682 | ||
681 | /** | 683 | /** |
682 | Return key, which matches the given type. | 684 | Return key, which matches the given type. |
683 | If @p type == Key::Custom you can specify a string | 685 | If @p type == Key::Custom you can specify a string |
684 | that should match. If you leave the string empty, the first | 686 | that should match. If you leave the string empty, the first |
685 | key with a custom value is returned. | 687 | key with a custom value is returned. |
686 | */ | 688 | */ |
687 | Key key( int type, QString customTypeString = QString::null ) const; | 689 | Key key( int type, QString customTypeString = QString::null ) const; |
688 | 690 | ||
689 | /** | 691 | /** |
690 | Return list of all keys. | 692 | Return list of all keys. |
691 | */ | 693 | */ |
692 | Key::List keys() const; | 694 | Key::List keys() const; |
693 | 695 | ||
694 | /** | 696 | /** |
695 | Set the list of keys | 697 | Set the list of keys |
696 | @param keys The keys to be set. | 698 | @param keys The keys to be set. |
697 | */ | 699 | */ |
698 | void setKeys( const Key::List& keys); | 700 | void setKeys( const Key::List& keys); |
699 | 701 | ||
700 | /** | 702 | /** |
701 | Return list of keys with a special type. | 703 | Return list of keys with a special type. |
702 | If @p type == Key::Custom you can specify a string | 704 | If @p type == Key::Custom you can specify a string |
703 | that should match. If you leave the string empty, all custom | 705 | that should match. If you leave the string empty, all custom |
704 | keys will be returned. | 706 | keys will be returned. |
705 | */ | 707 | */ |
706 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 708 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
707 | 709 | ||
708 | /** | 710 | /** |
709 | Return key with the given id. | 711 | Return key with the given id. |
710 | */ | 712 | */ |
711 | Key findKey( const QString &id ) const; | 713 | Key findKey( const QString &id ) const; |
712 | 714 | ||
713 | /** | 715 | /** |
714 | Insert an address. If an address with the same id already exists | 716 | Insert an address. If an address with the same id already exists |
715 | in this addressee it is not duplicated. | 717 | in this addressee it is not duplicated. |
716 | */ | 718 | */ |
717 | void insertAddress( const Address &address ); | 719 | void insertAddress( const Address &address ); |
718 | 720 | ||
719 | /** | 721 | /** |
720 | Remove address. If no address with the given id exists for this | 722 | Remove address. If no address with the given id exists for this |
721 | addresse nothing happens. | 723 | addresse nothing happens. |
722 | */ | 724 | */ |
723 | void removeAddress( const Address &address ); | 725 | void removeAddress( const Address &address ); |
724 | 726 | ||
725 | /** | 727 | /** |
726 | Return address, which matches the given type. | 728 | Return address, which matches the given type. |
727 | */ | 729 | */ |
728 | Address address( int type ) const; | 730 | Address address( int type ) const; |
729 | 731 | ||
730 | /** | 732 | /** |
731 | Return list of all addresses. | 733 | Return list of all addresses. |
732 | */ | 734 | */ |
733 | Address::List addresses() const; | 735 | Address::List addresses() const; |
734 | 736 | Address otherAddress() const; | |
735 | /** | 737 | /** |
736 | Return list of addresses with a special type. | 738 | Return list of addresses with a special type. |
737 | */ | 739 | */ |
738 | Address::List addresses( int type ) const; | 740 | Address::List addresses( int type ) const; |
739 | 741 | ||
740 | /** | 742 | /** |
741 | Return address with the given id. | 743 | Return address with the given id. |
742 | */ | 744 | */ |
743 | Address findAddress( const QString &id ) const; | 745 | Address findAddress( const QString &id ) const; |
744 | 746 | ||
745 | /** | 747 | /** |
746 | Insert category. If the category already exists it is not duplicated. | 748 | Insert category. If the category already exists it is not duplicated. |
747 | */ | 749 | */ |
748 | void insertCategory( const QString & ); | 750 | void insertCategory( const QString & ); |
749 | 751 | ||
750 | /** | 752 | /** |
751 | Remove category. | 753 | Remove category. |
752 | */ | 754 | */ |
753 | void removeCategory( const QString & ); | 755 | void removeCategory( const QString & ); |
754 | 756 | ||
755 | /** | 757 | /** |
756 | Return, if addressee has the given category. | 758 | Return, if addressee has the given category. |
757 | */ | 759 | */ |
758 | bool hasCategory( const QString & ) const; | 760 | bool hasCategory( const QString & ) const; |
759 | 761 | ||
760 | /** | 762 | /** |
761 | Set categories to given value. | 763 | Set categories to given value. |
762 | */ | 764 | */ |
763 | void setCategories( const QStringList & ); | 765 | void setCategories( const QStringList & ); |
764 | 766 | ||
765 | /** | 767 | /** |
766 | Return list of all set categories. | 768 | Return list of all set categories. |
767 | */ | 769 | */ |
768 | QStringList categories() const; | 770 | QStringList categories() const; |
769 | 771 | ||
770 | /** | 772 | /** |
771 | Insert custom entry. The entry is identified by the name of the inserting | 773 | Insert custom entry. The entry is identified by the name of the inserting |
772 | application and a unique name. If an entry with the given app and name | 774 | application and a unique name. If an entry with the given app and name |
773 | already exists its value is replaced with the new given value. | 775 | already exists its value is replaced with the new given value. |
774 | */ | 776 | */ |
775 | void insertCustom( const QString &app, const QString &name, | 777 | void insertCustom( const QString &app, const QString &name, |
776 | const QString &value ); | 778 | const QString &value ); |
777 | 779 | ||
778 | /** | 780 | /** |
779 | Remove custom entry. | 781 | Remove custom entry. |
780 | */ | 782 | */ |
781 | void removeCustom( const QString &app, const QString &name ); | 783 | void removeCustom( const QString &app, const QString &name ); |
782 | 784 | ||
783 | /** | 785 | /** |
784 | Return value of custom entry, identified by app and entry name. | 786 | Return value of custom entry, identified by app and entry name. |
785 | */ | 787 | */ |
786 | QString custom( const QString &app, const QString &name ) const; | 788 | QString custom( const QString &app, const QString &name ) const; |
787 | 789 | ||
788 | /** | 790 | /** |
789 | Set all custom entries. | 791 | Set all custom entries. |
790 | */ | 792 | */ |
791 | void setCustoms( const QStringList & ); | 793 | void setCustoms( const QStringList & ); |
792 | 794 | ||
793 | /** | 795 | /** |
794 | Return list of all custom entries. | 796 | Return list of all custom entries. |
795 | */ | 797 | */ |
796 | QStringList customs() const; | 798 | QStringList customs() const; |
797 | 799 | ||
798 | /** | 800 | /** |
799 | Parse full email address. The result is given back in fullName and email. | 801 | Parse full email address. The result is given back in fullName and email. |
800 | */ | 802 | */ |
801 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 803 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
802 | QString &email ); | 804 | QString &email ); |
803 | 805 | ||
804 | /** | 806 | /** |
805 | Debug output. | 807 | Debug output. |
806 | */ | 808 | */ |
807 | void dump() const; | 809 | void dump() const; |
808 | 810 | ||
809 | /** | 811 | /** |
810 | Returns string representation of the addressee. | 812 | Returns string representation of the addressee. |
811 | */ | 813 | */ |
812 | QString asString() const; | 814 | QString asString() const; |
813 | 815 | ||
814 | /** | 816 | /** |
815 | Set resource where the addressee is from. | 817 | Set resource where the addressee is from. |
816 | */ | 818 | */ |
817 | void setResource( Resource *resource ); | 819 | void setResource( Resource *resource ); |
818 | 820 | ||
819 | /** | 821 | /** |
820 | Return pointer to resource. | 822 | Return pointer to resource. |
821 | */ | 823 | */ |
822 | Resource *resource() const; | 824 | Resource *resource() const; |
823 | 825 | ||
824 | /** | 826 | /** |
825 | Return resourcelabel. | 827 | Return resourcelabel. |
826 | */ | 828 | */ |
827 | //US | 829 | //US |
828 | static QString resourceLabel(); | 830 | static QString resourceLabel(); |
829 | static QString categoryLabel(); | 831 | static QString categoryLabel(); |
830 | /** | 832 | /** |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 12b9b09..1752745 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -139,192 +139,216 @@ bool PhoneNumber::simplifyNumber() | |||
139 | // make cellphone compatible | 139 | // make cellphone compatible |
140 | void PhoneNumber::simplifyType() | 140 | void PhoneNumber::simplifyType() |
141 | { | 141 | { |
142 | if ( mType & Fax ) mType = Fax; | 142 | if ( mType & Fax ) mType = Fax; |
143 | else if ( mType & Cell ) mType = Cell; | 143 | else if ( mType & Cell ) mType = Cell; |
144 | else if ( mType & Work ) mType = Work ; | 144 | else if ( mType & Work ) mType = Work ; |
145 | else if ( mType & Home ) mType = Home; | 145 | else if ( mType & Home ) mType = Home; |
146 | else mType = Pref; | 146 | else mType = Pref; |
147 | } | 147 | } |
148 | bool PhoneNumber::contains( const PhoneNumber &p ) | 148 | bool PhoneNumber::contains( const PhoneNumber &p ) |
149 | { | 149 | { |
150 | PhoneNumber myself; | 150 | PhoneNumber myself; |
151 | PhoneNumber other; | 151 | PhoneNumber other; |
152 | myself = *this; | 152 | myself = *this; |
153 | other = p; | 153 | other = p; |
154 | myself.simplifyNumber(); | 154 | myself.simplifyNumber(); |
155 | other.simplifyNumber(); | 155 | other.simplifyNumber(); |
156 | if ( myself.number() != other.number ()) | 156 | if ( myself.number() != other.number ()) |
157 | return false; | 157 | return false; |
158 | myself.simplifyType(); | 158 | myself.simplifyType(); |
159 | other.simplifyType(); | 159 | other.simplifyType(); |
160 | if ( myself.type() == other.type()) | 160 | if ( myself.type() == other.type()) |
161 | return true; | 161 | return true; |
162 | return false; | 162 | return false; |
163 | } | 163 | } |
164 | 164 | ||
165 | void PhoneNumber::setId( const QString &id ) | 165 | void PhoneNumber::setId( const QString &id ) |
166 | { | 166 | { |
167 | mId = id; | 167 | mId = id; |
168 | } | 168 | } |
169 | 169 | ||
170 | QString PhoneNumber::id() const | 170 | QString PhoneNumber::id() const |
171 | { | 171 | { |
172 | return mId; | 172 | return mId; |
173 | } | 173 | } |
174 | 174 | ||
175 | void PhoneNumber::setNumber( const QString &number ) | 175 | void PhoneNumber::setNumber( const QString &number ) |
176 | { | 176 | { |
177 | mNumber = number; | 177 | mNumber = number; |
178 | } | 178 | } |
179 | 179 | ||
180 | QString PhoneNumber::number() const | 180 | QString PhoneNumber::number() const |
181 | { | 181 | { |
182 | return mNumber; | 182 | return mNumber; |
183 | } | 183 | } |
184 | 184 | ||
185 | void PhoneNumber::setType( int type ) | 185 | void PhoneNumber::setType( int type ) |
186 | { | 186 | { |
187 | mType = type; | 187 | mType = type; |
188 | } | 188 | } |
189 | 189 | ||
190 | int PhoneNumber::type() const | 190 | int PhoneNumber::type() const |
191 | { | 191 | { |
192 | return mType; | 192 | return mType; |
193 | } | 193 | } |
194 | 194 | ||
195 | QString PhoneNumber::typeLabel() const | 195 | QString PhoneNumber::typeLabel() const |
196 | { | 196 | { |
197 | QString label; | 197 | QString label; |
198 | bool first = true; | 198 | bool first = true; |
199 | 199 | ||
200 | TypeList list = typeList(); | 200 | TypeList list = typeList(); |
201 | 201 | ||
202 | TypeList::Iterator it; | 202 | TypeList::Iterator it; |
203 | for ( it = list.begin(); it != list.end(); ++it ) { | 203 | for ( it = list.begin(); it != list.end(); ++it ) { |
204 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 204 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
205 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 205 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
206 | if ( first ) | 206 | if ( first ) |
207 | first = false; | 207 | first = false; |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | return label; | 211 | return label; |
212 | } | 212 | } |
213 | 213 | ||
214 | QString PhoneNumber::label() const | 214 | QString PhoneNumber::label() const |
215 | { | 215 | { |
216 | return typeLabel( type() ); | 216 | return typeLabel( type() ); |
217 | } | 217 | } |
218 | 218 | ||
219 | PhoneNumber::TypeList PhoneNumber::typeList() | 219 | PhoneNumber::TypeList PhoneNumber::typeList() |
220 | { | 220 | { |
221 | TypeList list; | 221 | TypeList list; |
222 | 222 | ||
223 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 223 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
224 | << Bbs << Modem << Car << Isdn << Pcs << Pager; | 224 | << Bbs << Modem << Car << Isdn << Pcs << Pager; |
225 | 225 | ||
226 | return list; | 226 | return list; |
227 | } | 227 | } |
228 | PhoneNumber::TypeList PhoneNumber::supportedTypeList() | 228 | PhoneNumber::TypeList PhoneNumber::supportedTypeList() |
229 | { | 229 | { |
230 | static TypeList list; | 230 | static TypeList list; |
231 | if ( list.count() == 0 ) | 231 | if ( list.count() == 0 ) |
232 | list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice; | 232 | list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice; |
233 | return list; | 233 | return list; |
234 | } | 234 | } |
235 | |||
236 | #if 0 | ||
237 | Home| Pref i18n("Home") Home | ||
238 | Work| Pref i18n("Work") Business | ||
239 | Cell i18n("Mobile") Mobile | ||
240 | Pcs|Pref i18n("SiP") Radio | ||
241 | Pcs|Voice i18n("VoIP") TTY/TTD | ||
242 | Home i18n("Home2") Home 2 | ||
243 | Work i18n("Work2") Business 2 | ||
244 | Car i18n("Mobile2") Car | ||
245 | Pcs i18n("SiP2") Telex | ||
246 | Work| Msg | Voice i18n("Assistent") Assistent | ||
247 | Work| Msg i18n("Company") Company | ||
248 | Home | Fax i18n("Fax (Home)") Home Fax | ||
249 | Work| Fax i18n("Fax (Work)") Business Fax | ||
250 | Fax i18n("Fax (Other)") Other Fax | ||
251 | Pager i18n("Pager") Pager | ||
252 | Isdn i18n("ISDN") Isdn | ||
253 | Msg i18n("Callback") Callback | ||
254 | Pref i18n("Primary") Primary | ||
255 | Voice; i18n("Other") Other | ||
256 | |||
257 | #endif | ||
258 | |||
235 | QStringList PhoneNumber::supportedTypeListNames() | 259 | QStringList PhoneNumber::supportedTypeListNames() |
236 | { | 260 | { |
237 | static QStringList list; | 261 | static QStringList list; |
238 | if ( list.count() == 0 ) | 262 | if ( list.count() == 0 ) |
239 | list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other"); | 263 | list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other"); |
240 | return list; | 264 | return list; |
241 | } | 265 | } |
242 | 266 | ||
243 | int PhoneNumber::typeListIndex4Type(int type ) | 267 | int PhoneNumber::typeListIndex4Type(int type ) |
244 | { | 268 | { |
245 | TypeList list = supportedTypeList(); | 269 | TypeList list = supportedTypeList(); |
246 | int i = 0; | 270 | int i = 0; |
247 | while ( i < list.count() ) { | 271 | while ( i < list.count() ) { |
248 | if ( list [i] == type ) | 272 | if ( list [i] == type ) |
249 | return i; | 273 | return i; |
250 | ++i; | 274 | ++i; |
251 | } | 275 | } |
252 | return list.count()-1; | 276 | return list.count()-1; |
253 | } | 277 | } |
254 | 278 | ||
255 | QString PhoneNumber::label( int type ) | 279 | QString PhoneNumber::label( int type ) |
256 | { | 280 | { |
257 | return typeLabel( type ); | 281 | return typeLabel( type ); |
258 | } | 282 | } |
259 | 283 | ||
260 | QString PhoneNumber::typeLabel( int type ) | 284 | QString PhoneNumber::typeLabel( int type ) |
261 | { | 285 | { |
262 | if ((type & Cell) == Cell) | 286 | if ((type & Cell) == Cell) |
263 | return i18n("Mobile"); | 287 | return i18n("Mobile"); |
264 | if ((type & Home) == Home) { | 288 | if ((type & Home) == Home) { |
265 | if ((type & Pref) == Pref) | 289 | if ((type & Pref) == Pref) |
266 | return i18n("Home"); | 290 | return i18n("Home"); |
267 | if ((type & Fax) == Fax) | 291 | if ((type & Fax) == Fax) |
268 | return i18n("Fax (Home)"); | 292 | return i18n("Fax (Home)"); |
269 | return i18n("Home2"); | 293 | return i18n("Home2"); |
270 | } | 294 | } |
271 | 295 | ||
272 | if ((type & Work) == Work) { | 296 | if ((type & Work) == Work) { |
273 | if ((type & Pref) == Pref) | 297 | if ((type & Pref) == Pref) |
274 | return i18n("Work"); | 298 | return i18n("Work"); |
275 | if ((type & Fax) == Fax) | 299 | if ((type & Fax) == Fax) |
276 | return i18n("Fax (Work)"); | 300 | return i18n("Fax (Work)"); |
277 | if ((type & Msg) == Msg) { | 301 | if ((type & Msg) == Msg) { |
278 | if ((type & Voice) == Voice) | 302 | if ((type & Voice) == Voice) |
279 | return i18n("Assistent"); | 303 | return i18n("Assistent"); |
280 | return i18n("Company"); | 304 | return i18n("Company"); |
281 | } | 305 | } |
282 | return i18n("Work2"); | 306 | return i18n("Work2"); |
283 | } | 307 | } |
284 | if ((type & Pcs) == Pcs) { | 308 | if ((type & Pcs) == Pcs) { |
285 | if ((type & Pref) == Pref) | 309 | if ((type & Pref) == Pref) |
286 | return i18n("SiP"); | 310 | return i18n("SiP"); |
287 | if ((type & Voice) == Voice) | 311 | if ((type & Voice) == Voice) |
288 | return i18n("VoIP"); | 312 | return i18n("VoIP"); |
289 | return i18n("SiP2"); | 313 | return i18n("SiP2"); |
290 | } | 314 | } |
291 | if ((type & Car) == Car) | 315 | if ((type & Car) == Car) |
292 | return i18n("Mobile2"); | 316 | return i18n("Mobile2"); |
293 | if ((type & Pager) == Pager) | 317 | if ((type & Pager) == Pager) |
294 | return i18n("Pager"); | 318 | return i18n("Pager"); |
295 | if ((type & Isdn) == Isdn) | 319 | if ((type & Isdn) == Isdn) |
296 | return i18n("ISDN"); | 320 | return i18n("ISDN"); |
297 | if ((type & Video) == Video) | 321 | if ((type & Video) == Video) |
298 | return i18n("Video"); | 322 | return i18n("Video"); |
299 | 323 | ||
300 | if ((type & Msg) == Msg) | 324 | if ((type & Msg) == Msg) |
301 | return i18n("Callback"); | 325 | return i18n("Callback"); |
302 | if ((type & Fax) == Fax) | 326 | if ((type & Fax) == Fax) |
303 | return i18n("Fax (Other)"); | 327 | return i18n("Fax (Other)"); |
304 | 328 | ||
305 | if ((type & Pref) == Pref) | 329 | if ((type & Pref) == Pref) |
306 | return i18n("Primary"); | 330 | return i18n("Primary"); |
307 | 331 | ||
308 | 332 | ||
309 | return i18n("Other"); | 333 | return i18n("Other"); |
310 | 334 | ||
311 | 335 | ||
312 | #if 0 | 336 | #if 0 |
313 | 337 | ||
314 | 338 | ||
315 | 339 | ||
316 | QString typeString; | 340 | QString typeString; |
317 | 341 | ||
318 | 342 | ||
319 | if ((type & Cell) == Cell) | 343 | if ((type & Cell) == Cell) |
320 | typeString += i18n("Mobile") +" "; | 344 | typeString += i18n("Mobile") +" "; |
321 | if ((type & Home) == Home) | 345 | if ((type & Home) == Home) |
322 | typeString += i18n("Home")+" "; | 346 | typeString += i18n("Home")+" "; |
323 | else if ((type & Work) == Work) | 347 | else if ((type & Work) == Work) |
324 | typeString += i18n("Work")+" "; | 348 | typeString += i18n("Work")+" "; |
325 | 349 | ||
326 | if ((type & Sip) == Sip) | 350 | if ((type & Sip) == Sip) |
327 | typeString += i18n("SIP")+" "; | 351 | typeString += i18n("SIP")+" "; |
328 | if ((type & Car) == Car) | 352 | if ((type & Car) == Car) |
329 | typeString += i18n("Car")+" "; | 353 | typeString += i18n("Car")+" "; |
330 | 354 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 7d8586a..ab2824c 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -65,192 +65,193 @@ $Id$ | |||
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | #include <kprefsdialog.h> | 99 | #include <kprefsdialog.h> |
100 | 100 | ||
101 | 101 | ||
102 | //#include <qlabel.h> | 102 | //#include <qlabel.h> |
103 | 103 | ||
104 | 104 | ||
105 | #ifndef DESKTOP_VERSION | 105 | #ifndef DESKTOP_VERSION |
106 | #include <qpe/ir.h> | 106 | #include <qpe/ir.h> |
107 | #include <qpe/qpemenubar.h> | 107 | #include <qpe/qpemenubar.h> |
108 | #include <qtopia/qcopenvelope_qws.h> | 108 | #include <qtopia/qcopenvelope_qws.h> |
109 | #else | 109 | #else |
110 | 110 | ||
111 | #include <qmenubar.h> | 111 | #include <qmenubar.h> |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #endif // KAB_EMBEDDED | 114 | #endif // KAB_EMBEDDED |
115 | #include "kcmconfigs/kcmkabconfig.h" | 115 | #include "kcmconfigs/kcmkabconfig.h" |
116 | #include "kcmconfigs/kcmkdepimconfig.h" | 116 | #include "kcmconfigs/kcmkdepimconfig.h" |
117 | #include "kpimglobalprefs.h" | 117 | #include "kpimglobalprefs.h" |
118 | #include "externalapphandler.h" | 118 | #include "externalapphandler.h" |
119 | #include "xxportselectdialog.h" | 119 | #include "xxportselectdialog.h" |
120 | 120 | ||
121 | 121 | ||
122 | #include <kresources/selectdialog.h> | 122 | #include <kresources/selectdialog.h> |
123 | #include <kmessagebox.h> | 123 | #include <kmessagebox.h> |
124 | 124 | ||
125 | #include <picture.h> | 125 | #include <picture.h> |
126 | #include <resource.h> | 126 | #include <resource.h> |
127 | 127 | ||
128 | //US#include <qsplitter.h> | 128 | //US#include <qsplitter.h> |
129 | #include <qmap.h> | 129 | #include <qmap.h> |
130 | #include <qdir.h> | 130 | #include <qdir.h> |
131 | #include <qfile.h> | 131 | #include <qfile.h> |
132 | #include <qvbox.h> | 132 | #include <qvbox.h> |
133 | #include <qlayout.h> | 133 | #include <qlayout.h> |
134 | #include <qclipboard.h> | 134 | #include <qclipboard.h> |
135 | #include <qtextstream.h> | 135 | #include <qtextstream.h> |
136 | #include <qradiobutton.h> | 136 | #include <qradiobutton.h> |
137 | #include <qbuttongroup.h> | 137 | #include <qbuttongroup.h> |
138 | 138 | ||
139 | #include <libkdepim/categoryselectdialog.h> | 139 | #include <libkdepim/categoryselectdialog.h> |
140 | #include <libkdepim/categoryeditdialog.h> | 140 | #include <libkdepim/categoryeditdialog.h> |
141 | #include <kabc/vcardconverter.h> | 141 | #include <kabc/vcardconverter.h> |
142 | 142 | ||
143 | 143 | ||
144 | #include "addresseeutil.h" | 144 | #include "addresseeutil.h" |
145 | #include "undocmds.h" | 145 | #include "undocmds.h" |
146 | #include "addresseeeditordialog.h" | 146 | #include "addresseeeditordialog.h" |
147 | #include "viewmanager.h" | 147 | #include "viewmanager.h" |
148 | #include "details/detailsviewcontainer.h" | 148 | #include "details/detailsviewcontainer.h" |
149 | #include "kabprefs.h" | 149 | #include "kabprefs.h" |
150 | #include "xxportmanager.h" | 150 | #include "xxportmanager.h" |
151 | #include "incsearchwidget.h" | 151 | #include "incsearchwidget.h" |
152 | #include "jumpbuttonbar.h" | 152 | #include "jumpbuttonbar.h" |
153 | #include "extensionmanager.h" | 153 | #include "extensionmanager.h" |
154 | #include "addresseeconfig.h" | 154 | #include "addresseeconfig.h" |
155 | #include "nameeditdialog.h" | 155 | #include "nameeditdialog.h" |
156 | #include <kcmultidialog.h> | 156 | #include <kcmultidialog.h> |
157 | 157 | ||
158 | #ifdef _WIN32_ | 158 | #ifdef _WIN32_ |
159 | #ifdef _OL_IMPORT_ | 159 | #ifdef _OL_IMPORT_ |
160 | #include "kaimportoldialog.h" | 160 | #include "kaimportoldialog.h" |
161 | #include <libkdepim/ol_access.h> | ||
161 | #endif | 162 | #endif |
162 | #else | 163 | #else |
163 | #include <unistd.h> | 164 | #include <unistd.h> |
164 | #endif | 165 | #endif |
165 | // sync includes | 166 | // sync includes |
166 | #include <libkdepim/ksyncprofile.h> | 167 | #include <libkdepim/ksyncprofile.h> |
167 | #include <libkdepim/ksyncprefsdialog.h> | 168 | #include <libkdepim/ksyncprefsdialog.h> |
168 | 169 | ||
169 | 170 | ||
170 | class KABCatPrefs : public QDialog | 171 | class KABCatPrefs : public QDialog |
171 | { | 172 | { |
172 | public: | 173 | public: |
173 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 174 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
174 | QDialog( parent, name, true ) | 175 | QDialog( parent, name, true ) |
175 | { | 176 | { |
176 | setCaption( i18n("Manage new Categories") ); | 177 | setCaption( i18n("Manage new Categories") ); |
177 | QVBoxLayout* lay = new QVBoxLayout( this ); | 178 | QVBoxLayout* lay = new QVBoxLayout( this ); |
178 | lay->setSpacing( 3 ); | 179 | lay->setSpacing( 3 ); |
179 | lay->setMargin( 3 ); | 180 | lay->setMargin( 3 ); |
180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 181 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
181 | lay->addWidget( lab ); | 182 | lay->addWidget( lab ); |
182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 183 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
183 | lay->addWidget( format ); | 184 | lay->addWidget( format ); |
184 | format->setExclusive ( true ) ; | 185 | format->setExclusive ( true ) ; |
185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 186 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
186 | new QRadioButton(i18n("Remove from addressees"), format ); | 187 | new QRadioButton(i18n("Remove from addressees"), format ); |
187 | addCatBut->setChecked( true ); | 188 | addCatBut->setChecked( true ); |
188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 189 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
189 | lay->addWidget( ok ); | 190 | lay->addWidget( ok ); |
190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 191 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
191 | lay->addWidget( cancel ); | 192 | lay->addWidget( cancel ); |
192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 193 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 194 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
194 | resize( 200, 200 ); | 195 | resize( 200, 200 ); |
195 | } | 196 | } |
196 | 197 | ||
197 | bool addCat() { return addCatBut->isChecked(); } | 198 | bool addCat() { return addCatBut->isChecked(); } |
198 | private: | 199 | private: |
199 | QRadioButton* addCatBut; | 200 | QRadioButton* addCatBut; |
200 | }; | 201 | }; |
201 | 202 | ||
202 | class KABFormatPrefs : public QDialog | 203 | class KABFormatPrefs : public QDialog |
203 | { | 204 | { |
204 | public: | 205 | public: |
205 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 206 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
206 | QDialog( parent, name, true ) | 207 | QDialog( parent, name, true ) |
207 | { | 208 | { |
208 | setCaption( i18n("Set formatted name") ); | 209 | setCaption( i18n("Set formatted name") ); |
209 | QVBoxLayout* lay = new QVBoxLayout( this ); | 210 | QVBoxLayout* lay = new QVBoxLayout( this ); |
210 | lay->setSpacing( 3 ); | 211 | lay->setSpacing( 3 ); |
211 | lay->setMargin( 3 ); | 212 | lay->setMargin( 3 ); |
212 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 213 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
213 | lay->addWidget( lab ); | 214 | lay->addWidget( lab ); |
214 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 215 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
215 | lay->addWidget( format ); | 216 | lay->addWidget( format ); |
216 | format->setExclusive ( true ) ; | 217 | format->setExclusive ( true ) ; |
217 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 218 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
218 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 219 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
219 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 220 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
220 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 221 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
221 | simple->setChecked( true ); | 222 | simple->setChecked( true ); |
222 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 223 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
223 | lay->addWidget( setCompany ); | 224 | lay->addWidget( setCompany ); |
224 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 225 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
225 | lay->addWidget( ok ); | 226 | lay->addWidget( ok ); |
226 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 227 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
227 | lay->addWidget( cancel ); | 228 | lay->addWidget( cancel ); |
228 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 229 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
229 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 230 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
230 | //resize( 200, 200 ); | 231 | //resize( 200, 200 ); |
231 | 232 | ||
232 | } | 233 | } |
233 | public: | 234 | public: |
234 | QRadioButton* simple, *full, *reverse, *company; | 235 | QRadioButton* simple, *full, *reverse, *company; |
235 | QCheckBox* setCompany; | 236 | QCheckBox* setCompany; |
236 | }; | 237 | }; |
237 | 238 | ||
238 | 239 | ||
239 | 240 | ||
240 | class KAex2phonePrefs : public QDialog | 241 | class KAex2phonePrefs : public QDialog |
241 | { | 242 | { |
242 | public: | 243 | public: |
243 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 244 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
244 | QDialog( parent, name, true ) | 245 | QDialog( parent, name, true ) |
245 | { | 246 | { |
246 | setCaption( i18n("Export to phone options") ); | 247 | setCaption( i18n("Export to phone options") ); |
247 | QVBoxLayout* lay = new QVBoxLayout( this ); | 248 | QVBoxLayout* lay = new QVBoxLayout( this ); |
248 | lay->setSpacing( 3 ); | 249 | lay->setSpacing( 3 ); |
249 | lay->setMargin( 3 ); | 250 | lay->setMargin( 3 ); |
250 | QLabel *lab; | 251 | QLabel *lab; |
251 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 252 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
252 | lab->setAlignment (AlignHCenter ); | 253 | lab->setAlignment (AlignHCenter ); |
253 | QHBox* temphb; | 254 | QHBox* temphb; |
254 | temphb = new QHBox( this ); | 255 | temphb = new QHBox( this ); |
255 | new QLabel( i18n("I/O device: "), temphb ); | 256 | new QLabel( i18n("I/O device: "), temphb ); |
256 | mPhoneDevice = new QLineEdit( temphb); | 257 | mPhoneDevice = new QLineEdit( temphb); |
@@ -1276,218 +1277,266 @@ void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | |||
1276 | Command *command = 0; | 1277 | Command *command = 0; |
1277 | QString uid; | 1278 | QString uid; |
1278 | 1279 | ||
1279 | // check if it exists already | 1280 | // check if it exists already |
1280 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1281 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1281 | if ( origAddr.isEmpty() ) | 1282 | if ( origAddr.isEmpty() ) |
1282 | command = new PwNewCommand( mAddressBook, addr ); | 1283 | command = new PwNewCommand( mAddressBook, addr ); |
1283 | else { | 1284 | else { |
1284 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1285 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1285 | uid = addr.uid(); | 1286 | uid = addr.uid(); |
1286 | } | 1287 | } |
1287 | 1288 | ||
1288 | UndoStack::instance()->push( command ); | 1289 | UndoStack::instance()->push( command ); |
1289 | RedoStack::instance()->clear(); | 1290 | RedoStack::instance()->clear(); |
1290 | if ( updateDetails ) | 1291 | if ( updateDetails ) |
1291 | mDetails->setAddressee( addr ); | 1292 | mDetails->setAddressee( addr ); |
1292 | setModified( true ); | 1293 | setModified( true ); |
1293 | } | 1294 | } |
1294 | 1295 | ||
1295 | void KABCore::newContact() | 1296 | void KABCore::newContact() |
1296 | { | 1297 | { |
1297 | 1298 | ||
1298 | 1299 | ||
1299 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1300 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1300 | 1301 | ||
1301 | QPtrList<KRES::Resource> kresResources; | 1302 | QPtrList<KRES::Resource> kresResources; |
1302 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1303 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1303 | KABC::Resource *resource; | 1304 | KABC::Resource *resource; |
1304 | while ( ( resource = it.current() ) != 0 ) { | 1305 | while ( ( resource = it.current() ) != 0 ) { |
1305 | ++it; | 1306 | ++it; |
1306 | if ( !resource->readOnly() ) { | 1307 | if ( !resource->readOnly() ) { |
1307 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1308 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1308 | if ( res ) | 1309 | if ( res ) |
1309 | kresResources.append( res ); | 1310 | kresResources.append( res ); |
1310 | } | 1311 | } |
1311 | } | 1312 | } |
1312 | 1313 | ||
1313 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1314 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1314 | resource = static_cast<KABC::Resource*>( res ); | 1315 | resource = static_cast<KABC::Resource*>( res ); |
1315 | 1316 | ||
1316 | if ( resource ) { | 1317 | if ( resource ) { |
1317 | KABC::Addressee addr; | 1318 | KABC::Addressee addr; |
1318 | addr.setResource( resource ); | 1319 | addr.setResource( resource ); |
1319 | mEditorDialog->setAddressee( addr ); | 1320 | mEditorDialog->setAddressee( addr ); |
1320 | mEditorDialog->setCaption( i18n("Edit new contact")); | 1321 | mEditorDialog->setCaption( i18n("Edit new contact")); |
1321 | KApplication::execDialog ( mEditorDialog ); | 1322 | KApplication::execDialog ( mEditorDialog ); |
1322 | 1323 | ||
1323 | } else | 1324 | } else |
1324 | return; | 1325 | return; |
1325 | 1326 | ||
1326 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1327 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1327 | 1328 | ||
1328 | 1329 | ||
1329 | } | 1330 | } |
1330 | 1331 | ||
1331 | void KABCore::addEmail( QString aStr ) | 1332 | void KABCore::addEmail( QString aStr ) |
1332 | { | 1333 | { |
1333 | #ifndef KAB_EMBEDDED | 1334 | #ifndef KAB_EMBEDDED |
1334 | QString fullName, email; | 1335 | QString fullName, email; |
1335 | 1336 | ||
1336 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1337 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1337 | 1338 | ||
1338 | // Try to lookup the addressee matching the email address | 1339 | // Try to lookup the addressee matching the email address |
1339 | bool found = false; | 1340 | bool found = false; |
1340 | QStringList emailList; | 1341 | QStringList emailList; |
1341 | KABC::AddressBook::Iterator it; | 1342 | KABC::AddressBook::Iterator it; |
1342 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1343 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1343 | emailList = (*it).emails(); | 1344 | emailList = (*it).emails(); |
1344 | if ( emailList.contains( email ) > 0 ) { | 1345 | if ( emailList.contains( email ) > 0 ) { |
1345 | found = true; | 1346 | found = true; |
1346 | (*it).setNameFromString( fullName ); | 1347 | (*it).setNameFromString( fullName ); |
1347 | editContact( (*it).uid() ); | 1348 | editContact( (*it).uid() ); |
1348 | } | 1349 | } |
1349 | } | 1350 | } |
1350 | 1351 | ||
1351 | if ( !found ) { | 1352 | if ( !found ) { |
1352 | KABC::Addressee addr; | 1353 | KABC::Addressee addr; |
1353 | addr.setNameFromString( fullName ); | 1354 | addr.setNameFromString( fullName ); |
1354 | addr.insertEmail( email, true ); | 1355 | addr.insertEmail( email, true ); |
1355 | 1356 | ||
1356 | mAddressBook->insertAddressee( addr ); | 1357 | mAddressBook->insertAddressee( addr ); |
1357 | mViewManager->refreshView( addr.uid() ); | 1358 | mViewManager->refreshView( addr.uid() ); |
1358 | editContact( addr.uid() ); | 1359 | editContact( addr.uid() ); |
1359 | } | 1360 | } |
1360 | #else //KAB_EMBEDDED | 1361 | #else //KAB_EMBEDDED |
1361 | qDebug("KABCore::addEmail finsih method"); | 1362 | qDebug("KABCore::addEmail finsih method"); |
1362 | #endif //KAB_EMBEDDED | 1363 | #endif //KAB_EMBEDDED |
1363 | } | 1364 | } |
1364 | 1365 | ||
1365 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1366 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1366 | { | 1367 | { |
1367 | mXXPortManager->importVCard( url, showPreview ); | 1368 | mXXPortManager->importVCard( url, showPreview ); |
1368 | } | 1369 | } |
1369 | void KABCore::importFromOL() | 1370 | void KABCore::importFromOL() |
1370 | { | 1371 | { |
1371 | #ifdef _OL_IMPORT_ | 1372 | #ifdef _OL_IMPORT_ |
1372 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1373 | KABC::Addressee::List list = OL_access::instance()->importOLcontacts(); |
1373 | idgl->exec(); | 1374 | if ( list.count() > 0 ) { |
1374 | KABC::Addressee::List list = idgl->getAddressList(); | 1375 | KABC::Addressee::List listNew; |
1375 | if ( list.count() > 0 ) { | 1376 | KABC::Addressee::List listExisting; |
1376 | KABC::Addressee::List listNew; | 1377 | KABC::Addressee::List::Iterator it; |
1377 | KABC::Addressee::List listExisting; | 1378 | KABC::AddressBook::Iterator iter; |
1378 | KABC::Addressee::List::Iterator it; | 1379 | for ( it = list.begin(); it != list.end(); ++it ) { |
1379 | KABC::AddressBook::Iterator iter; | 1380 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1380 | for ( it = list.begin(); it != list.end(); ++it ) { | 1381 | listNew.append( (*it) ); |
1381 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1382 | else |
1382 | listNew.append( (*it) ); | 1383 | listExisting.append( (*it) ); |
1383 | else | 1384 | } |
1384 | listExisting.append( (*it) ); | 1385 | QString mess = i18n("%1 contacts read from OL.\n\n%2 contacts added to addressbook!").arg( list.count()).arg( listNew.count() ); |
1385 | } | 1386 | if ( listExisting.count() > 0 ) |
1386 | if ( listExisting.count() > 0 ) | 1387 | mess += "\n\n"+ i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ); |
1387 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1388 | |
1388 | if ( listNew.count() > 0 ) { | 1389 | KMessageBox::information( this, mess ); |
1389 | pasteWithNewUid = false; | 1390 | if ( listNew.count() > 0 ) { |
1390 | pasteContacts( listNew ); | 1391 | pasteWithNewUid = false; |
1391 | pasteWithNewUid = true; | 1392 | pasteContacts( listNew ); |
1393 | pasteWithNewUid = true; | ||
1394 | } | ||
1392 | } | 1395 | } |
1393 | } | ||
1394 | delete idgl; | ||
1395 | #endif | 1396 | #endif |
1396 | } | 1397 | } |
1397 | 1398 | ||
1399 | bool KABCore::readOLdata( KABC::AddressBook* local ) | ||
1400 | { | ||
1401 | #ifdef _OL_IMPORT_ | ||
1402 | QStringList folderList = OL_access::instance()->getFolderSelection( OL_CONTACT_DATA , i18n("Select Folder to sync")); | ||
1403 | KABC::Addressee::List list; | ||
1404 | if ( folderList.count() ) { | ||
1405 | OL_access::instance()->readContactData( OL_access::instance()->getFolderFromID( 0, folderList[1] ) , &list, true ); | ||
1406 | KABC::Addressee::List::Iterator it; | ||
1407 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
1408 | (*it).setExternalUID( (*it).uid() ); | ||
1409 | (*it).setOriginalExternalUID( (*it).uid() ); | ||
1410 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | ||
1411 | local->insertAddressee( (*it) , false, false ); | ||
1412 | } | ||
1413 | mOLsyncFolderID = folderList[1]; | ||
1414 | //KMessageBox::information( this, i18n("OLsync folder ID ") + mOLsyncFolderID ); | ||
1415 | } | ||
1416 | return list.count() > 0; | ||
1417 | #else | ||
1418 | return false; | ||
1419 | #endif | ||
1420 | } | ||
1421 | bool KABCore::writeOLdata( KABC::AddressBook* aBook ) | ||
1422 | { | ||
1423 | #ifdef _OL_IMPORT_ | ||
1424 | if ( !OL_access::instance()->setSelectedFolder( mOLsyncFolderID ) ) | ||
1425 | return false; | ||
1426 | KABC::AddressBook::Iterator it; | ||
1427 | for ( it = aBook->begin(); it != aBook->end(); ++it ) { | ||
1428 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
1429 | KABC::Addressee addressee = (*it); | ||
1430 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | ||
1431 | (*it) = OL_access::instance()->addAddressee( (*it) ); | ||
1432 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
1433 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | ||
1434 | OL_access::instance()->deleteAddressee( (*it) ); | ||
1435 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
1436 | //changed | ||
1437 | (*it) = OL_access::instance()->changeAddressee( (*it) ); | ||
1438 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
1439 | } | ||
1440 | } | ||
1441 | } | ||
1442 | return true; | ||
1443 | #else | ||
1444 | return false; | ||
1445 | #endif | ||
1446 | } | ||
1398 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1447 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1399 | { | 1448 | { |
1400 | mXXPortManager->importVCard( vCard, showPreview ); | 1449 | mXXPortManager->importVCard( vCard, showPreview ); |
1401 | } | 1450 | } |
1402 | 1451 | ||
1403 | //US added a second method without defaultparameter | 1452 | //US added a second method without defaultparameter |
1404 | void KABCore::editContact2() { | 1453 | void KABCore::editContact2() { |
1405 | editContact( QString::null ); | 1454 | editContact( QString::null ); |
1406 | } | 1455 | } |
1407 | 1456 | ||
1408 | void KABCore::editContact( const QString &uid ) | 1457 | void KABCore::editContact( const QString &uid ) |
1409 | { | 1458 | { |
1410 | 1459 | ||
1411 | if ( mExtensionManager->isQuickEditVisible() ) | 1460 | if ( mExtensionManager->isQuickEditVisible() ) |
1412 | return; | 1461 | return; |
1413 | 1462 | ||
1414 | // First, locate the contact entry | 1463 | // First, locate the contact entry |
1415 | QString localUID = uid; | 1464 | QString localUID = uid; |
1416 | if ( localUID.isNull() ) { | 1465 | if ( localUID.isNull() ) { |
1417 | QStringList uidList = mViewManager->selectedUids(); | 1466 | QStringList uidList = mViewManager->selectedUids(); |
1418 | if ( uidList.count() > 0 ) | 1467 | if ( uidList.count() > 0 ) |
1419 | localUID = *( uidList.at( 0 ) ); | 1468 | localUID = *( uidList.at( 0 ) ); |
1420 | } | 1469 | } |
1421 | 1470 | ||
1422 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1471 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1423 | if ( !addr.isEmpty() ) { | 1472 | if ( !addr.isEmpty() ) { |
1424 | mEditorDialog->setAddressee( addr ); | 1473 | mEditorDialog->setAddressee( addr ); |
1425 | KApplication::execDialog ( mEditorDialog ); | 1474 | KApplication::execDialog ( mEditorDialog ); |
1426 | } | 1475 | } |
1427 | } | 1476 | } |
1428 | 1477 | ||
1429 | /** | 1478 | /** |
1430 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1479 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1431 | the method will try to find a selected addressee in the view. | 1480 | the method will try to find a selected addressee in the view. |
1432 | */ | 1481 | */ |
1433 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1482 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1434 | { | 1483 | { |
1435 | if ( mMultipleViewsAtOnce ) | 1484 | if ( mMultipleViewsAtOnce ) |
1436 | { | 1485 | { |
1437 | editContact( uid ); | 1486 | editContact( uid ); |
1438 | } | 1487 | } |
1439 | else | 1488 | else |
1440 | { | 1489 | { |
1441 | setDetailsVisible( true ); | 1490 | setDetailsVisible( true ); |
1442 | mActionDetails->setChecked(true); | 1491 | mActionDetails->setChecked(true); |
1443 | } | 1492 | } |
1444 | 1493 | ||
1445 | } | 1494 | } |
1446 | 1495 | ||
1447 | void KABCore::save() | 1496 | void KABCore::save() |
1448 | { | 1497 | { |
1449 | if (syncManager->blockSave()) | 1498 | if (syncManager->blockSave()) |
1450 | return; | 1499 | return; |
1451 | if ( !mModified ) | 1500 | if ( !mModified ) |
1452 | return; | 1501 | return; |
1453 | 1502 | ||
1454 | syncManager->setBlockSave(true); | 1503 | syncManager->setBlockSave(true); |
1455 | QString text = i18n( "There was an error while attempting to save\n the " | 1504 | QString text = i18n( "There was an error while attempting to save\n the " |
1456 | "address book. Please check that some \nother application is " | 1505 | "address book. Please check that some \nother application is " |
1457 | "not using it. " ); | 1506 | "not using it. " ); |
1458 | message(i18n("Saving ... please wait! "), false); | 1507 | message(i18n("Saving ... please wait! "), false); |
1459 | //qApp->processEvents(); | 1508 | //qApp->processEvents(); |
1460 | #ifndef KAB_EMBEDDED | 1509 | #ifndef KAB_EMBEDDED |
1461 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1510 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1462 | if ( !b || !b->save() ) { | 1511 | if ( !b || !b->save() ) { |
1463 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1512 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1464 | } | 1513 | } |
1465 | #else //KAB_EMBEDDED | 1514 | #else //KAB_EMBEDDED |
1466 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1515 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1467 | if ( !b || !b->save() ) { | 1516 | if ( !b || !b->save() ) { |
1468 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1517 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1469 | } | 1518 | } |
1470 | #endif //KAB_EMBEDDED | 1519 | #endif //KAB_EMBEDDED |
1471 | 1520 | ||
1472 | message(i18n("Addressbook saved!")); | 1521 | message(i18n("Addressbook saved!")); |
1473 | setModified( false ); | 1522 | setModified( false ); |
1474 | syncManager->setBlockSave(false); | 1523 | syncManager->setBlockSave(false); |
1475 | } | 1524 | } |
1476 | 1525 | ||
1477 | 1526 | ||
1478 | void KABCore::undo() | 1527 | void KABCore::undo() |
1479 | { | 1528 | { |
1480 | UndoStack::instance()->undo(); | 1529 | UndoStack::instance()->undo(); |
1481 | 1530 | ||
1482 | // Refresh the view | 1531 | // Refresh the view |
1483 | mViewManager->refreshView(); | 1532 | mViewManager->refreshView(); |
1484 | } | 1533 | } |
1485 | 1534 | ||
1486 | void KABCore::redo() | 1535 | void KABCore::redo() |
1487 | { | 1536 | { |
1488 | RedoStack::instance()->redo(); | 1537 | RedoStack::instance()->redo(); |
1489 | 1538 | ||
1490 | // Refresh the view | 1539 | // Refresh the view |
1491 | mViewManager->refreshView(); | 1540 | mViewManager->refreshView(); |
1492 | } | 1541 | } |
1493 | void KABCore::setJumpButtonBar( bool visible ) | 1542 | void KABCore::setJumpButtonBar( bool visible ) |
@@ -3281,198 +3330,235 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
3281 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3330 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3282 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3331 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3283 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3332 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3284 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3333 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3285 | addresseeRSync.setNote( "" ) ; | 3334 | addresseeRSync.setNote( "" ) ; |
3286 | addresseeLSync.setNote( "" ); | 3335 | addresseeLSync.setNote( "" ); |
3287 | 3336 | ||
3288 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3337 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3289 | remote->insertAddressee( addresseeRSync, false ); | 3338 | remote->insertAddressee( addresseeRSync, false ); |
3290 | local->insertAddressee( addresseeLSync, false ); | 3339 | local->insertAddressee( addresseeLSync, false ); |
3291 | QString mes; | 3340 | QString mes; |
3292 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3341 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3293 | qDebug( mes ); | 3342 | qDebug( mes ); |
3294 | mes = i18n("Local addressbook changed!\n") +mes; | 3343 | mes = i18n("Local addressbook changed!\n") +mes; |
3295 | if ( syncManager->mShowSyncSummary ) { | 3344 | if ( syncManager->mShowSyncSummary ) { |
3296 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3345 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3297 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3346 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3298 | qDebug("KA: WB cancelled "); | 3347 | qDebug("KA: WB cancelled "); |
3299 | syncManager->mWriteBackFile = false; | 3348 | syncManager->mWriteBackFile = false; |
3300 | return syncOK; | 3349 | return syncOK; |
3301 | } | 3350 | } |
3302 | } | 3351 | } |
3303 | return syncOK; | 3352 | return syncOK; |
3304 | } | 3353 | } |
3305 | 3354 | ||
3306 | 3355 | ||
3307 | //this is a overwritten callbackmethods from the syncinterface | 3356 | //this is a overwritten callbackmethods from the syncinterface |
3308 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 3357 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
3309 | { | 3358 | { |
3310 | 3359 | ||
3311 | //pending prepare addresseeview for output | 3360 | //pending prepare addresseeview for output |
3312 | //pending detect, if remote file has REV field. if not switch to external sync | 3361 | //pending detect, if remote file has REV field. if not switch to external sync |
3313 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3362 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3314 | if ( manager != syncManager ) | 3363 | if ( manager != syncManager ) |
3315 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3364 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3316 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3365 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3317 | 3366 | ||
3318 | AddressBook abLocal(filename,"syncContact"); | 3367 | AddressBook abLocal(filename,"syncContact"); |
3319 | bool syncOK = false; | 3368 | bool syncOK = false; |
3320 | if ( abLocal.load() ) { | 3369 | if ( abLocal.load() ) { |
3321 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3370 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3322 | bool external = false; | 3371 | bool external = false; |
3323 | bool isXML = false; | 3372 | bool isXML = false; |
3324 | if ( filename.right(4) == ".xml") { | 3373 | if ( filename.right(4) == ".xml") { |
3325 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3374 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3326 | isXML = true; | 3375 | isXML = true; |
3327 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3376 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3328 | } else { | 3377 | } else { |
3329 | external = !manager->mIsKapiFile; | 3378 | external = !manager->mIsKapiFile; |
3330 | if ( external ) { | 3379 | if ( external ) { |
3331 | qDebug("KA: Sync::Setting vcf mode to external "); | 3380 | qDebug("KA: Sync::Setting vcf mode to external "); |
3332 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3381 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3333 | AddressBook::Iterator it; | 3382 | AddressBook::Iterator it; |
3334 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3383 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3335 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3384 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3336 | (*it).computeCsum( mCurrentSyncDevice ); | 3385 | (*it).computeCsum( mCurrentSyncDevice ); |
3337 | } | 3386 | } |
3338 | } | 3387 | } |
3339 | } | 3388 | } |
3340 | //AddressBook::Iterator it; | 3389 | //AddressBook::Iterator it; |
3341 | //QStringList vcards; | 3390 | //QStringList vcards; |
3342 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3391 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3343 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3392 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3344 | //} | 3393 | //} |
3345 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3394 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3346 | syncManager->hideProgressBar(); | 3395 | syncManager->hideProgressBar(); |
3347 | if ( syncOK ) { | 3396 | if ( syncOK ) { |
3348 | if ( syncManager->mWriteBackFile ) | 3397 | if ( syncManager->mWriteBackFile ) |
3349 | { | 3398 | { |
3350 | if ( external ) | 3399 | if ( external ) |
3351 | abLocal.removeSyncAddressees( !isXML); | 3400 | abLocal.removeSyncAddressees( !isXML); |
3352 | qDebug("KA: Sync::Saving remote AB "); | 3401 | qDebug("KA: Sync::Saving remote AB "); |
3353 | if ( ! abLocal.saveAB()) | 3402 | if ( ! abLocal.saveAB()) |
3354 | qDebug("KA: sync::Error writing back AB to file "); | 3403 | qDebug("KA: sync::Error writing back AB to file "); |
3355 | if ( external ) { | 3404 | if ( external ) { |
3356 | // afterwrite processing | 3405 | // afterwrite processing |
3357 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3406 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3358 | } | 3407 | } |
3359 | } | 3408 | } |
3360 | } | 3409 | } |
3361 | setModified(); | 3410 | setModified(); |
3362 | 3411 | ||
3363 | } | 3412 | } |
3364 | abLocal.removeResources(); | 3413 | abLocal.removeResources(); |
3365 | if ( syncOK ) | 3414 | if ( syncOK ) |
3366 | mViewManager->refreshView(); | 3415 | mViewManager->refreshView(); |
3367 | return syncOK; | 3416 | return syncOK; |
3368 | 3417 | ||
3369 | } | 3418 | } |
3370 | void KABCore::removeSyncInfo( QString syncProfile) | 3419 | void KABCore::removeSyncInfo( QString syncProfile) |
3371 | { | 3420 | { |
3372 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3421 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3373 | mAddressBook->removeSyncInfo( syncProfile ); | 3422 | mAddressBook->removeSyncInfo( syncProfile ); |
3374 | setModified(); | 3423 | setModified(); |
3375 | } | 3424 | } |
3376 | 3425 | ||
3426 | bool KABCore::syncOL() | ||
3427 | { | ||
3428 | disableBR( true ); | ||
3429 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | ||
3430 | AddressBook abLocal; | ||
3431 | if ( ! readOLdata( &abLocal ) ) | ||
3432 | return false; | ||
3433 | bool syncOK = false; | ||
3434 | message(i18n("Data from OL loaded..."), false); | ||
3435 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | ||
3436 | message(i18n("Sync preprocessing..."),false); | ||
3437 | abLocal.preOLSync( mAddressBook ,mCurrentSyncDevice ); | ||
3438 | message(i18n("Synchronizing..."),false); | ||
3439 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | ||
3440 | syncManager->hideProgressBar(); | ||
3441 | if ( syncOK ) { | ||
3442 | if ( syncManager->mWriteBackFile ) { | ||
3443 | abLocal.removeSyncAddressees( false ); | ||
3444 | message(i18n("Saving address data to OL..."),false); | ||
3445 | //abLocal.saveAB(); | ||
3446 | writeOLdata( &abLocal ); | ||
3447 | message(i18n("Sync postprocessing..."),false); | ||
3448 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | ||
3449 | } | ||
3450 | } else | ||
3451 | message( i18n("Sync cancelled or failed.") ); | ||
3452 | setModified(); | ||
3453 | abLocal.removeResources(); | ||
3454 | if ( syncOK ) { | ||
3455 | mViewManager->refreshView(); | ||
3456 | message(i18n("OL syncing finished.")); | ||
3457 | } | ||
3458 | disableBR( false ); | ||
3459 | return syncOK; | ||
3460 | } | ||
3377 | 3461 | ||
3378 | //this is a overwritten callbackmethods from the syncinterface | 3462 | //this is a overwritten callbackmethods from the syncinterface |
3379 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3463 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3380 | { | 3464 | { |
3381 | if ( resource == "phone" ) | 3465 | if ( resource == "phone" ) |
3382 | return syncPhone(); | 3466 | return syncPhone(); |
3467 | if ( resource == "ol" ) | ||
3468 | return syncOL(); | ||
3383 | disableBR( true ); | 3469 | disableBR( true ); |
3384 | if ( manager != syncManager ) | 3470 | if ( manager != syncManager ) |
3385 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3471 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3386 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3472 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3387 | 3473 | ||
3388 | AddressBook abLocal( resource,"syncContact"); | 3474 | AddressBook abLocal( resource,"syncContact"); |
3389 | bool syncOK = false; | 3475 | bool syncOK = false; |
3390 | message(i18n("Loading DTM address data..."), false); | 3476 | message(i18n("Loading DTM address data..."), false); |
3391 | if ( abLocal.load() ) { | 3477 | if ( abLocal.load() ) { |
3392 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3478 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3393 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3479 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3394 | message(i18n("Sync preprocessing..."),false); | 3480 | message(i18n("Sync preprocessing..."),false); |
3395 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3481 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3396 | message(i18n("Synchronizing..."),false); | 3482 | message(i18n("Synchronizing..."),false); |
3397 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3483 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3398 | syncManager->hideProgressBar(); | 3484 | syncManager->hideProgressBar(); |
3399 | if ( syncOK ) { | 3485 | if ( syncOK ) { |
3400 | if ( syncManager->mWriteBackFile ) { | 3486 | if ( syncManager->mWriteBackFile ) { |
3401 | abLocal.removeSyncAddressees( false ); | 3487 | abLocal.removeSyncAddressees( false ); |
3402 | message(i18n("Saving DTM address data..."),false); | 3488 | message(i18n("Saving DTM address data..."),false); |
3403 | abLocal.saveAB(); | 3489 | abLocal.saveAB(); |
3404 | message(i18n("Sync postprocessing..."),false); | 3490 | message(i18n("Sync postprocessing..."),false); |
3405 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3491 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3406 | } | 3492 | } |
3407 | } else | 3493 | } else |
3408 | message( i18n("Sync cancelled or failed.") ); | 3494 | message( i18n("Sync cancelled or failed.") ); |
3409 | setModified(); | 3495 | setModified(); |
3410 | } | 3496 | } |
3411 | abLocal.removeResources(); | 3497 | abLocal.removeResources(); |
3412 | if ( syncOK ) { | 3498 | if ( syncOK ) { |
3413 | mViewManager->refreshView(); | 3499 | mViewManager->refreshView(); |
3414 | message(i18n("DTM syncing finished.")); | 3500 | message(i18n("DTM syncing finished.")); |
3415 | } | 3501 | } |
3416 | disableBR( false ); | 3502 | disableBR( false ); |
3417 | return syncOK; | 3503 | return syncOK; |
3418 | 3504 | ||
3419 | } | 3505 | } |
3420 | void KABCore::message( QString m, bool startTimer) | 3506 | void KABCore::message( QString m, bool startTimer) |
3421 | { | 3507 | { |
3422 | topLevelWidget()->setCaption( m ); | 3508 | topLevelWidget()->setCaption( m ); |
3423 | qApp->processEvents(); | 3509 | qApp->processEvents(); |
3424 | if ( startTimer ) | 3510 | if ( startTimer ) |
3425 | mMessageTimer->start( 15000, true ); | 3511 | mMessageTimer->start( 15000, true ); |
3426 | else | 3512 | else |
3427 | mMessageTimer->stop(); | 3513 | mMessageTimer->stop(); |
3428 | } | 3514 | } |
3429 | bool KABCore::syncPhone() | 3515 | bool KABCore::syncPhone() |
3430 | { | 3516 | { |
3431 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3517 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3432 | QString fileName = getPhoneFile(); | 3518 | QString fileName = getPhoneFile(); |
3433 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3519 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3434 | message(i18n("Phone access failed!")); | 3520 | message(i18n("Phone access failed!")); |
3435 | return false; | 3521 | return false; |
3436 | } | 3522 | } |
3437 | AddressBook abLocal( fileName,"syncContact"); | 3523 | AddressBook abLocal( fileName,"syncContact"); |
3438 | bool syncOK = false; | 3524 | bool syncOK = false; |
3439 | { | 3525 | { |
3440 | abLocal.importFromFile( fileName ); | 3526 | abLocal.importFromFile( fileName ); |
3441 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3527 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3442 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3528 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3443 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3529 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3444 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3530 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3445 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3531 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3446 | syncManager->hideProgressBar(); | 3532 | syncManager->hideProgressBar(); |
3447 | if ( syncOK ) { | 3533 | if ( syncOK ) { |
3448 | if ( syncManager->mWriteBackFile ) { | 3534 | if ( syncManager->mWriteBackFile ) { |
3449 | abLocal.removeSyncAddressees( true ); | 3535 | abLocal.removeSyncAddressees( true ); |
3450 | abLocal.saveABphone( fileName ); | 3536 | abLocal.saveABphone( fileName ); |
3451 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3537 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3452 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3538 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3453 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3539 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3454 | } | 3540 | } |
3455 | } | 3541 | } |
3456 | setModified(); | 3542 | setModified(); |
3457 | } | 3543 | } |
3458 | abLocal.removeResources(); | 3544 | abLocal.removeResources(); |
3459 | if ( syncOK ) | 3545 | if ( syncOK ) |
3460 | mViewManager->refreshView(); | 3546 | mViewManager->refreshView(); |
3461 | return syncOK; | 3547 | return syncOK; |
3462 | } | 3548 | } |
3463 | void KABCore::getFile( bool success ,const QString & resource) | 3549 | void KABCore::getFile( bool success ,const QString & resource) |
3464 | { | 3550 | { |
3465 | if ( ! success ) { | 3551 | if ( ! success ) { |
3466 | message( i18n("Error receiving file. Nothing changed!") ); | 3552 | message( i18n("Error receiving file. Nothing changed!") ); |
3467 | return; | 3553 | return; |
3468 | } | 3554 | } |
3469 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); | 3555 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); |
3470 | if ( count ) | 3556 | if ( count ) |
3471 | setModified( true ); | 3557 | setModified( true ); |
3472 | message( i18n("Pi-Sync successful!") ); | 3558 | message( i18n("Pi-Sync successful!") ); |
3473 | mViewManager->refreshView(); | 3559 | mViewManager->refreshView(); |
3474 | } | 3560 | } |
3475 | void KABCore::syncFileRequest(const QString & resource) | 3561 | void KABCore::syncFileRequest(const QString & resource) |
3476 | { | 3562 | { |
3477 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3563 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3478 | syncManager->slotSyncMenu( 999 ); | 3564 | syncManager->slotSyncMenu( 999 ); |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index e69cb60..ec6a9ec 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -422,114 +422,119 @@ class KABCore : public QWidget, public KSyncInterface | |||
422 | KDGanttMinimizeSplitter* mMiniSplitter; | 422 | KDGanttMinimizeSplitter* mMiniSplitter; |
423 | XXPortManager *mXXPortManager; | 423 | XXPortManager *mXXPortManager; |
424 | JumpButtonBar *mJumpButtonBar; | 424 | JumpButtonBar *mJumpButtonBar; |
425 | IncSearchWidget *mIncSearchWidget; | 425 | IncSearchWidget *mIncSearchWidget; |
426 | ExtensionManager *mExtensionManager; | 426 | ExtensionManager *mExtensionManager; |
427 | 427 | ||
428 | KCMultiDialog *mConfigureDialog; | 428 | KCMultiDialog *mConfigureDialog; |
429 | 429 | ||
430 | #ifndef KAB_EMBEDDED | 430 | #ifndef KAB_EMBEDDED |
431 | LDAPSearchDialog *mLdapSearchDialog; | 431 | LDAPSearchDialog *mLdapSearchDialog; |
432 | #endif //KAB_EMBEDDED | 432 | #endif //KAB_EMBEDDED |
433 | // QDict<AddresseeEditorDialog> mEditorDict; | 433 | // QDict<AddresseeEditorDialog> mEditorDict; |
434 | AddresseeEditorDialog *mEditorDialog; | 434 | AddresseeEditorDialog *mEditorDialog; |
435 | bool mReadWrite; | 435 | bool mReadWrite; |
436 | bool mModified; | 436 | bool mModified; |
437 | bool mIsPart; | 437 | bool mIsPart; |
438 | bool mMultipleViewsAtOnce; | 438 | bool mMultipleViewsAtOnce; |
439 | 439 | ||
440 | 440 | ||
441 | //US file menu | 441 | //US file menu |
442 | KAction *mActionMail; | 442 | KAction *mActionMail; |
443 | KAction *mActionBeam; | 443 | KAction *mActionBeam; |
444 | KToggleAction *mActionBR; | 444 | KToggleAction *mActionBR; |
445 | KAction *mActionExport2phone; | 445 | KAction *mActionExport2phone; |
446 | KAction* mActionPrint; | 446 | KAction* mActionPrint; |
447 | KAction* mActionPrintDetails; | 447 | KAction* mActionPrintDetails; |
448 | KAction* mActionNewContact; | 448 | KAction* mActionNewContact; |
449 | KAction *mActionSave; | 449 | KAction *mActionSave; |
450 | KAction *mActionEditAddressee; | 450 | KAction *mActionEditAddressee; |
451 | KAction *mActionMailVCard; | 451 | KAction *mActionMailVCard; |
452 | KAction *mActionBeamVCard; | 452 | KAction *mActionBeamVCard; |
453 | 453 | ||
454 | KAction *mActionQuit; | 454 | KAction *mActionQuit; |
455 | 455 | ||
456 | //US edit menu | 456 | //US edit menu |
457 | KAction *mActionCopy; | 457 | KAction *mActionCopy; |
458 | KAction *mActionCut; | 458 | KAction *mActionCut; |
459 | KAction *mActionPaste; | 459 | KAction *mActionPaste; |
460 | KAction *mActionSelectAll; | 460 | KAction *mActionSelectAll; |
461 | KAction *mActionUndo; | 461 | KAction *mActionUndo; |
462 | KAction *mActionRedo; | 462 | KAction *mActionRedo; |
463 | KAction *mActionDelete; | 463 | KAction *mActionDelete; |
464 | 464 | ||
465 | //US settings menu | 465 | //US settings menu |
466 | KAction *mActionConfigResources; | 466 | KAction *mActionConfigResources; |
467 | KAction *mActionConfigGlobal; | 467 | KAction *mActionConfigGlobal; |
468 | KAction *mActionConfigKAddressbook; | 468 | KAction *mActionConfigKAddressbook; |
469 | KAction *mActionConfigShortcuts; | 469 | KAction *mActionConfigShortcuts; |
470 | KAction *mActionConfigureToolbars; | 470 | KAction *mActionConfigureToolbars; |
471 | KAction *mActionKeyBindings; | 471 | KAction *mActionKeyBindings; |
472 | KToggleAction *mActionJumpBar; | 472 | KToggleAction *mActionJumpBar; |
473 | KToggleAction *mActionDetails; | 473 | KToggleAction *mActionDetails; |
474 | KAction *mActionWhoAmI; | 474 | KAction *mActionWhoAmI; |
475 | KAction *mActionCategories; | 475 | KAction *mActionCategories; |
476 | KAction *mActionEditCategories; | 476 | KAction *mActionEditCategories; |
477 | KAction *mActionManageCategories; | 477 | KAction *mActionManageCategories; |
478 | KAction *mActionAboutKAddressbook; | 478 | KAction *mActionAboutKAddressbook; |
479 | KAction *mActionLicence; | 479 | KAction *mActionLicence; |
480 | KAction *mActionFaq; | 480 | KAction *mActionFaq; |
481 | KAction *mActionWN; | 481 | KAction *mActionWN; |
482 | KAction *mActionSyncHowto; | 482 | KAction *mActionSyncHowto; |
483 | KAction *mActionStorageHowto; | 483 | KAction *mActionStorageHowto; |
484 | KAction *mActionKdeSyncHowto; | 484 | KAction *mActionKdeSyncHowto; |
485 | KAction *mActionMultiSyncHowto; | 485 | KAction *mActionMultiSyncHowto; |
486 | 486 | ||
487 | KAction *mActionDeleteView; | 487 | KAction *mActionDeleteView; |
488 | 488 | ||
489 | QPopupMenu *viewMenu; | 489 | QPopupMenu *viewMenu; |
490 | QPopupMenu *filterMenu; | 490 | QPopupMenu *filterMenu; |
491 | QPopupMenu *settingsMenu; | 491 | QPopupMenu *settingsMenu; |
492 | QPopupMenu *changeMenu; | 492 | QPopupMenu *changeMenu; |
493 | QPopupMenu *beamMenu; | 493 | QPopupMenu *beamMenu; |
494 | //US QAction *mActionSave; | 494 | //US QAction *mActionSave; |
495 | QPopupMenu *ImportMenu; | 495 | QPopupMenu *ImportMenu; |
496 | QPopupMenu *ExportMenu; | 496 | QPopupMenu *ExportMenu; |
497 | //LR additional methods | 497 | //LR additional methods |
498 | KAction *mActionRemoveVoice; | 498 | KAction *mActionRemoveVoice; |
499 | KAction *mActionSetFormattedName; | 499 | KAction *mActionSetFormattedName; |
500 | KAction * mActionImportOL; | 500 | KAction * mActionImportOL; |
501 | 501 | ||
502 | #ifndef KAB_EMBEDDED | 502 | #ifndef KAB_EMBEDDED |
503 | KAddressBookService *mAddressBookService; | 503 | KAddressBookService *mAddressBookService; |
504 | #endif //KAB_EMBEDDED | 504 | #endif //KAB_EMBEDDED |
505 | 505 | ||
506 | class KABCorePrivate; | 506 | class KABCorePrivate; |
507 | KABCorePrivate *d; | 507 | KABCorePrivate *d; |
508 | //US bool mBlockSaveFlag; | 508 | //US bool mBlockSaveFlag; |
509 | 509 | ||
510 | #ifdef KAB_EMBEDDED | 510 | #ifdef KAB_EMBEDDED |
511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
512 | #endif //KAB_EMBEDDED | 512 | #endif //KAB_EMBEDDED |
513 | 513 | ||
514 | //this are the overwritten callbackmethods from the syncinterface | 514 | //this are the overwritten callbackmethods from the syncinterface |
515 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); | 515 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); |
516 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 516 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
517 | virtual void removeSyncInfo( QString syncProfile); | 517 | virtual void removeSyncInfo( QString syncProfile); |
518 | bool readOLdata( KABC::AddressBook* local ); | ||
519 | bool writeOLdata( KABC::AddressBook* local ); | ||
520 | bool syncOL(); | ||
518 | bool syncPhone(); | 521 | bool syncPhone(); |
519 | void message( QString m , bool startTimer = true); | 522 | void message( QString m , bool startTimer = true); |
520 | 523 | ||
521 | // LR ******************************* | 524 | // LR ******************************* |
522 | // sync stuff! | 525 | // sync stuff! |
523 | QString sentSyncFile(); | 526 | QString sentSyncFile(); |
524 | QPopupMenu *syncMenu; | 527 | QPopupMenu *syncMenu; |
525 | KSyncManager* syncManager; | 528 | KSyncManager* syncManager; |
526 | int mGlobalSyncMode; | 529 | int mGlobalSyncMode; |
527 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 530 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
528 | KABC::Addressee getLastSyncAddressee(); | 531 | KABC::Addressee getLastSyncAddressee(); |
529 | QDateTime mLastAddressbookSync; | 532 | QDateTime mLastAddressbookSync; |
530 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 533 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
531 | // ********************* | 534 | // ********************* |
535 | //OL sync stuff | ||
536 | QString mOLsyncFolderID; | ||
532 | 537 | ||
533 | }; | 538 | }; |
534 | 539 | ||
535 | #endif | 540 | #endif |
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 2f794d6..6afc288 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp | |||
@@ -1,735 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook/Pi. | 2 | This file is part of KAddressbook/Pi. |
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 <qtooltip.h> | ||
25 | #include <qframe.h> | ||
26 | #include <qpixmap.h> | ||
27 | #include <qlayout.h> | ||
28 | #include <qprogressbar.h> | ||
29 | #include <qprogressdialog.h> | ||
30 | #include <qwidgetstack.h> | ||
31 | #include <qdatetime.h> | ||
32 | #include <qdir.h> | ||
33 | #include <qregexp.h> | ||
34 | #include <qapplication.h> | ||
35 | #include <qhbox.h> | ||
36 | #include <qheader.h> | ||
37 | #include <qdatetime.h> | ||
38 | #include <qlistview.h> | ||
39 | |||
40 | #include <kdebug.h> | ||
41 | #include <klocale.h> | ||
42 | #include <kstandarddirs.h> | ||
43 | #include <kmessagebox.h> | ||
44 | #include <kfiledialog.h> | ||
45 | |||
46 | #include <libkdepim/categoryselectdialog.h> | ||
47 | #include <libkdepim/kinputdialog.h> | ||
48 | |||
49 | #include <libkcal/calendarlocal.h> | ||
50 | #include <libkcal/icalformat.h> | ||
51 | |||
52 | #include <kabc/addresseelist.h> | ||
53 | #include <kabc/phonenumber.h> | ||
54 | |||
55 | #include "kaimportoldialog.h" | ||
56 | |||
57 | #include "../outport/msoutl9.h" | ||
58 | #include <ole2.h> | ||
59 | #include <comutil.h> | ||
60 | _Application gOlAppAB; | ||
61 | |||
62 | QDateTime mDdate2Qdtr( DATE dt) | ||
63 | { | ||
64 | COleDateTime odt; | ||
65 | SYSTEMTIME st; | ||
66 | odt = dt; | ||
67 | if ( odt.GetStatus() != 0 ) | ||
68 | return QDateTime(); | ||
69 | odt.GetAsSystemTime(st); | ||
70 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! | ||
71 | return QDateTime(); | ||
72 | // it seems so, that 1.1.4501 indicates: DATE invalid | ||
73 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | ||
74 | return qdt; | ||
75 | } | ||
76 | |||
77 | class OLEListViewItem : public QCheckListItem | ||
78 | { | ||
79 | public: | ||
80 | OLEListViewItem( QListView *parent, QString text ) : | ||
81 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | ||
82 | OLEListViewItem( QListViewItem *after, QString text ) : | ||
83 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | ||
84 | ~OLEListViewItem() {}; | ||
85 | void setData( DWORD data ) {mData= data; }; | ||
86 | DWORD data() { return mData ;}; | ||
87 | private: | ||
88 | DWORD mData; | ||
89 | }; | ||
90 | |||
91 | KAImportOLdialog::KAImportOLdialog( const QString &caption, | ||
92 | KABC::AddressBook * aBook, QWidget *parent ) : | ||
93 | KDialogBase( Plain, caption, User1 | Close, Ok, | ||
94 | parent, caption, true, false, i18n("Import!") ) | ||
95 | { | ||
96 | QHBox * mw = new QHBox( this ); | ||
97 | setMainWidget( mw ); | ||
98 | mListView = new QListView( mw ); | ||
99 | mListView->addColumn(i18n("Select Folder to import")); | ||
100 | mListView->addColumn(i18n("Content Type")); | ||
101 | mABook = aBook; | ||
102 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | ||
103 | setupFolderView(); | ||
104 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | ||
105 | } | ||
106 | |||
107 | KAImportOLdialog::~KAImportOLdialog() | ||
108 | { | ||
109 | |||
110 | } | ||
111 | |||
112 | KABC::Addressee::List KAImportOLdialog::getAddressList() | ||
113 | { | ||
114 | return mAList; | ||
115 | } | ||
116 | void KAImportOLdialog::setupFolderView() | ||
117 | { | ||
118 | SCODE sc = ::OleInitialize(NULL); | ||
119 | if ( FAILED ( sc ) ) { | ||
120 | KMessageBox::information(this,"OLE initialisation failed"); | ||
121 | return; | ||
122 | } | ||
123 | |||
124 | if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ | ||
125 | KMessageBox::information(this,"Sorry, cannot access Outlook"); | ||
126 | return ; | ||
127 | } | ||
128 | MAPIFolder mfInbox; | ||
129 | MAPIFolder mfRoot; | ||
130 | CString szName; | ||
131 | _NameSpace olNS; | ||
132 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); | ||
133 | mfInbox = olNS.GetDefaultFolder(6); | ||
134 | mfRoot = mfInbox.GetParent(); | ||
135 | szName = mfRoot.GetName(); | ||
136 | long iType = mfRoot.GetDefaultItemType(); | ||
137 | QString mes; | ||
138 | mes = QString::fromUcs2( szName.GetBuffer() ); | ||
139 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); | ||
140 | mfRoot.m_lpDispatch->AddRef(); | ||
141 | addFolder( root, mfRoot.m_lpDispatch ); | ||
142 | root->setOpen( true ); | ||
143 | mListView->setSortColumn( 0 ); | ||
144 | mListView->sort( ); | ||
145 | } | ||
146 | |||
147 | |||
148 | void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) | ||
149 | { | ||
150 | MAPIFolder mfParent(dispParent), mfChild; | ||
151 | _Folders folders; | ||
152 | _variant_t fndx((long)0); | ||
153 | CString szName; | ||
154 | long iType; | ||
155 | OLEListViewItem* hChild; | ||
156 | |||
157 | folders = mfParent.GetFolders(); | ||
158 | for(int i=1; i <= folders.GetCount(); ++i) | ||
159 | { | ||
160 | fndx = (long)i; | ||
161 | mfChild = folders.Item(fndx.Detach()); | ||
162 | mfChild.m_lpDispatch->AddRef(); | ||
163 | szName = mfChild.GetName(); | ||
164 | iType = mfChild.GetDefaultItemType(); | ||
165 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | ||
166 | if ( iType != 2) | ||
167 | hChild->setEnabled( false ); | ||
168 | QString ts; | ||
169 | switch( iType ) { | ||
170 | case 0: | ||
171 | ts = i18n("Mail"); | ||
172 | break; | ||
173 | case 1: | ||
174 | ts = i18n("Calendar"); | ||
175 | break; | ||
176 | case 2: | ||
177 | ts = i18n("Contacts"); | ||
178 | break; | ||
179 | case 3: | ||
180 | ts = i18n("Todos"); | ||
181 | break; | ||
182 | case 4: | ||
183 | ts = i18n("Journals"); | ||
184 | break; | ||
185 | case 5: | ||
186 | ts = i18n("Notes"); | ||
187 | break; | ||
188 | default: | ||
189 | ts = i18n("Unknown"); | ||
190 | } | ||
191 | hChild->setText( 1,ts); | ||
192 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | ||
193 | mfChild.m_lpDispatch->AddRef(); | ||
194 | addFolder(hChild, mfChild.m_lpDispatch); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | void KAImportOLdialog::slotApply() | ||
199 | { | ||
200 | importedItems = 0; | ||
201 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | ||
202 | while ( child ) { | ||
203 | if ( child->isOn() ) | ||
204 | readContactData( child->data() ); | ||
205 | child = (OLEListViewItem*) child->itemBelow(); | ||
206 | } | ||
207 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | ||
208 | KMessageBox::information(this,mes); | ||
209 | } | ||
210 | void KAImportOLdialog::readContactData( DWORD folder ) | ||
211 | { | ||
212 | |||
213 | LPDISPATCH dispItem = (LPDISPATCH)folder; | ||
214 | dispItem->AddRef(); | ||
215 | MAPIFolder mf(dispItem); | ||
216 | mf.m_lpDispatch->AddRef(); | ||
217 | _Items folderItems; | ||
218 | _variant_t indx((long)0); | ||
219 | LPDISPATCH itm; | ||
220 | int i; | ||
221 | folderItems = mf.GetItems(); | ||
222 | QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this); | ||
223 | bar.setCaption (i18n("Importing!") ); | ||
224 | int h = bar.sizeHint().height() ; | ||
225 | int w = 300; | ||
226 | int dw = QApplication::desktop()->width(); | ||
227 | int dh = QApplication::desktop()->height(); | ||
228 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
229 | bar.show(); | ||
230 | for(i=1; i <= folderItems.GetCount(); ++i) | ||
231 | { | ||
232 | qApp->processEvents(); | ||
233 | if ( ! bar.isVisible() ) | ||
234 | return ; | ||
235 | bar.setProgress( i ); | ||
236 | indx = (long)i; | ||
237 | itm = folderItems.Item(indx.Detach()); | ||
238 | _ContactItem * pItem = (_ContactItem *)&itm; | ||
239 | ol2kapiContact( pItem ); | ||
240 | itm->Release(); | ||
241 | } | ||
242 | } | ||
243 | void KAImportOLdialog::slotOk() | ||
244 | { | ||
245 | QDialog::accept(); | ||
246 | } | ||
247 | |||
248 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | ||
249 | { | ||
250 | KABC::Addressee addressee; | ||
251 | |||
252 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); | ||
253 | //GetLastModificationTime() | ||
254 | //addressee.setName( const QString &name ); | ||
255 | //addressee.setFormattedName( const QString &formattedName ); | ||
256 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); | ||
257 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); | ||
258 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); | ||
259 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); | ||
260 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); | ||
261 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); | ||
262 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); | ||
263 | if ( dtb.isValid() ) | ||
264 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); | ||
265 | |||
266 | //QString::fromUcs2(aItem->.GetBuffer()) | ||
267 | //addressee.setMailer( const QString &mailer ); | ||
268 | //addressee.setTimeZone( const TimeZone &timeZone ); | ||
269 | //addressee.setGeo( const Geo &geo ); | ||
270 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix | ||
271 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); | ||
272 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); | ||
273 | QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); | ||
274 | notesStr.replace( QRegExp("\\r"), ""); | ||
275 | |||
276 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); | ||
277 | //addressee.setRevision( const QDateTime &revision ); | ||
278 | // addressee.setSortString( const QString &sortString ); | ||
279 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); | ||
280 | |||
281 | QString tempS; | ||
282 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); | ||
283 | if ( tempS.length() > 12 ) | ||
284 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); | ||
285 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); | ||
286 | if ( !tempS.isEmpty() ) | ||
287 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); | ||
288 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); | ||
289 | if ( !tempS.isEmpty() ) | ||
290 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); | ||
291 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); | ||
292 | if ( !tempS.isEmpty() ) | ||
293 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); | ||
294 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); | ||
295 | if ( !tempS.isEmpty() ) | ||
296 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); | ||
297 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); | ||
298 | if ( !tempS.isEmpty() ) | ||
299 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); | ||
300 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); | ||
301 | if ( !tempS.isEmpty() ) | ||
302 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); | ||
303 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); | ||
304 | if (dtb.isValid() ) { | ||
305 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); | ||
306 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | ||
307 | } | ||
308 | int sec = aItem->GetSensitivity() ; | ||
309 | if ( sec > 1 )// mapping pers -> private | ||
310 | --sec; | ||
311 | addressee.setSecrecy( sec ); | ||
312 | //addressee.setLogo( const Picture &logo ); | ||
313 | //addressee.setPhoto( const Picture &photo ); | ||
314 | //addressee.setSound( const Sound &sound ); | ||
315 | //addressee.setAgent( const Agent &agent ); | ||
316 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); | ||
317 | cat = cat.replace( QRegExp("; "), ";"); | ||
318 | addressee.setCategories( QStringList::split( ";", cat )); | ||
319 | |||
320 | QString phoneS; | ||
321 | |||
322 | phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); | ||
323 | if ( ! phoneS.isEmpty()) | ||
324 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); | ||
325 | phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); | ||
326 | if ( ! phoneS.isEmpty()) | ||
327 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | ||
328 | phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); | ||
329 | if ( ! phoneS.isEmpty()) | ||
330 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | ||
331 | phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); | ||
332 | if ( ! phoneS.isEmpty()) | ||
333 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); | ||
334 | phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); | ||
335 | if ( ! phoneS.isEmpty()) | ||
336 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); | ||
337 | phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); | ||
338 | if ( ! phoneS.isEmpty()) | ||
339 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | ||
340 | phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); | ||
341 | if ( ! phoneS.isEmpty()) | ||
342 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | ||
343 | phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); | ||
344 | if ( ! phoneS.isEmpty()) | ||
345 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); | ||
346 | phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); | ||
347 | if ( ! phoneS.isEmpty()) | ||
348 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); | ||
349 | phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); | ||
350 | if ( ! phoneS.isEmpty()) | ||
351 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); | ||
352 | phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); | ||
353 | if ( ! phoneS.isEmpty()) | ||
354 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); | ||
355 | phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); | ||
356 | if ( ! phoneS.isEmpty()) | ||
357 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); | ||
358 | phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); | ||
359 | if ( ! phoneS.isEmpty()) | ||
360 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); | ||
361 | phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); | ||
362 | if ( ! phoneS.isEmpty()) | ||
363 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); | ||
364 | phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); | ||
365 | if ( ! phoneS.isEmpty()) | ||
366 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); | ||
367 | phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); | ||
368 | if ( ! phoneS.isEmpty()) | ||
369 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); | ||
370 | phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); | ||
371 | if ( ! phoneS.isEmpty()) | ||
372 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); | ||
373 | phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); | ||
374 | if ( ! phoneS.isEmpty()) | ||
375 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); | ||
376 | phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); | ||
377 | if ( ! phoneS.isEmpty()) | ||
378 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); | ||
379 | |||
380 | bool preferred = true; | ||
381 | phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); | ||
382 | if ( ! phoneS.isEmpty()) { | ||
383 | addressee.insertEmail(phoneS , preferred ); | ||
384 | preferred = false; | ||
385 | } | ||
386 | phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); | ||
387 | if ( ! phoneS.isEmpty()) { | ||
388 | addressee.insertEmail(phoneS , preferred ); | ||
389 | preferred = false; | ||
390 | } | ||
391 | phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); | ||
392 | if ( ! phoneS.isEmpty()) { | ||
393 | addressee.insertEmail(phoneS , preferred ); | ||
394 | preferred = false; | ||
395 | } | ||
396 | // is this the number of the preferred email? | ||
397 | //long GetSelectedMailingAddress();??? | ||
398 | |||
399 | KABC::Address addressHome; | ||
400 | KABC::Address* addressAdd = &addressHome; | ||
401 | bool insert = false; | ||
402 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); | ||
403 | phoneS.replace( QRegExp("\\r"), ""); | ||
404 | if ( ! phoneS.isEmpty()) { | ||
405 | addressAdd->setCountry(phoneS ); | ||
406 | insert = true; | ||
407 | } | ||
408 | phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); | ||
409 | phoneS.replace( QRegExp("\\r"), ""); | ||
410 | if ( ! phoneS.isEmpty()) { | ||
411 | addressAdd->setRegion(phoneS ); | ||
412 | insert = true; | ||
413 | } | ||
414 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); | ||
415 | phoneS.replace( QRegExp("\\r"), ""); | ||
416 | if ( ! phoneS.isEmpty()) { | ||
417 | addressAdd->setLocality(phoneS ); | ||
418 | insert = true; | ||
419 | } | ||
420 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); | ||
421 | phoneS.replace( QRegExp("\\r"), ""); | ||
422 | if ( ! phoneS.isEmpty()) { | ||
423 | addressAdd->setPostalCode(phoneS ); | ||
424 | insert = true; | ||
425 | } | ||
426 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); | ||
427 | phoneS.replace( QRegExp("\\r"), ""); | ||
428 | if ( ! phoneS.isEmpty()) { | ||
429 | addressAdd->setPostOfficeBox(phoneS ); | ||
430 | insert = true; | ||
431 | } | ||
432 | phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); | ||
433 | phoneS.replace( QRegExp("\\r"), ""); | ||
434 | if ( ! phoneS.isEmpty()) { | ||
435 | addressAdd->setStreet(phoneS ); | ||
436 | insert = true; | ||
437 | } | ||
438 | phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); | ||
439 | phoneS.replace( QRegExp("\\r"), ""); | ||
440 | if ( ! phoneS.isEmpty()) { | ||
441 | // redundant !addressAdd->setExtended(phoneS ); | ||
442 | // insert = true; | ||
443 | } | ||
444 | addressAdd->setType( KABC::Address::Home ); | ||
445 | if ( insert ) | ||
446 | addressee.insertAddress( *addressAdd ); | ||
447 | // ++++++++++++++++++++++ end of address | ||
448 | |||
449 | KABC::Address addressWork; | ||
450 | addressAdd = &addressWork; | ||
451 | insert = false; | ||
452 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); | ||
453 | phoneS.replace( QRegExp("\\r"), ""); | ||
454 | if ( ! phoneS.isEmpty()) { | ||
455 | addressAdd->setCountry(phoneS ); | ||
456 | insert = true; | ||
457 | } | ||
458 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); | ||
459 | phoneS.replace( QRegExp("\\r"), ""); | ||
460 | if ( ! phoneS.isEmpty()) { | ||
461 | addressAdd->setRegion(phoneS ); | ||
462 | insert = true; | ||
463 | } | ||
464 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); | ||
465 | phoneS.replace( QRegExp("\\r"), ""); | ||
466 | if ( ! phoneS.isEmpty()) { | ||
467 | addressAdd->setLocality(phoneS ); | ||
468 | insert = true; | ||
469 | } | ||
470 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); | ||
471 | phoneS.replace( QRegExp("\\r"), ""); | ||
472 | if ( ! phoneS.isEmpty()) { | ||
473 | addressAdd->setPostalCode(phoneS ); | ||
474 | insert = true; | ||
475 | } | ||
476 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); | ||
477 | phoneS.replace( QRegExp("\\r"), ""); | ||
478 | if ( ! phoneS.isEmpty()) { | ||
479 | addressAdd->setPostOfficeBox(phoneS ); | ||
480 | insert = true; | ||
481 | } | ||
482 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); | ||
483 | phoneS.replace( QRegExp("\\r"), ""); | ||
484 | if ( ! phoneS.isEmpty()) { | ||
485 | addressAdd->setStreet(phoneS ); | ||
486 | insert = true; | ||
487 | } | ||
488 | phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); | ||
489 | phoneS.replace( QRegExp("\\r"), ""); | ||
490 | if ( ! phoneS.isEmpty()) { | ||
491 | // redundant !addressAdd->setExtended(phoneS ); | ||
492 | // insert = true; | ||
493 | } | ||
494 | addressAdd->setType( KABC::Address::Work ); | ||
495 | if ( insert ) | ||
496 | addressee.insertAddress( *addressAdd ); | ||
497 | // ++++++++++++++++++++++ end of address | ||
498 | |||
499 | KABC::Address addressOther; | ||
500 | addressAdd = &addressOther; | ||
501 | insert = false; | ||
502 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); | ||
503 | phoneS.replace( QRegExp("\\r"), ""); | ||
504 | if ( ! phoneS.isEmpty()) { | ||
505 | addressAdd->setCountry(phoneS ); | ||
506 | insert = true; | ||
507 | } | ||
508 | phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); | ||
509 | phoneS.replace( QRegExp("\\r"), ""); | ||
510 | if ( ! phoneS.isEmpty()) { | ||
511 | addressAdd->setRegion(phoneS ); | ||
512 | insert = true; | ||
513 | } | ||
514 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); | ||
515 | phoneS.replace( QRegExp("\\r"), ""); | ||
516 | if ( ! phoneS.isEmpty()) { | ||
517 | addressAdd->setLocality(phoneS ); | ||
518 | insert = true; | ||
519 | } | ||
520 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); | ||
521 | phoneS.replace( QRegExp("\\r"), ""); | ||
522 | if ( ! phoneS.isEmpty()) { | ||
523 | addressAdd->setPostalCode(phoneS ); | ||
524 | insert = true; | ||
525 | } | ||
526 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); | ||
527 | phoneS.replace( QRegExp("\\r"), ""); | ||
528 | if ( ! phoneS.isEmpty()) { | ||
529 | addressAdd->setPostOfficeBox(phoneS ); | ||
530 | insert = true; | ||
531 | } | ||
532 | phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); | ||
533 | phoneS.replace( QRegExp("\\r"), ""); | ||
534 | if ( ! phoneS.isEmpty()) { | ||
535 | addressAdd->setStreet(phoneS ); | ||
536 | insert = true; | ||
537 | } | ||
538 | phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); | ||
539 | if ( ! phoneS.isEmpty()) { | ||
540 | // redundant !addressAdd->setExtended(phoneS ); | ||
541 | //insert = true; | ||
542 | } | ||
543 | //addressAdd->setId( ); | ||
544 | if ( insert ) | ||
545 | addressee.insertAddress( *addressAdd ); | ||
546 | // ++++++++++++++++++++++ end of address | ||
547 | KABC::Address addressMail; | ||
548 | addressAdd = &addressMail; | ||
549 | insert = false; | ||
550 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); | ||
551 | phoneS.replace( QRegExp("\\r"), ""); | ||
552 | if ( ! phoneS.isEmpty()) { | ||
553 | addressAdd->setCountry(phoneS ); | ||
554 | insert = true; | ||
555 | } | ||
556 | phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); | ||
557 | phoneS.replace( QRegExp("\\r"), ""); | ||
558 | if ( ! phoneS.isEmpty()) { | ||
559 | addressAdd->setRegion(phoneS ); | ||
560 | insert = true; | ||
561 | } | ||
562 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); | ||
563 | phoneS.replace( QRegExp("\\r"), ""); | ||
564 | if ( ! phoneS.isEmpty()) { | ||
565 | addressAdd->setLocality(phoneS ); | ||
566 | insert = true; | ||
567 | } | ||
568 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); | ||
569 | phoneS.replace( QRegExp("\\r"), ""); | ||
570 | if ( ! phoneS.isEmpty()) { | ||
571 | addressAdd->setPostalCode(phoneS ); | ||
572 | insert = true; | ||
573 | } | ||
574 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); | ||
575 | phoneS.replace( QRegExp("\\r"), ""); | ||
576 | if ( ! phoneS.isEmpty()) { | ||
577 | addressAdd->setPostOfficeBox(phoneS ); | ||
578 | insert = true; | ||
579 | } | ||
580 | phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); | ||
581 | phoneS.replace( QRegExp("\\r"), ""); | ||
582 | if ( ! phoneS.isEmpty()) { | ||
583 | addressAdd->setStreet(phoneS ); | ||
584 | insert = true; | ||
585 | } | ||
586 | phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); | ||
587 | phoneS.replace( QRegExp("\\r"), ""); | ||
588 | if ( ! phoneS.isEmpty()) { | ||
589 | // redundant ! addressAdd->setExtended(phoneS ); | ||
590 | // insert = true; | ||
591 | } | ||
592 | addressAdd->setType( KABC::Address::Postal ); | ||
593 | if ( insert ) { | ||
594 | addressee.insertAddress( *addressAdd ); | ||
595 | } | ||
596 | // the following code is disabled | ||
597 | // it does not seem to be useful | ||
598 | #if 0 | ||
599 | if ( insert ) { | ||
600 | addressAdd->setType( KABC::Address::Home ); | ||
601 | if ( addressMail == addressHome ) { | ||
602 | addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); | ||
603 | addressee.insertAddress( addressHome ); | ||
604 | } else { | ||
605 | addressAdd->setType( KABC::Address::Work ); | ||
606 | if ( addressMail == addressWork ){ | ||
607 | addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); | ||
608 | addressee.insertAddress( addressWork ); | ||
609 | |||
610 | } else { | ||
611 | addressAdd->setType( 0 ); | ||
612 | if ( addressOther == addressMail ){ | ||
613 | addressOther.setType( KABC::Address::Postal ); | ||
614 | addressee.insertAddress( addressOther ); | ||
615 | } else { | ||
616 | addressee.insertAddress( *addressAdd ); | ||
617 | } | ||
618 | } | ||
619 | } | ||
620 | } | ||
621 | #endif | ||
622 | // ++++++++++++++++++++++ end of ALL addresses | ||
623 | //GetUserProperties(); | ||
624 | tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); | ||
625 | phoneS.replace( QRegExp("\\r"), ""); | ||
626 | if ( !tempS.isEmpty() ) | ||
627 | addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); | ||
628 | tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); | ||
629 | if ( !tempS.isEmpty() ) | ||
630 | addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); | ||
631 | int gen = aItem->GetGender(); | ||
632 | if ( gen != 0 ) { // 0 undef - 1 female - 2 male | ||
633 | if ( gen == 1 ) | ||
634 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); | ||
635 | else | ||
636 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); | ||
637 | } | ||
638 | QString additionalInfo; | ||
639 | QString tempAdd; | ||
640 | tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer()); | ||
641 | if ( ! tempAdd.isEmpty() ) { | ||
642 | additionalInfo += i18n("\nLanguage: "); | ||
643 | additionalInfo += tempAdd; | ||
644 | } | ||
645 | tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer()); | ||
646 | phoneS.replace( QRegExp("\\r"), ""); | ||
647 | if ( ! tempAdd.isEmpty() ) { | ||
648 | additionalInfo += i18n("\nHobby: "); | ||
649 | additionalInfo += tempAdd;; | ||
650 | } | ||
651 | tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer()); | ||
652 | phoneS.replace( QRegExp("\\r"), ""); | ||
653 | if ( ! tempAdd.isEmpty() ) { | ||
654 | additionalInfo += i18n("\nHomepage: "); | ||
655 | additionalInfo += tempAdd;; | ||
656 | } | ||
657 | tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer()); | ||
658 | phoneS.replace( QRegExp("\\r"), ""); | ||
659 | if ( ! tempAdd.isEmpty() ) { | ||
660 | additionalInfo += i18n("\nBilling information: "); | ||
661 | additionalInfo += tempAdd;; | ||
662 | } | ||
663 | tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer()); | ||
664 | phoneS.replace( QRegExp("\\r"), ""); | ||
665 | if ( ! tempAdd.isEmpty() ) { | ||
666 | additionalInfo += i18n("\nCustomer ID: "); | ||
667 | additionalInfo += tempAdd;; | ||
668 | } | ||
669 | tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer()); | ||
670 | phoneS.replace( QRegExp("\\r"), ""); | ||
671 | if ( ! tempAdd.isEmpty() ) { | ||
672 | additionalInfo += i18n("\nUser1: "); | ||
673 | additionalInfo += tempAdd;; | ||
674 | } | ||
675 | tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer()); | ||
676 | phoneS.replace( QRegExp("\\r"), ""); | ||
677 | if ( ! tempAdd.isEmpty() ) { | ||
678 | additionalInfo += i18n("\nUser2: "); | ||
679 | additionalInfo += tempAdd;; | ||
680 | } | ||
681 | tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer()); | ||
682 | phoneS.replace( QRegExp("\\r"), ""); | ||
683 | if ( ! tempAdd.isEmpty() ) { | ||
684 | additionalInfo += i18n("\nUser3: "); | ||
685 | additionalInfo += tempAdd;; | ||
686 | } | ||
687 | tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); | ||
688 | phoneS.replace( QRegExp("\\r"), ""); | ||
689 | if ( ! tempAdd.isEmpty() ) { | ||
690 | additionalInfo += i18n("\nUser4: "); | ||
691 | additionalInfo += tempAdd;; | ||
692 | } | ||
693 | if (!additionalInfo.isEmpty() ) { | ||
694 | tempAdd = notesStr; | ||
695 | notesStr = "+++++++++++++++++++++++++++\n"; | ||
696 | notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:"); | ||
697 | notesStr += additionalInfo; | ||
698 | notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n"); | ||
699 | notesStr += "+++++++++++++++++++++++++++\n"; | ||
700 | notesStr += tempAdd; | ||
701 | } | ||
702 | addressee.setNote( notesStr ); | ||
703 | #if 0 | ||
704 | // pending | ||
705 | - IM address: no clue where to get info about the helper ID | ||
706 | -custom fields: difficult to implement - not implemented | ||
707 | -keys: makes no sense | ||
708 | #endif | ||
709 | |||
710 | if ( addAddressee( addressee )) | ||
711 | ++importedItems; | ||
712 | } | ||
713 | void KAImportOLdialog::slotCancel() | ||
714 | { | ||
715 | reject(); | ||
716 | } | ||
717 | |||
718 | bool KAImportOLdialog::addAddressee( KABC::Addressee a ) | ||
719 | { | ||
720 | bool add = true; | ||
721 | KABC::Addressee::List::Iterator it; | ||
722 | for ( it = mAList.begin(); it != mAList.end(); ++it ) { | ||
723 | if ( (*it).uid() == a.uid() ) { | ||
724 | add = false; | ||
725 | break; | ||
726 | } | ||
727 | } | ||
728 | if ( add ) { | ||
729 | if ( mABook->findByUid(a.uid() ).isEmpty()) | ||
730 | mAList.append ( a ); | ||
731 | else | ||
732 | add = false; | ||
733 | } | ||
734 | return add; | ||
735 | } | ||
diff --git a/kaddressbook/kaimportoldialog.h b/kaddressbook/kaimportoldialog.h index 41ea5f8..278935b 100644 --- a/kaddressbook/kaimportoldialog.h +++ b/kaddressbook/kaimportoldialog.h | |||
@@ -1,85 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 KOINCIDENCEEDITOR_H | ||
24 | #define KOINCIDENCEEDITOR_H | ||
25 | |||
26 | #include <kdialogbase.h> | ||
27 | |||
28 | #include <afxdisp.h> | ||
29 | |||
30 | #include <kabc/addressee.h> | ||
31 | #include <kabc/addressbook.h> | ||
32 | |||
33 | class QDateTime; | ||
34 | class QListView; | ||
35 | class OLEListViewItem; | ||
36 | class _ContactItem; | ||
37 | |||
38 | |||
39 | //using namespace KABC; | ||
40 | //class KABC::AddressBook; | ||
41 | |||
42 | /** | ||
43 | This is the base class for the calendar component editors. | ||
44 | */ | ||
45 | class KAImportOLdialog : public KDialogBase | ||
46 | { | ||
47 | Q_OBJECT | ||
48 | public: | ||
49 | /** | ||
50 | Construct new IncidenceEditor. | ||
51 | */ | ||
52 | KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook, | ||
53 | QWidget *parent ); | ||
54 | ~KAImportOLdialog(); | ||
55 | |||
56 | /** Initialize editor. This function creates the tab widgets. */ | ||
57 | void init(); | ||
58 | KABC::Addressee::List getAddressList(); | ||
59 | public slots: | ||
60 | |||
61 | |||
62 | signals: | ||
63 | |||
64 | protected slots: | ||
65 | void slotApply(); | ||
66 | void slotOk(); | ||
67 | void slotCancel(); | ||
68 | |||
69 | protected: | ||
70 | void setupFolderView(); | ||
71 | void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent); | ||
72 | void readContactData( DWORD folder ); | ||
73 | void ol2kapiContact( _ContactItem * ); | ||
74 | |||
75 | KABC::AddressBook * mABook; | ||
76 | QListView * mListView; | ||
77 | KABC::Addressee::List mAList; | ||
78 | bool addAddressee( KABC::Addressee a ); | ||
79 | private: | ||
80 | int importedItems; | ||
81 | }; | ||
82 | |||
83 | #endif | ||
84 | |||
85 | |||
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index 5639aa2..df3b551 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -1,215 +1,218 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | #include <qlistbox.h> | 30 | #include <qlistbox.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qbuttongroup.h> | 32 | #include <qbuttongroup.h> |
33 | #include <qhbox.h> | 33 | #include <qhbox.h> |
34 | #include <qcursor.h> | 34 | #include <qcursor.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qapplication.h> | 36 | #include <qapplication.h> |
37 | 37 | ||
38 | #include <kbuttonbox.h> | 38 | #include <kbuttonbox.h> |
39 | #include <klistview.h> | 39 | #include <klistview.h> |
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <kconfig.h> | 42 | #include <kconfig.h> |
43 | #include <kmessagebox.h> | ||
43 | #include <klineedit.h> | 44 | #include <klineedit.h> |
44 | #include <kcombobox.h> | 45 | #include <kcombobox.h> |
45 | #include <klocale.h> | 46 | #include <klocale.h> |
46 | #include <kdebug.h> | 47 | #include <kdebug.h> |
47 | #include <kglobal.h> | 48 | #include <kglobal.h> |
48 | #include <kiconloader.h> | 49 | #include <kiconloader.h> |
49 | 50 | ||
50 | #include <kabc/phonenumber.h> | 51 | #include <kabc/phonenumber.h> |
51 | 52 | ||
52 | #include "typecombo.h" | 53 | #include "typecombo.h" |
53 | 54 | ||
54 | #include "phoneeditwidget.h" | 55 | #include "phoneeditwidget.h" |
55 | 56 | ||
56 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | 57 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) |
57 | : QWidget(parent,name) | 58 | : QWidget(parent,name) |
58 | { | 59 | { |
59 | QGridLayout* gridLayout = new QGridLayout ( this, 2,2 ); | 60 | QGridLayout* gridLayout = new QGridLayout ( this, 2,2 ); |
60 | 61 | ||
61 | QLabel *temp = new QLabel( "", this ); | 62 | QLabel *temp = new QLabel( "", this ); |
62 | temp->setAlignment( Qt::AlignCenter ); | 63 | temp->setAlignment( Qt::AlignCenter ); |
63 | temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 64 | temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
64 | QPushButton *addBut = new QPushButton ( "add", this ); | 65 | QPushButton *addBut = new QPushButton ( "add", this ); |
65 | addBut->setPixmap ( SmallIcon("plus")); | 66 | addBut->setPixmap ( SmallIcon("plus")); |
66 | addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() ); | 67 | addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() ); |
67 | connect(addBut,SIGNAL(clicked ()),SLOT(addNumber())); | 68 | connect(addBut,SIGNAL(clicked ()),SLOT(addNumber())); |
68 | 69 | ||
69 | sv = new QScrollView( this ); | 70 | sv = new QScrollView( this ); |
70 | sv->setFrameStyle ( QFrame::Plain ); | 71 | sv->setFrameStyle ( QFrame::Plain ); |
71 | sv->setLineWidth ( 0 ); | 72 | sv->setLineWidth ( 0 ); |
72 | sv->setMidLineWidth ( 0 ); | 73 | sv->setMidLineWidth ( 0 ); |
73 | mw = new QWidget ( sv->viewport() ); | 74 | mw = new QWidget ( sv->viewport() ); |
74 | sv->addChild(mw); | 75 | sv->addChild(mw); |
75 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 76 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
76 | mainLayout = new QVBoxLayout ( mw ); | 77 | mainLayout = new QVBoxLayout ( mw ); |
77 | mainLayout->setMargin( 0 ); | 78 | mainLayout->setMargin( 0 ); |
78 | mainLayout->setSpacing( 0 ); | 79 | mainLayout->setSpacing( 0 ); |
79 | gridLayout->setMargin( 2 ); | 80 | gridLayout->setMargin( 2 ); |
80 | gridLayout->setSpacing( 4 ); | 81 | gridLayout->setSpacing( 4 ); |
81 | if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) { | 82 | if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) { |
82 | gridLayout->addWidget( addBut, 0, 0 ); | 83 | gridLayout->addWidget( addBut, 0, 0 ); |
83 | gridLayout->addWidget( temp, 0, 1 ); | 84 | gridLayout->addWidget( temp, 0, 1 ); |
84 | gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 ); | 85 | gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 ); |
85 | } else { | 86 | } else { |
86 | gridLayout->addWidget( temp, 1, 0 ); | 87 | gridLayout->addWidget( temp, 1, 0 ); |
87 | gridLayout->addWidget( addBut, 0, 0 ); | 88 | gridLayout->addWidget( addBut, 0, 0 ); |
88 | gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 ); | 89 | gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 ); |
89 | } | 90 | } |
90 | setDefaults(); | 91 | setDefaults(); |
91 | mTypeNumberEditList.setAutoDelete( true ); | 92 | mTypeNumberEditList.setAutoDelete( true ); |
92 | mPopup = new QPopupMenu( this ); | 93 | mPopup = new QPopupMenu( this ); |
93 | QStringList list = PhoneNumber::supportedTypeListNames(); | 94 | QStringList list = PhoneNumber::supportedTypeListNames(); |
94 | mPopupCount = list.count(); | 95 | mPopupCount = list.count(); |
95 | int i = 0; | 96 | int i = 0; |
96 | while ( i < mPopupCount ) { | 97 | while ( i < mPopupCount ) { |
97 | mPopup->insertItem( list[ i ], i ); | 98 | mPopup->insertItem( list[ i ], i ); |
98 | ++i; | 99 | ++i; |
99 | } | 100 | } |
100 | connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int))); | 101 | connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int))); |
101 | 102 | ||
102 | } | 103 | } |
103 | 104 | ||
104 | PhoneEditWidget::~PhoneEditWidget() | 105 | PhoneEditWidget::~PhoneEditWidget() |
105 | { | 106 | { |
106 | } | 107 | } |
107 | void PhoneEditWidget::setDefaults() | 108 | void PhoneEditWidget::setDefaults() |
108 | { | 109 | { |
109 | mTypeNumberEditList.clear(); | 110 | mTypeNumberEditList.clear(); |
110 | PhoneTypeNumberEdit* edit = appendEditCombo(); | 111 | PhoneTypeNumberEdit* edit = appendEditCombo(); |
111 | KABC::PhoneNumber phoneNumber; | 112 | KABC::PhoneNumber phoneNumber; |
112 | phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); | 113 | phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); |
113 | edit->setPhoneNumber( phoneNumber ); | 114 | edit->setPhoneNumber( phoneNumber ); |
114 | edit = appendEditCombo(); | 115 | edit = appendEditCombo(); |
115 | phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); | 116 | KABC::PhoneNumber phoneNumber2; |
116 | edit->setPhoneNumber( phoneNumber ); | 117 | phoneNumber2.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); |
118 | edit->setPhoneNumber( phoneNumber2 ); | ||
117 | edit = appendEditCombo(); | 119 | edit = appendEditCombo(); |
118 | phoneNumber.setType( KABC::PhoneNumber::Cell ); | 120 | KABC::PhoneNumber phoneNumber3; |
119 | edit->setPhoneNumber( phoneNumber ); | 121 | phoneNumber3.setType( KABC::PhoneNumber::Cell ); |
122 | edit->setPhoneNumber( phoneNumber3 ); | ||
120 | 123 | ||
121 | } | 124 | } |
122 | void PhoneEditWidget::addNumberInt( int index ) | 125 | void PhoneEditWidget::addNumberInt( int index ) |
123 | { | 126 | { |
124 | PhoneTypeNumberEdit* edit = appendEditCombo(); | 127 | PhoneTypeNumberEdit* edit = appendEditCombo(); |
125 | KABC::PhoneNumber phoneNumber; | 128 | KABC::PhoneNumber phoneNumber; |
126 | phoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); | 129 | phoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); |
127 | edit->setPhoneNumber( phoneNumber ); | 130 | edit->setPhoneNumber( phoneNumber ); |
128 | //verticalScrollBar()->setValue( 1024); | 131 | //verticalScrollBar()->setValue( 1024); |
129 | QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) ); | 132 | QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) ); |
130 | } | 133 | } |
131 | void PhoneEditWidget::bottomVisible() | 134 | void PhoneEditWidget::bottomVisible() |
132 | { | 135 | { |
133 | sv->setContentsPos ( 0, 1024 ); | 136 | sv->setContentsPos ( 0, 1024 ); |
134 | } | 137 | } |
135 | void PhoneEditWidget::addNumber() | 138 | void PhoneEditWidget::addNumber() |
136 | { | 139 | { |
137 | int i = 0; | 140 | int i = 0; |
138 | while ( i < mPopupCount ) { | 141 | while ( i < mPopupCount ) { |
139 | mPopup->setItemEnabled( i, true ); | 142 | mPopup->setItemEnabled( i, true ); |
140 | ++i; | 143 | ++i; |
141 | } | 144 | } |
142 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); | 145 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); |
143 | while ( edit ) { | 146 | while ( edit ) { |
144 | if ( edit->currentType() < mPopupCount -1 ) | 147 | if ( edit->currentType() < mPopupCount -1 ) |
145 | mPopup->setItemEnabled( edit->currentType(), false ); | 148 | mPopup->setItemEnabled( edit->currentType(), false ); |
146 | edit = mTypeNumberEditList.next(); | 149 | edit = mTypeNumberEditList.next(); |
147 | } | 150 | } |
148 | mPopup->popup( QCursor::pos() ); | 151 | mPopup->popup( QCursor::pos() ); |
149 | } | 152 | } |
150 | PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() | 153 | PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() |
151 | { | 154 | { |
152 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); | 155 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); |
153 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); | 156 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); |
154 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); | 157 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); |
155 | connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); | 158 | connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); |
156 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); | 159 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); |
157 | 160 | ||
158 | mainLayout->add( edit ); | 161 | mainLayout->add( edit ); |
159 | mTypeNumberEditList.append( edit ); | 162 | mTypeNumberEditList.append( edit ); |
160 | return edit; | 163 | return edit; |
161 | } | 164 | } |
162 | 165 | ||
163 | void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) | 166 | void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) |
164 | { | 167 | { |
165 | mPendingDelete = ew; | 168 | mPendingDelete = ew; |
166 | QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); | 169 | QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); |
167 | } | 170 | } |
168 | void PhoneEditWidget::pendingDelete() | 171 | void PhoneEditWidget::pendingDelete() |
169 | { | 172 | { |
170 | mTypeNumberEditList.removeRef( mPendingDelete ); | 173 | mTypeNumberEditList.removeRef( mPendingDelete ); |
171 | emit modified(); | 174 | emit modified(); |
172 | } | 175 | } |
173 | 176 | ||
174 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) | 177 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) |
175 | { | 178 | { |
176 | if ( li.isEmpty() ) { | 179 | if ( li.isEmpty() ) { |
177 | setDefaults(); | 180 | setDefaults(); |
178 | return; | 181 | return; |
179 | } | 182 | } |
180 | mTypeNumberEditList.clear(); | 183 | mTypeNumberEditList.clear(); |
181 | KABC::PhoneNumber::List::Iterator it; | 184 | KABC::PhoneNumber::List::Iterator it; |
182 | KABC::PhoneNumber::List list2 = li; | 185 | KABC::PhoneNumber::List list2 = li; |
183 | KABC::PhoneNumber::List list ; | 186 | KABC::PhoneNumber::List list ; |
184 | 187 | ||
185 | PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList(); | 188 | PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList(); |
186 | int i = 0; | 189 | int i = 0; |
187 | int max = tList.count(); | 190 | int max = tList.count(); |
188 | while ( i < max-1 ) { | 191 | while ( i < max-1 ) { |
189 | for ( it = list2.begin(); it != list2.end(); ++it ) { | 192 | for ( it = list2.begin(); it != list2.end(); ++it ) { |
190 | if ( (*it).type() == tList[i] ) { | 193 | if ( (*it).type() == tList[i] ) { |
191 | list.append( (*it ) ); | 194 | list.append( (*it ) ); |
192 | break; | 195 | break; |
193 | } | 196 | } |
194 | } | 197 | } |
195 | ++i; | 198 | ++i; |
196 | } | 199 | } |
197 | for ( it = list2.begin(); it != list2.end(); ++it ) { | 200 | for ( it = list2.begin(); it != list2.end(); ++it ) { |
198 | if ( (*it).type() == tList[ max-1 ] ) | 201 | if ( (*it).type() == tList[ max-1 ] ) |
199 | list.append( (*it ) ); | 202 | list.append( (*it ) ); |
200 | } | 203 | } |
201 | for ( it = list.begin(); it != list.end(); ++it ) { | 204 | for ( it = list.begin(); it != list.end(); ++it ) { |
202 | PhoneTypeNumberEdit* editNew = appendEditCombo(); | 205 | PhoneTypeNumberEdit* editNew = appendEditCombo(); |
203 | editNew->setPhoneNumber( (*it ) ); | 206 | editNew->setPhoneNumber( (*it ) ); |
204 | } | 207 | } |
205 | 208 | ||
206 | } | 209 | } |
207 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 210 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
208 | { | 211 | { |
209 | KABC::PhoneNumber::List retList; | 212 | KABC::PhoneNumber::List retList; |
210 | 213 | ||
211 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); | 214 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); |
212 | while ( edit ) { | 215 | while ( edit ) { |
213 | if ( edit->isValid() ) { | 216 | if ( edit->isValid() ) { |
214 | retList.append( edit->phoneNumber()); | 217 | retList.append( edit->phoneNumber()); |
215 | } | 218 | } |
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index a69846c..ee17da8 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h | |||
@@ -1,89 +1,90 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 JOURNALENTRY_H | 23 | #ifndef JOURNALENTRY_H |
24 | #define JOURNALENTRY_H | 24 | #define JOURNALENTRY_H |
25 | // | 25 | // |
26 | // Widget showing one Journal entry | 26 | // Widget showing one Journal entry |
27 | 27 | ||
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | class QLabel; | 32 | class QLabel; |
33 | class KTextEdit; | 33 | class KTextEdit; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class KLineEdit; | 35 | class KLineEdit; |
36 | class KOLocationBox; | 36 | class KOLocationBox; |
37 | 37 | ||
38 | using namespace KCal; | 38 | using namespace KCal; |
39 | 39 | ||
40 | class JournalEntry : public QFrame { | 40 | class JournalEntry : public QFrame { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | JournalEntry(Calendar *,QWidget *parent); | 43 | JournalEntry(Calendar *,QWidget *parent); |
44 | virtual ~JournalEntry(); | 44 | virtual ~JournalEntry(); |
45 | 45 | ||
46 | void setJournal(Journal *, bool saveJournal = true ); | 46 | void setJournal(Journal *, bool saveJournal = true ); |
47 | Journal *journal() const; | 47 | Journal *journal() const; |
48 | 48 | ||
49 | void setDate(const QDate &); | 49 | void setDate(const QDate &); |
50 | 50 | ||
51 | void clear(); | 51 | void clear(); |
52 | 52 | ||
53 | void flushEntry(); | 53 | void flushEntry(); |
54 | void setShowOnly(); | 54 | void setShowOnly(); |
55 | QSize sizeHint() const; | 55 | QSize sizeHint() const; |
56 | void setVisibleMode( bool b ) { visibleMode = b;} | 56 | void setVisibleMode( bool b ) { visibleMode = b;} |
57 | void fillCalendar( int id = 0 ); | 57 | void fillCalendar( int id = 0 ); |
58 | void resizeEvent(QResizeEvent* e ) ; | 58 | void resizeEvent(QResizeEvent* e ) ; |
59 | KTextEdit * editor() {return mEditor;}; | ||
59 | protected slots: | 60 | protected slots: |
60 | void slotSaveTemplate(); | 61 | void slotSaveTemplate(); |
61 | void slotLoadTemplate(); | 62 | void slotLoadTemplate(); |
62 | void toggleShowJournal(); | 63 | void toggleShowJournal(); |
63 | void setVisibleOn(); | 64 | void setVisibleOn(); |
64 | signals: | 65 | signals: |
65 | void deleteJournal(Journal *); | 66 | void deleteJournal(Journal *); |
66 | void newJournal(); | 67 | void newJournal(); |
67 | void showJournalOnly( Journal * ); | 68 | void showJournalOnly( Journal * ); |
68 | 69 | ||
69 | protected: | 70 | protected: |
70 | bool eventFilter( QObject *o, QEvent *e ); | 71 | bool eventFilter( QObject *o, QEvent *e ); |
71 | 72 | ||
72 | void writeJournal(); | 73 | void writeJournal(); |
73 | 74 | ||
74 | private: | 75 | private: |
75 | int mMaxWidDiff; | 76 | int mMaxWidDiff; |
76 | int mDeskWid; | 77 | int mDeskWid; |
77 | bool visibleMode; | 78 | bool visibleMode; |
78 | bool showOnlyMode; | 79 | bool showOnlyMode; |
79 | Calendar *mCalendar; | 80 | Calendar *mCalendar; |
80 | Journal *mJournal; | 81 | Journal *mJournal; |
81 | QDate mDate; | 82 | QDate mDate; |
82 | void keyPressEvent ( QKeyEvent * ) ; | 83 | void keyPressEvent ( QKeyEvent * ) ; |
83 | QComboBox *mCalendarBox; | 84 | QComboBox *mCalendarBox; |
84 | KOLocationBox * mTitle; | 85 | KOLocationBox * mTitle; |
85 | KTextEdit *mEditor; | 86 | KTextEdit *mEditor; |
86 | int heiHint; | 87 | int heiHint; |
87 | }; | 88 | }; |
88 | 89 | ||
89 | #endif | 90 | #endif |
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index a23a3b2..406df5a 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp | |||
@@ -1,241 +1,250 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 | 23 | ||
24 | // | 24 | // |
25 | // View of Journal entries | 25 | // View of Journal entries |
26 | 26 | ||
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qscrollview.h> | 28 | #include <qscrollview.h> |
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | #include <qhbox.h> | 30 | #include <qhbox.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | 35 | ||
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include "koprefs.h" | 38 | #include "koprefs.h" |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <ktextedit.h> | ||
40 | 41 | ||
41 | #include <libkcal/calendar.h> | 42 | #include <libkcal/calendar.h> |
42 | 43 | ||
43 | #include "journalentry.h" | 44 | #include "journalentry.h" |
44 | 45 | ||
45 | #include "kojournalview.h" | 46 | #include "kojournalview.h" |
46 | using namespace KOrg; | 47 | using namespace KOrg; |
47 | 48 | ||
48 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, | 49 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, |
49 | const char *name) | 50 | const char *name) |
50 | : KOrg::BaseView(calendar, parent, name) | 51 | : KOrg::BaseView(calendar, parent, name) |
51 | { | 52 | { |
52 | mCalendar = calendar; | 53 | mCalendar = calendar; |
53 | QHBox * vb = new QHBox ( this ); | 54 | QHBox * vb = new QHBox ( this ); |
54 | QPushButton * newJournal = new QPushButton( vb ); | 55 | QPushButton * newJournal = new QPushButton( vb ); |
55 | QPixmap icon; | 56 | QPixmap icon; |
56 | if ( QApplication::desktop()->width() < 321 ) | 57 | if ( QApplication::desktop()->width() < 321 ) |
57 | icon = SmallIcon("ko16old"); | 58 | icon = SmallIcon("ko16old"); |
58 | else | 59 | else |
59 | icon = SmallIcon("ko24old"); | 60 | icon = SmallIcon("ko24old"); |
60 | newJournal->setPixmap (icon ) ; | 61 | newJournal->setPixmap (icon ) ; |
61 | int size = newJournal->sizeHint().height(); | 62 | int size = newJournal->sizeHint().height(); |
62 | newJournal->setFixedSize( size, size ); | 63 | newJournal->setFixedSize( size, size ); |
63 | mDateLabel = new QLabel ( vb ); | 64 | mDateLabel = new QLabel ( vb ); |
64 | mDateLabel->setMargin(1); | 65 | mDateLabel->setMargin(1); |
65 | mDateLabel->setAlignment(AlignCenter); | 66 | mDateLabel->setAlignment(AlignCenter); |
66 | QScrollView * sv = new QScrollView( this ); | 67 | QScrollView * sv = new QScrollView( this ); |
67 | QVBoxLayout * hbl = new QVBoxLayout( this ); | 68 | QVBoxLayout * hbl = new QVBoxLayout( this ); |
68 | hbl->addWidget( vb ); | 69 | hbl->addWidget( vb ); |
69 | hbl->addWidget( sv ); | 70 | hbl->addWidget( sv ); |
70 | parWid = new QWidget( sv->viewport() ); | 71 | parWid = new QWidget( sv->viewport() ); |
71 | sv->addChild(parWid); | 72 | sv->addChild(parWid); |
72 | sv->setResizePolicy( QScrollView:: AutoOneFit ); | 73 | sv->setResizePolicy( QScrollView:: AutoOneFit ); |
73 | mTopLayout = new QVBoxLayout(parWid); | 74 | mTopLayout = new QVBoxLayout(parWid); |
74 | connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); | 75 | connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); |
75 | getNewEntry(); | 76 | getNewEntry(); |
76 | } | 77 | } |
77 | 78 | ||
78 | KOJournalView::~KOJournalView() | 79 | KOJournalView::~KOJournalView() |
79 | { | 80 | { |
80 | } | 81 | } |
81 | 82 | ||
82 | int KOJournalView::currentDateCount() | 83 | int KOJournalView::currentDateCount() |
83 | { | 84 | { |
84 | return 0; | 85 | return 0; |
85 | } | 86 | } |
86 | JournalEntry* KOJournalView::getNewEntry() | 87 | JournalEntry* KOJournalView::getNewEntry() |
87 | { | 88 | { |
88 | JournalEntry* Entry = new JournalEntry(mCalendar,parWid); | 89 | JournalEntry* Entry = new JournalEntry(mCalendar,parWid); |
89 | jEntries.append( Entry ); | 90 | jEntries.append( Entry ); |
90 | mTopLayout->addWidget(Entry); | 91 | mTopLayout->addWidget(Entry); |
91 | Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 92 | Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); |
92 | connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; | 93 | connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; |
93 | connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; | 94 | connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; |
94 | connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; | 95 | connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; |
95 | return Entry; | 96 | return Entry; |
96 | } | 97 | } |
97 | 98 | ||
98 | QPtrList<Incidence> KOJournalView::selectedIncidences() | 99 | QPtrList<Incidence> KOJournalView::selectedIncidences() |
99 | { | 100 | { |
100 | QPtrList<Incidence> eventList; | 101 | QPtrList<Incidence> eventList; |
101 | 102 | ||
102 | return eventList; | 103 | return eventList; |
103 | } | 104 | } |
104 | void KOJournalView::updateConfig() | 105 | void KOJournalView::updateConfig() |
105 | { | 106 | { |
106 | JournalEntry* mEntry = jEntries.first(); | 107 | JournalEntry* mEntry = jEntries.first(); |
107 | while ( mEntry ) { | 108 | while ( mEntry ) { |
108 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 109 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); |
109 | mEntry = jEntries.next(); | 110 | mEntry = jEntries.next(); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | void KOJournalView::updateView() | 113 | void KOJournalView::updateView() |
113 | { | 114 | { |
114 | JournalEntry* mEntry = jEntries.first(); | 115 | JournalEntry* mEntry = jEntries.first(); |
115 | while ( mEntry ) { | 116 | while ( mEntry ) { |
116 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 117 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); |
117 | mEntry = jEntries.next(); | 118 | mEntry = jEntries.next(); |
118 | } | 119 | } |
119 | showDates( mDate, QDate() ); | 120 | showDates( mDate, QDate() ); |
120 | } | 121 | } |
121 | void KOJournalView::checkModified() | 122 | void KOJournalView::checkModified() |
122 | { | 123 | { |
123 | flushView(); | 124 | flushView(); |
124 | } | 125 | } |
125 | void KOJournalView::flushView() | 126 | void KOJournalView::flushView() |
126 | { | 127 | { |
127 | static bool ff = false; | 128 | static bool ff = false; |
128 | if ( ff ) return; | 129 | if ( ff ) return; |
129 | ff = true; | 130 | ff = true; |
130 | JournalEntry* mEntry = jEntries.first(); | 131 | JournalEntry* mEntry = jEntries.first(); |
131 | while ( mEntry ) { | 132 | while ( mEntry ) { |
132 | mEntry->flushEntry(); | 133 | mEntry->flushEntry(); |
133 | mEntry = jEntries.next(); | 134 | mEntry = jEntries.next(); |
134 | } | 135 | } |
135 | ff = false; | 136 | ff = false; |
136 | } | 137 | } |
137 | 138 | ||
138 | void KOJournalView::clearList() | 139 | void KOJournalView::clearList() |
139 | { | 140 | { |
140 | JournalEntry* mEntry = jEntries.first(); | 141 | JournalEntry* mEntry = jEntries.first(); |
141 | while ( mEntry ) { | 142 | while ( mEntry ) { |
142 | mEntry->clear(); | 143 | mEntry->clear(); |
143 | mEntry = jEntries.next(); | 144 | mEntry = jEntries.next(); |
144 | } | 145 | } |
145 | } | 146 | } |
146 | void KOJournalView::newJournal() | 147 | void KOJournalView::newJournal() |
147 | { | 148 | { |
148 | //qDebug(" KOJournalView::newJournal()"); | 149 | //qDebug(" KOJournalView::newJournal()"); |
149 | flushView(); | 150 | flushView(); |
150 | Journal* mJournal = new Journal; | 151 | Journal* mJournal = new Journal; |
151 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 152 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
152 | mCalendar->addJournal(mJournal); | 153 | mCalendar->addJournal(mJournal); |
153 | showDates( mDate, QDate() ); | 154 | showDates( mDate, QDate() ); |
154 | } | 155 | } |
155 | 156 | ||
156 | void KOJournalView::showOnly ( Journal* j ) | 157 | void KOJournalView::showOnly ( Journal* j ) |
157 | { | 158 | { |
158 | //qDebug("showOnly %x ", j); | 159 | //qDebug("showOnly %x ", j); |
159 | flushView(); | 160 | flushView(); |
160 | if ( j == 0 ) { | 161 | if ( j == 0 ) { |
161 | showDates( mDate, QDate() ); | 162 | showDates( mDate, QDate() ); |
162 | return; | 163 | return; |
163 | } | 164 | } |
164 | QPtrList<Journal> jl; | 165 | QPtrList<Journal> jl; |
165 | jl.append ( j ); | 166 | jl.append ( j ); |
166 | showList( jl ); | 167 | showList( jl ); |
167 | JournalEntry* mEntry = jEntries.first(); | 168 | JournalEntry* mEntry = jEntries.first(); |
168 | mEntry->setShowOnly(); | 169 | mEntry->setShowOnly(); |
169 | } | 170 | } |
170 | void KOJournalView::showList(QPtrList<Journal> jl) | 171 | void KOJournalView::showList(QPtrList<Journal> jl) |
171 | { | 172 | { |
172 | static bool ff = false; | 173 | static bool ff = false; |
173 | if ( ff ) return; | 174 | if ( ff ) return; |
174 | ff = true; | 175 | ff = true; |
175 | //qDebug("KOJournalView::showList %d",jl.count() ); | 176 | //qDebug("KOJournalView::showList %d",jl.count() ); |
176 | JournalEntry* mEntry = jEntries.first(); | 177 | JournalEntry* mEntry = jEntries.first(); |
177 | JournalEntry* firstEntry = mEntry; | 178 | JournalEntry* firstEntry = mEntry; |
178 | int count = jl.count(); | 179 | int count = jl.count(); |
179 | int iii = 0; | 180 | int iii = 0; |
181 | QWidget* fw = qApp->focusWidget (); | ||
180 | while ( iii < count ) { | 182 | while ( iii < count ) { |
181 | if ( !mEntry ) { | 183 | if ( !mEntry ) { |
182 | mEntry = getNewEntry(); | 184 | mEntry = getNewEntry(); |
183 | mEntry->setVisibleMode( true ); | 185 | mEntry->setVisibleMode( true ); |
184 | mEntry->setDate(mDate); | 186 | mEntry->setDate(mDate); |
185 | mEntry->setJournal(jl.at(iii), false); | 187 | mEntry->setJournal(jl.at(iii), false); |
186 | mEntry->setVisibleMode( true ); | 188 | mEntry->setVisibleMode( true ); |
187 | mEntry->show(); | 189 | mEntry->show(); |
188 | mEntry = 0; | 190 | mEntry = 0; |
189 | } else { | 191 | } else { |
192 | int xxx = -1, yyy = -1; | ||
193 | if ( ((QWidget*) mEntry->editor() ) == fw ) { | ||
194 | mEntry->editor()->getCursorPosition( &xxx,&yyy); | ||
195 | } | ||
190 | mEntry->setVisibleMode( true ); | 196 | mEntry->setVisibleMode( true ); |
191 | mEntry->setDate(mDate); | 197 | mEntry->setDate(mDate); |
192 | mEntry->setJournal(jl.at(iii), false); | 198 | mEntry->setJournal(jl.at(iii), false); |
193 | mEntry->setVisibleMode( true ); | 199 | mEntry->setVisibleMode( true ); |
194 | mEntry->show(); | 200 | mEntry->show(); |
201 | if ( xxx > -1 && yyy > -1 ) { | ||
202 | mEntry->editor()->setCursorPosition( xxx, yyy ); | ||
203 | } | ||
195 | mEntry = jEntries.next(); | 204 | mEntry = jEntries.next(); |
196 | } | 205 | } |
197 | ++iii; | 206 | ++iii; |
198 | } | 207 | } |
199 | while ( mEntry ) { | 208 | while ( mEntry ) { |
200 | mEntry->setDate(mDate); | 209 | mEntry->setDate(mDate); |
201 | mEntry->clear(); | 210 | mEntry->clear(); |
202 | if ( mEntry != firstEntry ) { | 211 | if ( mEntry != firstEntry ) { |
203 | mEntry->hide(); | 212 | mEntry->hide(); |
204 | mEntry->setVisibleMode( false ); | 213 | mEntry->setVisibleMode( false ); |
205 | } | 214 | } |
206 | else { | 215 | else { |
207 | mEntry->setVisibleMode( true ); | 216 | mEntry->setVisibleMode( true ); |
208 | mEntry->show(); | 217 | mEntry->show(); |
209 | } | 218 | } |
210 | mEntry = jEntries.next(); | 219 | mEntry = jEntries.next(); |
211 | } | 220 | } |
212 | ff = false; | 221 | ff = false; |
213 | } | 222 | } |
214 | 223 | ||
215 | void KOJournalView::showDates(const QDate &start, const QDate &) | 224 | void KOJournalView::showDates(const QDate &start, const QDate &) |
216 | { | 225 | { |
217 | mDate = start; | 226 | mDate = start; |
218 | mDateLabel->setText(KGlobal::locale()->formatDate(mDate)); | 227 | mDateLabel->setText(KGlobal::locale()->formatDate(mDate)); |
219 | QPtrList<Journal> jl = calendar()->journals4Date( start ); | 228 | QPtrList<Journal> jl = calendar()->journals4Date( start ); |
220 | showList( jl ); | 229 | showList( jl ); |
221 | } | 230 | } |
222 | 231 | ||
223 | void KOJournalView::showEvents(QPtrList<Event>) | 232 | void KOJournalView::showEvents(QPtrList<Event>) |
224 | { | 233 | { |
225 | // After new creation of list view no events are selected. | 234 | // After new creation of list view no events are selected. |
226 | // emit incidenceSelected( 0 ); | 235 | // emit incidenceSelected( 0 ); |
227 | } | 236 | } |
228 | 237 | ||
229 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) | 238 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) |
230 | { | 239 | { |
231 | updateView(); | 240 | updateView(); |
232 | } | 241 | } |
233 | 242 | ||
234 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) |
235 | { | 244 | { |
236 | //qDebug("keyPressEven "); | 245 | //qDebug("keyPressEven "); |
237 | if ( e->state() == Qt::ControlButton ) { | 246 | if ( e->state() == Qt::ControlButton ) { |
238 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) | 247 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) |
239 | e->ignore(); | 248 | e->ignore(); |
240 | } | 249 | } |
241 | } | 250 | } |
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 59be506..f376e6c 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -754,192 +754,194 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS | |||
754 | QStringList list = QStringList::split( " ", message ); | 754 | QStringList list = QStringList::split( " ", message ); |
755 | int i = 0; | 755 | int i = 0; |
756 | while ( i < list.count ( ) ) { | 756 | while ( i < list.count ( ) ) { |
757 | //qDebug("add%sdd ",list[i].latin1() ); | 757 | //qDebug("add%sdd ",list[i].latin1() ); |
758 | proc->addArgument( list[i] ); | 758 | proc->addArgument( list[i] ); |
759 | //KMessageBox::sorry( 0,list[i]); | 759 | //KMessageBox::sorry( 0,list[i]); |
760 | ++i; | 760 | ++i; |
761 | } | 761 | } |
762 | } else { | 762 | } else { |
763 | proc->addArgument(message ); | 763 | proc->addArgument(message ); |
764 | //KMessageBox::sorry( 0, message ); | 764 | //KMessageBox::sorry( 0, message ); |
765 | 765 | ||
766 | } | 766 | } |
767 | 767 | ||
768 | parameters2 = translateMessage(parameters2, urls, "" ); | 768 | parameters2 = translateMessage(parameters2, urls, "" ); |
769 | QString arg = "to='%1'"; | 769 | QString arg = "to='%1'"; |
770 | arg = arg.arg( emails ) + ","+parameters2;; | 770 | arg = arg.arg( emails ) + ","+parameters2;; |
771 | 771 | ||
772 | //KMessageBox::sorry( 0,arg ); | 772 | //KMessageBox::sorry( 0,arg ); |
773 | //qDebug("2add%sdd ",arg.latin1() ); | 773 | //qDebug("2add%sdd ",arg.latin1() ); |
774 | proc->addArgument( arg); | 774 | proc->addArgument( arg); |
775 | proc->launch(""); | 775 | proc->launch(""); |
776 | #endif | 776 | #endif |
777 | 777 | ||
778 | return true; | 778 | return true; |
779 | } | 779 | } |
780 | 780 | ||
781 | /************************************************************************** | 781 | /************************************************************************** |
782 | * | 782 | * |
783 | **************************************************************************/ | 783 | **************************************************************************/ |
784 | 784 | ||
785 | 785 | ||
786 | //calls the emailapplication and creates a mail with parameter emails as recipients | 786 | //calls the emailapplication and creates a mail with parameter emails as recipients |
787 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 787 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
788 | { | 788 | { |
789 | 789 | ||
790 | QString channel; | 790 | QString channel; |
791 | QString message; | 791 | QString message; |
792 | QString parameters; | 792 | QString parameters; |
793 | 793 | ||
794 | 794 | ||
795 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 795 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
796 | if (client == KPimGlobalPrefs::OTHER_EMC) | 796 | if (client == KPimGlobalPrefs::OTHER_EMC) |
797 | { | 797 | { |
798 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 798 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
799 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 799 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
800 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 800 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
801 | } | 801 | } |
802 | else | 802 | else |
803 | { | 803 | { |
804 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 804 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
805 | if (!dai) | 805 | if (!dai) |
806 | { | 806 | { |
807 | qDebug("could not find configured email application."); | 807 | qDebug("could not find configured email application."); |
808 | return false; | 808 | return false; |
809 | } | 809 | } |
810 | channel = dai->_channel; | 810 | channel = dai->_channel; |
811 | message = dai->_message; | 811 | message = dai->_message; |
812 | parameters = dai->_parameters; | 812 | parameters = dai->_parameters; |
813 | } | 813 | } |
814 | 814 | ||
815 | #ifdef DESKTOP_VERSION | 815 | #ifdef DESKTOP_VERSION |
816 | //message = channel + " " +message + " \""+ parameters + "\""; | 816 | //message = channel + " " +message + " \""+ parameters + "\""; |
817 | #endif | 817 | #endif |
818 | //first check if one of the mailers need the emails right in the message. | 818 | //first check if one of the mailers need the emails right in the message. |
819 | message = translateMessage(message, name, emailadress); | 819 | message = translateMessage(message, name, emailadress); |
820 | 820 | ||
821 | #ifdef DEBUG_EXT_APP_HANDLER | 821 | #ifdef DEBUG_EXT_APP_HANDLER |
822 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 822 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
823 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 823 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
824 | #endif | 824 | #endif |
825 | 825 | ||
826 | #ifndef DESKTOP_VERSION | 826 | #ifndef DESKTOP_VERSION |
827 | QCopEnvelope e(channel.latin1(), message.latin1()); | 827 | QCopEnvelope e(channel.latin1(), message.latin1()); |
828 | //US we need no names in the To field. The emailadresses are enough | 828 | //US we need no names in the To field. The emailadresses are enough |
829 | 829 | ||
830 | passParameters(&e, parameters, name, emailadress); | 830 | passParameters(&e, parameters, name, emailadress); |
831 | #else // DESKTOP_VERSION | 831 | #else // DESKTOP_VERSION |
832 | 832 | ||
833 | //KMessageBox::sorry( 0,channel ); | 833 | //KMessageBox::sorry( 0,channel ); |
834 | QProcess * proc = new QProcess( this ); | 834 | QProcess * proc = new QProcess( this ); |
835 | proc->addArgument( channel ); | 835 | proc->addArgument( channel ); |
836 | if ( message.find (" " ) > 0 ) { | 836 | if ( message.find (" " ) > 0 ) { |
837 | QStringList list = QStringList::split( " ", message ); | 837 | QStringList list = QStringList::split( " ", message ); |
838 | int i = 0; | 838 | int i = 0; |
839 | while ( i < list.count ( ) ) { | 839 | while ( i < list.count ( ) ) { |
840 | //qDebug("add%sdd ",list[i].latin1() ); | 840 | //qDebug("add%sdd ",list[i].latin1() ); |
841 | proc->addArgument( list[i] ); | 841 | proc->addArgument( list[i] ); |
842 | //KMessageBox::sorry( 0,list[i]); | 842 | //KMessageBox::sorry( 0,list[i]); |
843 | ++i; | 843 | ++i; |
844 | } | 844 | } |
845 | } else { | 845 | } else { |
846 | proc->addArgument(message ); | 846 | proc->addArgument(message ); |
847 | 847 | ||
848 | } | 848 | } |
849 | parameters = translateMessage(parameters, name, emailadress); | 849 | parameters = translateMessage(parameters, name, emailadress); |
850 | |||
851 | //KMessageBox::information(0,parameters); | ||
850 | proc->addArgument( parameters ); | 852 | proc->addArgument( parameters ); |
851 | proc->launch(""); | 853 | proc->launch(""); |
852 | #endif | 854 | #endif |
853 | 855 | ||
854 | return true; | 856 | return true; |
855 | } | 857 | } |
856 | 858 | ||
857 | /************************************************************************** | 859 | /************************************************************************** |
858 | * | 860 | * |
859 | **************************************************************************/ | 861 | **************************************************************************/ |
860 | 862 | ||
861 | //calls the emailapplication and creates a mail with parameter as recipients | 863 | //calls the emailapplication and creates a mail with parameter as recipients |
862 | // parameters format is | 864 | // parameters format is |
863 | // NAME <EMAIL>:SUBJECT | 865 | // NAME <EMAIL>:SUBJECT |
864 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 866 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
865 | { | 867 | { |
866 | QString line = adressline; | 868 | QString line = adressline; |
867 | 869 | ||
868 | int first = line.find( "<"); | 870 | int first = line.find( "<"); |
869 | int last = line.find( ">"); | 871 | int last = line.find( ">"); |
870 | QString name = line.left(first); | 872 | QString name = line.left(first); |
871 | QString emailadress = line.mid(first+1, last-first-1); | 873 | QString emailadress = line.mid(first+1, last-first-1); |
872 | 874 | ||
873 | //Subject can not be handled right now. | 875 | //Subject can not be handled right now. |
874 | return mailToOneContact( name, emailadress ); | 876 | return mailToOneContact( name, emailadress ); |
875 | 877 | ||
876 | } | 878 | } |
877 | 879 | ||
878 | 880 | ||
879 | /************************************************************************** | 881 | /************************************************************************** |
880 | * | 882 | * |
881 | **************************************************************************/ | 883 | **************************************************************************/ |
882 | 884 | ||
883 | //calls the phoneapplication with the number | 885 | //calls the phoneapplication with the number |
884 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 886 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
885 | { | 887 | { |
886 | #ifndef DESKTOP_VERSION | 888 | #ifndef DESKTOP_VERSION |
887 | QString channel; | 889 | QString channel; |
888 | QString message; | 890 | QString message; |
889 | QString parameters; | 891 | QString parameters; |
890 | 892 | ||
891 | 893 | ||
892 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 894 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
893 | if (client == KPimGlobalPrefs::OTHER_PHC) | 895 | if (client == KPimGlobalPrefs::OTHER_PHC) |
894 | { | 896 | { |
895 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 897 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
896 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 898 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
897 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 899 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
898 | } | 900 | } |
899 | else | 901 | else |
900 | { | 902 | { |
901 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 903 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
902 | if (!dai) | 904 | if (!dai) |
903 | { | 905 | { |
904 | qDebug("could not find configured phone application."); | 906 | qDebug("could not find configured phone application."); |
905 | return false; | 907 | return false; |
906 | } | 908 | } |
907 | channel = dai->_channel; | 909 | channel = dai->_channel; |
908 | message = dai->_message; | 910 | message = dai->_message; |
909 | parameters = dai->_parameters; | 911 | parameters = dai->_parameters; |
910 | } | 912 | } |
911 | 913 | ||
912 | 914 | ||
913 | //first check if one of the mailers need the emails right in the message. | 915 | //first check if one of the mailers need the emails right in the message. |
914 | message = translateMessage(message, phonenumber, ""); | 916 | message = translateMessage(message, phonenumber, ""); |
915 | 917 | ||
916 | 918 | ||
917 | #ifdef DEBUG_EXT_APP_HANDLER | 919 | #ifdef DEBUG_EXT_APP_HANDLER |
918 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 920 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
919 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 921 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
920 | #endif | 922 | #endif |
921 | 923 | ||
922 | QCopEnvelope e(channel.latin1(), message.latin1()); | 924 | QCopEnvelope e(channel.latin1(), message.latin1()); |
923 | //US we need no names in the To field. The emailadresses are enough | 925 | //US we need no names in the To field. The emailadresses are enough |
924 | 926 | ||
925 | passParameters(&e, parameters, phonenumber, ""); | 927 | passParameters(&e, parameters, phonenumber, ""); |
926 | 928 | ||
927 | 929 | ||
928 | #else | 930 | #else |
929 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 931 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
930 | #endif | 932 | #endif |
931 | 933 | ||
932 | 934 | ||
933 | return true; | 935 | return true; |
934 | } | 936 | } |
935 | 937 | ||
936 | /************************************************************************** | 938 | /************************************************************************** |
937 | * | 939 | * |
938 | **************************************************************************/ | 940 | **************************************************************************/ |
939 | 941 | ||
940 | //calls the smsapplication with the number | 942 | //calls the smsapplication with the number |
941 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 943 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
942 | { | 944 | { |
943 | #ifndef DESKTOP_VERSION | 945 | #ifndef DESKTOP_VERSION |
944 | QString channel; | 946 | QString channel; |
945 | QString message; | 947 | QString message; |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index b7929ec..5708dfc 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -19,224 +19,224 @@ | |||
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 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qapplication.h> | 52 | #include <qapplication.h> |
53 | 53 | ||
54 | #include <klocale.h> | 54 | #include <klocale.h> |
55 | #include <kglobal.h> | 55 | #include <kglobal.h> |
56 | #include <kconfig.h> | 56 | #include <kconfig.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | 58 | ||
59 | QDateTime KSyncManager::mRequestedSyncEvent; | 59 | QDateTime KSyncManager::mRequestedSyncEvent; |
60 | 60 | ||
61 | 61 | ||
62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
64 | { | 64 | { |
65 | mServerSocket = 0; | 65 | mServerSocket = 0; |
66 | bar = new QProgressBar ( 1, 0 ); | 66 | bar = new QProgressBar ( 1, 0 ); |
67 | bar->setCaption (""); | 67 | bar->setCaption (""); |
68 | mWriteBackInPast = 2; | 68 | mWriteBackInPast = 2; |
69 | 69 | ||
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | KSyncManager::~KSyncManager() | 73 | KSyncManager::~KSyncManager() |
74 | { | 74 | { |
75 | delete bar; | 75 | delete bar; |
76 | } | 76 | } |
77 | 77 | ||
78 | void KSyncManager::setDefaultFileName( QString s) | 78 | void KSyncManager::setDefaultFileName( QString s) |
79 | { | 79 | { |
80 | mDefFileName = s ; | 80 | mDefFileName = s ; |
81 | if ( mPrefs->mPassiveSyncAutoStart ) | 81 | if ( mPrefs->mPassiveSyncAutoStart ) |
82 | enableQuick( false ); | 82 | enableQuick( false ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KSyncManager::fillSyncMenu() | 85 | void KSyncManager::fillSyncMenu() |
86 | { | 86 | { |
87 | if ( mSyncMenu->count() ) | 87 | if ( mSyncMenu->count() ) |
88 | mSyncMenu->clear(); | 88 | mSyncMenu->clear(); |
89 | 89 | ||
90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
91 | mSyncMenu->insertSeparator(); | 91 | mSyncMenu->insertSeparator(); |
92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
95 | clearMenu->insertSeparator(); | 95 | clearMenu->insertSeparator(); |
96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
97 | mSyncMenu->insertSeparator(); | 97 | mSyncMenu->insertSeparator(); |
98 | if ( mServerSocket == 0 ) { | 98 | if ( mServerSocket == 0 ) { |
99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
100 | } else { | 100 | } else { |
101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
102 | } | 102 | } |
103 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
105 | mSyncMenu->insertSeparator(); | 105 | mSyncMenu->insertSeparator(); |
106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
107 | config.setGroup("General"); | 107 | config.setGroup("General"); |
108 | QStringList prof = config.readListEntry("SyncProfileNames"); | 108 | QStringList prof = config.readListEntry("SyncProfileNames"); |
109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
110 | if ( prof.count() < 2 ) { | 110 | if ( prof.count() < 2 ) { |
111 | prof.clear(); | 111 | prof.clear(); |
112 | QString externalName; | 112 | QString externalName; |
113 | #ifdef DESKTOP_VERSION | 113 | #ifdef DESKTOP_VERSION |
114 | #ifdef _WIN32_ | 114 | #ifdef _WIN32_ |
115 | externalName = "OutLook(not_implemented)"; | 115 | externalName = "OutLook"; |
116 | #else | 116 | #else |
117 | externalName = "KDE_Desktop"; | 117 | externalName = "KDE_Desktop"; |
118 | #endif | 118 | #endif |
119 | #else | 119 | #else |
120 | externalName = "Sharp_DTM"; | 120 | externalName = "Sharp_DTM"; |
121 | #endif | 121 | #endif |
122 | prof << externalName; | 122 | prof << externalName; |
123 | prof << i18n("Local_file"); | 123 | prof << i18n("Local_file"); |
124 | prof << i18n("Last_file"); | 124 | prof << i18n("Last_file"); |
125 | KSyncProfile* temp = new KSyncProfile (); | 125 | KSyncProfile* temp = new KSyncProfile (); |
126 | temp->setName( prof[0] ); | 126 | temp->setName( prof[0] ); |
127 | temp->writeConfig(&config); | 127 | temp->writeConfig(&config); |
128 | temp->setName( prof[1] ); | 128 | temp->setName( prof[1] ); |
129 | temp->writeConfig(&config); | 129 | temp->writeConfig(&config); |
130 | temp->setName( prof[2] ); | 130 | temp->setName( prof[2] ); |
131 | temp->writeConfig(&config); | 131 | temp->writeConfig(&config); |
132 | config.setGroup("General"); | 132 | config.setGroup("General"); |
133 | config.writeEntry("SyncProfileNames",prof); | 133 | config.writeEntry("SyncProfileNames",prof); |
134 | config.writeEntry("ExternSyncProfiles",externalName); | 134 | config.writeEntry("ExternSyncProfiles",externalName); |
135 | config.sync(); | 135 | config.sync(); |
136 | delete temp; | 136 | delete temp; |
137 | } | 137 | } |
138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
139 | mSyncProfileNames = prof; | 139 | mSyncProfileNames = prof; |
140 | unsigned int i; | 140 | unsigned int i; |
141 | for ( i = 0; i < prof.count(); ++i ) { | 141 | for ( i = 0; i < prof.count(); ++i ) { |
142 | QString insertText = prof[i]; | 142 | QString insertText = prof[i]; |
143 | if ( i == 0 ) { | 143 | if ( i == 0 ) { |
144 | #ifdef DESKTOP_VERSION | 144 | #ifdef DESKTOP_VERSION |
145 | #ifdef _WIN32_ | 145 | #ifdef _WIN32_ |
146 | insertText = "OutLook(not_implemented)"; | 146 | insertText = "OutLook"; |
147 | #else | 147 | #else |
148 | insertText = "KDE_Desktop"; | 148 | insertText = "KDE_Desktop"; |
149 | #endif | 149 | #endif |
150 | #else | 150 | #else |
151 | insertText = "Sharp_DTM"; | 151 | insertText = "Sharp_DTM"; |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | mSyncMenu->insertItem( insertText, 1000+i ); | 154 | mSyncMenu->insertItem( insertText, 1000+i ); |
155 | clearMenu->insertItem( insertText, 1000+i ); | 155 | clearMenu->insertItem( insertText, 1000+i ); |
156 | if ( i == 2 ) | 156 | if ( i == 2 ) |
157 | mSyncMenu->insertSeparator(); | 157 | mSyncMenu->insertSeparator(); |
158 | } | 158 | } |
159 | QDir app_dir; | 159 | QDir app_dir; |
160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
161 | if ( mTargetApp == PWMPI) { | 161 | if ( mTargetApp == PWMPI) { |
162 | mSyncMenu->removeItem( 1000 ); | 162 | mSyncMenu->removeItem( 1000 ); |
163 | clearMenu->removeItem( 1000 ); | 163 | clearMenu->removeItem( 1000 ); |
164 | } | 164 | } |
165 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
167 | mSyncMenu->removeItem( 1000 ); | 167 | mSyncMenu->removeItem( 1000 ); |
168 | clearMenu->removeItem( 1000 ); | 168 | clearMenu->removeItem( 1000 ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mSyncMenu->removeItem( 1002 ); | 171 | mSyncMenu->removeItem( 1002 ); |
172 | clearMenu->removeItem( 1002 ); | 172 | clearMenu->removeItem( 1002 ); |
173 | } | 173 | } |
174 | void KSyncManager::slotClearMenu( int action ) | 174 | void KSyncManager::slotClearMenu( int action ) |
175 | { | 175 | { |
176 | QString syncDevice; | 176 | QString syncDevice; |
177 | if ( action > 999 ) { | 177 | if ( action > 999 ) { |
178 | syncDevice = mSyncProfileNames[action - 1000] ; | 178 | syncDevice = mSyncProfileNames[action - 1000] ; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | int result = 0; | 183 | int result = 0; |
184 | QString sd; | 184 | QString sd; |
185 | if ( syncDevice.isEmpty() ) | 185 | if ( syncDevice.isEmpty() ) |
186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
187 | else | 187 | else |
188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
189 | 189 | ||
190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
191 | 0, 1 ); | 191 | 0, 1 ); |
192 | if ( result ) | 192 | if ( result ) |
193 | return; | 193 | return; |
194 | mImplementation->removeSyncInfo( syncDevice ); | 194 | mImplementation->removeSyncInfo( syncDevice ); |
195 | } | 195 | } |
196 | void KSyncManager::slotSyncMenu( int action ) | 196 | void KSyncManager::slotSyncMenu( int action ) |
197 | { | 197 | { |
198 | qDebug("KSM::syncaction %d ", action); | 198 | qDebug("KSM::syncaction %d ", action); |
199 | mCurrentResourceLocal = ""; | 199 | mCurrentResourceLocal = ""; |
200 | emit multiResourceSyncStart( false ); | 200 | emit multiResourceSyncStart( false ); |
201 | if ( action == 5000 ) | 201 | if ( action == 5000 ) |
202 | return; | 202 | return; |
203 | mSyncWithDesktop = false; | 203 | mSyncWithDesktop = false; |
204 | if ( action == 0 ) { | 204 | if ( action == 0 ) { |
205 | 205 | ||
206 | // seems to be a Qt2 event handling bug | 206 | // seems to be a Qt2 event handling bug |
207 | // syncmenu.clear causes a segfault at first time | 207 | // syncmenu.clear causes a segfault at first time |
208 | // when we call it after the main event loop, it is ok | 208 | // when we call it after the main event loop, it is ok |
209 | // same behaviour when calling OM/Pi via QCOP for the first time | 209 | // same behaviour when calling OM/Pi via QCOP for the first time |
210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
211 | //confSync(); | 211 | //confSync(); |
212 | 212 | ||
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | if ( action == 1 ) { | 215 | if ( action == 1 ) { |
216 | multiSync( true ); | 216 | multiSync( true ); |
217 | return; | 217 | return; |
218 | } | 218 | } |
219 | if ( action == 2 ) { | 219 | if ( action == 2 ) { |
220 | enableQuick(); | 220 | enableQuick(); |
221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | if ( action == 3 ) { | 224 | if ( action == 3 ) { |
225 | delete mServerSocket; | 225 | delete mServerSocket; |
226 | mServerSocket = 0; | 226 | mServerSocket = 0; |
227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (blockSave()) | 231 | if (blockSave()) |
232 | return; | 232 | return; |
233 | 233 | ||
234 | setBlockSave(true); | 234 | setBlockSave(true); |
235 | bool silent = false; | 235 | bool silent = false; |
236 | if ( action == 999 ) { | 236 | if ( action == 999 ) { |
237 | //special mode for silent syncing | 237 | //special mode for silent syncing |
238 | action = 1000; | 238 | action = 1000; |
239 | silent = true; | 239 | silent = true; |
240 | } | 240 | } |
241 | 241 | ||
242 | mCurrentSyncProfile = action - 1000 ; | 242 | mCurrentSyncProfile = action - 1000 ; |
@@ -841,290 +841,357 @@ bool KSyncManager::edit_sync_options() | |||
841 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 841 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
842 | QVBoxLayout lay ( &dia ); | 842 | QVBoxLayout lay ( &dia ); |
843 | lay.setSpacing( 2 ); | 843 | lay.setSpacing( 2 ); |
844 | lay.setMargin( 3 ); | 844 | lay.setMargin( 3 ); |
845 | lay.addWidget(&gr); | 845 | lay.addWidget(&gr); |
846 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 846 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
847 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 847 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
848 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 848 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
849 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 849 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
850 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 850 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
851 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 851 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
852 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 852 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
853 | QPushButton pb ( "OK", &dia); | 853 | QPushButton pb ( "OK", &dia); |
854 | lay.addWidget( &pb ); | 854 | lay.addWidget( &pb ); |
855 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 855 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
856 | switch ( mSyncAlgoPrefs ) { | 856 | switch ( mSyncAlgoPrefs ) { |
857 | case 0: | 857 | case 0: |
858 | loc.setChecked( true); | 858 | loc.setChecked( true); |
859 | break; | 859 | break; |
860 | case 1: | 860 | case 1: |
861 | rem.setChecked( true ); | 861 | rem.setChecked( true ); |
862 | break; | 862 | break; |
863 | case 2: | 863 | case 2: |
864 | newest.setChecked( true); | 864 | newest.setChecked( true); |
865 | break; | 865 | break; |
866 | case 3: | 866 | case 3: |
867 | ask.setChecked( true); | 867 | ask.setChecked( true); |
868 | break; | 868 | break; |
869 | case 4: | 869 | case 4: |
870 | f_loc.setChecked( true); | 870 | f_loc.setChecked( true); |
871 | break; | 871 | break; |
872 | case 5: | 872 | case 5: |
873 | f_rem.setChecked( true); | 873 | f_rem.setChecked( true); |
874 | break; | 874 | break; |
875 | case 6: | 875 | case 6: |
876 | // both.setChecked( true); | 876 | // both.setChecked( true); |
877 | break; | 877 | break; |
878 | default: | 878 | default: |
879 | break; | 879 | break; |
880 | } | 880 | } |
881 | if ( dia.exec() ) { | 881 | if ( dia.exec() ) { |
882 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 882 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
883 | return true; | 883 | return true; |
884 | } | 884 | } |
885 | return false; | 885 | return false; |
886 | } | 886 | } |
887 | 887 | ||
888 | QString KSyncManager::getPassword( ) | 888 | QString KSyncManager::getPassword( ) |
889 | { | 889 | { |
890 | QString retfile = ""; | 890 | QString retfile = ""; |
891 | QDialog dia ( mParent, "input-dialog", true ); | 891 | QDialog dia ( mParent, "input-dialog", true ); |
892 | QLineEdit lab ( &dia ); | 892 | QLineEdit lab ( &dia ); |
893 | lab.setEchoMode( QLineEdit::Password ); | 893 | lab.setEchoMode( QLineEdit::Password ); |
894 | QVBoxLayout lay( &dia ); | 894 | QVBoxLayout lay( &dia ); |
895 | lay.setMargin(7); | 895 | lay.setMargin(7); |
896 | lay.setSpacing(7); | 896 | lay.setSpacing(7); |
897 | lay.addWidget( &lab); | 897 | lay.addWidget( &lab); |
898 | dia.setFixedSize( 230,50 ); | 898 | dia.setFixedSize( 230,50 ); |
899 | dia.setCaption( i18n("Enter password") ); | 899 | dia.setCaption( i18n("Enter password") ); |
900 | QPushButton pb ( "OK", &dia); | 900 | QPushButton pb ( "OK", &dia); |
901 | lay.addWidget( &pb ); | 901 | lay.addWidget( &pb ); |
902 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 902 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
903 | dia.show(); | 903 | dia.show(); |
904 | int res = dia.exec(); | 904 | int res = dia.exec(); |
905 | if ( res ) | 905 | if ( res ) |
906 | retfile = lab.text(); | 906 | retfile = lab.text(); |
907 | dia.hide(); | 907 | dia.hide(); |
908 | qApp->processEvents(); | 908 | qApp->processEvents(); |
909 | return retfile; | 909 | return retfile; |
910 | 910 | ||
911 | } | 911 | } |
912 | 912 | ||
913 | 913 | ||
914 | void KSyncManager::confSync() | 914 | void KSyncManager::confSync() |
915 | { | 915 | { |
916 | static KSyncPrefsDialog* sp = 0; | 916 | static KSyncPrefsDialog* sp = 0; |
917 | if ( ! sp ) { | 917 | if ( ! sp ) { |
918 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 918 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
919 | } | 919 | } |
920 | sp->usrReadConfig(); | 920 | sp->usrReadConfig(); |
921 | #ifndef DESKTOP_VERSION | 921 | #ifndef DESKTOP_VERSION |
922 | sp->showMaximized(); | 922 | sp->showMaximized(); |
923 | #else | 923 | #else |
924 | sp->show(); | 924 | sp->show(); |
925 | #endif | 925 | #endif |
926 | sp->exec(); | 926 | sp->exec(); |
927 | QStringList oldSyncProfileNames = mSyncProfileNames; | 927 | QStringList oldSyncProfileNames = mSyncProfileNames; |
928 | mSyncProfileNames = sp->getSyncProfileNames(); | 928 | mSyncProfileNames = sp->getSyncProfileNames(); |
929 | mLocalMachineName = sp->getLocalMachineName (); | 929 | mLocalMachineName = sp->getLocalMachineName (); |
930 | uint ii; | 930 | uint ii; |
931 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 931 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
932 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 932 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
933 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 933 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
934 | } | 934 | } |
935 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 935 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
936 | } | 936 | } |
937 | void KSyncManager::syncOL() | ||
938 | { | ||
939 | mSyncWithDesktop = true; | ||
940 | emit save(); | ||
941 | switch(mTargetApp) | ||
942 | { | ||
943 | case (KAPI): | ||
944 | { | ||
945 | syncExternalApplication("ol"); | ||
946 | } | ||
947 | break; | ||
948 | case (KOPI): | ||
949 | { | ||
950 | #ifdef DESKTOP_VERSION | ||
951 | QString command = "kdecaldump33"; | ||
952 | QString commandfile = "kdecaldump33"; | ||
953 | QString commandpath = qApp->applicationDirPath () + "/"; | ||
954 | #else | ||
955 | QString command = "kdecaldump33"; | ||
956 | QString commandfile = "kdecaldump33"; | ||
957 | QString commandpath = QDir::homeDirPath ()+"/"; | ||
958 | #endif | ||
959 | if ( ! QFile::exists ( commandpath+commandfile ) ) | ||
960 | command = commandfile; | ||
961 | else | ||
962 | command = commandpath+commandfile; | ||
963 | |||
964 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | ||
965 | int result = system ( command.latin1()); | ||
966 | qDebug("Cal dump 33 command call result result: %d ", result); | ||
967 | if ( result != 0 ) { | ||
968 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | ||
969 | commandfile = "kdecaldump34"; | ||
970 | if ( ! QFile::exists ( commandpath+commandfile ) ) | ||
971 | command = commandfile; | ||
972 | else | ||
973 | command = commandpath+commandfile; | ||
974 | result = system ( command.latin1()); | ||
975 | qDebug("Cal dump 34 command call result result: %d ", result); | ||
976 | if ( result != 0 ) { | ||
977 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | ||
978 | return; | ||
979 | } | ||
980 | } | ||
981 | if ( syncWithFile( fileName,true ) ) { | ||
982 | if ( mWriteBackFile ) { | ||
983 | command += " --read"; | ||
984 | system ( command.latin1()); | ||
985 | } | ||
986 | } | ||
987 | |||
988 | } | ||
989 | break; | ||
990 | case (PWMPI): | ||
991 | |||
992 | break; | ||
993 | default: | ||
994 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | ||
995 | break; | ||
996 | |||
997 | } | ||
998 | } | ||
937 | void KSyncManager::syncKDE() | 999 | void KSyncManager::syncKDE() |
938 | { | 1000 | { |
1001 | #ifdef _WIN32_ | ||
1002 | syncOL(); | ||
1003 | #else | ||
1004 | |||
939 | mSyncWithDesktop = true; | 1005 | mSyncWithDesktop = true; |
940 | emit save(); | 1006 | emit save(); |
941 | switch(mTargetApp) | 1007 | switch(mTargetApp) |
942 | { | 1008 | { |
943 | case (KAPI): | 1009 | case (KAPI): |
944 | { | 1010 | { |
945 | #ifdef DESKTOP_VERSION | 1011 | #ifdef DESKTOP_VERSION |
946 | QString command = "kdeabdump33"; | 1012 | QString command = "kdeabdump33"; |
947 | QString commandfile = "kdeabdump33"; | 1013 | QString commandfile = "kdeabdump33"; |
948 | QString commandpath = qApp->applicationDirPath () + "/"; | 1014 | QString commandpath = qApp->applicationDirPath () + "/"; |
949 | #else | 1015 | #else |
950 | QString command = "kdeabdump33"; | 1016 | QString command = "kdeabdump33"; |
951 | QString commandfile = "kdeabdump33"; | 1017 | QString commandfile = "kdeabdump33"; |
952 | QString commandpath = QDir::homeDirPath ()+"/"; | 1018 | QString commandpath = QDir::homeDirPath ()+"/"; |
953 | #endif | 1019 | #endif |
954 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1020 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
955 | command = commandfile; | 1021 | command = commandfile; |
956 | else | 1022 | else |
957 | command = commandpath+commandfile; | 1023 | command = commandpath+commandfile; |
958 | 1024 | ||
959 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 1025 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
960 | int result = system ( command.latin1()); | 1026 | int result = system ( command.latin1()); |
961 | qDebug("AB dump 33 command call result: %d ", result); | 1027 | qDebug("AB dump 33 command call result: %d ", result); |
962 | if ( result != 0 ) { | 1028 | if ( result != 0 ) { |
963 | qDebug("Calling AB dump version 33 failed. Trying 34... "); | 1029 | qDebug("Calling AB dump version 33 failed. Trying 34... "); |
964 | commandfile = "kdeabdump34"; | 1030 | commandfile = "kdeabdump34"; |
965 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1031 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
966 | command = commandfile; | 1032 | command = commandfile; |
967 | else | 1033 | else |
968 | command = commandpath+commandfile; | 1034 | command = commandpath+commandfile; |
969 | result = system ( command.latin1()); | 1035 | result = system ( command.latin1()); |
970 | qDebug("AB dump 34 command call result: %d ", result); | 1036 | qDebug("AB dump 34 command call result: %d ", result); |
971 | if ( result != 0 ) { | 1037 | if ( result != 0 ) { |
972 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 1038 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
973 | return; | 1039 | return; |
974 | } | 1040 | } |
975 | } | 1041 | } |
976 | if ( syncWithFile( fileName,true ) ) { | 1042 | if ( syncWithFile( fileName,true ) ) { |
977 | if ( mWriteBackFile ) { | 1043 | if ( mWriteBackFile ) { |
978 | command += " --read"; | 1044 | command += " --read"; |
979 | system ( command.latin1()); | 1045 | system ( command.latin1()); |
980 | } | 1046 | } |
981 | } | 1047 | } |
982 | 1048 | ||
983 | } | 1049 | } |
984 | break; | 1050 | break; |
985 | case (KOPI): | 1051 | case (KOPI): |
986 | { | 1052 | { |
987 | #ifdef DESKTOP_VERSION | 1053 | #ifdef DESKTOP_VERSION |
988 | QString command = "kdecaldump33"; | 1054 | QString command = "kdecaldump33"; |
989 | QString commandfile = "kdecaldump33"; | 1055 | QString commandfile = "kdecaldump33"; |
990 | QString commandpath = qApp->applicationDirPath () + "/"; | 1056 | QString commandpath = qApp->applicationDirPath () + "/"; |
991 | #else | 1057 | #else |
992 | QString command = "kdecaldump33"; | 1058 | QString command = "kdecaldump33"; |
993 | QString commandfile = "kdecaldump33"; | 1059 | QString commandfile = "kdecaldump33"; |
994 | QString commandpath = QDir::homeDirPath ()+"/"; | 1060 | QString commandpath = QDir::homeDirPath ()+"/"; |
995 | #endif | 1061 | #endif |
996 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1062 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
997 | command = commandfile; | 1063 | command = commandfile; |
998 | else | 1064 | else |
999 | command = commandpath+commandfile; | 1065 | command = commandpath+commandfile; |
1000 | 1066 | ||
1001 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 1067 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
1002 | int result = system ( command.latin1()); | 1068 | int result = system ( command.latin1()); |
1003 | qDebug("Cal dump 33 command call result result: %d ", result); | 1069 | qDebug("Cal dump 33 command call result result: %d ", result); |
1004 | if ( result != 0 ) { | 1070 | if ( result != 0 ) { |
1005 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | 1071 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); |
1006 | commandfile = "kdecaldump34"; | 1072 | commandfile = "kdecaldump34"; |
1007 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1073 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
1008 | command = commandfile; | 1074 | command = commandfile; |
1009 | else | 1075 | else |
1010 | command = commandpath+commandfile; | 1076 | command = commandpath+commandfile; |
1011 | result = system ( command.latin1()); | 1077 | result = system ( command.latin1()); |
1012 | qDebug("Cal dump 34 command call result result: %d ", result); | 1078 | qDebug("Cal dump 34 command call result result: %d ", result); |
1013 | if ( result != 0 ) { | 1079 | if ( result != 0 ) { |
1014 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 1080 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
1015 | return; | 1081 | return; |
1016 | } | 1082 | } |
1017 | } | 1083 | } |
1018 | if ( syncWithFile( fileName,true ) ) { | 1084 | if ( syncWithFile( fileName,true ) ) { |
1019 | if ( mWriteBackFile ) { | 1085 | if ( mWriteBackFile ) { |
1020 | command += " --read"; | 1086 | command += " --read"; |
1021 | system ( command.latin1()); | 1087 | system ( command.latin1()); |
1022 | } | 1088 | } |
1023 | } | 1089 | } |
1024 | 1090 | ||
1025 | } | 1091 | } |
1026 | break; | 1092 | break; |
1027 | case (PWMPI): | 1093 | case (PWMPI): |
1028 | 1094 | ||
1029 | break; | 1095 | break; |
1030 | default: | 1096 | default: |
1031 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 1097 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
1032 | break; | 1098 | break; |
1033 | 1099 | ||
1034 | } | 1100 | } |
1101 | #endif | ||
1035 | } | 1102 | } |
1036 | 1103 | ||
1037 | void KSyncManager::syncSharp() | 1104 | void KSyncManager::syncSharp() |
1038 | { | 1105 | { |
1039 | 1106 | ||
1040 | if ( ! syncExternalApplication("sharp") ) | 1107 | if ( ! syncExternalApplication("sharp") ) |
1041 | qDebug("KSM::ERROR sync sharp "); | 1108 | qDebug("KSM::ERROR sync sharp "); |
1042 | } | 1109 | } |
1043 | 1110 | ||
1044 | bool KSyncManager::syncExternalApplication(QString resource) | 1111 | bool KSyncManager::syncExternalApplication(QString resource) |
1045 | { | 1112 | { |
1046 | 1113 | ||
1047 | emit save(); | 1114 | emit save(); |
1048 | 1115 | ||
1049 | if ( mAskForPreferences ) | 1116 | if ( mAskForPreferences ) |
1050 | if ( !edit_sync_options()) { | 1117 | if ( !edit_sync_options()) { |
1051 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1118 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1052 | return false; | 1119 | return false; |
1053 | } | 1120 | } |
1054 | 1121 | ||
1055 | qDebug("KSM::Sync extern %s", resource.latin1()); | 1122 | qDebug("KSM::Sync extern %s", resource.latin1()); |
1056 | 1123 | ||
1057 | bool syncOK = mImplementation->syncExternal(this, resource); | 1124 | bool syncOK = mImplementation->syncExternal(this, resource); |
1058 | 1125 | ||
1059 | return syncOK; | 1126 | return syncOK; |
1060 | 1127 | ||
1061 | } | 1128 | } |
1062 | 1129 | ||
1063 | void KSyncManager::syncPhone() | 1130 | void KSyncManager::syncPhone() |
1064 | { | 1131 | { |
1065 | 1132 | ||
1066 | syncExternalApplication("phone"); | 1133 | syncExternalApplication("phone"); |
1067 | 1134 | ||
1068 | } | 1135 | } |
1069 | 1136 | ||
1070 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1137 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1071 | { | 1138 | { |
1072 | if (!bar->isVisible()) | 1139 | if (!bar->isVisible()) |
1073 | { | 1140 | { |
1074 | int w = 300; | 1141 | int w = 300; |
1075 | if ( QApplication::desktop()->width() < 320 ) | 1142 | if ( QApplication::desktop()->width() < 320 ) |
1076 | w = 220; | 1143 | w = 220; |
1077 | int h = bar->sizeHint().height() ; | 1144 | int h = bar->sizeHint().height() ; |
1078 | int dw = QApplication::desktop()->width(); | 1145 | int dw = QApplication::desktop()->width(); |
1079 | int dh = QApplication::desktop()->height(); | 1146 | int dh = QApplication::desktop()->height(); |
1080 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1147 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1081 | bar->setCaption (caption); | 1148 | bar->setCaption (caption); |
1082 | bar->setTotalSteps ( total ) ; | 1149 | bar->setTotalSteps ( total ) ; |
1083 | bar->show(); | 1150 | bar->show(); |
1084 | } | 1151 | } |
1085 | bar->raise(); | 1152 | bar->raise(); |
1086 | bar->setProgress( percentage ); | 1153 | bar->setProgress( percentage ); |
1087 | qApp->processEvents(); | 1154 | qApp->processEvents(); |
1088 | } | 1155 | } |
1089 | 1156 | ||
1090 | void KSyncManager::hideProgressBar() | 1157 | void KSyncManager::hideProgressBar() |
1091 | { | 1158 | { |
1092 | bar->hide(); | 1159 | bar->hide(); |
1093 | qApp->processEvents(); | 1160 | qApp->processEvents(); |
1094 | } | 1161 | } |
1095 | 1162 | ||
1096 | bool KSyncManager::isProgressBarCanceled() | 1163 | bool KSyncManager::isProgressBarCanceled() |
1097 | { | 1164 | { |
1098 | return !bar->isVisible(); | 1165 | return !bar->isVisible(); |
1099 | } | 1166 | } |
1100 | 1167 | ||
1101 | QString KSyncManager::syncFileName() | 1168 | QString KSyncManager::syncFileName() |
1102 | { | 1169 | { |
1103 | 1170 | ||
1104 | QString fn = "tempfile"; | 1171 | QString fn = "tempfile"; |
1105 | switch(mTargetApp) | 1172 | switch(mTargetApp) |
1106 | { | 1173 | { |
1107 | case (KAPI): | 1174 | case (KAPI): |
1108 | fn = "tempsyncab.vcf"; | 1175 | fn = "tempsyncab.vcf"; |
1109 | break; | 1176 | break; |
1110 | case (KOPI): | 1177 | case (KOPI): |
1111 | fn = "tempsynccal.ics"; | 1178 | fn = "tempsynccal.ics"; |
1112 | break; | 1179 | break; |
1113 | case (PWMPI): | 1180 | case (PWMPI): |
1114 | fn = "tempsyncpw.pwm"; | 1181 | fn = "tempsyncpw.pwm"; |
1115 | break; | 1182 | break; |
1116 | default: | 1183 | default: |
1117 | break; | 1184 | break; |
1118 | } | 1185 | } |
1119 | #ifdef DESKTOP_VERSION | 1186 | #ifdef DESKTOP_VERSION |
1120 | return locateLocal( "tmp", fn ); | 1187 | return locateLocal( "tmp", fn ); |
1121 | #else | 1188 | #else |
1122 | return (QString( "/tmp/" )+ fn ); | 1189 | return (QString( "/tmp/" )+ fn ); |
1123 | #endif | 1190 | #endif |
1124 | } | 1191 | } |
1125 | 1192 | ||
1126 | void KSyncManager::syncPi() | 1193 | void KSyncManager::syncPi() |
1127 | { | 1194 | { |
1128 | mIsKapiFile = true; | 1195 | mIsKapiFile = true; |
1129 | mPisyncFinished = false; | 1196 | mPisyncFinished = false; |
1130 | qApp->processEvents(); | 1197 | qApp->processEvents(); |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 04cdade..71d17e9 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -110,140 +110,139 @@ class KCommandSocket : public QObject | |||
110 | QWidget* tlw; | 110 | QWidget* tlw; |
111 | QSocket* mSocket; | 111 | QSocket* mSocket; |
112 | QString mPassWord; | 112 | QString mPassWord; |
113 | Q_UINT16 mPort; | 113 | Q_UINT16 mPort; |
114 | QString mHost; | 114 | QString mHost; |
115 | QString mFileName; | 115 | QString mFileName; |
116 | QTimer* mTimerSocket; | 116 | QTimer* mTimerSocket; |
117 | int mRetVal; | 117 | int mRetVal; |
118 | QTime mTime; | 118 | QTime mTime; |
119 | QString mFileString; | 119 | QString mFileString; |
120 | bool mFirst; | 120 | bool mFirst; |
121 | bool mFirstLine; | 121 | bool mFirstLine; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | 124 | ||
125 | class KSyncManager : public QObject | 125 | class KSyncManager : public QObject |
126 | { | 126 | { |
127 | Q_OBJECT | 127 | Q_OBJECT |
128 | 128 | ||
129 | public: | 129 | public: |
130 | enum TargetApp { | 130 | enum TargetApp { |
131 | KOPI = 0, | 131 | KOPI = 0, |
132 | KAPI = 1, | 132 | KAPI = 1, |
133 | PWMPI = 2 }; | 133 | PWMPI = 2 }; |
134 | 134 | ||
135 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 135 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
136 | ~KSyncManager() ; | 136 | ~KSyncManager() ; |
137 | 137 | ||
138 | void multiSync( bool askforPrefs ); | 138 | void multiSync( bool askforPrefs ); |
139 | bool blockSave() { return mBlockSaveFlag; } | 139 | bool blockSave() { return mBlockSaveFlag; } |
140 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 140 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
141 | void setDefaultFileName( QString s) ; | 141 | void setDefaultFileName( QString s) ; |
142 | QString defaultFileName() { return mDefFileName ;} | 142 | QString defaultFileName() { return mDefFileName ;} |
143 | QString syncFileName(); | 143 | QString syncFileName(); |
144 | void enableQuick( bool ask = true); | 144 | void enableQuick( bool ask = true); |
145 | 145 | ||
146 | bool syncWithDesktop () { return mSyncWithDesktop;} | 146 | bool syncWithDesktop () { return mSyncWithDesktop;} |
147 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 147 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
148 | QString getCurrentSyncName() { return mCurrentSyncName; } | 148 | QString getCurrentSyncName() { return mCurrentSyncName; } |
149 | 149 | ||
150 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 150 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
151 | void hideProgressBar(); | 151 | void hideProgressBar(); |
152 | bool isProgressBarCanceled(); | 152 | bool isProgressBarCanceled(); |
153 | 153 | ||
154 | // sync stuff | 154 | // sync stuff |
155 | QString mLocalMachineName; | 155 | QString mLocalMachineName; |
156 | QStringList mExternSyncProfiles; | 156 | QStringList mExternSyncProfiles; |
157 | QStringList mSyncProfileNames; | 157 | QStringList mSyncProfileNames; |
158 | bool mAskForPreferences; | 158 | bool mAskForPreferences; |
159 | bool mShowSyncSummary; | 159 | bool mShowSyncSummary; |
160 | bool mIsKapiFile; | 160 | bool mIsKapiFile; |
161 | bool mWriteBackExistingOnly; | 161 | bool mWriteBackExistingOnly; |
162 | int mSyncAlgoPrefs; | 162 | int mSyncAlgoPrefs; |
163 | bool mWriteBackFile; | 163 | bool mWriteBackFile; |
164 | int mWriteBackInFuture; | 164 | int mWriteBackInFuture; |
165 | int mWriteBackInPast; | 165 | int mWriteBackInPast; |
166 | QString mPhoneDevice; | 166 | QString mPhoneDevice; |
167 | QString mPhoneConnection; | 167 | QString mPhoneConnection; |
168 | QString mPhoneModel; | 168 | QString mPhoneModel; |
169 | QString mPassWordPiSync; | 169 | QString mPassWordPiSync; |
170 | QString mActiveSyncPort; | 170 | QString mActiveSyncPort; |
171 | QString mActiveSyncIP ; | 171 | QString mActiveSyncIP ; |
172 | QString mFilterInCal; | 172 | QString mFilterInCal; |
173 | QString mFilterOutCal; | 173 | QString mFilterOutCal; |
174 | QString mFilterInAB; | 174 | QString mFilterInAB; |
175 | QString mFilterOutAB; | 175 | QString mFilterOutAB; |
176 | static QDateTime mRequestedSyncEvent; | 176 | static QDateTime mRequestedSyncEvent; |
177 | 177 | ||
178 | signals: | 178 | signals: |
179 | void save(); | 179 | void save(); |
180 | void request_file(); | 180 | void request_file(); |
181 | void getFile( bool ); | 181 | void getFile( bool ); |
182 | void getFile( bool, const QString &); | 182 | void getFile( bool, const QString &); |
183 | void request_file(const QString &); | 183 | void request_file(const QString &); |
184 | void multiResourceSyncStart( bool ); | 184 | void multiResourceSyncStart( bool ); |
185 | 185 | ||
186 | public slots: | 186 | public slots: |
187 | void slotSyncMenu( int ); | 187 | void slotSyncMenu( int ); |
188 | void slotClearMenu( int action ); | 188 | void slotClearMenu( int action ); |
189 | void deleteCommandSocket(KCommandSocket*s, int state); | 189 | void deleteCommandSocket(KCommandSocket*s, int state); |
190 | void readFileFromSocket(); | 190 | void readFileFromSocket(); |
191 | void fillSyncMenu(); | 191 | void fillSyncMenu(); |
192 | 192 | ||
193 | private: | 193 | private: |
194 | void syncPi(); | 194 | void syncPi(); |
195 | KServerSocket * mServerSocket; | 195 | KServerSocket * mServerSocket; |
196 | KPimPrefs* mPrefs; | 196 | KPimPrefs* mPrefs; |
197 | QString mDefFileName; | 197 | QString mDefFileName; |
198 | QString mCurrentSyncDevice; | 198 | QString mCurrentSyncDevice; |
199 | QString mCurrentSyncName; | 199 | QString mCurrentSyncName; |
200 | void quickSyncLocalFile(); | 200 | void quickSyncLocalFile(); |
201 | bool syncWithFile( QString fn , bool quick ); | 201 | bool syncWithFile( QString fn , bool quick ); |
202 | void syncLocalFile(); | 202 | void syncLocalFile(); |
203 | void syncPhone(); | 203 | void syncPhone(); |
204 | void syncSharp(); | 204 | void syncSharp(); |
205 | void syncKDE(); | 205 | void syncKDE(); |
206 | void syncOL(); | ||
206 | bool syncExternalApplication(QString); | 207 | bool syncExternalApplication(QString); |
207 | int mCurrentSyncProfile ; | 208 | int mCurrentSyncProfile ; |
208 | void syncRemote( KSyncProfile* prof, bool ask = true); | 209 | void syncRemote( KSyncProfile* prof, bool ask = true); |
209 | bool edit_sync_options(); | 210 | bool edit_sync_options(); |
210 | bool edit_pisync_options(); | 211 | bool edit_pisync_options(); |
211 | int ringSync(); | 212 | int ringSync(); |
212 | QString getPassword( ); | 213 | QString getPassword( ); |
213 | bool mPisyncFinished; | 214 | bool mPisyncFinished; |
214 | QStringList mSpecificResources; | 215 | QStringList mSpecificResources; |
215 | QString mCurrentResourceLocal; | 216 | QString mCurrentResourceLocal; |
216 | QString mCurrentResourceRemote; | 217 | QString mCurrentResourceRemote; |
217 | bool mBlockSaveFlag; | 218 | bool mBlockSaveFlag; |
218 | QWidget* mParent; | 219 | QWidget* mParent; |
219 | KSyncInterface* mImplementation; | 220 | KSyncInterface* mImplementation; |
220 | TargetApp mTargetApp; | 221 | TargetApp mTargetApp; |
221 | QPopupMenu* mSyncMenu; | 222 | QPopupMenu* mSyncMenu; |
222 | QProgressBar* bar; | 223 | QProgressBar* bar; |
223 | bool mSyncWithDesktop; | 224 | bool mSyncWithDesktop; |
224 | 225 | ||
225 | private slots: | 226 | private slots: |
226 | void displayErrorPort(); | 227 | void displayErrorPort(); |
227 | void confSync(); | 228 | void confSync(); |
228 | 229 | ||
229 | 230 | ||
230 | }; | 231 | }; |
231 | 232 | ||
232 | 233 | ||
233 | class KSyncInterface | 234 | class KSyncInterface |
234 | { | 235 | { |
235 | public : | 236 | public : |
236 | virtual void removeSyncInfo( QString syncProfile) = 0; | 237 | virtual void removeSyncInfo( QString syncProfile) = 0; |
237 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; | 238 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; |
238 | virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) | 239 | virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) |
239 | { | 240 | { |
240 | // empty implementation, because some syncable applications do not | 241 | // empty implementation, because some syncable applications do not |
241 | // have an external(sharpdtm) syncmode, like pwmanager. | 242 | // have an external(sharpdtm) syncmode, like pwmanager. |
242 | return false; | 243 | return false; |
243 | } | 244 | } |
244 | |||
245 | |||
246 | }; | 245 | }; |
247 | 246 | ||
248 | 247 | ||
249 | #endif | 248 | #endif |
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro index 84af7ad..7160d0e 100644 --- a/libkdepim/libkdepim.pro +++ b/libkdepim/libkdepim.pro | |||
@@ -1,61 +1,76 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
3 | DEFINES +=KORG_NOKABC | 3 | DEFINES +=KORG_NOKABC |
4 | TARGET = microkdepim | 4 | TARGET = microkdepim |
5 | INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. | 5 | INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. |
6 | DESTDIR=../bin | 6 | DESTDIR=../bin |
7 | 7 | ||
8 | DEFINES += DESKTOP_VERSION | 8 | DEFINES += DESKTOP_VERSION |
9 | include( ../variables.pri ) | 9 | include( ../variables.pri ) |
10 | unix : { | 10 | unix : { |
11 | OBJECTS_DIR = obj/unix | 11 | OBJECTS_DIR = obj/unix |
12 | MOC_DIR = moc/unix | 12 | MOC_DIR = moc/unix |
13 | } | 13 | } |
14 | win32: { | 14 | win32: { |
15 | DEFINES += _WIN32_ | 15 | DEFINES += _WIN32_ |
16 | OBJECTS_DIR = obj/win | 16 | OBJECTS_DIR = obj/win |
17 | MOC_DIR = moc/win | 17 | MOC_DIR = moc/win |
18 | } | 18 | } |
19 | INTERFACES = \ | 19 | INTERFACES = \ |
20 | 20 | ||
21 | HEADERS = \ | 21 | HEADERS = \ |
22 | categoryeditdialog.h \ | 22 | categoryeditdialog.h \ |
23 | categoryeditdialog_base.h \ | 23 | categoryeditdialog_base.h \ |
24 | categoryselectdialog.h \ | 24 | categoryselectdialog.h \ |
25 | categoryselectdialog_base.h \ | 25 | categoryselectdialog_base.h \ |
26 | externalapphandler.h \ | 26 | externalapphandler.h \ |
27 | kdateedit.h \ | 27 | kdateedit.h \ |
28 | kdatepicker.h \ | 28 | kdatepicker.h \ |
29 | kinputdialog.h \ | 29 | kinputdialog.h \ |
30 | kpimprefs.h \ | 30 | kpimprefs.h \ |
31 | kpimglobalprefs.h \ | 31 | kpimglobalprefs.h \ |
32 | kprefsdialog.h \ | 32 | kprefsdialog.h \ |
33 | kprefswidget.h \ | 33 | kprefswidget.h \ |
34 | ksyncmanager.h \ | 34 | ksyncmanager.h \ |
35 | ksyncprofile.h \ | 35 | ksyncprofile.h \ |
36 | ksyncprefsdialog.h \ | 36 | ksyncprefsdialog.h \ |
37 | kcmconfigs/kcmkdepimconfig.h \ | 37 | kcmconfigs/kcmkdepimconfig.h \ |
38 | kcmconfigs/kdepimconfigwidget.h \ | 38 | kcmconfigs/kdepimconfigwidget.h \ |
39 | phoneaccess.h | 39 | phoneaccess.h |
40 | 40 | ||
41 | SOURCES = \ | 41 | SOURCES = \ |
42 | categoryeditdialog.cpp \ | 42 | categoryeditdialog.cpp \ |
43 | categoryeditdialog_base.cpp \ | 43 | categoryeditdialog_base.cpp \ |
44 | categoryselectdialog.cpp \ | 44 | categoryselectdialog.cpp \ |
45 | categoryselectdialog_base.cpp \ | 45 | categoryselectdialog_base.cpp \ |
46 | externalapphandler.cpp \ | 46 | externalapphandler.cpp \ |
47 | kdateedit.cpp \ | 47 | kdateedit.cpp \ |
48 | kdatepicker.cpp \ | 48 | kdatepicker.cpp \ |
49 | kinputdialog.cpp \ | 49 | kinputdialog.cpp \ |
50 | kpimprefs.cpp \ | 50 | kpimprefs.cpp \ |
51 | kpimglobalprefs.cpp \ | 51 | kpimglobalprefs.cpp \ |
52 | kprefsdialog.cpp \ | 52 | kprefsdialog.cpp \ |
53 | kprefswidget.cpp \ | 53 | kprefswidget.cpp \ |
54 | ksyncmanager.cpp \ | 54 | ksyncmanager.cpp \ |
55 | ksyncprofile.cpp \ | 55 | ksyncprofile.cpp \ |
56 | ksyncprefsdialog.cpp \ | 56 | ksyncprefsdialog.cpp \ |
57 | kcmconfigs/kcmkdepimconfig.cpp \ | 57 | kcmconfigs/kcmkdepimconfig.cpp \ |
58 | kcmconfigs/kdepimconfigwidget.cpp \ | 58 | kcmconfigs/kdepimconfigwidget.cpp \ |
59 | phoneaccess.cpp | 59 | phoneaccess.cpp |
60 | 60 | ||
61 | win32: { | ||
61 | 62 | ||
63 | #olimport section | ||
64 | importol { | ||
65 | debug: { | ||
66 | LIBS += mfc71ud.lib | ||
67 | } | ||
68 | release: { | ||
69 | LIBS += mfc71u.lib | ||
70 | } | ||
71 | DEFINES += _OL_IMPORT_ | ||
72 | HEADERS += ol_access.h | ||
73 | SOURCES += ol_access.cpp | ||
74 | #olimport section end | ||
75 | } | ||
76 | } | ||