summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-09-09 18:57:57 (UTC)
committer ulf69 <ulf69>2004-09-09 18:57:57 (UTC)
commit880518b6f1d4b06e3df45224c244d9c62f6fb7a9 (patch) (unidiff)
tree2b0b5a0c7e40481c31f29ff2bd98aa6abb4c6c90 /kabc
parent72860f2b84ba97de9223238d9fb97edc0804cc68 (diff)
downloadkdepimpi-880518b6f1d4b06e3df45224c244d9c62f6fb7a9.zip
kdepimpi-880518b6f1d4b06e3df45224c244d9c62f6fb7a9.tar.gz
kdepimpi-880518b6f1d4b06e3df45224c244d9c62f6fb7a9.tar.bz2
added sip type to phonnumbers
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp4
-rw-r--r--kabc/addressee.h5
-rw-r--r--kabc/field.cpp8
-rw-r--r--kabc/phonenumber.cpp4
-rw-r--r--kabc/phonenumber.h3
-rw-r--r--kabc/vcard21parser.cpp5
-rw-r--r--kabc/vcard21parser.h1
-rw-r--r--kabc/vcardformatimpl.cpp2
-rw-r--r--kabc/vcardparser/vcardtool.cpp1
9 files changed, 29 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index d484073..6b282e2 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -419,128 +419,132 @@ QString Addressee::businessAddressPostalCodeLabel()
419{ 419{
420 return i18n("Business Address Postal Code"); 420 return i18n("Business Address Postal Code");
421} 421}
422 422
423 423
424QString Addressee::businessAddressCountryLabel() 424QString Addressee::businessAddressCountryLabel()
425{ 425{
426 return i18n("Business Address Country"); 426 return i18n("Business Address Country");
427} 427}
428 428
429 429
430QString Addressee::businessAddressLabelLabel() 430QString Addressee::businessAddressLabelLabel()
431{ 431{
432 return i18n("Business Address Label"); 432 return i18n("Business Address Label");
433} 433}
434 434
435 435
436QString Addressee::homePhoneLabel() 436QString Addressee::homePhoneLabel()
437{ 437{
438 return i18n("Home Phone"); 438 return i18n("Home Phone");
439} 439}
440 440
441 441
442QString Addressee::businessPhoneLabel() 442QString Addressee::businessPhoneLabel()
443{ 443{
444 return i18n("Business Phone"); 444 return i18n("Business Phone");
445} 445}
446 446
447 447
448QString Addressee::mobilePhoneLabel() 448QString Addressee::mobilePhoneLabel()
449{ 449{
450 return i18n("Mobile Phone"); 450 return i18n("Mobile Phone");
451} 451}
452 452
453 453
454QString Addressee::homeFaxLabel() 454QString Addressee::homeFaxLabel()
455{ 455{
456 return i18n("Home Fax"); 456 return i18n("Home Fax");
457} 457}
458 458
459 459
460QString Addressee::businessFaxLabel() 460QString Addressee::businessFaxLabel()
461{ 461{
462 return i18n("Business Fax"); 462 return i18n("Business Fax");
463} 463}
464 464
465 465
466QString Addressee::carPhoneLabel() 466QString Addressee::carPhoneLabel()
467{ 467{
468 return i18n("Car Phone"); 468 return i18n("Car Phone");
469} 469}
470 470
471 471
472QString Addressee::isdnLabel() 472QString Addressee::isdnLabel()
473{ 473{
474 return i18n("ISDN"); 474 return i18n("ISDN");
475} 475}
476 476
477 477
478QString Addressee::pagerLabel() 478QString Addressee::pagerLabel()
479{ 479{
480 return i18n("Pager"); 480 return i18n("Pager");
481} 481}
482 482
483QString Addressee::sipLabel()
484{
485 return i18n("SIP");
486}
483 487
484QString Addressee::emailLabel() 488QString Addressee::emailLabel()
485{ 489{
486 return i18n("Email Address"); 490 return i18n("Email Address");
487} 491}
488 492
489 493
490void Addressee::setMailer( const QString &mailer ) 494void Addressee::setMailer( const QString &mailer )
491{ 495{
492 if ( mailer == mData->mailer ) return; 496 if ( mailer == mData->mailer ) return;
493 detach(); 497 detach();
494 mData->empty = false; 498 mData->empty = false;
495 mData->mailer = mailer; 499 mData->mailer = mailer;
496} 500}
497 501
498QString Addressee::mailer() const 502QString Addressee::mailer() const
499{ 503{
500 return mData->mailer; 504 return mData->mailer;
501} 505}
502 506
503QString Addressee::mailerLabel() 507QString Addressee::mailerLabel()
504{ 508{
505 return i18n("Mail Client"); 509 return i18n("Mail Client");
506} 510}
507 511
508 512
509void Addressee::setTimeZone( const TimeZone &timeZone ) 513void Addressee::setTimeZone( const TimeZone &timeZone )
510{ 514{
511 if ( timeZone == mData->timeZone ) return; 515 if ( timeZone == mData->timeZone ) return;
512 detach(); 516 detach();
513 mData->empty = false; 517 mData->empty = false;
514 mData->timeZone = timeZone; 518 mData->timeZone = timeZone;
515} 519}
516 520
517TimeZone Addressee::timeZone() const 521TimeZone Addressee::timeZone() const
518{ 522{
519 return mData->timeZone; 523 return mData->timeZone;
520} 524}
521 525
522QString Addressee::timeZoneLabel() 526QString Addressee::timeZoneLabel()
523{ 527{
524 return i18n("Time Zone"); 528 return i18n("Time Zone");
525} 529}
526 530
527 531
528void Addressee::setGeo( const Geo &geo ) 532void Addressee::setGeo( const Geo &geo )
529{ 533{
530 if ( geo == mData->geo ) return; 534 if ( geo == mData->geo ) return;
531 detach(); 535 detach();
532 mData->empty = false; 536 mData->empty = false;
533 mData->geo = geo; 537 mData->geo = geo;
534} 538}
535 539
536Geo Addressee::geo() const 540Geo Addressee::geo() const
537{ 541{
538 return mData->geo; 542 return mData->geo;
539} 543}
540 544
541QString Addressee::geoLabel() 545QString Addressee::geoLabel()
542{ 546{
543 return i18n("Geographic Position"); 547 return i18n("Geographic Position");
544} 548}
545 549
546 550
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 393d1cc..27782f9 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -272,128 +272,133 @@ class Addressee
272 */ 272 */
273 static QString businessAddressLocalityLabel(); 273 static QString businessAddressLocalityLabel();
274 274
275 /** 275 /**
276 Return translated label for businessAddressRegion field. 276 Return translated label for businessAddressRegion field.
277 */ 277 */
278 static QString businessAddressRegionLabel(); 278 static QString businessAddressRegionLabel();
279 279
280 /** 280 /**
281 Return translated label for businessAddressPostalCode field. 281 Return translated label for businessAddressPostalCode field.
282 */ 282 */
283 static QString businessAddressPostalCodeLabel(); 283 static QString businessAddressPostalCodeLabel();
284 284
285 /** 285 /**
286 Return translated label for businessAddressCountry field. 286 Return translated label for businessAddressCountry field.
287 */ 287 */
288 static QString businessAddressCountryLabel(); 288 static QString businessAddressCountryLabel();
289 289
290 /** 290 /**
291 Return translated label for businessAddressLabel field. 291 Return translated label for businessAddressLabel field.
292 */ 292 */
293 static QString businessAddressLabelLabel(); 293 static QString businessAddressLabelLabel();
294 294
295 /** 295 /**
296 Return translated label for homePhone field. 296 Return translated label for homePhone field.
297 */ 297 */
298 static QString homePhoneLabel(); 298 static QString homePhoneLabel();
299 299
300 /** 300 /**
301 Return translated label for businessPhone field. 301 Return translated label for businessPhone field.
302 */ 302 */
303 static QString businessPhoneLabel(); 303 static QString businessPhoneLabel();
304 304
305 /** 305 /**
306 Return translated label for mobilePhone field. 306 Return translated label for mobilePhone field.
307 */ 307 */
308 static QString mobilePhoneLabel(); 308 static QString mobilePhoneLabel();
309 309
310 /** 310 /**
311 Return translated label for homeFax field. 311 Return translated label for homeFax field.
312 */ 312 */
313 static QString homeFaxLabel(); 313 static QString homeFaxLabel();
314 314
315 /** 315 /**
316 Return translated label for businessFax field. 316 Return translated label for businessFax field.
317 */ 317 */
318 static QString businessFaxLabel(); 318 static QString businessFaxLabel();
319 319
320 /** 320 /**
321 Return translated label for carPhone field. 321 Return translated label for carPhone field.
322 */ 322 */
323 static QString carPhoneLabel(); 323 static QString carPhoneLabel();
324 324
325 /** 325 /**
326 Return translated label for isdn field. 326 Return translated label for isdn field.
327 */ 327 */
328 static QString isdnLabel(); 328 static QString isdnLabel();
329 329
330 /** 330 /**
331 Return translated label for pager field. 331 Return translated label for pager field.
332 */ 332 */
333 static QString pagerLabel(); 333 static QString pagerLabel();
334 334
335 /** 335 /**
336 Return translated label for sip field.
337 */
338 static QString sipLabel();
339
340 /**
336 Return translated label for email field. 341 Return translated label for email field.
337 */ 342 */
338 static QString emailLabel(); 343 static QString emailLabel();
339 344
340 /** 345 /**
341 Set mail client. 346 Set mail client.
342 */ 347 */
343 void setMailer( const QString &mailer ); 348 void setMailer( const QString &mailer );
344 /** 349 /**
345 Return mail client. 350 Return mail client.
346 */ 351 */
347 QString mailer() const; 352 QString mailer() const;
348 /** 353 /**
349 Return translated label for mailer field. 354 Return translated label for mailer field.
350 */ 355 */
351 static QString mailerLabel(); 356 static QString mailerLabel();
352 357
353 /** 358 /**
354 Set time zone. 359 Set time zone.
355 */ 360 */
356 void setTimeZone( const TimeZone &timeZone ); 361 void setTimeZone( const TimeZone &timeZone );
357 /** 362 /**
358 Return time zone. 363 Return time zone.
359 */ 364 */
360 TimeZone timeZone() const; 365 TimeZone timeZone() const;
361 /** 366 /**
362 Return translated label for timeZone field. 367 Return translated label for timeZone field.
363 */ 368 */
364 static QString timeZoneLabel(); 369 static QString timeZoneLabel();
365 370
366 /** 371 /**
367 Set geographic position. 372 Set geographic position.
368 */ 373 */
369 void setGeo( const Geo &geo ); 374 void setGeo( const Geo &geo );
370 /** 375 /**
371 Return geographic position. 376 Return geographic position.
372 */ 377 */
373 Geo geo() const; 378 Geo geo() const;
374 /** 379 /**
375 Return translated label for geo field. 380 Return translated label for geo field.
376 */ 381 */
377 static QString geoLabel(); 382 static QString geoLabel();
378 383
379 /** 384 /**
380 Set title. 385 Set title.
381 */ 386 */
382 void setTitle( const QString &title ); 387 void setTitle( const QString &title );
383 /** 388 /**
384 Return title. 389 Return title.
385 */ 390 */
386 QString title() const; 391 QString title() const;
387 /** 392 /**
388 Return translated label for title field. 393 Return translated label for title field.
389 */ 394 */
390 static QString titleLabel(); 395 static QString titleLabel();
391 396
392 /** 397 /**
393 Set role. 398 Set role.
394 */ 399 */
395 void setRole( const QString &role ); 400 void setRole( const QString &role );
396 /** 401 /**
397 Return role. 402 Return role.
398 */ 403 */
399 QString role() const; 404 QString role() const;
diff --git a/kabc/field.cpp b/kabc/field.cpp
index e27970e..d95cd19 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -23,462 +23,468 @@
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kconfigbase.h> 31#include <kconfigbase.h>
32#include <kglobal.h> 32#include <kglobal.h>
33 33
34#include "field.h" 34#include "field.h"
35#include "resource.h" 35#include "resource.h"
36 36
37using namespace KABC; 37using namespace KABC;
38 38
39class Field::FieldImpl 39class Field::FieldImpl
40{ 40{
41 public: 41 public:
42 FieldImpl( int fieldId, int category = 0, 42 FieldImpl( int fieldId, int category = 0,
43 const QString &label = QString::null, 43 const QString &label = QString::null,
44 const QString &key = QString::null, 44 const QString &key = QString::null,
45 const QString &app = QString::null ) 45 const QString &app = QString::null )
46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ), 46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
47 mKey( key ), mApp( app ) {} 47 mKey( key ), mApp( app ) {}
48 48
49 enum FieldId 49 enum FieldId
50 { 50 {
51 CustomField, 51 CustomField,
52 FormattedName, 52 FormattedName,
53 FamilyName, 53 FamilyName,
54 GivenName, 54 GivenName,
55 AdditionalName, 55 AdditionalName,
56 Prefix, 56 Prefix,
57 Suffix, 57 Suffix,
58 NickName, 58 NickName,
59 Birthday, 59 Birthday,
60 HomeAddressStreet, 60 HomeAddressStreet,
61 HomeAddressLocality, 61 HomeAddressLocality,
62 HomeAddressRegion, 62 HomeAddressRegion,
63 HomeAddressPostalCode, 63 HomeAddressPostalCode,
64 HomeAddressCountry, 64 HomeAddressCountry,
65 HomeAddressLabel, 65 HomeAddressLabel,
66 BusinessAddressStreet, 66 BusinessAddressStreet,
67 BusinessAddressLocality, 67 BusinessAddressLocality,
68 BusinessAddressRegion, 68 BusinessAddressRegion,
69 BusinessAddressPostalCode, 69 BusinessAddressPostalCode,
70 BusinessAddressCountry, 70 BusinessAddressCountry,
71 BusinessAddressLabel, 71 BusinessAddressLabel,
72 HomePhone, 72 HomePhone,
73 BusinessPhone, 73 BusinessPhone,
74 MobilePhone, 74 MobilePhone,
75 HomeFax, 75 HomeFax,
76 BusinessFax, 76 BusinessFax,
77 CarPhone, 77 CarPhone,
78 Isdn, 78 Isdn,
79 Pager, 79 Pager,
80 Email, 80 Email,
81 Mailer, 81 Mailer,
82 Title, 82 Title,
83 Role, 83 Role,
84 Organization, 84 Organization,
85 Note, 85 Note,
86 Url, 86 Url,
87 Resource 87 Resource,
88 Sip
88 }; 89 };
89 90
90 int fieldId() { return mFieldId; } 91 int fieldId() { return mFieldId; }
91 int category() { return mCategory; } 92 int category() { return mCategory; }
92 93
93 QString label() { return mLabel; } 94 QString label() { return mLabel; }
94 QString key() { return mKey; } 95 QString key() { return mKey; }
95 QString app() { return mApp; } 96 QString app() { return mApp; }
96 97
97 private: 98 private:
98 int mFieldId; 99 int mFieldId;
99 int mCategory; 100 int mCategory;
100 101
101 QString mLabel; 102 QString mLabel;
102 QString mKey; 103 QString mKey;
103 QString mApp; 104 QString mApp;
104}; 105};
105 106
106 107
107Field::List Field::mAllFields; 108Field::List Field::mAllFields;
108Field::List Field::mDefaultFields; 109Field::List Field::mDefaultFields;
109Field::List Field::mCustomFields; 110Field::List Field::mCustomFields;
110 111
111 112
112Field::Field( FieldImpl *impl ) 113Field::Field( FieldImpl *impl )
113{ 114{
114 mImpl = impl; 115 mImpl = impl;
115} 116}
116 117
117Field::~Field() 118Field::~Field()
118{ 119{
119 delete mImpl; 120 delete mImpl;
120} 121}
121 122
122QString Field::label() 123QString Field::label()
123{ 124{
124 switch ( mImpl->fieldId() ) { 125 switch ( mImpl->fieldId() ) {
125 case FieldImpl::FormattedName: 126 case FieldImpl::FormattedName:
126 return Addressee::formattedNameLabel(); 127 return Addressee::formattedNameLabel();
127 case FieldImpl::FamilyName: 128 case FieldImpl::FamilyName:
128 return Addressee::familyNameLabel(); 129 return Addressee::familyNameLabel();
129 case FieldImpl::GivenName: 130 case FieldImpl::GivenName:
130 return Addressee::givenNameLabel(); 131 return Addressee::givenNameLabel();
131 case FieldImpl::AdditionalName: 132 case FieldImpl::AdditionalName:
132 return Addressee::additionalNameLabel(); 133 return Addressee::additionalNameLabel();
133 case FieldImpl::Prefix: 134 case FieldImpl::Prefix:
134 return Addressee::prefixLabel(); 135 return Addressee::prefixLabel();
135 case FieldImpl::Suffix: 136 case FieldImpl::Suffix:
136 return Addressee::suffixLabel(); 137 return Addressee::suffixLabel();
137 case FieldImpl::NickName: 138 case FieldImpl::NickName:
138 return Addressee::nickNameLabel(); 139 return Addressee::nickNameLabel();
139 case FieldImpl::Birthday: 140 case FieldImpl::Birthday:
140 return Addressee::birthdayLabel(); 141 return Addressee::birthdayLabel();
141 case FieldImpl::HomeAddressStreet: 142 case FieldImpl::HomeAddressStreet:
142 return Addressee::homeAddressStreetLabel(); 143 return Addressee::homeAddressStreetLabel();
143 case FieldImpl::HomeAddressLocality: 144 case FieldImpl::HomeAddressLocality:
144 return Addressee::homeAddressLocalityLabel(); 145 return Addressee::homeAddressLocalityLabel();
145 case FieldImpl::HomeAddressRegion: 146 case FieldImpl::HomeAddressRegion:
146 return Addressee::homeAddressRegionLabel(); 147 return Addressee::homeAddressRegionLabel();
147 case FieldImpl::HomeAddressPostalCode: 148 case FieldImpl::HomeAddressPostalCode:
148 return Addressee::homeAddressPostalCodeLabel(); 149 return Addressee::homeAddressPostalCodeLabel();
149 case FieldImpl::HomeAddressCountry: 150 case FieldImpl::HomeAddressCountry:
150 return Addressee::homeAddressCountryLabel(); 151 return Addressee::homeAddressCountryLabel();
151 case FieldImpl::HomeAddressLabel: 152 case FieldImpl::HomeAddressLabel:
152 return Addressee::homeAddressLabelLabel(); 153 return Addressee::homeAddressLabelLabel();
153 case FieldImpl::BusinessAddressStreet: 154 case FieldImpl::BusinessAddressStreet:
154 return Addressee::businessAddressStreetLabel(); 155 return Addressee::businessAddressStreetLabel();
155 case FieldImpl::BusinessAddressLocality: 156 case FieldImpl::BusinessAddressLocality:
156 return Addressee::businessAddressLocalityLabel(); 157 return Addressee::businessAddressLocalityLabel();
157 case FieldImpl::BusinessAddressRegion: 158 case FieldImpl::BusinessAddressRegion:
158 return Addressee::businessAddressRegionLabel(); 159 return Addressee::businessAddressRegionLabel();
159 case FieldImpl::BusinessAddressPostalCode: 160 case FieldImpl::BusinessAddressPostalCode:
160 return Addressee::businessAddressPostalCodeLabel(); 161 return Addressee::businessAddressPostalCodeLabel();
161 case FieldImpl::BusinessAddressCountry: 162 case FieldImpl::BusinessAddressCountry:
162 return Addressee::businessAddressCountryLabel(); 163 return Addressee::businessAddressCountryLabel();
163 case FieldImpl::BusinessAddressLabel: 164 case FieldImpl::BusinessAddressLabel:
164 return Addressee::businessAddressLabelLabel(); 165 return Addressee::businessAddressLabelLabel();
165 case FieldImpl::HomePhone: 166 case FieldImpl::HomePhone:
166 return Addressee::homePhoneLabel(); 167 return Addressee::homePhoneLabel();
167 case FieldImpl::BusinessPhone: 168 case FieldImpl::BusinessPhone:
168 return Addressee::businessPhoneLabel(); 169 return Addressee::businessPhoneLabel();
169 case FieldImpl::MobilePhone: 170 case FieldImpl::MobilePhone:
170 return Addressee::mobilePhoneLabel(); 171 return Addressee::mobilePhoneLabel();
171 case FieldImpl::HomeFax: 172 case FieldImpl::HomeFax:
172 return Addressee::homeFaxLabel(); 173 return Addressee::homeFaxLabel();
173 case FieldImpl::BusinessFax: 174 case FieldImpl::BusinessFax:
174 return Addressee::businessFaxLabel(); 175 return Addressee::businessFaxLabel();
175 case FieldImpl::CarPhone: 176 case FieldImpl::CarPhone:
176 return Addressee::carPhoneLabel(); 177 return Addressee::carPhoneLabel();
177 case FieldImpl::Isdn: 178 case FieldImpl::Isdn:
178 return Addressee::isdnLabel(); 179 return Addressee::isdnLabel();
179 case FieldImpl::Pager: 180 case FieldImpl::Pager:
180 return Addressee::pagerLabel(); 181 return Addressee::pagerLabel();
181 case FieldImpl::Email: 182 case FieldImpl::Email:
182 return Addressee::emailLabel(); 183 return Addressee::emailLabel();
183 case FieldImpl::Mailer: 184 case FieldImpl::Mailer:
184 return Addressee::mailerLabel(); 185 return Addressee::mailerLabel();
185 case FieldImpl::Title: 186 case FieldImpl::Title:
186 return Addressee::titleLabel(); 187 return Addressee::titleLabel();
187 case FieldImpl::Role: 188 case FieldImpl::Role:
188 return Addressee::roleLabel(); 189 return Addressee::roleLabel();
189 case FieldImpl::Organization: 190 case FieldImpl::Organization:
190 return Addressee::organizationLabel(); 191 return Addressee::organizationLabel();
191 case FieldImpl::Note: 192 case FieldImpl::Note:
192 return Addressee::noteLabel(); 193 return Addressee::noteLabel();
193 case FieldImpl::Url: 194 case FieldImpl::Url:
194 return Addressee::urlLabel(); 195 return Addressee::urlLabel();
195 case FieldImpl::Resource: 196 case FieldImpl::Resource:
196 return Addressee::resourceLabel(); 197 return Addressee::resourceLabel();
198 case FieldImpl::Sip:
199 return Addressee::sipLabel();
197 case FieldImpl::CustomField: 200 case FieldImpl::CustomField:
198 return mImpl->label(); 201 return mImpl->label();
199 default: 202 default:
200 return i18n("Unknown Field"); 203 return i18n("Unknown Field");
201 } 204 }
202} 205}
203 206
204int Field::category() 207int Field::category()
205{ 208{
206 return mImpl->category(); 209 return mImpl->category();
207} 210}
208 211
209QString Field::categoryLabel( int category ) 212QString Field::categoryLabel( int category )
210{ 213{
211 switch ( category ) { 214 switch ( category ) {
212 case All: 215 case All:
213 return i18n("All"); 216 return i18n("All");
214 case Frequent: 217 case Frequent:
215 return i18n("Frequent"); 218 return i18n("Frequent");
216 case Address: 219 case Address:
217 return i18n("Address"); 220 return i18n("Address");
218 case Email: 221 case Email:
219 return i18n("Email"); 222 return i18n("Email");
220 case Personal: 223 case Personal:
221 return i18n("Personal"); 224 return i18n("Personal");
222 case Organization: 225 case Organization:
223 return i18n("Organization"); 226 return i18n("Organization");
224 case CustomCategory: 227 case CustomCategory:
225 return i18n("Custom"); 228 return i18n("Custom");
226 default: 229 default:
227 return i18n("Undefined"); 230 return i18n("Undefined");
228 } 231 }
229} 232}
230 233
231QString Field::value( const KABC::Addressee &a ) 234QString Field::value( const KABC::Addressee &a )
232{ 235{
233 switch ( mImpl->fieldId() ) { 236 switch ( mImpl->fieldId() ) {
234 case FieldImpl::FormattedName: 237 case FieldImpl::FormattedName:
235 return a.formattedName(); 238 return a.formattedName();
236 case FieldImpl::FamilyName: 239 case FieldImpl::FamilyName:
237 return a.familyName(); 240 return a.familyName();
238 case FieldImpl::GivenName: 241 case FieldImpl::GivenName:
239 return a.givenName(); 242 return a.givenName();
240 case FieldImpl::AdditionalName: 243 case FieldImpl::AdditionalName:
241 return a.additionalName(); 244 return a.additionalName();
242 case FieldImpl::Prefix: 245 case FieldImpl::Prefix:
243 return a.prefix(); 246 return a.prefix();
244 case FieldImpl::Suffix: 247 case FieldImpl::Suffix:
245 return a.suffix(); 248 return a.suffix();
246 case FieldImpl::NickName: 249 case FieldImpl::NickName:
247 return a.nickName(); 250 return a.nickName();
248 case FieldImpl::Mailer: 251 case FieldImpl::Mailer:
249 return a.mailer(); 252 return a.mailer();
250 case FieldImpl::Title: 253 case FieldImpl::Title:
251 return a.title(); 254 return a.title();
252 case FieldImpl::Role: 255 case FieldImpl::Role:
253 return a.role(); 256 return a.role();
254 case FieldImpl::Organization: 257 case FieldImpl::Organization:
255 return a.organization(); 258 return a.organization();
256 case FieldImpl::Note: 259 case FieldImpl::Note:
257 return a.note(); 260 return a.note();
258 case FieldImpl::Email: 261 case FieldImpl::Email:
259 return a.preferredEmail(); 262 return a.preferredEmail();
260 case FieldImpl::Birthday: 263 case FieldImpl::Birthday:
261 if ( a.birthday().isValid() ) { 264 if ( a.birthday().isValid() ) {
262//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 265//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
263// But Qt::IsoDate was not specified. 266// But Qt::IsoDate was not specified.
264// QString _oldFormat = KGlobal::locale()->dateFormat(); 267// QString _oldFormat = KGlobal::locale()->dateFormat();
265// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 268// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
266 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); 269 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
267// KGlobal::locale()->setDateFormat(_oldFormat); 270// KGlobal::locale()->setDateFormat(_oldFormat);
268 return dt; 271 return dt;
269 } 272 }
270 else 273 else
271 return QString::null; 274 return QString::null;
272 case FieldImpl::Url: 275 case FieldImpl::Url:
273 return a.url().prettyURL(); 276 return a.url().prettyURL();
274//US 277//US
275 case FieldImpl::Resource: 278 case FieldImpl::Resource:
276 return a.resource()->resourceName(); 279 return a.resource()->resourceName();
277 case FieldImpl::HomePhone: 280 case FieldImpl::HomePhone:
278 return a.phoneNumber( PhoneNumber::Home ).number(); 281 return a.phoneNumber( PhoneNumber::Home ).number();
279 case FieldImpl::BusinessPhone: 282 case FieldImpl::BusinessPhone:
280 return a.phoneNumber( PhoneNumber::Work ).number(); 283 return a.phoneNumber( PhoneNumber::Work ).number();
281 case FieldImpl::MobilePhone: 284 case FieldImpl::MobilePhone:
282 return a.phoneNumber( PhoneNumber::Cell ).number(); 285 return a.phoneNumber( PhoneNumber::Cell ).number();
283 case FieldImpl::HomeFax: 286 case FieldImpl::HomeFax:
284 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 287 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
285 case FieldImpl::BusinessFax: 288 case FieldImpl::BusinessFax:
286 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 289 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
287 case FieldImpl::CarPhone: 290 case FieldImpl::CarPhone:
288 return a.phoneNumber( PhoneNumber::Car ).number(); 291 return a.phoneNumber( PhoneNumber::Car ).number();
289 case FieldImpl::Isdn: 292 case FieldImpl::Isdn:
290 return a.phoneNumber( PhoneNumber::Isdn ).number(); 293 return a.phoneNumber( PhoneNumber::Isdn ).number();
291 case FieldImpl::Pager: 294 case FieldImpl::Pager:
292 return a.phoneNumber( PhoneNumber::Pager ).number(); 295 return a.phoneNumber( PhoneNumber::Pager ).number();
296 case FieldImpl::Sip:
297 return a.phoneNumber( PhoneNumber::Sip ).number();
293 case FieldImpl::HomeAddressStreet: 298 case FieldImpl::HomeAddressStreet:
294 return a.address( Address::Home ).street(); 299 return a.address( Address::Home ).street();
295 case FieldImpl::HomeAddressLocality: 300 case FieldImpl::HomeAddressLocality:
296 return a.address( Address::Home ).locality(); 301 return a.address( Address::Home ).locality();
297 case FieldImpl::HomeAddressRegion: 302 case FieldImpl::HomeAddressRegion:
298 return a.address( Address::Home ).region(); 303 return a.address( Address::Home ).region();
299 case FieldImpl::HomeAddressPostalCode: 304 case FieldImpl::HomeAddressPostalCode:
300 return a.address( Address::Home ).postalCode(); 305 return a.address( Address::Home ).postalCode();
301 case FieldImpl::HomeAddressCountry: 306 case FieldImpl::HomeAddressCountry:
302 return a.address( Address::Home ).country(); 307 return a.address( Address::Home ).country();
303 case FieldImpl::BusinessAddressStreet: 308 case FieldImpl::BusinessAddressStreet:
304 return a.address( Address::Work ).street(); 309 return a.address( Address::Work ).street();
305 case FieldImpl::BusinessAddressLocality: 310 case FieldImpl::BusinessAddressLocality:
306 return a.address( Address::Work ).locality(); 311 return a.address( Address::Work ).locality();
307 case FieldImpl::BusinessAddressRegion: 312 case FieldImpl::BusinessAddressRegion:
308 return a.address( Address::Work ).region(); 313 return a.address( Address::Work ).region();
309 case FieldImpl::BusinessAddressPostalCode: 314 case FieldImpl::BusinessAddressPostalCode:
310 return a.address( Address::Work ).postalCode(); 315 return a.address( Address::Work ).postalCode();
311 case FieldImpl::BusinessAddressCountry: 316 case FieldImpl::BusinessAddressCountry:
312 return a.address( Address::Work ).country(); 317 return a.address( Address::Work ).country();
313 case FieldImpl::CustomField: 318 case FieldImpl::CustomField:
314 return a.custom( mImpl->app(), mImpl->key() ); 319 return a.custom( mImpl->app(), mImpl->key() );
315 default: 320 default:
316 return QString::null; 321 return QString::null;
317 } 322 }
318} 323}
319 324
320bool Field::setValue( KABC::Addressee &a, const QString &value ) 325bool Field::setValue( KABC::Addressee &a, const QString &value )
321{ 326{
322 switch ( mImpl->fieldId() ) { 327 switch ( mImpl->fieldId() ) {
323 case FieldImpl::FormattedName: 328 case FieldImpl::FormattedName:
324 a.setFormattedName( value ); 329 a.setFormattedName( value );
325 return true; 330 return true;
326 case FieldImpl::FamilyName: 331 case FieldImpl::FamilyName:
327 a.setFamilyName( value ); 332 a.setFamilyName( value );
328 return true; 333 return true;
329 case FieldImpl::GivenName: 334 case FieldImpl::GivenName:
330 a.setGivenName( value ); 335 a.setGivenName( value );
331 return true; 336 return true;
332 case FieldImpl::AdditionalName: 337 case FieldImpl::AdditionalName:
333 a.setAdditionalName( value ); 338 a.setAdditionalName( value );
334 return true; 339 return true;
335 case FieldImpl::Prefix: 340 case FieldImpl::Prefix:
336 a.setPrefix( value ); 341 a.setPrefix( value );
337 return true; 342 return true;
338 case FieldImpl::Suffix: 343 case FieldImpl::Suffix:
339 a.setSuffix( value ); 344 a.setSuffix( value );
340 return true; 345 return true;
341 case FieldImpl::NickName: 346 case FieldImpl::NickName:
342 a.setNickName( value ); 347 a.setNickName( value );
343 return true; 348 return true;
344 case FieldImpl::Mailer: 349 case FieldImpl::Mailer:
345 a.setMailer( value ); 350 a.setMailer( value );
346 return true; 351 return true;
347 case FieldImpl::Title: 352 case FieldImpl::Title:
348 a.setTitle( value ); 353 a.setTitle( value );
349 return true; 354 return true;
350 case FieldImpl::Role: 355 case FieldImpl::Role:
351 a.setRole( value ); 356 a.setRole( value );
352 return true; 357 return true;
353 case FieldImpl::Organization: 358 case FieldImpl::Organization:
354 a.setOrganization( value ); 359 a.setOrganization( value );
355 return true; 360 return true;
356 case FieldImpl::Note: 361 case FieldImpl::Note:
357 a.setNote( value ); 362 a.setNote( value );
358 return true; 363 return true;
359 case FieldImpl::Birthday: 364 case FieldImpl::Birthday:
360//US 365//US
361//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 366//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
362// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 367// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
363 { 368 {
364 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate 369 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
365 a.setBirthday(dt); 370 a.setBirthday(dt);
366 } 371 }
367 return true; 372 return true;
368 case FieldImpl::CustomField: 373 case FieldImpl::CustomField:
369 a.insertCustom( mImpl->app(), mImpl->key(), value ); 374 a.insertCustom( mImpl->app(), mImpl->key(), value );
370//US never copy the resourcename back to the adressee. 375//US never copy the resourcename back to the adressee.
371 case FieldImpl::Resource: 376 case FieldImpl::Resource:
372 default: 377 default:
373 return false; 378 return false;
374 } 379 }
375} 380}
376 381
377bool Field::isCustom() 382bool Field::isCustom()
378{ 383{
379 return mImpl->fieldId() == FieldImpl::CustomField; 384 return mImpl->fieldId() == FieldImpl::CustomField;
380} 385}
381 386
382Field::List Field::allFields() 387Field::List Field::allFields()
383{ 388{
384 if ( mAllFields.isEmpty() ) { 389 if ( mAllFields.isEmpty() ) {
385 createField( FieldImpl::FormattedName, Frequent ); 390 createField( FieldImpl::FormattedName, Frequent );
386 createField( FieldImpl::FamilyName, Frequent ); 391 createField( FieldImpl::FamilyName, Frequent );
387 createField( FieldImpl::GivenName, Frequent ); 392 createField( FieldImpl::GivenName, Frequent );
388 createField( FieldImpl::AdditionalName ); 393 createField( FieldImpl::AdditionalName );
389 createField( FieldImpl::Prefix ); 394 createField( FieldImpl::Prefix );
390 createField( FieldImpl::Suffix ); 395 createField( FieldImpl::Suffix );
391 createField( FieldImpl::NickName, Personal ); 396 createField( FieldImpl::NickName, Personal );
392 createField( FieldImpl::Birthday, Personal ); 397 createField( FieldImpl::Birthday, Personal );
393 createField( FieldImpl::HomeAddressStreet, Address|Personal ); 398 createField( FieldImpl::HomeAddressStreet, Address|Personal );
394 createField( FieldImpl::HomeAddressLocality, Address|Personal ); 399 createField( FieldImpl::HomeAddressLocality, Address|Personal );
395 createField( FieldImpl::HomeAddressRegion, Address|Personal ); 400 createField( FieldImpl::HomeAddressRegion, Address|Personal );
396 createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); 401 createField( FieldImpl::HomeAddressPostalCode, Address|Personal );
397 createField( FieldImpl::HomeAddressCountry, Address|Personal ); 402 createField( FieldImpl::HomeAddressCountry, Address|Personal );
398 createField( FieldImpl::HomeAddressLabel, Address|Personal ); 403 createField( FieldImpl::HomeAddressLabel, Address|Personal );
399 createField( FieldImpl::BusinessAddressStreet, Address|Organization ); 404 createField( FieldImpl::BusinessAddressStreet, Address|Organization );
400 createField( FieldImpl::BusinessAddressLocality, Address|Organization ); 405 createField( FieldImpl::BusinessAddressLocality, Address|Organization );
401 createField( FieldImpl::BusinessAddressRegion, Address|Organization ); 406 createField( FieldImpl::BusinessAddressRegion, Address|Organization );
402 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); 407 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization );
403 createField( FieldImpl::BusinessAddressCountry, Address|Organization ); 408 createField( FieldImpl::BusinessAddressCountry, Address|Organization );
404 createField( FieldImpl::BusinessAddressLabel, Address|Organization ); 409 createField( FieldImpl::BusinessAddressLabel, Address|Organization );
405 createField( FieldImpl::HomePhone, Personal|Frequent ); 410 createField( FieldImpl::HomePhone, Personal|Frequent );
406 createField( FieldImpl::BusinessPhone, Organization|Frequent ); 411 createField( FieldImpl::BusinessPhone, Organization|Frequent );
407 createField( FieldImpl::MobilePhone, Frequent ); 412 createField( FieldImpl::MobilePhone, Frequent );
408 createField( FieldImpl::HomeFax ); 413 createField( FieldImpl::HomeFax );
409 createField( FieldImpl::BusinessFax ); 414 createField( FieldImpl::BusinessFax );
410 createField( FieldImpl::CarPhone ); 415 createField( FieldImpl::CarPhone );
411 createField( FieldImpl::Isdn ); 416 createField( FieldImpl::Isdn );
412 createField( FieldImpl::Pager ); 417 createField( FieldImpl::Pager );
413 createField( FieldImpl::Email, Email|Frequent ); 418 createField( FieldImpl::Email, Email|Frequent );
414 createField( FieldImpl::Mailer, Email ); 419 createField( FieldImpl::Mailer, Email );
415 createField( FieldImpl::Title, Organization ); 420 createField( FieldImpl::Title, Organization );
416 createField( FieldImpl::Role, Organization ); 421 createField( FieldImpl::Role, Organization );
417 createField( FieldImpl::Organization, Organization ); 422 createField( FieldImpl::Organization, Organization );
418 createField( FieldImpl::Note ); 423 createField( FieldImpl::Note );
419 createField( FieldImpl::Url ); 424 createField( FieldImpl::Url );
420 createField( FieldImpl::Resource ); 425 createField( FieldImpl::Resource );
426 createField( FieldImpl::Sip );
421 } 427 }
422 428
423 return mAllFields; 429 return mAllFields;
424} 430}
425 431
426Field::List Field::defaultFields() 432Field::List Field::defaultFields()
427{ 433{
428 if ( mDefaultFields.isEmpty() ) { 434 if ( mDefaultFields.isEmpty() ) {
429 createDefaultField( FieldImpl::GivenName ); 435 createDefaultField( FieldImpl::GivenName );
430 createDefaultField( FieldImpl::FamilyName ); 436 createDefaultField( FieldImpl::FamilyName );
431 createDefaultField( FieldImpl::Email ); 437 createDefaultField( FieldImpl::Email );
432 } 438 }
433 439
434 return mDefaultFields; 440 return mDefaultFields;
435} 441}
436 442
437void Field::createField( int id, int category ) 443void Field::createField( int id, int category )
438{ 444{
439 mAllFields.append( new Field( new FieldImpl( id, category ) ) ); 445 mAllFields.append( new Field( new FieldImpl( id, category ) ) );
440} 446}
441 447
442void Field::createDefaultField( int id, int category ) 448void Field::createDefaultField( int id, int category )
443{ 449{
444 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); 450 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) );
445} 451}
446 452
447void Field::deleteFields() 453void Field::deleteFields()
448{ 454{
449 Field::List::ConstIterator it; 455 Field::List::ConstIterator it;
450 456
451 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { 457 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) {
452 delete (*it); 458 delete (*it);
453 } 459 }
454 mAllFields.clear(); 460 mAllFields.clear();
455 461
456 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { 462 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) {
457 delete (*it); 463 delete (*it);
458 } 464 }
459 mDefaultFields.clear(); 465 mDefaultFields.clear();
460 466
461 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { 467 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) {
462 delete (*it); 468 delete (*it);
463 } 469 }
464 mCustomFields.clear(); 470 mCustomFields.clear();
465} 471}
466 472
467void Field::saveFields( const QString &identifier, 473void Field::saveFields( const QString &identifier,
468 const Field::List &fields ) 474 const Field::List &fields )
469{ 475{
470 KConfig *cfg = KGlobal::config(); 476 KConfig *cfg = KGlobal::config();
471 KConfigGroupSaver( cfg, "KABCFields" ); 477 KConfigGroupSaver( cfg, "KABCFields" );
472 saveFields( cfg, identifier, fields ); 478 saveFields( cfg, identifier, fields );
473} 479}
474 480
475void Field::saveFields( KConfig *cfg, const QString &identifier, 481void Field::saveFields( KConfig *cfg, const QString &identifier,
476 const Field::List &fields ) 482 const Field::List &fields )
477{ 483{
478 QValueList<int> fieldIds; 484 QValueList<int> fieldIds;
479 485
480//US 486//US
481// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); 487// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1());
482 488
483 int custom = 0; 489 int custom = 0;
484 Field::List::ConstIterator it; 490 Field::List::ConstIterator it;
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 4ad608d..7aeb2ee 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -64,137 +64,139 @@ bool PhoneNumber::operator==( const PhoneNumber &p ) const
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68 68
69void PhoneNumber::setId( const QString &id ) 69void PhoneNumber::setId( const QString &id )
70{ 70{
71 mId = id; 71 mId = id;
72} 72}
73 73
74QString PhoneNumber::id() const 74QString PhoneNumber::id() const
75{ 75{
76 return mId; 76 return mId;
77} 77}
78 78
79void PhoneNumber::setNumber( const QString &number ) 79void PhoneNumber::setNumber( const QString &number )
80{ 80{
81 mNumber = number; 81 mNumber = number;
82} 82}
83 83
84QString PhoneNumber::number() const 84QString PhoneNumber::number() const
85{ 85{
86 return mNumber; 86 return mNumber;
87} 87}
88 88
89void PhoneNumber::setType( int type ) 89void PhoneNumber::setType( int type )
90{ 90{
91 mType = type; 91 mType = type;
92} 92}
93 93
94int PhoneNumber::type() const 94int PhoneNumber::type() const
95{ 95{
96 return mType; 96 return mType;
97} 97}
98 98
99QString PhoneNumber::typeLabel() const 99QString PhoneNumber::typeLabel() const
100{ 100{
101 QString label; 101 QString label;
102 bool first = true; 102 bool first = true;
103 103
104 TypeList list = typeList(); 104 TypeList list = typeList();
105 105
106 TypeList::Iterator it; 106 TypeList::Iterator it;
107 for ( it = list.begin(); it != list.end(); ++it ) { 107 for ( it = list.begin(); it != list.end(); ++it ) {
108 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 108 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
109 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 109 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
110 if ( first ) 110 if ( first )
111 first = false; 111 first = false;
112 } 112 }
113 } 113 }
114 114
115 return label; 115 return label;
116} 116}
117 117
118QString PhoneNumber::label() const 118QString PhoneNumber::label() const
119{ 119{
120 return typeLabel( type() ); 120 return typeLabel( type() );
121} 121}
122 122
123PhoneNumber::TypeList PhoneNumber::typeList() 123PhoneNumber::TypeList PhoneNumber::typeList()
124{ 124{
125 TypeList list; 125 TypeList list;
126 126
127 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 127 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
128 << Bbs << Modem << Car << Isdn << Pcs << Pager; 128 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip;
129 129
130 return list; 130 return list;
131} 131}
132 132
133QString PhoneNumber::label( int type ) 133QString PhoneNumber::label( int type )
134{ 134{
135 return typeLabel( type ); 135 return typeLabel( type );
136} 136}
137 137
138QString PhoneNumber::typeLabel( int type ) 138QString PhoneNumber::typeLabel( int type )
139{ 139{
140 QString typeString; 140 QString typeString;
141 141
142 if ((type & Home) == Home) 142 if ((type & Home) == Home)
143 typeString += i18n("Home"); 143 typeString += i18n("Home");
144 else if ((type & Work) == Work) 144 else if ((type & Work) == Work)
145 typeString += i18n("Work"); 145 typeString += i18n("Work");
146 146
147 if (!typeString.isEmpty()) 147 if (!typeString.isEmpty())
148 typeString += " "; 148 typeString += " ";
149 149
150 if ((type & Cell) == Cell) 150 if ((type & Cell) == Cell)
151 typeString += i18n("Mobile"); 151 typeString += i18n("Mobile");
152 else if ((type & Fax) == Fax) 152 else if ((type & Fax) == Fax)
153 typeString += i18n("Fax"); 153 typeString += i18n("Fax");
154 else if ((type & Msg) == Msg) 154 else if ((type & Msg) == Msg)
155 typeString += i18n("Messenger"); 155 typeString += i18n("Messenger");
156 else if ((type & Voice) == Voice) { 156 else if ((type & Voice) == Voice) {
157// add nothing in case of the Voice flag 157// add nothing in case of the Voice flag
158// typeString += i18n("Voice"); 158// typeString += i18n("Voice");
159 } 159 }
160 else if ((type & Video) == Video) 160 else if ((type & Video) == Video)
161 typeString += i18n("Video"); 161 typeString += i18n("Video");
162 else if ((type & Bbs) == Bbs) 162 else if ((type & Bbs) == Bbs)
163 typeString += i18n("Mailbox"); 163 typeString += i18n("Mailbox");
164 else if ((type & Modem) == Modem) 164 else if ((type & Modem) == Modem)
165 typeString += i18n("Modem"); 165 typeString += i18n("Modem");
166 else if ((type & Car) == Car) 166 else if ((type & Car) == Car)
167 typeString += i18n("Car"); 167 typeString += i18n("Car");
168 else if ((type & Isdn) == Isdn) 168 else if ((type & Isdn) == Isdn)
169 typeString += i18n("ISDN"); 169 typeString += i18n("ISDN");
170 else if ((type & Pcs) == Pcs) 170 else if ((type & Pcs) == Pcs)
171 typeString += i18n("PCS"); 171 typeString += i18n("PCS");
172 else if ((type & Pager) == Pager) 172 else if ((type & Pager) == Pager)
173 typeString += i18n("Pager"); 173 typeString += i18n("Pager");
174 else if ((type & Sip) == Sip)
175 typeString += i18n("SIP");
174 176
175 // add the prefered flag 177 // add the prefered flag
176 if (!typeString.isEmpty()) 178 if (!typeString.isEmpty())
177 typeString += " "; 179 typeString += " ";
178 180
179 if ((type & Pref) == Pref) 181 if ((type & Pref) == Pref)
180 typeString += i18n("(p)"); 182 typeString += i18n("(p)");
181 183
182 //if we still have no match, return "other" 184 //if we still have no match, return "other"
183 if (typeString.isEmpty()) 185 if (typeString.isEmpty())
184 return i18n("Other"); 186 return i18n("Other");
185 187
186 188
187 return typeString; 189 return typeString;
188} 190}
189 191
190QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 192QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
191{ 193{
192 return s << phone.mId << phone.mType << phone.mNumber; 194 return s << phone.mId << phone.mType << phone.mNumber;
193} 195}
194 196
195QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) 197QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
196{ 198{
197 s >> phone.mId >> phone.mType >> phone.mNumber; 199 s >> phone.mId >> phone.mType >> phone.mNumber;
198 200
199 return s; 201 return s;
200} 202}
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h
index 6a9c8cb..1df344f 100644
--- a/kabc/phonenumber.h
+++ b/kabc/phonenumber.h
@@ -3,132 +3,133 @@
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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_PHONENUMBER_H 28#ifndef KABC_PHONENUMBER_H
29#define KABC_PHONENUMBER_H 29#define KABC_PHONENUMBER_H
30 30
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qstring.h> 32#include <qstring.h>
33 33
34namespace KABC { 34namespace KABC {
35 35
36/** 36/**
37 @short Phonenumber information. 37 @short Phonenumber information.
38 38
39 This class provides phone number information. A phone number is classified by 39 This class provides phone number information. A phone number is classified by
40 a type. The following types are available, it's possible to use multiple types 40 a type. The following types are available, it's possible to use multiple types
41 @ref Types for a number by combining them through a logical or. 41 @ref Types for a number by combining them through a logical or.
42*/ 42*/
43class PhoneNumber 43class PhoneNumber
44{ 44{
45 friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); 45 friend QDataStream &operator<<( QDataStream &, const PhoneNumber & );
46 friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); 46 friend QDataStream &operator>>( QDataStream &, PhoneNumber & );
47 47
48 public: 48 public:
49 typedef QValueList<PhoneNumber> List; 49 typedef QValueList<PhoneNumber> List;
50 typedef QValueList<int> TypeList; 50 typedef QValueList<int> TypeList;
51 51
52 /** 52 /**
53 @li @p Home - Home number 53 @li @p Home - Home number
54 @li @p Work - Office number 54 @li @p Work - Office number
55 @li @p Msg - Messaging 55 @li @p Msg - Messaging
56 @li @p Pref - Preferred number 56 @li @p Pref - Preferred number
57 @li @p Voice - Voice 57 @li @p Voice - Voice
58 @li @p Fax - Fax machine 58 @li @p Fax - Fax machine
59 @li @p Cell - Cell phone 59 @li @p Cell - Cell phone
60 @li @p Video - Video phone 60 @li @p Video - Video phone
61 @li @p Bbs - Mailbox 61 @li @p Bbs - Mailbox
62 @li @p Modem - Modem 62 @li @p Modem - Modem
63 @li @p Car - Car phone 63 @li @p Car - Car phone
64 @li @p Isdn - ISDN connection 64 @li @p Isdn - ISDN connection
65 @li @p Pcs - Personal Communication Service 65 @li @p Pcs - Personal Communication Service
66 @li @p Pager - Pager 66 @li @p Pager - Pager
67 @li @p SIP - VoIP
67 */ 68 */
68 enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, 69 enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32,
69 Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, 70 Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024,
70 Isdn = 2048, Pcs = 4096, Pager = 8192 }; 71 Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 };
71 72
72 /** 73 /**
73 Create an empty phone number object. 74 Create an empty phone number object.
74 */ 75 */
75 PhoneNumber(); 76 PhoneNumber();
76 77
77 /** 78 /**
78 Create a phonenumber object. 79 Create a phonenumber object.
79 80
80 @param number Number 81 @param number Number
81 @param type Type as defined in enum. Multiple types can be 82 @param type Type as defined in enum. Multiple types can be
82 specified by combining them by a logical or. 83 specified by combining them by a logical or.
83 */ 84 */
84 PhoneNumber( const QString &number, int type = Home ); 85 PhoneNumber( const QString &number, int type = Home );
85 86
86 /** 87 /**
87 Destructor. 88 Destructor.
88 */ 89 */
89 ~PhoneNumber(); 90 ~PhoneNumber();
90 91
91 bool operator==( const PhoneNumber & ) const; 92 bool operator==( const PhoneNumber & ) const;
92 bool operator!=( const PhoneNumber & ) const; 93 bool operator!=( const PhoneNumber & ) const;
93 94
94 /** 95 /**
95 Sets the unique identifier. 96 Sets the unique identifier.
96 */ 97 */
97 void setId( const QString &id ); 98 void setId( const QString &id );
98 99
99 /** 100 /**
100 Returns the unique identifier. 101 Returns the unique identifier.
101 */ 102 */
102 QString id() const; 103 QString id() const;
103 104
104 /** 105 /**
105 Sets the number. 106 Sets the number.
106 */ 107 */
107 void setNumber( const QString & ); 108 void setNumber( const QString & );
108 109
109 /** 110 /**
110 Returns the number. 111 Returns the number.
111 */ 112 */
112 QString number() const; 113 QString number() const;
113 114
114 /** 115 /**
115 Sets the type. Multiple types can be specified by combining them by 116 Sets the type. Multiple types can be specified by combining them by
116 a logical or. 117 a logical or.
117 */ 118 */
118 void setType( int ); 119 void setType( int );
119 120
120 /** 121 /**
121 Returns the type. Can be a multiple types combined by a logical or. 122 Returns the type. Can be a multiple types combined by a logical or.
122 */ 123 */
123 int type() const; 124 int type() const;
124 125
125 /** 126 /**
126 Returns a translated string of all types the address has. 127 Returns a translated string of all types the address has.
127 */ 128 */
128 QString typeLabel() const; 129 QString typeLabel() const;
129 130
130 /** 131 /**
131 Returns the translated label for phone number depending on its type. 132 Returns the translated label for phone number depending on its type.
132 */ 133 */
133 QString label() const; 134 QString label() const;
134 135
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp
index b02aac4..277de22 100644
--- a/kabc/vcard21parser.cpp
+++ b/kabc/vcard21parser.cpp
@@ -109,129 +109,130 @@ bool VCardLineX::isValid() const
109 return true; 109 return true;
110 if ( name == VCARD_LOGO ) 110 if ( name == VCARD_LOGO )
111 return true; 111 return true;
112 break; 112 break;
113 113
114 case 'm': 114 case 'm':
115 if ( name == VCARD_MAILER ) 115 if ( name == VCARD_MAILER )
116 return true; 116 return true;
117 break; 117 break;
118 118
119 case 'n': 119 case 'n':
120 if ( name == VCARD_N ) 120 if ( name == VCARD_N )
121 return true; 121 return true;
122 if ( name == VCARD_NAME ) 122 if ( name == VCARD_NAME )
123 return true; 123 return true;
124 if ( name == VCARD_NICKNAME ) 124 if ( name == VCARD_NICKNAME )
125 return true; 125 return true;
126 if ( name == VCARD_NOTE ) 126 if ( name == VCARD_NOTE )
127 return true; 127 return true;
128 break; 128 break;
129 129
130 case 'o': 130 case 'o':
131 if ( name == VCARD_ORG ) 131 if ( name == VCARD_ORG )
132 return true; 132 return true;
133 break; 133 break;
134 134
135 case 'p': 135 case 'p':
136 if ( name == VCARD_PHOTO ) 136 if ( name == VCARD_PHOTO )
137 return true; 137 return true;
138 if ( name == VCARD_PROFILE ) 138 if ( name == VCARD_PROFILE )
139 return true; 139 return true;
140 if ( name == VCARD_PRODID ) 140 if ( name == VCARD_PRODID )
141 return true; 141 return true;
142 break; 142 break;
143 143
144 case 'r': 144 case 'r':
145 if ( name == VCARD_ROLE ) 145 if ( name == VCARD_ROLE )
146 return true; 146 return true;
147 if ( name == VCARD_REV ) 147 if ( name == VCARD_REV )
148 return true; 148 return true;
149 break; 149 break;
150 150
151 case 's': 151 case 's':
152 if ( name == VCARD_SOURCE ) 152 if ( name == VCARD_SOURCE )
153 return true; 153 return true;
154 if ( name == VCARD_SOUND ) 154 if ( name == VCARD_SOUND )
155 return true; 155 return true;
156 break; 156 break;
157 157
158 case 't': 158 case 't':
159 if ( name == VCARD_TEL && qualified && 159 if ( name == VCARD_TEL && qualified &&
160 (qualifiers.contains(VCARD_TEL_HOME) || 160 (qualifiers.contains(VCARD_TEL_HOME) ||
161 qualifiers.contains(VCARD_TEL_WORK) || 161 qualifiers.contains(VCARD_TEL_WORK) ||
162 qualifiers.contains(VCARD_TEL_PREF) || 162 qualifiers.contains(VCARD_TEL_PREF) ||
163 qualifiers.contains(VCARD_TEL_VOICE) || 163 qualifiers.contains(VCARD_TEL_VOICE) ||
164 qualifiers.contains(VCARD_TEL_FAX) || 164 qualifiers.contains(VCARD_TEL_FAX) ||
165 qualifiers.contains(VCARD_TEL_MSG) || 165 qualifiers.contains(VCARD_TEL_MSG) ||
166 qualifiers.contains(VCARD_TEL_CELL) || 166 qualifiers.contains(VCARD_TEL_CELL) ||
167 qualifiers.contains(VCARD_TEL_PAGER) || 167 qualifiers.contains(VCARD_TEL_PAGER) ||
168 qualifiers.contains(VCARD_TEL_BBS) || 168 qualifiers.contains(VCARD_TEL_BBS) ||
169 qualifiers.contains(VCARD_TEL_MODEM) || 169 qualifiers.contains(VCARD_TEL_MODEM) ||
170 qualifiers.contains(VCARD_TEL_CAR) || 170 qualifiers.contains(VCARD_TEL_CAR) ||
171 qualifiers.contains(VCARD_TEL_ISDN) || 171 qualifiers.contains(VCARD_TEL_ISDN) ||
172 qualifiers.contains(VCARD_TEL_VIDEO) || 172 qualifiers.contains(VCARD_TEL_VIDEO) ||
173 qualifiers.contains(VCARD_TEL_PCS) 173 qualifiers.contains(VCARD_TEL_PCS) ||
174 qualifiers.contains(VCARD_TEL_SIP)
174 ) ) 175 ) )
175 return true; 176 return true;
176 if ( name == VCARD_TZ ) 177 if ( name == VCARD_TZ )
177 return true; 178 return true;
178 if ( name == VCARD_TITLE ) 179 if ( name == VCARD_TITLE )
179 return true; 180 return true;
180 break; 181 break;
181 182
182 case 'u': 183 case 'u':
183 if ( name == VCARD_URL ) 184 if ( name == VCARD_URL )
184 return true; 185 return true;
185 if ( name == VCARD_UID ) 186 if ( name == VCARD_UID )
186 return true; 187 return true;
187 break; 188 break;
188 189
189 case 'v': 190 case 'v':
190 if ( name == VCARD_VERSION ) 191 if ( name == VCARD_VERSION )
191 return true; 192 return true;
192 break; 193 break;
193 default: 194 default:
194 break; 195 break;
195 } 196 }
196 197
197 return false; 198 return false;
198} 199}
199 200
200 201
201VCard21Parser::VCard21Parser() 202VCard21Parser::VCard21Parser()
202{ 203{
203} 204}
204 205
205VCard21Parser::~VCard21Parser() 206VCard21Parser::~VCard21Parser()
206{ 207{
207} 208}
208 209
209void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data) 210void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data)
210{ 211{
211 KABC::Addressee mAddressee = readFromString(data); 212 KABC::Addressee mAddressee = readFromString(data);
212 addressbook->insertAddressee(mAddressee); 213 addressbook->insertAddressee(mAddressee);
213} 214}
214 215
215KABC::Addressee VCard21Parser::readFromString( const QString &data) 216KABC::Addressee VCard21Parser::readFromString( const QString &data)
216{ 217{
217 KABC::Addressee addressee; 218 KABC::Addressee addressee;
218 VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data); 219 VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data);
219 QString tmpStr; 220 QString tmpStr;
220 221
221 // Check if parsing failed 222 // Check if parsing failed
222 if (mVCard == 0) 223 if (mVCard == 0)
223 { 224 {
224 kdDebug() << "Parsing failed" << endl; 225 kdDebug() << "Parsing failed" << endl;
225 return addressee; 226 return addressee;
226 } 227 }
227 //set the addressees name and formated name 228 //set the addressees name and formated name
228 QStringList tmpList = mVCard->getValues(VCARD_N); 229 QStringList tmpList = mVCard->getValues(VCARD_N);
229 QString formattedName = ""; 230 QString formattedName = "";
230 if (tmpList.count() > 0) 231 if (tmpList.count() > 0)
231 addressee.setFamilyName(tmpList[0]); 232 addressee.setFamilyName(tmpList[0]);
232 if (tmpList.count() > 1) 233 if (tmpList.count() > 1)
233 addressee.setGivenName(tmpList[1]); 234 addressee.setGivenName(tmpList[1]);
234 if (tmpList.count() > 2) 235 if (tmpList.count() > 2)
235 addressee.setAdditionalName(tmpList[2]); 236 addressee.setAdditionalName(tmpList[2]);
236 if (tmpList.count() > 3) 237 if (tmpList.count() > 3)
237 addressee.setPrefix(tmpList[3]); 238 addressee.setPrefix(tmpList[3]);
@@ -240,128 +241,130 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data)
240 241
241 tmpStr = (mVCard->getValue(VCARD_FN)); 242 tmpStr = (mVCard->getValue(VCARD_FN));
242 if (!tmpStr.isEmpty()) 243 if (!tmpStr.isEmpty())
243 addressee.setFormattedName(tmpStr); 244 addressee.setFormattedName(tmpStr);
244 245
245 //set the addressee's nick name 246 //set the addressee's nick name
246 tmpStr = mVCard->getValue(VCARD_NICKNAME); 247 tmpStr = mVCard->getValue(VCARD_NICKNAME);
247 addressee.setNickName(tmpStr); 248 addressee.setNickName(tmpStr);
248 //set the addressee's organisation 249 //set the addressee's organisation
249 tmpStr = mVCard->getValue(VCARD_ORG); 250 tmpStr = mVCard->getValue(VCARD_ORG);
250 addressee.setOrganization(tmpStr); 251 addressee.setOrganization(tmpStr);
251 //set the addressee's title 252 //set the addressee's title
252 tmpStr = mVCard->getValue(VCARD_TITLE); 253 tmpStr = mVCard->getValue(VCARD_TITLE);
253 addressee.setTitle(tmpStr); 254 addressee.setTitle(tmpStr);
254 //set the addressee's email - we can only deal with two. The preferenced one and one other. 255 //set the addressee's email - we can only deal with two. The preferenced one and one other.
255 tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); 256 tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET);
256 addressee.insertEmail(tmpStr, false); 257 addressee.insertEmail(tmpStr, false);
257 tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); 258 tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF);
258 addressee.insertEmail(tmpStr, true); 259 addressee.insertEmail(tmpStr, true);
259 //set the addressee's url 260 //set the addressee's url
260 tmpStr = mVCard->getValue(VCARD_URL); 261 tmpStr = mVCard->getValue(VCARD_URL);
261 if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); 262 if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK);
262 if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); 263 if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME);
263 if (!tmpStr.isEmpty()) { 264 if (!tmpStr.isEmpty()) {
264 addressee.setUrl(KURL(tmpStr)); 265 addressee.setUrl(KURL(tmpStr));
265 } 266 }
266 267
267 //set the addressee's birthday 268 //set the addressee's birthday
268 tmpStr = mVCard->getValue(VCARD_BDAY); 269 tmpStr = mVCard->getValue(VCARD_BDAY);
269 addressee.setBirthday(VCardStringToDate(tmpStr)); 270 addressee.setBirthday(VCardStringToDate(tmpStr));
270 271
271 //set the addressee's phone numbers 272 //set the addressee's phone numbers
272 for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { 273 for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) {
273 if ( (*i).name == VCARD_TEL ) { 274 if ( (*i).name == VCARD_TEL ) {
274 int type = 0; 275 int type = 0;
275 if ( (*i).qualified ) { 276 if ( (*i).qualified ) {
276 if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) 277 if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) )
277 type |= PhoneNumber::Home; 278 type |= PhoneNumber::Home;
278 if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) 279 if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) )
279 type |= PhoneNumber::Work; 280 type |= PhoneNumber::Work;
280 if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) 281 if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) )
281 type |= PhoneNumber::Pref; 282 type |= PhoneNumber::Pref;
282 // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) 283 // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) )
283 // type |= PhoneNumber::Voice; 284 // type |= PhoneNumber::Voice;
284 if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) 285 if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) )
285 type |= PhoneNumber::Fax; 286 type |= PhoneNumber::Fax;
286 if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) 287 if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) )
287 type |= PhoneNumber::Msg; 288 type |= PhoneNumber::Msg;
288 if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) 289 if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) )
289 type |= PhoneNumber::Cell; 290 type |= PhoneNumber::Cell;
290 if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) 291 if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) )
291 type |= PhoneNumber::Pager; 292 type |= PhoneNumber::Pager;
292 if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) 293 if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) )
293 type |= PhoneNumber::Bbs; 294 type |= PhoneNumber::Bbs;
294 if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) 295 if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) )
295 type |= PhoneNumber::Modem; 296 type |= PhoneNumber::Modem;
296 if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) 297 if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) )
297 type |= PhoneNumber::Car; 298 type |= PhoneNumber::Car;
298 if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) 299 if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) )
299 type |= PhoneNumber::Isdn; 300 type |= PhoneNumber::Isdn;
300 if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) 301 if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) )
301 type |= PhoneNumber::Video; 302 type |= PhoneNumber::Video;
302 if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) 303 if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) )
303 type |= PhoneNumber::Pcs; 304 type |= PhoneNumber::Pcs;
305 if ( (*i).qualifiers.contains( VCARD_TEL_SIP ) )
306 type |= PhoneNumber::Sip;
304 } 307 }
305 addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); 308 addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) );
306 } 309 }
307 } 310 }
308 311
309 //set the addressee's addresses 312 //set the addressee's addresses
310 for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { 313 for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) {
311 if ( (*i).name == VCARD_ADR ) { 314 if ( (*i).name == VCARD_ADR ) {
312 int type = 0; 315 int type = 0;
313 if ( (*i).qualified ) { 316 if ( (*i).qualified ) {
314 if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) 317 if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) )
315 type |= Address::Dom; 318 type |= Address::Dom;
316 if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) 319 if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) )
317 type |= Address::Intl; 320 type |= Address::Intl;
318 if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) 321 if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) )
319 type |= Address::Postal; 322 type |= Address::Postal;
320 if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) 323 if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) )
321 type |= Address::Parcel; 324 type |= Address::Parcel;
322 if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) 325 if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) )
323 type |= Address::Home; 326 type |= Address::Home;
324 if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) 327 if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) )
325 type |= Address::Work; 328 type |= Address::Work;
326 if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) 329 if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) )
327 type |= Address::Pref; 330 type |= Address::Pref;
328 } 331 }
329 addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); 332 addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) );
330 } 333 }
331 } 334 }
332 335
333 //set the addressee's delivery label 336 //set the addressee's delivery label
334 tmpStr = mVCard->getValue(VCARD_LABEL); 337 tmpStr = mVCard->getValue(VCARD_LABEL);
335 if (!tmpStr.isEmpty()) { 338 if (!tmpStr.isEmpty()) {
336qDebug("VCard21Parser::readFromString please verify if replace is correct"); 339qDebug("VCard21Parser::readFromString please verify if replace is correct");
337//US tmpStr.replace("\r\n","\n"); 340//US tmpStr.replace("\r\n","\n");
338 tmpStr.replace( QRegExp("\r\n"), "\n" ); 341 tmpStr.replace( QRegExp("\r\n"), "\n" );
339 Address tmpAddress; 342 Address tmpAddress;
340 tmpAddress.setLabel(tmpStr); 343 tmpAddress.setLabel(tmpStr);
341 addressee.insertAddress(tmpAddress); 344 addressee.insertAddress(tmpAddress);
342 } 345 }
343 346
344 //set the addressee's notes 347 //set the addressee's notes
345 tmpStr = mVCard->getValue(VCARD_NOTE); 348 tmpStr = mVCard->getValue(VCARD_NOTE);
346qDebug("VCard21Parser::readFromString please verify if correct"); 349qDebug("VCard21Parser::readFromString please verify if correct");
347//US tmpStr.replace("\r\n","\n"); 350//US tmpStr.replace("\r\n","\n");
348 tmpStr.replace( QRegExp("\r\n"), "\n" ); 351 tmpStr.replace( QRegExp("\r\n"), "\n" );
349 addressee.setNote(tmpStr); 352 addressee.setNote(tmpStr);
350 353
351 //set the addressee's timezone 354 //set the addressee's timezone
352 tmpStr = mVCard->getValue(VCARD_TZ); 355 tmpStr = mVCard->getValue(VCARD_TZ);
353 TimeZone tmpZone(tmpStr.toInt()); 356 TimeZone tmpZone(tmpStr.toInt());
354 addressee.setTimeZone(tmpZone); 357 addressee.setTimeZone(tmpZone);
355 358
356 //set the addressee's geographical position 359 //set the addressee's geographical position
357 tmpList = mVCard->getValues(VCARD_GEO); 360 tmpList = mVCard->getValues(VCARD_GEO);
358 if (tmpList.count()==2) 361 if (tmpList.count()==2)
359 { 362 {
360 tmpStr = tmpList[0]; 363 tmpStr = tmpList[0];
361 float glat = tmpStr.toFloat(); 364 float glat = tmpStr.toFloat();
362 tmpStr = tmpList[1]; 365 tmpStr = tmpList[1];
363 float glong = tmpStr.toFloat(); 366 float glong = tmpStr.toFloat();
364 Geo tmpGeo(glat,glong); 367 Geo tmpGeo(glat,glong);
365 addressee.setGeo(tmpGeo); 368 addressee.setGeo(tmpGeo);
366 } 369 }
367 370
diff --git a/kabc/vcard21parser.h b/kabc/vcard21parser.h
index 24b0eb2..77e69b6 100644
--- a/kabc/vcard21parser.h
+++ b/kabc/vcard21parser.h
@@ -31,128 +31,129 @@ $Id$
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <kdebug.h> 33#include <kdebug.h>
34#include <qregexp.h> 34#include <qregexp.h>
35#include <qstring.h> 35#include <qstring.h>
36#include <kurl.h> 36#include <kurl.h>
37#include <qvaluelist.h> 37#include <qvaluelist.h>
38 38
39#include "addressee.h" 39#include "addressee.h"
40#include "addressbook.h" 40#include "addressbook.h"
41#include "phonenumber.h" 41#include "phonenumber.h"
42 42
43 43
44#define VCARD_BEGIN "begin:vcard" 44#define VCARD_BEGIN "begin:vcard"
45#define VCARD_END "end:vcard" 45#define VCARD_END "end:vcard"
46#define VCARD_BEGIN_N "begin" 46#define VCARD_BEGIN_N "begin"
47#define VCARD_END_N "end" 47#define VCARD_END_N "end"
48#define VCARD_VERSION "version" 48#define VCARD_VERSION "version"
49 49
50#define VCARD_FN "fn" 50#define VCARD_FN "fn"
51#define VCARD_N "n" 51#define VCARD_N "n"
52 52
53// optional 53// optional
54#define VCARD_NAME "name" 54#define VCARD_NAME "name"
55#define VCARD_NICKNAME "nickname" 55#define VCARD_NICKNAME "nickname"
56#define VCARD_PHOTO "photo" 56#define VCARD_PHOTO "photo"
57#define VCARD_BDAY "bday" 57#define VCARD_BDAY "bday"
58#define VCARD_ADR "adr" 58#define VCARD_ADR "adr"
59 59
60// types 60// types
61#define VCARD_ADR_DOM "dom" 61#define VCARD_ADR_DOM "dom"
62#define VCARD_ADR_INTL "intl" 62#define VCARD_ADR_INTL "intl"
63#define VCARD_ADR_POSTAL "postal" 63#define VCARD_ADR_POSTAL "postal"
64#define VCARD_ADR_PARCEL "parcel" 64#define VCARD_ADR_PARCEL "parcel"
65#define VCARD_ADR_HOME "home" 65#define VCARD_ADR_HOME "home"
66#define VCARD_ADR_WORK "work" 66#define VCARD_ADR_WORK "work"
67#define VCARD_ADR_PREF "pref" 67#define VCARD_ADR_PREF "pref"
68// values 68// values
69#define VCARD_ADR_POBOX "PO Box" 69#define VCARD_ADR_POBOX "PO Box"
70#define VCARD_ADR_EXTADR "Extended Address" 70#define VCARD_ADR_EXTADR "Extended Address"
71#define VCARD_ADR_STREET "Street" 71#define VCARD_ADR_STREET "Street"
72#define VCARD_ADR_LOCALITY "Locality" 72#define VCARD_ADR_LOCALITY "Locality"
73#define VCARD_ADR_REGION "Region" 73#define VCARD_ADR_REGION "Region"
74#define VCARD_ADR_POSTCODE "Postal Code" 74#define VCARD_ADR_POSTCODE "Postal Code"
75#define VCARD_ADR_COUNTRY "Country Name" 75#define VCARD_ADR_COUNTRY "Country Name"
76#define VCARD_LABEL "label" 76#define VCARD_LABEL "label"
77#define VCARD_PROFILE "profile" 77#define VCARD_PROFILE "profile"
78#define VCARD_SOURCE "source" 78#define VCARD_SOURCE "source"
79#define VCARD_TEL "tel" 79#define VCARD_TEL "tel"
80// types 80// types
81#define VCARD_TEL_HOME "home" 81#define VCARD_TEL_HOME "home"
82#define VCARD_TEL_WORK "work" 82#define VCARD_TEL_WORK "work"
83#define VCARD_TEL_PREF "pref" 83#define VCARD_TEL_PREF "pref"
84#define VCARD_TEL_VOICE "voice" 84#define VCARD_TEL_VOICE "voice"
85#define VCARD_TEL_FAX "fax" 85#define VCARD_TEL_FAX "fax"
86#define VCARD_TEL_MSG "msg" 86#define VCARD_TEL_MSG "msg"
87#define VCARD_TEL_CELL "cell" 87#define VCARD_TEL_CELL "cell"
88#define VCARD_TEL_PAGER "pager" 88#define VCARD_TEL_PAGER "pager"
89#define VCARD_TEL_BBS "bbs" 89#define VCARD_TEL_BBS "bbs"
90#define VCARD_TEL_MODEM "modem" 90#define VCARD_TEL_MODEM "modem"
91#define VCARD_TEL_CAR "car" 91#define VCARD_TEL_CAR "car"
92#define VCARD_TEL_ISDN "isdn" 92#define VCARD_TEL_ISDN "isdn"
93#define VCARD_TEL_VIDEO "video" 93#define VCARD_TEL_VIDEO "video"
94#define VCARD_TEL_PCS "pcs" 94#define VCARD_TEL_PCS "pcs"
95#define VCARD_TEL_SIP "sip"
95#define VCARD_EMAIL "email" 96#define VCARD_EMAIL "email"
96// types 97// types
97#define VCARD_EMAIL_PREF "pref" 98#define VCARD_EMAIL_PREF "pref"
98#define VCARD_EMAIL_INTERNET "internet" 99#define VCARD_EMAIL_INTERNET "internet"
99#define VCARD_EMAIL_X400 "x400" 100#define VCARD_EMAIL_X400 "x400"
100#define VCARD_TZ "tz" 101#define VCARD_TZ "tz"
101#define VCARD_GEO "geo" 102#define VCARD_GEO "geo"
102#define VCARD_MAILER "mailer" 103#define VCARD_MAILER "mailer"
103#define VCARD_TITLE "title" 104#define VCARD_TITLE "title"
104#define VCARD_ROLE "role" 105#define VCARD_ROLE "role"
105#define VCARD_LOGO "logo" 106#define VCARD_LOGO "logo"
106#define VCARD_AGENT "agent" 107#define VCARD_AGENT "agent"
107#define VCARD_ORG "org" 108#define VCARD_ORG "org"
108#define VCARD_CATEGORIES "categories" 109#define VCARD_CATEGORIES "categories"
109#define VCARD_NOTE "note" 110#define VCARD_NOTE "note"
110#define VCARD_PRODID "prodid" 111#define VCARD_PRODID "prodid"
111#define VCARD_REV "rev" 112#define VCARD_REV "rev"
112#define VCARD_SOUND "sound" 113#define VCARD_SOUND "sound"
113#define VCARD_UID "uid" 114#define VCARD_UID "uid"
114#define VCARD_URL "url" 115#define VCARD_URL "url"
115#define VCARD_CLASS "class" 116#define VCARD_CLASS "class"
116#define VCARD_CLASS_PUBLIC "public" 117#define VCARD_CLASS_PUBLIC "public"
117#define VCARD_CLASS_PRIVATE "private" 118#define VCARD_CLASS_PRIVATE "private"
118#define VCARD_CLASS_CONFIDENTIAL "confidential" 119#define VCARD_CLASS_CONFIDENTIAL "confidential"
119#define VCARD_KEY "key" 120#define VCARD_KEY "key"
120// types 121// types
121#define VCARD_KEY_X509 "x509" 122#define VCARD_KEY_X509 "x509"
122#define VCARD_KEY_PGP "pgp" 123#define VCARD_KEY_PGP "pgp"
123 124
124#define VCARD_QUOTED_PRINTABLE "quoted-printable" 125#define VCARD_QUOTED_PRINTABLE "quoted-printable"
125// this one is a temporary hack until we support TYPE=VALUE 126// this one is a temporary hack until we support TYPE=VALUE
126#define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable" 127#define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable"
127#define VCARD_BASE64 "base64" 128#define VCARD_BASE64 "base64"
128 129
129#define VC_STATE_BEGIN 1 130#define VC_STATE_BEGIN 1
130#define VC_STATE_BODY 2 131#define VC_STATE_BODY 2
131#define VC_STATE_END 4 132#define VC_STATE_END 4
132#define VC_STATE_HAVE_N 8 133#define VC_STATE_HAVE_N 8
133#define VC_STATE_HAVE_VERSION 16 134#define VC_STATE_HAVE_VERSION 16
134 135
135#define VC_ERR_NO_BEGIN 1 136#define VC_ERR_NO_BEGIN 1
136#define VC_ERR_NO_END 2 137#define VC_ERR_NO_END 2
137#define VC_ERR_INVALID_LINE 3 138#define VC_ERR_INVALID_LINE 3
138#define VC_ERR_INTERNAL 4 139#define VC_ERR_INTERNAL 4
139#define VC_ERR_INVALID_NAME 5 140#define VC_ERR_INVALID_NAME 5
140#define VC_ERR_MISSING_MANDATORY 6 141#define VC_ERR_MISSING_MANDATORY 6
141 142
142namespace KABC { 143namespace KABC {
143 144
144class AddressBook; 145class AddressBook;
145 146
146class VCard21Parser 147class VCard21Parser
147{ 148{
148public: 149public:
149 150
150 /** 151 /**
151 * Constructor. 152 * Constructor.
152 */ 153 */
153 VCard21Parser(); 154 VCard21Parser();
154 155
155 /** 156 /**
156 * Destructor. 157 * Destructor.
157 */ 158 */
158 virtual ~VCard21Parser(); 159 virtual ~VCard21Parser();
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index bffaa64..2d6eb3d 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -530,160 +530,162 @@ int VCardFormatImpl::readAddressParam( ContentLine *cl )
530 for( ; it.current(); ++it ) { 530 for( ; it.current(); ++it ) {
531 if ( (*it)->name().upper() == "TYPE" ) { 531 if ( (*it)->name().upper() == "TYPE" ) {
532 tmpStr = (*it)->value().lower(); 532 tmpStr = (*it)->value().lower();
533 if ( tmpStr == "dom" ) type |= Address::Dom; 533 if ( tmpStr == "dom" ) type |= Address::Dom;
534 else if ( tmpStr == "intl" ) type |= Address::Intl; 534 else if ( tmpStr == "intl" ) type |= Address::Intl;
535 else if ( tmpStr == "parcel" ) type |= Address::Parcel; 535 else if ( tmpStr == "parcel" ) type |= Address::Parcel;
536 else if ( tmpStr == "postal" ) type |= Address::Postal; 536 else if ( tmpStr == "postal" ) type |= Address::Postal;
537 else if ( tmpStr == "work" ) type |= Address::Work; 537 else if ( tmpStr == "work" ) type |= Address::Work;
538 else if ( tmpStr == "home" ) type |= Address::Home; 538 else if ( tmpStr == "home" ) type |= Address::Home;
539 else if ( tmpStr == "pref" ) type |= Address::Pref; 539 else if ( tmpStr == "pref" ) type |= Address::Pref;
540 } 540 }
541 } 541 }
542 return type; 542 return type;
543} 543}
544 544
545void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) 545void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a )
546{ 546{
547 ContentLine cl; 547 ContentLine cl;
548 cl.setName(EntityTypeToParamName( EntityN ) ); 548 cl.setName(EntityTypeToParamName( EntityN ) );
549 NValue *v = new NValue; 549 NValue *v = new NValue;
550 v->setFamily( a.familyName().utf8() ); 550 v->setFamily( a.familyName().utf8() );
551 v->setGiven( a.givenName().utf8() ); 551 v->setGiven( a.givenName().utf8() );
552 v->setMiddle( a.additionalName().utf8() ); 552 v->setMiddle( a.additionalName().utf8() );
553 v->setPrefix( a.prefix().utf8() ); 553 v->setPrefix( a.prefix().utf8() );
554 v->setSuffix( a.suffix().utf8() ); 554 v->setSuffix( a.suffix().utf8() );
555 555
556 cl.setValue( v ); 556 cl.setValue( v );
557 vcard->add(cl); 557 vcard->add(cl);
558} 558}
559 559
560void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) 560void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a )
561{ 561{
562 NValue *v = (NValue *)cl->value(); 562 NValue *v = (NValue *)cl->value();
563 a.setFamilyName( QString::fromUtf8( v->family() ) ); 563 a.setFamilyName( QString::fromUtf8( v->family() ) );
564 a.setGivenName( QString::fromUtf8( v->given() ) ); 564 a.setGivenName( QString::fromUtf8( v->given() ) );
565 a.setAdditionalName( QString::fromUtf8( v->middle() ) ); 565 a.setAdditionalName( QString::fromUtf8( v->middle() ) );
566 a.setPrefix( QString::fromUtf8( v->prefix() ) ); 566 a.setPrefix( QString::fromUtf8( v->prefix() ) );
567 a.setSuffix( QString::fromUtf8( v->suffix() ) ); 567 a.setSuffix( QString::fromUtf8( v->suffix() ) );
568} 568}
569 569
570void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) 570void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p )
571{ 571{
572 if ( p.number().isEmpty() ) 572 if ( p.number().isEmpty() )
573 return; 573 return;
574 574
575 ContentLine cl; 575 ContentLine cl;
576 cl.setName(EntityTypeToParamName(EntityTelephone)); 576 cl.setName(EntityTypeToParamName(EntityTelephone));
577 cl.setValue(new TelValue( p.number().utf8() )); 577 cl.setValue(new TelValue( p.number().utf8() ));
578 578
579 ParamList params; 579 ParamList params;
580 if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); 580 if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) );
581 if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); 581 if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) );
582 if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); 582 if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) );
583 if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); 583 if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) );
584 if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); 584 if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) );
585 if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); 585 if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) );
586 if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); 586 if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) );
587 if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); 587 if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) );
588 if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); 588 if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) );
589 if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); 589 if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) );
590 if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); 590 if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) );
591 if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); 591 if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) );
592 if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); 592 if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) );
593 if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); 593 if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) );
594 if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) );
594 cl.setParamList( params ); 595 cl.setParamList( params );
595 596
596 v->add(cl); 597 v->add(cl);
597} 598}
598 599
599PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) 600PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl )
600{ 601{
601 PhoneNumber p; 602 PhoneNumber p;
602 TelValue *value = (TelValue *)cl->value(); 603 TelValue *value = (TelValue *)cl->value();
603 p.setNumber( QString::fromUtf8( value->asString() ) ); 604 p.setNumber( QString::fromUtf8( value->asString() ) );
604 605
605 int type = 0; 606 int type = 0;
606 ParamList params = cl->paramList(); 607 ParamList params = cl->paramList();
607 ParamListIterator it( params ); 608 ParamListIterator it( params );
608 QCString tmpStr; 609 QCString tmpStr;
609 for( ; it.current(); ++it ) { 610 for( ; it.current(); ++it ) {
610 if ( (*it)->name() == "TYPE" ) { 611 if ( (*it)->name() == "TYPE" ) {
611 tmpStr = (*it)->value().lower(); 612 tmpStr = (*it)->value().lower();
612 if ( tmpStr == "home" ) type |= PhoneNumber::Home; 613 if ( tmpStr == "home" ) type |= PhoneNumber::Home;
613 else if ( tmpStr == "work" ) type |= PhoneNumber::Work; 614 else if ( tmpStr == "work" ) type |= PhoneNumber::Work;
614 else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; 615 else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg;
615 else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; 616 else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref;
616 else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; 617 else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice;
617 else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; 618 else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax;
618 else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; 619 else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell;
619 else if ( tmpStr == "video" ) type |= PhoneNumber::Video; 620 else if ( tmpStr == "video" ) type |= PhoneNumber::Video;
620 else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; 621 else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs;
621 else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; 622 else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem;
622 else if ( tmpStr == "car" ) type |= PhoneNumber::Car; 623 else if ( tmpStr == "car" ) type |= PhoneNumber::Car;
623 else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; 624 else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn;
624 else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; 625 else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs;
625 else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; 626 else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager;
627 else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip;
626 } 628 }
627 } 629 }
628 p.setType( type ); 630 p.setType( type );
629 631
630 return p; 632 return p;
631} 633}
632 634
633QString VCardFormatImpl::readTextValue( ContentLine *cl ) 635QString VCardFormatImpl::readTextValue( ContentLine *cl )
634{ 636{
635 VCARD::Value *value = cl->value(); 637 VCARD::Value *value = cl->value();
636 if ( value ) { 638 if ( value ) {
637 return QString::fromUtf8( value->asString() ); 639 return QString::fromUtf8( value->asString() );
638 } else { 640 } else {
639 kdDebug(5700) << "No value: " << cl->asString() << endl; 641 kdDebug(5700) << "No value: " << cl->asString() << endl;
640 return QString::null; 642 return QString::null;
641 } 643 }
642} 644}
643 645
644QDate VCardFormatImpl::readDateValue( ContentLine *cl ) 646QDate VCardFormatImpl::readDateValue( ContentLine *cl )
645{ 647{
646 DateValue *dateValue = (DateValue *)cl->value(); 648 DateValue *dateValue = (DateValue *)cl->value();
647 if ( dateValue ) 649 if ( dateValue )
648 return dateValue->qdate(); 650 return dateValue->qdate();
649 else 651 else
650 return QDate(); 652 return QDate();
651} 653}
652 654
653QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) 655QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl )
654{ 656{
655 DateValue *dateValue = (DateValue *)cl->value(); 657 DateValue *dateValue = (DateValue *)cl->value();
656 if ( dateValue ) 658 if ( dateValue )
657 return dateValue->qdt(); 659 return dateValue->qdt();
658 else 660 else
659 return QDateTime(); 661 return QDateTime();
660} 662}
661 663
662Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) 664Geo VCardFormatImpl::readGeoValue( ContentLine *cl )
663{ 665{
664 GeoValue *geoValue = (GeoValue *)cl->value(); 666 GeoValue *geoValue = (GeoValue *)cl->value();
665 if ( geoValue ) { 667 if ( geoValue ) {
666 Geo geo( geoValue->latitude(), geoValue->longitude() ); 668 Geo geo( geoValue->latitude(), geoValue->longitude() );
667 return geo; 669 return geo;
668 } else 670 } else
669 return Geo(); 671 return Geo();
670} 672}
671 673
672TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) 674TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl )
673{ 675{
674 UTCValue *utcValue = (UTCValue *)cl->value(); 676 UTCValue *utcValue = (UTCValue *)cl->value();
675 if ( utcValue ) { 677 if ( utcValue ) {
676 TimeZone tz; 678 TimeZone tz;
677 tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); 679 tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1));
678 return tz; 680 return tz;
679 } else 681 } else
680 return TimeZone(); 682 return TimeZone();
681} 683}
682 684
683Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) 685Secrecy VCardFormatImpl::readClassValue( ContentLine *cl )
684{ 686{
685 ClassValue *classValue = (ClassValue *)cl->value(); 687 ClassValue *classValue = (ClassValue *)cl->value();
686 if ( classValue ) { 688 if ( classValue ) {
687 Secrecy secrecy; 689 Secrecy secrecy;
688 switch ( classValue->type() ) { 690 switch ( classValue->type() ) {
689 case ClassValue::Public: 691 case ClassValue::Public:
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp
index 71f29d7..3fb212e 100644
--- a/kabc/vcardparser/vcardtool.cpp
+++ b/kabc/vcardparser/vcardtool.cpp
@@ -1,123 +1,124 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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#include <qdatastream.h> 21#include <qdatastream.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qregexp.h> 23#include <qregexp.h>
24#include <kmdcodec.h> 24#include <kmdcodec.h>
25 25
26#include "agent.h" 26#include "agent.h"
27#include "key.h" 27#include "key.h"
28#include "picture.h" 28#include "picture.h"
29#include "secrecy.h" 29#include "secrecy.h"
30#include "sound.h" 30#include "sound.h"
31 31
32#include "vcardtool.h" 32#include "vcardtool.h"
33 33
34using namespace KABC; 34using namespace KABC;
35 35
36VCardTool::VCardTool() 36VCardTool::VCardTool()
37{ 37{
38 mAddressTypeMap.insert( "dom", Address::Dom ); 38 mAddressTypeMap.insert( "dom", Address::Dom );
39 mAddressTypeMap.insert( "intl", Address::Intl ); 39 mAddressTypeMap.insert( "intl", Address::Intl );
40 mAddressTypeMap.insert( "postal", Address::Postal ); 40 mAddressTypeMap.insert( "postal", Address::Postal );
41 mAddressTypeMap.insert( "parcel", Address::Parcel ); 41 mAddressTypeMap.insert( "parcel", Address::Parcel );
42 mAddressTypeMap.insert( "home", Address::Home ); 42 mAddressTypeMap.insert( "home", Address::Home );
43 mAddressTypeMap.insert( "work", Address::Work ); 43 mAddressTypeMap.insert( "work", Address::Work );
44 mAddressTypeMap.insert( "pref", Address::Pref ); 44 mAddressTypeMap.insert( "pref", Address::Pref );
45 45
46 mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); 46 mPhoneTypeMap.insert( "HOME", PhoneNumber::Home );
47 mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); 47 mPhoneTypeMap.insert( "WORK", PhoneNumber::Work );
48 mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); 48 mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg );
49 mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); 49 mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref );
50 mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); 50 mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice );
51 mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); 51 mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax );
52 mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); 52 mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell );
53 mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); 53 mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video );
54 mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); 54 mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs );
55 mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); 55 mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem );
56 mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); 56 mPhoneTypeMap.insert( "CAR", PhoneNumber::Car );
57 mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); 57 mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn );
58 mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); 58 mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs );
59 mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); 59 mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager );
60 mPhoneTypeMap.insert( "SIP", PhoneNumber::Sip );
60} 61}
61 62
62VCardTool::~VCardTool() 63VCardTool::~VCardTool()
63{ 64{
64} 65}
65 66
66QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) 67QString VCardTool::createVCards( Addressee::List list, VCard::Version version )
67{ 68{
68 VCard::List vCardList; 69 VCard::List vCardList;
69 70
70 Addressee::List::Iterator addrIt; 71 Addressee::List::Iterator addrIt;
71 for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) { 72 for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) {
72 VCard card; 73 VCard card;
73 QStringList::ConstIterator strIt; 74 QStringList::ConstIterator strIt;
74 75
75 // ADR + LABEL 76 // ADR + LABEL
76 Address::List addresses = (*addrIt).addresses(); 77 Address::List addresses = (*addrIt).addresses();
77 for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) { 78 for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) {
78 QStringList address; 79 QStringList address;
79 80
80/*US 81/*US
81 address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); 82 address.append( (*it).postOfficeBox().replace( ';', "\\;" ) );
82 address.append( (*it).extended().replace( ';', "\\;" ) ); 83 address.append( (*it).extended().replace( ';', "\\;" ) );
83 address.append( (*it).street().replace( ';', "\\;" ) ); 84 address.append( (*it).street().replace( ';', "\\;" ) );
84 address.append( (*it).locality().replace( ';', "\\;" ) ); 85 address.append( (*it).locality().replace( ';', "\\;" ) );
85 address.append( (*it).region().replace( ';', "\\;" ) ); 86 address.append( (*it).region().replace( ';', "\\;" ) );
86 address.append( (*it).postalCode().replace( ';', "\\;" ) ); 87 address.append( (*it).postalCode().replace( ';', "\\;" ) );
87 address.append( (*it).country().replace( ';', "\\;" ) ); 88 address.append( (*it).country().replace( ';', "\\;" ) );
88*/ 89*/
89//US using the old implementation instead 90//US using the old implementation instead
90 //qDebug("VCardTool::createVCards has to be verified"); 91 //qDebug("VCardTool::createVCards has to be verified");
91 address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); 92 address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) );
92 address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); 93 address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) );
93 address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); 94 address.append( (*it).street().replace( QRegExp(";"), "\\;" ) );
94 address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); 95 address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) );
95 address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); 96 address.append( (*it).region().replace( QRegExp(";"), "\\;" ) );
96 address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); 97 address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) );
97 address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); 98 address.append( (*it).country().replace( QRegExp(";"), "\\;" ) );
98 99
99 VCardLine adrLine( "ADR", address.join( ";" ) ); 100 VCardLine adrLine( "ADR", address.join( ";" ) );
100 VCardLine labelLine( "LABEL", (*it).label() ); 101 VCardLine labelLine( "LABEL", (*it).label() );
101 102
102 bool hasLabel = !(*it).label().isEmpty(); 103 bool hasLabel = !(*it).label().isEmpty();
103 QMap<QString, int>::Iterator typeIt; 104 QMap<QString, int>::Iterator typeIt;
104 for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { 105 for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) {
105 if ( typeIt.data() & (*it).type() ) { 106 if ( typeIt.data() & (*it).type() ) {
106 if ( version == VCard::v3_0 ) { 107 if ( version == VCard::v3_0 ) {
107 adrLine.addParameter( "TYPE", typeIt.key().lower() ); 108 adrLine.addParameter( "TYPE", typeIt.key().lower() );
108 } 109 }
109 else { 110 else {
110 adrLine.addParameter( "TYPE", typeIt.key() ); 111 adrLine.addParameter( "TYPE", typeIt.key() );
111 } 112 }
112 if ( hasLabel ) { 113 if ( hasLabel ) {
113 if ( version == VCard::v3_0 ) { 114 if ( version == VCard::v3_0 ) {
114 labelLine.addParameter( "TYPE", typeIt.key().lower() ); 115 labelLine.addParameter( "TYPE", typeIt.key().lower() );
115 } 116 }
116 else { 117 else {
117 labelLine.addParameter( "TYPE", typeIt.key() ); 118 labelLine.addParameter( "TYPE", typeIt.key() );
118 } 119 }
119 } 120 }
120 } 121 }
121 } 122 }
122 123
123 card.addLine( adrLine ); 124 card.addLine( adrLine );