summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index ffa6a7d..b6ea461 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -32,12 +32,14 @@
32 32
33 33
34#include "vobject_p.h" 34#include "vobject_p.h"
35 35
36/* OPIE */ 36/* OPIE */
37#include <opie2/ocontactaccessbackend_vcard.h> 37#include <opie2/ocontactaccessbackend_vcard.h>
38#include <opie2/odebug.h>
39
38#include <qpe/timeconversion.h> 40#include <qpe/timeconversion.h>
39 41
40//FIXME: Hack to allow direct access to FILE* fh. Rewrite this! 42//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
41#define protected public 43#define protected public
42#include <qfile.h> 44#include <qfile.h>
43#undef protected 45#undef protected
@@ -61,26 +63,26 @@ bool OPimContactAccessBackend_VCard::load ()
61 63
62 if ( QFile::exists(m_file) ){ 64 if ( QFile::exists(m_file) ){
63 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 65 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
64 if ( !obj ) 66 if ( !obj )
65 return false; 67 return false;
66 }else{ 68 }else{
67 qWarning("File \"%s\" not found !", m_file.latin1() ); 69 owarn << "File \"" << m_file << "\" not found !" << oendl;
68 return false; 70 return false;
69 } 71 }
70 72
71 while ( obj ) { 73 while ( obj ) {
72 OPimContact con = parseVObject( obj ); 74 OPimContact con = parseVObject( obj );
73 /* 75 /*
74 * if uid is 0 assign a new one 76 * if uid is 0 assign a new one
75 * this at least happens on 77 * this at least happens on
76 * Nokia6210 78 * Nokia6210
77 */ 79 */
78 if ( con.uid() == 0 ){ 80 if ( con.uid() == 0 ){
79 con.setUid( 1 ); 81 con.setUid( 1 );
80 qWarning("assigned new uid %d",con.uid() ); 82 owarn << "assigned new uid " << con.uid() << "" << oendl;
81 } 83 }
82 84
83 m_map.insert( con.uid(), con ); 85 m_map.insert( con.uid(), con );
84 86
85 VObject *t = obj; 87 VObject *t = obj;
86 obj = nextVObjectInList(obj); 88 obj = nextVObjectInList(obj);
@@ -313,13 +315,13 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
313 if ( (type & UNKNOWN) != UNKNOWN ) { 315 if ( (type & UNKNOWN) != UNKNOWN ) {
314 if ( ( type & (HOME|WORK) ) == 0 ) // default 316 if ( ( type & (HOME|WORK) ) == 0 ) // default
315 type |= HOME; 317 type |= HOME;
316 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 318 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
317 type |= VOICE; 319 type |= VOICE;
318 320
319 qWarning("value %s %d", value.data(), type ); 321 owarn << "value " << value.data() << " " << type << "" << oendl;
320 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 322 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
321 c.setHomePhone( value ); 323 c.setHomePhone( value );
322 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 324 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
323 c.setHomeFax( value ); 325 c.setHomeFax( value );
324 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 326 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
325 c.setHomeMobile( value ); 327 c.setHomeMobile( value );
@@ -507,13 +509,13 @@ VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
507 } 509 }
508 510
509 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 511 safeAddPropValue( vcard, VCNoteProp, c.notes() );
510 512
511 // Exporting Birthday regarding RFC 2425 (5.8.4) 513 // Exporting Birthday regarding RFC 2425 (5.8.4)
512 if ( c.birthday().isValid() ){ 514 if ( c.birthday().isValid() ){
513 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 515 owarn << "Exporting birthday as: " << convDateToVCardDate( c.birthday() ) << "" << oendl;
514 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 516 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
515 } 517 }
516 518
517 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 519 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
518 VObject *org = safeAddProp( vcard, VCOrgProp ); 520 VObject *org = safeAddProp( vcard, VCOrgProp );
519 safeAddPropValue( org, VCOrgNameProp, c.company() ); 521 safeAddPropValue( org, VCOrgNameProp, c.company() );
@@ -526,13 +528,13 @@ VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
526 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 528 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
527 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 529 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
528 530
529 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 531 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
530 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 532 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
531 if ( c.anniversary().isValid() ){ 533 if ( c.anniversary().isValid() ){
532 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 534 owarn << "Exporting anniversary as: " << convDateToVCardDate( c.anniversary() ) << "" << oendl;
533 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 535 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
534 } 536 }
535 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 537 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
536 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 538 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
537 539
538 return vcard; 540 return vcard;
@@ -555,27 +557,27 @@ QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) co
555QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 557QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
556{ 558{
557 int monthPos = datestr.find('-'); 559 int monthPos = datestr.find('-');
558 int dayPos = datestr.find('-', monthPos+1 ); 560 int dayPos = datestr.find('-', monthPos+1 );
559 int sep_ignore = 1; 561 int sep_ignore = 1;
560 if ( monthPos == -1 || dayPos == -1 ) { 562 if ( monthPos == -1 || dayPos == -1 ) {
561 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 563 odebug << "fromString didn't find - in str = " << datestr << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
562 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) 564 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
563 if ( datestr.length() == 8 ){ 565 if ( datestr.length() == 8 ){
564 monthPos = 4; 566 monthPos = 4;
565 dayPos = 6; 567 dayPos = 6;
566 sep_ignore = 0; 568 sep_ignore = 0;
567 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 569 odebug << "Try with follwing positions str = " << datestr << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
568 } else { 570 } else {
569 return QDate(); 571 return QDate();
570 } 572 }
571 } 573 }
572 int y = datestr.left( monthPos ).toInt(); 574 int y = datestr.left( monthPos ).toInt();
573 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 575 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
574 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 576 int d = datestr.mid( dayPos + sep_ignore ).toInt();
575 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 577 odebug << "TimeConversion::fromString ymd = " << datestr << " => " << y << " " << m << " " << d << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
576 QDate date ( y,m,d ); 578 QDate date ( y,m,d );
577 return date; 579 return date;
578} 580}
579 581
580VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) 582VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
581{ 583{