author | eilers <eilers> | 2004-11-19 11:27:04 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-11-19 11:27:04 (UTC) |
commit | 58759f9d1219ecb5eddc9c8c19f89004ee2a942a (patch) (side-by-side diff) | |
tree | 6f34792623e60de8b73d0de52075864675980944 /libopie2 | |
parent | 362e353e4ee43a5aa37fd4c264ad0b40bbd0098b (diff) | |
download | opie-58759f9d1219ecb5eddc9c8c19f89004ee2a942a.zip opie-58759f9d1219ecb5eddc9c8c19f89004ee2a942a.tar.gz opie-58759f9d1219ecb5eddc9c8c19f89004ee2a942a.tar.bz2 |
Make VCARD importer more stable if something parsed which was not expected.
Thus, we are now able to import VCards from Evolution 2 and Apple Addressbook..
This is fixing issue #1479
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | 36 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.h | 7 |
2 files changed, 36 insertions, 7 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index 43e530a..5bb21c7 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp @@ -50,3 +50,5 @@ OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& m_dirty( false ), - m_file( filename ) + m_file( filename ), + version_major( 1 ), + version_minor( 0 ) { @@ -188,3 +190,2 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) OPimContact c; - VObjectIterator it; @@ -195,4 +196,13 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) QString value = QString::fromUtf8( vObjectStringZValue( o ) ); - odebug << "(1)Read: %s" << QString( value ).latin1() << oendl; - if ( name == VCNameProp ) { + odebug << "(1)Read: " << name << " " << QString( value ).latin1() << oendl; + if ( name == VCVersionProp ) { + + odebug << "Version: " << value << oendl; + QStringList version = QStringList::split( ".", value ); + version_major = version[0].toUInt(); + version_minor = version[1].toUInt(); + odebug << "Major: "<< version_major << " Minor: " << version_minor << oendl; + + } + else if ( name == VCNameProp ) { VObjectIterator nit; @@ -203,3 +213,3 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) QString value = QString::fromUtf8( vObjectStringZValue( o ) ); - odebug << "(2)Read: %s" << value.latin1() << oendl; + odebug << "Nametype is: "<< name << " Value: " << value.latin1() << oendl; if ( name == VCNamePrefixesProp ) @@ -228,4 +238,5 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); QString value = QString::fromUtf8( vObjectStringZValue( o ) ); + odebug << "AddressType is: "<< name << " Value: " << value.latin1() << oendl; if ( name == VCHomeProp ) @@ -276,2 +287,3 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) QCString name = vObjectTypeInfo( o ); + odebug << "Telephonetype is: "<< name << " Value: " << value.latin1() << oendl; if ( name == VCHomeProp ) @@ -290,2 +302,4 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) ; + else if ( name.left( 2 ) == "X-" || name.left( 2 ) == "x-" ) + ; // Ignore else @@ -299,2 +313,4 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) + odebug << "value %s %d" << value.data() << type << oendl; + if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) @@ -323,7 +339,11 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) QCString name = vObjectTypeInfo( o ); + odebug << "Emailtype is: "<< name << " Value: " << value.latin1() << oendl; if ( name != VCInternetProp && name != VCHomeProp && name != VCWorkProp && - name != VCPreferredProp ) + name != VCPreferredProp && + name.left( 2 ) != "X-" && name.left( 2 ) != "x-" ){ // ### preffered should map to default email valid = FALSE; + odebug << "Email was detected as invalid!" << oendl; + } } @@ -584,2 +604,4 @@ VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *pr + + } diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h index 1faf747..b734530 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h @@ -77,2 +77,9 @@ private: QMap<int, OPimContact> m_map; + + /** + * Version of parsed VCard + */ + uint version_major; + uint version_minor; + }; |