summaryrefslogtreecommitdiff
path: root/libopie/pim
authoreilers <eilers>2002-12-07 13:26:22 (UTC)
committer eilers <eilers>2002-12-07 13:26:22 (UTC)
commit1e0c4ae8e82863179199b0437a6d9cca6b661a7e (patch) (unidiff)
tree8a452f8747290d638787ee47a3a8bf8147db0786 /libopie/pim
parentad2a10877ae6e50b1a765a9b7cff14494c65e588 (diff)
downloadopie-1e0c4ae8e82863179199b0437a6d9cca6b661a7e.zip
opie-1e0c4ae8e82863179199b0437a6d9cca6b661a7e.tar.gz
opie-1e0c4ae8e82863179199b0437a6d9cca6b661a7e.tar.bz2
Fixing bug in storing anniversary..
Diffstat (limited to 'libopie/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp37
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.h4
2 files changed, 28 insertions, 13 deletions
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index 09ae37b..ca9e410 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -12,16 +12,19 @@
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.5 2002/12/07 13:26:22 eilers
21 * Fixing bug in storing anniversary..
22 *
20 * Revision 1.4 2002/11/13 14:14:51 eilers 23 * Revision 1.4 2002/11/13 14:14:51 eilers
21 * Added sorted for Contacts.. 24 * Added sorted for Contacts..
22 * 25 *
23 * Revision 1.3 2002/11/11 16:41:09 kergoth 26 * Revision 1.3 2002/11/11 16:41:09 kergoth
24 * no default arguments in implementation 27 * no default arguments in implementation
25 * 28 *
26 * Revision 1.2 2002/11/10 15:41:53 eilers 29 * Revision 1.2 2002/11/10 15:41:53 eilers
27 * Bugfixes.. 30 * Bugfixes..
@@ -378,17 +381,17 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
378 } 381 }
379 else if ( name == "X-Qtopia-Spouse" ) { 382 else if ( name == "X-Qtopia-Spouse" ) {
380 c.setSpouse( value ); 383 c.setSpouse( value );
381 } 384 }
382 else if ( name == "X-Qtopia-Gender" ) { 385 else if ( name == "X-Qtopia-Gender" ) {
383 c.setGender( value ); 386 c.setGender( value );
384 } 387 }
385 else if ( name == "X-Qtopia-Anniversary" ) { 388 else if ( name == "X-Qtopia-Anniversary" ) {
386 c.setAnniversary( TimeConversion::fromString( value ) ); 389 c.setAnniversary( convVCardDateToDate( value ) );
387 } 390 }
388 else if ( name == "X-Qtopia-Nickname" ) { 391 else if ( name == "X-Qtopia-Nickname" ) {
389 c.setNickname( value ); 392 c.setNickname( value );
390 } 393 }
391 else if ( name == "X-Qtopia-Children" ) { 394 else if ( name == "X-Qtopia-Children" ) {
392 c.setChildren( value ); 395 c.setChildren( value );
393 } 396 }
394 else if ( name == VCBirthDateProp ) { 397 else if ( name == VCBirthDateProp ) {
@@ -489,50 +492,58 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
489 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 492 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
490 safeAddProp( email, VCInternetProp ); 493 safeAddProp( email, VCInternetProp );
491 } 494 }
492 495
493 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 496 safeAddPropValue( vcard, VCNoteProp, c.notes() );
494 497
495 // Exporting Birthday regarding RFC 2425 (5.8.4) 498 // Exporting Birthday regarding RFC 2425 (5.8.4)
496 if ( c.birthday().isValid() ){ 499 if ( c.birthday().isValid() ){
497 QString birthd_rfc2425 = QString("%1-%2-%3") 500 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
498 .arg( c.birthday().year() ) 501 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
499 .arg( c.birthday().month(), 2 )
500 .arg( c.birthday().day(), 2 );
501 // Now replace spaces with "0"...
502 int pos = 0;
503 while ( ( pos = birthd_rfc2425.find (' ') ) > 0 )
504 birthd_rfc2425.replace( pos, 1, "0" );
505
506 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
507 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
508 } 502 }
509 503
510 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 504 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
511 VObject *org = safeAddProp( vcard, VCOrgProp ); 505 VObject *org = safeAddProp( vcard, VCOrgProp );
512 safeAddPropValue( org, VCOrgNameProp, c.company() ); 506 safeAddPropValue( org, VCOrgNameProp, c.company() );
513 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 507 safeAddPropValue( org, VCOrgUnitProp, c.department() );
514 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 508 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
515 } 509 }
516 510
517 // some values we have to export as custom fields 511 // some values we have to export as custom fields
518 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 512 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
519 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 513 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
520 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 514 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
521 515
522 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 516 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
523 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 517 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
524 safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); 518 if ( c.anniversary().isValid() ){
519 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
520 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
521 }
525 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 522 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
526 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 523 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
527 524
528 return vcard; 525 return vcard;
529} 526}
530 527
528QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
529{
530 QString str_rfc2425 = QString("%1-%2-%3")
531 .arg( d.year() )
532 .arg( d.month(), 2 )
533 .arg( d.day(), 2 );
534 // Now replace spaces with "0"...
535 int pos = 0;
536 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
537 str_rfc2425.replace( pos, 1, "0" );
538
539 return str_rfc2425;
540}
541
531QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 542QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
532{ 543{
533 int monthPos = datestr.find('-'); 544 int monthPos = datestr.find('-');
534 int dayPos = datestr.find('-', monthPos+1 ); 545 int dayPos = datestr.find('-', monthPos+1 );
535 int sep_ignore = 1; 546 int sep_ignore = 1;
536 if ( monthPos == -1 || dayPos == -1 ) { 547 if ( monthPos == -1 || dayPos == -1 ) {
537 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 548 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
538 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) 549 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
diff --git a/libopie/pim/ocontactaccessbackend_vcard.h b/libopie/pim/ocontactaccessbackend_vcard.h
index 4437756..236da00 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.h
+++ b/libopie/pim/ocontactaccessbackend_vcard.h
@@ -12,16 +12,19 @@
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.4 2002/12/07 13:26:22 eilers
21 * Fixing bug in storing anniversary..
22 *
20 * Revision 1.3 2002/11/13 14:14:51 eilers 23 * Revision 1.3 2002/11/13 14:14:51 eilers
21 * Added sorted for Contacts.. 24 * Added sorted for Contacts..
22 * 25 *
23 * Revision 1.2 2002/11/10 15:41:53 eilers 26 * Revision 1.2 2002/11/10 15:41:53 eilers
24 * Bugfixes.. 27 * Bugfixes..
25 * 28 *
26 * Revision 1.1 2002/11/09 14:34:52 eilers 29 * Revision 1.1 2002/11/09 14:34:52 eilers
27 * Added VCard Backend. 30 * Added VCard Backend.
@@ -57,16 +60,17 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
57 const uint querySettings(); 60 const uint querySettings();
58 bool hasQuerySettings (uint querySettings) const; 61 bool hasQuerySettings (uint querySettings) const;
59 QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ); 62 QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
60 bool wasChangedExternally(); 63 bool wasChangedExternally();
61 64
62private: 65private:
63 OContact parseVObject( VObject* obj ); 66 OContact parseVObject( VObject* obj );
64 VObject* createVObject( const OContact& c ); 67 VObject* createVObject( const OContact& c );
68 QString convDateToVCardDate( const QDate& c ) const;
65 QDate convVCardDateToDate( const QString& datestr ); 69 QDate convVCardDateToDate( const QString& datestr );
66 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); 70 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
67 VObject *safeAddProp( VObject* o, const char* prop); 71 VObject *safeAddProp( VObject* o, const char* prop);
68 72
69 bool m_dirty : 1; 73 bool m_dirty : 1;
70 QString m_file; 74 QString m_file;
71 QMap<int, OContact> m_map; 75 QMap<int, OContact> m_map;
72}; 76};