[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    VCard parsing problems
From:       Andreas Gungl <a.gungl () gmx ! de>
Date:       2003-12-29 21:27:03
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

dealing with VCard parsing in KMail (vcard attachments) I found some serious 
problems in the vcard implementation in kdelibs/kabc. To describe the 
problems lets start with a small code snippet from KMail's vcardviewer.cpp:

  VCardConverter vcc;
  bool ok = vcc.vCardToAddressee(vCard, a, VCardConverter::v3_0);
  if (!ok)
    ok = vcc.vCardToAddressee(vCard, a, VCardConverter::v2_1);

The intention is to find out, if a vcard attachment could get parsed 
correctly. The first problem is that kabc doesn't hide resp. encapsulate 
the versioning problem. So we try 3.0 first and 2.1 if 3.0 failed.

Next problem is that the called methods return always true. :-(
I started a workaround for the 3.0 parsing code. It tries to handle some 
intermediate boolean return codes better. And, it tries to find out 
(currently very simple) whether the parsed string (what it basically is) is 
really containing a vcard.
Please see the attached patch for details!

What I would like to know is, what's the status of the 3.0 vs. 2.1 parsing? 
Would it be possible (or recommended) to skip the 2.1 parser completely? 
Who is currently maintaining the vcard parser code?

I could spend some time on the problems related to bug #70389, but I would 
need a little assistance from the kabc side to finish the changes before 
3.2 will get tagged.

Regards,
Andreas
- -- 
    ~
  ' v '
 //   \\
/(     )\  Powered by Penguin.
  ^ ' ^

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iD8DBQE/8JwnVhjiFd4beU8RAgcxAJ9IsEL+zdVByMNrToc5CsRnMKDsiwCggOLk
ZQPYw9znGsNxA/6/anvc61w=
=a/JB
-----END PGP SIGNATURE-----

["vcardformatimpl.cpp.diff" (text/x-diff)]

Index: vcardformatimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/kabc/vcardformatimpl.cpp,v
retrieving revision 1.41
diff -u -3 -p -r1.41 vcardformatimpl.cpp
--- vcardformatimpl.cpp	14 May 2003 13:09:11 -0000	1.41
+++ vcardformatimpl.cpp	29 Dec 2003 21:07:41 -0000
@@ -118,6 +118,7 @@ bool VCardFormatImpl::loadAddressee( Add
 {
   QPtrList<ContentLine> contentLines = v.contentLineList();
   ContentLine *cl;
+  int nReadEntities = 0;
 
   for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
     QCString n = cl->name();
@@ -135,26 +136,32 @@ bool VCardFormatImpl::loadAddressee( Add
 
       case EntityUID:
         addressee.setUid( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityEmail:
         addressee.insertEmail( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityName:
         addressee.setName( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityFullName:
         addressee.setFormattedName( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityURL:
         addressee.setUrl( KURL( readTextValue( cl ) ) );
+        nReadEntities++;
         break;
 
       case EntityNickname:
         addressee.setNickName( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityLabel:
@@ -163,89 +170,111 @@ bool VCardFormatImpl::loadAddressee( Add
 
       case EntityMailer:
         addressee.setMailer( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityTitle:
         addressee.setTitle( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityRole:
         addressee.setRole( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityOrganisation:
         addressee.setOrganization( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityNote:
         addressee.setNote( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityProductID:
         addressee.setProductId( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntitySortString:
         addressee.setSortString( readTextValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityN:
         readNValue( cl, addressee );
+        nReadEntities++;
         break;
 
       case EntityAddress:
         addressee.insertAddress( readAddressValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityTelephone:
         addressee.insertPhoneNumber( readTelephoneValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityCategories:
         addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) );
+        nReadEntities++;
         break;
 
       case EntityBirthday:
         addressee.setBirthday( readDateValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityRevision:
         addressee.setRevision( readDateTimeValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityGeo:
         addressee.setGeo( readGeoValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityTimeZone:
         addressee.setTimeZone( readUTCValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityVersion:
+        kdDebug( 5006 ) << "VCard version read: " << readTextValue( cl ) << " \
(expected is 3.0)" << endl;  break;
 
       case EntityClass:
         addressee.setSecrecy( readClassValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityKey:
         addressee.insertKey( readKeyValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntityPhoto:
         addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) );
+        nReadEntities++;
         break;
 
       case EntityLogo:
         addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) );
+        nReadEntities++;
         break;
 
       case EntityAgent:
         addressee.setAgent( readAgentValue( cl ) );
+        nReadEntities++;
         break;
 
       case EntitySound:
         addressee.setSound( readSoundValue( cl, addressee ) );
+        nReadEntities++;
         break;
 
       default:
@@ -254,6 +283,9 @@ bool VCardFormatImpl::loadAddressee( Add
         break;
     }
   }
+  
+  if ( nReadEntities == 0)
+    return false;
 
   for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
     EntityType type = cl->entityType();
@@ -971,8 +1003,7 @@ bool VCardFormatImpl::readFromString( co
 
   if ( it.current() ) {
     VCard v(*it.current());
-    loadAddressee( addressee, v );
-    return true;
+    return loadAddressee( addressee, v );
   }
 
   return false;



_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic