summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp82
-rw-r--r--libopie/pim/otodoaccessvcal.cpp7
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp82
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp7
4 files changed, 108 insertions, 70 deletions
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index 1dc6b48..622d40a 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -16,8 +16,23 @@
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.7 2003/02/16 22:25:46 zecke
21 * 0000276 Fix for that bug.. or better temp workaround
22 * A Preferred Number is HOME|VOICE
23 * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test
24 * triggers both
25 * and the cell phone number overrides the other entries..
26 *
27 * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the
28 * number
29 *
30 * The right and final fix would be to reorder the if statement to make it
31 * if else based and the less common thing put to the bottom
32 *
33 * OTodoAccessVcal fix the date for beaming
34 *
20 * Revision 1.6 2003/01/13 15:49:31 eilers 35 * Revision 1.6 2003/01/13 15:49:31 eilers
21 * Fixing crash when businesscard.vcf is missing.. 36 * Fixing crash when businesscard.vcf is missing..
22 * 37 *
23 * Revision 1.5 2002/12/07 13:26:22 eilers 38 * Revision 1.5 2002/12/07 13:26:22 eilers
@@ -52,12 +67,12 @@ OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString fil
52} 67}
53 68
54 69
55bool OContactAccessBackend_VCard::load () 70bool OContactAccessBackend_VCard::load ()
56{ 71{
57 m_map.clear(); 72 m_map.clear();
58 m_dirty = false; 73 m_dirty = false;
59 74
60 VObject* obj = 0l; 75 VObject* obj = 0l;
61 76
62 if ( QFile( m_file ).exists() ){ 77 if ( QFile( m_file ).exists() ){
63 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 78 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
@@ -80,9 +95,9 @@ bool OContactAccessBackend_VCard::load ()
80 qWarning("assigned new uid %d",con.uid() ); 95 qWarning("assigned new uid %d",con.uid() );
81 } 96 }
82 97
83 m_map.insert( con.uid(), con ); 98 m_map.insert( con.uid(), con );
84 99
85 VObject *t = obj; 100 VObject *t = obj;
86 obj = nextVObjectInList(obj); 101 obj = nextVObjectInList(obj);
87 cleanVObject( t ); 102 cleanVObject( t );
88 } 103 }
@@ -94,9 +109,9 @@ bool OContactAccessBackend_VCard::reload()
94{ 109{
95 return load(); 110 return load();
96} 111}
97bool OContactAccessBackend_VCard::save() 112bool OContactAccessBackend_VCard::save()
98{ 113{
99 if (!m_dirty ) 114 if (!m_dirty )
100 return true; 115 return true;
101 116
102 QFileDirect file( m_file ); 117 QFileDirect file( m_file );
@@ -116,9 +131,9 @@ bool OContactAccessBackend_VCard::save()
116 cleanStrTbl(); 131 cleanStrTbl();
117 132
118 m_dirty = false; 133 m_dirty = false;
119 return true; 134 return true;
120 135
121 136
122} 137}
123void OContactAccessBackend_VCard::clear () 138void OContactAccessBackend_VCard::clear ()
124{ 139{
@@ -136,18 +151,18 @@ bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
136bool OContactAccessBackend_VCard::remove ( int uid ) 151bool OContactAccessBackend_VCard::remove ( int uid )
137{ 152{
138 m_map.remove( uid ); 153 m_map.remove( uid );
139 m_dirty = true; 154 m_dirty = true;
140 return true; 155 return true;
141} 156}
142 157
143bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 158bool OContactAccessBackend_VCard::replace ( const OContact &contact )
144{ 159{
145 m_map.replace( contact.uid(), contact ); 160 m_map.replace( contact.uid(), contact );
146 m_dirty = true; 161 m_dirty = true;
147 return true; 162 return true;
148} 163}
149 164
150OContact OContactAccessBackend_VCard::find ( int uid ) const 165OContact OContactAccessBackend_VCard::find ( int uid ) const
151{ 166{
152 return m_map[uid]; 167 return m_map[uid];
153} 168}
@@ -205,9 +220,9 @@ QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int )
205 220
206OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 221OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
207{ 222{
208 OContact c; 223 OContact c;
209 224
210 VObjectIterator it; 225 VObjectIterator it;
211 initPropIterator( &it, obj ); 226 initPropIterator( &it, obj );
212 while( moreIteration( &it ) ) { 227 while( moreIteration( &it ) ) {
213 VObject *o = nextVObject( &it ); 228 VObject *o = nextVObject( &it );
@@ -238,9 +253,9 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
238 QString city; 253 QString city;
239 QString region; 254 QString region;
240 QString postal; 255 QString postal;
241 QString country; 256 QString country;
242 257
243 VObjectIterator nit; 258 VObjectIterator nit;
244 initPropIterator( &nit, o ); 259 initPropIterator( &nit, o );
245 while( moreIteration( &nit ) ) { 260 while( moreIteration( &nit ) ) {
246 VObject *o = nextVObject( &nit ); 261 VObject *o = nextVObject( &nit );
@@ -285,9 +300,9 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
285 PAGER = 0x20, 300 PAGER = 0x20,
286 UNKNOWN = 0x80 301 UNKNOWN = 0x80
287 }; 302 };
288 int type = 0; 303 int type = 0;
289 304
290 VObjectIterator nit; 305 VObjectIterator nit;
291 initPropIterator( &nit, o ); 306 initPropIterator( &nit, o );
292 while( moreIteration( &nit ) ) { 307 while( moreIteration( &nit ) ) {
293 VObject *o = nextVObject( &nit ); 308 VObject *o = nextVObject( &nit );
@@ -313,16 +328,17 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
313 if ( ( type & (HOME|WORK) ) == 0 ) // default 328 if ( ( type & (HOME|WORK) ) == 0 ) // default
314 type |= HOME; 329 type |= HOME;
315 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 330 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
316 type |= VOICE; 331 type |= VOICE;
317 332
318 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 333 qWarning("value %s %d", value.data(), type );
334 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
319 c.setHomePhone( value ); 335 c.setHomePhone( value );
320 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 336 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
321 c.setHomeFax( value ); 337 c.setHomeFax( value );
322 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 338 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
323 c.setHomeMobile( value ); 339 c.setHomeMobile( value );
324 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 340 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
325 c.setBusinessPhone( value ); 341 c.setBusinessPhone( value );
326 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 342 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
327 c.setBusinessFax( value ); 343 c.setBusinessFax( value );
328 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 344 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
@@ -405,11 +421,11 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
405 } 421 }
406 else if ( name == VCBirthDateProp ) { 422 else if ( name == VCBirthDateProp ) {
407 // Reading Birthdate regarding RFC 2425 (5.8.4) 423 // Reading Birthdate regarding RFC 2425 (5.8.4)
408 c.setBirthday( convVCardDateToDate( value ) ); 424 c.setBirthday( convVCardDateToDate( value ) );
409 425
410 } 426 }
411 427
412#if 0 428#if 0
413 else { 429 else {
414 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 430 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
415 VObjectIterator nit; 431 VObjectIterator nit;
@@ -433,50 +449,50 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
433 VObject *vcard = newVObject( VCCardProp ); 449 VObject *vcard = newVObject( VCCardProp );
434 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 450 safeAddPropValue( vcard, VCVersionProp, "2.1" );
435 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 451 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
436 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 452 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
437 453
438 // full name 454 // full name
439 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 455 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
440 456
441 // name properties 457 // name properties
442 VObject *name = safeAddProp( vcard, VCNameProp ); 458 VObject *name = safeAddProp( vcard, VCNameProp );
443 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 459 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
444 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 460 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
445 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 461 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
446 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 462 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
447 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 463 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
448 464
449 // home properties 465 // home properties
450 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 466 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
451 safeAddProp( home_adr, VCHomeProp ); 467 safeAddProp( home_adr, VCHomeProp );
452 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 468 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
453 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 469 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
454 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 470 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
455 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 471 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
456 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 472 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
457 473
458 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 474 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
459 safeAddProp( home_phone, VCHomeProp ); 475 safeAddProp( home_phone, VCHomeProp );
460 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 476 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
461 safeAddProp( home_phone, VCHomeProp ); 477 safeAddProp( home_phone, VCHomeProp );
462 safeAddProp( home_phone, VCCellularProp ); 478 safeAddProp( home_phone, VCCellularProp );
463 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 479 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
464 safeAddProp( home_phone, VCHomeProp ); 480 safeAddProp( home_phone, VCHomeProp );
465 safeAddProp( home_phone, VCFaxProp ); 481 safeAddProp( home_phone, VCFaxProp );
466 482
467 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 483 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
468 safeAddProp( url, VCHomeProp ); 484 safeAddProp( url, VCHomeProp );
469 485
470 // work properties 486 // work properties
471 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 487 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
472 safeAddProp( work_adr, VCWorkProp ); 488 safeAddProp( work_adr, VCWorkProp );
473 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 489 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
474 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 490 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
475 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 491 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
476 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 492 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
477 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 493 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
478 494
479 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 495 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
480 safeAddProp( work_phone, VCWorkProp ); 496 safeAddProp( work_phone, VCWorkProp );
481 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 497 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
482 safeAddProp( work_phone, VCWorkProp ); 498 safeAddProp( work_phone, VCWorkProp );
@@ -486,52 +502,52 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
486 safeAddProp( work_phone, VCFaxProp ); 502 safeAddProp( work_phone, VCFaxProp );
487 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 503 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
488 safeAddProp( work_phone, VCWorkProp ); 504 safeAddProp( work_phone, VCWorkProp );
489 safeAddProp( work_phone, VCPagerProp ); 505 safeAddProp( work_phone, VCPagerProp );
490 506
491 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 507 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
492 safeAddProp( url, VCWorkProp ); 508 safeAddProp( url, VCWorkProp );
493 509
494 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 510 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
495 safeAddProp( title, VCWorkProp ); 511 safeAddProp( title, VCWorkProp );
496 512
497 513
498 QStringList emails = c.emailList(); 514 QStringList emails = c.emailList();
499 emails.prepend( c.defaultEmail() ); 515 emails.prepend( c.defaultEmail() );
500 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 516 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
501 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 517 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
502 safeAddProp( email, VCInternetProp ); 518 safeAddProp( email, VCInternetProp );
503 } 519 }
504 520
505 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 521 safeAddPropValue( vcard, VCNoteProp, c.notes() );
506 522
507 // Exporting Birthday regarding RFC 2425 (5.8.4) 523 // Exporting Birthday regarding RFC 2425 (5.8.4)
508 if ( c.birthday().isValid() ){ 524 if ( c.birthday().isValid() ){
509 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 525 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
510 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 526 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
511 } 527 }
512 528
513 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 529 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
514 VObject *org = safeAddProp( vcard, VCOrgProp ); 530 VObject *org = safeAddProp( vcard, VCOrgProp );
515 safeAddPropValue( org, VCOrgNameProp, c.company() ); 531 safeAddPropValue( org, VCOrgNameProp, c.company() );
516 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 532 safeAddPropValue( org, VCOrgUnitProp, c.department() );
517 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 533 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
518 } 534 }
519 535
520 // some values we have to export as custom fields 536 // some values we have to export as custom fields
521 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 537 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
522 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 538 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
523 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 539 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
524 540
525 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 541 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
526 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 542 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
527 if ( c.anniversary().isValid() ){ 543 if ( c.anniversary().isValid() ){
528 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 544 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
529 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 545 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
530 } 546 }
531 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 547 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
532 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 548 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
533 549
534 return vcard; 550 return vcard;
535} 551}
536 552
537QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const 553QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
@@ -543,9 +559,9 @@ QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
543 // Now replace spaces with "0"... 559 // Now replace spaces with "0"...
544 int pos = 0; 560 int pos = 0;
545 while ( ( pos = str_rfc2425.find (' ') ) > 0 ) 561 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
546 str_rfc2425.replace( pos, 1, "0" ); 562 str_rfc2425.replace( pos, 1, "0" );
547 563
548 return str_rfc2425; 564 return str_rfc2425;
549} 565}
550 566
551QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 567QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp
index e96cc3c..309f9e1 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/libopie/pim/otodoaccessvcal.cpp
@@ -57,11 +57,14 @@ namespace {
57 VObject *task = newVObject( VCTodoProp ); 57 VObject *task = newVObject( VCTodoProp );
58 if( task == 0 ) 58 if( task == 0 )
59 return 0l; 59 return 0l;
60 60
61 if( event.hasDueDate() ) 61 if( event.hasDueDate() ) {
62 QTime time(0, 0, 0);
63 QDateTime date(event.dueDate(), time );
62 addPropValue( task, VCDueProp, 64 addPropValue( task, VCDueProp,
63 TimeConversion::toISO8601( event.dueDate() ) ); 65 TimeConversion::toISO8601( date ) );
66 }
64 67
65 if( event.isCompleted() ) 68 if( event.isCompleted() )
66 addPropValue( task, VCStatusProp, "COMPLETED"); 69 addPropValue( task, VCStatusProp, "COMPLETED");
67 70
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index 1dc6b48..622d40a 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -16,8 +16,23 @@
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.7 2003/02/16 22:25:46 zecke
21 * 0000276 Fix for that bug.. or better temp workaround
22 * A Preferred Number is HOME|VOICE
23 * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test
24 * triggers both
25 * and the cell phone number overrides the other entries..
26 *
27 * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the
28 * number
29 *
30 * The right and final fix would be to reorder the if statement to make it
31 * if else based and the less common thing put to the bottom
32 *
33 * OTodoAccessVcal fix the date for beaming
34 *
20 * Revision 1.6 2003/01/13 15:49:31 eilers 35 * Revision 1.6 2003/01/13 15:49:31 eilers
21 * Fixing crash when businesscard.vcf is missing.. 36 * Fixing crash when businesscard.vcf is missing..
22 * 37 *
23 * Revision 1.5 2002/12/07 13:26:22 eilers 38 * Revision 1.5 2002/12/07 13:26:22 eilers
@@ -52,12 +67,12 @@ OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString fil
52} 67}
53 68
54 69
55bool OContactAccessBackend_VCard::load () 70bool OContactAccessBackend_VCard::load ()
56{ 71{
57 m_map.clear(); 72 m_map.clear();
58 m_dirty = false; 73 m_dirty = false;
59 74
60 VObject* obj = 0l; 75 VObject* obj = 0l;
61 76
62 if ( QFile( m_file ).exists() ){ 77 if ( QFile( m_file ).exists() ){
63 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 78 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
@@ -80,9 +95,9 @@ bool OContactAccessBackend_VCard::load ()
80 qWarning("assigned new uid %d",con.uid() ); 95 qWarning("assigned new uid %d",con.uid() );
81 } 96 }
82 97
83 m_map.insert( con.uid(), con ); 98 m_map.insert( con.uid(), con );
84 99
85 VObject *t = obj; 100 VObject *t = obj;
86 obj = nextVObjectInList(obj); 101 obj = nextVObjectInList(obj);
87 cleanVObject( t ); 102 cleanVObject( t );
88 } 103 }
@@ -94,9 +109,9 @@ bool OContactAccessBackend_VCard::reload()
94{ 109{
95 return load(); 110 return load();
96} 111}
97bool OContactAccessBackend_VCard::save() 112bool OContactAccessBackend_VCard::save()
98{ 113{
99 if (!m_dirty ) 114 if (!m_dirty )
100 return true; 115 return true;
101 116
102 QFileDirect file( m_file ); 117 QFileDirect file( m_file );
@@ -116,9 +131,9 @@ bool OContactAccessBackend_VCard::save()
116 cleanStrTbl(); 131 cleanStrTbl();
117 132
118 m_dirty = false; 133 m_dirty = false;
119 return true; 134 return true;
120 135
121 136
122} 137}
123void OContactAccessBackend_VCard::clear () 138void OContactAccessBackend_VCard::clear ()
124{ 139{
@@ -136,18 +151,18 @@ bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
136bool OContactAccessBackend_VCard::remove ( int uid ) 151bool OContactAccessBackend_VCard::remove ( int uid )
137{ 152{
138 m_map.remove( uid ); 153 m_map.remove( uid );
139 m_dirty = true; 154 m_dirty = true;
140 return true; 155 return true;
141} 156}
142 157
143bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 158bool OContactAccessBackend_VCard::replace ( const OContact &contact )
144{ 159{
145 m_map.replace( contact.uid(), contact ); 160 m_map.replace( contact.uid(), contact );
146 m_dirty = true; 161 m_dirty = true;
147 return true; 162 return true;
148} 163}
149 164
150OContact OContactAccessBackend_VCard::find ( int uid ) const 165OContact OContactAccessBackend_VCard::find ( int uid ) const
151{ 166{
152 return m_map[uid]; 167 return m_map[uid];
153} 168}
@@ -205,9 +220,9 @@ QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int )
205 220
206OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 221OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
207{ 222{
208 OContact c; 223 OContact c;
209 224
210 VObjectIterator it; 225 VObjectIterator it;
211 initPropIterator( &it, obj ); 226 initPropIterator( &it, obj );
212 while( moreIteration( &it ) ) { 227 while( moreIteration( &it ) ) {
213 VObject *o = nextVObject( &it ); 228 VObject *o = nextVObject( &it );
@@ -238,9 +253,9 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
238 QString city; 253 QString city;
239 QString region; 254 QString region;
240 QString postal; 255 QString postal;
241 QString country; 256 QString country;
242 257
243 VObjectIterator nit; 258 VObjectIterator nit;
244 initPropIterator( &nit, o ); 259 initPropIterator( &nit, o );
245 while( moreIteration( &nit ) ) { 260 while( moreIteration( &nit ) ) {
246 VObject *o = nextVObject( &nit ); 261 VObject *o = nextVObject( &nit );
@@ -285,9 +300,9 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
285 PAGER = 0x20, 300 PAGER = 0x20,
286 UNKNOWN = 0x80 301 UNKNOWN = 0x80
287 }; 302 };
288 int type = 0; 303 int type = 0;
289 304
290 VObjectIterator nit; 305 VObjectIterator nit;
291 initPropIterator( &nit, o ); 306 initPropIterator( &nit, o );
292 while( moreIteration( &nit ) ) { 307 while( moreIteration( &nit ) ) {
293 VObject *o = nextVObject( &nit ); 308 VObject *o = nextVObject( &nit );
@@ -313,16 +328,17 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
313 if ( ( type & (HOME|WORK) ) == 0 ) // default 328 if ( ( type & (HOME|WORK) ) == 0 ) // default
314 type |= HOME; 329 type |= HOME;
315 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 330 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
316 type |= VOICE; 331 type |= VOICE;
317 332
318 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 333 qWarning("value %s %d", value.data(), type );
334 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
319 c.setHomePhone( value ); 335 c.setHomePhone( value );
320 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 336 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
321 c.setHomeFax( value ); 337 c.setHomeFax( value );
322 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 338 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
323 c.setHomeMobile( value ); 339 c.setHomeMobile( value );
324 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 340 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
325 c.setBusinessPhone( value ); 341 c.setBusinessPhone( value );
326 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 342 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
327 c.setBusinessFax( value ); 343 c.setBusinessFax( value );
328 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 344 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
@@ -405,11 +421,11 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
405 } 421 }
406 else if ( name == VCBirthDateProp ) { 422 else if ( name == VCBirthDateProp ) {
407 // Reading Birthdate regarding RFC 2425 (5.8.4) 423 // Reading Birthdate regarding RFC 2425 (5.8.4)
408 c.setBirthday( convVCardDateToDate( value ) ); 424 c.setBirthday( convVCardDateToDate( value ) );
409 425
410 } 426 }
411 427
412#if 0 428#if 0
413 else { 429 else {
414 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 430 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
415 VObjectIterator nit; 431 VObjectIterator nit;
@@ -433,50 +449,50 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
433 VObject *vcard = newVObject( VCCardProp ); 449 VObject *vcard = newVObject( VCCardProp );
434 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 450 safeAddPropValue( vcard, VCVersionProp, "2.1" );
435 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 451 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
436 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 452 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
437 453
438 // full name 454 // full name
439 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 455 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
440 456
441 // name properties 457 // name properties
442 VObject *name = safeAddProp( vcard, VCNameProp ); 458 VObject *name = safeAddProp( vcard, VCNameProp );
443 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 459 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
444 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 460 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
445 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 461 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
446 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 462 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
447 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 463 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
448 464
449 // home properties 465 // home properties
450 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 466 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
451 safeAddProp( home_adr, VCHomeProp ); 467 safeAddProp( home_adr, VCHomeProp );
452 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 468 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
453 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 469 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
454 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 470 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
455 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 471 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
456 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 472 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
457 473
458 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 474 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
459 safeAddProp( home_phone, VCHomeProp ); 475 safeAddProp( home_phone, VCHomeProp );
460 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 476 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
461 safeAddProp( home_phone, VCHomeProp ); 477 safeAddProp( home_phone, VCHomeProp );
462 safeAddProp( home_phone, VCCellularProp ); 478 safeAddProp( home_phone, VCCellularProp );
463 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 479 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
464 safeAddProp( home_phone, VCHomeProp ); 480 safeAddProp( home_phone, VCHomeProp );
465 safeAddProp( home_phone, VCFaxProp ); 481 safeAddProp( home_phone, VCFaxProp );
466 482
467 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 483 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
468 safeAddProp( url, VCHomeProp ); 484 safeAddProp( url, VCHomeProp );
469 485
470 // work properties 486 // work properties
471 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 487 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
472 safeAddProp( work_adr, VCWorkProp ); 488 safeAddProp( work_adr, VCWorkProp );
473 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 489 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
474 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 490 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
475 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 491 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
476 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 492 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
477 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 493 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
478 494
479 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 495 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
480 safeAddProp( work_phone, VCWorkProp ); 496 safeAddProp( work_phone, VCWorkProp );
481 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 497 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
482 safeAddProp( work_phone, VCWorkProp ); 498 safeAddProp( work_phone, VCWorkProp );
@@ -486,52 +502,52 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
486 safeAddProp( work_phone, VCFaxProp ); 502 safeAddProp( work_phone, VCFaxProp );
487 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 503 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
488 safeAddProp( work_phone, VCWorkProp ); 504 safeAddProp( work_phone, VCWorkProp );
489 safeAddProp( work_phone, VCPagerProp ); 505 safeAddProp( work_phone, VCPagerProp );
490 506
491 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 507 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
492 safeAddProp( url, VCWorkProp ); 508 safeAddProp( url, VCWorkProp );
493 509
494 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 510 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
495 safeAddProp( title, VCWorkProp ); 511 safeAddProp( title, VCWorkProp );
496 512
497 513
498 QStringList emails = c.emailList(); 514 QStringList emails = c.emailList();
499 emails.prepend( c.defaultEmail() ); 515 emails.prepend( c.defaultEmail() );
500 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 516 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
501 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 517 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
502 safeAddProp( email, VCInternetProp ); 518 safeAddProp( email, VCInternetProp );
503 } 519 }
504 520
505 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 521 safeAddPropValue( vcard, VCNoteProp, c.notes() );
506 522
507 // Exporting Birthday regarding RFC 2425 (5.8.4) 523 // Exporting Birthday regarding RFC 2425 (5.8.4)
508 if ( c.birthday().isValid() ){ 524 if ( c.birthday().isValid() ){
509 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 525 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
510 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 526 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
511 } 527 }
512 528
513 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 529 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
514 VObject *org = safeAddProp( vcard, VCOrgProp ); 530 VObject *org = safeAddProp( vcard, VCOrgProp );
515 safeAddPropValue( org, VCOrgNameProp, c.company() ); 531 safeAddPropValue( org, VCOrgNameProp, c.company() );
516 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 532 safeAddPropValue( org, VCOrgUnitProp, c.department() );
517 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 533 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
518 } 534 }
519 535
520 // some values we have to export as custom fields 536 // some values we have to export as custom fields
521 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 537 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
522 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 538 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
523 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 539 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
524 540
525 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 541 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
526 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 542 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
527 if ( c.anniversary().isValid() ){ 543 if ( c.anniversary().isValid() ){
528 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 544 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
529 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 545 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
530 } 546 }
531 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 547 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
532 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 548 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
533 549
534 return vcard; 550 return vcard;
535} 551}
536 552
537QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const 553QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
@@ -543,9 +559,9 @@ QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
543 // Now replace spaces with "0"... 559 // Now replace spaces with "0"...
544 int pos = 0; 560 int pos = 0;
545 while ( ( pos = str_rfc2425.find (' ') ) > 0 ) 561 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
546 str_rfc2425.replace( pos, 1, "0" ); 562 str_rfc2425.replace( pos, 1, "0" );
547 563
548 return str_rfc2425; 564 return str_rfc2425;
549} 565}
550 566
551QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 567QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index e96cc3c..309f9e1 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -57,11 +57,14 @@ namespace {
57 VObject *task = newVObject( VCTodoProp ); 57 VObject *task = newVObject( VCTodoProp );
58 if( task == 0 ) 58 if( task == 0 )
59 return 0l; 59 return 0l;
60 60
61 if( event.hasDueDate() ) 61 if( event.hasDueDate() ) {
62 QTime time(0, 0, 0);
63 QDateTime date(event.dueDate(), time );
62 addPropValue( task, VCDueProp, 64 addPropValue( task, VCDueProp,
63 TimeConversion::toISO8601( event.dueDate() ) ); 65 TimeConversion::toISO8601( date ) );
66 }
64 67
65 if( event.isCompleted() ) 68 if( event.isCompleted() )
66 addPropValue( task, VCStatusProp, "COMPLETED"); 69 addPropValue( task, VCStatusProp, "COMPLETED");
67 70