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 /kabc | |
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 |
4 files changed, 96 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 70eda1b..9332e21 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -37,16 +37,17 @@ $Id$ | |||
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 |
@@ -507,16 +508,42 @@ Addressee AddressBook::findByUid( const QString &uid ) | |||
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 | { |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e43de31..05225f9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -283,16 +283,21 @@ class AddressBook : public QObject | |||
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. |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 4cdd5e5..fb32f6e 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -27,18 +27,20 @@ $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 | ||
@@ -65,17 +67,17 @@ struct Addressee::AddresseeData : public KShared | |||
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; |
@@ -85,25 +87,28 @@ struct Addressee::AddresseeData : public KShared | |||
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 | ||
@@ -163,16 +168,63 @@ 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 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 27782f9..f098371 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -91,17 +91,26 @@ class Addressee | |||
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 | */ |
@@ -810,16 +819,17 @@ class Addressee | |||
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 | ||