11 commits - CMakeLists.txt kolabformat/kolabobject.cpp kolabformat/kolabobject.i kolabformat/mimeobject.cpp kolabformat/mimeobject.h tests/CMakeLists.txt tests/formattest.cpp tests/formattest.h tests/mimeobjecttest.cpp tests/mimeobjecttest.h tests/testfiles tests/testutils.h utils/CMakeLists.txt utils/kolabformatchecker.cpp

Christian Mollekopf mollekopf at kolabsys.com
Wed Jan 2 14:24:05 CET 2013


 CMakeLists.txt                                |    1 
 kolabformat/kolabobject.cpp                   |    2 
 kolabformat/kolabobject.i                     |    2 
 kolabformat/mimeobject.cpp                    |  162 ++++++++++++++++++++++++++
 kolabformat/mimeobject.h                      |   60 +++++++++
 tests/CMakeLists.txt                          |    1 
 tests/formattest.cpp                          |   82 +++++++++++++
 tests/formattest.h                            |    3 
 tests/mimeobjecttest.cpp                      |  142 ++++++++++++++++++++++
 tests/mimeobjecttest.h                        |   34 +++++
 tests/testfiles/v3/contacts/distlist.vcf      |    5 
 tests/testfiles/v3/contacts/distlist.vcf.mime |   18 --
 tests/testutils.h                             |   17 ++
 utils/CMakeLists.txt                          |    5 
 utils/kolabformatchecker.cpp                  |   93 ++++++++++++++
 15 files changed, 611 insertions(+), 16 deletions(-)

New commits:
commit 2befab0a53b6794020e750cab2e3a5feae1de412
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed Jan 2 14:19:38 2013 +0100

    Use the correct kolab type for distlists + test.

diff --git a/kolabformat/kolabobject.cpp b/kolabformat/kolabobject.cpp
index 6377968..d2ff3ac 100644
--- a/kolabformat/kolabobject.cpp
+++ b/kolabformat/kolabobject.cpp
@@ -576,7 +576,7 @@ KMime::Message::Ptr KolabObjectWriter::writeDistlist(const KABC::ContactGroup &d
         const Kolab::DistList &dist = Kolab::Conversion::fromKABC(distlist);
         const std::string &v3String = Kolab::writeDistlist(dist, Conversion::toStdString(getProductId(productId)));
         ErrorHandler::handleLibkolabxmlErrors();
-        return  Mime::createMessage(Conversion::fromStdString(dist.uid()), xCardMimeType(), contactKolabType(), Conversion::fromStdString(v3String).toUtf8(), true, getProductId(productId));
+        return  Mime::createMessage(Conversion::fromStdString(dist.uid()), xCardMimeType(), distlistKolabType(), Conversion::fromStdString(v3String).toUtf8(), true, getProductId(productId));
     }
     KolabV2::DistributionList d(&distlist);
     return distListToKolabFormat(d, getProductId(productId));
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 9e2613c..5354920 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -29,6 +29,7 @@
 
 #include <kcalcore/icalformat.h>
 #include <kabc/vcardconverter.h>
+#include <kabc/contactgrouptool.h>
 #include <akonadi/notes/noteutils.h>
 
 #include "testutils.h"
@@ -280,6 +281,72 @@ void FormatTest::testContact()
     QCOMPARE(Kolab::ErrorHandler::instance().error(), Kolab::ErrorHandler::Debug);
 }
 
+void FormatTest::testDistlist_data()
+{
+    QTest::addColumn<Kolab::Version>( "version" );
+    QTest::addColumn<Kolab::ObjectType>( "type" );
+    QTest::addColumn<QString>( "vcardFileName" );
+    QTest::addColumn<QString>( "mimeFileName" );
+    
+    QTest::newRow( "v3distlistSimple" ) << Kolab::KolabV3 << Kolab::DistlistObject << TESTFILEDIR+QString::fromLatin1("v3/contacts/distlist.vcf") << TESTFILEDIR+QString::fromLatin1("v3/contacts/distlist.vcf.mime");
+}
+
+void FormatTest::testDistlist()
+{
+    QFETCH( Kolab::Version, version );
+    QFETCH( Kolab::ObjectType, type );
+    QFETCH( QString, vcardFileName ); //To compare
+    QFETCH( QString, mimeFileName ); //For parsing
+    
+    //Parse mime message
+    bool ok = false;
+    const KMime::Message::Ptr &msg = readMimeFile( mimeFileName, ok );
+    QVERIFY(ok);
+    Kolab::KolabObjectReader reader;
+    Kolab::ObjectType t = reader.parseMimeMessage(msg);
+    QCOMPARE(t, type);
+    QCOMPARE(reader.getVersion(), version);
+    QCOMPARE(Kolab::ErrorHandler::instance().error(), Kolab::ErrorHandler::Debug);
+    
+    KABC::ContactGroup convertedAddressee = reader.getDistlist();
+    
+    //Parse vcard
+    QFile vcardFile( vcardFileName );
+    QVERIFY( vcardFile.open( QFile::ReadOnly ) );
+    KABC::VCardConverter converter;
+    QByteArray c = vcardFile.readAll();
+    QBuffer data(&c);
+    data.open(QIODevice::ReadOnly);
+    
+    KABC::ContactGroup realAddressee;
+    KABC::ContactGroupTool::convertFromXml( &data, realAddressee );
+
+    {
+        QBuffer expected;
+        expected.open(QIODevice::WriteOnly);
+        KABC::ContactGroupTool::convertToXml(realAddressee, &expected);
+        
+        QBuffer converted;
+        converted.open(QIODevice::WriteOnly);
+        KABC::ContactGroupTool::convertToXml(convertedAddressee, &converted);
+        
+        showDiff(expected.buffer(), converted.buffer());
+    }
+    QCOMPARE( realAddressee, convertedAddressee );
+
+    //Write
+    const KMime::Message::Ptr &convertedMime = Kolab::KolabObjectWriter::writeDistlist(realAddressee, version);
+    
+    if ( !compareMimeMessage( convertedMime, msg )) {
+        QString expected = msg->encodedContent();
+        normalizeMimemessage(expected);
+        QString converted = convertedMime->encodedContent();
+        normalizeMimemessage(converted);
+        showDiff(expected, converted);
+        QVERIFY( false );
+    }
+    QCOMPARE(Kolab::ErrorHandler::instance().error(), Kolab::ErrorHandler::Debug);
+}
 
 void FormatTest::testNote_data()
 {
@@ -377,6 +444,18 @@ void FormatTest::generateVCard()
 //     KABC::Addressee convertedAddressee = reader.getContact();
 //     KABC::VCardConverter converter;
 //     qDebug() << converter.createVCard(convertedAddressee);
+
+//     bool ok = false;
+//     const KMime::Message::Ptr &msg = readMimeFile( TESTFILEDIR+QString::fromLatin1("v3/contacts/distlist.vcf.mime"), ok );
+//     qDebug() << msg->encodedContent();
+//     Kolab::KolabObjectReader reader;
+//     Kolab::ObjectType t = reader.parseMimeMessage(msg);
+// 
+//     KABC::ContactGroup convertedAddressee = reader.getDistlist();
+//     QBuffer buf;
+//     buf.open(QIODevice::WriteOnly);
+//     KABC::ContactGroupTool::convertToXml(convertedAddressee, &buf);
+//     qDebug() << buf.buffer();
 }
 
 //Pseudo test to show that JPG is always lossy, even with quality set to 100
