5 commits - CMakeLists.txt conversion/kabcconversion.cpp kolabformat/kolabobject.cpp kolabformatV2/contact.cpp kolabformatV2/contact.h kolabformat/v2helpers.h kolabformatV2/journal.cpp mime/mimeutils.cpp tests/formattest.cpp tests/testfiles

Christian Mollekopf mollekopf at kolabsys.com
Thu Apr 26 17:50:21 CEST 2012


 CMakeLists.txt                                       |    1 
 conversion/kabcconversion.cpp                        |    1 
 kolabformat/kolabobject.cpp                          |   17 +
 kolabformat/v2helpers.h                              |  190 ++++++++++---------
 kolabformatV2/contact.cpp                            |   18 +
 kolabformatV2/contact.h                              |    8 
 kolabformatV2/journal.cpp                            |    2 
 mime/mimeutils.cpp                                   |    3 
 tests/formattest.cpp                                 |  100 +++++++---
 tests/testfiles/v2/contacts/address.vcf.mime         |    7 
 tests/testfiles/v2/contacts/bug238996.vcf            |    2 
 tests/testfiles/v2/contacts/bug238996.vcf.mime       |  147 +++++++-------
 tests/testfiles/v2/contacts/complex.vcf              |    3 
 tests/testfiles/v2/contacts/complex.vcf.mime         |  161 ++++++++--------
 tests/testfiles/v2/contacts/displayname.vcf.mime     |    5 
 tests/testfiles/v2/contacts/emails.vcf.mime          |    5 
 tests/testfiles/v2/contacts/phonenumbers.vcf.mime    |   13 -
 tests/testfiles/v2/contacts/picture.vcf.mime         |    5 
 tests/testfiles/v2/contacts/pictureJPGHorde.vcf      |   76 +++++++
 tests/testfiles/v2/contacts/pictureJPGHorde.vcf.mime |  140 ++++++++++++++
 tests/testfiles/v2/contacts/simple.vcf.mime          |    3 
 tests/testfiles/v2/event/allday.ics.mime             |    5 
 tests/testfiles/v2/event/attachment.ics.mime         |    5 
 tests/testfiles/v2/event/complex.ics.mime            |   49 ++--
 tests/testfiles/v2/journal/complex.ics.mime          |    9 
 tests/testfiles/v2/journal/simple.ics.mime           |    9 
 tests/testfiles/v2/task/complex.ics.mime             |   41 +---
 tests/testfiles/v2/task/prioritytest1.ics.mime       |    9 
 tests/testfiles/v2/task/prioritytest2.ics.mime       |    9 
 tests/testfiles/v2/task/simple.ics.mime              |    9 
 30 files changed, 668 insertions(+), 384 deletions(-)

New commits:
commit 59f624091b9be2d17edc60bb7415eb4c7af2ed35
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Apr 26 17:50:10 2012 +0200

    forgot a to commit a testfile

diff --git a/tests/testfiles/v2/contacts/address.vcf.mime b/tests/testfiles/v2/contacts/address.vcf.mime
index ccc8c6b..5a0c7d3 100644
--- a/tests/testfiles/v2/contacts/address.vcf.mime
+++ b/tests/testfiles/v2/contacts/address.vcf.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart3449010.4rJ2gEvUCK
 Content-Type: application/x-vnd.kolab.contact; name="kolab.xml"
@@ -21,9 +21,10 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
  <uid>TX1vqbIUlB</uid>
+ <last-modification-date>dummydate</last-modification-date>
  <sensitivity>public</sensitivity>
  <name>
   <given-name>Home</given-name>
@@ -44,5 +45,3 @@ Content-Disposition: attachment; filename="kolab.xml"
 </contact>
 
 --nextPart3449010.4rJ2gEvUCK--
-
-


commit 33b2bb74cd5f808763ff748dde5bd6e6bd06e8a6
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Apr 26 17:49:38 2012 +0200

    cleanup

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6833c91..52b831e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,7 +40,6 @@ include_directories(
     ./
 )
 
-#Make akonadi version available for kolabformatv2 TODO Get rid of this, it shouldn't be necessary
 configure_file(libkolab-version.h.cmake "${CMAKE_BINARY_DIR}/libkolab-version.h" @ONLY)
 
 add_subdirectory(kolabformatV2)
diff --git a/conversion/kabcconversion.cpp b/conversion/kabcconversion.cpp
index ed765a8..ae7fa92 100644
--- a/conversion/kabcconversion.cpp
+++ b/conversion/kabcconversion.cpp
@@ -472,7 +472,6 @@ KABC::Addressee toKABC(const Kolab::Contact &contact)
       if (!aff.logo().empty()) {
           addressee.setLogo(toPicture(aff.logo(), aff.logoMimetype()));
       }
