-rw-r--r-- | kabc/addressbook.cpp | 8 | ||||
-rw-r--r-- | kabc/addressbook.h | 1 | ||||
-rw-r--r-- | kabc/addressee.cpp | 5 |
3 files changed, 13 insertions, 1 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 3641c0c..2785131 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -44,1024 +44,1032 @@ $Id$ | |||
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | 50 | #include <libkdepim/phoneaccess.h> |
51 | #include "addressbook.h" | 51 | #include "addressbook.h" |
52 | #include "resource.h" | 52 | #include "resource.h" |
53 | #include "vcardconverter.h" | 53 | #include "vcardconverter.h" |
54 | #include "vcardparser/vcardtool.h" | 54 | #include "vcardparser/vcardtool.h" |
55 | 55 | ||
56 | //US #include "addressbook.moc" | 56 | //US #include "addressbook.moc" |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | 59 | ||
60 | struct AddressBook::AddressBookData | 60 | struct AddressBook::AddressBookData |
61 | { | 61 | { |
62 | Addressee::List mAddressees; | 62 | Addressee::List mAddressees; |
63 | Addressee::List mRemovedAddressees; | 63 | Addressee::List mRemovedAddressees; |
64 | Field::List mAllFields; | 64 | Field::List mAllFields; |
65 | KConfig *mConfig; | 65 | KConfig *mConfig; |
66 | KRES::Manager<Resource> *mManager; | 66 | KRES::Manager<Resource> *mManager; |
67 | //US ErrorHandler *mErrorHandler; | 67 | //US ErrorHandler *mErrorHandler; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct AddressBook::Iterator::IteratorData | 70 | struct AddressBook::Iterator::IteratorData |
71 | { | 71 | { |
72 | Addressee::List::Iterator mIt; | 72 | Addressee::List::Iterator mIt; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | struct AddressBook::ConstIterator::ConstIteratorData | 75 | struct AddressBook::ConstIterator::ConstIteratorData |
76 | { | 76 | { |
77 | Addressee::List::ConstIterator mIt; | 77 | Addressee::List::ConstIterator mIt; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | AddressBook::Iterator::Iterator() | 80 | AddressBook::Iterator::Iterator() |
81 | { | 81 | { |
82 | d = new IteratorData; | 82 | d = new IteratorData; |
83 | } | 83 | } |
84 | 84 | ||
85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
86 | { | 86 | { |
87 | d = new IteratorData; | 87 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 88 | d->mIt = i.d->mIt; |
89 | } | 89 | } |
90 | 90 | ||
91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
92 | { | 92 | { |
93 | if( this == &i ) return *this; // guard against self assignment | 93 | if( this == &i ) return *this; // guard against self assignment |
94 | delete d; // delete the old data the Iterator was completely constructed before | 94 | delete d; // delete the old data the Iterator was completely constructed before |
95 | d = new IteratorData; | 95 | d = new IteratorData; |
96 | d->mIt = i.d->mIt; | 96 | d->mIt = i.d->mIt; |
97 | return *this; | 97 | return *this; |
98 | } | 98 | } |
99 | 99 | ||
100 | AddressBook::Iterator::~Iterator() | 100 | AddressBook::Iterator::~Iterator() |
101 | { | 101 | { |
102 | delete d; | 102 | delete d; |
103 | } | 103 | } |
104 | 104 | ||
105 | const Addressee &AddressBook::Iterator::operator*() const | 105 | const Addressee &AddressBook::Iterator::operator*() const |
106 | { | 106 | { |
107 | return *(d->mIt); | 107 | return *(d->mIt); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee &AddressBook::Iterator::operator*() | 110 | Addressee &AddressBook::Iterator::operator*() |
111 | { | 111 | { |
112 | return *(d->mIt); | 112 | return *(d->mIt); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee *AddressBook::Iterator::operator->() | 115 | Addressee *AddressBook::Iterator::operator->() |
116 | { | 116 | { |
117 | return &(*(d->mIt)); | 117 | return &(*(d->mIt)); |
118 | } | 118 | } |
119 | 119 | ||
120 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 120 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
121 | { | 121 | { |
122 | (d->mIt)++; | 122 | (d->mIt)++; |
123 | return *this; | 123 | return *this; |
124 | } | 124 | } |
125 | 125 | ||
126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
127 | { | 127 | { |
128 | (d->mIt)++; | 128 | (d->mIt)++; |
129 | return *this; | 129 | return *this; |
130 | } | 130 | } |
131 | 131 | ||
132 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 132 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
133 | { | 133 | { |
134 | (d->mIt)--; | 134 | (d->mIt)--; |
135 | return *this; | 135 | return *this; |
136 | } | 136 | } |
137 | 137 | ||
138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
139 | { | 139 | { |
140 | (d->mIt)--; | 140 | (d->mIt)--; |
141 | return *this; | 141 | return *this; |
142 | } | 142 | } |
143 | 143 | ||
144 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 144 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
145 | { | 145 | { |
146 | return ( d->mIt == it.d->mIt ); | 146 | return ( d->mIt == it.d->mIt ); |
147 | } | 147 | } |
148 | 148 | ||
149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
150 | { | 150 | { |
151 | return ( d->mIt != it.d->mIt ); | 151 | return ( d->mIt != it.d->mIt ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | AddressBook::ConstIterator::ConstIterator() | 155 | AddressBook::ConstIterator::ConstIterator() |
156 | { | 156 | { |
157 | d = new ConstIteratorData; | 157 | d = new ConstIteratorData; |
158 | } | 158 | } |
159 | 159 | ||
160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
161 | { | 161 | { |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | } | 164 | } |
165 | 165 | ||
166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
167 | { | 167 | { |
168 | if( this == &i ) return *this; // guard for self assignment | 168 | if( this == &i ) return *this; // guard for self assignment |
169 | delete d; // delete the old data because the Iterator was really constructed before | 169 | delete d; // delete the old data because the Iterator was really constructed before |
170 | d = new ConstIteratorData; | 170 | d = new ConstIteratorData; |
171 | d->mIt = i.d->mIt; | 171 | d->mIt = i.d->mIt; |
172 | return *this; | 172 | return *this; |
173 | } | 173 | } |
174 | 174 | ||
175 | AddressBook::ConstIterator::~ConstIterator() | 175 | AddressBook::ConstIterator::~ConstIterator() |
176 | { | 176 | { |
177 | delete d; | 177 | delete d; |
178 | } | 178 | } |
179 | 179 | ||
180 | const Addressee &AddressBook::ConstIterator::operator*() const | 180 | const Addressee &AddressBook::ConstIterator::operator*() const |
181 | { | 181 | { |
182 | return *(d->mIt); | 182 | return *(d->mIt); |
183 | } | 183 | } |
184 | 184 | ||
185 | const Addressee* AddressBook::ConstIterator::operator->() const | 185 | const Addressee* AddressBook::ConstIterator::operator->() const |
186 | { | 186 | { |
187 | return &(*(d->mIt)); | 187 | return &(*(d->mIt)); |
188 | } | 188 | } |
189 | 189 | ||
190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
191 | { | 191 | { |
192 | (d->mIt)++; | 192 | (d->mIt)++; |
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
215 | { | 215 | { |
216 | return ( d->mIt == it.d->mIt ); | 216 | return ( d->mIt == it.d->mIt ); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
220 | { | 220 | { |
221 | return ( d->mIt != it.d->mIt ); | 221 | return ( d->mIt != it.d->mIt ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami ); | 280 | d->mManager = new KRES::Manager<Resource>( fami ); |
281 | d->mManager->readConfig( d->mConfig ); | 281 | d->mManager->readConfig( d->mConfig ); |
282 | if ( family == "syncContact" ) { | 282 | if ( family == "syncContact" ) { |
283 | KRES::Manager<Resource> *manager = d->mManager; | 283 | KRES::Manager<Resource> *manager = d->mManager; |
284 | KRES::Manager<Resource>::ActiveIterator it; | 284 | KRES::Manager<Resource>::ActiveIterator it; |
285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
286 | (*it)->setAddressBook( this ); | 286 | (*it)->setAddressBook( this ); |
287 | if ( !(*it)->open() ) | 287 | if ( !(*it)->open() ) |
288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
289 | } | 289 | } |
290 | Resource *res = standardResource(); | 290 | Resource *res = standardResource(); |
291 | if ( !res ) { | 291 | if ( !res ) { |
292 | qDebug("ERROR: no standard resource"); | 292 | qDebug("ERROR: no standard resource"); |
293 | res = manager->createResource( "file" ); | 293 | res = manager->createResource( "file" ); |
294 | if ( res ) | 294 | if ( res ) |
295 | { | 295 | { |
296 | addResource( res ); | 296 | addResource( res ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | qDebug(" No resource available!!!"); | 299 | qDebug(" No resource available!!!"); |
300 | } | 300 | } |
301 | setStandardResource( res ); | 301 | setStandardResource( res ); |
302 | manager->writeConfig(); | 302 | manager->writeConfig(); |
303 | } | 303 | } |
304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
305 | "X-Department", "KADDRESSBOOK" ); | 305 | "X-Department", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
307 | "X-Profession", "KADDRESSBOOK" ); | 307 | "X-Profession", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
309 | "X-AssistantsName", "KADDRESSBOOK" ); | 309 | "X-AssistantsName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
311 | "X-ManagersName", "KADDRESSBOOK" ); | 311 | "X-ManagersName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
313 | "X-SpousesName", "KADDRESSBOOK" ); | 313 | "X-SpousesName", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
315 | "X-Office", "KADDRESSBOOK" ); | 315 | "X-Office", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
317 | "X-IMAddress", "KADDRESSBOOK" ); | 317 | "X-IMAddress", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
319 | "X-Anniversary", "KADDRESSBOOK" ); | 319 | "X-Anniversary", "KADDRESSBOOK" ); |
320 | 320 | ||
321 | //US added this field to become compatible with Opie/qtopia addressbook | 321 | //US added this field to become compatible with Opie/qtopia addressbook |
322 | // values can be "female" or "male" or "". An empty field represents undefined. | 322 | // values can be "female" or "male" or "". An empty field represents undefined. |
323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
324 | "X-Gender", "KADDRESSBOOK" ); | 324 | "X-Gender", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
326 | "X-Children", "KADDRESSBOOK" ); | 326 | "X-Children", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
330 | "X-ExternalID", "KADDRESSBOOK" ); | 330 | "X-ExternalID", "KADDRESSBOOK" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~AddressBook() |
334 | { | 334 | { |
335 | delete d->mConfig; d->mConfig = 0; | 335 | delete d->mConfig; d->mConfig = 0; |
336 | delete d->mManager; d->mManager = 0; | 336 | delete d->mManager; d->mManager = 0; |
337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
338 | delete d; d = 0; | 338 | delete d; d = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | bool AddressBook::load() | 341 | bool AddressBook::load() |
342 | { | 342 | { |
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { | 395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { |
396 | if ( !(*it).IDStr().isEmpty() ) { | 396 | if ( !(*it).IDStr().isEmpty() ) { |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
398 | } | 398 | } |
399 | KABC::VCardConverter converter; | 399 | KABC::VCardConverter converter; |
400 | QString vcard; | 400 | QString vcard; |
401 | //Resource *resource() const; | 401 | //Resource *resource() const; |
402 | converter.addresseeToVCard( *it, vcard, version ); | 402 | converter.addresseeToVCard( *it, vcard, version ); |
403 | t << vcard << "\r\n"; | 403 | t << vcard << "\r\n"; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | t << "\r\n\r\n"; | 406 | t << "\r\n\r\n"; |
407 | outFile.close(); | 407 | outFile.close(); |
408 | } | 408 | } |
409 | // if QStringList uids is empty, all are exported | 409 | // if QStringList uids is empty, all are exported |
410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
411 | { | 411 | { |
412 | KABC::VCardConverter converter; | 412 | KABC::VCardConverter converter; |
413 | QString datastream; | 413 | QString datastream; |
414 | Iterator it; | 414 | Iterator it; |
415 | bool all = uids.isEmpty(); | 415 | bool all = uids.isEmpty(); |
416 | for ( it = begin(); it != end(); ++it ) { | 416 | for ( it = begin(); it != end(); ++it ) { |
417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
418 | if ( ! all ) { | 418 | if ( ! all ) { |
419 | if ( ! ( uids.contains((*it).uid() ) )) | 419 | if ( ! ( uids.contains((*it).uid() ) )) |
420 | continue; | 420 | continue; |
421 | } | 421 | } |
422 | KABC::Addressee a = ( *it ); | 422 | KABC::Addressee a = ( *it ); |
423 | if ( a.isEmpty() ) | 423 | if ( a.isEmpty() ) |
424 | continue; | 424 | continue; |
425 | if ( all && a.resource() && !a.resource()->includeInSync() ) | 425 | if ( all && a.resource() && !a.resource()->includeInSync() ) |
426 | continue; | 426 | continue; |
427 | a.simplifyEmails(); | 427 | a.simplifyEmails(); |
428 | a.simplifyPhoneNumbers(); | 428 | a.simplifyPhoneNumbers(); |
429 | a.simplifyPhoneNumberTypes(); | 429 | a.simplifyPhoneNumberTypes(); |
430 | a.simplifyAddresses(); | 430 | a.simplifyAddresses(); |
431 | 431 | ||
432 | QString vcard; | 432 | QString vcard; |
433 | QString vcardnew; | 433 | QString vcardnew; |
434 | converter.addresseeToVCard( a, vcard ); | 434 | converter.addresseeToVCard( a, vcard ); |
435 | int start = 0; | 435 | int start = 0; |
436 | int next; | 436 | int next; |
437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
438 | int semi = vcard.find(";", next); | 438 | int semi = vcard.find(";", next); |
439 | int dopp = vcard.find(":", next); | 439 | int dopp = vcard.find(":", next); |
440 | int sep; | 440 | int sep; |
441 | if ( semi < dopp && semi >= 0 ) | 441 | if ( semi < dopp && semi >= 0 ) |
442 | sep = semi ; | 442 | sep = semi ; |
443 | else | 443 | else |
444 | sep = dopp; | 444 | sep = dopp; |
445 | vcardnew +=vcard.mid( start, next - start); | 445 | vcardnew +=vcard.mid( start, next - start); |
446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
447 | start = sep; | 447 | start = sep; |
448 | } | 448 | } |
449 | vcardnew += vcard.mid( start,vcard.length() ); | 449 | vcardnew += vcard.mid( start,vcard.length() ); |
450 | vcard = ""; | 450 | vcard = ""; |
451 | start = 0; | 451 | start = 0; |
452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
453 | int sep = vcardnew.find(":", next); | 453 | int sep = vcardnew.find(":", next); |
454 | vcard +=vcardnew.mid( start, next - start+3); | 454 | vcard +=vcardnew.mid( start, next - start+3); |
455 | start = sep; | 455 | start = sep; |
456 | } | 456 | } |
457 | vcard += vcardnew.mid( start,vcardnew.length() ); | 457 | vcard += vcardnew.mid( start,vcardnew.length() ); |
458 | vcard.replace ( QRegExp(";;;") , "" ); | 458 | vcard.replace ( QRegExp(";;;") , "" ); |
459 | vcard.replace ( QRegExp(";;") , "" ); | 459 | vcard.replace ( QRegExp(";;") , "" ); |
460 | datastream += vcard; | 460 | datastream += vcard; |
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | QFile outFile(fileName); | 464 | QFile outFile(fileName); |
465 | if ( outFile.open(IO_WriteOnly) ) { | 465 | if ( outFile.open(IO_WriteOnly) ) { |
466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
467 | QTextStream t( &outFile ); // use a text stream | 467 | QTextStream t( &outFile ); // use a text stream |
468 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 468 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
469 | t <<datastream; | 469 | t <<datastream; |
470 | t << "\r\n\r\n"; | 470 | t << "\r\n\r\n"; |
471 | outFile.close(); | 471 | outFile.close(); |
472 | 472 | ||
473 | } else { | 473 | } else { |
474 | qDebug("Error open temp file "); | 474 | qDebug("Error open temp file "); |
475 | return false; | 475 | return false; |
476 | } | 476 | } |
477 | return true; | 477 | return true; |
478 | 478 | ||
479 | } | 479 | } |
480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
481 | { | 481 | { |
482 | 482 | ||
483 | if ( removeOld ) | 483 | if ( removeOld ) |
484 | setUntagged( true ); | 484 | setUntagged( true ); |
485 | KABC::Addressee::List list; | 485 | KABC::Addressee::List list; |
486 | QFile file( fileName ); | 486 | QFile file( fileName ); |
487 | file.open( IO_ReadOnly ); | 487 | file.open( IO_ReadOnly ); |
488 | QByteArray rawData = file.readAll(); | 488 | QByteArray rawData = file.readAll(); |
489 | file.close(); | 489 | file.close(); |
490 | QString data; | 490 | QString data; |
491 | if ( replaceLabel ) { | 491 | if ( replaceLabel ) { |
492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
493 | data.replace ( QRegExp("LABEL") , "ADR" ); | 493 | data.replace ( QRegExp("LABEL") , "ADR" ); |
494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
495 | } else | 495 | } else |
496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
497 | KABC::VCardTool tool; | 497 | KABC::VCardTool tool; |
498 | list = tool.parseVCards( data ); | 498 | list = tool.parseVCards( data ); |
499 | KABC::Addressee::List::Iterator it; | 499 | KABC::Addressee::List::Iterator it; |
500 | for ( it = list.begin(); it != list.end(); ++it ) { | 500 | for ( it = list.begin(); it != list.end(); ++it ) { |
501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
502 | if ( !id.isEmpty() ) | 502 | if ( !id.isEmpty() ) |
503 | (*it).setIDStr(id ); | 503 | (*it).setIDStr(id ); |
504 | (*it).setResource( 0 ); | 504 | (*it).setResource( 0 ); |
505 | if ( replaceLabel ) | 505 | if ( replaceLabel ) |
506 | (*it).removeVoice(); | 506 | (*it).removeVoice(); |
507 | if ( removeOld ) | 507 | if ( removeOld ) |
508 | (*it).setTagged( true ); | 508 | (*it).setTagged( true ); |
509 | insertAddressee( (*it), false, true ); | 509 | insertAddressee( (*it), false, true ); |
510 | } | 510 | } |
511 | if ( removeOld ) | 511 | if ( removeOld ) |
512 | removeUntagged(); | 512 | removeUntagged(); |
513 | return list.count(); | 513 | return list.count(); |
514 | } | 514 | } |
515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) |
516 | { | 516 | { |
517 | Iterator ait; | 517 | Iterator ait; |
518 | for ( ait = begin(); ait != end(); ++ait ) { | 518 | for ( ait = begin(); ait != end(); ++ait ) { |
519 | if ( setNonSyncTagged ) { | 519 | if ( setNonSyncTagged ) { |
520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | 520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { |
521 | (*ait).setTagged( true ); | 521 | (*ait).setTagged( true ); |
522 | } else | 522 | } else |
523 | (*ait).setTagged( false ); | 523 | (*ait).setTagged( false ); |
524 | } else | 524 | } else |
525 | (*ait).setTagged( false ); | 525 | (*ait).setTagged( false ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | void AddressBook::removeUntagged() | 528 | void AddressBook::removeUntagged() |
529 | { | 529 | { |
530 | Iterator ait; | 530 | Iterator ait; |
531 | bool todelete = false; | 531 | bool todelete = false; |
532 | Iterator todel; | 532 | Iterator todel; |
533 | for ( ait = begin(); ait != end(); ++ait ) { | 533 | for ( ait = begin(); ait != end(); ++ait ) { |
534 | if ( todelete ) | 534 | if ( todelete ) |
535 | removeAddressee( todel ); | 535 | removeAddressee( todel ); |
536 | if (!(*ait).tagged()) { | 536 | if (!(*ait).tagged()) { |
537 | todelete = true; | 537 | todelete = true; |
538 | todel = ait; | 538 | todel = ait; |
539 | } else | 539 | } else |
540 | todelete = false; | 540 | todelete = false; |
541 | } | 541 | } |
542 | if ( todelete ) | 542 | if ( todelete ) |
543 | removeAddressee( todel ); | 543 | removeAddressee( todel ); |
544 | deleteRemovedAddressees(); | 544 | deleteRemovedAddressees(); |
545 | } | 545 | } |
546 | void AddressBook::smplifyAddressees() | 546 | void AddressBook::smplifyAddressees() |
547 | { | 547 | { |
548 | Iterator ait; | 548 | Iterator ait; |
549 | for ( ait = begin(); ait != end(); ++ait ) { | 549 | for ( ait = begin(); ait != end(); ++ait ) { |
550 | (*ait).simplifyEmails(); | 550 | (*ait).simplifyEmails(); |
551 | (*ait).simplifyPhoneNumbers(); | 551 | (*ait).simplifyPhoneNumbers(); |
552 | (*ait).simplifyPhoneNumberTypes(); | 552 | (*ait).simplifyPhoneNumberTypes(); |
553 | (*ait).simplifyAddresses(); | 553 | (*ait).simplifyAddresses(); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | void AddressBook::removeSyncInfo( QString syncProfile) | ||
557 | { | ||
558 | Iterator ait; | ||
559 | for ( ait = begin(); ait != end(); ++ait ) { | ||
560 | (*ait).removeID( syncProfile ); | ||
561 | } | ||
562 | |||
563 | } | ||
556 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 564 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) |
557 | { | 565 | { |
558 | Iterator ait; | 566 | Iterator ait; |
559 | for ( ait = begin(); ait != end(); ++ait ) { | 567 | for ( ait = begin(); ait != end(); ++ait ) { |
560 | QString id = (*ait).IDStr(); | 568 | QString id = (*ait).IDStr(); |
561 | (*ait).setIDStr( ":"); | 569 | (*ait).setIDStr( ":"); |
562 | (*ait).setExternalUID( id ); | 570 | (*ait).setExternalUID( id ); |
563 | (*ait).setOriginalExternalUID( id ); | 571 | (*ait).setOriginalExternalUID( id ); |
564 | if ( isPreSync ) | 572 | if ( isPreSync ) |
565 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 573 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
566 | else { | 574 | else { |
567 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 575 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
568 | (*ait).setID( currentSyncDevice,id ); | 576 | (*ait).setID( currentSyncDevice,id ); |
569 | 577 | ||
570 | } | 578 | } |
571 | } | 579 | } |
572 | } | 580 | } |
573 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 581 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) |
574 | { | 582 | { |
575 | 583 | ||
576 | setUntagged(); | 584 | setUntagged(); |
577 | KABC::Addressee::List list; | 585 | KABC::Addressee::List list; |
578 | QFile file( fileName ); | 586 | QFile file( fileName ); |
579 | file.open( IO_ReadOnly ); | 587 | file.open( IO_ReadOnly ); |
580 | QByteArray rawData = file.readAll(); | 588 | QByteArray rawData = file.readAll(); |
581 | file.close(); | 589 | file.close(); |
582 | QString data; | 590 | QString data; |
583 | 591 | ||
584 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 592 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
585 | KABC::VCardTool tool; | 593 | KABC::VCardTool tool; |
586 | list = tool.parseVCards( data ); | 594 | list = tool.parseVCards( data ); |
587 | KABC::Addressee::List::Iterator it; | 595 | KABC::Addressee::List::Iterator it; |
588 | for ( it = list.begin(); it != list.end(); ++it ) { | 596 | for ( it = list.begin(); it != list.end(); ++it ) { |
589 | Iterator ait; | 597 | Iterator ait; |
590 | for ( ait = begin(); ait != end(); ++ait ) { | 598 | for ( ait = begin(); ait != end(); ++ait ) { |
591 | if ( !(*ait).tagged() ) { | 599 | if ( !(*ait).tagged() ) { |
592 | if ( (*ait).containsAdr(*it)) { | 600 | if ( (*ait).containsAdr(*it)) { |
593 | (*ait).setTagged(true); | 601 | (*ait).setTagged(true); |
594 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 602 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
595 | (*it).setIDStr( ":"); | 603 | (*it).setIDStr( ":"); |
596 | (*it).setID( currentSyncDevice,id ); | 604 | (*it).setID( currentSyncDevice,id ); |
597 | (*it).setExternalUID( id ); | 605 | (*it).setExternalUID( id ); |
598 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 606 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
599 | (*it).setUid( ( (*ait).uid() )); | 607 | (*it).setUid( ( (*ait).uid() )); |
600 | break; | 608 | break; |
601 | } | 609 | } |
602 | } | 610 | } |
603 | 611 | ||
604 | } | 612 | } |
605 | if ( ait == end() ) | 613 | if ( ait == end() ) |
606 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); | 614 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); |
607 | } | 615 | } |
608 | clear(); | 616 | clear(); |
609 | for ( it = list.begin(); it != list.end(); ++it ) { | 617 | for ( it = list.begin(); it != list.end(); ++it ) { |
610 | insertAddressee( (*it) ); | 618 | insertAddressee( (*it) ); |
611 | } | 619 | } |
612 | } | 620 | } |
613 | 621 | ||
614 | bool AddressBook::saveABphone( QString fileName ) | 622 | bool AddressBook::saveABphone( QString fileName ) |
615 | { | 623 | { |
616 | //smplifyAddressees(); | 624 | //smplifyAddressees(); |
617 | qDebug("saveABphone:: saving AB... "); | 625 | qDebug("saveABphone:: saving AB... "); |
618 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 626 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
619 | return false; | 627 | return false; |
620 | qDebug("saveABphone:: writing to phone... "); | 628 | qDebug("saveABphone:: writing to phone... "); |
621 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 629 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
622 | return false; | 630 | return false; |
623 | } | 631 | } |
624 | qDebug("saveABphone:: re-reading from phone... "); | 632 | qDebug("saveABphone:: re-reading from phone... "); |
625 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 633 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
626 | return false; | 634 | return false; |
627 | } | 635 | } |
628 | return true; | 636 | return true; |
629 | } | 637 | } |
630 | bool AddressBook::saveAB() | 638 | bool AddressBook::saveAB() |
631 | { | 639 | { |
632 | bool ok = true; | 640 | bool ok = true; |
633 | 641 | ||
634 | deleteRemovedAddressees(); | 642 | deleteRemovedAddressees(); |
635 | Iterator ait; | 643 | Iterator ait; |
636 | for ( ait = begin(); ait != end(); ++ait ) { | 644 | for ( ait = begin(); ait != end(); ++ait ) { |
637 | if ( !(*ait).IDStr().isEmpty() ) { | 645 | if ( !(*ait).IDStr().isEmpty() ) { |
638 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 646 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
639 | } | 647 | } |
640 | } | 648 | } |
641 | KRES::Manager<Resource>::ActiveIterator it; | 649 | KRES::Manager<Resource>::ActiveIterator it; |
642 | KRES::Manager<Resource> *manager = d->mManager; | 650 | KRES::Manager<Resource> *manager = d->mManager; |
643 | qDebug("SaveAB::saving..." ); | 651 | qDebug("SaveAB::saving..." ); |
644 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 652 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
645 | qDebug("SaveAB::checking resource..." ); | 653 | qDebug("SaveAB::checking resource..." ); |
646 | if ( (*it)->readOnly() ) | 654 | if ( (*it)->readOnly() ) |
647 | qDebug("resource is readonly." ); | 655 | qDebug("resource is readonly." ); |
648 | if ( (*it)->isOpen() ) | 656 | if ( (*it)->isOpen() ) |
649 | qDebug("resource is open" ); | 657 | qDebug("resource is open" ); |
650 | 658 | ||
651 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 659 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
652 | Ticket *ticket = requestSaveTicket( *it ); | 660 | Ticket *ticket = requestSaveTicket( *it ); |
653 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 661 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
654 | if ( !ticket ) { | 662 | if ( !ticket ) { |
655 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) | 663 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) |
656 | .arg( (*it)->resourceName() ) ); | 664 | .arg( (*it)->resourceName() ) ); |
657 | return false; | 665 | return false; |
658 | } | 666 | } |
659 | 667 | ||
660 | //if ( !save( ticket ) ) | 668 | //if ( !save( ticket ) ) |
661 | if ( ticket->resource() ) { | 669 | if ( ticket->resource() ) { |
662 | QString name = ticket->resource()->resourceName(); | 670 | QString name = ticket->resource()->resourceName(); |
663 | if ( ! ticket->resource()->save( ticket ) ) | 671 | if ( ! ticket->resource()->save( ticket ) ) |
664 | ok = false; | 672 | ok = false; |
665 | else | 673 | else |
666 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); | 674 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); |
667 | 675 | ||
668 | } else | 676 | } else |
669 | ok = false; | 677 | ok = false; |
670 | 678 | ||
671 | } | 679 | } |
672 | } | 680 | } |
673 | return ok; | 681 | return ok; |
674 | } | 682 | } |
675 | 683 | ||
676 | AddressBook::Iterator AddressBook::begin() | 684 | AddressBook::Iterator AddressBook::begin() |
677 | { | 685 | { |
678 | Iterator it = Iterator(); | 686 | Iterator it = Iterator(); |
679 | it.d->mIt = d->mAddressees.begin(); | 687 | it.d->mIt = d->mAddressees.begin(); |
680 | return it; | 688 | return it; |
681 | } | 689 | } |
682 | 690 | ||
683 | AddressBook::ConstIterator AddressBook::begin() const | 691 | AddressBook::ConstIterator AddressBook::begin() const |
684 | { | 692 | { |
685 | ConstIterator it = ConstIterator(); | 693 | ConstIterator it = ConstIterator(); |
686 | it.d->mIt = d->mAddressees.begin(); | 694 | it.d->mIt = d->mAddressees.begin(); |
687 | return it; | 695 | return it; |
688 | } | 696 | } |
689 | 697 | ||
690 | AddressBook::Iterator AddressBook::end() | 698 | AddressBook::Iterator AddressBook::end() |
691 | { | 699 | { |
692 | Iterator it = Iterator(); | 700 | Iterator it = Iterator(); |
693 | it.d->mIt = d->mAddressees.end(); | 701 | it.d->mIt = d->mAddressees.end(); |
694 | return it; | 702 | return it; |
695 | } | 703 | } |
696 | 704 | ||
697 | AddressBook::ConstIterator AddressBook::end() const | 705 | AddressBook::ConstIterator AddressBook::end() const |
698 | { | 706 | { |
699 | ConstIterator it = ConstIterator(); | 707 | ConstIterator it = ConstIterator(); |
700 | it.d->mIt = d->mAddressees.end(); | 708 | it.d->mIt = d->mAddressees.end(); |
701 | return it; | 709 | return it; |
702 | } | 710 | } |
703 | 711 | ||
704 | void AddressBook::clear() | 712 | void AddressBook::clear() |
705 | { | 713 | { |
706 | d->mAddressees.clear(); | 714 | d->mAddressees.clear(); |
707 | } | 715 | } |
708 | 716 | ||
709 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 717 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
710 | { | 718 | { |
711 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 719 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
712 | 720 | ||
713 | if ( !resource ) | 721 | if ( !resource ) |
714 | { | 722 | { |
715 | qDebug("AddressBook::requestSaveTicket no resource" ); | 723 | qDebug("AddressBook::requestSaveTicket no resource" ); |
716 | resource = standardResource(); | 724 | resource = standardResource(); |
717 | } | 725 | } |
718 | 726 | ||
719 | KRES::Manager<Resource>::ActiveIterator it; | 727 | KRES::Manager<Resource>::ActiveIterator it; |
720 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 728 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
721 | if ( (*it) == resource ) { | 729 | if ( (*it) == resource ) { |
722 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 730 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
723 | return 0; | 731 | return 0; |
724 | else | 732 | else |
725 | return (*it)->requestSaveTicket(); | 733 | return (*it)->requestSaveTicket(); |
726 | } | 734 | } |
727 | } | 735 | } |
728 | 736 | ||
729 | return 0; | 737 | return 0; |
730 | } | 738 | } |
731 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 739 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
732 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 740 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
733 | { | 741 | { |
734 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 742 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
735 | //qDebug("block insert "); | 743 | //qDebug("block insert "); |
736 | return; | 744 | return; |
737 | } | 745 | } |
738 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 746 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
739 | bool found = false; | 747 | bool found = false; |
740 | Addressee::List::Iterator it; | 748 | Addressee::List::Iterator it; |
741 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 749 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
742 | if ( a.uid() == (*it).uid() ) { | 750 | if ( a.uid() == (*it).uid() ) { |
743 | 751 | ||
744 | bool changed = false; | 752 | bool changed = false; |
745 | Addressee addr = a; | 753 | Addressee addr = a; |
746 | if ( addr != (*it) ) | 754 | if ( addr != (*it) ) |
747 | changed = true; | 755 | changed = true; |
748 | 756 | ||
749 | if ( takeResource ) { | 757 | if ( takeResource ) { |
750 | Resource * res = (*it).resource(); | 758 | Resource * res = (*it).resource(); |
751 | (*it) = a; | 759 | (*it) = a; |
752 | (*it).setResource( res ); | 760 | (*it).setResource( res ); |
753 | } else { | 761 | } else { |
754 | (*it) = a; | 762 | (*it) = a; |
755 | if ( (*it).resource() == 0 ) | 763 | if ( (*it).resource() == 0 ) |
756 | (*it).setResource( standardResource() ); | 764 | (*it).setResource( standardResource() ); |
757 | } | 765 | } |
758 | if ( changed ) { | 766 | if ( changed ) { |
759 | if ( setRev ) { | 767 | if ( setRev ) { |
760 | 768 | ||
761 | // get rid of micro seconds | 769 | // get rid of micro seconds |
762 | QDateTime dt = QDateTime::currentDateTime(); | 770 | QDateTime dt = QDateTime::currentDateTime(); |
763 | QTime t = dt.time(); | 771 | QTime t = dt.time(); |
764 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 772 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
765 | (*it).setRevision( dt ); | 773 | (*it).setRevision( dt ); |
766 | } | 774 | } |
767 | (*it).setChanged( true ); | 775 | (*it).setChanged( true ); |
768 | } | 776 | } |
769 | 777 | ||
770 | found = true; | 778 | found = true; |
771 | } else { | 779 | } else { |
772 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 780 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
773 | QString name = (*it).uid().mid( 19 ); | 781 | QString name = (*it).uid().mid( 19 ); |
774 | Addressee b = a; | 782 | Addressee b = a; |
775 | QString id = b.getID( name ); | 783 | QString id = b.getID( name ); |
776 | if ( ! id.isEmpty() ) { | 784 | if ( ! id.isEmpty() ) { |
777 | QString des = (*it).note(); | 785 | QString des = (*it).note(); |
778 | int startN; | 786 | int startN; |
779 | if( (startN = des.find( id ) ) >= 0 ) { | 787 | if( (startN = des.find( id ) ) >= 0 ) { |
780 | int endN = des.find( ",", startN+1 ); | 788 | int endN = des.find( ",", startN+1 ); |
781 | des = des.left( startN ) + des.mid( endN+1 ); | 789 | des = des.left( startN ) + des.mid( endN+1 ); |
782 | (*it).setNote( des ); | 790 | (*it).setNote( des ); |
783 | } | 791 | } |
784 | } | 792 | } |
785 | } | 793 | } |
786 | } | 794 | } |
787 | } | 795 | } |
788 | if ( found ) | 796 | if ( found ) |
789 | return; | 797 | return; |
790 | d->mAddressees.append( a ); | 798 | d->mAddressees.append( a ); |
791 | Addressee& addr = d->mAddressees.last(); | 799 | Addressee& addr = d->mAddressees.last(); |
792 | if ( addr.resource() == 0 ) | 800 | if ( addr.resource() == 0 ) |
793 | addr.setResource( standardResource() ); | 801 | addr.setResource( standardResource() ); |
794 | 802 | ||
795 | addr.setChanged( true ); | 803 | addr.setChanged( true ); |
796 | } | 804 | } |
797 | 805 | ||
798 | void AddressBook::removeAddressee( const Addressee &a ) | 806 | void AddressBook::removeAddressee( const Addressee &a ) |
799 | { | 807 | { |
800 | Iterator it; | 808 | Iterator it; |
801 | Iterator it2; | 809 | Iterator it2; |
802 | bool found = false; | 810 | bool found = false; |
803 | for ( it = begin(); it != end(); ++it ) { | 811 | for ( it = begin(); it != end(); ++it ) { |
804 | if ( a.uid() == (*it).uid() ) { | 812 | if ( a.uid() == (*it).uid() ) { |
805 | found = true; | 813 | found = true; |
806 | it2 = it; | 814 | it2 = it; |
807 | } else { | 815 | } else { |
808 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 816 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
809 | QString name = (*it).uid().mid( 19 ); | 817 | QString name = (*it).uid().mid( 19 ); |
810 | Addressee b = a; | 818 | Addressee b = a; |
811 | QString id = b.getID( name ); | 819 | QString id = b.getID( name ); |
812 | if ( ! id.isEmpty() ) { | 820 | if ( ! id.isEmpty() ) { |
813 | QString des = (*it).note(); | 821 | QString des = (*it).note(); |
814 | if( des.find( id ) < 0 ) { | 822 | if( des.find( id ) < 0 ) { |
815 | des += id + ","; | 823 | des += id + ","; |
816 | (*it).setNote( des ); | 824 | (*it).setNote( des ); |
817 | } | 825 | } |
818 | } | 826 | } |
819 | } | 827 | } |
820 | 828 | ||
821 | } | 829 | } |
822 | } | 830 | } |
823 | 831 | ||
824 | if ( found ) | 832 | if ( found ) |
825 | removeAddressee( it2 ); | 833 | removeAddressee( it2 ); |
826 | 834 | ||
827 | } | 835 | } |
828 | 836 | ||
829 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 837 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
830 | { | 838 | { |
831 | Iterator it = begin(); | 839 | Iterator it = begin(); |
832 | Iterator it2 ; | 840 | Iterator it2 ; |
833 | QDateTime dt ( QDate( 2004,1,1) ); | 841 | QDateTime dt ( QDate( 2004,1,1) ); |
834 | while ( it != end() ) { | 842 | while ( it != end() ) { |
835 | (*it).setRevision( dt ); | 843 | (*it).setRevision( dt ); |
836 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 844 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
837 | (*it).setIDStr(""); | 845 | (*it).setIDStr(""); |
838 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 846 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
839 | it2 = it; | 847 | it2 = it; |
840 | //qDebug("removing %s ",(*it).uid().latin1() ); | 848 | //qDebug("removing %s ",(*it).uid().latin1() ); |
841 | ++it; | 849 | ++it; |
842 | removeAddressee( it2 ); | 850 | removeAddressee( it2 ); |
843 | } else { | 851 | } else { |
844 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 852 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
845 | ++it; | 853 | ++it; |
846 | } | 854 | } |
847 | } | 855 | } |
848 | deleteRemovedAddressees(); | 856 | deleteRemovedAddressees(); |
849 | } | 857 | } |
850 | 858 | ||
851 | void AddressBook::removeAddressee( const Iterator &it ) | 859 | void AddressBook::removeAddressee( const Iterator &it ) |
852 | { | 860 | { |
853 | d->mRemovedAddressees.append( (*it) ); | 861 | d->mRemovedAddressees.append( (*it) ); |
854 | d->mAddressees.remove( it.d->mIt ); | 862 | d->mAddressees.remove( it.d->mIt ); |
855 | } | 863 | } |
856 | 864 | ||
857 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 865 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
858 | { | 866 | { |
859 | Iterator it; | 867 | Iterator it; |
860 | for ( it = begin(); it != end(); ++it ) { | 868 | for ( it = begin(); it != end(); ++it ) { |
861 | if ( a.uid() == (*it).uid() ) { | 869 | if ( a.uid() == (*it).uid() ) { |
862 | return it; | 870 | return it; |
863 | } | 871 | } |
864 | } | 872 | } |
865 | return end(); | 873 | return end(); |
866 | } | 874 | } |
867 | 875 | ||
868 | Addressee AddressBook::findByUid( const QString &uid ) | 876 | Addressee AddressBook::findByUid( const QString &uid ) |
869 | { | 877 | { |
870 | Iterator it; | 878 | Iterator it; |
871 | for ( it = begin(); it != end(); ++it ) { | 879 | for ( it = begin(); it != end(); ++it ) { |
872 | if ( uid == (*it).uid() ) { | 880 | if ( uid == (*it).uid() ) { |
873 | return *it; | 881 | return *it; |
874 | } | 882 | } |
875 | } | 883 | } |
876 | return Addressee(); | 884 | return Addressee(); |
877 | } | 885 | } |
878 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 886 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
879 | { | 887 | { |
880 | //qDebug("AddressBook::preExternSync "); | 888 | //qDebug("AddressBook::preExternSync "); |
881 | AddressBook::Iterator it; | 889 | AddressBook::Iterator it; |
882 | for ( it = begin(); it != end(); ++it ) { | 890 | for ( it = begin(); it != end(); ++it ) { |
883 | (*it).setID( csd, (*it).externalUID() ); | 891 | (*it).setID( csd, (*it).externalUID() ); |
884 | (*it).computeCsum( csd ); | 892 | (*it).computeCsum( csd ); |
885 | } | 893 | } |
886 | mergeAB( aBook ,csd, isSubset ); | 894 | mergeAB( aBook ,csd, isSubset ); |
887 | } | 895 | } |
888 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 896 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
889 | { | 897 | { |
890 | //qDebug("AddressBook::postExternSync "); | 898 | //qDebug("AddressBook::postExternSync "); |
891 | AddressBook::Iterator it; | 899 | AddressBook::Iterator it; |
892 | for ( it = begin(); it != end(); ++it ) { | 900 | for ( it = begin(); it != end(); ++it ) { |
893 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 901 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
894 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 902 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
895 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 903 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
896 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 904 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
897 | if ( ad.isEmpty() ) { | 905 | if ( ad.isEmpty() ) { |
898 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 906 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
899 | } else { | 907 | } else { |
900 | (*it).computeCsum( csd ); | 908 | (*it).computeCsum( csd ); |
901 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 909 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
902 | ad.setID( csd, (*it).externalUID() ); | 910 | ad.setID( csd, (*it).externalUID() ); |
903 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 911 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
904 | aBook->insertAddressee( ad ); | 912 | aBook->insertAddressee( ad ); |
905 | } | 913 | } |
906 | } | 914 | } |
907 | } | 915 | } |
908 | } | 916 | } |
909 | 917 | ||
910 | bool AddressBook::containsExternalUid( const QString& uid ) | 918 | bool AddressBook::containsExternalUid( const QString& uid ) |
911 | { | 919 | { |
912 | Iterator it; | 920 | Iterator it; |
913 | for ( it = begin(); it != end(); ++it ) { | 921 | for ( it = begin(); it != end(); ++it ) { |
914 | if ( uid == (*it).externalUID( ) ) | 922 | if ( uid == (*it).externalUID( ) ) |
915 | return true; | 923 | return true; |
916 | } | 924 | } |
917 | return false; | 925 | return false; |
918 | } | 926 | } |
919 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 927 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
920 | { | 928 | { |
921 | Iterator it; | 929 | Iterator it; |
922 | for ( it = begin(); it != end(); ++it ) { | 930 | for ( it = begin(); it != end(); ++it ) { |
923 | if ( uid == (*it).getID( profile ) ) | 931 | if ( uid == (*it).getID( profile ) ) |
924 | return (*it); | 932 | return (*it); |
925 | } | 933 | } |
926 | return Addressee(); | 934 | return Addressee(); |
927 | } | 935 | } |
928 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 936 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
929 | { | 937 | { |
930 | Iterator it; | 938 | Iterator it; |
931 | Addressee ad; | 939 | Addressee ad; |
932 | for ( it = begin(); it != end(); ++it ) { | 940 | for ( it = begin(); it != end(); ++it ) { |
933 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 941 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
934 | if ( !ad.isEmpty() ) { | 942 | if ( !ad.isEmpty() ) { |
935 | (*it).mergeContact( ad ,isSubset); | 943 | (*it).mergeContact( ad ,isSubset); |
936 | } | 944 | } |
937 | } | 945 | } |
938 | #if 0 | 946 | #if 0 |
939 | // test only | 947 | // test only |
940 | for ( it = begin(); it != end(); ++it ) { | 948 | for ( it = begin(); it != end(); ++it ) { |
941 | 949 | ||
942 | qDebug("uid %s ", (*it).uid().latin1()); | 950 | qDebug("uid %s ", (*it).uid().latin1()); |
943 | } | 951 | } |
944 | #endif | 952 | #endif |
945 | } | 953 | } |
946 | 954 | ||
947 | #if 0 | 955 | #if 0 |
948 | Addressee::List AddressBook::getExternLastSyncAddressees() | 956 | Addressee::List AddressBook::getExternLastSyncAddressees() |
949 | { | 957 | { |
950 | Addressee::List results; | 958 | Addressee::List results; |
951 | 959 | ||
952 | Iterator it; | 960 | Iterator it; |
953 | for ( it = begin(); it != end(); ++it ) { | 961 | for ( it = begin(); it != end(); ++it ) { |
954 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 962 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
955 | if ( (*it).familyName().left(4) == "!E: " ) | 963 | if ( (*it).familyName().left(4) == "!E: " ) |
956 | results.append( *it ); | 964 | results.append( *it ); |
957 | } | 965 | } |
958 | } | 966 | } |
959 | 967 | ||
960 | return results; | 968 | return results; |
961 | } | 969 | } |
962 | #endif | 970 | #endif |
963 | void AddressBook::resetTempSyncStat() | 971 | void AddressBook::resetTempSyncStat() |
964 | { | 972 | { |
965 | Iterator it; | 973 | Iterator it; |
966 | for ( it = begin(); it != end(); ++it ) { | 974 | for ( it = begin(); it != end(); ++it ) { |
967 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 975 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
968 | } | 976 | } |
969 | 977 | ||
970 | } | 978 | } |
971 | 979 | ||
972 | QStringList AddressBook:: uidList() | 980 | QStringList AddressBook:: uidList() |
973 | { | 981 | { |
974 | QStringList results; | 982 | QStringList results; |
975 | Iterator it; | 983 | Iterator it; |
976 | for ( it = begin(); it != end(); ++it ) { | 984 | for ( it = begin(); it != end(); ++it ) { |
977 | results.append( (*it).uid() ); | 985 | results.append( (*it).uid() ); |
978 | } | 986 | } |
979 | return results; | 987 | return results; |
980 | } | 988 | } |
981 | 989 | ||
982 | 990 | ||
983 | Addressee::List AddressBook::allAddressees() | 991 | Addressee::List AddressBook::allAddressees() |
984 | { | 992 | { |
985 | return d->mAddressees; | 993 | return d->mAddressees; |
986 | 994 | ||
987 | } | 995 | } |
988 | 996 | ||
989 | Addressee::List AddressBook::findByName( const QString &name ) | 997 | Addressee::List AddressBook::findByName( const QString &name ) |
990 | { | 998 | { |
991 | Addressee::List results; | 999 | Addressee::List results; |
992 | 1000 | ||
993 | Iterator it; | 1001 | Iterator it; |
994 | for ( it = begin(); it != end(); ++it ) { | 1002 | for ( it = begin(); it != end(); ++it ) { |
995 | if ( name == (*it).realName() ) { | 1003 | if ( name == (*it).realName() ) { |
996 | results.append( *it ); | 1004 | results.append( *it ); |
997 | } | 1005 | } |
998 | } | 1006 | } |
999 | 1007 | ||
1000 | return results; | 1008 | return results; |
1001 | } | 1009 | } |
1002 | 1010 | ||
1003 | Addressee::List AddressBook::findByEmail( const QString &email ) | 1011 | Addressee::List AddressBook::findByEmail( const QString &email ) |
1004 | { | 1012 | { |
1005 | Addressee::List results; | 1013 | Addressee::List results; |
1006 | QStringList mailList; | 1014 | QStringList mailList; |
1007 | 1015 | ||
1008 | Iterator it; | 1016 | Iterator it; |
1009 | for ( it = begin(); it != end(); ++it ) { | 1017 | for ( it = begin(); it != end(); ++it ) { |
1010 | mailList = (*it).emails(); | 1018 | mailList = (*it).emails(); |
1011 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 1019 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
1012 | if ( email == (*ite) ) { | 1020 | if ( email == (*ite) ) { |
1013 | results.append( *it ); | 1021 | results.append( *it ); |
1014 | } | 1022 | } |
1015 | } | 1023 | } |
1016 | } | 1024 | } |
1017 | 1025 | ||
1018 | return results; | 1026 | return results; |
1019 | } | 1027 | } |
1020 | 1028 | ||
1021 | Addressee::List AddressBook::findByCategory( const QString &category ) | 1029 | Addressee::List AddressBook::findByCategory( const QString &category ) |
1022 | { | 1030 | { |
1023 | Addressee::List results; | 1031 | Addressee::List results; |
1024 | 1032 | ||
1025 | Iterator it; | 1033 | Iterator it; |
1026 | for ( it = begin(); it != end(); ++it ) { | 1034 | for ( it = begin(); it != end(); ++it ) { |
1027 | if ( (*it).hasCategory( category) ) { | 1035 | if ( (*it).hasCategory( category) ) { |
1028 | results.append( *it ); | 1036 | results.append( *it ); |
1029 | } | 1037 | } |
1030 | } | 1038 | } |
1031 | 1039 | ||
1032 | return results; | 1040 | return results; |
1033 | } | 1041 | } |
1034 | 1042 | ||
1035 | void AddressBook::dump() const | 1043 | void AddressBook::dump() const |
1036 | { | 1044 | { |
1037 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 1045 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
1038 | 1046 | ||
1039 | ConstIterator it; | 1047 | ConstIterator it; |
1040 | for( it = begin(); it != end(); ++it ) { | 1048 | for( it = begin(); it != end(); ++it ) { |
1041 | (*it).dump(); | 1049 | (*it).dump(); |
1042 | } | 1050 | } |
1043 | 1051 | ||
1044 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 1052 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
1045 | } | 1053 | } |
1046 | 1054 | ||
1047 | QString AddressBook::identifier() | 1055 | QString AddressBook::identifier() |
1048 | { | 1056 | { |
1049 | QStringList identifier; | 1057 | QStringList identifier; |
1050 | 1058 | ||
1051 | 1059 | ||
1052 | KRES::Manager<Resource>::ActiveIterator it; | 1060 | KRES::Manager<Resource>::ActiveIterator it; |
1053 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1061 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1054 | if ( !(*it)->identifier().isEmpty() ) | 1062 | if ( !(*it)->identifier().isEmpty() ) |
1055 | identifier.append( (*it)->identifier() ); | 1063 | identifier.append( (*it)->identifier() ); |
1056 | } | 1064 | } |
1057 | 1065 | ||
1058 | return identifier.join( ":" ); | 1066 | return identifier.join( ":" ); |
1059 | } | 1067 | } |
1060 | 1068 | ||
1061 | Field::List AddressBook::fields( int category ) | 1069 | Field::List AddressBook::fields( int category ) |
1062 | { | 1070 | { |
1063 | if ( d->mAllFields.isEmpty() ) { | 1071 | if ( d->mAllFields.isEmpty() ) { |
1064 | d->mAllFields = Field::allFields(); | 1072 | d->mAllFields = Field::allFields(); |
1065 | } | 1073 | } |
1066 | 1074 | ||
1067 | if ( category == Field::All ) return d->mAllFields; | 1075 | if ( category == Field::All ) return d->mAllFields; |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 5edca06..f124dc9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,348 +1,349 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void removeSyncInfo( QString syncProfile); | ||
147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
148 | void export2File( QString fileName ); | 149 | void export2File( QString fileName ); |
149 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | 150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); |
150 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
151 | void setUntagged( bool setNonSyncTagged = false ); | 152 | void setUntagged( bool setNonSyncTagged = false ); |
152 | void removeUntagged(); | 153 | void removeUntagged(); |
153 | void findNewExtIds( QString fileName, QString currentSyncDevice ); | 154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); |
154 | /** | 155 | /** |
155 | Returns a iterator for first entry of address book. | 156 | Returns a iterator for first entry of address book. |
156 | */ | 157 | */ |
157 | Iterator begin(); | 158 | Iterator begin(); |
158 | 159 | ||
159 | /** | 160 | /** |
160 | Returns a const iterator for first entry of address book. | 161 | Returns a const iterator for first entry of address book. |
161 | */ | 162 | */ |
162 | ConstIterator begin() const; | 163 | ConstIterator begin() const; |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Returns a iterator for first entry of address book. | 166 | Returns a iterator for first entry of address book. |
166 | */ | 167 | */ |
167 | Iterator end(); | 168 | Iterator end(); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | Returns a const iterator for first entry of address book. | 171 | Returns a const iterator for first entry of address book. |
171 | */ | 172 | */ |
172 | ConstIterator end() const; | 173 | ConstIterator end() const; |
173 | 174 | ||
174 | /** | 175 | /** |
175 | Removes all entries from address book. | 176 | Removes all entries from address book. |
176 | */ | 177 | */ |
177 | void clear(); | 178 | void clear(); |
178 | 179 | ||
179 | /** | 180 | /** |
180 | Insert an Addressee object into address book. If an object with the same | 181 | Insert an Addressee object into address book. If an object with the same |
181 | unique id already exists in the address book it it replaced by the new | 182 | unique id already exists in the address book it it replaced by the new |
182 | one. If not the new object is appended to the address book. | 183 | one. If not the new object is appended to the address book. |
183 | */ | 184 | */ |
184 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
185 | 186 | ||
186 | /** | 187 | /** |
187 | Removes entry from the address book. | 188 | Removes entry from the address book. |
188 | */ | 189 | */ |
189 | void removeAddressee( const Addressee & ); | 190 | void removeAddressee( const Addressee & ); |
190 | 191 | ||
191 | /** | 192 | /** |
192 | This is like @ref removeAddressee() just above, with the difference that | 193 | This is like @ref removeAddressee() just above, with the difference that |
193 | the first element is a iterator, returned by @ref begin(). | 194 | the first element is a iterator, returned by @ref begin(). |
194 | */ | 195 | */ |
195 | void removeAddressee( const Iterator & ); | 196 | void removeAddressee( const Iterator & ); |
196 | 197 | ||
197 | /** | 198 | /** |
198 | Find the specified entry in address book. Returns end(), if the entry | 199 | Find the specified entry in address book. Returns end(), if the entry |
199 | couldn't be found. | 200 | couldn't be found. |
200 | */ | 201 | */ |
201 | Iterator find( const Addressee & ); | 202 | Iterator find( const Addressee & ); |
202 | 203 | ||
203 | /** | 204 | /** |
204 | Find the entry specified by an unique id. Returns an empty Addressee | 205 | Find the entry specified by an unique id. Returns an empty Addressee |
205 | object, if the address book does not contain an entry with this id. | 206 | object, if the address book does not contain an entry with this id. |
206 | */ | 207 | */ |
207 | Addressee findByUid( const QString & ); | 208 | Addressee findByUid( const QString & ); |
208 | 209 | ||
209 | 210 | ||
210 | /** | 211 | /** |
211 | Returns a list of all addressees in the address book. This list can | 212 | Returns a list of all addressees in the address book. This list can |
212 | be sorted with @ref KABC::AddresseeList for example. | 213 | be sorted with @ref KABC::AddresseeList for example. |
213 | */ | 214 | */ |
214 | Addressee::List allAddressees(); | 215 | Addressee::List allAddressees(); |
215 | 216 | ||
216 | /** | 217 | /** |
217 | 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 |
218 | an empty list, if no entries could be found. | 219 | an empty list, if no entries could be found. |
219 | */ | 220 | */ |
220 | Addressee::List findByName( const QString & ); | 221 | Addressee::List findByName( const QString & ); |
221 | 222 | ||
222 | /** | 223 | /** |
223 | 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. |
224 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
225 | */ | 226 | */ |
226 | Addressee::List findByEmail( const QString & ); | 227 | Addressee::List findByEmail( const QString & ); |
227 | 228 | ||
228 | /** | 229 | /** |
229 | 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. |
230 | Returns an empty list, if no entries could be found. | 231 | Returns an empty list, if no entries could be found. |
231 | */ | 232 | */ |
232 | Addressee::List findByCategory( const QString & ); | 233 | Addressee::List findByCategory( const QString & ); |
233 | 234 | ||
234 | /** | 235 | /** |
235 | Return a string identifying this addressbook. | 236 | Return a string identifying this addressbook. |
236 | */ | 237 | */ |
237 | virtual QString identifier(); | 238 | virtual QString identifier(); |
238 | 239 | ||
239 | /** | 240 | /** |
240 | Used for debug output. | 241 | Used for debug output. |
241 | */ | 242 | */ |
242 | void dump() const; | 243 | void dump() const; |
243 | 244 | ||
244 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
245 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
246 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
247 | 248 | ||
248 | /** | 249 | /** |
249 | 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 |
250 | with the given field category. | 251 | with the given field category. |
251 | */ | 252 | */ |
252 | Field::List fields( int category = Field::All ); | 253 | Field::List fields( int category = Field::All ); |
253 | 254 | ||
254 | /** | 255 | /** |
255 | Add custom field to address book. | 256 | Add custom field to address book. |
256 | 257 | ||
257 | @param label User visible label of the field. | 258 | @param label User visible label of the field. |
258 | @param category Ored list of field categories. | 259 | @param category Ored list of field categories. |
259 | @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. |
260 | @param app String used as application key for reading and writing | 261 | @param app String used as application key for reading and writing |
261 | the field. | 262 | the field. |
262 | */ | 263 | */ |
263 | bool addCustomField( const QString &label, int category = Field::All, | 264 | bool addCustomField( const QString &label, int category = Field::All, |
264 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
265 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
266 | 267 | ||
267 | 268 | ||
268 | /** | 269 | /** |
269 | Add address book resource. | 270 | Add address book resource. |
270 | */ | 271 | */ |
271 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
272 | 273 | ||
273 | /** | 274 | /** |
274 | Remove address book resource. | 275 | Remove address book resource. |
275 | */ | 276 | */ |
276 | bool removeResource( Resource * ); | 277 | bool removeResource( Resource * ); |
277 | 278 | ||
278 | /** | 279 | /** |
279 | Return pointer list of all resources. | 280 | Return pointer list of all resources. |
280 | */ | 281 | */ |
281 | QPtrList<Resource> resources(); | 282 | QPtrList<Resource> resources(); |
282 | 283 | ||
283 | /** | 284 | /** |
284 | Set the @p ErrorHandler, that is used by @ref error() to | 285 | Set the @p ErrorHandler, that is used by @ref error() to |
285 | provide gui-independend error messages. | 286 | provide gui-independend error messages. |
286 | */ | 287 | */ |
287 | void setErrorHandler( ErrorHandler * ); | 288 | void setErrorHandler( ErrorHandler * ); |
288 | 289 | ||
289 | /** | 290 | /** |
290 | Shows gui independend error messages. | 291 | Shows gui independend error messages. |
291 | */ | 292 | */ |
292 | void error( const QString& ); | 293 | void error( const QString& ); |
293 | 294 | ||
294 | /** | 295 | /** |
295 | Query all resources to clean up their lock files | 296 | Query all resources to clean up their lock files |
296 | */ | 297 | */ |
297 | void cleanUp(); | 298 | void cleanUp(); |
298 | 299 | ||
299 | // sync stuff | 300 | // sync stuff |
300 | //Addressee::List getExternLastSyncAddressees(); | 301 | //Addressee::List getExternLastSyncAddressees(); |
301 | void resetTempSyncStat(); | 302 | void resetTempSyncStat(); |
302 | QStringList uidList(); | 303 | QStringList uidList(); |
303 | void removeSyncAddressees( bool removeDeleted = false ); | 304 | void removeSyncAddressees( bool removeDeleted = false ); |
304 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 305 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
305 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 306 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
306 | bool containsExternalUid( const QString& uid ); | 307 | bool containsExternalUid( const QString& uid ); |
307 | 308 | ||
308 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 309 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
309 | void postExternSync( AddressBook* aBook, const QString& csd ); | 310 | void postExternSync( AddressBook* aBook, const QString& csd ); |
310 | signals: | 311 | signals: |
311 | /** | 312 | /** |
312 | Emitted, when the address book has changed on disk. | 313 | Emitted, when the address book has changed on disk. |
313 | */ | 314 | */ |
314 | void addressBookChanged( AddressBook * ); | 315 | void addressBookChanged( AddressBook * ); |
315 | 316 | ||
316 | /** | 317 | /** |
317 | Emitted, when the address book has been locked for writing. | 318 | Emitted, when the address book has been locked for writing. |
318 | */ | 319 | */ |
319 | void addressBookLocked( AddressBook * ); | 320 | void addressBookLocked( AddressBook * ); |
320 | 321 | ||
321 | /** | 322 | /** |
322 | Emitted, when the address book has been unlocked. | 323 | Emitted, when the address book has been unlocked. |
323 | */ | 324 | */ |
324 | void addressBookUnlocked( AddressBook * ); | 325 | void addressBookUnlocked( AddressBook * ); |
325 | 326 | ||
326 | protected: | 327 | protected: |
327 | void deleteRemovedAddressees(); | 328 | void deleteRemovedAddressees(); |
328 | void setStandardResource( Resource * ); | 329 | void setStandardResource( Resource * ); |
329 | Resource *standardResource(); | 330 | Resource *standardResource(); |
330 | KRES::Manager<Resource> *resourceManager(); | 331 | KRES::Manager<Resource> *resourceManager(); |
331 | 332 | ||
332 | void init(const QString &config, const QString &family); | 333 | void init(const QString &config, const QString &family); |
333 | 334 | ||
334 | private: | 335 | private: |
335 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 336 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
336 | 337 | ||
337 | 338 | ||
338 | struct AddressBookData; | 339 | struct AddressBookData; |
339 | AddressBookData *d; | 340 | AddressBookData *d; |
340 | bool blockLSEchange; | 341 | bool blockLSEchange; |
341 | }; | 342 | }; |
342 | 343 | ||
343 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 344 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
344 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 345 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
345 | 346 | ||
346 | } | 347 | } |
347 | 348 | ||
348 | #endif | 349 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 40877ef..a660a9d 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -44,1025 +44,1028 @@ using namespace KABC; | |||
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 286 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 287 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | 302 | ||
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 312 | (*it).setType( ( *phoneItAD ).type() ); |
313 | (*it).setNumber( ( *phoneItAD ).number() ); | 313 | (*it).setNumber( ( *phoneItAD ).number() ); |
314 | break; | 314 | break; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | if ( isSubSet && ! found ) | 317 | if ( isSubSet && ! found ) |
318 | mData->phoneNumbers.append( *phoneItAD ); | 318 | mData->phoneNumbers.append( *phoneItAD ); |
319 | } | 319 | } |
320 | if ( isSubSet ) { | 320 | if ( isSubSet ) { |
321 | // ************* emails; | 321 | // ************* emails; |
322 | t = mData->emails; | 322 | t = mData->emails; |
323 | tAD = ad.mData->emails; | 323 | tAD = ad.mData->emails; |
324 | for ( iii = 0; iii < tAD.count(); ++iii) | 324 | for ( iii = 0; iii < tAD.count(); ++iii) |
325 | if ( !t.contains(tAD[iii] ) ) | 325 | if ( !t.contains(tAD[iii] ) ) |
326 | mData->emails.append( tAD[iii] ); | 326 | mData->emails.append( tAD[iii] ); |
327 | } | 327 | } |
328 | 328 | ||
329 | // ************* categories; | 329 | // ************* categories; |
330 | t = mData->categories; | 330 | t = mData->categories; |
331 | tAD = ad.mData->categories; | 331 | tAD = ad.mData->categories; |
332 | for ( iii = 0; iii < tAD.count(); ++iii) | 332 | for ( iii = 0; iii < tAD.count(); ++iii) |
333 | if ( !t.contains(tAD[iii] ) ) | 333 | if ( !t.contains(tAD[iii] ) ) |
334 | mData->categories.append( tAD[iii] ); | 334 | mData->categories.append( tAD[iii] ); |
335 | QStringList::ConstIterator it; | 335 | QStringList::ConstIterator it; |
336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
337 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 337 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
338 | bool found = false; | 338 | bool found = false; |
339 | QStringList::ConstIterator itL; | 339 | QStringList::ConstIterator itL; |
340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
341 | if ( (*itL).startsWith( qualifiedName ) ) { | 341 | if ( (*itL).startsWith( qualifiedName ) ) { |
342 | found = true; | 342 | found = true; |
343 | break; | 343 | break; |
344 | } | 344 | } |
345 | } | 345 | } |
346 | if ( ! found ) { | 346 | if ( ! found ) { |
347 | mData->custom.append( *it ); | 347 | mData->custom.append( *it ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
352 | if ( !mData->sound.isIntern() ) { | 352 | if ( !mData->sound.isIntern() ) { |
353 | if ( mData->sound.url().isEmpty() ) { | 353 | if ( mData->sound.url().isEmpty() ) { |
354 | mData->sound = ad.mData->sound; | 354 | mData->sound = ad.mData->sound; |
355 | } | 355 | } |
356 | } | 356 | } |
357 | if ( !mData->agent.isIntern() ) { | 357 | if ( !mData->agent.isIntern() ) { |
358 | if ( mData->agent.url().isEmpty() ) { | 358 | if ( mData->agent.url().isEmpty() ) { |
359 | mData->agent = ad.mData->agent; | 359 | mData->agent = ad.mData->agent; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | { | 362 | { |
363 | Key::List::Iterator itA; | 363 | Key::List::Iterator itA; |
364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
365 | bool found = false; | 365 | bool found = false; |
366 | Key::List::Iterator it; | 366 | Key::List::Iterator it; |
367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
368 | if ( (*it) == (*itA)) { | 368 | if ( (*it) == (*itA)) { |
369 | found = true; | 369 | found = true; |
370 | break; | 370 | break; |
371 | 371 | ||
372 | } | 372 | } |
373 | } | 373 | } |
374 | if ( ! found ) { | 374 | if ( ! found ) { |
375 | mData->keys.append( *itA ); | 375 | mData->keys.append( *itA ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | } | 378 | } |
379 | KABC::Address::List::Iterator addressIterA; | 379 | KABC::Address::List::Iterator addressIterA; |
380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
381 | bool found = false; | 381 | bool found = false; |
382 | KABC::Address::List::Iterator addressIter; | 382 | KABC::Address::List::Iterator addressIter; |
383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
384 | ++addressIter ) { | 384 | ++addressIter ) { |
385 | if ( (*addressIter) == (*addressIterA)) { | 385 | if ( (*addressIter) == (*addressIterA)) { |
386 | found = true; | 386 | found = true; |
387 | (*addressIter).setType( (*addressIterA).type() ); | 387 | (*addressIter).setType( (*addressIterA).type() ); |
388 | break; | 388 | break; |
389 | } | 389 | } |
390 | 390 | ||
391 | } | 391 | } |
392 | if ( isSubSet && ! found ) { | 392 | if ( isSubSet && ! found ) { |
393 | mData->addresses.append( *addressIterA ); | 393 | mData->addresses.append( *addressIterA ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | //qDebug("merge contact %s ", ad.uid().latin1()); | 396 | //qDebug("merge contact %s ", ad.uid().latin1()); |
397 | setUid( ad.uid() ); | 397 | setUid( ad.uid() ); |
398 | setRevision( ad.revision() ); | 398 | setRevision( ad.revision() ); |
399 | } | 399 | } |
400 | 400 | ||
401 | bool Addressee::removeVoice() | 401 | bool Addressee::removeVoice() |
402 | { | 402 | { |
403 | PhoneNumber::List phoneN = phoneNumbers(); | 403 | PhoneNumber::List phoneN = phoneNumbers(); |
404 | PhoneNumber::List::Iterator phoneIt; | 404 | PhoneNumber::List::Iterator phoneIt; |
405 | bool found = false; | 405 | bool found = false; |
406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
410 | insertPhoneNumber( (*phoneIt) ); | 410 | insertPhoneNumber( (*phoneIt) ); |
411 | found = true; | 411 | found = true; |
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | } | 415 | } |
416 | return found; | 416 | return found; |
417 | } | 417 | } |
418 | 418 | ||
419 | bool Addressee::containsAdr(const Addressee& ad ) | 419 | bool Addressee::containsAdr(const Addressee& ad ) |
420 | { | 420 | { |
421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
428 | 428 | ||
429 | // compare phone numbers | 429 | // compare phone numbers |
430 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 430 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
431 | PhoneNumber::List::Iterator phoneIt; | 431 | PhoneNumber::List::Iterator phoneIt; |
432 | bool found = false; | 432 | bool found = false; |
433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
434 | bool found = false; | 434 | bool found = false; |
435 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 435 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
436 | PhoneNumber::List::Iterator phoneItL; | 436 | PhoneNumber::List::Iterator phoneItL; |
437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
439 | found = true; | 439 | found = true; |
440 | break; | 440 | break; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | if ( ! found ) | 443 | if ( ! found ) |
444 | return false; | 444 | return false; |
445 | } | 445 | } |
446 | return true; | 446 | return true; |
447 | 447 | ||
448 | } | 448 | } |
449 | void Addressee::simplifyAddresses() | 449 | void Addressee::simplifyAddresses() |
450 | { | 450 | { |
451 | 451 | ||
452 | 452 | ||
453 | Address::List list; | 453 | Address::List list; |
454 | Address::List::Iterator it; | 454 | Address::List::Iterator it; |
455 | Address::List::Iterator it2; | 455 | Address::List::Iterator it2; |
456 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 456 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
457 | it2 = it; | 457 | it2 = it; |
458 | ++it2; | 458 | ++it2; |
459 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 459 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
460 | if ( (*it) == (*it2) ) { | 460 | if ( (*it) == (*it2) ) { |
461 | list.append( *it ); | 461 | list.append( *it ); |
462 | break; | 462 | break; |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | for( it = list.begin(); it != list.end(); ++it ) { | 466 | for( it = list.begin(); it != list.end(); ++it ) { |
467 | removeAddress( (*it) ); | 467 | removeAddress( (*it) ); |
468 | } | 468 | } |
469 | 469 | ||
470 | list.clear(); | 470 | list.clear(); |
471 | int max = 2; | 471 | int max = 2; |
472 | if ( mData->url.isValid() ) | 472 | if ( mData->url.isValid() ) |
473 | max = 1; | 473 | max = 1; |
474 | if ( mData->addresses.count() <= max ) return ; | 474 | if ( mData->addresses.count() <= max ) return ; |
475 | int count = 0; | 475 | int count = 0; |
476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
477 | if ( count >= max ) | 477 | if ( count >= max ) |
478 | list.append( *it ); | 478 | list.append( *it ); |
479 | ++count; | 479 | ++count; |
480 | } | 480 | } |
481 | for( it = list.begin(); it != list.end(); ++it ) { | 481 | for( it = list.begin(); it != list.end(); ++it ) { |
482 | removeAddress( (*it) ); | 482 | removeAddress( (*it) ); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | // removes all emails but the first | 486 | // removes all emails but the first |
487 | // needed by phone sync | 487 | // needed by phone sync |
488 | void Addressee::simplifyEmails() | 488 | void Addressee::simplifyEmails() |
489 | { | 489 | { |
490 | if ( mData->emails.count() == 0 ) return ; | 490 | if ( mData->emails.count() == 0 ) return ; |
491 | QString email = mData->emails.first(); | 491 | QString email = mData->emails.first(); |
492 | detach(); | 492 | detach(); |
493 | mData->emails.clear(); | 493 | mData->emails.clear(); |
494 | mData->emails.append( email ); | 494 | mData->emails.append( email ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void Addressee::simplifyPhoneNumbers() | 497 | void Addressee::simplifyPhoneNumbers() |
498 | { | 498 | { |
499 | int max = 4; | 499 | int max = 4; |
500 | int inList = mData->phoneNumbers.count(); | 500 | int inList = mData->phoneNumbers.count(); |
501 | KABC::PhoneNumber::List removeNumbers; | 501 | KABC::PhoneNumber::List removeNumbers; |
502 | KABC::PhoneNumber::List::Iterator phoneIter; | 502 | KABC::PhoneNumber::List::Iterator phoneIter; |
503 | if ( inList > max ) { | 503 | if ( inList > max ) { |
504 | // delete non-preferred numbers | 504 | // delete non-preferred numbers |
505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
506 | ++phoneIter ) { | 506 | ++phoneIter ) { |
507 | if ( inList > max ) { | 507 | if ( inList > max ) { |
508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
509 | removeNumbers.append( ( *phoneIter ) ); | 509 | removeNumbers.append( ( *phoneIter ) ); |
510 | --inList; | 510 | --inList; |
511 | } | 511 | } |
512 | } else | 512 | } else |
513 | break; | 513 | break; |
514 | } | 514 | } |
515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
516 | ++phoneIter ) { | 516 | ++phoneIter ) { |
517 | removePhoneNumber(( *phoneIter )); | 517 | removePhoneNumber(( *phoneIter )); |
518 | } | 518 | } |
519 | // delete preferred numbers | 519 | // delete preferred numbers |
520 | if ( inList > max ) { | 520 | if ( inList > max ) { |
521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
522 | ++phoneIter ) { | 522 | ++phoneIter ) { |
523 | if ( inList > max ) { | 523 | if ( inList > max ) { |
524 | removeNumbers.append( ( *phoneIter ) ); | 524 | removeNumbers.append( ( *phoneIter ) ); |
525 | --inList; | 525 | --inList; |
526 | } else | 526 | } else |
527 | break; | 527 | break; |
528 | } | 528 | } |
529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
530 | ++phoneIter ) { | 530 | ++phoneIter ) { |
531 | removePhoneNumber(( *phoneIter )); | 531 | removePhoneNumber(( *phoneIter )); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | } | 534 | } |
535 | // remove non-numeric characters | 535 | // remove non-numeric characters |
536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
537 | ++phoneIter ) { | 537 | ++phoneIter ) { |
538 | if ( ! ( *phoneIter ).simplifyNumber() ) | 538 | if ( ! ( *phoneIter ).simplifyNumber() ) |
539 | removeNumbers.append( ( *phoneIter ) ); | 539 | removeNumbers.append( ( *phoneIter ) ); |
540 | } | 540 | } |
541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
542 | ++phoneIter ) { | 542 | ++phoneIter ) { |
543 | removePhoneNumber(( *phoneIter )); | 543 | removePhoneNumber(( *phoneIter )); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | void Addressee::simplifyPhoneNumberTypes() | 546 | void Addressee::simplifyPhoneNumberTypes() |
547 | { | 547 | { |
548 | KABC::PhoneNumber::List::Iterator phoneIter; | 548 | KABC::PhoneNumber::List::Iterator phoneIter; |
549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
550 | ++phoneIter ) | 550 | ++phoneIter ) |
551 | ( *phoneIter ).simplifyType(); | 551 | ( *phoneIter ).simplifyType(); |
552 | } | 552 | } |
553 | void Addressee::removeID(const QString &prof) | 553 | void Addressee::removeID(const QString &prof) |
554 | { | 554 | { |
555 | detach(); | 555 | detach(); |
556 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 556 | if ( prof.isEmpty() ) |
557 | mData->mExternalId = ":"; | ||
558 | else | ||
559 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | ||
557 | 560 | ||
558 | } | 561 | } |
559 | void Addressee::setID( const QString & prof , const QString & id ) | 562 | void Addressee::setID( const QString & prof , const QString & id ) |
560 | { | 563 | { |
561 | detach(); | 564 | detach(); |
562 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 565 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
563 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 566 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
564 | } | 567 | } |
565 | void Addressee::setTempSyncStat( int id ) | 568 | void Addressee::setTempSyncStat( int id ) |
566 | { | 569 | { |
567 | if ( mData->mTempSyncStat == id ) return; | 570 | if ( mData->mTempSyncStat == id ) return; |
568 | detach(); | 571 | detach(); |
569 | mData->mTempSyncStat = id; | 572 | mData->mTempSyncStat = id; |
570 | } | 573 | } |
571 | int Addressee::tempSyncStat() const | 574 | int Addressee::tempSyncStat() const |
572 | { | 575 | { |
573 | return mData->mTempSyncStat; | 576 | return mData->mTempSyncStat; |
574 | } | 577 | } |
575 | 578 | ||
576 | QString Addressee::getID( const QString & prof) | 579 | QString Addressee::getID( const QString & prof) |
577 | { | 580 | { |
578 | return KIdManager::getId ( mData->mExternalId, prof ); | 581 | return KIdManager::getId ( mData->mExternalId, prof ); |
579 | } | 582 | } |
580 | 583 | ||
581 | void Addressee::setCsum( const QString & prof , const QString & id ) | 584 | void Addressee::setCsum( const QString & prof , const QString & id ) |
582 | { | 585 | { |
583 | detach(); | 586 | detach(); |
584 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 587 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
585 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 588 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
586 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 589 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
587 | } | 590 | } |
588 | 591 | ||
589 | QString Addressee::getCsum( const QString & prof) | 592 | QString Addressee::getCsum( const QString & prof) |
590 | { | 593 | { |
591 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 594 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
592 | } | 595 | } |
593 | 596 | ||
594 | void Addressee::setIDStr( const QString & s ) | 597 | void Addressee::setIDStr( const QString & s ) |
595 | { | 598 | { |
596 | detach(); | 599 | detach(); |
597 | mData->mExternalId = s; | 600 | mData->mExternalId = s; |
598 | } | 601 | } |
599 | 602 | ||
600 | QString Addressee::IDStr() const | 603 | QString Addressee::IDStr() const |
601 | { | 604 | { |
602 | return mData->mExternalId; | 605 | return mData->mExternalId; |
603 | } | 606 | } |
604 | 607 | ||
605 | void Addressee::setExternalUID( const QString &id ) | 608 | void Addressee::setExternalUID( const QString &id ) |
606 | { | 609 | { |
607 | if ( id == mData->externalUID ) return; | 610 | if ( id == mData->externalUID ) return; |
608 | detach(); | 611 | detach(); |
609 | mData->empty = false; | 612 | mData->empty = false; |
610 | mData->externalUID = id; | 613 | mData->externalUID = id; |
611 | } | 614 | } |
612 | 615 | ||
613 | QString Addressee::externalUID() const | 616 | QString Addressee::externalUID() const |
614 | { | 617 | { |
615 | return mData->externalUID; | 618 | return mData->externalUID; |
616 | } | 619 | } |
617 | void Addressee::setOriginalExternalUID( const QString &id ) | 620 | void Addressee::setOriginalExternalUID( const QString &id ) |
618 | { | 621 | { |
619 | if ( id == mData->originalExternalUID ) return; | 622 | if ( id == mData->originalExternalUID ) return; |
620 | detach(); | 623 | detach(); |
621 | mData->empty = false; | 624 | mData->empty = false; |
622 | //qDebug("*******Set orig uid %s ", id.latin1()); | 625 | //qDebug("*******Set orig uid %s ", id.latin1()); |
623 | mData->originalExternalUID = id; | 626 | mData->originalExternalUID = id; |
624 | } | 627 | } |
625 | 628 | ||
626 | QString Addressee::originalExternalUID() const | 629 | QString Addressee::originalExternalUID() const |
627 | { | 630 | { |
628 | return mData->originalExternalUID; | 631 | return mData->originalExternalUID; |
629 | } | 632 | } |
630 | 633 | ||
631 | void Addressee::setUid( const QString &id ) | 634 | void Addressee::setUid( const QString &id ) |
632 | { | 635 | { |
633 | if ( id == mData->uid ) return; | 636 | if ( id == mData->uid ) return; |
634 | detach(); | 637 | detach(); |
635 | //qDebug("****setuid %s ", id.latin1()); | 638 | //qDebug("****setuid %s ", id.latin1()); |
636 | mData->empty = false; | 639 | mData->empty = false; |
637 | mData->uid = id; | 640 | mData->uid = id; |
638 | } | 641 | } |
639 | 642 | ||
640 | QString Addressee::uid() const | 643 | QString Addressee::uid() const |
641 | { | 644 | { |
642 | if ( mData->uid.isEmpty() ) | 645 | if ( mData->uid.isEmpty() ) |
643 | mData->uid = KApplication::randomString( 10 ); | 646 | mData->uid = KApplication::randomString( 10 ); |
644 | 647 | ||
645 | return mData->uid; | 648 | return mData->uid; |
646 | } | 649 | } |
647 | 650 | ||
648 | QString Addressee::uidLabel() | 651 | QString Addressee::uidLabel() |
649 | { | 652 | { |
650 | return i18n("Unique Identifier"); | 653 | return i18n("Unique Identifier"); |
651 | } | 654 | } |
652 | 655 | ||
653 | void Addressee::setName( const QString &name ) | 656 | void Addressee::setName( const QString &name ) |
654 | { | 657 | { |
655 | if ( name == mData->name ) return; | 658 | if ( name == mData->name ) return; |
656 | detach(); | 659 | detach(); |
657 | mData->empty = false; | 660 | mData->empty = false; |
658 | mData->name = name; | 661 | mData->name = name; |
659 | } | 662 | } |
660 | 663 | ||
661 | QString Addressee::name() const | 664 | QString Addressee::name() const |
662 | { | 665 | { |
663 | return mData->name; | 666 | return mData->name; |
664 | } | 667 | } |
665 | 668 | ||
666 | QString Addressee::nameLabel() | 669 | QString Addressee::nameLabel() |
667 | { | 670 | { |
668 | return i18n("Name"); | 671 | return i18n("Name"); |
669 | } | 672 | } |
670 | 673 | ||
671 | 674 | ||
672 | void Addressee::setFormattedName( const QString &formattedName ) | 675 | void Addressee::setFormattedName( const QString &formattedName ) |
673 | { | 676 | { |
674 | if ( formattedName == mData->formattedName ) return; | 677 | if ( formattedName == mData->formattedName ) return; |
675 | detach(); | 678 | detach(); |
676 | mData->empty = false; | 679 | mData->empty = false; |
677 | mData->formattedName = formattedName; | 680 | mData->formattedName = formattedName; |
678 | } | 681 | } |
679 | 682 | ||
680 | QString Addressee::formattedName() const | 683 | QString Addressee::formattedName() const |
681 | { | 684 | { |
682 | return mData->formattedName; | 685 | return mData->formattedName; |
683 | } | 686 | } |
684 | 687 | ||
685 | QString Addressee::formattedNameLabel() | 688 | QString Addressee::formattedNameLabel() |
686 | { | 689 | { |
687 | return i18n("Formatted Name"); | 690 | return i18n("Formatted Name"); |
688 | } | 691 | } |
689 | 692 | ||
690 | 693 | ||
691 | void Addressee::setFamilyName( const QString &familyName ) | 694 | void Addressee::setFamilyName( const QString &familyName ) |
692 | { | 695 | { |
693 | if ( familyName == mData->familyName ) return; | 696 | if ( familyName == mData->familyName ) return; |
694 | detach(); | 697 | detach(); |
695 | mData->empty = false; | 698 | mData->empty = false; |
696 | mData->familyName = familyName; | 699 | mData->familyName = familyName; |
697 | } | 700 | } |
698 | 701 | ||
699 | QString Addressee::familyName() const | 702 | QString Addressee::familyName() const |
700 | { | 703 | { |
701 | return mData->familyName; | 704 | return mData->familyName; |
702 | } | 705 | } |
703 | 706 | ||
704 | QString Addressee::familyNameLabel() | 707 | QString Addressee::familyNameLabel() |
705 | { | 708 | { |
706 | return i18n("Family Name"); | 709 | return i18n("Family Name"); |
707 | } | 710 | } |
708 | 711 | ||
709 | 712 | ||
710 | void Addressee::setGivenName( const QString &givenName ) | 713 | void Addressee::setGivenName( const QString &givenName ) |
711 | { | 714 | { |
712 | if ( givenName == mData->givenName ) return; | 715 | if ( givenName == mData->givenName ) return; |
713 | detach(); | 716 | detach(); |
714 | mData->empty = false; | 717 | mData->empty = false; |
715 | mData->givenName = givenName; | 718 | mData->givenName = givenName; |
716 | } | 719 | } |
717 | 720 | ||
718 | QString Addressee::givenName() const | 721 | QString Addressee::givenName() const |
719 | { | 722 | { |
720 | return mData->givenName; | 723 | return mData->givenName; |
721 | } | 724 | } |
722 | 725 | ||
723 | QString Addressee::givenNameLabel() | 726 | QString Addressee::givenNameLabel() |
724 | { | 727 | { |
725 | return i18n("Given Name"); | 728 | return i18n("Given Name"); |
726 | } | 729 | } |
727 | 730 | ||
728 | 731 | ||
729 | void Addressee::setAdditionalName( const QString &additionalName ) | 732 | void Addressee::setAdditionalName( const QString &additionalName ) |
730 | { | 733 | { |
731 | if ( additionalName == mData->additionalName ) return; | 734 | if ( additionalName == mData->additionalName ) return; |
732 | detach(); | 735 | detach(); |
733 | mData->empty = false; | 736 | mData->empty = false; |
734 | mData->additionalName = additionalName; | 737 | mData->additionalName = additionalName; |
735 | } | 738 | } |
736 | 739 | ||
737 | QString Addressee::additionalName() const | 740 | QString Addressee::additionalName() const |
738 | { | 741 | { |
739 | return mData->additionalName; | 742 | return mData->additionalName; |
740 | } | 743 | } |
741 | 744 | ||
742 | QString Addressee::additionalNameLabel() | 745 | QString Addressee::additionalNameLabel() |
743 | { | 746 | { |
744 | return i18n("Additional Names"); | 747 | return i18n("Additional Names"); |
745 | } | 748 | } |
746 | 749 | ||
747 | 750 | ||
748 | void Addressee::setPrefix( const QString &prefix ) | 751 | void Addressee::setPrefix( const QString &prefix ) |
749 | { | 752 | { |
750 | if ( prefix == mData->prefix ) return; | 753 | if ( prefix == mData->prefix ) return; |
751 | detach(); | 754 | detach(); |
752 | mData->empty = false; | 755 | mData->empty = false; |
753 | mData->prefix = prefix; | 756 | mData->prefix = prefix; |
754 | } | 757 | } |
755 | 758 | ||
756 | QString Addressee::prefix() const | 759 | QString Addressee::prefix() const |
757 | { | 760 | { |
758 | return mData->prefix; | 761 | return mData->prefix; |
759 | } | 762 | } |
760 | 763 | ||
761 | QString Addressee::prefixLabel() | 764 | QString Addressee::prefixLabel() |
762 | { | 765 | { |
763 | return i18n("Honorific Prefixes"); | 766 | return i18n("Honorific Prefixes"); |
764 | } | 767 | } |
765 | 768 | ||
766 | 769 | ||
767 | void Addressee::setSuffix( const QString &suffix ) | 770 | void Addressee::setSuffix( const QString &suffix ) |
768 | { | 771 | { |
769 | if ( suffix == mData->suffix ) return; | 772 | if ( suffix == mData->suffix ) return; |
770 | detach(); | 773 | detach(); |
771 | mData->empty = false; | 774 | mData->empty = false; |
772 | mData->suffix = suffix; | 775 | mData->suffix = suffix; |
773 | } | 776 | } |
774 | 777 | ||
775 | QString Addressee::suffix() const | 778 | QString Addressee::suffix() const |
776 | { | 779 | { |
777 | return mData->suffix; | 780 | return mData->suffix; |
778 | } | 781 | } |
779 | 782 | ||
780 | QString Addressee::suffixLabel() | 783 | QString Addressee::suffixLabel() |
781 | { | 784 | { |
782 | return i18n("Honorific Suffixes"); | 785 | return i18n("Honorific Suffixes"); |
783 | } | 786 | } |
784 | 787 | ||
785 | 788 | ||
786 | void Addressee::setNickName( const QString &nickName ) | 789 | void Addressee::setNickName( const QString &nickName ) |
787 | { | 790 | { |
788 | if ( nickName == mData->nickName ) return; | 791 | if ( nickName == mData->nickName ) return; |
789 | detach(); | 792 | detach(); |
790 | mData->empty = false; | 793 | mData->empty = false; |
791 | mData->nickName = nickName; | 794 | mData->nickName = nickName; |
792 | } | 795 | } |
793 | 796 | ||
794 | QString Addressee::nickName() const | 797 | QString Addressee::nickName() const |
795 | { | 798 | { |
796 | return mData->nickName; | 799 | return mData->nickName; |
797 | } | 800 | } |
798 | 801 | ||
799 | QString Addressee::nickNameLabel() | 802 | QString Addressee::nickNameLabel() |
800 | { | 803 | { |
801 | return i18n("Nick Name"); | 804 | return i18n("Nick Name"); |
802 | } | 805 | } |
803 | 806 | ||
804 | 807 | ||
805 | void Addressee::setBirthday( const QDateTime &birthday ) | 808 | void Addressee::setBirthday( const QDateTime &birthday ) |
806 | { | 809 | { |
807 | if ( birthday == mData->birthday ) return; | 810 | if ( birthday == mData->birthday ) return; |
808 | detach(); | 811 | detach(); |
809 | mData->empty = false; | 812 | mData->empty = false; |
810 | mData->birthday = birthday; | 813 | mData->birthday = birthday; |
811 | } | 814 | } |
812 | 815 | ||
813 | QDateTime Addressee::birthday() const | 816 | QDateTime Addressee::birthday() const |
814 | { | 817 | { |
815 | return mData->birthday; | 818 | return mData->birthday; |
816 | } | 819 | } |
817 | 820 | ||
818 | QString Addressee::birthdayLabel() | 821 | QString Addressee::birthdayLabel() |
819 | { | 822 | { |
820 | return i18n("Birthday"); | 823 | return i18n("Birthday"); |
821 | } | 824 | } |
822 | 825 | ||
823 | 826 | ||
824 | QString Addressee::homeAddressStreetLabel() | 827 | QString Addressee::homeAddressStreetLabel() |
825 | { | 828 | { |
826 | return i18n("Home Address Street"); | 829 | return i18n("Home Address Street"); |
827 | } | 830 | } |
828 | 831 | ||
829 | 832 | ||
830 | QString Addressee::homeAddressLocalityLabel() | 833 | QString Addressee::homeAddressLocalityLabel() |
831 | { | 834 | { |
832 | return i18n("Home Address Locality"); | 835 | return i18n("Home Address Locality"); |
833 | } | 836 | } |
834 | 837 | ||
835 | 838 | ||
836 | QString Addressee::homeAddressRegionLabel() | 839 | QString Addressee::homeAddressRegionLabel() |
837 | { | 840 | { |
838 | return i18n("Home Address Region"); | 841 | return i18n("Home Address Region"); |
839 | } | 842 | } |
840 | 843 | ||
841 | 844 | ||
842 | QString Addressee::homeAddressPostalCodeLabel() | 845 | QString Addressee::homeAddressPostalCodeLabel() |
843 | { | 846 | { |
844 | return i18n("Home Address Postal Code"); | 847 | return i18n("Home Address Postal Code"); |
845 | } | 848 | } |
846 | 849 | ||
847 | 850 | ||
848 | QString Addressee::homeAddressCountryLabel() | 851 | QString Addressee::homeAddressCountryLabel() |
849 | { | 852 | { |
850 | return i18n("Home Address Country"); | 853 | return i18n("Home Address Country"); |
851 | } | 854 | } |
852 | 855 | ||
853 | 856 | ||
854 | QString Addressee::homeAddressLabelLabel() | 857 | QString Addressee::homeAddressLabelLabel() |
855 | { | 858 | { |
856 | return i18n("Home Address Label"); | 859 | return i18n("Home Address Label"); |
857 | } | 860 | } |
858 | 861 | ||
859 | 862 | ||
860 | QString Addressee::businessAddressStreetLabel() | 863 | QString Addressee::businessAddressStreetLabel() |
861 | { | 864 | { |
862 | return i18n("Business Address Street"); | 865 | return i18n("Business Address Street"); |
863 | } | 866 | } |
864 | 867 | ||
865 | 868 | ||
866 | QString Addressee::businessAddressLocalityLabel() | 869 | QString Addressee::businessAddressLocalityLabel() |
867 | { | 870 | { |
868 | return i18n("Business Address Locality"); | 871 | return i18n("Business Address Locality"); |
869 | } | 872 | } |
870 | 873 | ||
871 | 874 | ||
872 | QString Addressee::businessAddressRegionLabel() | 875 | QString Addressee::businessAddressRegionLabel() |
873 | { | 876 | { |
874 | return i18n("Business Address Region"); | 877 | return i18n("Business Address Region"); |
875 | } | 878 | } |
876 | 879 | ||
877 | 880 | ||
878 | QString Addressee::businessAddressPostalCodeLabel() | 881 | QString Addressee::businessAddressPostalCodeLabel() |
879 | { | 882 | { |
880 | return i18n("Business Address Postal Code"); | 883 | return i18n("Business Address Postal Code"); |
881 | } | 884 | } |
882 | 885 | ||
883 | 886 | ||
884 | QString Addressee::businessAddressCountryLabel() | 887 | QString Addressee::businessAddressCountryLabel() |
885 | { | 888 | { |
886 | return i18n("Business Address Country"); | 889 | return i18n("Business Address Country"); |
887 | } | 890 | } |
888 | 891 | ||
889 | 892 | ||
890 | QString Addressee::businessAddressLabelLabel() | 893 | QString Addressee::businessAddressLabelLabel() |
891 | { | 894 | { |
892 | return i18n("Business Address Label"); | 895 | return i18n("Business Address Label"); |
893 | } | 896 | } |
894 | 897 | ||
895 | 898 | ||
896 | QString Addressee::homePhoneLabel() | 899 | QString Addressee::homePhoneLabel() |
897 | { | 900 | { |
898 | return i18n("Home Phone"); | 901 | return i18n("Home Phone"); |
899 | } | 902 | } |
900 | 903 | ||
901 | 904 | ||
902 | QString Addressee::businessPhoneLabel() | 905 | QString Addressee::businessPhoneLabel() |
903 | { | 906 | { |
904 | return i18n("Business Phone"); | 907 | return i18n("Business Phone"); |
905 | } | 908 | } |
906 | 909 | ||
907 | 910 | ||
908 | QString Addressee::mobilePhoneLabel() | 911 | QString Addressee::mobilePhoneLabel() |
909 | { | 912 | { |
910 | return i18n("Mobile Phone"); | 913 | return i18n("Mobile Phone"); |
911 | } | 914 | } |
912 | 915 | ||
913 | 916 | ||
914 | QString Addressee::homeFaxLabel() | 917 | QString Addressee::homeFaxLabel() |
915 | { | 918 | { |
916 | return i18n("Home Fax"); | 919 | return i18n("Home Fax"); |
917 | } | 920 | } |
918 | 921 | ||
919 | 922 | ||
920 | QString Addressee::businessFaxLabel() | 923 | QString Addressee::businessFaxLabel() |
921 | { | 924 | { |
922 | return i18n("Business Fax"); | 925 | return i18n("Business Fax"); |
923 | } | 926 | } |
924 | 927 | ||
925 | 928 | ||
926 | QString Addressee::carPhoneLabel() | 929 | QString Addressee::carPhoneLabel() |
927 | { | 930 | { |
928 | return i18n("Car Phone"); | 931 | return i18n("Car Phone"); |
929 | } | 932 | } |
930 | 933 | ||
931 | 934 | ||
932 | QString Addressee::isdnLabel() | 935 | QString Addressee::isdnLabel() |
933 | { | 936 | { |
934 | return i18n("ISDN"); | 937 | return i18n("ISDN"); |
935 | } | 938 | } |
936 | 939 | ||
937 | 940 | ||
938 | QString Addressee::pagerLabel() | 941 | QString Addressee::pagerLabel() |
939 | { | 942 | { |
940 | return i18n("Pager"); | 943 | return i18n("Pager"); |
941 | } | 944 | } |
942 | 945 | ||
943 | QString Addressee::sipLabel() | 946 | QString Addressee::sipLabel() |
944 | { | 947 | { |
945 | return i18n("SIP"); | 948 | return i18n("SIP"); |
946 | } | 949 | } |
947 | 950 | ||
948 | QString Addressee::emailLabel() | 951 | QString Addressee::emailLabel() |
949 | { | 952 | { |
950 | return i18n("Email Address"); | 953 | return i18n("Email Address"); |
951 | } | 954 | } |
952 | 955 | ||
953 | 956 | ||
954 | void Addressee::setMailer( const QString &mailer ) | 957 | void Addressee::setMailer( const QString &mailer ) |
955 | { | 958 | { |
956 | if ( mailer == mData->mailer ) return; | 959 | if ( mailer == mData->mailer ) return; |
957 | detach(); | 960 | detach(); |
958 | mData->empty = false; | 961 | mData->empty = false; |
959 | mData->mailer = mailer; | 962 | mData->mailer = mailer; |
960 | } | 963 | } |
961 | 964 | ||
962 | QString Addressee::mailer() const | 965 | QString Addressee::mailer() const |
963 | { | 966 | { |
964 | return mData->mailer; | 967 | return mData->mailer; |
965 | } | 968 | } |
966 | 969 | ||
967 | QString Addressee::mailerLabel() | 970 | QString Addressee::mailerLabel() |
968 | { | 971 | { |
969 | return i18n("Mail Client"); | 972 | return i18n("Mail Client"); |
970 | } | 973 | } |
971 | 974 | ||
972 | 975 | ||
973 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 976 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
974 | { | 977 | { |
975 | if ( timeZone == mData->timeZone ) return; | 978 | if ( timeZone == mData->timeZone ) return; |
976 | detach(); | 979 | detach(); |
977 | mData->empty = false; | 980 | mData->empty = false; |
978 | mData->timeZone = timeZone; | 981 | mData->timeZone = timeZone; |
979 | } | 982 | } |
980 | 983 | ||
981 | TimeZone Addressee::timeZone() const | 984 | TimeZone Addressee::timeZone() const |
982 | { | 985 | { |
983 | return mData->timeZone; | 986 | return mData->timeZone; |
984 | } | 987 | } |
985 | 988 | ||
986 | QString Addressee::timeZoneLabel() | 989 | QString Addressee::timeZoneLabel() |
987 | { | 990 | { |
988 | return i18n("Time Zone"); | 991 | return i18n("Time Zone"); |
989 | } | 992 | } |
990 | 993 | ||
991 | 994 | ||
992 | void Addressee::setGeo( const Geo &geo ) | 995 | void Addressee::setGeo( const Geo &geo ) |
993 | { | 996 | { |
994 | if ( geo == mData->geo ) return; | 997 | if ( geo == mData->geo ) return; |
995 | detach(); | 998 | detach(); |
996 | mData->empty = false; | 999 | mData->empty = false; |
997 | mData->geo = geo; | 1000 | mData->geo = geo; |
998 | } | 1001 | } |
999 | 1002 | ||
1000 | Geo Addressee::geo() const | 1003 | Geo Addressee::geo() const |
1001 | { | 1004 | { |
1002 | return mData->geo; | 1005 | return mData->geo; |
1003 | } | 1006 | } |
1004 | 1007 | ||
1005 | QString Addressee::geoLabel() | 1008 | QString Addressee::geoLabel() |
1006 | { | 1009 | { |
1007 | return i18n("Geographic Position"); | 1010 | return i18n("Geographic Position"); |
1008 | } | 1011 | } |
1009 | 1012 | ||
1010 | 1013 | ||
1011 | void Addressee::setTitle( const QString &title ) | 1014 | void Addressee::setTitle( const QString &title ) |
1012 | { | 1015 | { |
1013 | if ( title == mData->title ) return; | 1016 | if ( title == mData->title ) return; |
1014 | detach(); | 1017 | detach(); |
1015 | mData->empty = false; | 1018 | mData->empty = false; |
1016 | mData->title = title; | 1019 | mData->title = title; |
1017 | } | 1020 | } |
1018 | 1021 | ||
1019 | QString Addressee::title() const | 1022 | QString Addressee::title() const |
1020 | { | 1023 | { |
1021 | return mData->title; | 1024 | return mData->title; |
1022 | } | 1025 | } |
1023 | 1026 | ||
1024 | QString Addressee::titleLabel() | 1027 | QString Addressee::titleLabel() |
1025 | { | 1028 | { |
1026 | return i18n("Title"); | 1029 | return i18n("Title"); |
1027 | } | 1030 | } |
1028 | 1031 | ||
1029 | 1032 | ||
1030 | void Addressee::setRole( const QString &role ) | 1033 | void Addressee::setRole( const QString &role ) |
1031 | { | 1034 | { |
1032 | if ( role == mData->role ) return; | 1035 | if ( role == mData->role ) return; |
1033 | detach(); | 1036 | detach(); |
1034 | mData->empty = false; | 1037 | mData->empty = false; |
1035 | mData->role = role; | 1038 | mData->role = role; |
1036 | } | 1039 | } |
1037 | 1040 | ||
1038 | QString Addressee::role() const | 1041 | QString Addressee::role() const |
1039 | { | 1042 | { |
1040 | return mData->role; | 1043 | return mData->role; |
1041 | } | 1044 | } |
1042 | 1045 | ||
1043 | QString Addressee::roleLabel() | 1046 | QString Addressee::roleLabel() |
1044 | { | 1047 | { |
1045 | return i18n("Role"); | 1048 | return i18n("Role"); |
1046 | } | 1049 | } |
1047 | 1050 | ||
1048 | 1051 | ||
1049 | void Addressee::setOrganization( const QString &organization ) | 1052 | void Addressee::setOrganization( const QString &organization ) |
1050 | { | 1053 | { |
1051 | if ( organization == mData->organization ) return; | 1054 | if ( organization == mData->organization ) return; |
1052 | detach(); | 1055 | detach(); |
1053 | mData->empty = false; | 1056 | mData->empty = false; |
1054 | mData->organization = organization; | 1057 | mData->organization = organization; |
1055 | } | 1058 | } |
1056 | 1059 | ||
1057 | QString Addressee::organization() const | 1060 | QString Addressee::organization() const |
1058 | { | 1061 | { |
1059 | return mData->organization; | 1062 | return mData->organization; |
1060 | } | 1063 | } |
1061 | 1064 | ||
1062 | QString Addressee::organizationLabel() | 1065 | QString Addressee::organizationLabel() |
1063 | { | 1066 | { |
1064 | return i18n("Organization"); | 1067 | return i18n("Organization"); |
1065 | } | 1068 | } |
1066 | 1069 | ||
1067 | 1070 | ||
1068 | void Addressee::setNote( const QString ¬e ) | 1071 | void Addressee::setNote( const QString ¬e ) |