diff --git a/tests/formattest.h b/tests/formattest.h
index 12655fb..8097bfc 100644
--- a/tests/formattest.h
+++ b/tests/formattest.h
@@ -55,6 +55,9 @@ private slots:
     
     void testContact_data();
     void testContact();
+    
+    void testDistlist_data();
+    void testDistlist();
 
     void testNote_data();
     void testNote();
diff --git a/tests/testfiles/v3/contacts/distlist.vcf b/tests/testfiles/v3/contacts/distlist.vcf
new file mode 100644
index 0000000..cc4984c
--- /dev/null
+++ b/tests/testfiles/v3/contacts/distlist.vcf
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<contactGroup uid="4xuyC0cyjV" name="My Distlist">
+    <contactData name="John Doe" email="jdoe at example.com"/>
+    <contactData name="John Doe2" email="jdoe2 at example.com"/>
+</contactGroup>
\ No newline at end of file
diff --git a/tests/testfiles/v3/contacts/distlist.vcf.mime b/tests/testfiles/v3/contacts/distlist.vcf.mime
index d54c26c..372728e 100644
--- a/tests/testfiles/v3/contacts/distlist.vcf.mime
+++ b/tests/testfiles/v3/contacts/distlist.vcf.mime
@@ -1,10 +1,9 @@
 Date: Mon, 23 Apr 2012 12:46:37 +0200
-X-Kolab-Type: application/x-vnd.kolab.distribution-list
+X-Kolab-Type: application/x-vnd.kolab.contact.distlist
 X-Kolab-Mime-Version: 3.0
 User-Agent: Libkolab-0.1.0
 Content-Type: multipart/mixed; boundary="nextPart1365947.WmFcbPlLFA"
 Subject: 4xuyC0cyjV
-From: Volker Krause <vkrause at kde.org>
 MIME-Version: 1.0
 
 
@@ -38,10 +37,6 @@ Content-Disposition: attachment; filename="kolab.xml"
     <rev>
       <timestamp>20120505T050505Z</timestamp>
     </rev>
-    <categories>
-      <text>cat1</text>
-      <text>cat2</text>
-    </categories>
     <kind>
       <text>group</text>
     </kind>
@@ -49,18 +44,13 @@ Content-Disposition: attachment; filename="kolab.xml"
       <text>My Distlist</text>
     </fn>
     <member>
-      <uri>mailto:John%20Doe%3cjdoe at example.com%3e</uri>
+      <uri>mailto:John%20Doe%3Cjdoe%40example.com%3E</uri>
     </member>
     <member>
-      <uri>mailto:John%20Doe2%3cjdoe2 at example.com%3e</uri>
+      <uri>mailto:John%20Doe2%3Cjdoe2%40example.com%3E</uri>
     </member>
-    <x-custom>
-      <identifier>X-Identifier</identifier>
-      <value>TestValue</value>
-    </x-custom>
-
   </vcard>
 
 </vcards>
 
---nextPart1365947.WmFcbPlLFA--
\ No newline at end of file
+--nextPart1365947.WmFcbPlLFA--
diff --git a/tests/testutils.h b/tests/testutils.h
index 24f1db5..d61ec22 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -96,6 +96,7 @@ void normalizeMimemessage(QString &content)
     content.replace(QRegExp("\\bLibkolabxml-\\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>");
+    content.replace(QRegExp("<timestamp>*</timestamp>", Qt::CaseSensitive, QRegExp::Wildcard), "<timestamp></timestamp>");
 
     content.replace(QRegExp("--nextPart\\S*", Qt::CaseSensitive), "--part");
     content.replace(QRegExp("\\bboundary=\"nextPart[^\\n]*", Qt::CaseSensitive), "boundary");


commit b2aaea7035eb6915ccaf9c4cb9091323edaae62b
Merge: fcf7967 a6a6dc1
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed Jan 2 12:56:53 2013 +0100

    Merge remote-tracking branch 'origin/mimeobject'
    
    Conflicts:
    	tests/CMakeLists.txt

diff --cc tests/CMakeLists.txt
index b3aa7ac,43f7499..284a33b
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@@ -20,4 -20,4 +20,5 @@@ addTest(calendaringtest
  addTest(icalendartest)
  addTest(freebusytest)
  addTest(kolabobjecttest)
 +addTest(timezonetest)
+ addTest(mimeobjecttest)


commit a6a6dc1e0ab52db294584df6917b56a18a8fe34d
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Thu Dec 20 10:06:07 2012 +0100

    added CMakeList.txt to git commit for the mimeobjecttest

diff --git a/kolabformat/mimeobject.h b/kolabformat/mimeobject.h
index cca42f0..e025947 100644
--- a/kolabformat/mimeobject.h
+++ b/kolabformat/mimeobject.h
@@ -37,23 +37,23 @@ class KOLAB_EXPORT MIMEObject
 public:
     explicit MIMEObject();
 
-    std::string writeEvent(const Event  &event, Version version, const std::string &productId = std::string());
+    std::string writeEvent(const Kolab::Event  &event, Version version, const std::string &productId = std::string());
     Kolab::Event readEvent(const std::string &s);
 
-    std::string writeTodo(const Todo &todo, Version version, const std::string &productId = std::string());
-    Todo readTodo(const std::string &s);
+    std::string writeTodo(const Kolab::Todo &todo, Version version, const std::string &productId = std::string());
+    Kolab::Todo readTodo(const std::string &s);
 
-    std::string writeJournal(const Journal &journal, Version version, const std::string &productId = std::string());
-    Journal readJournal(const std::string &s);
+    std::string writeJournal(const Kolab::Journal &journal, Version version, const std::string &productId = std::string());
+    Kolab::Journal readJournal(const std::string &s);
 
-    std::string writeNote(const Note &note, Version version, const std::string &productId = std::string());
-    Note readNote(const std::string &s);
+    std::string writeNote(const Kolab::Note &note, Version version, const std::string &productId = std::string());
+    Kolab::Note readNote(const std::string &s);
 
-    std::string writeContact(const Contact &contact, Version version, const std::string &productId = std::string());
-    Contact readContact(const std::string &s);
+    std::string writeContact(const Kolab::Contact &contact, Version version, const std::string &productId = std::string());
+    Kolab::Contact readContact(const std::string &s);
 
-    std::string writeDistlist(const DistList &distlist, Version version, const std::string &productId = std::string());
-    DistList readDistlist(const std::string &s);
+    std::string writeDistlist(const Kolab::DistList &distlist, Version version, const std::string &productId = std::string());
+    Kolab::DistList readDistlist(const std::string &s);
 
 };
 }
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7362351..43f7499 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -20,3 +20,4 @@ addTest(calendaringtest)
 addTest(icalendartest)
 addTest(freebusytest)
 addTest(kolabobjecttest)
+addTest(mimeobjecttest)


commit 9bf311afa11da8b7aee1ec2099de5f3e3451fc13
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Thu Dec 20 08:59:56 2012 +0100

    Changed tabs to spaces

diff --git a/kolabformat/mimeobject.h b/kolabformat/mimeobject.h
index 612f057..cca42f0 100644
--- a/kolabformat/mimeobject.h
+++ b/kolabformat/mimeobject.h
@@ -35,10 +35,10 @@ namespace Kolab
 class KOLAB_EXPORT MIMEObject
 {
 public:
-	explicit MIMEObject();
+    explicit MIMEObject();
 
-	std::string writeEvent(const Event  &event, Version version, const std::string &productId = std::string());
-	Kolab::Event readEvent(const std::string &s);
+    std::string writeEvent(const Event  &event, Version version, const std::string &productId = std::string());
+    Kolab::Event readEvent(const std::string &s);
 
     std::string writeTodo(const Todo &todo, Version version, const std::string &productId = std::string());
     Todo readTodo(const std::string &s);
@@ -55,7 +55,6 @@ public:
     std::string writeDistlist(const DistList &distlist, Version version, const std::string &productId = std::string());
     DistList readDistlist(const std::string &s);
 
-
 };
 }
 #endif  


commit 6e518f0363f3733ce7f49bfb9af5bc2e0e018a49
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Mon Dec 17 23:10:56 2012 +0100

    Compleated mimeobject and wrote testcases

