-rw-r--r-- | kabc/addressbook.cpp | 16 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 17 | ||||
-rw-r--r-- | kabc/addressee.h | 1 |
4 files changed, 31 insertions, 5 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index dc3cda1..bf6d053 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -21,784 +21,792 @@ | |||
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 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | 43 | ||
44 | #include <kglobal.h> | 44 | #include <kglobal.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kmessagebox.h> | 46 | #include <kmessagebox.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | #include <libkcal/syncdefines.h> | 48 | #include <libkcal/syncdefines.h> |
49 | #include "addressbook.h" | 49 | #include "addressbook.h" |
50 | #include "resource.h" | 50 | #include "resource.h" |
51 | #include "vcardconverter.h" | 51 | #include "vcardconverter.h" |
52 | #include "vcardparser/vcardtool.h" | 52 | #include "vcardparser/vcardtool.h" |
53 | 53 | ||
54 | //US #include "addressbook.moc" | 54 | //US #include "addressbook.moc" |
55 | 55 | ||
56 | using namespace KABC; | 56 | using namespace KABC; |
57 | 57 | ||
58 | struct AddressBook::AddressBookData | 58 | struct AddressBook::AddressBookData |
59 | { | 59 | { |
60 | Addressee::List mAddressees; | 60 | Addressee::List mAddressees; |
61 | Addressee::List mRemovedAddressees; | 61 | Addressee::List mRemovedAddressees; |
62 | Field::List mAllFields; | 62 | Field::List mAllFields; |
63 | KConfig *mConfig; | 63 | KConfig *mConfig; |
64 | KRES::Manager<Resource> *mManager; | 64 | KRES::Manager<Resource> *mManager; |
65 | //US ErrorHandler *mErrorHandler; | 65 | //US ErrorHandler *mErrorHandler; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct AddressBook::Iterator::IteratorData | 68 | struct AddressBook::Iterator::IteratorData |
69 | { | 69 | { |
70 | Addressee::List::Iterator mIt; | 70 | Addressee::List::Iterator mIt; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | struct AddressBook::ConstIterator::ConstIteratorData | 73 | struct AddressBook::ConstIterator::ConstIteratorData |
74 | { | 74 | { |
75 | Addressee::List::ConstIterator mIt; | 75 | Addressee::List::ConstIterator mIt; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | AddressBook::Iterator::Iterator() | 78 | AddressBook::Iterator::Iterator() |
79 | { | 79 | { |
80 | d = new IteratorData; | 80 | d = new IteratorData; |
81 | } | 81 | } |
82 | 82 | ||
83 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 83 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
84 | { | 84 | { |
85 | d = new IteratorData; | 85 | d = new IteratorData; |
86 | d->mIt = i.d->mIt; | 86 | d->mIt = i.d->mIt; |
87 | } | 87 | } |
88 | 88 | ||
89 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 89 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
90 | { | 90 | { |
91 | if( this == &i ) return *this; // guard against self assignment | 91 | if( this == &i ) return *this; // guard against self assignment |
92 | delete d; // delete the old data the Iterator was completely constructed before | 92 | delete d; // delete the old data the Iterator was completely constructed before |
93 | d = new IteratorData; | 93 | d = new IteratorData; |
94 | d->mIt = i.d->mIt; | 94 | d->mIt = i.d->mIt; |
95 | return *this; | 95 | return *this; |
96 | } | 96 | } |
97 | 97 | ||
98 | AddressBook::Iterator::~Iterator() | 98 | AddressBook::Iterator::~Iterator() |
99 | { | 99 | { |
100 | delete d; | 100 | delete d; |
101 | } | 101 | } |
102 | 102 | ||
103 | const Addressee &AddressBook::Iterator::operator*() const | 103 | const Addressee &AddressBook::Iterator::operator*() const |
104 | { | 104 | { |
105 | return *(d->mIt); | 105 | return *(d->mIt); |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee &AddressBook::Iterator::operator*() | 108 | Addressee &AddressBook::Iterator::operator*() |
109 | { | 109 | { |
110 | return *(d->mIt); | 110 | return *(d->mIt); |
111 | } | 111 | } |
112 | 112 | ||
113 | Addressee *AddressBook::Iterator::operator->() | 113 | Addressee *AddressBook::Iterator::operator->() |
114 | { | 114 | { |
115 | return &(*(d->mIt)); | 115 | return &(*(d->mIt)); |
116 | } | 116 | } |
117 | 117 | ||
118 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 118 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
119 | { | 119 | { |
120 | (d->mIt)++; | 120 | (d->mIt)++; |
121 | return *this; | 121 | return *this; |
122 | } | 122 | } |
123 | 123 | ||
124 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 124 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
125 | { | 125 | { |
126 | (d->mIt)++; | 126 | (d->mIt)++; |
127 | return *this; | 127 | return *this; |
128 | } | 128 | } |
129 | 129 | ||
130 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 130 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
131 | { | 131 | { |
132 | (d->mIt)--; | 132 | (d->mIt)--; |
133 | return *this; | 133 | return *this; |
134 | } | 134 | } |
135 | 135 | ||
136 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 136 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
137 | { | 137 | { |
138 | (d->mIt)--; | 138 | (d->mIt)--; |
139 | return *this; | 139 | return *this; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
143 | { | 143 | { |
144 | return ( d->mIt == it.d->mIt ); | 144 | return ( d->mIt == it.d->mIt ); |
145 | } | 145 | } |
146 | 146 | ||
147 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 147 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
148 | { | 148 | { |
149 | return ( d->mIt != it.d->mIt ); | 149 | return ( d->mIt != it.d->mIt ); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | AddressBook::ConstIterator::ConstIterator() | 153 | AddressBook::ConstIterator::ConstIterator() |
154 | { | 154 | { |
155 | d = new ConstIteratorData; | 155 | d = new ConstIteratorData; |
156 | } | 156 | } |
157 | 157 | ||
158 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 158 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
159 | { | 159 | { |
160 | d = new ConstIteratorData; | 160 | d = new ConstIteratorData; |
161 | d->mIt = i.d->mIt; | 161 | d->mIt = i.d->mIt; |
162 | } | 162 | } |
163 | 163 | ||
164 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 164 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
165 | { | 165 | { |
166 | if( this == &i ) return *this; // guard for self assignment | 166 | if( this == &i ) return *this; // guard for self assignment |
167 | delete d; // delete the old data because the Iterator was really constructed before | 167 | delete d; // delete the old data because the Iterator was really constructed before |
168 | d = new ConstIteratorData; | 168 | d = new ConstIteratorData; |
169 | d->mIt = i.d->mIt; | 169 | d->mIt = i.d->mIt; |
170 | return *this; | 170 | return *this; |
171 | } | 171 | } |
172 | 172 | ||
173 | AddressBook::ConstIterator::~ConstIterator() | 173 | AddressBook::ConstIterator::~ConstIterator() |
174 | { | 174 | { |
175 | delete d; | 175 | delete d; |
176 | } | 176 | } |
177 | 177 | ||
178 | const Addressee &AddressBook::ConstIterator::operator*() const | 178 | const Addressee &AddressBook::ConstIterator::operator*() const |
179 | { | 179 | { |
180 | return *(d->mIt); | 180 | return *(d->mIt); |
181 | } | 181 | } |
182 | 182 | ||
183 | const Addressee* AddressBook::ConstIterator::operator->() const | 183 | const Addressee* AddressBook::ConstIterator::operator->() const |
184 | { | 184 | { |
185 | return &(*(d->mIt)); | 185 | return &(*(d->mIt)); |
186 | } | 186 | } |
187 | 187 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
189 | { | 189 | { |
190 | (d->mIt)++; | 190 | (d->mIt)++; |
191 | return *this; | 191 | return *this; |
192 | } | 192 | } |
193 | 193 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
195 | { | 195 | { |
196 | (d->mIt)++; | 196 | (d->mIt)++; |
197 | return *this; | 197 | return *this; |
198 | } | 198 | } |
199 | 199 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
201 | { | 201 | { |
202 | (d->mIt)--; | 202 | (d->mIt)--; |
203 | return *this; | 203 | return *this; |
204 | } | 204 | } |
205 | 205 | ||
206 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 206 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
207 | { | 207 | { |
208 | (d->mIt)--; | 208 | (d->mIt)--; |
209 | return *this; | 209 | return *this; |
210 | } | 210 | } |
211 | 211 | ||
212 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
213 | { | 213 | { |
214 | return ( d->mIt == it.d->mIt ); | 214 | return ( d->mIt == it.d->mIt ); |
215 | } | 215 | } |
216 | 216 | ||
217 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 217 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
218 | { | 218 | { |
219 | return ( d->mIt != it.d->mIt ); | 219 | return ( d->mIt != it.d->mIt ); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | AddressBook::AddressBook() | 223 | AddressBook::AddressBook() |
224 | { | 224 | { |
225 | init(0, "contact"); | 225 | init(0, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config ) | 228 | AddressBook::AddressBook( const QString &config ) |
229 | { | 229 | { |
230 | init(config, "contact"); | 230 | init(config, "contact"); |
231 | } | 231 | } |
232 | 232 | ||
233 | AddressBook::AddressBook( const QString &config, const QString &family ) | 233 | AddressBook::AddressBook( const QString &config, const QString &family ) |
234 | { | 234 | { |
235 | init(config, family); | 235 | init(config, family); |
236 | 236 | ||
237 | } | 237 | } |
238 | 238 | ||
239 | // the default family is "contact" | 239 | // the default family is "contact" |
240 | void AddressBook::init(const QString &config, const QString &family ) | 240 | void AddressBook::init(const QString &config, const QString &family ) |
241 | { | 241 | { |
242 | blockLSEchange = false; | 242 | blockLSEchange = false; |
243 | d = new AddressBookData; | 243 | d = new AddressBookData; |
244 | QString fami = family; | 244 | QString fami = family; |
245 | if (config != 0) { | 245 | if (config != 0) { |
246 | if ( family == "syncContact" ) { | 246 | if ( family == "syncContact" ) { |
247 | qDebug("creating sync config "); | 247 | qDebug("creating sync config "); |
248 | fami = "contact"; | 248 | fami = "contact"; |
249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
250 | con->setGroup( "General" ); | 250 | con->setGroup( "General" ); |
251 | con->writeEntry( "ResourceKeys", QString("sync") ); | 251 | con->writeEntry( "ResourceKeys", QString("sync") ); |
252 | con->writeEntry( "Standard", QString("sync") ); | 252 | con->writeEntry( "Standard", QString("sync") ); |
253 | con->setGroup( "Resource_sync" ); | 253 | con->setGroup( "Resource_sync" ); |
254 | con->writeEntry( "FileName", config ); | 254 | con->writeEntry( "FileName", config ); |
255 | con->writeEntry( "FileFormat", QString("vcard") ); | 255 | con->writeEntry( "FileFormat", QString("vcard") ); |
256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
257 | con->writeEntry( "ResourceName", QString("sync_res") ); | 257 | con->writeEntry( "ResourceName", QString("sync_res") ); |
258 | if ( config.right(4) == ".xml" ) | 258 | if ( config.right(4) == ".xml" ) |
259 | con->writeEntry( "ResourceType", QString("qtopia") ); | 259 | con->writeEntry( "ResourceType", QString("qtopia") ); |
260 | else if ( config == "sharp" ) { | 260 | else if ( config == "sharp" ) { |
261 | con->writeEntry( "ResourceType", QString("sharp") ); | 261 | con->writeEntry( "ResourceType", QString("sharp") ); |
262 | } else { | 262 | } else { |
263 | con->writeEntry( "ResourceType", QString("file") ); | 263 | con->writeEntry( "ResourceType", QString("file") ); |
264 | } | 264 | } |
265 | //con->sync(); | 265 | //con->sync(); |
266 | d->mConfig = con; | 266 | d->mConfig = con; |
267 | } | 267 | } |
268 | else | 268 | else |
269 | d->mConfig = new KConfig( locateLocal("config", config) ); | 269 | d->mConfig = new KConfig( locateLocal("config", config) ); |
270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
271 | } | 271 | } |
272 | else { | 272 | else { |
273 | d->mConfig = 0; | 273 | d->mConfig = 0; |
274 | // qDebug("AddressBook::init 1 config=0"); | 274 | // qDebug("AddressBook::init 1 config=0"); |
275 | } | 275 | } |
276 | 276 | ||
277 | //US d->mErrorHandler = 0; | 277 | //US d->mErrorHandler = 0; |
278 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 278 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
279 | d->mManager->readConfig( d->mConfig ); | 279 | d->mManager->readConfig( d->mConfig ); |
280 | if ( family == "syncContact" ) { | 280 | if ( family == "syncContact" ) { |
281 | KRES::Manager<Resource> *manager = d->mManager; | 281 | KRES::Manager<Resource> *manager = d->mManager; |
282 | KRES::Manager<Resource>::ActiveIterator it; | 282 | KRES::Manager<Resource>::ActiveIterator it; |
283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
284 | (*it)->setAddressBook( this ); | 284 | (*it)->setAddressBook( this ); |
285 | if ( !(*it)->open() ) | 285 | if ( !(*it)->open() ) |
286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
287 | } | 287 | } |
288 | Resource *res = standardResource(); | 288 | Resource *res = standardResource(); |
289 | if ( !res ) { | 289 | if ( !res ) { |
290 | qDebug("ERROR: no standard resource"); | 290 | qDebug("ERROR: no standard resource"); |
291 | res = manager->createResource( "file" ); | 291 | res = manager->createResource( "file" ); |
292 | if ( res ) | 292 | if ( res ) |
293 | { | 293 | { |
294 | addResource( res ); | 294 | addResource( res ); |
295 | } | 295 | } |
296 | else | 296 | else |
297 | qDebug(" No resource available!!!"); | 297 | qDebug(" No resource available!!!"); |
298 | } | 298 | } |
299 | setStandardResource( res ); | 299 | setStandardResource( res ); |
300 | manager->writeConfig(); | 300 | manager->writeConfig(); |
301 | } | 301 | } |
302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
303 | "X-Department", "KADDRESSBOOK" ); | 303 | "X-Department", "KADDRESSBOOK" ); |
304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
305 | "X-Profession", "KADDRESSBOOK" ); | 305 | "X-Profession", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
307 | "X-AssistantsName", "KADDRESSBOOK" ); | 307 | "X-AssistantsName", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
309 | "X-ManagersName", "KADDRESSBOOK" ); | 309 | "X-ManagersName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
311 | "X-SpousesName", "KADDRESSBOOK" ); | 311 | "X-SpousesName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
313 | "X-Office", "KADDRESSBOOK" ); | 313 | "X-Office", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
315 | "X-IMAddress", "KADDRESSBOOK" ); | 315 | "X-IMAddress", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
317 | "X-Anniversary", "KADDRESSBOOK" ); | 317 | "X-Anniversary", "KADDRESSBOOK" ); |
318 | 318 | ||
319 | //US added this field to become compatible with Opie/qtopia addressbook | 319 | //US added this field to become compatible with Opie/qtopia addressbook |
320 | // values can be "female" or "male" or "". An empty field represents undefined. | 320 | // values can be "female" or "male" or "". An empty field represents undefined. |
321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
322 | "X-Gender", "KADDRESSBOOK" ); | 322 | "X-Gender", "KADDRESSBOOK" ); |
323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
324 | "X-Children", "KADDRESSBOOK" ); | 324 | "X-Children", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
328 | "X-ExternalID", "KADDRESSBOOK" ); | 328 | "X-ExternalID", "KADDRESSBOOK" ); |
329 | } | 329 | } |
330 | 330 | ||
331 | AddressBook::~AddressBook() | 331 | AddressBook::~AddressBook() |
332 | { | 332 | { |
333 | delete d->mConfig; d->mConfig = 0; | 333 | delete d->mConfig; d->mConfig = 0; |
334 | delete d->mManager; d->mManager = 0; | 334 | delete d->mManager; d->mManager = 0; |
335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
336 | delete d; d = 0; | 336 | delete d; d = 0; |
337 | } | 337 | } |
338 | 338 | ||
339 | bool AddressBook::load() | 339 | bool AddressBook::load() |
340 | { | 340 | { |
341 | 341 | ||
342 | 342 | ||
343 | clear(); | 343 | clear(); |
344 | 344 | ||
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 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } | 351 | } |
352 | 352 | ||
353 | // mark all addressees as unchanged | 353 | // mark all addressees as unchanged |
354 | Addressee::List::Iterator addrIt; | 354 | Addressee::List::Iterator addrIt; |
355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
356 | (*addrIt).setChanged( false ); | 356 | (*addrIt).setChanged( false ); |
357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
358 | if ( !id.isEmpty() ) { | 358 | if ( !id.isEmpty() ) { |
359 | //qDebug("setId aa %s ", id.latin1()); | 359 | //qDebug("setId aa %s ", id.latin1()); |
360 | (*addrIt).setIDStr(id ); | 360 | (*addrIt).setIDStr(id ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | blockLSEchange = true; | 363 | blockLSEchange = true; |
364 | return ok; | 364 | return ok; |
365 | } | 365 | } |
366 | 366 | ||
367 | bool AddressBook::save( Ticket *ticket ) | 367 | bool AddressBook::save( Ticket *ticket ) |
368 | { | 368 | { |
369 | kdDebug(5700) << "AddressBook::save()"<< endl; | 369 | kdDebug(5700) << "AddressBook::save()"<< endl; |
370 | 370 | ||
371 | if ( ticket->resource() ) { | 371 | if ( ticket->resource() ) { |
372 | deleteRemovedAddressees(); | 372 | deleteRemovedAddressees(); |
373 | return ticket->resource()->save( ticket ); | 373 | return ticket->resource()->save( ticket ); |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | void AddressBook::export2File( QString fileName ) | 378 | void AddressBook::export2File( QString fileName ) |
379 | { | 379 | { |
380 | 380 | ||
381 | QFile outFile( fileName ); | 381 | QFile outFile( fileName ); |
382 | if ( !outFile.open( IO_WriteOnly ) ) { | 382 | if ( !outFile.open( IO_WriteOnly ) ) { |
383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
384 | KMessageBox::error( 0, text.arg( fileName ) ); | 384 | KMessageBox::error( 0, text.arg( fileName ) ); |
385 | return ; | 385 | return ; |
386 | } | 386 | } |
387 | QTextStream t( &outFile ); | 387 | QTextStream t( &outFile ); |
388 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 388 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
389 | Iterator it; | 389 | Iterator it; |
390 | KABC::VCardConverter::Version version; | 390 | KABC::VCardConverter::Version version; |
391 | version = KABC::VCardConverter::v3_0; | 391 | version = KABC::VCardConverter::v3_0; |
392 | for ( it = begin(); it != end(); ++it ) { | 392 | for ( it = begin(); it != end(); ++it ) { |
393 | if ( !(*it).IDStr().isEmpty() ) { | 393 | if ( !(*it).IDStr().isEmpty() ) { |
394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
395 | } | 395 | } |
396 | KABC::VCardConverter converter; | 396 | KABC::VCardConverter converter; |
397 | QString vcard; | 397 | QString vcard; |
398 | //Resource *resource() const; | 398 | //Resource *resource() const; |
399 | converter.addresseeToVCard( *it, vcard, version ); | 399 | converter.addresseeToVCard( *it, vcard, version ); |
400 | t << vcard << "\r\n"; | 400 | t << vcard << "\r\n"; |
401 | } | 401 | } |
402 | t << "\r\n\r\n"; | 402 | t << "\r\n\r\n"; |
403 | outFile.close(); | 403 | outFile.close(); |
404 | } | 404 | } |
405 | void AddressBook::importFromFile( QString fileName ) | 405 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) |
406 | { | 406 | { |
407 | 407 | ||
408 | KABC::Addressee::List list; | 408 | KABC::Addressee::List list; |
409 | QFile file( fileName ); | 409 | QFile file( fileName ); |
410 | 410 | ||
411 | file.open( IO_ReadOnly ); | 411 | file.open( IO_ReadOnly ); |
412 | QByteArray rawData = file.readAll(); | 412 | QByteArray rawData = file.readAll(); |
413 | file.close(); | 413 | file.close(); |
414 | 414 | qDebug("AddressBook::importFromFile "); | |
415 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 415 | QString data; |
416 | if ( replaceLabel ) { | ||
417 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | ||
418 | data.replace ( QRegExp("LABEL") , "ADR" ); | ||
419 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | ||
420 | } else | ||
421 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | ||
416 | KABC::VCardTool tool; | 422 | KABC::VCardTool tool; |
417 | list = tool.parseVCards( data ); | 423 | list = tool.parseVCards( data ); |
418 | KABC::Addressee::List::Iterator it; | 424 | KABC::Addressee::List::Iterator it; |
419 | for ( it = list.begin(); it != list.end(); ++it ) { | 425 | for ( it = list.begin(); it != list.end(); ++it ) { |
420 | (*it).setResource( 0 ); | 426 | (*it).setResource( 0 ); |
427 | if ( replaceLabel ) | ||
428 | (*it).removeVoice(); | ||
421 | insertAddressee( (*it), false, true ); | 429 | insertAddressee( (*it), false, true ); |
422 | } | 430 | } |
423 | 431 | ||
424 | } | 432 | } |
425 | 433 | ||
426 | bool AddressBook::saveAB() | 434 | bool AddressBook::saveAB() |
427 | { | 435 | { |
428 | bool ok = true; | 436 | bool ok = true; |
429 | 437 | ||
430 | deleteRemovedAddressees(); | 438 | deleteRemovedAddressees(); |
431 | Iterator ait; | 439 | Iterator ait; |
432 | for ( ait = begin(); ait != end(); ++ait ) { | 440 | for ( ait = begin(); ait != end(); ++ait ) { |
433 | if ( !(*ait).IDStr().isEmpty() ) { | 441 | if ( !(*ait).IDStr().isEmpty() ) { |
434 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 442 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
435 | } | 443 | } |
436 | } | 444 | } |
437 | KRES::Manager<Resource>::ActiveIterator it; | 445 | KRES::Manager<Resource>::ActiveIterator it; |
438 | KRES::Manager<Resource> *manager = d->mManager; | 446 | KRES::Manager<Resource> *manager = d->mManager; |
439 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 447 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
440 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 448 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
441 | Ticket *ticket = requestSaveTicket( *it ); | 449 | Ticket *ticket = requestSaveTicket( *it ); |
442 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 450 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
443 | if ( !ticket ) { | 451 | if ( !ticket ) { |
444 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 452 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
445 | .arg( (*it)->resourceName() ) ); | 453 | .arg( (*it)->resourceName() ) ); |
446 | return false; | 454 | return false; |
447 | } | 455 | } |
448 | 456 | ||
449 | //if ( !save( ticket ) ) | 457 | //if ( !save( ticket ) ) |
450 | if ( ticket->resource() ) { | 458 | if ( ticket->resource() ) { |
451 | if ( ! ticket->resource()->save( ticket ) ) | 459 | if ( ! ticket->resource()->save( ticket ) ) |
452 | ok = false; | 460 | ok = false; |
453 | } else | 461 | } else |
454 | ok = false; | 462 | ok = false; |
455 | 463 | ||
456 | } | 464 | } |
457 | } | 465 | } |
458 | return ok; | 466 | return ok; |
459 | } | 467 | } |
460 | 468 | ||
461 | AddressBook::Iterator AddressBook::begin() | 469 | AddressBook::Iterator AddressBook::begin() |
462 | { | 470 | { |
463 | Iterator it = Iterator(); | 471 | Iterator it = Iterator(); |
464 | it.d->mIt = d->mAddressees.begin(); | 472 | it.d->mIt = d->mAddressees.begin(); |
465 | return it; | 473 | return it; |
466 | } | 474 | } |
467 | 475 | ||
468 | AddressBook::ConstIterator AddressBook::begin() const | 476 | AddressBook::ConstIterator AddressBook::begin() const |
469 | { | 477 | { |
470 | ConstIterator it = ConstIterator(); | 478 | ConstIterator it = ConstIterator(); |
471 | it.d->mIt = d->mAddressees.begin(); | 479 | it.d->mIt = d->mAddressees.begin(); |
472 | return it; | 480 | return it; |
473 | } | 481 | } |
474 | 482 | ||
475 | AddressBook::Iterator AddressBook::end() | 483 | AddressBook::Iterator AddressBook::end() |
476 | { | 484 | { |
477 | Iterator it = Iterator(); | 485 | Iterator it = Iterator(); |
478 | it.d->mIt = d->mAddressees.end(); | 486 | it.d->mIt = d->mAddressees.end(); |
479 | return it; | 487 | return it; |
480 | } | 488 | } |
481 | 489 | ||
482 | AddressBook::ConstIterator AddressBook::end() const | 490 | AddressBook::ConstIterator AddressBook::end() const |
483 | { | 491 | { |
484 | ConstIterator it = ConstIterator(); | 492 | ConstIterator it = ConstIterator(); |
485 | it.d->mIt = d->mAddressees.end(); | 493 | it.d->mIt = d->mAddressees.end(); |
486 | return it; | 494 | return it; |
487 | } | 495 | } |
488 | 496 | ||
489 | void AddressBook::clear() | 497 | void AddressBook::clear() |
490 | { | 498 | { |
491 | d->mAddressees.clear(); | 499 | d->mAddressees.clear(); |
492 | } | 500 | } |
493 | 501 | ||
494 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 502 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
495 | { | 503 | { |
496 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 504 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
497 | 505 | ||
498 | if ( !resource ) | 506 | if ( !resource ) |
499 | { | 507 | { |
500 | qDebug("AddressBook::requestSaveTicket no resource" ); | 508 | qDebug("AddressBook::requestSaveTicket no resource" ); |
501 | resource = standardResource(); | 509 | resource = standardResource(); |
502 | } | 510 | } |
503 | 511 | ||
504 | KRES::Manager<Resource>::ActiveIterator it; | 512 | KRES::Manager<Resource>::ActiveIterator it; |
505 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 513 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
506 | if ( (*it) == resource ) { | 514 | if ( (*it) == resource ) { |
507 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 515 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
508 | return 0; | 516 | return 0; |
509 | else | 517 | else |
510 | return (*it)->requestSaveTicket(); | 518 | return (*it)->requestSaveTicket(); |
511 | } | 519 | } |
512 | } | 520 | } |
513 | 521 | ||
514 | return 0; | 522 | return 0; |
515 | } | 523 | } |
516 | 524 | ||
517 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 525 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
518 | { | 526 | { |
519 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 527 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
520 | //qDebug("block insert "); | 528 | //qDebug("block insert "); |
521 | return; | 529 | return; |
522 | } | 530 | } |
523 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 531 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
524 | bool found = false; | 532 | bool found = false; |
525 | Addressee::List::Iterator it; | 533 | Addressee::List::Iterator it; |
526 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 534 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
527 | if ( a.uid() == (*it).uid() ) { | 535 | if ( a.uid() == (*it).uid() ) { |
528 | 536 | ||
529 | bool changed = false; | 537 | bool changed = false; |
530 | Addressee addr = a; | 538 | Addressee addr = a; |
531 | if ( addr != (*it) ) | 539 | if ( addr != (*it) ) |
532 | changed = true; | 540 | changed = true; |
533 | 541 | ||
534 | if ( takeResource ) { | 542 | if ( takeResource ) { |
535 | Resource * res = (*it).resource(); | 543 | Resource * res = (*it).resource(); |
536 | (*it) = a; | 544 | (*it) = a; |
537 | (*it).setResource( res ); | 545 | (*it).setResource( res ); |
538 | } else { | 546 | } else { |
539 | (*it) = a; | 547 | (*it) = a; |
540 | if ( (*it).resource() == 0 ) | 548 | if ( (*it).resource() == 0 ) |
541 | (*it).setResource( standardResource() ); | 549 | (*it).setResource( standardResource() ); |
542 | } | 550 | } |
543 | if ( changed ) { | 551 | if ( changed ) { |
544 | if ( setRev ) { | 552 | if ( setRev ) { |
545 | 553 | ||
546 | // get rid of micro seconds | 554 | // get rid of micro seconds |
547 | QDateTime dt = QDateTime::currentDateTime(); | 555 | QDateTime dt = QDateTime::currentDateTime(); |
548 | QTime t = dt.time(); | 556 | QTime t = dt.time(); |
549 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 557 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
550 | (*it).setRevision( dt ); | 558 | (*it).setRevision( dt ); |
551 | } | 559 | } |
552 | (*it).setChanged( true ); | 560 | (*it).setChanged( true ); |
553 | } | 561 | } |
554 | 562 | ||
555 | found = true; | 563 | found = true; |
556 | } else { | 564 | } else { |
557 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 565 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
558 | QString name = (*it).uid().mid( 19 ); | 566 | QString name = (*it).uid().mid( 19 ); |
559 | Addressee b = a; | 567 | Addressee b = a; |
560 | QString id = b.getID( name ); | 568 | QString id = b.getID( name ); |
561 | if ( ! id.isEmpty() ) { | 569 | if ( ! id.isEmpty() ) { |
562 | QString des = (*it).note(); | 570 | QString des = (*it).note(); |
563 | int startN; | 571 | int startN; |
564 | if( (startN = des.find( id ) ) >= 0 ) { | 572 | if( (startN = des.find( id ) ) >= 0 ) { |
565 | int endN = des.find( ",", startN+1 ); | 573 | int endN = des.find( ",", startN+1 ); |
566 | des = des.left( startN ) + des.mid( endN+1 ); | 574 | des = des.left( startN ) + des.mid( endN+1 ); |
567 | (*it).setNote( des ); | 575 | (*it).setNote( des ); |
568 | } | 576 | } |
569 | } | 577 | } |
570 | } | 578 | } |
571 | } | 579 | } |
572 | } | 580 | } |
573 | if ( found ) | 581 | if ( found ) |
574 | return; | 582 | return; |
575 | d->mAddressees.append( a ); | 583 | d->mAddressees.append( a ); |
576 | Addressee& addr = d->mAddressees.last(); | 584 | Addressee& addr = d->mAddressees.last(); |
577 | if ( addr.resource() == 0 ) | 585 | if ( addr.resource() == 0 ) |
578 | addr.setResource( standardResource() ); | 586 | addr.setResource( standardResource() ); |
579 | 587 | ||
580 | addr.setChanged( true ); | 588 | addr.setChanged( true ); |
581 | } | 589 | } |
582 | 590 | ||
583 | void AddressBook::removeAddressee( const Addressee &a ) | 591 | void AddressBook::removeAddressee( const Addressee &a ) |
584 | { | 592 | { |
585 | Iterator it; | 593 | Iterator it; |
586 | Iterator it2; | 594 | Iterator it2; |
587 | bool found = false; | 595 | bool found = false; |
588 | for ( it = begin(); it != end(); ++it ) { | 596 | for ( it = begin(); it != end(); ++it ) { |
589 | if ( a.uid() == (*it).uid() ) { | 597 | if ( a.uid() == (*it).uid() ) { |
590 | found = true; | 598 | found = true; |
591 | it2 = it; | 599 | it2 = it; |
592 | } else { | 600 | } else { |
593 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 601 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
594 | QString name = (*it).uid().mid( 19 ); | 602 | QString name = (*it).uid().mid( 19 ); |
595 | Addressee b = a; | 603 | Addressee b = a; |
596 | QString id = b.getID( name ); | 604 | QString id = b.getID( name ); |
597 | if ( ! id.isEmpty() ) { | 605 | if ( ! id.isEmpty() ) { |
598 | QString des = (*it).note(); | 606 | QString des = (*it).note(); |
599 | if( des.find( id ) < 0 ) { | 607 | if( des.find( id ) < 0 ) { |
600 | des += id + ","; | 608 | des += id + ","; |
601 | (*it).setNote( des ); | 609 | (*it).setNote( des ); |
602 | } | 610 | } |
603 | } | 611 | } |
604 | } | 612 | } |
605 | 613 | ||
606 | } | 614 | } |
607 | } | 615 | } |
608 | 616 | ||
609 | if ( found ) | 617 | if ( found ) |
610 | removeAddressee( it2 ); | 618 | removeAddressee( it2 ); |
611 | 619 | ||
612 | } | 620 | } |
613 | 621 | ||
614 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 622 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
615 | { | 623 | { |
616 | Iterator it = begin(); | 624 | Iterator it = begin(); |
617 | Iterator it2 ; | 625 | Iterator it2 ; |
618 | QDateTime dt ( QDate( 2004,1,1) ); | 626 | QDateTime dt ( QDate( 2004,1,1) ); |
619 | while ( it != end() ) { | 627 | while ( it != end() ) { |
620 | (*it).setRevision( dt ); | 628 | (*it).setRevision( dt ); |
621 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 629 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
622 | (*it).setIDStr(""); | 630 | (*it).setIDStr(""); |
623 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 631 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
624 | it2 = it; | 632 | it2 = it; |
625 | //qDebug("removing %s ",(*it).uid().latin1() ); | 633 | //qDebug("removing %s ",(*it).uid().latin1() ); |
626 | ++it; | 634 | ++it; |
627 | removeAddressee( it2 ); | 635 | removeAddressee( it2 ); |
628 | } else { | 636 | } else { |
629 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 637 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
630 | ++it; | 638 | ++it; |
631 | } | 639 | } |
632 | } | 640 | } |
633 | deleteRemovedAddressees(); | 641 | deleteRemovedAddressees(); |
634 | } | 642 | } |
635 | 643 | ||
636 | void AddressBook::removeAddressee( const Iterator &it ) | 644 | void AddressBook::removeAddressee( const Iterator &it ) |
637 | { | 645 | { |
638 | d->mRemovedAddressees.append( (*it) ); | 646 | d->mRemovedAddressees.append( (*it) ); |
639 | d->mAddressees.remove( it.d->mIt ); | 647 | d->mAddressees.remove( it.d->mIt ); |
640 | } | 648 | } |
641 | 649 | ||
642 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 650 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
643 | { | 651 | { |
644 | Iterator it; | 652 | Iterator it; |
645 | for ( it = begin(); it != end(); ++it ) { | 653 | for ( it = begin(); it != end(); ++it ) { |
646 | if ( a.uid() == (*it).uid() ) { | 654 | if ( a.uid() == (*it).uid() ) { |
647 | return it; | 655 | return it; |
648 | } | 656 | } |
649 | } | 657 | } |
650 | return end(); | 658 | return end(); |
651 | } | 659 | } |
652 | 660 | ||
653 | Addressee AddressBook::findByUid( const QString &uid ) | 661 | Addressee AddressBook::findByUid( const QString &uid ) |
654 | { | 662 | { |
655 | Iterator it; | 663 | Iterator it; |
656 | for ( it = begin(); it != end(); ++it ) { | 664 | for ( it = begin(); it != end(); ++it ) { |
657 | if ( uid == (*it).uid() ) { | 665 | if ( uid == (*it).uid() ) { |
658 | return *it; | 666 | return *it; |
659 | } | 667 | } |
660 | } | 668 | } |
661 | return Addressee(); | 669 | return Addressee(); |
662 | } | 670 | } |
663 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 671 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) |
664 | { | 672 | { |
665 | //qDebug("AddressBook::preExternSync "); | 673 | //qDebug("AddressBook::preExternSync "); |
666 | AddressBook::Iterator it; | 674 | AddressBook::Iterator it; |
667 | for ( it = begin(); it != end(); ++it ) { | 675 | for ( it = begin(); it != end(); ++it ) { |
668 | (*it).setID( csd, (*it).externalUID() ); | 676 | (*it).setID( csd, (*it).externalUID() ); |
669 | (*it).computeCsum( csd ); | 677 | (*it).computeCsum( csd ); |
670 | } | 678 | } |
671 | mergeAB( aBook ,csd ); | 679 | mergeAB( aBook ,csd ); |
672 | } | 680 | } |
673 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 681 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
674 | { | 682 | { |
675 | //qDebug("AddressBook::postExternSync "); | 683 | //qDebug("AddressBook::postExternSync "); |
676 | AddressBook::Iterator it; | 684 | AddressBook::Iterator it; |
677 | for ( it = begin(); it != end(); ++it ) { | 685 | for ( it = begin(); it != end(); ++it ) { |
678 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 686 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
679 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 687 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
680 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 688 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
681 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 689 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
682 | if ( ad.isEmpty() ) { | 690 | if ( ad.isEmpty() ) { |
683 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 691 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
684 | } else { | 692 | } else { |
685 | (*it).computeCsum( csd ); | 693 | (*it).computeCsum( csd ); |
686 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 694 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
687 | ad.setID( csd, (*it).externalUID() ); | 695 | ad.setID( csd, (*it).externalUID() ); |
688 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 696 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
689 | aBook->insertAddressee( ad ); | 697 | aBook->insertAddressee( ad ); |
690 | } | 698 | } |
691 | } | 699 | } |
692 | } | 700 | } |
693 | } | 701 | } |
694 | 702 | ||
695 | bool AddressBook::containsExternalUid( const QString& uid ) | 703 | bool AddressBook::containsExternalUid( const QString& uid ) |
696 | { | 704 | { |
697 | Iterator it; | 705 | Iterator it; |
698 | for ( it = begin(); it != end(); ++it ) { | 706 | for ( it = begin(); it != end(); ++it ) { |
699 | if ( uid == (*it).externalUID( ) ) | 707 | if ( uid == (*it).externalUID( ) ) |
700 | return true; | 708 | return true; |
701 | } | 709 | } |
702 | return false; | 710 | return false; |
703 | } | 711 | } |
704 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 712 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
705 | { | 713 | { |
706 | Iterator it; | 714 | Iterator it; |
707 | for ( it = begin(); it != end(); ++it ) { | 715 | for ( it = begin(); it != end(); ++it ) { |
708 | if ( uid == (*it).getID( profile ) ) | 716 | if ( uid == (*it).getID( profile ) ) |
709 | return (*it); | 717 | return (*it); |
710 | } | 718 | } |
711 | return Addressee(); | 719 | return Addressee(); |
712 | } | 720 | } |
713 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 721 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) |
714 | { | 722 | { |
715 | Iterator it; | 723 | Iterator it; |
716 | Addressee ad; | 724 | Addressee ad; |
717 | for ( it = begin(); it != end(); ++it ) { | 725 | for ( it = begin(); it != end(); ++it ) { |
718 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 726 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
719 | if ( !ad.isEmpty() ) { | 727 | if ( !ad.isEmpty() ) { |
720 | (*it).mergeContact( ad ); | 728 | (*it).mergeContact( ad ); |
721 | } | 729 | } |
722 | } | 730 | } |
723 | #if 0 | 731 | #if 0 |
724 | // test only | 732 | // test only |
725 | for ( it = begin(); it != end(); ++it ) { | 733 | for ( it = begin(); it != end(); ++it ) { |
726 | 734 | ||
727 | qDebug("uid %s ", (*it).uid().latin1()); | 735 | qDebug("uid %s ", (*it).uid().latin1()); |
728 | } | 736 | } |
729 | #endif | 737 | #endif |
730 | } | 738 | } |
731 | 739 | ||
732 | #if 0 | 740 | #if 0 |
733 | Addressee::List AddressBook::getExternLastSyncAddressees() | 741 | Addressee::List AddressBook::getExternLastSyncAddressees() |
734 | { | 742 | { |
735 | Addressee::List results; | 743 | Addressee::List results; |
736 | 744 | ||
737 | Iterator it; | 745 | Iterator it; |
738 | for ( it = begin(); it != end(); ++it ) { | 746 | for ( it = begin(); it != end(); ++it ) { |
739 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 747 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
740 | if ( (*it).familyName().left(4) == "!E: " ) | 748 | if ( (*it).familyName().left(4) == "!E: " ) |
741 | results.append( *it ); | 749 | results.append( *it ); |
742 | } | 750 | } |
743 | } | 751 | } |
744 | 752 | ||
745 | return results; | 753 | return results; |
746 | } | 754 | } |
747 | #endif | 755 | #endif |
748 | void AddressBook::resetTempSyncStat() | 756 | void AddressBook::resetTempSyncStat() |
749 | { | 757 | { |
750 | Iterator it; | 758 | Iterator it; |
751 | for ( it = begin(); it != end(); ++it ) { | 759 | for ( it = begin(); it != end(); ++it ) { |
752 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 760 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
753 | } | 761 | } |
754 | 762 | ||
755 | } | 763 | } |
756 | 764 | ||
757 | QStringList AddressBook:: uidList() | 765 | QStringList AddressBook:: uidList() |
758 | { | 766 | { |
759 | QStringList results; | 767 | QStringList results; |
760 | Iterator it; | 768 | Iterator it; |
761 | for ( it = begin(); it != end(); ++it ) { | 769 | for ( it = begin(); it != end(); ++it ) { |
762 | results.append( (*it).uid() ); | 770 | results.append( (*it).uid() ); |
763 | } | 771 | } |
764 | return results; | 772 | return results; |
765 | } | 773 | } |
766 | 774 | ||
767 | 775 | ||
768 | Addressee::List AddressBook::allAddressees() | 776 | Addressee::List AddressBook::allAddressees() |
769 | { | 777 | { |
770 | return d->mAddressees; | 778 | return d->mAddressees; |
771 | 779 | ||
772 | } | 780 | } |
773 | 781 | ||
774 | Addressee::List AddressBook::findByName( const QString &name ) | 782 | Addressee::List AddressBook::findByName( const QString &name ) |
775 | { | 783 | { |
776 | Addressee::List results; | 784 | Addressee::List results; |
777 | 785 | ||
778 | Iterator it; | 786 | Iterator it; |
779 | for ( it = begin(); it != end(); ++it ) { | 787 | for ( it = begin(); it != end(); ++it ) { |
780 | if ( name == (*it).realName() ) { | 788 | if ( name == (*it).realName() ) { |
781 | results.append( *it ); | 789 | results.append( *it ); |
782 | } | 790 | } |
783 | } | 791 | } |
784 | 792 | ||
785 | return results; | 793 | return results; |
786 | } | 794 | } |
787 | 795 | ||
788 | Addressee::List AddressBook::findByEmail( const QString &email ) | 796 | Addressee::List AddressBook::findByEmail( const QString &email ) |
789 | { | 797 | { |
790 | Addressee::List results; | 798 | Addressee::List results; |
791 | QStringList mailList; | 799 | QStringList mailList; |
792 | 800 | ||
793 | Iterator it; | 801 | Iterator it; |
794 | for ( it = begin(); it != end(); ++it ) { | 802 | for ( it = begin(); it != end(); ++it ) { |
795 | mailList = (*it).emails(); | 803 | mailList = (*it).emails(); |
796 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 804 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
797 | if ( email == (*ite) ) { | 805 | if ( email == (*ite) ) { |
798 | results.append( *it ); | 806 | results.append( *it ); |
799 | } | 807 | } |
800 | } | 808 | } |
801 | } | 809 | } |
802 | 810 | ||
803 | return results; | 811 | return results; |
804 | } | 812 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 3603ec1..cea1b03 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,341 +1,341 @@ | |||
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 | void export2File( QString fileName ); | 145 | void export2File( QString fileName ); |
146 | void importFromFile( QString fileName ); | 146 | void importFromFile( QString fileName, bool replaceLabel = false ); |
147 | /** | 147 | /** |
148 | Returns a iterator for first entry of address book. | 148 | Returns a iterator for first entry of address book. |
149 | */ | 149 | */ |
150 | Iterator begin(); | 150 | Iterator begin(); |
151 | 151 | ||
152 | /** | 152 | /** |
153 | Returns a const iterator for first entry of address book. | 153 | Returns a const iterator for first entry of address book. |
154 | */ | 154 | */ |
155 | ConstIterator begin() const; | 155 | ConstIterator begin() const; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Returns a iterator for first entry of address book. | 158 | Returns a iterator for first entry of address book. |
159 | */ | 159 | */ |
160 | Iterator end(); | 160 | Iterator end(); |
161 | 161 | ||
162 | /** | 162 | /** |
163 | Returns a const iterator for first entry of address book. | 163 | Returns a const iterator for first entry of address book. |
164 | */ | 164 | */ |
165 | ConstIterator end() const; | 165 | ConstIterator end() const; |
166 | 166 | ||
167 | /** | 167 | /** |
168 | Removes all entries from address book. | 168 | Removes all entries from address book. |
169 | */ | 169 | */ |
170 | void clear(); | 170 | void clear(); |
171 | 171 | ||
172 | /** | 172 | /** |
173 | Insert an Addressee object into address book. If an object with the same | 173 | Insert an Addressee object into address book. If an object with the same |
174 | unique id already exists in the address book it it replaced by the new | 174 | unique id already exists in the address book it it replaced by the new |
175 | one. If not the new object is appended to the address book. | 175 | one. If not the new object is appended to the address book. |
176 | */ | 176 | */ |
177 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 177 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
178 | 178 | ||
179 | /** | 179 | /** |
180 | Removes entry from the address book. | 180 | Removes entry from the address book. |
181 | */ | 181 | */ |
182 | void removeAddressee( const Addressee & ); | 182 | void removeAddressee( const Addressee & ); |
183 | 183 | ||
184 | /** | 184 | /** |
185 | This is like @ref removeAddressee() just above, with the difference that | 185 | This is like @ref removeAddressee() just above, with the difference that |
186 | the first element is a iterator, returned by @ref begin(). | 186 | the first element is a iterator, returned by @ref begin(). |
187 | */ | 187 | */ |
188 | void removeAddressee( const Iterator & ); | 188 | void removeAddressee( const Iterator & ); |
189 | 189 | ||
190 | /** | 190 | /** |
191 | Find the specified entry in address book. Returns end(), if the entry | 191 | Find the specified entry in address book. Returns end(), if the entry |
192 | couldn't be found. | 192 | couldn't be found. |
193 | */ | 193 | */ |
194 | Iterator find( const Addressee & ); | 194 | Iterator find( const Addressee & ); |
195 | 195 | ||
196 | /** | 196 | /** |
197 | Find the entry specified by an unique id. Returns an empty Addressee | 197 | Find the entry specified by an unique id. Returns an empty Addressee |
198 | object, if the address book does not contain an entry with this id. | 198 | object, if the address book does not contain an entry with this id. |
199 | */ | 199 | */ |
200 | Addressee findByUid( const QString & ); | 200 | Addressee findByUid( const QString & ); |
201 | 201 | ||
202 | 202 | ||
203 | /** | 203 | /** |
204 | Returns a list of all addressees in the address book. This list can | 204 | Returns a list of all addressees in the address book. This list can |
205 | be sorted with @ref KABC::AddresseeList for example. | 205 | be sorted with @ref KABC::AddresseeList for example. |
206 | */ | 206 | */ |
207 | Addressee::List allAddressees(); | 207 | Addressee::List allAddressees(); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Find all entries with the specified name in the address book. Returns | 210 | Find all entries with the specified name in the address book. Returns |
211 | an empty list, if no entries could be found. | 211 | an empty list, if no entries could be found. |
212 | */ | 212 | */ |
213 | Addressee::List findByName( const QString & ); | 213 | Addressee::List findByName( const QString & ); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | Find all entries with the specified email address in the address book. | 216 | Find all entries with the specified email address in the address book. |
217 | Returns an empty list, if no entries could be found. | 217 | Returns an empty list, if no entries could be found. |
218 | */ | 218 | */ |
219 | Addressee::List findByEmail( const QString & ); | 219 | Addressee::List findByEmail( const QString & ); |
220 | 220 | ||
221 | /** | 221 | /** |
222 | Find all entries wich have the specified category in the address book. | 222 | Find all entries wich have the specified category in the address book. |
223 | Returns an empty list, if no entries could be found. | 223 | Returns an empty list, if no entries could be found. |
224 | */ | 224 | */ |
225 | Addressee::List findByCategory( const QString & ); | 225 | Addressee::List findByCategory( const QString & ); |
226 | 226 | ||
227 | /** | 227 | /** |
228 | Return a string identifying this addressbook. | 228 | Return a string identifying this addressbook. |
229 | */ | 229 | */ |
230 | virtual QString identifier(); | 230 | virtual QString identifier(); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | Used for debug output. | 233 | Used for debug output. |
234 | */ | 234 | */ |
235 | void dump() const; | 235 | void dump() const; |
236 | 236 | ||
237 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 237 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
238 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 238 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
239 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 239 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
240 | 240 | ||
241 | /** | 241 | /** |
242 | Return list of all Fields known to the address book which are associated | 242 | Return list of all Fields known to the address book which are associated |
243 | with the given field category. | 243 | with the given field category. |
244 | */ | 244 | */ |
245 | Field::List fields( int category = Field::All ); | 245 | Field::List fields( int category = Field::All ); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | Add custom field to address book. | 248 | Add custom field to address book. |
249 | 249 | ||
250 | @param label User visible label of the field. | 250 | @param label User visible label of the field. |
251 | @param category Ored list of field categories. | 251 | @param category Ored list of field categories. |
252 | @param key Identifier used as key for reading and writing the field. | 252 | @param key Identifier used as key for reading and writing the field. |
253 | @param app String used as application key for reading and writing | 253 | @param app String used as application key for reading and writing |
254 | the field. | 254 | the field. |
255 | */ | 255 | */ |
256 | bool addCustomField( const QString &label, int category = Field::All, | 256 | bool addCustomField( const QString &label, int category = Field::All, |
257 | const QString &key = QString::null, | 257 | const QString &key = QString::null, |
258 | const QString &app = QString::null ); | 258 | const QString &app = QString::null ); |
259 | 259 | ||
260 | 260 | ||
261 | /** | 261 | /** |
262 | Add address book resource. | 262 | Add address book resource. |
263 | */ | 263 | */ |
264 | bool addResource( Resource * ); | 264 | bool addResource( Resource * ); |
265 | 265 | ||
266 | /** | 266 | /** |
267 | Remove address book resource. | 267 | Remove address book resource. |
268 | */ | 268 | */ |
269 | bool removeResource( Resource * ); | 269 | bool removeResource( Resource * ); |
270 | 270 | ||
271 | /** | 271 | /** |
272 | Return pointer list of all resources. | 272 | Return pointer list of all resources. |
273 | */ | 273 | */ |
274 | QPtrList<Resource> resources(); | 274 | QPtrList<Resource> resources(); |
275 | 275 | ||
276 | /** | 276 | /** |
277 | Set the @p ErrorHandler, that is used by @ref error() to | 277 | Set the @p ErrorHandler, that is used by @ref error() to |
278 | provide gui-independend error messages. | 278 | provide gui-independend error messages. |
279 | */ | 279 | */ |
280 | void setErrorHandler( ErrorHandler * ); | 280 | void setErrorHandler( ErrorHandler * ); |
281 | 281 | ||
282 | /** | 282 | /** |
283 | Shows gui independend error messages. | 283 | Shows gui independend error messages. |
284 | */ | 284 | */ |
285 | void error( const QString& ); | 285 | void error( const QString& ); |
286 | 286 | ||
287 | /** | 287 | /** |
288 | Query all resources to clean up their lock files | 288 | Query all resources to clean up their lock files |
289 | */ | 289 | */ |
290 | void cleanUp(); | 290 | void cleanUp(); |
291 | 291 | ||
292 | // sync stuff | 292 | // sync stuff |
293 | //Addressee::List getExternLastSyncAddressees(); | 293 | //Addressee::List getExternLastSyncAddressees(); |
294 | void resetTempSyncStat(); | 294 | void resetTempSyncStat(); |
295 | QStringList uidList(); | 295 | QStringList uidList(); |
296 | void removeSyncAddressees( bool removeDeleted = false ); | 296 | void removeSyncAddressees( bool removeDeleted = false ); |
297 | void mergeAB( AddressBook *aBook, const QString& profile ); | 297 | void mergeAB( AddressBook *aBook, const QString& profile ); |
298 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 298 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
299 | bool containsExternalUid( const QString& uid ); | 299 | bool containsExternalUid( const QString& uid ); |
300 | 300 | ||
301 | void preExternSync( AddressBook* aBook, const QString& csd ); | 301 | void preExternSync( AddressBook* aBook, const QString& csd ); |
302 | void postExternSync( AddressBook* aBook, const QString& csd ); | 302 | void postExternSync( AddressBook* aBook, const QString& csd ); |
303 | signals: | 303 | signals: |
304 | /** | 304 | /** |
305 | Emitted, when the address book has changed on disk. | 305 | Emitted, when the address book has changed on disk. |
306 | */ | 306 | */ |
307 | void addressBookChanged( AddressBook * ); | 307 | void addressBookChanged( AddressBook * ); |
308 | 308 | ||
309 | /** | 309 | /** |
310 | Emitted, when the address book has been locked for writing. | 310 | Emitted, when the address book has been locked for writing. |
311 | */ | 311 | */ |
312 | void addressBookLocked( AddressBook * ); | 312 | void addressBookLocked( AddressBook * ); |
313 | 313 | ||
314 | /** | 314 | /** |
315 | Emitted, when the address book has been unlocked. | 315 | Emitted, when the address book has been unlocked. |
316 | */ | 316 | */ |
317 | void addressBookUnlocked( AddressBook * ); | 317 | void addressBookUnlocked( AddressBook * ); |
318 | 318 | ||
319 | protected: | 319 | protected: |
320 | void deleteRemovedAddressees(); | 320 | void deleteRemovedAddressees(); |
321 | void setStandardResource( Resource * ); | 321 | void setStandardResource( Resource * ); |
322 | Resource *standardResource(); | 322 | Resource *standardResource(); |
323 | KRES::Manager<Resource> *resourceManager(); | 323 | KRES::Manager<Resource> *resourceManager(); |
324 | 324 | ||
325 | void init(const QString &config, const QString &family); | 325 | void init(const QString &config, const QString &family); |
326 | 326 | ||
327 | private: | 327 | private: |
328 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 328 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
329 | 329 | ||
330 | 330 | ||
331 | struct AddressBookData; | 331 | struct AddressBookData; |
332 | AddressBookData *d; | 332 | AddressBookData *d; |
333 | bool blockLSEchange; | 333 | bool blockLSEchange; |
334 | }; | 334 | }; |
335 | 335 | ||
336 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 336 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
337 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 337 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
338 | 338 | ||
339 | } | 339 | } |
340 | 340 | ||
341 | #endif | 341 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 19a1845..3f3d5c0 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,701 +1,718 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | 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 | }; | 91 | }; |
92 | 92 | ||
93 | Addressee::Addressee() | 93 | Addressee::Addressee() |
94 | { | 94 | { |
95 | mData = new AddresseeData; | 95 | mData = new AddresseeData; |
96 | mData->empty = true; | 96 | mData->empty = true; |
97 | mData->changed = false; | 97 | mData->changed = false; |
98 | mData->resource = 0; | 98 | mData->resource = 0; |
99 | mData->mExternalId = ":"; | 99 | mData->mExternalId = ":"; |
100 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 100 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
101 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 101 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee::~Addressee() | 104 | Addressee::~Addressee() |
105 | { | 105 | { |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee::Addressee( const Addressee &a ) | 108 | Addressee::Addressee( const Addressee &a ) |
109 | { | 109 | { |
110 | mData = a.mData; | 110 | mData = a.mData; |
111 | } | 111 | } |
112 | 112 | ||
113 | Addressee &Addressee::operator=( const Addressee &a ) | 113 | Addressee &Addressee::operator=( const Addressee &a ) |
114 | { | 114 | { |
115 | mData = a.mData; | 115 | mData = a.mData; |
116 | return (*this); | 116 | return (*this); |
117 | } | 117 | } |
118 | 118 | ||
119 | Addressee Addressee::copy() | 119 | Addressee Addressee::copy() |
120 | { | 120 | { |
121 | Addressee a; | 121 | Addressee a; |
122 | *(a.mData) = *mData; | 122 | *(a.mData) = *mData; |
123 | return a; | 123 | return a; |
124 | } | 124 | } |
125 | 125 | ||
126 | void Addressee::detach() | 126 | void Addressee::detach() |
127 | { | 127 | { |
128 | if ( mData.count() == 1 ) return; | 128 | if ( mData.count() == 1 ) return; |
129 | *this = copy(); | 129 | *this = copy(); |
130 | } | 130 | } |
131 | 131 | ||
132 | bool Addressee::operator==( const Addressee &a ) const | 132 | bool Addressee::operator==( const Addressee &a ) const |
133 | { | 133 | { |
134 | if ( uid() != a.uid() ) return false; | 134 | if ( uid() != a.uid() ) return false; |
135 | if ( mData->name != a.mData->name ) return false; | 135 | if ( mData->name != a.mData->name ) return false; |
136 | if ( mData->formattedName != a.mData->formattedName ) return false; | 136 | if ( mData->formattedName != a.mData->formattedName ) return false; |
137 | if ( mData->familyName != a.mData->familyName ) return false; | 137 | if ( mData->familyName != a.mData->familyName ) return false; |
138 | if ( mData->givenName != a.mData->givenName ) return false; | 138 | if ( mData->givenName != a.mData->givenName ) return false; |
139 | if ( mData->additionalName != a.mData->additionalName ) return false; | 139 | if ( mData->additionalName != a.mData->additionalName ) return false; |
140 | if ( mData->prefix != a.mData->prefix ) return false; | 140 | if ( mData->prefix != a.mData->prefix ) return false; |
141 | if ( mData->suffix != a.mData->suffix ) return false; | 141 | if ( mData->suffix != a.mData->suffix ) return false; |
142 | if ( mData->nickName != a.mData->nickName ) return false; | 142 | if ( mData->nickName != a.mData->nickName ) return false; |
143 | if ( mData->birthday != a.mData->birthday ) return false; | 143 | if ( mData->birthday != a.mData->birthday ) return false; |
144 | if ( mData->mailer != a.mData->mailer ) return false; | 144 | if ( mData->mailer != a.mData->mailer ) return false; |
145 | if ( mData->timeZone != a.mData->timeZone ) return false; | 145 | if ( mData->timeZone != a.mData->timeZone ) return false; |
146 | if ( mData->geo != a.mData->geo ) return false; | 146 | if ( mData->geo != a.mData->geo ) return false; |
147 | if ( mData->title != a.mData->title ) return false; | 147 | if ( mData->title != a.mData->title ) return false; |
148 | if ( mData->role != a.mData->role ) return false; | 148 | if ( mData->role != a.mData->role ) return false; |
149 | if ( mData->organization != a.mData->organization ) return false; | 149 | if ( mData->organization != a.mData->organization ) return false; |
150 | if ( mData->note != a.mData->note ) return false; | 150 | if ( mData->note != a.mData->note ) return false; |
151 | if ( mData->productId != a.mData->productId ) return false; | 151 | if ( mData->productId != a.mData->productId ) return false; |
152 | //if ( mData->revision != a.mData->revision ) return false; | 152 | //if ( mData->revision != a.mData->revision ) return false; |
153 | if ( mData->sortString != a.mData->sortString ) return false; | 153 | if ( mData->sortString != a.mData->sortString ) return false; |
154 | if ( mData->secrecy != a.mData->secrecy ) return false; | 154 | if ( mData->secrecy != a.mData->secrecy ) return false; |
155 | if ( mData->logo != a.mData->logo ) return false; | 155 | if ( mData->logo != a.mData->logo ) return false; |
156 | if ( mData->photo != a.mData->photo ) return false; | 156 | if ( mData->photo != a.mData->photo ) return false; |
157 | if ( mData->sound != a.mData->sound ) return false; | 157 | if ( mData->sound != a.mData->sound ) return false; |
158 | if ( mData->agent != a.mData->agent ) return false; | 158 | if ( mData->agent != a.mData->agent ) return false; |
159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
160 | ( mData->url != a.mData->url ) ) return false; | 160 | ( mData->url != a.mData->url ) ) return false; |
161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
162 | if ( mData->addresses != a.mData->addresses ) return false; | 162 | if ( mData->addresses != a.mData->addresses ) return false; |
163 | if ( mData->keys != a.mData->keys ) return false; | 163 | if ( mData->keys != a.mData->keys ) return false; |
164 | if ( mData->emails != a.mData->emails ) return false; | 164 | if ( mData->emails != a.mData->emails ) return false; |
165 | if ( mData->categories != a.mData->categories ) return false; | 165 | if ( mData->categories != a.mData->categories ) return false; |
166 | if ( mData->custom != a.mData->custom ) return false; | 166 | if ( mData->custom != a.mData->custom ) return false; |
167 | 167 | ||
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | 170 | ||
171 | bool Addressee::operator!=( const Addressee &a ) const | 171 | bool Addressee::operator!=( const Addressee &a ) const |
172 | { | 172 | { |
173 | return !( a == *this ); | 173 | return !( a == *this ); |
174 | } | 174 | } |
175 | 175 | ||
176 | bool Addressee::isEmpty() const | 176 | bool Addressee::isEmpty() const |
177 | { | 177 | { |
178 | return mData->empty; | 178 | return mData->empty; |
179 | } | 179 | } |
180 | ulong Addressee::getCsum4List( const QStringList & attList) | 180 | ulong Addressee::getCsum4List( const QStringList & attList) |
181 | { | 181 | { |
182 | int max = attList.count(); | 182 | int max = attList.count(); |
183 | ulong cSum = 0; | 183 | ulong cSum = 0; |
184 | int j,k,i; | 184 | int j,k,i; |
185 | int add; | 185 | int add; |
186 | for ( i = 0; i < max ; ++i ) { | 186 | for ( i = 0; i < max ; ++i ) { |
187 | QString s = attList[i]; | 187 | QString s = attList[i]; |
188 | if ( ! s.isEmpty() ){ | 188 | if ( ! s.isEmpty() ){ |
189 | j = s.length(); | 189 | j = s.length(); |
190 | for ( k = 0; k < j; ++k ) { | 190 | for ( k = 0; k < j; ++k ) { |
191 | int mul = k +1; | 191 | int mul = k +1; |
192 | add = s[k].unicode (); | 192 | add = s[k].unicode (); |
193 | if ( k < 16 ) | 193 | if ( k < 16 ) |
194 | mul = mul * mul; | 194 | mul = mul * mul; |
195 | int ii = i+1; | 195 | int ii = i+1; |
196 | add = add * mul *ii*ii*ii; | 196 | add = add * mul *ii*ii*ii; |
197 | cSum += add; | 197 | cSum += add; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | } | 201 | } |
202 | //QString dump = attList.join(","); | 202 | //QString dump = attList.join(","); |
203 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 203 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
204 | 204 | ||
205 | return cSum; | 205 | return cSum; |
206 | 206 | ||
207 | } | 207 | } |
208 | void Addressee::computeCsum(const QString &dev) | 208 | void Addressee::computeCsum(const QString &dev) |
209 | { | 209 | { |
210 | QStringList l; | 210 | QStringList l; |
211 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 211 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
215 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 215 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
230 | // if ( !mData->logo.isEmpty() ) l.append( ); | 230 | // if ( !mData->logo.isEmpty() ) l.append( ); |
231 | //if ( !mData->photo.isEmpty() ) l.append( ); | 231 | //if ( !mData->photo.isEmpty() ) l.append( ); |
232 | //if ( !mData->sound.isEmpty() ) l.append( ); | 232 | //if ( !mData->sound.isEmpty() ) l.append( ); |
233 | //if ( !mData->agent.isEmpty() ) l.append( ); | 233 | //if ( !mData->agent.isEmpty() ) l.append( ); |
234 | //if ( mData->url.isValid() ) l.append( ); | 234 | //if ( mData->url.isValid() ) l.append( ); |
235 | #if 0 | 235 | #if 0 |
236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
237 | if ( !mData->addresses.isEmpty() ) l.append( ); | 237 | if ( !mData->addresses.isEmpty() ) l.append( ); |
238 | //if ( !mData->keys.isEmpty() ) l.append( ); | 238 | //if ( !mData->keys.isEmpty() ) l.append( ); |
239 | if ( !mData->emails.isEmpty() ) l.append( ); | 239 | if ( !mData->emails.isEmpty() ) l.append( ); |
240 | if ( !mData->categories .isEmpty() ) l.append( ); | 240 | if ( !mData->categories .isEmpty() ) l.append( ); |
241 | if ( !mData->custom.isEmpty() ) l.append( ); | 241 | if ( !mData->custom.isEmpty() ) l.append( ); |
242 | #endif | 242 | #endif |
243 | KABC::PhoneNumber::List phoneNumbers; | 243 | KABC::PhoneNumber::List phoneNumbers; |
244 | KABC::PhoneNumber::List::Iterator phoneIter; | 244 | KABC::PhoneNumber::List::Iterator phoneIter; |
245 | 245 | ||
246 | QStringList t; | 246 | QStringList t; |
247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
248 | ++phoneIter ) | 248 | ++phoneIter ) |
249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
250 | t.sort(); | 250 | t.sort(); |
251 | uint iii; | 251 | uint iii; |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->emails; | 254 | t = mData->emails; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->categories; | 258 | t = mData->categories; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | t = mData->custom; | 262 | t = mData->custom; |
263 | t.sort(); | 263 | t.sort(); |
264 | for ( iii = 0; iii < t.count(); ++iii) | 264 | for ( iii = 0; iii < t.count(); ++iii) |
265 | l.append( t[iii] ); | 265 | l.append( t[iii] ); |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
276 | setCsum( dev, QString::number (cs )); | 276 | setCsum( dev, QString::number (cs )); |
277 | } | 277 | } |
278 | 278 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 279 | void Addressee::mergeContact( const Addressee& ad ) |
280 | { | 280 | { |
281 | 281 | ||
282 | detach(); | 282 | detach(); |
283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
291 | if ( !mData->birthday.isValid() ) | 291 | if ( !mData->birthday.isValid() ) |
292 | if ( ad.mData->birthday.isValid()) | 292 | if ( ad.mData->birthday.isValid()) |
293 | mData->birthday = ad.mData->birthday; | 293 | mData->birthday = ad.mData->birthday; |
294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
305 | 305 | ||
306 | // pending: | 306 | // pending: |
307 | // merging phonenumbers | 307 | // merging phonenumbers |
308 | // merging addresses | 308 | // merging addresses |
309 | // merging emails; | 309 | // merging emails; |
310 | // merging categories; | 310 | // merging categories; |
311 | // merging custom; | 311 | // merging custom; |
312 | // merging keys | 312 | // merging keys |
313 | qDebug("merge contact %s ", ad.uid().latin1()); | 313 | qDebug("merge contact %s ", ad.uid().latin1()); |
314 | setUid( ad.uid() ); | 314 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 315 | setRevision( ad.revision() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | bool Addressee::removeVoice() | ||
319 | { | ||
320 | PhoneNumber::List phoneN = phoneNumbers(); | ||
321 | PhoneNumber::List::Iterator phoneIt; | ||
322 | bool found = false; | ||
323 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | ||
324 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | ||
325 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | ||
326 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | ||
327 | insertPhoneNumber( (*phoneIt) ); | ||
328 | found = true; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | } | ||
333 | return found; | ||
334 | } | ||
318 | void Addressee::simplifyAddresses() | 335 | void Addressee::simplifyAddresses() |
319 | { | 336 | { |
320 | if ( mData->addresses.count() < 3 ) return ; | 337 | if ( mData->addresses.count() < 3 ) return ; |
321 | int count = 0; | 338 | int count = 0; |
322 | Address::List list; | 339 | Address::List list; |
323 | Address::List::Iterator it; | 340 | Address::List::Iterator it; |
324 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 341 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
325 | if ( count > 1 ) | 342 | if ( count > 1 ) |
326 | list.append( *it ); | 343 | list.append( *it ); |
327 | ++count; | 344 | ++count; |
328 | } | 345 | } |
329 | for( it = list.begin(); it != list.end(); ++it ) { | 346 | for( it = list.begin(); it != list.end(); ++it ) { |
330 | removeAddress( (*it) ); | 347 | removeAddress( (*it) ); |
331 | } | 348 | } |
332 | } | 349 | } |
333 | 350 | ||
334 | // removes all emails but the first | 351 | // removes all emails but the first |
335 | // needed by phone sync | 352 | // needed by phone sync |
336 | void Addressee::simplifyEmails() | 353 | void Addressee::simplifyEmails() |
337 | { | 354 | { |
338 | if ( mData->emails.count() == 0 ) return ; | 355 | if ( mData->emails.count() == 0 ) return ; |
339 | QString email = mData->emails.first(); | 356 | QString email = mData->emails.first(); |
340 | detach(); | 357 | detach(); |
341 | mData->emails.clear(); | 358 | mData->emails.clear(); |
342 | mData->emails.append( email ); | 359 | mData->emails.append( email ); |
343 | } | 360 | } |
344 | 361 | ||
345 | void Addressee::simplifyPhoneNumbers() | 362 | void Addressee::simplifyPhoneNumbers() |
346 | { | 363 | { |
347 | KABC::PhoneNumber::List removeNumbers; | 364 | KABC::PhoneNumber::List removeNumbers; |
348 | KABC::PhoneNumber::List::Iterator phoneIter; | 365 | KABC::PhoneNumber::List::Iterator phoneIter; |
349 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 366 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
350 | ++phoneIter ) { | 367 | ++phoneIter ) { |
351 | if ( ! ( *phoneIter ).simplifyNumber() ) | 368 | if ( ! ( *phoneIter ).simplifyNumber() ) |
352 | removeNumbers.append( ( *phoneIter ) ); | 369 | removeNumbers.append( ( *phoneIter ) ); |
353 | } | 370 | } |
354 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 371 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
355 | ++phoneIter ) { | 372 | ++phoneIter ) { |
356 | removePhoneNumber(( *phoneIter )); | 373 | removePhoneNumber(( *phoneIter )); |
357 | } | 374 | } |
358 | } | 375 | } |
359 | void Addressee::simplifyPhoneNumberTypes() | 376 | void Addressee::simplifyPhoneNumberTypes() |
360 | { | 377 | { |
361 | KABC::PhoneNumber::List::Iterator phoneIter; | 378 | KABC::PhoneNumber::List::Iterator phoneIter; |
362 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 379 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
363 | ++phoneIter ) | 380 | ++phoneIter ) |
364 | ( *phoneIter ).simplifyType(); | 381 | ( *phoneIter ).simplifyType(); |
365 | } | 382 | } |
366 | void Addressee::removeID(const QString &prof) | 383 | void Addressee::removeID(const QString &prof) |
367 | { | 384 | { |
368 | detach(); | 385 | detach(); |
369 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 386 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
370 | 387 | ||
371 | } | 388 | } |
372 | void Addressee::setID( const QString & prof , const QString & id ) | 389 | void Addressee::setID( const QString & prof , const QString & id ) |
373 | { | 390 | { |
374 | detach(); | 391 | detach(); |
375 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 392 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
376 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 393 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
377 | } | 394 | } |
378 | void Addressee::setTempSyncStat( int id ) | 395 | void Addressee::setTempSyncStat( int id ) |
379 | { | 396 | { |
380 | if ( mData->mTempSyncStat == id ) return; | 397 | if ( mData->mTempSyncStat == id ) return; |
381 | detach(); | 398 | detach(); |
382 | mData->mTempSyncStat = id; | 399 | mData->mTempSyncStat = id; |
383 | } | 400 | } |
384 | int Addressee::tempSyncStat() const | 401 | int Addressee::tempSyncStat() const |
385 | { | 402 | { |
386 | return mData->mTempSyncStat; | 403 | return mData->mTempSyncStat; |
387 | } | 404 | } |
388 | 405 | ||
389 | QString Addressee::getID( const QString & prof) | 406 | QString Addressee::getID( const QString & prof) |
390 | { | 407 | { |
391 | return KIdManager::getId ( mData->mExternalId, prof ); | 408 | return KIdManager::getId ( mData->mExternalId, prof ); |
392 | } | 409 | } |
393 | 410 | ||
394 | void Addressee::setCsum( const QString & prof , const QString & id ) | 411 | void Addressee::setCsum( const QString & prof , const QString & id ) |
395 | { | 412 | { |
396 | detach(); | 413 | detach(); |
397 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 414 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
398 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 415 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
399 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 416 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
400 | } | 417 | } |
401 | 418 | ||
402 | QString Addressee::getCsum( const QString & prof) | 419 | QString Addressee::getCsum( const QString & prof) |
403 | { | 420 | { |
404 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 421 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
405 | } | 422 | } |
406 | 423 | ||
407 | void Addressee::setIDStr( const QString & s ) | 424 | void Addressee::setIDStr( const QString & s ) |
408 | { | 425 | { |
409 | detach(); | 426 | detach(); |
410 | mData->mExternalId = s; | 427 | mData->mExternalId = s; |
411 | } | 428 | } |
412 | 429 | ||
413 | QString Addressee::IDStr() const | 430 | QString Addressee::IDStr() const |
414 | { | 431 | { |
415 | return mData->mExternalId; | 432 | return mData->mExternalId; |
416 | } | 433 | } |
417 | 434 | ||
418 | void Addressee::setExternalUID( const QString &id ) | 435 | void Addressee::setExternalUID( const QString &id ) |
419 | { | 436 | { |
420 | if ( id == mData->externalUID ) return; | 437 | if ( id == mData->externalUID ) return; |
421 | detach(); | 438 | detach(); |
422 | mData->empty = false; | 439 | mData->empty = false; |
423 | mData->externalUID = id; | 440 | mData->externalUID = id; |
424 | } | 441 | } |
425 | 442 | ||
426 | QString Addressee::externalUID() const | 443 | QString Addressee::externalUID() const |
427 | { | 444 | { |
428 | return mData->externalUID; | 445 | return mData->externalUID; |
429 | } | 446 | } |
430 | void Addressee::setOriginalExternalUID( const QString &id ) | 447 | void Addressee::setOriginalExternalUID( const QString &id ) |
431 | { | 448 | { |
432 | if ( id == mData->originalExternalUID ) return; | 449 | if ( id == mData->originalExternalUID ) return; |
433 | detach(); | 450 | detach(); |
434 | mData->empty = false; | 451 | mData->empty = false; |
435 | //qDebug("*******Set orig uid %s ", id.latin1()); | 452 | //qDebug("*******Set orig uid %s ", id.latin1()); |
436 | mData->originalExternalUID = id; | 453 | mData->originalExternalUID = id; |
437 | } | 454 | } |
438 | 455 | ||
439 | QString Addressee::originalExternalUID() const | 456 | QString Addressee::originalExternalUID() const |
440 | { | 457 | { |
441 | return mData->originalExternalUID; | 458 | return mData->originalExternalUID; |
442 | } | 459 | } |
443 | 460 | ||
444 | void Addressee::setUid( const QString &id ) | 461 | void Addressee::setUid( const QString &id ) |
445 | { | 462 | { |
446 | if ( id == mData->uid ) return; | 463 | if ( id == mData->uid ) return; |
447 | detach(); | 464 | detach(); |
448 | //qDebug("****setuid %s ", id.latin1()); | 465 | //qDebug("****setuid %s ", id.latin1()); |
449 | mData->empty = false; | 466 | mData->empty = false; |
450 | mData->uid = id; | 467 | mData->uid = id; |
451 | } | 468 | } |
452 | 469 | ||
453 | QString Addressee::uid() const | 470 | QString Addressee::uid() const |
454 | { | 471 | { |
455 | if ( mData->uid.isEmpty() ) | 472 | if ( mData->uid.isEmpty() ) |
456 | mData->uid = KApplication::randomString( 10 ); | 473 | mData->uid = KApplication::randomString( 10 ); |
457 | 474 | ||
458 | return mData->uid; | 475 | return mData->uid; |
459 | } | 476 | } |
460 | 477 | ||
461 | QString Addressee::uidLabel() | 478 | QString Addressee::uidLabel() |
462 | { | 479 | { |
463 | return i18n("Unique Identifier"); | 480 | return i18n("Unique Identifier"); |
464 | } | 481 | } |
465 | 482 | ||
466 | void Addressee::setName( const QString &name ) | 483 | void Addressee::setName( const QString &name ) |
467 | { | 484 | { |
468 | if ( name == mData->name ) return; | 485 | if ( name == mData->name ) return; |
469 | detach(); | 486 | detach(); |
470 | mData->empty = false; | 487 | mData->empty = false; |
471 | mData->name = name; | 488 | mData->name = name; |
472 | } | 489 | } |
473 | 490 | ||
474 | QString Addressee::name() const | 491 | QString Addressee::name() const |
475 | { | 492 | { |
476 | return mData->name; | 493 | return mData->name; |
477 | } | 494 | } |
478 | 495 | ||
479 | QString Addressee::nameLabel() | 496 | QString Addressee::nameLabel() |
480 | { | 497 | { |
481 | return i18n("Name"); | 498 | return i18n("Name"); |
482 | } | 499 | } |
483 | 500 | ||
484 | 501 | ||
485 | void Addressee::setFormattedName( const QString &formattedName ) | 502 | void Addressee::setFormattedName( const QString &formattedName ) |
486 | { | 503 | { |
487 | if ( formattedName == mData->formattedName ) return; | 504 | if ( formattedName == mData->formattedName ) return; |
488 | detach(); | 505 | detach(); |
489 | mData->empty = false; | 506 | mData->empty = false; |
490 | mData->formattedName = formattedName; | 507 | mData->formattedName = formattedName; |
491 | } | 508 | } |
492 | 509 | ||
493 | QString Addressee::formattedName() const | 510 | QString Addressee::formattedName() const |
494 | { | 511 | { |
495 | return mData->formattedName; | 512 | return mData->formattedName; |
496 | } | 513 | } |
497 | 514 | ||
498 | QString Addressee::formattedNameLabel() | 515 | QString Addressee::formattedNameLabel() |
499 | { | 516 | { |
500 | return i18n("Formatted Name"); | 517 | return i18n("Formatted Name"); |
501 | } | 518 | } |
502 | 519 | ||
503 | 520 | ||
504 | void Addressee::setFamilyName( const QString &familyName ) | 521 | void Addressee::setFamilyName( const QString &familyName ) |
505 | { | 522 | { |
506 | if ( familyName == mData->familyName ) return; | 523 | if ( familyName == mData->familyName ) return; |
507 | detach(); | 524 | detach(); |
508 | mData->empty = false; | 525 | mData->empty = false; |
509 | mData->familyName = familyName; | 526 | mData->familyName = familyName; |
510 | } | 527 | } |
511 | 528 | ||
512 | QString Addressee::familyName() const | 529 | QString Addressee::familyName() const |
513 | { | 530 | { |
514 | return mData->familyName; | 531 | return mData->familyName; |
515 | } | 532 | } |
516 | 533 | ||
517 | QString Addressee::familyNameLabel() | 534 | QString Addressee::familyNameLabel() |
518 | { | 535 | { |
519 | return i18n("Family Name"); | 536 | return i18n("Family Name"); |
520 | } | 537 | } |
521 | 538 | ||
522 | 539 | ||
523 | void Addressee::setGivenName( const QString &givenName ) | 540 | void Addressee::setGivenName( const QString &givenName ) |
524 | { | 541 | { |
525 | if ( givenName == mData->givenName ) return; | 542 | if ( givenName == mData->givenName ) return; |
526 | detach(); | 543 | detach(); |
527 | mData->empty = false; | 544 | mData->empty = false; |
528 | mData->givenName = givenName; | 545 | mData->givenName = givenName; |
529 | } | 546 | } |
530 | 547 | ||
531 | QString Addressee::givenName() const | 548 | QString Addressee::givenName() const |
532 | { | 549 | { |
533 | return mData->givenName; | 550 | return mData->givenName; |
534 | } | 551 | } |
535 | 552 | ||
536 | QString Addressee::givenNameLabel() | 553 | QString Addressee::givenNameLabel() |
537 | { | 554 | { |
538 | return i18n("Given Name"); | 555 | return i18n("Given Name"); |
539 | } | 556 | } |
540 | 557 | ||
541 | 558 | ||
542 | void Addressee::setAdditionalName( const QString &additionalName ) | 559 | void Addressee::setAdditionalName( const QString &additionalName ) |
543 | { | 560 | { |
544 | if ( additionalName == mData->additionalName ) return; | 561 | if ( additionalName == mData->additionalName ) return; |
545 | detach(); | 562 | detach(); |
546 | mData->empty = false; | 563 | mData->empty = false; |
547 | mData->additionalName = additionalName; | 564 | mData->additionalName = additionalName; |
548 | } | 565 | } |
549 | 566 | ||
550 | QString Addressee::additionalName() const | 567 | QString Addressee::additionalName() const |
551 | { | 568 | { |
552 | return mData->additionalName; | 569 | return mData->additionalName; |
553 | } | 570 | } |
554 | 571 | ||
555 | QString Addressee::additionalNameLabel() | 572 | QString Addressee::additionalNameLabel() |
556 | { | 573 | { |
557 | return i18n("Additional Names"); | 574 | return i18n("Additional Names"); |
558 | } | 575 | } |
559 | 576 | ||
560 | 577 | ||
561 | void Addressee::setPrefix( const QString &prefix ) | 578 | void Addressee::setPrefix( const QString &prefix ) |
562 | { | 579 | { |
563 | if ( prefix == mData->prefix ) return; | 580 | if ( prefix == mData->prefix ) return; |
564 | detach(); | 581 | detach(); |
565 | mData->empty = false; | 582 | mData->empty = false; |
566 | mData->prefix = prefix; | 583 | mData->prefix = prefix; |
567 | } | 584 | } |
568 | 585 | ||
569 | QString Addressee::prefix() const | 586 | QString Addressee::prefix() const |
570 | { | 587 | { |
571 | return mData->prefix; | 588 | return mData->prefix; |
572 | } | 589 | } |
573 | 590 | ||
574 | QString Addressee::prefixLabel() | 591 | QString Addressee::prefixLabel() |
575 | { | 592 | { |
576 | return i18n("Honorific Prefixes"); | 593 | return i18n("Honorific Prefixes"); |
577 | } | 594 | } |
578 | 595 | ||
579 | 596 | ||
580 | void Addressee::setSuffix( const QString &suffix ) | 597 | void Addressee::setSuffix( const QString &suffix ) |
581 | { | 598 | { |
582 | if ( suffix == mData->suffix ) return; | 599 | if ( suffix == mData->suffix ) return; |
583 | detach(); | 600 | detach(); |
584 | mData->empty = false; | 601 | mData->empty = false; |
585 | mData->suffix = suffix; | 602 | mData->suffix = suffix; |
586 | } | 603 | } |
587 | 604 | ||
588 | QString Addressee::suffix() const | 605 | QString Addressee::suffix() const |
589 | { | 606 | { |
590 | return mData->suffix; | 607 | return mData->suffix; |
591 | } | 608 | } |
592 | 609 | ||
593 | QString Addressee::suffixLabel() | 610 | QString Addressee::suffixLabel() |
594 | { | 611 | { |
595 | return i18n("Honorific Suffixes"); | 612 | return i18n("Honorific Suffixes"); |
596 | } | 613 | } |
597 | 614 | ||
598 | 615 | ||
599 | void Addressee::setNickName( const QString &nickName ) | 616 | void Addressee::setNickName( const QString &nickName ) |
600 | { | 617 | { |
601 | if ( nickName == mData->nickName ) return; | 618 | if ( nickName == mData->nickName ) return; |
602 | detach(); | 619 | detach(); |
603 | mData->empty = false; | 620 | mData->empty = false; |
604 | mData->nickName = nickName; | 621 | mData->nickName = nickName; |
605 | } | 622 | } |
606 | 623 | ||
607 | QString Addressee::nickName() const | 624 | QString Addressee::nickName() const |
608 | { | 625 | { |
609 | return mData->nickName; | 626 | return mData->nickName; |
610 | } | 627 | } |
611 | 628 | ||
612 | QString Addressee::nickNameLabel() | 629 | QString Addressee::nickNameLabel() |
613 | { | 630 | { |
614 | return i18n("Nick Name"); | 631 | return i18n("Nick Name"); |
615 | } | 632 | } |
616 | 633 | ||
617 | 634 | ||
618 | void Addressee::setBirthday( const QDateTime &birthday ) | 635 | void Addressee::setBirthday( const QDateTime &birthday ) |
619 | { | 636 | { |
620 | if ( birthday == mData->birthday ) return; | 637 | if ( birthday == mData->birthday ) return; |
621 | detach(); | 638 | detach(); |
622 | mData->empty = false; | 639 | mData->empty = false; |
623 | mData->birthday = birthday; | 640 | mData->birthday = birthday; |
624 | } | 641 | } |
625 | 642 | ||
626 | QDateTime Addressee::birthday() const | 643 | QDateTime Addressee::birthday() const |
627 | { | 644 | { |
628 | return mData->birthday; | 645 | return mData->birthday; |
629 | } | 646 | } |
630 | 647 | ||
631 | QString Addressee::birthdayLabel() | 648 | QString Addressee::birthdayLabel() |
632 | { | 649 | { |
633 | return i18n("Birthday"); | 650 | return i18n("Birthday"); |
634 | } | 651 | } |
635 | 652 | ||
636 | 653 | ||
637 | QString Addressee::homeAddressStreetLabel() | 654 | QString Addressee::homeAddressStreetLabel() |
638 | { | 655 | { |
639 | return i18n("Home Address Street"); | 656 | return i18n("Home Address Street"); |
640 | } | 657 | } |
641 | 658 | ||
642 | 659 | ||
643 | QString Addressee::homeAddressLocalityLabel() | 660 | QString Addressee::homeAddressLocalityLabel() |
644 | { | 661 | { |
645 | return i18n("Home Address Locality"); | 662 | return i18n("Home Address Locality"); |
646 | } | 663 | } |
647 | 664 | ||
648 | 665 | ||
649 | QString Addressee::homeAddressRegionLabel() | 666 | QString Addressee::homeAddressRegionLabel() |
650 | { | 667 | { |
651 | return i18n("Home Address Region"); | 668 | return i18n("Home Address Region"); |
652 | } | 669 | } |
653 | 670 | ||
654 | 671 | ||
655 | QString Addressee::homeAddressPostalCodeLabel() | 672 | QString Addressee::homeAddressPostalCodeLabel() |
656 | { | 673 | { |
657 | return i18n("Home Address Postal Code"); | 674 | return i18n("Home Address Postal Code"); |
658 | } | 675 | } |
659 | 676 | ||
660 | 677 | ||
661 | QString Addressee::homeAddressCountryLabel() | 678 | QString Addressee::homeAddressCountryLabel() |
662 | { | 679 | { |
663 | return i18n("Home Address Country"); | 680 | return i18n("Home Address Country"); |
664 | } | 681 | } |
665 | 682 | ||
666 | 683 | ||
667 | QString Addressee::homeAddressLabelLabel() | 684 | QString Addressee::homeAddressLabelLabel() |
668 | { | 685 | { |
669 | return i18n("Home Address Label"); | 686 | return i18n("Home Address Label"); |
670 | } | 687 | } |
671 | 688 | ||
672 | 689 | ||
673 | QString Addressee::businessAddressStreetLabel() | 690 | QString Addressee::businessAddressStreetLabel() |
674 | { | 691 | { |
675 | return i18n("Business Address Street"); | 692 | return i18n("Business Address Street"); |
676 | } | 693 | } |
677 | 694 | ||
678 | 695 | ||
679 | QString Addressee::businessAddressLocalityLabel() | 696 | QString Addressee::businessAddressLocalityLabel() |
680 | { | 697 | { |
681 | return i18n("Business Address Locality"); | 698 | return i18n("Business Address Locality"); |
682 | } | 699 | } |
683 | 700 | ||
684 | 701 | ||
685 | QString Addressee::businessAddressRegionLabel() | 702 | QString Addressee::businessAddressRegionLabel() |
686 | { | 703 | { |
687 | return i18n("Business Address Region"); | 704 | return i18n("Business Address Region"); |
688 | } | 705 | } |
689 | 706 | ||
690 | 707 | ||
691 | QString Addressee::businessAddressPostalCodeLabel() | 708 | QString Addressee::businessAddressPostalCodeLabel() |
692 | { | 709 | { |
693 | return i18n("Business Address Postal Code"); | 710 | return i18n("Business Address Postal Code"); |
694 | } | 711 | } |
695 | 712 | ||
696 | 713 | ||
697 | QString Addressee::businessAddressCountryLabel() | 714 | QString Addressee::businessAddressCountryLabel() |
698 | { | 715 | { |
699 | return i18n("Business Address Country"); | 716 | return i18n("Business Address Country"); |
700 | } | 717 | } |
701 | 718 | ||
diff --git a/kabc/addressee.h b/kabc/addressee.h index 44f0629..9336edc 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,507 +1,508 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad ); | 119 | void mergeContact( const Addressee& ad ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | ||
124 | 125 | ||
125 | /** | 126 | /** |
126 | Set unique identifier. | 127 | Set unique identifier. |
127 | */ | 128 | */ |
128 | void setUid( const QString &uid ); | 129 | void setUid( const QString &uid ); |
129 | /** | 130 | /** |
130 | Return unique identifier. | 131 | Return unique identifier. |
131 | */ | 132 | */ |
132 | QString uid() const; | 133 | QString uid() const; |
133 | /** | 134 | /** |
134 | Return translated label for uid field. | 135 | Return translated label for uid field. |
135 | */ | 136 | */ |
136 | static QString uidLabel(); | 137 | static QString uidLabel(); |
137 | 138 | ||
138 | /** | 139 | /** |
139 | Set name. | 140 | Set name. |
140 | */ | 141 | */ |
141 | void setName( const QString &name ); | 142 | void setName( const QString &name ); |
142 | /** | 143 | /** |
143 | Return name. | 144 | Return name. |
144 | */ | 145 | */ |
145 | QString name() const; | 146 | QString name() const; |
146 | /** | 147 | /** |
147 | Return translated label for name field. | 148 | Return translated label for name field. |
148 | */ | 149 | */ |
149 | static QString nameLabel(); | 150 | static QString nameLabel(); |
150 | 151 | ||
151 | /** | 152 | /** |
152 | Set formatted name. | 153 | Set formatted name. |
153 | */ | 154 | */ |
154 | void setFormattedName( const QString &formattedName ); | 155 | void setFormattedName( const QString &formattedName ); |
155 | /** | 156 | /** |
156 | Return formatted name. | 157 | Return formatted name. |
157 | */ | 158 | */ |
158 | QString formattedName() const; | 159 | QString formattedName() const; |
159 | /** | 160 | /** |
160 | Return translated label for formattedName field. | 161 | Return translated label for formattedName field. |
161 | */ | 162 | */ |
162 | static QString formattedNameLabel(); | 163 | static QString formattedNameLabel(); |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Set family name. | 166 | Set family name. |
166 | */ | 167 | */ |
167 | void setFamilyName( const QString &familyName ); | 168 | void setFamilyName( const QString &familyName ); |
168 | /** | 169 | /** |
169 | Return family name. | 170 | Return family name. |
170 | */ | 171 | */ |
171 | QString familyName() const; | 172 | QString familyName() const; |
172 | /** | 173 | /** |
173 | Return translated label for familyName field. | 174 | Return translated label for familyName field. |
174 | */ | 175 | */ |
175 | static QString familyNameLabel(); | 176 | static QString familyNameLabel(); |
176 | 177 | ||
177 | /** | 178 | /** |
178 | Set given name. | 179 | Set given name. |
179 | */ | 180 | */ |
180 | void setGivenName( const QString &givenName ); | 181 | void setGivenName( const QString &givenName ); |
181 | /** | 182 | /** |
182 | Return given name. | 183 | Return given name. |
183 | */ | 184 | */ |
184 | QString givenName() const; | 185 | QString givenName() const; |
185 | /** | 186 | /** |
186 | Return translated label for givenName field. | 187 | Return translated label for givenName field. |
187 | */ | 188 | */ |
188 | static QString givenNameLabel(); | 189 | static QString givenNameLabel(); |
189 | 190 | ||
190 | /** | 191 | /** |
191 | Set additional names. | 192 | Set additional names. |
192 | */ | 193 | */ |
193 | void setAdditionalName( const QString &additionalName ); | 194 | void setAdditionalName( const QString &additionalName ); |
194 | /** | 195 | /** |
195 | Return additional names. | 196 | Return additional names. |
196 | */ | 197 | */ |
197 | QString additionalName() const; | 198 | QString additionalName() const; |
198 | /** | 199 | /** |
199 | Return translated label for additionalName field. | 200 | Return translated label for additionalName field. |
200 | */ | 201 | */ |
201 | static QString additionalNameLabel(); | 202 | static QString additionalNameLabel(); |
202 | 203 | ||
203 | /** | 204 | /** |
204 | Set honorific prefixes. | 205 | Set honorific prefixes. |
205 | */ | 206 | */ |
206 | void setPrefix( const QString &prefix ); | 207 | void setPrefix( const QString &prefix ); |
207 | /** | 208 | /** |
208 | Return honorific prefixes. | 209 | Return honorific prefixes. |
209 | */ | 210 | */ |
210 | QString prefix() const; | 211 | QString prefix() const; |
211 | /** | 212 | /** |
212 | Return translated label for prefix field. | 213 | Return translated label for prefix field. |
213 | */ | 214 | */ |
214 | static QString prefixLabel(); | 215 | static QString prefixLabel(); |
215 | 216 | ||
216 | /** | 217 | /** |
217 | Set honorific suffixes. | 218 | Set honorific suffixes. |
218 | */ | 219 | */ |
219 | void setSuffix( const QString &suffix ); | 220 | void setSuffix( const QString &suffix ); |
220 | /** | 221 | /** |
221 | Return honorific suffixes. | 222 | Return honorific suffixes. |
222 | */ | 223 | */ |
223 | QString suffix() const; | 224 | QString suffix() const; |
224 | /** | 225 | /** |
225 | Return translated label for suffix field. | 226 | Return translated label for suffix field. |
226 | */ | 227 | */ |
227 | static QString suffixLabel(); | 228 | static QString suffixLabel(); |
228 | 229 | ||
229 | /** | 230 | /** |
230 | Set nick name. | 231 | Set nick name. |
231 | */ | 232 | */ |
232 | void setNickName( const QString &nickName ); | 233 | void setNickName( const QString &nickName ); |
233 | /** | 234 | /** |
234 | Return nick name. | 235 | Return nick name. |
235 | */ | 236 | */ |
236 | QString nickName() const; | 237 | QString nickName() const; |
237 | /** | 238 | /** |
238 | Return translated label for nickName field. | 239 | Return translated label for nickName field. |
239 | */ | 240 | */ |
240 | static QString nickNameLabel(); | 241 | static QString nickNameLabel(); |
241 | 242 | ||
242 | /** | 243 | /** |
243 | Set birthday. | 244 | Set birthday. |
244 | */ | 245 | */ |
245 | void setBirthday( const QDateTime &birthday ); | 246 | void setBirthday( const QDateTime &birthday ); |
246 | /** | 247 | /** |
247 | Return birthday. | 248 | Return birthday. |
248 | */ | 249 | */ |
249 | QDateTime birthday() const; | 250 | QDateTime birthday() const; |
250 | /** | 251 | /** |
251 | Return translated label for birthday field. | 252 | Return translated label for birthday field. |
252 | */ | 253 | */ |
253 | static QString birthdayLabel(); | 254 | static QString birthdayLabel(); |
254 | 255 | ||
255 | /** | 256 | /** |
256 | Return translated label for homeAddressStreet field. | 257 | Return translated label for homeAddressStreet field. |
257 | */ | 258 | */ |
258 | static QString homeAddressStreetLabel(); | 259 | static QString homeAddressStreetLabel(); |
259 | 260 | ||
260 | /** | 261 | /** |
261 | Return translated label for homeAddressLocality field. | 262 | Return translated label for homeAddressLocality field. |
262 | */ | 263 | */ |
263 | static QString homeAddressLocalityLabel(); | 264 | static QString homeAddressLocalityLabel(); |
264 | 265 | ||
265 | /** | 266 | /** |
266 | Return translated label for homeAddressRegion field. | 267 | Return translated label for homeAddressRegion field. |
267 | */ | 268 | */ |
268 | static QString homeAddressRegionLabel(); | 269 | static QString homeAddressRegionLabel(); |
269 | 270 | ||
270 | /** | 271 | /** |
271 | Return translated label for homeAddressPostalCode field. | 272 | Return translated label for homeAddressPostalCode field. |
272 | */ | 273 | */ |
273 | static QString homeAddressPostalCodeLabel(); | 274 | static QString homeAddressPostalCodeLabel(); |
274 | 275 | ||
275 | /** | 276 | /** |
276 | Return translated label for homeAddressCountry field. | 277 | Return translated label for homeAddressCountry field. |
277 | */ | 278 | */ |
278 | static QString homeAddressCountryLabel(); | 279 | static QString homeAddressCountryLabel(); |
279 | 280 | ||
280 | /** | 281 | /** |
281 | Return translated label for homeAddressLabel field. | 282 | Return translated label for homeAddressLabel field. |
282 | */ | 283 | */ |
283 | static QString homeAddressLabelLabel(); | 284 | static QString homeAddressLabelLabel(); |
284 | 285 | ||
285 | /** | 286 | /** |
286 | Return translated label for businessAddressStreet field. | 287 | Return translated label for businessAddressStreet field. |
287 | */ | 288 | */ |
288 | static QString businessAddressStreetLabel(); | 289 | static QString businessAddressStreetLabel(); |
289 | 290 | ||
290 | /** | 291 | /** |
291 | Return translated label for businessAddressLocality field. | 292 | Return translated label for businessAddressLocality field. |
292 | */ | 293 | */ |
293 | static QString businessAddressLocalityLabel(); | 294 | static QString businessAddressLocalityLabel(); |
294 | 295 | ||
295 | /** | 296 | /** |
296 | Return translated label for businessAddressRegion field. | 297 | Return translated label for businessAddressRegion field. |
297 | */ | 298 | */ |
298 | static QString businessAddressRegionLabel(); | 299 | static QString businessAddressRegionLabel(); |
299 | 300 | ||
300 | /** | 301 | /** |
301 | Return translated label for businessAddressPostalCode field. | 302 | Return translated label for businessAddressPostalCode field. |
302 | */ | 303 | */ |
303 | static QString businessAddressPostalCodeLabel(); | 304 | static QString businessAddressPostalCodeLabel(); |
304 | 305 | ||
305 | /** | 306 | /** |
306 | Return translated label for businessAddressCountry field. | 307 | Return translated label for businessAddressCountry field. |
307 | */ | 308 | */ |
308 | static QString businessAddressCountryLabel(); | 309 | static QString businessAddressCountryLabel(); |
309 | 310 | ||
310 | /** | 311 | /** |
311 | Return translated label for businessAddressLabel field. | 312 | Return translated label for businessAddressLabel field. |
312 | */ | 313 | */ |
313 | static QString businessAddressLabelLabel(); | 314 | static QString businessAddressLabelLabel(); |
314 | 315 | ||
315 | /** | 316 | /** |
316 | Return translated label for homePhone field. | 317 | Return translated label for homePhone field. |
317 | */ | 318 | */ |
318 | static QString homePhoneLabel(); | 319 | static QString homePhoneLabel(); |
319 | 320 | ||
320 | /** | 321 | /** |
321 | Return translated label for businessPhone field. | 322 | Return translated label for businessPhone field. |
322 | */ | 323 | */ |
323 | static QString businessPhoneLabel(); | 324 | static QString businessPhoneLabel(); |
324 | 325 | ||
325 | /** | 326 | /** |
326 | Return translated label for mobilePhone field. | 327 | Return translated label for mobilePhone field. |
327 | */ | 328 | */ |
328 | static QString mobilePhoneLabel(); | 329 | static QString mobilePhoneLabel(); |
329 | 330 | ||
330 | /** | 331 | /** |
331 | Return translated label for homeFax field. | 332 | Return translated label for homeFax field. |
332 | */ | 333 | */ |
333 | static QString homeFaxLabel(); | 334 | static QString homeFaxLabel(); |
334 | 335 | ||
335 | /** | 336 | /** |
336 | Return translated label for businessFax field. | 337 | Return translated label for businessFax field. |
337 | */ | 338 | */ |
338 | static QString businessFaxLabel(); | 339 | static QString businessFaxLabel(); |
339 | 340 | ||
340 | /** | 341 | /** |
341 | Return translated label for carPhone field. | 342 | Return translated label for carPhone field. |
342 | */ | 343 | */ |
343 | static QString carPhoneLabel(); | 344 | static QString carPhoneLabel(); |
344 | 345 | ||
345 | /** | 346 | /** |
346 | Return translated label for isdn field. | 347 | Return translated label for isdn field. |
347 | */ | 348 | */ |
348 | static QString isdnLabel(); | 349 | static QString isdnLabel(); |
349 | 350 | ||
350 | /** | 351 | /** |
351 | Return translated label for pager field. | 352 | Return translated label for pager field. |
352 | */ | 353 | */ |
353 | static QString pagerLabel(); | 354 | static QString pagerLabel(); |
354 | 355 | ||
355 | /** | 356 | /** |
356 | Return translated label for sip field. | 357 | Return translated label for sip field. |
357 | */ | 358 | */ |
358 | static QString sipLabel(); | 359 | static QString sipLabel(); |
359 | 360 | ||
360 | /** | 361 | /** |
361 | Return translated label for email field. | 362 | Return translated label for email field. |
362 | */ | 363 | */ |
363 | static QString emailLabel(); | 364 | static QString emailLabel(); |
364 | 365 | ||
365 | /** | 366 | /** |
366 | Set mail client. | 367 | Set mail client. |
367 | */ | 368 | */ |
368 | void setMailer( const QString &mailer ); | 369 | void setMailer( const QString &mailer ); |
369 | /** | 370 | /** |
370 | Return mail client. | 371 | Return mail client. |
371 | */ | 372 | */ |
372 | QString mailer() const; | 373 | QString mailer() const; |
373 | /** | 374 | /** |
374 | Return translated label for mailer field. | 375 | Return translated label for mailer field. |
375 | */ | 376 | */ |
376 | static QString mailerLabel(); | 377 | static QString mailerLabel(); |
377 | 378 | ||
378 | /** | 379 | /** |
379 | Set time zone. | 380 | Set time zone. |
380 | */ | 381 | */ |
381 | void setTimeZone( const TimeZone &timeZone ); | 382 | void setTimeZone( const TimeZone &timeZone ); |
382 | /** | 383 | /** |
383 | Return time zone. | 384 | Return time zone. |
384 | */ | 385 | */ |
385 | TimeZone timeZone() const; | 386 | TimeZone timeZone() const; |
386 | /** | 387 | /** |
387 | Return translated label for timeZone field. | 388 | Return translated label for timeZone field. |
388 | */ | 389 | */ |
389 | static QString timeZoneLabel(); | 390 | static QString timeZoneLabel(); |
390 | 391 | ||
391 | /** | 392 | /** |
392 | Set geographic position. | 393 | Set geographic position. |
393 | */ | 394 | */ |
394 | void setGeo( const Geo &geo ); | 395 | void setGeo( const Geo &geo ); |
395 | /** | 396 | /** |
396 | Return geographic position. | 397 | Return geographic position. |
397 | */ | 398 | */ |
398 | Geo geo() const; | 399 | Geo geo() const; |
399 | /** | 400 | /** |
400 | Return translated label for geo field. | 401 | Return translated label for geo field. |
401 | */ | 402 | */ |
402 | static QString geoLabel(); | 403 | static QString geoLabel(); |
403 | 404 | ||
404 | /** | 405 | /** |
405 | Set title. | 406 | Set title. |
406 | */ | 407 | */ |
407 | void setTitle( const QString &title ); | 408 | void setTitle( const QString &title ); |
408 | /** | 409 | /** |
409 | Return title. | 410 | Return title. |
410 | */ | 411 | */ |
411 | QString title() const; | 412 | QString title() const; |
412 | /** | 413 | /** |
413 | Return translated label for title field. | 414 | Return translated label for title field. |
414 | */ | 415 | */ |
415 | static QString titleLabel(); | 416 | static QString titleLabel(); |
416 | 417 | ||
417 | /** | 418 | /** |
418 | Set role. | 419 | Set role. |
419 | */ | 420 | */ |
420 | void setRole( const QString &role ); | 421 | void setRole( const QString &role ); |
421 | /** | 422 | /** |
422 | Return role. | 423 | Return role. |
423 | */ | 424 | */ |
424 | QString role() const; | 425 | QString role() const; |
425 | /** | 426 | /** |
426 | Return translated label for role field. | 427 | Return translated label for role field. |
427 | */ | 428 | */ |
428 | static QString roleLabel(); | 429 | static QString roleLabel(); |
429 | 430 | ||
430 | /** | 431 | /** |
431 | Set organization. | 432 | Set organization. |
432 | */ | 433 | */ |
433 | void setOrganization( const QString &organization ); | 434 | void setOrganization( const QString &organization ); |
434 | /** | 435 | /** |
435 | Return organization. | 436 | Return organization. |
436 | */ | 437 | */ |
437 | QString organization() const; | 438 | QString organization() const; |
438 | /** | 439 | /** |
439 | Return translated label for organization field. | 440 | Return translated label for organization field. |
440 | */ | 441 | */ |
441 | static QString organizationLabel(); | 442 | static QString organizationLabel(); |
442 | 443 | ||
443 | /** | 444 | /** |
444 | Set note. | 445 | Set note. |
445 | */ | 446 | */ |
446 | void setNote( const QString ¬e ); | 447 | void setNote( const QString ¬e ); |
447 | /** | 448 | /** |
448 | Return note. | 449 | Return note. |
449 | */ | 450 | */ |
450 | QString note() const; | 451 | QString note() const; |
451 | /** | 452 | /** |
452 | Return translated label for note field. | 453 | Return translated label for note field. |
453 | */ | 454 | */ |
454 | static QString noteLabel(); | 455 | static QString noteLabel(); |
455 | 456 | ||
456 | /** | 457 | /** |
457 | Set product identifier. | 458 | Set product identifier. |
458 | */ | 459 | */ |
459 | void setProductId( const QString &productId ); | 460 | void setProductId( const QString &productId ); |
460 | /** | 461 | /** |
461 | Return product identifier. | 462 | Return product identifier. |
462 | */ | 463 | */ |
463 | QString productId() const; | 464 | QString productId() const; |
464 | /** | 465 | /** |
465 | Return translated label for productId field. | 466 | Return translated label for productId field. |
466 | */ | 467 | */ |
467 | static QString productIdLabel(); | 468 | static QString productIdLabel(); |
468 | 469 | ||
469 | /** | 470 | /** |
470 | Set revision date. | 471 | Set revision date. |
471 | */ | 472 | */ |
472 | void setRevision( const QDateTime &revision ); | 473 | void setRevision( const QDateTime &revision ); |
473 | /** | 474 | /** |
474 | Return revision date. | 475 | Return revision date. |
475 | */ | 476 | */ |
476 | QDateTime revision() const; | 477 | QDateTime revision() const; |
477 | /** | 478 | /** |
478 | Return translated label for revision field. | 479 | Return translated label for revision field. |
479 | */ | 480 | */ |
480 | static QString revisionLabel(); | 481 | static QString revisionLabel(); |
481 | 482 | ||
482 | /** | 483 | /** |
483 | Set sort string. | 484 | Set sort string. |
484 | */ | 485 | */ |
485 | void setSortString( const QString &sortString ); | 486 | void setSortString( const QString &sortString ); |
486 | /** | 487 | /** |
487 | Return sort string. | 488 | Return sort string. |
488 | */ | 489 | */ |
489 | QString sortString() const; | 490 | QString sortString() const; |
490 | /** | 491 | /** |
491 | Return translated label for sortString field. | 492 | Return translated label for sortString field. |
492 | */ | 493 | */ |
493 | static QString sortStringLabel(); | 494 | static QString sortStringLabel(); |
494 | 495 | ||
495 | /** | 496 | /** |
496 | Set URL. | 497 | Set URL. |
497 | */ | 498 | */ |
498 | void setUrl( const KURL &url ); | 499 | void setUrl( const KURL &url ); |
499 | /** | 500 | /** |
500 | Return URL. | 501 | Return URL. |
501 | */ | 502 | */ |
502 | KURL url() const; | 503 | KURL url() const; |
503 | /** | 504 | /** |
504 | Return translated label for url field. | 505 | Return translated label for url field. |
505 | */ | 506 | */ |
506 | static QString urlLabel(); | 507 | static QString urlLabel(); |
507 | 508 | ||