summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-02-20 19:57:50 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-02-20 19:57:50 (GMT)
commite4fed71f3edba1ded1c66cf2ddda6cac7e2d33d5 (patch)
tree1fbbc6b4231eedb5ceb0c86aa9f1de990cf907f7
parent221cae6c555732334f2709ffdcc6e09d83e4362e (diff)
parentdb2407f888f1ec7bd58764168516359ca3c53b5b (diff)
downloadlibkolab-e4fed71f3edba1ded1c66cf2ddda6cac7e2d33d5.tar.gz
Merge branch 'files' into 0.4
Conflicts: tests/CMakeLists.txt
-rw-r--r--CMakeLists.txt6
-rw-r--r--conversion/kabcconversion.cpp1
-rw-r--r--kolabformat/kolabobject.i2
-rw-r--r--kolabformat/mimeobject.cpp162
-rw-r--r--kolabformat/mimeobject.h60
-rw-r--r--kolabformat/python/CMakeLists.txt4
-rw-r--r--kolabformat/xmlobject.cpp21
-rw-r--r--kolabformat/xmlobject.h5
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/formattest.cpp14
-rw-r--r--tests/mimeobjecttest.cpp142
-rw-r--r--tests/mimeobjecttest.h34
-rw-r--r--tests/testutils.h17
-rw-r--r--utils/CMakeLists.txt5
-rw-r--r--utils/kolabformatchecker.cpp93
15 files changed, 550 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae03027..8c9652b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,7 +31,7 @@ endif()
# 0.1.1 (patch release for 0.1.0)
# 0.2 (0.2 development version towards 0.2.0)
set(Libkolab_VERSION_MAJOR 0)
-set(Libkolab_VERSION_MINOR 4)
+set(Libkolab_VERSION_MINOR 5)
# Enable the full x.y.z version only for release versions
set(Libkolab_VERSION_PATCH 1)
set(Libkolab_VERSION ${Libkolab_VERSION_MAJOR}.${Libkolab_VERSION_MINOR}.${Libkolab_VERSION_PATCH} )
@@ -124,6 +124,7 @@ set(KOLAB_SRCS
kolabformat/formathelpers.cpp
kolabformat/errorhandler.cpp
kolabformat/v2helpers.cpp
+ kolabformat/mimeobject.cpp
mime/mimeutils.cpp
${CONVERSION_SRCS}
${kolabformatv2_SRCS}
@@ -166,6 +167,8 @@ install(FILES
kolabformat/formathelpers.h
kolabformat/kolabobject.h
kolabformat/errorhandler.h
+ kolabformat/xmlobject.h
+ kolabformat/mimeobject.h
conversion/kcalconversion.h
conversion/kabcconversion.h
conversion/commonconversion.h
@@ -187,6 +190,7 @@ install(FILES ${Libkolab_BINARY_DIR}/LibkolabConfig.cmake ${Libkolab_BINARY_DIR}
include(SWIGUtils)
if(PYTHON_BINDINGS)
generatePythonBindings(shared shared.i)
+ add_subdirectory(kolabformat/python)
endif(PYTHON_BINDINGS)
if(PHP_BINDINGS)
diff --git a/conversion/kabcconversion.cpp b/conversion/kabcconversion.cpp
index 1be0df8..6ab7185 100644
--- a/conversion/kabcconversion.cpp
+++ b/conversion/kabcconversion.cpp
@@ -834,7 +834,6 @@ KABC::ContactGroup toKABC(const DistList &dl)
KABC::ContactGroup cg(fromStdString(dl.name()));
cg.setId(fromStdString(dl.uid()));
foreach(const Kolab::ContactReference &m, dl.members()) {
- KABC::ContactGroup::Data data;
switch (m.type()) {
case Kolab::ContactReference::EmailReference:
cg.append(KABC::ContactGroup::Data(fromStdString(m.name()), fromStdString(m.email())));
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..559cf75
--- /dev/null
+++ b/kolabformat/mimeobject.cpp
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2012 Sofia Balicka <balicka@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>
+
+namespace Kolab
+{
+
+MIMEObject::MIMEObject()
+{
+
+}
+
+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();
+}
+
+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::writeTodo(const Todo &todo, Version version, const std::string &productId){
+ KCalCore::Todo::Ptr kTodo = Conversion::toKCalCore(todo);
+
+ KMime::Message::Ptr msg = KolabObjectWriter().writeTodo(kTodo, version, QString::fromStdString(productId));
+ msg->assemble();
+
+ 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
new file mode 100644
index 0000000..89ff788
--- /dev/null
+++ b/kolabformat/mimeobject.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Sofia Balicka <balicka@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
+
+#ifndef SWIG
+#include "kolab_export.h"
+#else
+/* No export/import SWIG interface files */
+#define KOLAB_EXPORT
+#endif
+
+#include <kolabformat.h>
+#include "kolabdefinitions.h"
+
+
+namespace Kolab
+{
+
+class KOLAB_EXPORT MIMEObject
+{
+public:
+ MIMEObject();
+
+ 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 Kolab::Todo &todo, Version version, const std::string &productId = std::string());
+ Kolab::Todo readTodo(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 Kolab::Note &note, Version version, const std::string &productId = std::string());
+ Kolab::Note readNote(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 Kolab::DistList &distlist, Version version, const std::string &productId = std::string());
+ Kolab::DistList readDistlist(const std::string &s);
+
+};
+}
+#endif
diff --git a/kolabformat/python/CMakeLists.txt b/kolabformat/python/CMakeLists.txt
new file mode 100644
index 0000000..5ff8bfe
--- /dev/null
+++ b/kolabformat/python/CMakeLists.txt
@@ -0,0 +1,4 @@
+include_directories(../)
+include(SWIGUtils)
+generatePythonBindings(kolabobject ../kolabobject.i)
+
diff --git a/kolabformat/xmlobject.cpp b/kolabformat/xmlobject.cpp
index 9a8c78f..e9e2f7a 100644
--- a/kolabformat/xmlobject.cpp
+++ b/kolabformat/xmlobject.cpp
@@ -327,5 +327,26 @@ std::string XMLObject::writeConfiguration(const Configuration &configuration, Ve
return result;
}
+File XMLObject::readFile(const std::string& s, Version version)
+{
+ if (version == KolabV2) {
+ Critical() << "only v3 implementation available";
+ return File();
+ }
+ return Kolab::readFile(s, false);
+}
+
+std::string XMLObject::writeFile(const File &file, Version version, const std::string& productId)
+{
+ mWrittenUID.clear();
+ if (version != KolabV3) {
+ Critical() << "only v3 implementation available";
+ return std::string();
+ }
+ const std::string result = Kolab::writeFile(file, productId);
+ mWrittenUID = Kolab::getSerializedUID();
+ return result;
+}
+
};
diff --git a/kolabformat/xmlobject.h b/kolabformat/xmlobject.h
index 6bb4149..5066e8f 100644
--- a/kolabformat/xmlobject.h
+++ b/kolabformat/xmlobject.h
@@ -34,7 +34,7 @@ namespace Kolab {
class KOLAB_EXPORT XMLObject
{
public:
- explicit XMLObject();
+ XMLObject();
std::string getSerializedUID() const;
@@ -85,6 +85,9 @@ public:
Kolab::Configuration readConfiguration(const std::string& s, Kolab::Version version);
std::string writeConfiguration(const Kolab::Configuration &, Kolab::Version version, const std::string& productId = std::string());
+
+ Kolab::File readFile(const std::string& s, Kolab::Version version);
+ std::string writeFile(const Kolab::File &, Kolab::Version version, const std::string& productId = std::string());
private:
std::vector<std::string> mAttachments;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6f71a0c..c7d1f0b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -22,3 +22,4 @@ addTest(freebusytest)
addTest(kolabobjecttest)
addTest(timezonetest)
addTest(xmlobjecttest)
+addTest(mimeobjecttest)
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 3ca0c24..3c05eb0 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -37,20 +37,6 @@
#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");
- 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@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");
-}
-
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..0d5d42a
--- /dev/null
+++ b/tests/mimeobjecttest.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2012 Sofia Balicka <balicka@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"
+#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.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
new file mode 100644
index 0000000..badb4c5
--- /dev/null
+++ b/tests/mimeobjecttest.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 Sofia Balicka <balicka@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
+
+private slots:
+ void testEvent();
+ void testJournal();
+ void testNote();
+ void testContact();
+ void testDistlist();
+};
+#endif // MIMEOBJECTTEST_H
+
diff --git a/tests/testutils.h b/tests/testutils.h
index 071a571..e7a71e1 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -87,6 +87,23 @@ 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@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");
+ content.replace(QRegExp("Date[^\\n]*", Qt::CaseSensitive), "Date");
+}
+
+
//Normalize incidences for comparison
void normalizeIncidence( KCalCore::Incidence::Ptr incidence)
{
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
new file mode 100644
index 0000000..aeee18c
--- /dev/null
+++ b/utils/kolabformatchecker.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2012 Sofia Balicka <balicka@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>
+#include <vector>
+#include <kolabformat.h>
+#include "kolabformat/errorhandler.h"
+#include "tests/testutils.h"
+#include "kolabformat/kolabobject.h"
+#include "qstring.h"
+
+namespace po = boost::program_options;
+using namespace std;
+
+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\n";
+ return -1;
+ }
+
+ int returnValue = 0;
+
+ cout << endl;
+
+ for(vector<string>::const_iterator it = inputFiles.begin();
+ it != inputFiles.end(); it++){
+
+ cout << "File: " << *it << endl;
+
+ bool ok;
+ KMime::Message::Ptr message = readMimeFile( QString::fromStdString(*it), ok);
+
+ if(!ok){
+ returnValue = -1;
+ cout << endl;
+ continue;
+ }
+
+ Kolab::KolabObjectReader reader(message);
+
+ if (Kolab::ErrorHandler::errorOccured()){
+ cout << "Errors occured during parsing." << endl;
+ returnValue = -1;
+ } else {
+ cout << "Parsed message without error." << endl;
+ }
+
+ cout << endl;
+ }
+
+ return returnValue;
+}
+