diff --git a/kolabformat/mimeobject.cpp b/kolabformat/mimeobject.cpp
index 681d40b..559cf75 100644
--- a/kolabformat/mimeobject.cpp
+++ b/kolabformat/mimeobject.cpp
@@ -1,8 +1,26 @@
+/*
+ * Copyright (C) 2012  Sofia Balicka <balicka at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "mimeobject.h"
 #include "conversion/kcalconversion.h"
+#include "conversion/kolabconversion.h"
+#include "conversion/kabcconversion.h"
 #include "kolabformat/kolabobject.h"
 #include <QString>
-#include <iostream>
 
 namespace Kolab
 {
@@ -12,28 +30,133 @@ MIMEObject::MIMEObject()
 
 }
 
-Event MIMEObject::readEvent(const std::string &s)
+std::string MIMEObject::writeEvent(const Event &event, Version version, const std::string &productId)
 {
 
-	KMime::Message::Ptr msg(new KMime::Message);
-	msg->setContent(QByteArray(s.c_str()));
-	msg->parse();
-	
-	KCalCore::Event::Ptr event = KolabObjectReader(msg).getEvent();
-	
-	return Conversion::fromKCalCore(*event); 
+    KCalCore::Event::Ptr KEvent = Conversion::toKCalCore(event);
+
+    KMime::Message::Ptr msg = KolabObjectWriter().writeEvent(KEvent, version, QString::fromStdString(productId));
+    msg->assemble();
+
+    return msg->encodedContent().data();
 }
 
-std::string MIMEObject::writeEvent(const Event &event, Version version, const std::string &productId)
+Event MIMEObject::readEvent(const std::string &s)
 {
 
-	KCalCore::Event::Ptr KEvent = Conversion::toKCalCore(event);
+    KMime::Message::Ptr msg(new KMime::Message);
+    msg->setContent(QByteArray(s.c_str()));
+    msg->parse();
+    
+    KCalCore::Event::Ptr event = KolabObjectReader(msg).getEvent();
+    
+    return Conversion::fromKCalCore(*event); 
+}
+
+std::string MIMEObject::writeTodo(const Todo &todo, Version version, const std::string &productId){
+    KCalCore::Todo::Ptr kTodo = Conversion::toKCalCore(todo);
 
-	KMime::Message::Ptr msg = KolabObjectWriter().writeEvent(KEvent, version, QString::fromStdString(productId));
-	msg->assemble();
+    KMime::Message::Ptr msg = KolabObjectWriter().writeTodo(kTodo, version, QString::fromStdString(productId));
+    msg->assemble();
 
-	return msg->encodedContent().data();
+    return msg->encodedContent().data();
 }
 
+
+Todo MIMEObject::readTodo(const std::string &s){
+
+    KMime::Message::Ptr msg(new KMime::Message);
+    msg->setContent(QByteArray(s.c_str()));
+    msg->parse();
+    
+    KCalCore::Todo::Ptr todo = KolabObjectReader(msg).getTodo();
+    
+    return Conversion::fromKCalCore(*todo);
+}
+
+
+std::string MIMEObject::writeJournal(const Journal &journal, Version version, const std::string &productId){
+    KCalCore::Journal::Ptr kJournal = Conversion::toKCalCore(journal);
+
+    KMime::Message::Ptr msg = KolabObjectWriter().writeJournal(kJournal, version, QString::fromStdString(productId));
+    msg->assemble();
+
+    return msg->encodedContent().data();
+}
+
+
+Journal MIMEObject::readJournal(const std::string &s){
+
+    KMime::Message::Ptr msg(new KMime::Message);
+    msg->setContent(QByteArray(s.c_str()));
+    msg->parse();
+    
+    KCalCore::Journal::Ptr journal = KolabObjectReader(msg).getJournal();
+    
+    return Conversion::fromKCalCore(*journal);
+}
+
+std::string MIMEObject::writeNote(const Note &note, Version version, const std::string &productId){
+    KMime::Message::Ptr kNote = Conversion::toNote(note);
+
+    KMime::Message::Ptr msg = KolabObjectWriter().writeNote(kNote, version, QString::fromStdString(productId));
+    msg->assemble();
+
+    return msg->encodedContent().data();
+}
+
+
+Note MIMEObject::readNote(const std::string &s){
+
+    KMime::Message::Ptr msg(new KMime::Message);
+    msg->setContent(QByteArray(s.c_str()));
+    msg->parse();
+    
+    KMime::Message::Ptr note = KolabObjectReader(msg).getNote();
+    
+    return Conversion::fromNote(note);
+}
+
+std::string MIMEObject::writeContact(const Contact &contact, Version version, const std::string &productId){
+    KABC::Addressee kContact = Conversion::toKABC(contact);
+
+    KMime::Message::Ptr msg = KolabObjectWriter().writeContact(kContact, version, QString::fromStdString(productId));
+    msg->assemble();
+
+    return msg->encodedContent().data();
+}
+
+
+Contact MIMEObject::readContact(const std::string &s){
+
+    KMime::Message::Ptr msg(new KMime::Message);
+    msg->setContent(QByteArray(s.c_str()));
+    msg->parse();
+    
+    KABC::Addressee contact = KolabObjectReader(msg).getContact();
+    
+    return Conversion::fromKABC(contact);
+}
+
+std::string MIMEObject::writeDistlist(const DistList &distlist, Version version, const std::string &productId){
+    KABC::ContactGroup kDistlist = Conversion::toKABC(distlist);
+
+    KMime::Message::Ptr msg = KolabObjectWriter().writeDistlist(kDistlist, version, QString::fromStdString(productId));
+    msg->assemble();
+
+    return msg->encodedContent().data();
+}
+
+
+DistList MIMEObject::readDistlist(const std::string &s){
+
+    KMime::Message::Ptr msg(new KMime::Message);
+    msg->setContent(QByteArray(s.c_str()));
+    msg->parse();
+    
+    KABC::ContactGroup distlist = KolabObjectReader(msg).getDistlist();
+    
+    return Conversion::fromKABC(distlist);
+}
 }
 
diff --git a/kolabformat/mimeobject.h b/kolabformat/mimeobject.h
index ac4bd97..612f057 100644
--- a/kolabformat/mimeobject.h
+++ b/kolabformat/mimeobject.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2012  Sofia Balicka <balicka at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #ifndef MIMEOBJECT_H
 #define MIMEOBJECT_H
 
@@ -20,8 +37,25 @@ class KOLAB_EXPORT MIMEObject
 public:
 	explicit MIMEObject();
 
+	std::string writeEvent(const Event  &event, Version version, const std::string &productId = std::string());
 	Kolab::Event readEvent(const std::string &s);
-	std::string writeEvent(const Kolab::Event  &event, Version version, const std::string& productId = std::string());
+
+    std::string writeTodo(const Todo &todo, Version version, const std::string &productId = std::string());
+    Todo readTodo(const std::string &s);
+
+    std::string writeJournal(const Journal &journal, Version version, const std::string &productId = std::string());
+    Journal readJournal(const std::string &s);
+
+    std::string writeNote(const Note &note, Version version, const std::string &productId = std::string());
+    Note readNote(const std::string &s);
+
+    std::string writeContact(const Contact &contact, Version version, const std::string &productId = std::string());
+    Contact readContact(const std::string &s);
+
+    std::string writeDistlist(const DistList &distlist, Version version, const std::string &productId = std::string());
+    DistList readDistlist(const std::string &s);
+
+
 };
 }
 #endif  
diff --git a/tests/mimeobjecttest.cpp b/tests/mimeobjecttest.cpp
index 5aff4bb..0d5d42a 100644
--- a/tests/mimeobjecttest.cpp
+++ b/tests/mimeobjecttest.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2012  Sofia Balicka <balicka at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include <QTest>
 #include "mimeobjecttest.h"
 #include "kolabformat/kolabobject.h"
@@ -9,24 +26,117 @@
 
 void MIMEObjectTest::testEvent(){
 
-	Kolab::MIMEObject mimeobject;
+    Kolab::MIMEObject mimeobject;
 
-	std::ifstream t((TESTFILEDIR.toStdString()+"v3/event/simple.ics.mime").c_str());
-	std::stringstream buffer;
-	buffer << t.rdbuf();
+    std::ifstream t((TESTFILEDIR.toStdString()+"v3/event/simple.ics.mime").c_str());
+    std::stringstream buffer;
+    buffer << t.rdbuf();
 
     Kolab::Event event = mimeobject.readEvent(buffer.str());
-	
-	std::string message = mimeobject.writeEvent(event, Kolab::KolabV3);
-
-	QString qMessage = QString::fromStdString(message);
-	QString input = QString::fromStdString(buffer.str());
-	
-	normalizeMimemessage(qMessage);
-	normalizeMimemessage(input);
-	QCOMPARE(input, qMessage);
+    
+    std::string message = mimeobject.writeEvent(event, Kolab::KolabV3);
+
+    QString qMessage = QString::fromStdString(message);
+    QString input = QString::fromStdString(buffer.str());
+    
+    normalizeMimemessage(qMessage);
+    normalizeMimemessage(input);
+    
+    QCOMPARE(input.simplified(), qMessage.simplified());
+}
+/*
+void MIMEObjectTest::testTodo(){
+
+}
+*/
+
+void MIMEObjectTest::testJournal(){
+
+    Kolab::MIMEObject mimeobject;
+
+    std::ifstream t((TESTFILEDIR.toStdString()+"v3/journal/simple.ics.mime").c_str());
+    std::stringstream buffer;
+    buffer << t.rdbuf();
+
+    Kolab::Journal journal = mimeobject.readJournal(buffer.str());
+    
+    std::string message = mimeobject.writeJournal(journal, Kolab::KolabV3);
+
+    QString qMessage = QString::fromStdString(message);
+    QString input = QString::fromStdString(buffer.str());
+    
+    normalizeMimemessage(qMessage);
+    normalizeMimemessage(input);
+    
+    QCOMPARE(input.simplified(), qMessage.simplified());
+
 }
 
+void MIMEObjectTest::testNote(){
+
+    Kolab::MIMEObject mimeobject;
+
+    std::ifstream t((TESTFILEDIR.toStdString()+"v3/note/note.mime.mime").c_str());
+    std::stringstream buffer;
+    buffer << t.rdbuf();
+
+    Kolab::Note note = mimeobject.readNote(buffer.str());
+    
+    std::string message = mimeobject.writeNote(note, Kolab::KolabV3);
+
+    QString qMessage = QString::fromStdString(message);
+    QString input = QString::fromStdString(buffer.str());
+    
+    normalizeMimemessage(qMessage);
+    normalizeMimemessage(input);
+    
+    QCOMPARE(input.simplified(), qMessage.simplified());
+
+}
+
+void MIMEObjectTest::testContact(){
+
+    Kolab::MIMEObject mimeobject;
+
+    std::ifstream t((TESTFILEDIR.toStdString()+"v3/contacts/simple.vcf.mime").c_str());
+    std::stringstream buffer;
+    buffer << t.rdbuf();
+
+    Kolab::Contact contact = mimeobject.readContact(buffer.str());
+    
+    std::string message = mimeobject.writeContact(contact, Kolab::KolabV3);
+
+    QString qMessage = QString::fromStdString(message);
+    QString input = QString::fromStdString(buffer.str());
+    
+    normalizeMimemessage(qMessage);
+    normalizeMimemessage(input);
+    
+    QCOMPARE(input.simplified(), qMessage.simplified());
+
+}
+
+void MIMEObjectTest::testDistlist(){
+
+    Kolab::MIMEObject mimeobject;
+
+    std::ifstream t((TESTFILEDIR.toStdString()+"v3/contacts/distlist.vcf.mime").c_str());
+    std::stringstream buffer;
+    buffer << t.rdbuf();
+
+    Kolab::DistList distlist = mimeobject.readDistlist(buffer.str());
+    
+    std::string message = mimeobject.writeDistlist(distlist, Kolab::KolabV3);
+
+    QString qMessage = QString::fromStdString(message);
+    QString input = QString::fromStdString(buffer.str());
+    
+    normalizeMimemessage(qMessage);
+    normalizeMimemessage(input);
+    
+    QCOMPARE(input.simplified(), qMessage.simplified());
+
+}
 QTEST_MAIN( MIMEObjectTest )
 
 #include "mimeobjecttest.moc"
diff --git a/tests/mimeobjecttest.h b/tests/mimeobjecttest.h
index 74619b9..badb4c5 100644
--- a/tests/mimeobjecttest.h
+++ b/tests/mimeobjecttest.h
@@ -1,13 +1,34 @@
+/*
+ * Copyright (C) 2012  Sofia Balicka <balicka at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #ifndef MIMEOBJECTTEST_H
 #define MIMEOBJECTTEST_H
 #include <QObject>
 
 class MIMEObjectTest: public QObject
 {
-	Q_OBJECT
+    Q_OBJECT
 
 private slots:
-	void  testEvent();
+    void testEvent();
+    void testJournal(); 
+    void testNote();
+    void testContact();
+    void testDistlist();
 };
 #endif // MIMEOBJECTTEST_H
 
diff --git a/utils/kolabformatchecker.cpp b/utils/kolabformatchecker.cpp
index cfca944..aeee18c 100644
--- a/utils/kolabformatchecker.cpp
+++ b/utils/kolabformatchecker.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2012  Sofia Balicka <balicka at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include <boost/program_options.hpp>
 #include <iostream>
 #include <string>


commit 9c1dc3ca7d5744df4bf501c75aac69ec22187404
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Fri Dec 14 22:38:35 2012 +0100

    added testcase

diff --git a/kolabformat/mimeobject.cpp b/kolabformat/mimeobject.cpp
index 1d588d1..681d40b 100644
--- a/kolabformat/mimeobject.cpp
+++ b/kolabformat/mimeobject.cpp
@@ -1,17 +1,39 @@
 #include "mimeobject.h"
 #include "conversion/kcalconversion.h"
 #include "kolabformat/kolabobject.h"
+#include <QString>
+#include <iostream>
 
-Kolab::Event MIMEObject::readEvent(const std::string &s){
+namespace Kolab
+{
 
-	KMime:Message::Ptr msg(new KMime::Message);
-	msg.setContent(QByteArray(s.c_str()));
-	msg.parse();
-		
-	KCalCore::Event::Ptr event = Kolab::KolabObjectReader(msg).getEvent();
+MIMEObject::MIMEObject()
+{
 
-	return Kolab::Conversion::fromKCalCore(*event); 
 }
 
-Kolab::Event MIMEObject::writeEvent(const KMime::Message::Ptr &message){
+Event MIMEObject::readEvent(const std::string &s)
+{
+
+	KMime::Message::Ptr msg(new KMime::Message);
+	msg->setContent(QByteArray(s.c_str()));
+	msg->parse();
+	
+	KCalCore::Event::Ptr event = KolabObjectReader(msg).getEvent();
+	
+	return Conversion::fromKCalCore(*event); 
+}
+
+std::string MIMEObject::writeEvent(const Event &event, Version version, const std::string &productId)
+{
+
+	KCalCore::Event::Ptr KEvent = Conversion::toKCalCore(event);
+
+	KMime::Message::Ptr msg = KolabObjectWriter().writeEvent(KEvent, version, QString::fromStdString(productId));
+	msg->assemble();
+
+	return msg->encodedContent().data();
+}
+
+}
 
diff --git a/kolabformat/mimeobject.h b/kolabformat/mimeobject.h
index 9a9474f..ac4bd97 100644
--- a/kolabformat/mimeobject.h
+++ b/kolabformat/mimeobject.h
@@ -8,17 +8,20 @@
 #define KOLAB_EXPORT
 #endif
 
-//#include <qstring.h>
 #include <kolabformat.h>
+#include "kolabdefinitions.h"
 
 
+namespace Kolab
+{
+
 class KOLAB_EXPORT MIMEObject
 {
 public:
 	explicit MIMEObject();
 
 	Kolab::Event readEvent(const std::string &s);
-	std::string MIMEObject::writeEvent(const Todo &event, Version version, const std::string& productId);
+	std::string writeEvent(const Kolab::Event  &event, Version version, const std::string& productId = std::string());
 };
-
+}
 #endif  
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 346c6e8..9e2613c 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -36,6 +36,7 @@
 #include "kolabformat/errorhandler.h"
 #include "kolabformat/kolabdefinitions.h"
 
+/*
 void normalizeMimemessage(QString &content)
 {
     content.replace(QRegExp("\\bLibkolab-\\d.\\d.\\d\\b", Qt::CaseSensitive), "Libkolab-x.x.x");
@@ -49,7 +50,7 @@ void normalizeMimemessage(QString &content)
     content.replace(QRegExp("\\bboundary=\"nextPart[^\\n]*", Qt::CaseSensitive), "boundary");
     content.replace(QRegExp("Date[^\\n]*", Qt::CaseSensitive), "Date");
 }
-
+*/
 static bool compareMimeMessage( const KMime::Message::Ptr &msg, const KMime::Message::Ptr &expectedMsg )
 {
     // headers
diff --git a/tests/mimeobjecttest.cpp b/tests/mimeobjecttest.cpp
new file mode 100644
index 0000000..5aff4bb
--- /dev/null
+++ b/tests/mimeobjecttest.cpp
@@ -0,0 +1,32 @@
+#include <QTest>
+#include "mimeobjecttest.h"
+#include "kolabformat/kolabobject.h"
+#include "testutils.h"
+#include "kolabformat/mimeobject.h"
+#include <fstream>
+#include <sstream>
+#include <QString>
+
+void MIMEObjectTest::testEvent(){
+
+	Kolab::MIMEObject mimeobject;
+
+	std::ifstream t((TESTFILEDIR.toStdString()+"v3/event/simple.ics.mime").c_str());
+	std::stringstream buffer;
+	buffer << t.rdbuf();
+
+    Kolab::Event event = mimeobject.readEvent(buffer.str());
+	
+	std::string message = mimeobject.writeEvent(event, Kolab::KolabV3);
+
+	QString qMessage = QString::fromStdString(message);
+	QString input = QString::fromStdString(buffer.str());
+	
+	normalizeMimemessage(qMessage);
+	normalizeMimemessage(input);
+	QCOMPARE(input, qMessage);
+}
+
+QTEST_MAIN( MIMEObjectTest )
+
+#include "mimeobjecttest.moc"
diff --git a/tests/mimeobjecttest.h b/tests/mimeobjecttest.h
new file mode 100644
index 0000000..74619b9
--- /dev/null
+++ b/tests/mimeobjecttest.h
@@ -0,0 +1,13 @@
+#ifndef MIMEOBJECTTEST_H
+#define MIMEOBJECTTEST_H
+#include <QObject>
+
+class MIMEObjectTest: public QObject
+{
+	Q_OBJECT
+
+private slots:
+	void  testEvent();
+};
+#endif // MIMEOBJECTTEST_H
+
diff --git a/tests/testutils.h b/tests/testutils.h
index e6bb15c..24f1db5 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -87,6 +87,22 @@ KMime::Message::Ptr readMimeFile( const QString &fileName, bool &ok)
     return msg;
 }
 
+
+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("\\bLibkolab-\\d.\\d\\b", Qt::CaseSensitive), "Libkolab-x.x.x");
+    content.replace(QRegExp("\\bLibkolabxml-\\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>");
+
+    content.replace(QRegExp("--nextPart\\S*", Qt::CaseSensitive), "--part");
+    content.replace(QRegExp("\\bboundary=\"nextPart[^\\n]*", Qt::CaseSensitive), "boundary");
+    content.replace(QRegExp("Date[^\\n]*", Qt::CaseSensitive), "Date");
+}
+
+
 //Normalize incidences for comparison
 void normalizeIncidence( KCalCore::Incidence::Ptr incidence)
 {   


commit d83437de791a4413725212b6f467b18ed0ff7fbb
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Fri Dec 14 00:11:31 2012 +0100

    started mimeobject

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a459d3..6b6210d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,6 +123,7 @@ set(KOLAB_SRCS
     kolabformat/formathelpers.cpp
     kolabformat/errorhandler.cpp
     kolabformat/v2helpers.cpp
+	kolabformat/mimeobject.cpp
     mime/mimeutils.cpp
     ${CONVERSION_SRCS}
     ${kolabformatv2_SRCS}
diff --git a/kolabformat/kolabobject.i b/kolabformat/kolabobject.i
index 73c19be..6de018d 100644
--- a/kolabformat/kolabobject.i
+++ b/kolabformat/kolabobject.i
@@ -4,6 +4,7 @@
     
     #include "../kolabformat/xmlobject.h"
     #include "../kolabformat/kolabdefinitions.h"
+    #include "../kolabformat/mimeobject.h"
 %}
 
 %include "std_string.i"
@@ -14,3 +15,4 @@
 
 %include "../kolabformat/xmlobject.h"
 %include "../kolabformat/kolabdefinitions.h"
+%include "../kolabformat/mimeobject.h"
diff --git a/kolabformat/mimeobject.cpp b/kolabformat/mimeobject.cpp
new file mode 100644
index 0000000..1d588d1
--- /dev/null
+++ b/kolabformat/mimeobject.cpp
@@ -0,0 +1,17 @@
+#include "mimeobject.h"
+#include "conversion/kcalconversion.h"
+#include "kolabformat/kolabobject.h"
+
+Kolab::Event MIMEObject::readEvent(const std::string &s){
+
+	KMime:Message::Ptr msg(new KMime::Message);
+	msg.setContent(QByteArray(s.c_str()));
+	msg.parse();
+		
+	KCalCore::Event::Ptr event = Kolab::KolabObjectReader(msg).getEvent();
+
+	return Kolab::Conversion::fromKCalCore(*event); 
+}
+
+Kolab::Event MIMEObject::writeEvent(const KMime::Message::Ptr &message){
+
diff --git a/kolabformat/mimeobject.h b/kolabformat/mimeobject.h
new file mode 100644
index 0000000..9a9474f
--- /dev/null
+++ b/kolabformat/mimeobject.h
@@ -0,0 +1,24 @@
+#ifndef MIMEOBJECT_H
+#define MIMEOBJECT_H
+
+#ifndef SWIG
+#include "kolab_export.h"
+#else
+/* No export/import SWIG interface files */
+#define KOLAB_EXPORT
+#endif
+
+//#include <qstring.h>
+#include <kolabformat.h>
+
+
+class KOLAB_EXPORT MIMEObject
+{
+public:
+	explicit MIMEObject();
+
+	Kolab::Event readEvent(const std::string &s);
+	std::string MIMEObject::writeEvent(const Todo &event, Version version, const std::string& productId);
+};
+
+#endif  


commit 4c4f5f2cd1c47a971e030b0426d9c3425a1011e2
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Mon Dec 3 16:24:08 2012 +0100

    Improved error handling

diff --git a/utils/kolabformatchecker.cpp b/utils/kolabformatchecker.cpp
index b28c4a0..cfca944 100644
--- a/utils/kolabformatchecker.cpp
+++ b/utils/kolabformatchecker.cpp
@@ -3,14 +3,13 @@
 #include <string>
 #include <vector>
 #include <kolabformat.h>
+#include "kolabformat/errorhandler.h"
 #include "tests/testutils.h"
 #include "kolabformat/kolabobject.h"
-#include "kolabformat/errorhandler.h"
 #include "qstring.h"
 
 namespace po = boost::program_options;
 using namespace std;
-using namespace Kolab;
 
 int main(int argc, char *argv[])
 {
@@ -42,8 +41,6 @@ int main(int argc, char *argv[])
         return -1;
     }
 	
-	ErrorHandler::handleLibkolabxmlErrors();
-
 	int returnValue = 0;
 
 	cout << endl;
@@ -51,8 +48,6 @@ int main(int argc, char *argv[])
 	for(vector<string>::const_iterator it = inputFiles.begin();
             it != inputFiles.end(); it++){
 
-		ErrorHandler::clearErrors();
-
 		cout << "File: " << *it << endl;
 
 		bool ok;
@@ -65,11 +60,8 @@ int main(int argc, char *argv[])
 		}
 
 		Kolab::KolabObjectReader reader(message);
-	
-		if (error()){
-			cout << "Error: " << errorMessage() << endl;
-			returnValue = -1;
-		} else if (ErrorHandler::errorOccured()){
+
+		if (Kolab::ErrorHandler::errorOccured()){
 			cout << "Errors occured during parsing." << endl;
 			returnValue = -1;
 		} else {


commit c78c8e316668d51b1135ea2ee4e937496a6560f2
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Mon Dec 3 13:56:17 2012 +0100

    Changed error handling.

diff --git a/utils/kolabformatchecker.cpp b/utils/kolabformatchecker.cpp
index af5a0ed..b28c4a0 100644
--- a/utils/kolabformatchecker.cpp
+++ b/utils/kolabformatchecker.cpp
@@ -44,37 +44,41 @@ int main(int argc, char *argv[])
 	
 	ErrorHandler::handleLibkolabxmlErrors();
 
-	bool faildToOpen=false;
-		
+	int returnValue = 0;
+
 	cout << endl;
 
 	for(vector<string>::const_iterator it = inputFiles.begin();
             it != inputFiles.end(); it++){
 
+		ErrorHandler::clearErrors();
+
 		cout << "File: " << *it << endl;
 
 		bool ok;
 		KMime::Message::Ptr message = readMimeFile( QString::fromStdString(*it), ok);
 
 		if(!ok){
-			faildToOpen=true;
+			returnValue = -1;
 			cout << endl;
 			continue;
 		}
 
 		Kolab::KolabObjectReader reader(message);
 	
-		if (!error()) {
-            cout << "Parsed message without error." << endl;
-        }
-		
+		if (error()){
+			cout << "Error: " << errorMessage() << endl;
+			returnValue = -1;
+		} else if (ErrorHandler::errorOccured()){
+			cout << "Errors occured during parsing." << endl;
+			returnValue = -1;
+		} else {
+			cout << "Parsed message without error." << endl;
+		}
+
 		cout << endl;
     }
 
-	if (ErrorHandler::errorOccured() || faildToOpen){
-		return -1;
-	}
-
-    return 0;
+    return returnValue;
 }
 


commit 13269ae66fadc484b1b4ba68f44298cf95d818dc
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Mon Dec 3 13:08:08 2012 +0100

    Formatchecker rewritten

diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
new file mode 100644
index 0000000..19d34d1
--- /dev/null
+++ b/utils/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+find_package(Boost REQUIRED COMPONENTS program_options)
+
+add_executable(kolabformatchecker kolabformatchecker.cpp)
+target_link_libraries(kolabformatchecker kolab ${Boost_LIBRARIES})
diff --git a/utils/kolabformatchecker.cpp b/utils/kolabformatchecker.cpp
index f13a08c..af5a0ed 100644
--- a/utils/kolabformatchecker.cpp
+++ b/utils/kolabformatchecker.cpp
@@ -5,8 +5,8 @@
 #include <kolabformat.h>
 #include "tests/testutils.h"
 #include "kolabformat/kolabobject.h"
-#include "qstring.h"
 #include "kolabformat/errorhandler.h"
+#include "qstring.h"
 
 namespace po = boost::program_options;
 using namespace std;
@@ -38,60 +38,43 @@ int main(int argc, char *argv[])
     if (vm.count("input-file")) {
         inputFiles = vm["input-file"].as< vector<string> >();
     } else {
-        cout << "Specify input-file";
+        cout << "Specify input-file\n";
         return -1;
     }
 	
+	ErrorHandler::handleLibkolabxmlErrors();
+
+	bool faildToOpen=false;
+		
+	cout << endl;
+
 	for(vector<string>::const_iterator it = inputFiles.begin();
             it != inputFiles.end(); it++){
 
-		ErrorHandler::clearErrors();
+		cout << "File: " << *it << endl;
+
 		bool ok;
 		KMime::Message::Ptr message = readMimeFile( QString::fromStdString(*it), ok);
 
-		if(!ok) continue;
-
-		Kolab::KolabObjectReader reader(message);
-		ObjectType type = reader.getType();
-		
-		switch (type){
-			case ContactObject:
-				reader.getContact();
-				break;
-			case DistlistObject:
-				reader.getDistlist();
-				break;
-			case EventObject:
-				reader.getEvent();
-				break;
-			case TodoObject:
-				reader.getTodo();
-				break; 	
-			case JournalObject:
-				reader.getJournal();
-				break;
-			case FreebusyObject:
-				reader.getFreebusy();
-				break;
-			case NoteObject:
-				reader.getNote();
-				break;
-			//case DictionaryConfigurationObject:
-			//	break;
+		if(!ok){
+			faildToOpen=true;
+			cout << endl;
+			continue;
 		}
 
-		cout << "File: " << *it << endl;
-		
-		if (error()) {
-            cout << "Error: " << errorMessage() << endl;
-		} else  if (ErrorHandler::errorOccured() || type == InvalidObject){
-			//was machen?
-			cout << "error..." << endl;
-		} else {
+		Kolab::KolabObjectReader reader(message);
+	
+		if (!error()) {
             cout << "Parsed message without error." << endl;
         }
-
+		
+		cout << endl;
     }
+
+	if (ErrorHandler::errorOccured() || faildToOpen){
+		return -1;
+	}
+
     return 0;
 }
 


commit c0701e95450905fc0062f748c76444f7b422c830
Author: Sofia Balicka <balicka at kolabsys.com>
Date:   Fri Nov 30 22:08:51 2012 +0100

    fist attempt in writing the kolabformatchecker.cpp

diff --git a/utils/kolabformatchecker.cpp b/utils/kolabformatchecker.cpp
new file mode 100644
index 0000000..f13a08c
--- /dev/null
+++ b/utils/kolabformatchecker.cpp
@@ -0,0 +1,97 @@
+#include <boost/program_options.hpp>
+#include <iostream>
+#include <string>
+#include <vector>
+#include <kolabformat.h>
+#include "tests/testutils.h"
+#include "kolabformat/kolabobject.h"
+#include "qstring.h"
+#include "kolabformat/errorhandler.h"
+
+namespace po = boost::program_options;
+using namespace std;
+using namespace Kolab;
+
+int main(int argc, char *argv[])
+{
+    // Declare the supported options.
+    po::options_description desc("Allowed options");
+    desc.add_options()
+        ("help", "produce help message")
+        ("input-file", po::value<std::vector<std::string> >(), "input files")
+    ;
+
+    po::positional_options_description p;
+    p.add("input-file", -1);
+
+    po::variables_map vm;
+    po::store(po::command_line_parser(argc, argv).
+            options(desc).positional(p).run(), vm);
+    po::notify(vm);
+
+    if (vm.count("help")) {
+        cout << desc << "\n";
+        return 1;
+    }
+
+    vector<string> inputFiles;
+    if (vm.count("input-file")) {
+        inputFiles = vm["input-file"].as< vector<string> >();
+    } else {
+        cout << "Specify input-file";
+        return -1;
+    }
+	
+	for(vector<string>::const_iterator it = inputFiles.begin();
+            it != inputFiles.end(); it++){
+
+		ErrorHandler::clearErrors();
+		bool ok;
+		KMime::Message::Ptr message = readMimeFile( QString::fromStdString(*it), ok);
+
+		if(!ok) continue;
+
+		Kolab::KolabObjectReader reader(message);
+		ObjectType type = reader.getType();
+		
+		switch (type){
+			case ContactObject:
+				reader.getContact();
+				break;
+			case DistlistObject:
+				reader.getDistlist();
+				break;
+			case EventObject:
+				reader.getEvent();
+				break;
+			case TodoObject:
+				reader.getTodo();
+				break; 	
+			case JournalObject:
+				reader.getJournal();
+				break;
+			case FreebusyObject:
+				reader.getFreebusy();
+				break;
+			case NoteObject:
+				reader.getNote();
+				break;
+			//case DictionaryConfigurationObject:
+			//	break;
+		}
+
+		cout << "File: " << *it << endl;
+		
+		if (error()) {
+            cout << "Error: " << errorMessage() << endl;
+		} else  if (ErrorHandler::errorOccured() || type == InvalidObject){
+			//was machen?
+			cout << "error..." << endl;
+		} else {
+            cout << "Parsed message without error." << endl;
+        }
+
+    }
+    return 0;
+}
+





More information about the commits mailing list