summaryrefslogtreecommitdiff
authoreilers <eilers>2004-11-19 11:27:04 (UTC)
committer eilers <eilers>2004-11-19 11:27:04 (UTC)
commit58759f9d1219ecb5eddc9c8c19f89004ee2a942a (patch) (unidiff)
tree6f34792623e60de8b73d0de52075864675980944
parent362e353e4ee43a5aa37fd4c264ad0b40bbd0098b (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp36
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h7
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&
50 m_dirty( false ), 50 m_dirty( false ),
51 m_file( filename ) 51 m_file( filename ),
52 version_major( 1 ),
53 version_minor( 0 )
52{ 54{
@@ -188,3 +190,2 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
188 OPimContact c; 190 OPimContact c;
189
190 VObjectIterator it; 191 VObjectIterator it;
@@ -195,4 +196,13 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
195 QString value = QString::fromUtf8( vObjectStringZValue( o ) ); 196 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
196 odebug << "(1)Read: %s" << QString( value ).latin1() << oendl; 197 odebug << "(1)Read: " << name << " " << QString( value ).latin1() << oendl;
197 if ( name == VCNameProp ) { 198 if ( name == VCVersionProp ) {
199
200 odebug << "Version: " << value << oendl;
201 QStringList version = QStringList::split( ".", value );
202 version_major = version[0].toUInt();
203 version_minor = version[1].toUInt();
204 odebug << "Major: "<< version_major << " Minor: " << version_minor << oendl;
205
206 }
207 else if ( name == VCNameProp ) {
198 VObjectIterator nit; 208 VObjectIterator nit;
@@ -203,3 +213,3 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
203 QString value = QString::fromUtf8( vObjectStringZValue( o ) ); 213 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
204 odebug << "(2)Read: %s" << value.latin1() << oendl; 214 odebug << "Nametype is: "<< name << " Value: " << value.latin1() << oendl;
205 if ( name == VCNamePrefixesProp ) 215 if ( name == VCNamePrefixesProp )
@@ -228,4 +238,5 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
228 VObject *o = nextVObject( &nit ); 238 VObject *o = nextVObject( &nit );
229 QCString name = vObjectName( o ); 239 QCString name = vObjectTypeInfo( o );
230 QString value = QString::fromUtf8( vObjectStringZValue( o ) ); 240 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
241 odebug << "AddressType is: "<< name << " Value: " << value.latin1() << oendl;
231 if ( name == VCHomeProp ) 242 if ( name == VCHomeProp )
@@ -276,2 +287,3 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
276 QCString name = vObjectTypeInfo( o ); 287 QCString name = vObjectTypeInfo( o );
288 odebug << "Telephonetype is: "<< name << " Value: " << value.latin1() << oendl;
277 if ( name == VCHomeProp ) 289 if ( name == VCHomeProp )
@@ -290,2 +302,4 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
290 ; 302 ;
303 else if ( name.left( 2 ) == "X-" || name.left( 2 ) == "x-" )
304 ; // Ignore
291 else 305 else
@@ -299,2 +313,4 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
299 313
314 odebug << "value %s %d" << value.data() << type << oendl;
315
300 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 316 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
@@ -323,7 +339,11 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
323 QCString name = vObjectTypeInfo( o ); 339 QCString name = vObjectTypeInfo( o );
340 odebug << "Emailtype is: "<< name << " Value: " << value.latin1() << oendl;
324 if ( name != VCInternetProp && name != VCHomeProp && 341 if ( name != VCInternetProp && name != VCHomeProp &&
325 name != VCWorkProp && 342 name != VCWorkProp &&
326 name != VCPreferredProp ) 343 name != VCPreferredProp &&
344 name.left( 2 ) != "X-" && name.left( 2 ) != "x-" ){
327 // ### preffered should map to default email 345 // ### preffered should map to default email
328 valid = FALSE; 346 valid = FALSE;
347 odebug << "Email was detected as invalid!" << oendl;
348 }
329 } 349 }
@@ -584,2 +604,4 @@ VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *pr
584 604
605
606
585} 607}
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:
77 QMap<int, OPimContact> m_map; 77 QMap<int, OPimContact> m_map;
78
79 /**
80 * Version of parsed VCard
81 */
82 uint version_major;
83 uint version_minor;
84
78}; 85};