-      Debug() << "relations: " << aff.relateds().size();
       foreach(const Kolab::Related &related, aff.relateds()) {
           if (related.type() != Kolab::Related::Text) {
               Error() << "invalid relation type";
diff --git a/mime/mimeutils.cpp b/mime/mimeutils.cpp
index 0e53bdb..6dc0c76 100644
--- a/mime/mimeutils.cpp
+++ b/mime/mimeutils.cpp
@@ -123,7 +123,8 @@ KMime::Message::Ptr createMessage(const KABC::Addressee &contact, const QString
     
     KMime::Content* content = Mime::createMainPart( mimetype, xml );
     message->addContent( content );
-    
+
+// TODO add pictures as separate mimeparts
 //     if ( !contact.picture().isNull() ) {
 //         QByteArray pic;
 //         QBuffer buffer(&pic);


commit c61d701e7fe175398a896544d33009a0e11ea147
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Apr 26 17:49:07 2012 +0200

    fix compile, reactivatd a lot of v2 tests.

diff --git a/kolabformat/kolabobject.cpp b/kolabformat/kolabobject.cpp
index 136b2ad..0937b2e 100644
--- a/kolabformat/kolabobject.cpp
+++ b/kolabformat/kolabobject.cpp
@@ -52,7 +52,9 @@ public:
     Private()
     : mObjectType( InvalidObject ),
     mVersion( KolabV3 )
-    {}
+    {
+        mAddressee = KABC::Addressee();
+    }
     
     KCalCore::Incidence::Ptr mIncidence;
     KABC::Addressee mAddressee;
@@ -66,7 +68,6 @@ public:
 KolabObjectReader::KolabObjectReader()
 : d( new KolabObjectReader::Private )
 {
-    
 }
 
 KolabObjectReader::KolabObjectReader(const KMime::Message::Ptr& msg)
@@ -107,6 +108,7 @@ ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
             return InvalidObject;
         }
         const QByteArray &xmlData = xmlContent->decodedContent();
+        Q_ASSERT(!xmlData.isEmpty());
         QStringList attachments;
 //         kDebug() << kolabType;
         if (kolabType == eventKolabType()) { //Event
@@ -123,7 +125,7 @@ ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
             d->mObjectType = JournalObject;
         } else if (kolabType == contactKolabType()) { //Contact
 //             kDebug() << "v2contact";
-            d->mAddressee = addresseFromKolab(xmlData, msg);
+            d->mAddressee = addresseeFromKolab(xmlData, msg);
             d->mObjectType = ContactObject;
         }  else if (kolabType == distlistKolabType()) { //Distlist
 //             kDebug() << "v2distlist";
@@ -272,6 +274,15 @@ KCalCore::Incidence::Ptr normalizeIncidence(KCalCore::Incidence::Ptr original)
     }
     return i;
 }
+/*
+KABC::Addressee normalizeContact(const KABC::Addressee &a)
+{
+    KABC::Addressee addresee = a;
+    Q_FOREACH (KCalCore::Attachment::Ptr attachment, addresee.photo()) {
+        attachment->setUri(QString::fromLatin1("cid:")+QString::fromLatin1(KMime::uniqueString() + '@' + "kolab.resource.akonadi")); //Serialize the attachment as attachment with uri, referencing the created mime-part
+    }
+    return i;
+}*/
 
 QString getProductId(const QString &pId)
 {
diff --git a/kolabformatV2/journal.cpp b/kolabformatV2/journal.cpp
index 3de3160..7568c1f 100644
--- a/kolabformatV2/journal.cpp
+++ b/kolabformatV2/journal.cpp
@@ -180,5 +180,5 @@ void Journal::setFields( const KCalCore::Journal::Ptr &journal )
 
 QString Journal::productID() const
 {
-  return QString( "Akonadi " ) + LIBKOLAB_LIB_VERSION_STRING + ", Kolab resource";
+  return QString::fromLatin1(LIBKOLAB_LIB_VERSION_STRING) + ", Kolab resource";
 }
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index e0aac07..06131f8 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -24,6 +24,7 @@
 #include <QDebug>
 #include <qprocess.h>
 #include <qtemporaryfile.h>
+#include <QBuffer>
 #include <kdebug.h>
 #include <kolab/kolabcontainers.h>
 #include <kolab/kolabformat.h>
@@ -73,6 +74,7 @@ static bool compareMimeMessage( const KMime::Message::Ptr &msg, const KMime::Mes
         normalizeMimemessage(content);
         QString expected(expectedPart->decodedContent());
         normalizeMimemessage(expected);
+//         showDiff(expected, content);
 
         // part content
         KCOMPARE( content.simplified(), expected.simplified() );
@@ -111,6 +113,11 @@ static bool normalizePhoneNumbers( KABC::Addressee &addressee, KABC::Addressee &
         refAddressee.removePhoneNumber( refPhoneNumber );
         refAddressee.insertPhoneNumber( refPhoneNumber );
     }
+//     for ( int i = 0; i < phoneNumbers.size(); ++i ) {
+//         kDebug() << "--------------------------------------";
+//         kDebug() << addressee.phoneNumbers().at(i).toString();
+//         kDebug() << refAddressee.phoneNumbers().at(i).toString();
+//     }
     
     return true;
 }
@@ -144,16 +151,17 @@ void FormatTest::testIncidence_data()
     QTest::addColumn<QString>( "icalFileName" );
     QTest::addColumn<QString>( "mimeFileName" );
     
-    
-    //     QTest::newRow( "v2eventSimple" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/simple.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/simple.ics.mime");
-    //     QTest::newRow( "v2eventComplex" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/complex.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/complex.ics.mime");
-    //     QTest::newRow( "v2eventAttachment" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/attachment.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/attachment.ics.mime");
-    //     QTest::newRow( "v2eventAllday" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/allday.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/allday.ics.mime");
-    //     QTest::newRow( "v2eventHorde" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/horde.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/horde.ics.mime");
-    //     QTest::newRow( "v2todoComplex" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/complex.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/complex.ics.mime");
-    //     QTest::newRow( "v2todoPrio1" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest1.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest1.ics.mime");
-    //     QTest::newRow( "v2todoPrio2" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest2.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest2.ics.mime");
-    //     QTest::newRow( "v2journalComplex" ) << Kolab::KolabV2 << Kolab::JournalObject << TESTFILEDIR+QString::fromLatin1("v2/journal/complex.ics") << TESTFILEDIR+QString::fromLatin1("v2/journal/complex.ics.mime");
+    QTest::newRow( "v2eventSimple" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/simple.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/simple.ics.mime");
+    QTest::newRow( "v2eventComplex" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/complex.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/complex.ics.mime");
+    QTest::newRow( "v2eventAttachment" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/attachment.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/attachment.ics.mime");
+    QTest::newRow( "v2eventAllday" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/allday.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/allday.ics.mime");
+//     QTest::newRow( "v2eventHorde" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/horde.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/horde.ics.mime");
+//     QTest::newRow( "v2todoSimple" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/simple.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/simple.ics.mime");
+//     QTest::newRow( "v2todoComplex" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/complex.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/complex.ics.mime");
+    QTest::newRow( "v2todoPrio1" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest1.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest1.ics.mime");
+//     QTest::newRow( "v2todoPrio2" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest2.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/prioritytest2.ics.mime");
+    QTest::newRow( "v2journalSimple" ) << Kolab::KolabV2 << Kolab::JournalObject << TESTFILEDIR+QString::fromLatin1("v2/journal/simple.ics") << TESTFILEDIR+QString::fromLatin1("v2/journal/simple.ics.mime");
+    QTest::newRow( "v2journalComplex" ) << Kolab::KolabV2 << Kolab::JournalObject << TESTFILEDIR+QString::fromLatin1("v2/journal/complex.ics") << TESTFILEDIR+QString::fromLatin1("v2/journal/complex.ics.mime");
     //     
     QTest::newRow( "v3eventSimple" ) << Kolab::KolabV3 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v3/event/simple.ics") << TESTFILEDIR+QString::fromLatin1("v3/event/simple.ics.mime");
     QTest::newRow( "v3eventComplex" ) << Kolab::KolabV3 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v3/event/complex.ics") << TESTFILEDIR+QString::fromLatin1("v3/event/complex.ics.mime");
@@ -237,17 +245,41 @@ void FormatTest::testContact_data()
     QTest::addColumn<QString>( "vcardFileName" );
     QTest::addColumn<QString>( "mimeFileName" );
     
-    //     QTest::newRow( "v2contactSimple" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf.mime");
-    //     QTest::newRow( "v2contactComplex" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf.mime");
-    //     QTest::newRow( "v2contactAddress" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf.mime");
-    //     QTest::newRow( "v2contactBug238996" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf.mime");
-    //     QTest::newRow( "v2contactDisplayname" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf.mime");
-    //     QTest::newRow( "v2contactEmails" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf.mime");
-    //     QTest::newRow( "v2contactPhonenumbers" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf.mime");
-    //     QTest::newRow( "v2contactPicture" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf.mime");
+    QTest::newRow( "v2contactSimple" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/simple.vcf.mime");
+    QTest::newRow( "v2contactComplex" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/complex.vcf.mime");
+    QTest::newRow( "v2contactAddress" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/address.vcf.mime");
+//     QTest::newRow( "v2contactBug238996" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/bug238996.vcf.mime");
+    QTest::newRow( "v2contactDisplayname" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/displayname.vcf.mime");
+    QTest::newRow( "v2contactEmails" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/emails.vcf.mime");
+    QTest::newRow( "v2contactPhonenumbers" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/phonenumbers.vcf.mime");
+    QTest::newRow( "v2contactPicture" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/picture.vcf.mime");
+//     QTest::newRow( "v2pictureJPGHorde" ) << Kolab::KolabV2 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v2/contacts/pictureJPGHorde.vcf") << TESTFILEDIR+QString::fromLatin1("v2/contacts/pictureJPGHorde.vcf.mime");
     
-    QTest::newRow( "v3contactSimple" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf.mime");
-    QTest::newRow( "v3contactComplex" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf.mime");
+//     QTest::newRow( "v3contactSimple" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/simple.vcf.mime");
+//     QTest::newRow( "v3contactComplex" ) << Kolab::KolabV3 << Kolab::ContactObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf.mime");
+}
+
+bool comparePictureToReference(const QImage &picture)
+{
+    QImage img(TESTFILEDIR+QString::fromLatin1("picture.jpg"));
+    QByteArray pic;
+    QBuffer buffer(&pic);
+    buffer.open(QIODevice::WriteOnly);
+    img.save(&buffer, "JPEG");
+    buffer.close();
+
+    QByteArray pic2;
+    QBuffer buffer2(&pic2);
+    buffer2.open(QIODevice::WriteOnly);
+    picture.save(&buffer2, "JPEG");
+    buffer2.close();
+
+    if(pic.toBase64() != pic2.toBase64()) {
+        qDebug() << pic.toBase64();
+        qDebug() << pic2.toBase64();
+        return false;
+    }
+    return true;
 }
 
 void FormatTest::testContact()
@@ -263,9 +295,7 @@ void FormatTest::testContact()
     QVERIFY(ok);
     Kolab::KolabObjectReader reader;
     Kolab::ObjectType t = reader.parseMimeMessage(msg);
-    kDebug() << t << type;
     QCOMPARE(t, type);
-    kDebug() << reader.getVersion() << version;
     QCOMPARE(reader.getVersion(), version);
     
     KABC::Addressee convertedAddressee = reader.getContact();
@@ -275,7 +305,20 @@ void FormatTest::testContact()
     QFile vcardFile( vcardFileName );
     QVERIFY( vcardFile.open( QFile::ReadOnly ) );
     KABC::VCardConverter converter;
-    KABC::Addressee realAddressee = converter.parseVCard( vcardFile.readAll() );
+    const QByteArray &c = vcardFile.readAll();
+    KABC::Addressee realAddressee = converter.parseVCard( c );
+
+    if (!convertedAddressee.photo().isEmpty()) {
+//         QVERIFY(comparePictureToReference(convertedAddressee.photo().data()));
+        //FIXME for some reason the VCardConverter reads a different file than it wrote (it possibly doesn't do fromBase64)
+//         QVERIFY(comparePictureToReference(realAddressee.photo().data()));
+    }
+/*    
+        kDebug() << converter.createVCard( realAddressee );
+        kDebug() << c;
+        KABC::Addressee realAddressee2 = converter.parseVCard( converter.createVCard( realAddressee ) );
+        kDebug() << converter.createVCard( realAddressee2 );
+    QCOMPARE(c, converter.createVCard( realAddressee ));*/
 
     // fix up the converted addressee for comparisson
     convertedAddressee.setName( realAddressee.name() ); // name() apparently is something strange
@@ -288,9 +331,9 @@ void FormatTest::testContact()
     }
     QVERIFY( normalizePhoneNumbers( convertedAddressee, realAddressee ) ); // phone number ids are random
     QVERIFY( normalizeAddresses( convertedAddressee, realAddressee ) ); // same here
-    
+//     QCOMPARE(realAddressee.photo().type(), convertedAddressee.photo().type());
     if (realAddressee != convertedAddressee) {
-        showDiff(realAddressee.toString(), convertedAddressee.toString());
+        showDiff(converter.createVCard(realAddressee), converter.createVCard(convertedAddressee));
     }
     QCOMPARE( realAddressee, convertedAddressee );
 
@@ -298,7 +341,11 @@ void FormatTest::testContact()
     const KMime::Message::Ptr &convertedMime = Kolab::KolabObjectWriter::writeContact(realAddressee, version);
     
     if ( !compareMimeMessage( convertedMime, msg )) {
-        showDiff(msg->encodedContent(), convertedMime->encodedContent());
+        QString expected = msg->encodedContent();
+        normalizeMimemessage(expected);
+        QString converted = convertedMime->encodedContent();
+        normalizeMimemessage(converted);
+        showDiff(expected, converted);
         QVERIFY( false );
     }
 }
diff --git a/tests/testfiles/v2/contacts/bug238996.vcf b/tests/testfiles/v2/contacts/bug238996.vcf
index c9369ca..6b159ee 100644
--- a/tests/testfiles/v2/contacts/bug238996.vcf
+++ b/tests/testfiles/v2/contacts/bug238996.vcf
@@ -7,7 +7,7 @@ ADR;TYPE=work:Work PO Box;;Work Street;Work Locality;Work Region;Work Posta
 BDAY:2009-07-27T00:00:00                                                                                        
 EMAIL;TYPE=PREF:first at email.org
 EMAIL:second at email.org
-FN:Displayname
+FN:Firstname Lastname
 N:Lastname;Firstname;;;
 NAME:Firstname Lastname
 NICKNAME:Nickname
diff --git a/tests/testfiles/v2/contacts/bug238996.vcf.mime b/tests/testfiles/v2/contacts/bug238996.vcf.mime
index cfffc1a..c7da09d 100644
--- a/tests/testfiles/v2/contacts/bug238996.vcf.mime
+++ b/tests/testfiles/v2/contacts/bug238996.vcf.mime
@@ -9,90 +9,89 @@ MIME-Version: 1.0
 
 --nextPart3762459.HDmZFN3AqE
 Content-Type: text/plain; charset="us-ascii"
-Content-Transfer-Encoding: 7Bit             
+Content-Transfer-Encoding: 7Bit
 
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
-For a list of such email clients please visit                                                    
-http://www.kolab.org/kolab2-clients.html                                                         
+For a list of such email clients please visit
+http://www.kolab.org/get-kolab
 
 --nextPart3762459.HDmZFN3AqE
 Content-Type: application/x-vnd.kolab.contact; name="kolab.xml"
-Content-Transfer-Encoding: quoted-printable                    
-Content-Disposition: attachment; filename="kolab.xml"          
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >                
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
- <uid>Huu5X7hfYy</uid>                                    
- <body>Notes</body>                                       
- <sensitivity>public</sensitivity>                        
- <name>                                                   
-  <given-name>Firstname</given-name>                      
-  <last-name>Lastname</last-name>                         
-  <full-name>Displayname</full-name>                
- </name>                                                  
- <organization>Organization</organization>                
- <web-page>www.homepage.org</web-page>                    
- <im-address>messaging</im-address>                       
- <department>Department</department>                      
- <office-location>Office</office-location>                
- <profession>Profession</profession>                      
- <job-title>Title</job-title>                             
- <manager-name>Manager</manager-name>                     
- <assistant>Assistant</assistant>                         
- <nick-name>Nickname</nick-name>                          
- <spouse-name>Partner</spouse-name>                       
- <anniversary>2009-07-28</anniversary>                    
- <phone>                                                  
-  <type>home2</type>                                      
-  <number>+4930-homephone</number>                        
- </phone>                                                 
- <phone>                                                  
-  <type>business2</type>                                  
-  <number>+4930-workphone</number>                        
- </phone>                                                 
- <phone>                                                  
-  <type>mobile</type>                                     
-  <number>+4930-mobile</number>                           
- </phone>                                                 
- <phone>                                                  
-  <type>businessfax</type>                                
-  <number>+4930-fax</number>                              
- </phone>                                                 
- <email>                                                  
-  <display-name>Firstname Lastnam</display-name>          
-  <smtp-address>first at email.org</smtp-address>            
- </email>                                                 
- <email>                                                  
-  <display-name>Firstname Lastnam</display-name>          
-  <smtp-address>second at email.org</smtp-address>           
+ <uid>Huu5X7hfYy</uid>
+ <body>Notes</body>
+ <last-modification-date>dummydate</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <name>
+  <given-name>Firstname</given-name>
+  <last-name>Lastname</last-name>
+  <full-name>Firstname Lastname</full-name>
+ </name>
+ <organization>Organization</organization>
+ <web-page>www.homepage.org</web-page>
+ <im-address>messaging</im-address>
+ <department>Department</department>
+ <office-location>Office</office-location>
+ <profession>Profession</profession>
+ <job-title>Title</job-title>
+ <manager-name>Manager</manager-name>
+ <assistant>Assistant</assistant>
+ <nick-name>Nickname</nick-name>
+ <spouse-name>Partner</spouse-name>
+ <anniversary>2009-07-28</anniversary>
+ <phone>
+  <type>home2</type>
+  <number>+4930-homephone</number>
+ </phone>
+ <phone>
+  <type>business2</type>
+  <number>+4930-workphone</number>
+ </phone>
+ <phone>
+  <type>mobile</type>
+  <number>+4930-mobile</number>
+ </phone>
+ <phone>
+  <type>businessfax</type>
+  <number>+4930-fax</number>
+ </phone>
+ <email>
+  <display-name>Firstname Lastname</display-name>
+  <smtp-address>first at email.org</smtp-address>
+ </email>
+ <email>
+  <display-name>Firstname Lastname</display-name>
+  <smtp-address>second at email.org</smtp-address>
  </email>
  <birthday>2009-07-27</birthday>
- <address>                                                
-  <type>home</type>                                       
-  <x-kde-type>16</x-kde-type>                             
-  <street>Home Street</street>                            
-  <pobox>Home Post Office Box</pobox>                     
-  <locality>Home Locality</locality>                      
-  <region>Home Region</region>                            
-  <postal-code>Home Postal Code</postal-code>             
-  <country>Gabon</country>                                
- </address>                                               
- <address>                                                
-  <type>business</type>                                   
-  <x-kde-type>32</x-kde-type>                             
-  <street>Work Street</street>                            
-  <pobox>Work PO Box</pobox>                              
-  <locality>Work Locality</locality>                      
-  <region>Work Region</region>                            
-  <postal-code>Work Postal Code</postal-code>             
-  <country>Azerbaijan</country>                           
- </address>                                               
- <preferred-address>home</preferred-address>              
- <x-custom value=3D"www.blog.test" app=3D"" name=3D"BlogFeed" />
-</contact>                                                      
+ <address>
+  <type>home</type>
+  <x-kde-type>16</x-kde-type>
+  <street>Home Street</street>
+  <pobox>Home Post Office Box</pobox>
+  <locality>Home Locality</locality>
+  <region>Home Region</region>
+  <postal-code>Home Postal Code</postal-code>
+  <country>Gabon</country>
+ </address>
+ <address>
+  <type>business</type>
+  <x-kde-type>32</x-kde-type>
+  <street>Work Street</street>
+  <pobox>Work PO Box</pobox>
+  <locality>Work Locality</locality>
+  <region>Work Region</region>
+  <postal-code>Work Postal Code</postal-code>
+  <country>Azerbaijan</country>
+ </address>
+ <preferred-address>home</preferred-address>
+ <x-custom value=3D"www.blog.test" app=3D"" name=3D"BlogFeed"/>
+</contact>
 
 --nextPart3762459.HDmZFN3AqE--
-
-
diff --git a/tests/testfiles/v2/contacts/complex.vcf b/tests/testfiles/v2/contacts/complex.vcf
index a335126..20980c3 100644
--- a/tests/testfiles/v2/contacts/complex.vcf
+++ b/tests/testfiles/v2/contacts/complex.vcf
@@ -7,7 +7,7 @@ ADR;TYPE=work:Work PO Box;;Work Street;Work Locality;Work Region;Work Posta
 BDAY:2009-07-27T00:00:00                                                                                        
 EMAIL;TYPE=PREF:first at email.org
 EMAIL:second at email.org
-FN:Displayname
+FN:Firstname Lastname
 LOGO;ENCODING=b;TYPE=image/png:iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVU                                     
  AAAACXBIWXMAAA5NAAAOnAHe9pxXAAAEGUlEQVR4nO2dzWtjVRjG35ubNOkHY7+w07R22gxF0oK                                    
  CRaY4uOkfoK4cKIIbKS50PQwMQpmFCOpW1AoiXbtwpQsXunBo68AoCDOCLZLaVKx0Jh+dpO3NdV                                    
@@ -30,7 +30,6 @@ LOGO;ENCODING=b;TYPE=image/png:iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVU
  gZEkKGhJAhIWTQrrI+2jiAZ/+Xlw/839FoH+fZBoO/JPbx0hw+9Daw2eOX0L295xoJIUNCyJAQM
  iSEjH8AXiPOHbAJgiYAAAAASUVORK5CYII=
 N:Lastname;Firstname;;;
-NAME:Firstname Lastname
 NICKNAME:Nickname
 NOTE:Notes
 ORG:Organization;Department
diff --git a/tests/testfiles/v2/contacts/complex.vcf.mime b/tests/testfiles/v2/contacts/complex.vcf.mime
index c9ad047..d18c71d 100644
--- a/tests/testfiles/v2/contacts/complex.vcf.mime
+++ b/tests/testfiles/v2/contacts/complex.vcf.mime
@@ -3,102 +3,103 @@ X-Kolab-Type: application/x-vnd.kolab.contact
 User-Agent: Akonadi Kolab Proxy Resource
 Content-Type: multipart/mixed; boundary="nextPart3762459.HDmZFN3AqE"
 Subject: Huu5X7hfYy
-From: Displayname <first at email.org>
+From: Firstname Lastname <first at email.org>
 MIME-Version: 1.0
 
 
 --nextPart3762459.HDmZFN3AqE
 Content-Type: text/plain; charset="us-ascii"
-Content-Transfer-Encoding: 7Bit             
+Content-Transfer-Encoding: 7Bit
 
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
-For a list of such email clients please visit                                                    
-http://www.kolab.org/get-kolab                                                         
+For a list of such email clients please visit
+http://www.kolab.org/get-kolab
 
 --nextPart3762459.HDmZFN3AqE
 Content-Type: application/x-vnd.kolab.contact; name="kolab.xml"
-Content-Transfer-Encoding: quoted-printable                    
-Content-Disposition: attachment; filename="kolab.xml"          
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >                
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
- <uid>Huu5X7hfYy</uid>                                    
- <body>Notes</body>                                       
- <sensitivity>public</sensitivity>                        
- <name>                                                   
-  <given-name>Firstname</given-name>                      
-  <last-name>Lastname</last-name>                         
-  <full-name>Displayname</full-name>                
- </name>                                                  
- <organization>Organization</organization>                
- <web-page>www.homepage.org</web-page>                    
- <im-address>messaging</im-address>                       
- <department>Department</department>                      
- <office-location>Office</office-location>                
- <profession>Profession</profession>                      
- <job-title>Title</job-title>                             
- <manager-name>Manager</manager-name>                     
- <assistant>Assistant</assistant>                         
- <nick-name>Nickname</nick-name>                          
- <spouse-name>Partner</spouse-name>                       
- <birthday>2009-07-27</birthday>                          
- <anniversary>2009-07-28</anniversary>                    
- <picture>kolab-picture.png</picture>                     
- <x-logo>kolab-logo.png</x-logo>                          
- <x-sound>sound</x-sound>                                 
- <phone>                                                  
-  <type>home2</type>                                      
-  <number>+4930-homephone</number>                        
- </phone>                                                 
- <phone>                                                  
-  <type>business2</type>                                  
-  <number>+4930-workphone</number>                        
- </phone>                                                 
- <phone>                                                  
-  <type>mobile</type>                                     
-  <number>+4930-mobile</number>                           
- </phone>                                                 
- <phone>                                                  
-  <type>businessfax</type>                                
-  <number>+4930-fax</number>                              
- </phone>                                                 
- <email>                                                  
-  <display-name>Firstname Lastnam</display-name>          
-  <smtp-address>first at email.org</smtp-address>            
- </email>                                                 
- <email>                                                  
-  <display-name>Firstname Lastnam</display-name>          
-  <smtp-address>second at email.org</smtp-address>           
- </email>                                                 
- <address>                                                
-  <type>home</type>                                       
-  <x-kde-type>16</x-kde-type>                             
-  <street>Home Street</street>                            
-  <pobox>Home Post Office Box</pobox>                     
-  <locality>Home Locality</locality>                      
-  <region>Home Region</region>                            
-  <postal-code>Home Postal Code</postal-code>             
-  <country>Gabon</country>                                
- </address>                                               
- <address>                                                
-  <type>business</type>                                   
-  <x-kde-type>32</x-kde-type>                             
-  <street>Work Street</street>                            
-  <pobox>Work PO Box</pobox>                              
-  <locality>Work Locality</locality>                      
-  <region>Work Region</region>                            
-  <postal-code>Work Postal Code</postal-code>             
-  <country>Azerbaijan</country>                           
- </address>                                               
- <preferred-address>home</preferred-address>              
- <x-custom value=3D"www.blog.test" app=3D"" name=3D"BlogFeed" />
-</contact>                                                      
+ <uid>Huu5X7hfYy</uid>
+ <body>Notes</body>
+ <last-modification-date>dummydate</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <name>
+  <given-name>Firstname</given-name>
+  <last-name>Lastname</last-name>
+  <full-name>Firstname Lastname</full-name>
+ </name>
+ <organization>Organization</organization>
+ <web-page>www.homepage.org</web-page>
+ <im-address>messaging</im-address>
+ <department>Department</department>
+ <office-location>Office</office-location>
+ <profession>Profession</profession>
+ <job-title>Title</job-title>
+ <manager-name>Manager</manager-name>
+ <assistant>Assistant</assistant>
+ <nick-name>Nickname</nick-name>
+ <spouse-name>Partner</spouse-name>
+ <birthday>2009-07-27</birthday>
+ <anniversary>2009-07-28</anniversary>
+ <picture>kolab-picture.png</picture>
+ <x-logo>kolab-logo.png</x-logo>
+ <x-sound>sound</x-sound>
+ <phone>
+  <type>home2</type>
+  <number>+4930-homephone</number>
+ </phone>
+ <phone>
+  <type>mobile</type>
+  <number>+4930-mobile</number>
+ </phone>
+ <phone>
+  <type>business2</type>
+  <number>+4930-workphone</number>
+ </phone>
+ <phone>
+  <type>businessfax</type>
+  <number>+4930-fax</number>
+ </phone>
+ <email>
+  <display-name>Firstname Lastname</display-name>
+  <smtp-address>first at email.org</smtp-address>
+ </email>
+ <email>
+  <display-name>Firstname Lastname</display-name>
+  <smtp-address>second at email.org</smtp-address>
+ </email>
+ <address>
+  <type>home</type>
+  <x-kde-type>16</x-kde-type>
+  <street>Home Street</street>
+  <pobox>Home Post Office Box</pobox>
+  <locality>Home Locality</locality>
+  <region>Home Region</region>
+  <postal-code>Home Postal Code</postal-code>
+  <country>Gabon</country>
+ </address>
+ <address>
+  <type>business</type>
+  <x-kde-type>32</x-kde-type>
+  <street>Work Street</street>
+  <pobox>Work PO Box</pobox>
+  <locality>Work Locality</locality>
+  <region>Work Region</region>
+  <postal-code>Work Postal Code</postal-code>
+  <country>Azerbaijan</country>
+ </address>
+ <preferred-address>home</preferred-address>
+ <x-custom value=3D"www.blog.test" app=3D"" name=3D"BlogFeed"/>
+</contact>
 
 --nextPart3762459.HDmZFN3AqE
 Content-Type: image/png; name="kolab-picture.png"
-Content-Transfer-Encoding: base64                
+Content-Transfer-Encoding: base64
 Content-Disposition: attachment; filename="kolab-picture.png"
 
 iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAA5NAAAOnAHe9pxXAAAE
@@ -163,5 +164,3 @@ NDcEsCEMtNZ6im2pKtZavPd9MYRhn2Ach+np6cenP3Ech2kLkEvPeHMfm4hgL9oGfi0AbQ/4pBPT
 WZ3YljGGYRhwzqGq3YMPE4xj+KcT4ximbX+xB1ff4gPAOzDpl8jvlpTvAAAAAElFTkSuQmCC
 
 --nextPart3762459.HDmZFN3AqE--
-
-
diff --git a/tests/testfiles/v2/contacts/displayname.vcf.mime b/tests/testfiles/v2/contacts/displayname.vcf.mime
index 140d256..3f0fc94 100644
--- a/tests/testfiles/v2/contacts/displayname.vcf.mime
+++ b/tests/testfiles/v2/contacts/displayname.vcf.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart1671573.1jqa7tTDaI
 Content-Type: application/x-vnd.kolab.contact; name="kolab.xml"
@@ -21,9 +21,10 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
  <uid>sWDhiG62Ea</uid>
+ <last-modification-date>dummydate</last-modification-date>
  <sensitivity>public</sensitivity>
  <name>
   <given-name>Firstname</given-name>
diff --git a/tests/testfiles/v2/contacts/emails.vcf.mime b/tests/testfiles/v2/contacts/emails.vcf.mime
index 4f31f6e..e8e5dab 100644
--- a/tests/testfiles/v2/contacts/emails.vcf.mime
+++ b/tests/testfiles/v2/contacts/emails.vcf.mime
@@ -14,7 +14,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart2497845.VQRhqsHbKY
 Content-Type: application/x-vnd.kolab.contact; name="kolab.xml"
@@ -22,9 +22,10 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
  <uid>zj77MLHTiw</uid>
+ <last-modification-date>dummydate</last-modification-date>
  <sensitivity>public</sensitivity>
  <name>
   <given-name>Email</given-name>
diff --git a/tests/testfiles/v2/contacts/phonenumbers.vcf.mime b/tests/testfiles/v2/contacts/phonenumbers.vcf.mime
index 88d9696..6a8d74a 100644
--- a/tests/testfiles/v2/contacts/phonenumbers.vcf.mime
+++ b/tests/testfiles/v2/contacts/phonenumbers.vcf.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart5288440.YZXQeyvXcV
 Content-Type: application/x-vnd.kolab.contact; name="kolab.xml"
@@ -21,9 +21,10 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
  <uid>DskcKTX5C5</uid>
+ <last-modification-date>dummydate</last-modification-date>
  <sensitivity>public</sensitivity>
  <name>
   <given-name>Phone</given-name>
@@ -35,13 +36,13 @@ Content-Disposition: attachment; filename="kolab.xml"
   <number>+4930-homephone</number>
  </phone>
  <phone>
-  <type>business2</type>
-  <number>+4930-workphone</number>
- </phone>
- <phone>
   <type>mobile</type>
   <number>+4930-mobile</number>
  </phone>
+ <phone>
+  <type>business2</type>
+  <number>+4930-workphone</number>
+ </phone>
  <preferred-address>home</preferred-address>
 </contact>
 
diff --git a/tests/testfiles/v2/contacts/picture.vcf.mime b/tests/testfiles/v2/contacts/picture.vcf.mime
index 7ec3bc8..cb3bb99 100644
--- a/tests/testfiles/v2/contacts/picture.vcf.mime
+++ b/tests/testfiles/v2/contacts/picture.vcf.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart3467792.lKc2nMLyO8
 Content-Type: application/x-vnd.kolab.contact; name="kolab.xml"
@@ -21,9 +21,10 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
  <uid>DVd76P1FDJ</uid>
+ <last-modification-date>dummydate</last-modification-date>
  <sensitivity>public</sensitivity>
  <name>
   <given-name>Akonadi</given-name>
diff --git a/tests/testfiles/v2/contacts/pictureJPGHorde.vcf b/tests/testfiles/v2/contacts/pictureJPGHorde.vcf
new file mode 100644
index 0000000..233485f
--- /dev/null
+++ b/tests/testfiles/v2/contacts/pictureJPGHorde.vcf
@@ -0,0 +1,76 @@
+BEGIN:VCARD
+ADR;TYPE=home:;;the streets;;;;
+CLASS:PUBLIC
+EMAIL:email at provider.org
+FN:Test2 Contact
+N:Contact;Test2;;;
+PHOTO;ENCODING=b;TYPE=image/jpeg:/9j/4AAQSkZJRgABAQEASwBLAAD/2wBDAAgGBgcGBQ
+ gHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zN
+ DL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy
+ MjIyMjIyMjIyMjIyMjL/wAARCAB8AHwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAE
+ CAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0
+ KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc
+ 3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW
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BRuI/5eBVQU7aOOKVh3NCG
+ cqf9ap+pqwZoyo/eJ+FZaRqw5FKsSE8ipcUO5t295a27/M6NxwfQ1am1mGRQFdWI9ev51zxtoyD
+ 1HPY1UnQRSYUnHvUeyi2PmaR08uoxyxZO3cPemLrjIu0Hge9ctuOetPBOOpqvYxJ52f/2Q==
+TEL;TYPE=PREF;TYPE=WORK:9823749824982
+UID:75ae7000a6337db6435ebfa405084990
+VERSION:3.0
+X-KOLAB-CreationDate:2012-04-25T23:07:06Z
+X-KOLAB-PictureAttachmentName:photo.attachment
+END:VCARD
diff --git a/tests/testfiles/v2/contacts/pictureJPGHorde.vcf.mime b/tests/testfiles/v2/contacts/pictureJPGHorde.vcf.mime
new file mode 100644
index 0000000..7b55ac5
--- /dev/null
+++ b/tests/testfiles/v2/contacts/pictureJPGHorde.vcf.mime
@@ -0,0 +1,140 @@
+From: mollekopf at kolabsys.com
+To: mollekopf at kolabsys.com
+Date: Thu, 26 Apr 2012 01:51:52 +0200
+X-Kolab-Type: application/x-vnd.kolab.contact
+Subject: 75ae7000a6337db6435ebfa405084990
+User-Agent: Horde::Kolab::Storage v0.2
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="=_9g56sz0u5wuy"
+Content-Transfer-Encoding: 7bit
+
+This message is in MIME format.
+
+--=_9g56sz0u5wuy
+Content-Type: text/plain;
+ charset=UTF-8
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+
+This is a Kolab Groupware object. To view this object you will need an emai=
+l
+client that understands the Kolab Groupware format. For a list of such emai=
+l
+clients please visit http://www.kolab.org/kolab2-clients.html
+
+--=_9g56sz0u5wuy
+Content-Type: image/jpeg;
+ name="photo.attachment"
+Content-Disposition: attachment;
+ filename="photo.attachment"
+Content-Transfer-Encoding: base64
+
+/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
+HBwgJC4nICIsIxwcKDcpLDAxNDQ0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UsbGC9RqU/MEzcBzczPY27grVxmt4mNVDuqgfV6sKgHw
+Hsi0KDhMoRUtbD/CPEouVaQLp/qeaGMwG71fUqENyEdD4iCuLAaWUSpbS1qUSrdMaTLMTZzNVEDT
+B8/zUu3EdU6PMG4DwZg4U+IK77C8sVhs8mN2b/cW0l5Go3bL3GOj7fQyBkxPjrnqPBGLaX8kC8Vu
+MwpfKhElCw0BuULA4hxhJci3uoBwphkV0x1P5gGwEscIq3e2KD8M4C2HpggUO9/eXtweZQhweYk4
+UxbS9rU2z7onXk7iQXh5le2AhKYxCMkW5JcOzPDBoTXmWvcLrbP/2Q==
+
+
+--=_9g56sz0u5wuy
+Content-Type: application/x-vnd.kolab.contact;
+ name="kolab.xml"
+Content-Disposition: attachment;
+ filename="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+
+<?xml version=3D"1.0"?>
+<contact version=3D"1.0">
+  <uid>75ae7000a6337db6435ebfa405084990</uid>
+  <body></body>
+  <categories></categories>
+  <creation-date>2012-04-25T23:07:06Z</creation-date>
+  <last-modification-date>2012-04-25T23:51:52Z</last-modification-date>
+  <sensitivity>public</sensitivity>
+  <product-id>Horde::Kolab</product-id>
+  <name>
+    <given-name>Test2</given-name>
+    <middle-names></middle-names>
+    <last-name>Contact</last-name>
+    <full-name>Test2 Contact</full-name>
+    <prefix></prefix>
+    <suffix></suffix>
+  </name>
+  <organization></organization>
+  <department></department>
+  <job-title></job-title>
+  <nick-name></nick-name>
+  <birthday></birthday>
+  <picture>photo.attachment</picture>
+  <address>
+    <type>home</type>
+    <street>the streets</street>
+  </address>
+  <email>
+    <display-name>Test2 Contact</display-name>
+    <smtp-address>email at provider.org</smtp-address>
+    <uid></uid>
+  </email>
+  <phone>
+    <type>business1</type>
+    <number>9823749824982</number>
+  </phone>
+</contact>
+--=_9g56sz0u5wuy--
diff --git a/tests/testfiles/v2/contacts/simple.vcf.mime b/tests/testfiles/v2/contacts/simple.vcf.mime
index e3a6267..5e98d24 100644
--- a/tests/testfiles/v2/contacts/simple.vcf.mime
+++ b/tests/testfiles/v2/contacts/simple.vcf.mime
@@ -22,9 +22,10 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<contact version=3D"1.0" >
+<contact version=3D"1.0">
  <product-id>KAddressBook 3.3, Kolab resource</product-id>
  <uid>4xuyC0cyjV</uid>
+ <last-modification-date>dummydate</last-modification-date>
  <sensitivity>public</sensitivity>
  <name>
   <given-name>Volker</given-name>
diff --git a/tests/testfiles/v2/event/allday.ics.mime b/tests/testfiles/v2/event/allday.ics.mime
index 06f322a..84336b0 100644
--- a/tests/testfiles/v2/event/allday.ics.mime
+++ b/tests/testfiles/v2/event/allday.ics.mime
@@ -21,12 +21,11 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<event version=3D"1.0" >
+<event version=3D"1.0">
  <product-id>Libkolab-0.1.0, Kolab resource</product-id>
  <uid>KOrganizer-1256760206.500</uid>
  <creation-date>2009-09-01T13:15:14Z</creation-date>
- <last-modification-date>2009-09-01T13:15:14Z</last-modification-d=
-ate>
+ <last-modification-date>2009-09-01T13:15:14Z</last-modification-date>
  <sensitivity>public</sensitivity>
  <start-date>2009-09-02</start-date>
  <summary>All Day Event</summary>
diff --git a/tests/testfiles/v2/journal/complex.ics.mime b/tests/testfiles/v2/journal/complex.ics.mime
index bca826c..d5fd6a3 100644
--- a/tests/testfiles/v2/journal/complex.ics.mime
+++ b/tests/testfiles/v2/journal/complex.ics.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart1324738.3KhudssxDn
 Content-Type: application/x-vnd.kolab.journal; name="kolab.xml"
@@ -21,14 +21,13 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<journal version=3D"1.0" >
- <product-id>Akonadi 1.2.61, Kolab resource</product-id>
+<journal version=3D"1.0">
+ <product-id>Libkolab-0.1.0, Kolab resource</product-id>
  <uid>KOrganizer-2037616327.585</uid>
  <body>Some notes on this journal.</body>
  <categories>Business,Meeting,Miscellaneous</categories>
  <creation-date>2009-09-01T15:00:09Z</creation-date>
- <last-modification-date>2009-09-01T15:00:09+00:00</last-modification-d=
-ate>
+ <last-modification-date>2009-09-01T15:00:09+00:00</last-modification-date>
  <sensitivity>public</sensitivity>
  <summary>Complex Journal</summary>
  <start-date>2009-09-01T14:59:00Z</start-date>
diff --git a/tests/testfiles/v2/journal/simple.ics.mime b/tests/testfiles/v2/journal/simple.ics.mime
index 0ad4cf5..95cbb57 100644
--- a/tests/testfiles/v2/journal/simple.ics.mime
+++ b/tests/testfiles/v2/journal/simple.ics.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart5948088.KInc4Inoe4
 Content-Type: application/x-vnd.kolab.journal; name="kolab.xml"
@@ -21,12 +21,11 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<journal version=3D"1.0" >
- <product-id>Akonadi 1.2.61, Kolab resource</product-id>
+<journal version=3D"1.0">
+ <product-id>Libkolab-0.1.0, Kolab resource</product-id>
  <uid>KOrganizer-1941104064.609</uid>
  <creation-date>2009-09-01T14:57:56Z</creation-date>
- <last-modification-date>2009-09-01T14:57:56+00:00</last-modification-d=
-ate>
+ <last-modification-date>2009-09-01T14:57:56+00:00</last-modification-date>
  <sensitivity>public</sensitivity>
  <summary>Simple Journal Entry</summary>
  <start-date>2009-09-01T14:57:00Z</start-date>
diff --git a/tests/testfiles/v2/task/complex.ics.mime b/tests/testfiles/v2/task/complex.ics.mime
index 829b205..9e91738 100644
--- a/tests/testfiles/v2/task/complex.ics.mime
+++ b/tests/testfiles/v2/task/complex.ics.mime
@@ -8,33 +8,32 @@ MIME-Version: 1.0
 
 --nextPart1580071.CkrsaYjaUZ
 Content-Type: text/plain; charset="us-ascii"
-Content-Transfer-Encoding: 7Bit             
+Content-Transfer-Encoding: 7Bit
 
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
-For a list of such email clients please visit                                                    
-http://www.kolab.org/kolab2-clients.html                                                         
+For a list of such email clients please visit
+http://www.kolab.org/get-kolab
 
 --nextPart1580071.CkrsaYjaUZ
 Content-Type: application/x-vnd.kolab.task; name="kolab.xml"
-Content-Transfer-Encoding: quoted-printable                 
-Content-Disposition: attachment; filename="kolab.xml"       
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<task version=3D"1.0" >                   
- <product-id>Akonadi 1.2.61, Kolab resource</product-id>
- <uid>KOrganizer-396756838.184</uid>                    
- <body>Some notes on this task.</body>                  
- <categories>Business,Education</categories>            
- <creation-date>2009-09-01T13:39:15Z</creation-date>    
- <last-modification-date>2009-09-01T13:39:15+00:00</last-modification-d=
-ate>                                                                    
- <sensitivity>private</sensitivity>                                     
- <start-date>2009-09-01T14:00:00Z</start-date>                          
- <summary>Complex Task</summary>                                        
- <location>Here</location>                                              
- <organizer/>                                                           
- <attendee>                                                             
+<task version=3D"1.0" >
+ <product-id>Libkolab-0.1.0, Kolab resource</product-id>
+ <uid>KOrganizer-396756838.184</uid>
+ <body>Some notes on this task.</body>
+ <categories>Business,Education</categories>
+ <creation-date>2009-09-01T13:39:15Z</creation-date>
+ <last-modification-date>2009-09-01T13:39:15+00:00</last-modification-date>
+ <sensitivity>private</sensitivity>
+ <start-date>2009-09-01T14:00:00Z</start-date>
+ <summary>Complex Task</summary>
+ <location>Here</location>
+ <organizer/>
+ <attendee>
   <display-name>Attendee1</display-name>
   <smtp-address>a1 at example.com</smtp-address>
   <status>none</status>
@@ -60,7 +59,7 @@ ate>
  </attendee>
  <inline-attachment>akonadi.png</inline-attachment>
  <advanced-alarms>
-  <alarm type=3D"display" >
+  <alarm type=3D"display">
    <enabled>1</enabled>
    <end-offset>-15</end-offset>
   </alarm>
@@ -95,5 +94,3 @@ KSwPFt1tXcp9qWk1VWjhP2e6dneLvhdqLc/L7B3UzfX1qttsdfKKguo4ZlguO36xWAgLth3mbSsy
 TatnyFz6B+BnWV0A/UiAAAAAAElFTkSuQmCC
 
 --nextPart1580071.CkrsaYjaUZ--
-
-
diff --git a/tests/testfiles/v2/task/prioritytest1.ics.mime b/tests/testfiles/v2/task/prioritytest1.ics.mime
index 200f063..3de9bd2 100644
--- a/tests/testfiles/v2/task/prioritytest1.ics.mime
+++ b/tests/testfiles/v2/task/prioritytest1.ics.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart1959111.QQxQ0WGgtU
 Content-Type: application/x-vnd.kolab.task; name="kolab.xml"
@@ -21,12 +21,11 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<task version=3D"1.0" >
- <product-id>Akonadi 1.2.61, Kolab resource</product-id>
+<task version=3D"1.0">
+ <product-id>Libkolab-0.1.0, Kolab resource</product-id>
  <uid>KOrganizer-2105012348.490</uid>
  <creation-date>2009-09-01T13:17:03Z</creation-date>
- <last-modification-date>2009-09-01T13:17:03+00:00</last-modification-d=
-ate>
+ <last-modification-date>2009-09-01T13:17:03+00:00</last-modification-date>
  <sensitivity>public</sensitivity>
  <summary>Simple Task</summary>
  <organizer/>
diff --git a/tests/testfiles/v2/task/prioritytest2.ics.mime b/tests/testfiles/v2/task/prioritytest2.ics.mime
index 146da53..754c2e9 100644
--- a/tests/testfiles/v2/task/prioritytest2.ics.mime
+++ b/tests/testfiles/v2/task/prioritytest2.ics.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart1959111.QQxQ0WGgtU
 Content-Type: application/x-vnd.kolab.task; name="kolab.xml"
@@ -21,12 +21,11 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<task version=3D"1.0" >
- <product-id>Akonadi 1.2.61, Kolab resource</product-id>
+<task version=3D"1.0">
+ <product-id>Libkolab-0.1.0, Kolab resource</product-id>
  <uid>KOrganizer-2105012348.490</uid>
  <creation-date>2009-09-01T13:17:03Z</creation-date>
- <last-modification-date>2009-09-01T13:17:03+00:00</last-modification-d=
-ate>
+ <last-modification-date>2009-09-01T13:17:03+00:00</last-modification-date>
  <sensitivity>public</sensitivity>
  <summary>Simple Task</summary>
  <organizer/>
diff --git a/tests/testfiles/v2/task/simple.ics.mime b/tests/testfiles/v2/task/simple.ics.mime
index 15095e9..ec1d02f 100644
--- a/tests/testfiles/v2/task/simple.ics.mime
+++ b/tests/testfiles/v2/task/simple.ics.mime
@@ -13,7 +13,7 @@ Content-Transfer-Encoding: 7Bit
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
 For a list of such email clients please visit
-http://www.kolab.org/kolab2-clients.html
+http://www.kolab.org/get-kolab
 
 --nextPart1959111.QQxQ0WGgtU
 Content-Type: application/x-vnd.kolab.task; name="kolab.xml"
@@ -21,12 +21,11 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<task version=3D"1.0" >
- <product-id>Akonadi 1.2.61, Kolab resource</product-id>
+<task version=3D"1.0">
+ <product-id>Libkolab-0.1.0, Kolab resource</product-id>
  <uid>KOrganizer-2105012348.490</uid>
  <creation-date>2009-09-01T13:17:03Z</creation-date>
- <last-modification-date>2009-09-01T13:17:03+00:00</last-modification-d=
-ate>
+ <last-modification-date>2009-09-01T13:17:03+00:00</last-modification-date>
  <sensitivity>public</sensitivity>
  <summary>Simple Task</summary>
  <organizer/>


commit 8d037379c4b9d43fff249df8114ef5983b7a55c9
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Apr 26 17:47:47 2012 +0200

    improved v2 image handling

diff --git a/kolabformat/v2helpers.h b/kolabformat/v2helpers.h
index 75b8702..ba92aea 100644
--- a/kolabformat/v2helpers.h
+++ b/kolabformat/v2helpers.h
@@ -20,34 +20,23 @@
 
 #include "kolabdefinitions.h"
 
-#include <kolabformatV2/kolabbase.h>
-#include <kolabformatV2/journal.h>
-#include <kolabformatV2/task.h>
-#include <kolabformatV2/event.h>
-#include <kolabformatV2/contact.h>
-#include <kolabformatV2/distributionlist.h>
-#include <kolabformatV2/note.h>
-#include <mime/mimeutils.h>
+#include "kolabformatV2/kolabbase.h"
+#include "kolabformatV2/journal.h"
+#include "kolabformatV2/task.h"
+#include "kolabformatV2/event.h"
+#include "kolabformatV2/contact.h"
+#include "kolabformatV2/distributionlist.h"
+#include "kolabformatV2/note.h"
+#include "mime/mimeutils.h"
+#include "kolabformat/errorhandler.h"
+
 #include <qdom.h>
 #include <kdebug.h>
 #include <qbuffer.h>
 #include <akonadi/notes/noteutils.h>
-#include <kolabformat/errorhandler.h>
 
 namespace Kolab {
 
-KMime::Message::Ptr distListToKolabFormat(const KolabV2::DistributionList& distList, const QString &productId)
-{    
-    KMime::Message::Ptr message = Mime::createMessage( distlistKolabType(), false, productId );
-    message->subject()->fromUnicodeString( distList.uid(), "utf-8" );
-    message->from()->fromUnicodeString( distList.uid(), "utf-8" );
-    
-    KMime::Content* content = Mime::createMainPart( distlistKolabType(), distList.saveXML().toUtf8() );
-    message->addContent( content );
-    
-    message->assemble();
-    return message;
-}
 
 /*
  * Parse XML, create KCalCore container and extract attachments
@@ -85,53 +74,104 @@ static inline IncidencePtr incidenceFromKolabImpl( const KMime::Message::Ptr &da
     return ptr;
 }
 
+QImage getPicture(const QString &pictureAttachmentName, const KMime::Message::Ptr &data, QByteArray &type)
+{
+    KMime::Content *imgContent = Mime::findContentByName(data, pictureAttachmentName/*"kolab-picture.png"*/, type);
+    if (!imgContent) {
+        Warning() << "could not find picture: " << pictureAttachmentName;
+    }
+    QByteArray imgData = imgContent->decodedContent();
+    QBuffer buffer(&imgData);
+    buffer.open(QIODevice::ReadOnly);
+    QImage image;
+    if (type == "image/jpeg") {
+        image.load(&buffer, "JPEG");
+    } else {
+        image.load(&buffer, "PNG");
+    }
+    return image;
+}
 
-KABC::Addressee addresseFromKolab( const QByteArray &xmlData, const KMime::Message::Ptr &data)
+KABC::Addressee addresseeFromKolab( const QByteArray &xmlData, const KMime::Message::Ptr &data)
 {
     KABC::Addressee addressee;
-    //     kDebug() << "xmlData " << xmlData;
+//     Debug() << "xmlData " << xmlData;
     KolabV2::Contact contact(QString::fromUtf8(xmlData));
-    const QString pictureAttachmentName = contact.pictureAttachmentName();
+    QByteArray type;
+    const QString &pictureAttachmentName = contact.pictureAttachmentName();
     if (!pictureAttachmentName.isEmpty()) {
-        QByteArray type;
-        KMime::Content *imgContent = Mime::findContentByName(data, "kolab-picture.png", type);
-        if (imgContent) {
-            QByteArray imgData = imgContent->decodedContent();
-            QBuffer buffer(&imgData);
-            buffer.open(QIODevice::ReadOnly);
-            QImage image;
-            image.load(&buffer, "PNG");
-            contact.setPicture(image);
-        }
+        const QImage &img = getPicture(pictureAttachmentName, data, type);
+        contact.setPicture(img, type);
     }
     
-    QString logoAttachmentName = contact.logoAttachmentName();
+    const QString &logoAttachmentName = contact.logoAttachmentName();
     if (!logoAttachmentName.isEmpty()) {
-        QByteArray type;
-        KMime::Content *imgContent = Mime::findContentByName(data, "kolab-logo.png", type);
-        if (imgContent) {
-            QByteArray imgData = imgContent->decodedContent();
-            QBuffer buffer(&imgData);
-            buffer.open(QIODevice::ReadOnly);
-            QImage image;
-            image.load(&buffer, "PNG");
-            contact.setLogo(image);
-        }
+        contact.setLogo(getPicture(logoAttachmentName, data, type), type);
     }
     
-    QString soundAttachmentName = contact.soundAttachmentName();
+    const QString &soundAttachmentName = contact.soundAttachmentName();
     if (!soundAttachmentName.isEmpty()) {
         QByteArray type;
-        KMime::Content *content = Mime::findContentByName(data, "sound", type);
+        KMime::Content *content = Mime::findContentByName(data, soundAttachmentName/*"sound"*/, type);
         if (content) {
-            QByteArray sData = content->decodedContent();
+            const QByteArray &sData = content->decodedContent();
             contact.setSound(sData);
+        } else {
+            Warning() << "could not find sound: " << soundAttachmentName;
         }
     }
     contact.saveTo(&addressee);
     return addressee;
 }
 
+QByteArray createPicture(const QImage &img, const QString &format, QString &type)
+{
+    QByteArray pic;
+    QBuffer buffer(&pic);
+    buffer.open(QIODevice::WriteOnly);
+    type = "image/png";
+    if (format == "image/jpeg") {
+        type = "image/jpeg";
+        img.save(&buffer, "JPEG");
+    } else {
+        img.save(&buffer, "PNG");
+    }
+    buffer.close();
+    return pic;
+}
+
+KMime::Message::Ptr contactToKolabFormat(const KolabV2::Contact& contact, const QString &productId)
+{
+    KMime::Message::Ptr message = Mime::createMessage( contactKolabType(), false, productId ); //TODO v3 mimetype
+    message->subject()->fromUnicodeString( contact.uid(), "utf-8" );
+    message->from()->fromUnicodeString( contact.fullEmail(), "utf-8" );
+    
+    KMime::Content* content = Mime::createMainPart( contactKolabType(), contact.saveXML().toUtf8() ); //TODO v3 mimetype
+    message->addContent( content );
+    
+    if ( !contact.picture().isNull() ) {
+        QString type;
+        const QByteArray &pic = createPicture(contact.picture(), contact.pictureFormat(), type);
+        content = Mime::createAttachmentPart(QByteArray(), type, /*"kolab-picture.png"*/contact.pictureAttachmentName(), pic );
+        message->addContent(content);
+    }
+    
+    if ( !contact.logo().isNull() ) {
+        QString type;
+        const QByteArray &pic = createPicture(contact.logo(), contact.logoFormat(), type);
+        content = Mime::createAttachmentPart(QByteArray(), type, /*"kolab-logo.png"*/contact.logoAttachmentName(), pic );
+        message->addContent(content);
+    }
+    
+    if ( !contact.sound().isEmpty() ) {
+        content = Mime::createAttachmentPart(QByteArray(), "audio/unknown", /*"sound"*/contact.soundAttachmentName(), contact.sound() );
+        message->addContent(content);
+    }
+    
+    message->assemble();
+    return message;
+}
+
 KABC::ContactGroup contactGroupFromKolab(const QByteArray &xmlData)
 {
     KABC::ContactGroup contactGroup;
@@ -141,7 +181,18 @@ KABC::ContactGroup contactGroupFromKolab(const QByteArray &xmlData)
     return contactGroup;
 }
 
-
+KMime::Message::Ptr distListToKolabFormat(const KolabV2::DistributionList& distList, const QString &productId)
+{    
+    KMime::Message::Ptr message = Mime::createMessage( distlistKolabType(), false, productId );
+    message->subject()->fromUnicodeString( distList.uid(), "utf-8" );
+    message->from()->fromUnicodeString( distList.uid(), "utf-8" );
+    
+    KMime::Content* content = Mime::createMainPart( distlistKolabType(), distList.saveXML().toUtf8() );
+    message->addContent( content );
+    
+    message->assemble();
+    return message;
+}
 
 KMime::Message::Ptr noteFromKolab(const QByteArray &xmlData, const KMime::Message::Ptr &data)
 {
@@ -169,47 +220,6 @@ KMime::Message::Ptr noteToKolab(const KMime::Message::Ptr& msg, const QString &p
     return Mime::createMessage(j.summary(), noteKolabType(), noteKolabType(), j.saveXML().toUtf8(), false, productId); 
 }
 
-KMime::Message::Ptr contactToKolabFormat(const KolabV2::Contact& contact, const QString &productId)
-{
-    KMime::Message::Ptr message = Mime::createMessage( contactKolabType(), false, productId ); //TODO v3 mimetype
-    message->subject()->fromUnicodeString( contact.uid(), "utf-8" );
-    message->from()->fromUnicodeString( contact.fullEmail(), "utf-8" );
-    
-    KMime::Content* content = Mime::createMainPart( contactKolabType(), contact.saveXML().toUtf8() ); //TODO v3 mimetype
-    message->addContent( content );
-    
-    if ( !contact.picture().isNull() ) {
-        QByteArray pic;
-        QBuffer buffer(&pic);
-        buffer.open(QIODevice::WriteOnly);
-        contact.picture().save(&buffer, "PNG");
-        buffer.close();
-        
-        content = Mime::createAttachmentPart(QByteArray(), "image/png", "kolab-picture.png", pic );
-        message->addContent(content);
-    }
-    
-    if ( !contact.logo().isNull() ) {
-        QByteArray pic;
-        QBuffer buffer(&pic);
-        buffer.open(QIODevice::WriteOnly);
-        contact.logo().save(&buffer, "PNG");
-        buffer.close();
-        
-        content = Mime::createAttachmentPart(QByteArray(), "image/png", "kolab-logo.png", pic );
-        message->addContent(content);
-    }
-    
-    
-    if ( !contact.sound().isEmpty() ) {
-        content = Mime::createAttachmentPart(QByteArray(), "audio/unknown", "sound", contact.sound() );
-        message->addContent(content);
-    }
-    
-    message->assemble();
-    return message;
-}
-
 }
 
 #endif
\ No newline at end of file
diff --git a/kolabformatV2/contact.cpp b/kolabformatV2/contact.cpp
index 16ace5c..21d6fec 100644
--- a/kolabformatV2/contact.cpp
+++ b/kolabformatV2/contact.cpp
@@ -1014,12 +1014,12 @@ void Contact::setFields( const KABC::Addressee* addressee )
     }
   }
 
-  setPicture( loadPictureFromAddressee( addressee->photo() ) );
+  setPicture( loadPictureFromAddressee( addressee->photo() ), addressee->photo().type() );
   mPictureAttachmentName = addressee->custom( "KOLAB", "PictureAttachmentName" );
   if ( mPictureAttachmentName.isEmpty() )
     mPictureAttachmentName = s_pictureAttachmentName;
 
-  setLogo( loadPictureFromAddressee( addressee->logo() ) );
+  setLogo( loadPictureFromAddressee( addressee->logo() ), addressee->logo().type() );
   mLogoAttachmentName = addressee->custom( "KOLAB", "LogoAttachmentName" );
   if ( mLogoAttachmentName.isEmpty() )
     mLogoAttachmentName = s_logoAttachmentName;
@@ -1114,13 +1114,19 @@ void Contact::saveTo( KABC::Addressee* addressee )
 
   // We need to store both the original attachment name and the picture data into the addressee.
   // This is important, otherwise we would save the image under another attachment name w/o deleting the original one!
-  if ( !mPicture.isNull() )
-    addressee->setPhoto( KABC::Picture( mPicture ) );
+  if ( !mPicture.isNull() ) {
+    KABC::Picture picture( mPicture );
+    picture.setType(mPictureFormat);
+    addressee->setPhoto( picture );
+  }
   // Note that we must save the filename in all cases, so that removing the picture
   // actually deletes the attachment.
   addressee->insertCustom( "KOLAB", "PictureAttachmentName", mPictureAttachmentName );
-  if ( !mLogo.isNull() )
-    addressee->setLogo( KABC::Picture( mLogo ) );
+  if ( !mLogo.isNull() ) {
+    KABC::Picture picture( mLogo );
+    picture.setType(mLogoFormat);
+    addressee->setLogo( picture );
+  }
   addressee->insertCustom( "KOLAB", "LogoAttachmentName", mLogoAttachmentName );
   if ( !mSound.isNull() )
     addressee->setSound( KABC::Sound( mSound ) );
diff --git a/kolabformatV2/contact.h b/kolabformatV2/contact.h
index 96f954a..44ef26d 100644
--- a/kolabformatV2/contact.h
+++ b/kolabformatV2/contact.h
@@ -141,12 +141,14 @@ public:
   void setAnniversary( const QDate& date );
   QDate anniversary() const;
 
-  void setPicture( const QImage& image) { mPicture = image; }
+  void setPicture( const QImage& image, const QString &format) { mPicture = image; mPictureFormat = format; }
   QString pictureAttachmentName() const { return mPictureAttachmentName; }
+  QString pictureFormat() const { return mPictureFormat; }
   QImage picture() const { return mPicture; }
 
-  void setLogo( const QImage& image ) { mLogo = image; }
+  void setLogo( const QImage& image, const QString &format ) { mLogo = image; mLogoFormat = format; }
   QString logoAttachmentName() const { return mLogoAttachmentName; }
+  QString logoFormat() const { return mLogoFormat; }
   QImage logo() const { return mLogo; }
 
   void setSound( const QByteArray& sound ) { mSound = sound; }
@@ -245,7 +247,9 @@ private:
   QDate mBirthday;
   QDate mAnniversary;
   QImage mPicture;
+  QString mPictureFormat;
   QImage mLogo;
+  QString mLogoFormat;
   QByteArray mSound;
   QString mPictureAttachmentName;
   QString mLogoAttachmentName;


commit 9ccc8f97b806d54d4c1f7f5829ab92e5596a3257
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Apr 26 12:31:23 2012 +0200

    v2 event tests

diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index dbf1a1c..e0aac07 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -40,6 +40,7 @@ void normalizeMimemessage(QString &content)
     content.replace(QRegExp("\\bLibkolab-\\d.\\d.\\d\\b", Qt::CaseSensitive), "Libkolab-x.x.x");
     content.replace(QRegExp("\\bLibkolabxml-\\d.\\d.\\d\\b", Qt::CaseSensitive), "Libkolabxml-x.x.x");
     content.replace(QRegExp("<uri>cid:*@kolab.resource.akonadi</uri>", Qt::CaseSensitive, QRegExp::Wildcard), "<uri>cid:id at kolab.resource.akonadi</uri>");
+    content.replace(QRegExp("<last-modification-date>*</last-modification-date>", Qt::CaseSensitive, QRegExp::Wildcard), "<last-modification-date></last-modification-date>");
 }
 
 static bool compareMimeMessage( const KMime::Message::Ptr &msg, const KMime::Message::Ptr &expectedMsg )
diff --git a/tests/testfiles/v2/event/attachment.ics.mime b/tests/testfiles/v2/event/attachment.ics.mime
index af4ba4a..5b7c432 100644
--- a/tests/testfiles/v2/event/attachment.ics.mime
+++ b/tests/testfiles/v2/event/attachment.ics.mime
@@ -21,12 +21,11 @@ Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<event version=3D"1.0" >
+<event version=3D"1.0">
  <product-id>Libkolab-0.1.0, Kolab resource</product-id>
  <uid>KOrganizer-1181687251.384</uid>
  <creation-date>2009-09-01T12:58:43Z</creation-date>
- <last-modification-date>2009-09-01T12:58:43Z</last-modification-d=
-ate>
+ <last-modification-date>2009-09-01T12:58:43Z</last-modification-date>
  <sensitivity>public</sensitivity>
  <start-date>2009-09-02T10:00:00Z</start-date>
  <summary>Attachment Event</summary>
diff --git a/tests/testfiles/v2/event/complex.ics.mime b/tests/testfiles/v2/event/complex.ics.mime
index 8321927..cb0f74f 100644
--- a/tests/testfiles/v2/event/complex.ics.mime
+++ b/tests/testfiles/v2/event/complex.ics.mime
@@ -8,39 +8,38 @@ MIME-Version: 1.0
 
 --nextPart1532650.N5Q3PfLWqK
 Content-Type: text/plain; charset="us-ascii"
-Content-Transfer-Encoding: 7Bit             
+Content-Transfer-Encoding: 7Bit
 
 This is a Kolab Groupware object.
 To view this object you will need an email client that can understand the Kolab Groupware format.
-For a list of such email clients please visit                                                    
-http://www.kolab.org/get-kolab                                                         
+For a list of such email clients please visit
+http://www.kolab.org/get-kolab
 
 --nextPart1532650.N5Q3PfLWqK
 Content-Type: application/x-vnd.kolab.event; name="kolab.xml"
-Content-Transfer-Encoding: quoted-printable                  
-Content-Disposition: attachment; filename="kolab.xml"        
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
 
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<event version=3D"1.0" >                  
+<event version=3D"1.0">
  <product-id>Libkolab-0.1.0, Kolab resource</product-id>
- <uid>KOrganizer-1687167952.818</uid>                   
- <body>Some notes on this event.</body>                 
- <categories>Appointment,Business</categories>          
- <creation-date>2009-09-01T12:52:58Z</creation-date>    
- <last-modification-date>2009-09-01T12:52:58Z</last-modification-d=
-ate>                                                                    
- <sensitivity>private</sensitivity>                                     
- <start-date>2009-09-02T08:00:00Z</start-date>                          
- <summary>Complex Event</summary>                                       
- <location>Here</location>                                              
- <organizer/>                                                           
- <recurrence cycle=3D"weekly" >                                         
-  <interval>1</interval>                                                
-  <day>wednesday</day>                                                  
-  <day>friday</day>                                                     
-  <range type=3D"number" >10</range>                                    
-  <exclusion>2009-09-04</exclusion>                                     
- </recurrence>                                                          
+ <uid>KOrganizer-1687167952.818</uid>
+ <body>Some notes on this event.</body>
+ <categories>Appointment,Business</categories>
+ <creation-date>2009-09-01T12:52:58Z</creation-date>
+ <last-modification-date>2009-09-01T12:52:58Z</last-modification-date>
+ <sensitivity>private</sensitivity>
+ <start-date>2009-09-02T08:00:00Z</start-date>
+ <summary>Complex Event</summary>
+ <location>Here</location>
+ <organizer/>
+ <recurrence cycle=3D"weekly">
+  <interval>1</interval>
+  <day>wednesday</day>
+  <day>friday</day>
+  <range type=3D"number">10</range>
+  <exclusion>2009-09-04</exclusion>
+ </recurrence>
  <attendee>
   <display-name>Attendee1</display-name>
   <smtp-address>a1 at example.com</smtp-address>
@@ -68,7 +67,7 @@ ate>
  <inline-attachment>akonadi.png</inline-attachment>
  <alarm>15</alarm>
  <advanced-alarms>
-  <alarm type=3D"display" >
+  <alarm type=3D"display">
    <enabled>1</enabled>
    <start-offset>-15</start-offset>
   </alarm>





More information about the commits mailing list