author | zautrix <zautrix> | 2004-09-18 13:13:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-18 13:13:58 (UTC) |
commit | bb16660f29fc709791aa0ee4cb63a40710a994a8 (patch) (unidiff) | |
tree | 5d7387987848039bb3594a624b819d136a38b0cd | |
parent | 4ec7c78ebd2c5a79ff224e9b07d9a3164f7fe602 (diff) | |
download | kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.zip kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.gz kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.bz2 |
more AB syncing
-rw-r--r-- | kabc/addressbook.cpp | 27 | ||||
-rw-r--r-- | kabc/addressbook.h | 5 | ||||
-rw-r--r-- | kabc/addressee.cpp | 54 | ||||
-rw-r--r-- | kabc/addressee.h | 12 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 93 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 |
6 files changed, 156 insertions, 37 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 70eda1b..9332e21 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -29,32 +29,33 @@ $Id$ | |||
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | 41 | ||
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <libkcal/syncdefines.h> | ||
45 | #include "addressbook.h" | 46 | #include "addressbook.h" |
46 | #include "resource.h" | 47 | #include "resource.h" |
47 | 48 | ||
48 | //US #include "addressbook.moc" | 49 | //US #include "addressbook.moc" |
49 | 50 | ||
50 | using namespace KABC; | 51 | using namespace KABC; |
51 | 52 | ||
52 | struct AddressBook::AddressBookData | 53 | struct AddressBook::AddressBookData |
53 | { | 54 | { |
54 | Addressee::List mAddressees; | 55 | Addressee::List mAddressees; |
55 | Addressee::List mRemovedAddressees; | 56 | Addressee::List mRemovedAddressees; |
56 | Field::List mAllFields; | 57 | Field::List mAllFields; |
57 | KConfig *mConfig; | 58 | KConfig *mConfig; |
58 | KRES::Manager<Resource> *mManager; | 59 | KRES::Manager<Resource> *mManager; |
59 | //US ErrorHandler *mErrorHandler; | 60 | //US ErrorHandler *mErrorHandler; |
60 | }; | 61 | }; |
@@ -499,32 +500,58 @@ AddressBook::Iterator AddressBook::find( const Addressee &a ) | |||
499 | return it; | 500 | return it; |
500 | } | 501 | } |
501 | } | 502 | } |
502 | return end(); | 503 | return end(); |
503 | } | 504 | } |
504 | 505 | ||
505 | Addressee AddressBook::findByUid( const QString &uid ) | 506 | Addressee AddressBook::findByUid( const QString &uid ) |
506 | { | 507 | { |
507 | Iterator it; | 508 | Iterator it; |
508 | for ( it = begin(); it != end(); ++it ) { | 509 | for ( it = begin(); it != end(); ++it ) { |
509 | if ( uid == (*it).uid() ) { | 510 | if ( uid == (*it).uid() ) { |
510 | return *it; | 511 | return *it; |
511 | } | 512 | } |
512 | } | 513 | } |
513 | return Addressee(); | 514 | return Addressee(); |
514 | } | 515 | } |
516 | Addressee::List AddressBook::getExternLastSyncAddressees() | ||
517 | { | ||
518 | Addressee::List results; | ||
519 | |||
520 | Iterator it; | ||
521 | for ( it = begin(); it != end(); ++it ) { | ||
522 | if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) { | ||
523 | if ( (*it).familyName().left(3) == "E: " ) | ||
524 | results.append( *it ); | ||
525 | } | ||
526 | } | ||
527 | |||
528 | return results; | ||
529 | } | ||
530 | void AddressBook::resetTempSyncStat() | ||
531 | { | ||
532 | |||
533 | |||
534 | Iterator it; | ||
535 | for ( it = begin(); it != end(); ++it ) { | ||
536 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | ||
537 | } | ||
538 | |||
539 | } | ||
540 | |||
541 | |||
515 | 542 | ||
516 | Addressee::List AddressBook::allAddressees() | 543 | Addressee::List AddressBook::allAddressees() |
517 | { | 544 | { |
518 | return d->mAddressees; | 545 | return d->mAddressees; |
519 | } | 546 | } |
520 | 547 | ||
521 | Addressee::List AddressBook::findByName( const QString &name ) | 548 | Addressee::List AddressBook::findByName( const QString &name ) |
522 | { | 549 | { |
523 | Addressee::List results; | 550 | Addressee::List results; |
524 | 551 | ||
525 | Iterator it; | 552 | Iterator it; |
526 | for ( it = begin(); it != end(); ++it ) { | 553 | for ( it = begin(); it != end(); ++it ) { |
527 | if ( name == (*it).realName() ) { | 554 | if ( name == (*it).realName() ) { |
528 | results.append( *it ); | 555 | results.append( *it ); |
529 | } | 556 | } |
530 | } | 557 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e43de31..05225f9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -275,32 +275,37 @@ class AddressBook : public QObject | |||
275 | /** | 275 | /** |
276 | Set the @p ErrorHandler, that is used by @ref error() to | 276 | Set the @p ErrorHandler, that is used by @ref error() to |
277 | provide gui-independend error messages. | 277 | provide gui-independend error messages. |
278 | */ | 278 | */ |
279 | void setErrorHandler( ErrorHandler * ); | 279 | void setErrorHandler( ErrorHandler * ); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | Shows gui independend error messages. | 282 | Shows gui independend error messages. |
283 | */ | 283 | */ |
284 | void error( const QString& ); | 284 | void error( const QString& ); |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Query all resources to clean up their lock files | 287 | Query all resources to clean up their lock files |
288 | */ | 288 | */ |
289 | void cleanUp(); | 289 | void cleanUp(); |
290 | 290 | ||
291 | // sync stuff | ||
292 | Addressee::List getExternLastSyncAddressees(); | ||
293 | void resetTempSyncStat(); | ||
294 | |||
295 | |||
291 | signals: | 296 | signals: |
292 | /** | 297 | /** |
293 | Emitted, when the address book has changed on disk. | 298 | Emitted, when the address book has changed on disk. |
294 | */ | 299 | */ |
295 | void addressBookChanged( AddressBook * ); | 300 | void addressBookChanged( AddressBook * ); |
296 | 301 | ||
297 | /** | 302 | /** |
298 | Emitted, when the address book has been locked for writing. | 303 | Emitted, when the address book has been locked for writing. |
299 | */ | 304 | */ |
300 | void addressBookLocked( AddressBook * ); | 305 | void addressBookLocked( AddressBook * ); |
301 | 306 | ||
302 | /** | 307 | /** |
303 | Emitted, when the address book has been unlocked. | 308 | Emitted, when the address book has been unlocked. |
304 | */ | 309 | */ |
305 | void addressBookUnlocked( AddressBook * ); | 310 | void addressBookUnlocked( AddressBook * ); |
306 | 311 | ||
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 4cdd5e5..fb32f6e 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -19,34 +19,36 @@ | |||
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 <kidmanager.h> | ||
35 | //US | 36 | //US |
36 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | ||
37 | 39 | ||
38 | //US #include "resource.h" | 40 | //US #include "resource.h" |
39 | #include "addressee.h" | 41 | #include "addressee.h" |
40 | 42 | ||
41 | using namespace KABC; | 43 | using namespace KABC; |
42 | 44 | ||
43 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
44 | 46 | ||
45 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
46 | { | 48 | { |
47 | QString uid; | 49 | QString uid; |
48 | QString name; | 50 | QString name; |
49 | QString formattedName; | 51 | QString formattedName; |
50 | QString familyName; | 52 | QString familyName; |
51 | QString givenName; | 53 | QString givenName; |
52 | QString additionalName; | 54 | QString additionalName; |
@@ -57,61 +59,64 @@ struct Addressee::AddresseeData : public KShared | |||
57 | QString mailer; | 59 | QString mailer; |
58 | TimeZone timeZone; | 60 | TimeZone timeZone; |
59 | Geo geo; | 61 | Geo geo; |
60 | QString title; | 62 | QString title; |
61 | QString role; | 63 | QString role; |
62 | QString organization; | 64 | QString organization; |
63 | QString note; | 65 | QString note; |
64 | QString productId; | 66 | QString productId; |
65 | QDateTime revision; | 67 | QDateTime revision; |
66 | QString sortString; | 68 | QString sortString; |
67 | KURL url; | 69 | KURL url; |
68 | Secrecy secrecy; | 70 | Secrecy secrecy; |
69 | Picture logo; | 71 | Picture logo; |
70 | Picture photo; | 72 | Picture photo; |
71 | Sound sound; | 73 | Sound sound; |
72 | Agent agent; | 74 | Agent agent; |
73 | 75 | QString mExternalId; | |
74 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
75 | Address::List addresses; | 77 | Address::List addresses; |
76 | Key::List keys; | 78 | Key::List keys; |
77 | QStringList emails; | 79 | QStringList emails; |
78 | QStringList categories; | 80 | QStringList categories; |
79 | QStringList custom; | 81 | QStringList custom; |
80 | 82 | ||
81 | Resource *resource; | 83 | Resource *resource; |
82 | 84 | ||
83 | bool empty :1; | 85 | bool empty :1; |
84 | bool changed :1; | 86 | bool changed :1; |
85 | }; | 87 | }; |
86 | 88 | ||
87 | Addressee::Addressee() | 89 | Addressee::Addressee() |
88 | { | 90 | { |
89 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
90 | mData->empty = true; | 92 | mData->empty = true; |
91 | mData->changed = false; | 93 | mData->changed = false; |
92 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | ||
96 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
93 | } | 97 | } |
94 | 98 | ||
95 | Addressee::~Addressee() | 99 | Addressee::~Addressee() |
96 | { | 100 | { |
97 | } | 101 | } |
98 | 102 | ||
99 | Addressee::Addressee( const Addressee &a ) | 103 | Addressee::Addressee( const Addressee &a ) |
100 | { | 104 | { |
101 | mData = a.mData; | 105 | mData = a.mData; |
106 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
102 | } | 107 | } |
103 | 108 | ||
104 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
105 | { | 110 | { |
106 | mData = a.mData; | 111 | mData = a.mData; |
107 | return (*this); | 112 | return (*this); |
108 | } | 113 | } |
109 | 114 | ||
110 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
111 | { | 116 | { |
112 | Addressee a; | 117 | Addressee a; |
113 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
114 | return a; | 119 | return a; |
115 | } | 120 | } |
116 | 121 | ||
117 | void Addressee::detach() | 122 | void Addressee::detach() |
@@ -155,32 +160,79 @@ bool Addressee::operator==( const Addressee &a ) const | |||
155 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
156 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
157 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
158 | 163 | ||
159 | return true; | 164 | return true; |
160 | } | 165 | } |
161 | 166 | ||
162 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
163 | { | 168 | { |
164 | return !( a == *this ); | 169 | return !( a == *this ); |
165 | } | 170 | } |
166 | 171 | ||
167 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
168 | { | 173 | { |
169 | return mData->empty; | 174 | return mData->empty; |
170 | } | 175 | } |
176 | void Addressee::removeID(const QString &prof) | ||
177 | { | ||
178 | detach(); | ||
179 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | ||
180 | |||
181 | } | ||
182 | void Addressee::setID( const QString & prof , const QString & id ) | ||
183 | { | ||
184 | detach(); | ||
185 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | ||
186 | } | ||
187 | void Addressee::setTempSyncStat( int id ) | ||
188 | { | ||
189 | mTempSyncStat = id; | ||
190 | } | ||
191 | int Addressee::tempSyncStat() const | ||
192 | { | ||
193 | return mTempSyncStat; | ||
194 | } | ||
195 | |||
196 | QString Addressee::getID( const QString & prof) | ||
197 | { | ||
198 | return KIdManager::getId ( mData->mExternalId, prof ); | ||
199 | } | ||
200 | |||
201 | void Addressee::setCsum( const QString & prof , const QString & id ) | ||
202 | { | ||
203 | detach(); | ||
204 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | ||
205 | } | ||
206 | |||
207 | QString Addressee::getCsum( const QString & prof) | ||
208 | { | ||
209 | return KIdManager::getCsum ( mData->mExternalId, prof ); | ||
210 | } | ||
211 | |||
212 | void Addressee::setIDStr( const QString & s ) | ||
213 | { | ||
214 | detach(); | ||
215 | mData->mExternalId = s; | ||
216 | } | ||
217 | |||
218 | QString Addressee::IDStr() const | ||
219 | { | ||
220 | return mData->mExternalId; | ||
221 | } | ||
222 | |||
171 | 223 | ||
172 | void Addressee::setUid( const QString &id ) | 224 | void Addressee::setUid( const QString &id ) |
173 | { | 225 | { |
174 | if ( id == mData->uid ) return; | 226 | if ( id == mData->uid ) return; |
175 | detach(); | 227 | detach(); |
176 | mData->empty = false; | 228 | mData->empty = false; |
177 | mData->uid = id; | 229 | mData->uid = id; |
178 | } | 230 | } |
179 | 231 | ||
180 | QString Addressee::uid() const | 232 | QString Addressee::uid() const |
181 | { | 233 | { |
182 | if ( mData->uid.isEmpty() ) | 234 | if ( mData->uid.isEmpty() ) |
183 | mData->uid = KApplication::randomString( 10 ); | 235 | mData->uid = KApplication::randomString( 10 ); |
184 | 236 | ||
185 | return mData->uid; | 237 | return mData->uid; |
186 | } | 238 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 27782f9..f098371 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -83,33 +83,42 @@ class Addressee | |||
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | 99 | // sync stuff | |
100 | void setTempSyncStat(int id); | ||
101 | int tempSyncStat() const; | ||
102 | void setIDStr( const QString & ); | ||
103 | QString IDStr() const; | ||
104 | void setID( const QString &, const QString & ); | ||
105 | QString getID( const QString & ); | ||
106 | void setCsum( const QString &, const QString & ); | ||
107 | QString getCsum( const QString & ); | ||
108 | void removeID(const QString &); | ||
100 | /** | 109 | /** |
101 | Return, if the address book entry is empty. | 110 | Return, if the address book entry is empty. |
102 | */ | 111 | */ |
103 | bool isEmpty() const; | 112 | bool isEmpty() const; |
104 | 113 | ||
105 | /** | 114 | /** |
106 | Set unique identifier. | 115 | Set unique identifier. |
107 | */ | 116 | */ |
108 | void setUid( const QString &uid ); | 117 | void setUid( const QString &uid ); |
109 | /** | 118 | /** |
110 | Return unique identifier. | 119 | Return unique identifier. |
111 | */ | 120 | */ |
112 | QString uid() const; | 121 | QString uid() const; |
113 | /** | 122 | /** |
114 | Return translated label for uid field. | 123 | Return translated label for uid field. |
115 | */ | 124 | */ |
@@ -802,27 +811,28 @@ class Addressee | |||
802 | //US | 811 | //US |
803 | static QString resourceLabel(); | 812 | static QString resourceLabel(); |
804 | 813 | ||
805 | /** | 814 | /** |
806 | Mark addressee as changed. | 815 | Mark addressee as changed. |
807 | */ | 816 | */ |
808 | void setChanged( bool value ); | 817 | void setChanged( bool value ); |
809 | 818 | ||
810 | /** | 819 | /** |
811 | Return whether the addressee is changed. | 820 | Return whether the addressee is changed. |
812 | */ | 821 | */ |
813 | bool changed() const; | 822 | bool changed() const; |
814 | 823 | ||
815 | private: | 824 | private: |
816 | Addressee copy(); | 825 | Addressee copy(); |
817 | void detach(); | 826 | void detach(); |
827 | int mTempSyncStat; | ||
818 | 828 | ||
819 | struct AddresseeData; | 829 | struct AddresseeData; |
820 | mutable KSharedPtr<AddresseeData> mData; | 830 | mutable KSharedPtr<AddresseeData> mData; |
821 | }; | 831 | }; |
822 | 832 | ||
823 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 833 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
824 | QDataStream &operator>>( QDataStream &, Addressee & ); | 834 | QDataStream &operator>>( QDataStream &, Addressee & ); |
825 | 835 | ||
826 | } | 836 | } |
827 | 837 | ||
828 | #endif | 838 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 1196360..53c63ff 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2500,96 +2500,119 @@ QString KABCore::getPassword( ) | |||
2500 | lay.setSpacing(7); | 2500 | lay.setSpacing(7); |
2501 | lay.addWidget( &lab); | 2501 | lay.addWidget( &lab); |
2502 | dia.setFixedSize( 230,50 ); | 2502 | dia.setFixedSize( 230,50 ); |
2503 | dia.setCaption( i18n("Enter password") ); | 2503 | dia.setCaption( i18n("Enter password") ); |
2504 | QPushButton pb ( "OK", &dia); | 2504 | QPushButton pb ( "OK", &dia); |
2505 | lay.addWidget( &pb ); | 2505 | lay.addWidget( &pb ); |
2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2507 | dia.show(); | 2507 | dia.show(); |
2508 | int res = dia.exec(); | 2508 | int res = dia.exec(); |
2509 | if ( res ) | 2509 | if ( res ) |
2510 | retfile = lab.text(); | 2510 | retfile = lab.text(); |
2511 | dia.hide(); | 2511 | dia.hide(); |
2512 | qApp->processEvents(); | 2512 | qApp->processEvents(); |
2513 | return retfile; | 2513 | return retfile; |
2514 | 2514 | ||
2515 | } | 2515 | } |
2516 | #include <libkcal/syncdefines.h> | ||
2517 | |||
2518 | KABC::Addressee KABCore::getLastSyncAddressee() | ||
2519 | { | ||
2520 | Addressee lse; | ||
2521 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | ||
2522 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | ||
2523 | if (lse.isEmpty()) { | ||
2524 | lse.setUid( "last-syncEvent-"+mCurrentSyncDevice ); | ||
2525 | QString sum = ""; | ||
2526 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | ||
2527 | sum = "E: "; | ||
2528 | lse.setFamilyName(sum+mCurrentSyncDevice + i18n(" - sync event")); | ||
2529 | lse.setRevision( mLastAddressbookSync ); | ||
2530 | lse.setCategories( i18n("SyncEvent") ); | ||
2531 | mAddressBook->insertAddressee( lse ); | ||
2532 | } | ||
2533 | return lse; | ||
2534 | } | ||
2535 | |||
2516 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2536 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2517 | { | 2537 | { |
2518 | #if 0 | ||
2519 | bool syncOK = true; | 2538 | bool syncOK = true; |
2520 | int addedAddressee = 0; | 2539 | int addedAddressee = 0; |
2521 | int addedAddresseeR = 0; | 2540 | int addedAddresseeR = 0; |
2522 | int deletedAddresseeR = 0; | 2541 | int deletedAddresseeR = 0; |
2523 | int deletedAddresseeL = 0; | 2542 | int deletedAddresseeL = 0; |
2524 | int changedLocal = 0; | 2543 | int changedLocal = 0; |
2525 | int changedRemote = 0; | 2544 | int changedRemote = 0; |
2526 | //QPtrList<Addressee> el = local->rawAddressees(); | 2545 | //QPtrList<Addressee> el = local->rawAddressees(); |
2527 | Addressee* addresseeR; | 2546 | Addressee addresseeR; |
2528 | QString uid; | 2547 | QString uid; |
2529 | int take; | 2548 | int take; |
2530 | Addressee* addresseeL; | 2549 | Addressee addresseeL; |
2531 | Addressee* addresseeRSync; | 2550 | Addressee addresseeRSync; |
2532 | Addressee* addresseeLSync; | 2551 | Addressee addresseeLSync; |
2533 | QPtrList<Addressee> addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2552 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2534 | QPtrList<Addressee> addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2553 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2535 | bool fullDateRange = false; | 2554 | bool fullDateRange = false; |
2536 | local->resetTempSyncStat(); | 2555 | local->resetTempSyncStat(); |
2537 | mLastCalendarSync = QDateTime::currentDateTime(); | 2556 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2538 | QDateTime modifiedCalendar = mLastCalendarSync;; | 2557 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2539 | addresseeLSync = getLastSyncAddressee(); | 2558 | addresseeLSync = getLastSyncAddressee(); |
2540 | addresseeR = remote->addressee("last-syncAddressee-"+mCurrentSyncName ); | 2559 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2541 | if ( addresseeR ) { | 2560 | if ( !addresseeR.isEmpty() ) { |
2542 | addresseeRSync = (Addressee*) addresseeR->clone(); | 2561 | addresseeRSync = addresseeR; |
2543 | remote->deleteAddressee(addresseeR ); | 2562 | remote->removeAddressee(addresseeR ); |
2544 | 2563 | ||
2545 | } else { | 2564 | } else { |
2546 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2565 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2547 | addresseeRSync = (Addressee*)addresseeLSync->clone(); | 2566 | addresseeRSync = addresseeLSync ; |
2548 | } else { | 2567 | } else { |
2549 | fullDateRange = true; | 2568 | fullDateRange = true; |
2550 | addresseeRSync = new Addressee(); | 2569 | Addressee newAdd; |
2551 | addresseeRSync->setSummary(mCurrentSyncName + i18n(" - sync addressee")); | 2570 | addresseeRSync = newAdd; |
2552 | addresseeRSync->setUid("last-syncAddressee-"+mCurrentSyncName ); | 2571 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2553 | addresseeRSync->setDtStart( mLastCalendarSync ); | 2572 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2554 | addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 2573 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2555 | addresseeRSync->setCategories( i18n("SyncAddressee") ); | 2574 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2556 | } | 2575 | } |
2557 | } | 2576 | } |
2558 | if ( addresseeLSync->dtStart() == mLastCalendarSync ) | 2577 | if ( addresseeLSync.revision() == mLastAddressbookSync ) |
2559 | fullDateRange = true; | 2578 | fullDateRange = true; |
2560 | |||
2561 | if ( ! fullDateRange ) { | 2579 | if ( ! fullDateRange ) { |
2562 | if ( addresseeLSync->dtStart() != addresseeRSync->dtStart() ) { | 2580 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2563 | 2581 | ||
2564 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2582 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2565 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2583 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2566 | fullDateRange = true; | 2584 | fullDateRange = true; |
2567 | } | 2585 | } |
2568 | } | 2586 | } |
2569 | if ( fullDateRange ) | 2587 | if ( fullDateRange ) |
2570 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 2588 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2571 | else | 2589 | else |
2572 | mLastCalendarSync = addresseeLSync->dtStart(); | 2590 | mLastAddressbookSync = addresseeLSync.revision(); |
2573 | // for resyncing if own file has changed | 2591 | // for resyncing if own file has changed |
2592 | // PENDING fixme later when implemented | ||
2593 | #if 0 | ||
2574 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2594 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2575 | mLastCalendarSync = loadedFileVersion; | 2595 | mLastAddressbookSync = loadedFileVersion; |
2576 | qDebug("setting mLastCalendarSync "); | 2596 | qDebug("setting mLastAddressbookSync "); |
2577 | } | 2597 | } |
2598 | #endif | ||
2599 | |||
2600 | #if 0 | ||
2578 | //qDebug("*************************** "); | 2601 | //qDebug("*************************** "); |
2579 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 2602 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2580 | QPtrList<Incidence> er = remote->rawIncidences(); | 2603 | QPtrList<Incidence> er = remote->rawIncidences(); |
2581 | Incidence* inR = er.first(); | 2604 | Incidence* inR = er.first(); |
2582 | Incidence* inL; | 2605 | Incidence* inL; |
2583 | QProgressBar bar( er.count(),0 ); | 2606 | QProgressBar bar( er.count(),0 ); |
2584 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2607 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2585 | 2608 | ||
2586 | int w = 300; | 2609 | int w = 300; |
2587 | if ( QApplication::desktop()->width() < 320 ) | 2610 | if ( QApplication::desktop()->width() < 320 ) |
2588 | w = 220; | 2611 | w = 220; |
2589 | int h = bar.sizeHint().height() ; | 2612 | int h = bar.sizeHint().height() ; |
2590 | int dw = QApplication::desktop()->width(); | 2613 | int dw = QApplication::desktop()->width(); |
2591 | int dh = QApplication::desktop()->height(); | 2614 | int dh = QApplication::desktop()->height(); |
2592 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2615 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2593 | bar.show(); | 2616 | bar.show(); |
2594 | int modulo = (er.count()/10)+1; | 2617 | int modulo = (er.count()/10)+1; |
2595 | int incCounter = 0; | 2618 | int incCounter = 0; |
@@ -2644,33 +2667,33 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2644 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2667 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2645 | QString des = addresseeLSync->description(); | 2668 | QString des = addresseeLSync->description(); |
2646 | QString pref = "e"; | 2669 | QString pref = "e"; |
2647 | if ( inR->type() == "Todo" ) | 2670 | if ( inR->type() == "Todo" ) |
2648 | pref = "t"; | 2671 | pref = "t"; |
2649 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2672 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2650 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2673 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2651 | //remote->deleteIncidence( inR ); | 2674 | //remote->deleteIncidence( inR ); |
2652 | ++deletedAddresseeR; | 2675 | ++deletedAddresseeR; |
2653 | } else { | 2676 | } else { |
2654 | inR->setLastModified( modifiedCalendar ); | 2677 | inR->setLastModified( modifiedCalendar ); |
2655 | inL = inR->clone(); | 2678 | inL = inR->clone(); |
2656 | local->addIncidence( inL ); | 2679 | local->addIncidence( inL ); |
2657 | ++addedAddressee; | 2680 | ++addedAddressee; |
2658 | } | 2681 | } |
2659 | } else { | 2682 | } else { |
2660 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 2683 | if ( inR->lastModified() > mLastAddressbookSync || mode == 5 ) { |
2661 | inR->setLastModified( modifiedCalendar ); | 2684 | inR->setLastModified( modifiedCalendar ); |
2662 | local->addIncidence( inR->clone() ); | 2685 | local->addIncidence( inR->clone() ); |
2663 | ++addedAddressee; | 2686 | ++addedAddressee; |
2664 | } else { | 2687 | } else { |
2665 | checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2688 | checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2666 | remote->deleteIncidence( inR ); | 2689 | remote->deleteIncidence( inR ); |
2667 | ++deletedAddresseeR; | 2690 | ++deletedAddresseeR; |
2668 | } | 2691 | } |
2669 | } | 2692 | } |
2670 | } | 2693 | } |
2671 | } | 2694 | } |
2672 | inR = er.next(); | 2695 | inR = er.next(); |
2673 | } | 2696 | } |
2674 | QPtrList<Incidence> el = local->rawIncidences(); | 2697 | QPtrList<Incidence> el = local->rawIncidences(); |
2675 | inL = el.first(); | 2698 | inL = el.first(); |
2676 | modulo = (el.count()/10)+1; | 2699 | modulo = (el.count()/10)+1; |
@@ -2700,33 +2723,33 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2700 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2723 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2701 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2724 | checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2702 | local->deleteIncidence( inL ); | 2725 | local->deleteIncidence( inL ); |
2703 | ++deletedAddresseeL; | 2726 | ++deletedAddresseeL; |
2704 | } else { | 2727 | } else { |
2705 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2728 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
2706 | inL->removeID(mCurrentSyncDevice ); | 2729 | inL->removeID(mCurrentSyncDevice ); |
2707 | ++addedAddresseeR; | 2730 | ++addedAddresseeR; |
2708 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 2731 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
2709 | inL->setLastModified( modifiedCalendar ); | 2732 | inL->setLastModified( modifiedCalendar ); |
2710 | inR = inL->clone(); | 2733 | inR = inL->clone(); |
2711 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2734 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2712 | remote->addIncidence( inR ); | 2735 | remote->addIncidence( inR ); |
2713 | } | 2736 | } |
2714 | } | 2737 | } |
2715 | } else { | 2738 | } else { |
2716 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 2739 | if ( inL->lastModified() < mLastAddressbookSync && mode != 4 ) { |
2717 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2740 | checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2718 | local->deleteIncidence( inL ); | 2741 | local->deleteIncidence( inL ); |
2719 | ++deletedAddresseeL; | 2742 | ++deletedAddresseeL; |
2720 | } else { | 2743 | } else { |
2721 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2744 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
2722 | ++addedAddresseeR; | 2745 | ++addedAddresseeR; |
2723 | inL->setLastModified( modifiedCalendar ); | 2746 | inL->setLastModified( modifiedCalendar ); |
2724 | remote->addIncidence( inL->clone() ); | 2747 | remote->addIncidence( inL->clone() ); |
2725 | } | 2748 | } |
2726 | } | 2749 | } |
2727 | } | 2750 | } |
2728 | } | 2751 | } |
2729 | } | 2752 | } |
2730 | inL = el.next(); | 2753 | inL = el.next(); |
2731 | } | 2754 | } |
2732 | int delFut = 0; | 2755 | int delFut = 0; |
@@ -2747,38 +2770,38 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2747 | else if (inR->type() == "Addressee" ) { | 2770 | else if (inR->type() == "Addressee" ) { |
2748 | bool ok; | 2771 | bool ok; |
2749 | dt = inR->getNextOccurence( cur, &ok ); | 2772 | dt = inR->getNextOccurence( cur, &ok ); |
2750 | if ( !ok ) | 2773 | if ( !ok ) |
2751 | dt = cur.addSecs( -62 ); | 2774 | dt = cur.addSecs( -62 ); |
2752 | } | 2775 | } |
2753 | else | 2776 | else |
2754 | dt = inR->dtStart(); | 2777 | dt = inR->dtStart(); |
2755 | if ( dt < cur || dt > end ) { | 2778 | if ( dt < cur || dt > end ) { |
2756 | remote->deleteIncidence( inR ); | 2779 | remote->deleteIncidence( inR ); |
2757 | ++delFut; | 2780 | ++delFut; |
2758 | } | 2781 | } |
2759 | inR = er.next(); | 2782 | inR = er.next(); |
2760 | } | 2783 | } |
2761 | } | 2784 | } |
2762 | bar.hide(); | 2785 | bar.hide(); |
2763 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 2786 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2764 | addresseeLSync->setReadOnly( false ); | 2787 | addresseeLSync->setReadOnly( false ); |
2765 | addresseeLSync->setDtStart( mLastCalendarSync ); | 2788 | addresseeLSync->setDtStart( mLastAddressbookSync ); |
2766 | addresseeRSync->setDtStart( mLastCalendarSync ); | 2789 | addresseeRSync->setDtStart( mLastAddressbookSync ); |
2767 | addresseeLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 2790 | addresseeLSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); |
2768 | addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 2791 | addresseeRSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); |
2769 | addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 2792 | addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
2770 | addresseeLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 2793 | addresseeLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
2771 | addresseeLSync->setReadOnly( true ); | 2794 | addresseeLSync->setReadOnly( true ); |
2772 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2795 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2773 | remote->addAddressee( addresseeRSync ); | 2796 | remote->addAddressee( addresseeRSync ); |
2774 | QString mes; | 2797 | QString mes; |
2775 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2798 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2776 | QString delmess; | 2799 | QString delmess; |
2777 | if ( delFut ) { | 2800 | if ( delFut ) { |
2778 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 2801 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
2779 | mes += delmess; | 2802 | mes += delmess; |
2780 | } | 2803 | } |
2781 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 2804 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
2782 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 2805 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
2783 | } | 2806 | } |
2784 | qDebug( mes ); | 2807 | qDebug( mes ); |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 4487a8a..c67cee6 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -459,23 +459,25 @@ class KABCore : public QWidget | |||
459 | QString mCurrentSyncDevice; | 459 | QString mCurrentSyncDevice; |
460 | QString mCurrentSyncName; | 460 | QString mCurrentSyncName; |
461 | void quickSyncLocalFile(); | 461 | void quickSyncLocalFile(); |
462 | bool syncWithFile( QString fn , bool quick ); | 462 | bool syncWithFile( QString fn , bool quick ); |
463 | void KABCore::syncLocalFile(); | 463 | void KABCore::syncLocalFile(); |
464 | void KABCore::syncPhone(); | 464 | void KABCore::syncPhone(); |
465 | void KABCore::syncSharp(); | 465 | void KABCore::syncSharp(); |
466 | void multiSync( bool askforPrefs ); | 466 | void multiSync( bool askforPrefs ); |
467 | int mCurrentSyncProfile ; | 467 | int mCurrentSyncProfile ; |
468 | void syncRemote( KSyncProfile* prof, bool ask = true); | 468 | void syncRemote( KSyncProfile* prof, bool ask = true); |
469 | void edit_sync_options(); | 469 | void edit_sync_options(); |
470 | bool syncAB(QString filename, int mode); | 470 | bool syncAB(QString filename, int mode); |
471 | int ringSync(); | 471 | int ringSync(); |
472 | QString getPassword( ); | 472 | QString getPassword( ); |
473 | int mGlobalSyncMode; | 473 | int mGlobalSyncMode; |
474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
475 | KABC::Addressee getLastSyncAddressee(); | ||
476 | QDateTime mLastAddressbookSync; | ||
475 | public slots: | 477 | public slots: |
476 | void confSync(); | 478 | void confSync(); |
477 | // ********************* | 479 | // ********************* |
478 | 480 | ||
479 | }; | 481 | }; |
480 | 482 | ||
481 | #endif | 483 | #endif |