12 commits - conversion/kabcconversion.cpp kolabformat/kolabdefinitions.h kolabformat/kolabobject.cpp kolabformat/kolabobject.h kolabformat/v2helpers.h mime/mimeutils.cpp tests/formattest.cpp tests/formattest.h tests/testfiles tests/testutils.h
Christian Mollekopf
mollekopf at kolabsys.com
Fri Apr 27 17:26:55 CEST 2012
conversion/kabcconversion.cpp | 4
kolabformat/kolabdefinitions.h | 1
kolabformat/kolabobject.cpp | 201 ++++++++++++-----------
kolabformat/kolabobject.h | 1
kolabformat/v2helpers.h | 39 +++-
mime/mimeutils.cpp | 4
tests/formattest.cpp | 81 ++++++---
tests/formattest.h | 14 +
tests/testfiles/v2/contacts/bug238996.vcf.mime | 14 -
tests/testfiles/v2/task/complex.ics.mime | 3
tests/testfiles/v2/task/prioritytest2.ics.mime | 2
tests/testfiles/v2/task/simple.ics.mime | 1
tests/testfiles/v3/contacts/complex.vcf | 3
tests/testfiles/v3/contacts/complex.vcf.mime | 52 ++++--
tests/testfiles/v3/journal/complex.ics | 16 +
tests/testfiles/v3/journal/complex.ics.mime | 83 +++++++++
tests/testfiles/v3/journal/simple.ics | 14 +
tests/testfiles/v3/journal/simple.ics.mime | 75 ++++++++
tests/testfiles/v3/task/complex.ics | 51 +++++
tests/testfiles/v3/task/complex.ics.mime | 216 +++++++++++++++++++++++++
tests/testfiles/v3/task/simple.ics | 15 +
tests/testfiles/v3/task/simple.ics.mime | 70 ++++++++
tests/testutils.h | 1
23 files changed, 806 insertions(+), 155 deletions(-)
New commits:
commit 846ce8d1594c9310cb427fd50be7812a0e9aac1a
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 17:26:48 2012 +0200
Check error flag in test, localtime (floating) is clocktime in kdatetime.
diff --git a/conversion/kabcconversion.cpp b/conversion/kabcconversion.cpp
index ae7fa92..b710891 100644
--- a/conversion/kabcconversion.cpp
+++ b/conversion/kabcconversion.cpp
@@ -663,8 +663,8 @@ Kolab::Contact fromKABC(const KABC::Addressee &addressee)
if (!spouse.isEmpty()) {
c.setRelateds(std::vector<Kolab::Related>() << Kolab::Related(Kolab::Related::Text, spouse.toStdString(), Kolab::Related::Spouse));
}
- c.setBDay(fromDate(KDateTime(addressee.birthday())));
- c.setAnniversary(fromDate(KDateTime(QDate::fromString( addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("X-Anniversary")), Qt::ISODate ))));
+ c.setBDay(fromDate(KDateTime(addressee.birthday(), KDateTime::ClockTime)));
+ c.setAnniversary(fromDate(KDateTime(QDate::fromString( addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("X-Anniversary")), Qt::ISODate ), KDateTime::ClockTime)));
if (!addressee.photo().isEmpty()) {
std::string mimetype;
const std::string &photo = fromPicture(addressee.photo(), mimetype);
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 4317f28..f1c7527 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -28,6 +28,7 @@
#include <kdebug.h>
#include <kolab/kolabcontainers.h>
#include <kolab/kolabformat.h>
+#include <kolab/errorhandler.h>
#include <kcalcore/icalformat.h>
#include <kabc/vcardconverter.h>
@@ -240,6 +241,7 @@ void FormatTest::testIncidence()
showDiff(msg->encodedContent(), convertedMime->encodedContent());
QVERIFY( false );
}
+ QCOMPARE(Kolab::ErrorHandler::instance().error(), Kolab::ErrorHandler::Debug);
}
@@ -342,6 +344,7 @@ void FormatTest::testContact()
showDiff(expected, converted);
QVERIFY( false );
}
+ QCOMPARE(Kolab::ErrorHandler::instance().error(), Kolab::ErrorHandler::Debug);
}
commit f30dab4a60c508684bb8c3d8dc12a0de8d945edb
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 17:03:53 2012 +0200
writeIncidence convenience function
diff --git a/kolabformat/kolabobject.cpp b/kolabformat/kolabobject.cpp
index aa1b835..3b18a12 100644
--- a/kolabformat/kolabobject.cpp
+++ b/kolabformat/kolabobject.cpp
@@ -344,6 +344,22 @@ KMime::Message::Ptr KolabObjectWriter::writeJournal(const KCalCore::Journal::Ptr
return Mime::createMessage(i, journalKolabType(), journalKolabType(), xml.toLocal8Bit(), false, getProductId(productId));
}
+KMime::Message::Ptr KolabObjectWriter::writeIncidence(const KCalCore::Incidence::Ptr &i, Version v, const QString& productId, const QString& tz)
+{
+ switch (i->type()) {
+ case KCalCore::IncidenceBase::TypeEvent:
+ return writeEvent(i.dynamicCast<KCalCore::Event>(),v,productId,tz);
+ case KCalCore::IncidenceBase::TypeTodo:
+ return writeTodo(i.dynamicCast<KCalCore::Todo>(),v,productId,tz);
+ case KCalCore::IncidenceBase::TypeJournal:
+ return writeJournal(i.dynamicCast<KCalCore::Journal>(),v,productId,tz);
+ default:
+ Critical() << "unknown incidence type";
+ }
+ return KMime::Message::Ptr();
+}
+
+
KMime::Message::Ptr KolabObjectWriter::writeContact(const KABC::Addressee &addressee, Version v, const QString &productId)
{
ErrorHandler::clearErrors();
diff --git a/kolabformat/kolabobject.h b/kolabformat/kolabobject.h
index 5f0db29..604c1c5 100644
--- a/kolabformat/kolabobject.h
+++ b/kolabformat/kolabobject.h
@@ -102,6 +102,7 @@ public:
static KMime::Message::Ptr writeEvent(const KCalCore::Event::Ptr &, Version v = KolabV3, const QString &productId = QString(), const QString &tz = QString());
static KMime::Message::Ptr writeTodo(const KCalCore::Todo::Ptr &, Version v = KolabV3, const QString &productId = QString(),const QString &tz = QString());
static KMime::Message::Ptr writeJournal(const KCalCore::Journal::Ptr &, Version v = KolabV3, const QString &productId = QString(),const QString &tz = QString());
+ static KMime::Message::Ptr writeIncidence(const KCalCore::Incidence::Ptr &, Version v = KolabV3, const QString &productId = QString(),const QString &tz = QString());
static KMime::Message::Ptr writeContact(const KABC::Addressee &, Version v = KolabV3, const QString &productId = QString());
static KMime::Message::Ptr writeDistlist(const KABC::ContactGroup &, Version v = KolabV3, const QString &productId = QString());
static KMime::Message::Ptr writeNote(const KMime::Message::Ptr &, Version v = KolabV3, const QString &productId = QString());
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 5589e90..4317f28 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -348,30 +348,28 @@ void FormatTest::testContact()
//This function exists only to generate the reference files, it's not a real test.
void FormatTest::generateMimefile()
{
-// QFile icalFile( TESTFILEDIR+QString::fromLatin1("v3/event/complex.ics") );
+// QFile icalFile( TESTFILEDIR+QString::fromLatin1("v3/journal/complex.ics") );
// QVERIFY( icalFile.open( QFile::ReadOnly ) );
// KCalCore::ICalFormat format;
// const KCalCore::Incidence::Ptr realIncidence( format.fromString( QString::fromUtf8( icalFile.readAll() ) ) );
-//
+//
// QString result;
// QTextStream s(&result);
// Kolab::overrideTimestamp(Kolab::cDateTime(2012, 5, 5, 5,5,5, true));
-// Kolab::KolabObjectWriter::writeEvent(realIncidence.dynamicCast<KCalCore::Event>(), Kolab::KolabV3)->toStream(s);
-
+// Kolab::KolabObjectWriter::writeIncidence(realIncidence, Kolab::KolabV3)->toStream(s);
// QFile vcardFile( TESTFILEDIR+QString::fromLatin1("v3/contacts/complex.vcf") );
// QVERIFY( vcardFile.open( QFile::ReadOnly ) );
// KABC::VCardConverter converter;
// const KABC::Addressee realAddressee = converter.parseVCard( vcardFile.readAll() );
-//
+//
// kDebug() << realAddressee.photo().data();
-//
+//
// QString result;
// QTextStream s(&result);
// Kolab::overrideTimestamp(Kolab::cDateTime(2012, 5, 5, 5,5,5, true));
// Kolab::KolabObjectWriter::writeContact(realAddressee, Kolab::KolabV3)->toStream(s);
-
// kDebug() << result;
}
commit 6d06ae58e66150e6554de34cf88bc1117349d815
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 17:02:57 2012 +0200
more v3 tests
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 0ad1cb0..5589e90 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -166,6 +166,10 @@ void FormatTest::testIncidence_data()
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");
+ QTest::newRow( "v3todoSimple" ) << Kolab::KolabV3 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v3/task/simple.ics") << TESTFILEDIR+QString::fromLatin1("v3/task/simple.ics.mime");
+ QTest::newRow( "v3todoComplex" ) << Kolab::KolabV3 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v3/task/complex.ics") << TESTFILEDIR+QString::fromLatin1("v3/task/complex.ics.mime");
+ QTest::newRow( "v3journalSimple" ) << Kolab::KolabV3 << Kolab::JournalObject << TESTFILEDIR+QString::fromLatin1("v3/journal/simple.ics") << TESTFILEDIR+QString::fromLatin1("v3/journal/simple.ics.mime");
+ QTest::newRow( "v3journalComplex" ) << Kolab::KolabV3 << Kolab::JournalObject << TESTFILEDIR+QString::fromLatin1("v3/journal/complex.ics") << TESTFILEDIR+QString::fromLatin1("v3/journal/complex.ics.mime");
}
diff --git a/tests/testfiles/v3/journal/complex.ics b/tests/testfiles/v3/journal/complex.ics
new file mode 100644
index 0000000..4f57e28
--- /dev/null
+++ b/tests/testfiles/v3/journal/complex.ics
@@ -0,0 +1,16 @@
+BEGIN:VCALENDAR
+PRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN
+VERSION:2.0
+BEGIN:VJOURNAL
+DTSTAMP:20090901T150009Z
+CREATED:20090901T150009Z
+UID:KOrganizer-2037616327.585
+LAST-MODIFIED:20090901T150009Z
+DESCRIPTION:Some notes on this journal.
+SUMMARY:Complex Journal
+CATEGORIES:Business\,Meeting\,Miscellaneous
+DTSTART;TZID=Europe/Berlin:20090901T165900
+END:VJOURNAL
+
+END:VCALENDAR
+
diff --git a/tests/testfiles/v3/journal/complex.ics.mime b/tests/testfiles/v3/journal/complex.ics.mime
new file mode 100644
index 0000000..c37ddc5
--- /dev/null
+++ b/tests/testfiles/v3/journal/complex.ics.mime
@@ -0,0 +1,83 @@
+Date: Fri, 27 Apr 2012 17:01:37 +0200
+X-Kolab-Type: application/x-vnd.kolab.journal
+X-Kolab-Version: v3
+User-Agent: Libkolab-0.2.0
+Content-Type: multipart/mixed; boundary="nextPart6582735.aG9ClxN0L7"
+Subject: KOrganizer-2037616327.585
+MIME-Version: 1.0
+
+
+--nextPart6582735.aG9ClxN0L7
+Content-Type: text/plain; charset="us-ascii"
+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
+
+--nextPart6582735.aG9ClxN0L7
+Content-Type: application/calendar+xml; name="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"no" ?>
+<icalendar xmlns=3D"urn:ietf:params:xml:ns:icalendar-2.0">
+
+ <vcalendar>
+ <properties>
+ <prodid>
+ <text>Libkolab-0.2.0 Libkolabxml-0.4.0</text>
+ </prodid>
+ <version>
+ <text>2.0</text>
+ </version>
+ <x-kolab-version>
+ <text>3.0dev1</text>
+ </x-kolab-version>
+ </properties>
+ <components>
+ <vjournal>
+ <properties>
+ <uid>
+ <text>KOrganizer-2037616327.585</text>
+ </uid>
+ <created>
+ <date-time>2009-09-01T15:00:09Z</date-time>
+ </created>
+ <dtstamp>
+ <date-time>2012-05-05T05:05:05Z</date-time>
+ </dtstamp>
+ <sequence>
+ <integer>0</integer>
+ </sequence>
+ <class>
+ <text>PUBLIC</text>
+ </class>
+ <categories>
+ <text>Business</text>
+ <text>Meeting</text>
+ <text>Miscellaneous</text>
+ </categories>
+ <dtstart>
+ <parameters>
+ <tzid>
+ <text>/kolab.org/Europe/Berlin</text>
+ </tzid>
+ </parameters>
+ <date-time>2009-09-01T16:59:00</date-time>
+ </dtstart>
+ <summary>
+ <text>Complex Journal</text>
+ </summary>
+ <description>
+ <text>Some notes on this journal.</text>
+ </description>
+ </properties>
+ </vjournal>
+ </components>
+ </vcalendar>
+
+</icalendar>
+
+--nextPart6582735.aG9ClxN0L7--
diff --git a/tests/testfiles/v3/journal/simple.ics b/tests/testfiles/v3/journal/simple.ics
new file mode 100644
index 0000000..c49fc54
--- /dev/null
+++ b/tests/testfiles/v3/journal/simple.ics
@@ -0,0 +1,14 @@
+BEGIN:VCALENDAR
+PRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN
+VERSION:2.0
+BEGIN:VJOURNAL
+DTSTAMP:20090901T145756Z
+CREATED:20090901T145756Z
+UID:KOrganizer-1941104064.609
+LAST-MODIFIED:20090901T145756Z
+SUMMARY:Simple Journal Entry
+DTSTART;TZID=Europe/Berlin:20090901T165700
+END:VJOURNAL
+
+END:VCALENDAR
+
diff --git a/tests/testfiles/v3/journal/simple.ics.mime b/tests/testfiles/v3/journal/simple.ics.mime
new file mode 100644
index 0000000..cfffd9f
--- /dev/null
+++ b/tests/testfiles/v3/journal/simple.ics.mime
@@ -0,0 +1,75 @@
+Date: Fri, 27 Apr 2012 17:01:07 +0200
+X-Kolab-Type: application/x-vnd.kolab.journal
+X-Kolab-Version: v3
+User-Agent: Libkolab-0.2.0
+Content-Type: multipart/mixed; boundary="nextPart2827197.7XEdf2UEaf"
+Subject: KOrganizer-1941104064.609
+MIME-Version: 1.0
+
+
+--nextPart2827197.7XEdf2UEaf
+Content-Type: text/plain; charset="us-ascii"
+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
+
+--nextPart2827197.7XEdf2UEaf
+Content-Type: application/calendar+xml; name="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"no" ?>
+<icalendar xmlns=3D"urn:ietf:params:xml:ns:icalendar-2.0">
+
+ <vcalendar>
+ <properties>
+ <prodid>
+ <text>Libkolab-0.2.0 Libkolabxml-0.4.0</text>
+ </prodid>
+ <version>
+ <text>2.0</text>
+ </version>
+ <x-kolab-version>
+ <text>3.0dev1</text>
+ </x-kolab-version>
+ </properties>
+ <components>
+ <vjournal>
+ <properties>
+ <uid>
+ <text>KOrganizer-1941104064.609</text>
+ </uid>
+ <created>
+ <date-time>2009-09-01T14:57:56Z</date-time>
+ </created>
+ <dtstamp>
+ <date-time>2012-05-05T05:05:05Z</date-time>
+ </dtstamp>
+ <sequence>
+ <integer>0</integer>
+ </sequence>
+ <class>
+ <text>PUBLIC</text>
+ </class>
+ <dtstart>
+ <parameters>
+ <tzid>
+ <text>/kolab.org/Europe/Berlin</text>
+ </tzid>
+ </parameters>
+ <date-time>2009-09-01T16:57:00</date-time>
+ </dtstart>
+ <summary>
+ <text>Simple Journal Entry</text>
+ </summary>
+ </properties>
+ </vjournal>
+ </components>
+ </vcalendar>
+
+</icalendar>
+
+--nextPart2827197.7XEdf2UEaf--
diff --git a/tests/testfiles/v3/task/complex.ics b/tests/testfiles/v3/task/complex.ics
new file mode 100644
index 0000000..0188830
--- /dev/null
+++ b/tests/testfiles/v3/task/complex.ics
@@ -0,0 +1,51 @@
+BEGIN:VCALENDAR
+PRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN
+VERSION:2.0
+BEGIN:VTODO
+DTSTAMP:20090901T133915Z
+ATTENDEE;CN="Attendee1";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
+ ROLE=REQ-PARTICIPANT:mailto:a1 at example.com
+ATTENDEE;CN="Attendee2";RSVP=TRUE;PARTSTAT=TENTATIVE;ROLE=REQ-PARTICIPANT:mailto:
+ a2 at example.com
+ATTENDEE;CN="Attendee3";RSVP=FALSE;PARTSTAT=ACCEPTED;
+ ROLE=OPT-PARTICIPANT:mailto:a3 at example.com
+CREATED:20090901T133915Z
+UID:KOrganizer-396756838.184
+LAST-MODIFIED:20090901T133915Z
+DESCRIPTION:Some notes on this task.
+SUMMARY:Complex Task
+LOCATION:Here
+CLASS:PRIVATE
+PRIORITY:1
+CATEGORIES:Business\,Education
+ATTACH;VALUE=BINARY;FMTTYPE=image/png;ENCODING=BASE64;X-LABEL=akonadi.png:
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP
+ 8A/wD/oL2nkwAAAAlwSFlzAAAbrwAAG68BXhqRHAAAAAd0SU1FB9gFEQkdFPibCIYAAAMrSURB
+ VDjLpZNLaBx1AMZ/M/P/78zOzO7ObDbvNUnTxsUUm6YmaulNxN70UKEIRTyIBy8KHrypRUTw4E
+ k8CqKnXuyhHgQRFTRNAvVFbOnDNO/EfWZmdmczszPrwcdBvPnBd/ng98F3+OB/Svl3cPbSx5mZ
+ +ZkXjKx+setHs4cHbaW+7d2s79SvhK29j+6vvXH0nwVPfLh1WsTptdnxuDDxoGv3NZWuf4S3G1
+ C722BrrcrOnY1f/ebO05s337n3N6cBLLy1bI7njr4uD4nJhx4by5SGLQYcAzWnI6SGVFUkQKwM
+ RqH/jGHNfXJYXwoBBMDc/MhLThpOJ6ZEMzM4moquQpIVxI5Br5QlHrEImw5xuzRJ0n4beBlABR
+ gwxcXhUp5Ww6OXQvCXo/TPjUJq6FmJldPJOTZ2znj++HOfnwQQ0y9+e67X6iykpmTCNTnY9xBj
+ eTQVelFC0u3RjxNI+6iaQiajYtmGlXa6NxZe/f4pobv24/X9thBSYebUEHc26zT6kLMkaZTQ84
+ +IvYioE9PrRvTTCBSF2PczUTxyVuiOsXHju58Y0XTaQcTJM0OsXt9kaqqIrinEQUTYCPGrAR2v
+ RbcbELS7ZGWEj72hzL+5MqS0uzvBys/CzbsUxx0KJROvnTBZLtCPU/y6j1erE/g1wrBNdqREWK
+ wktdB4QP3h8qO/K6Z2RR8bJmjtUx7KMDtd4MSozuatXX5Zus3tH29Rre7S18GtjFNanAMpr37w
+ 2ti+ABAyeT0eLJ7vtWoDX1z9BiXV0DRJmqakSRfd1iiMOmSPjeKeqVC/H3oPT8r3ZNyzVID3L1
+ V2nDzPqsPlQ2PiGKoJCQFJ4qPIFH0gh3P6ONlHKlQ3ve6EEb57fl7GSh9DAVjaqmrNRsv97Kv1
+ xeurjcthkCyqURs7JzBdE6NokQgJSbQ+O65+euqEszo4UPytWMhvCwBUkSqq1jk356xNDUevLK
+ /sPbl+L7jQ8ZLyUaepGE1xMDZhfDlbKSwPFt1tXcp9qWk1VWjhP2e6dneLvhdqLc/L7B3UzfX1
+ qttsdfKKguo4ZlguO36xWAgLth3mbSsyTatnyFz6B+BnWV0A/UiAAAAAAElFTkSuQmCC
+DUE;TZID=Europe/Berlin:20090908T160000
+DTSTART;TZID=Europe/Berlin:20090901T160000
+PERCENT-COMPLETE:50
+RECURRENCE-ID;TZID=Europe/Berlin:20090908T160000
+BEGIN:VALARM
+DESCRIPTION:
+ACTION:DISPLAY
+TRIGGER;VALUE=DURATION;RELATED=END:-PT15M
+END:VALARM
+END:VTODO
+
+END:VCALENDAR
+
diff --git a/tests/testfiles/v3/task/complex.ics.mime b/tests/testfiles/v3/task/complex.ics.mime
new file mode 100644
index 0000000..751b2f0
--- /dev/null
+++ b/tests/testfiles/v3/task/complex.ics.mime
@@ -0,0 +1,216 @@
+Date: Fri, 27 Apr 2012 16:58:49 +0200
+X-Kolab-Type: application/x-vnd.kolab.task
+X-Kolab-Version: v3
+User-Agent: Libkolab-0.2.0
+Content-Type: multipart/mixed; boundary="nextPart1676922.i4WXLoZAWe"
+Subject: KOrganizer-396756838.184
+MIME-Version: 1.0
+
+
+--nextPart1676922.i4WXLoZAWe
+Content-Type: text/plain; charset="us-ascii"
+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
+
+--nextPart1676922.i4WXLoZAWe
+Content-Type: application/calendar+xml; name="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"no" ?>
+<icalendar xmlns=3D"urn:ietf:params:xml:ns:icalendar-2.0">
+
+ <vcalendar>
+ <properties>
+ <prodid>
+ <text>Libkolab-0.2.0 Libkolabxml-0.4.0</text>
+ </prodid>
+ <version>
+ <text>2.0</text>
+ </version>
+ <x-kolab-version>
+ <text>3.0dev1</text>
+ </x-kolab-version>
+ </properties>
+ <components>
+ <vtodo>
+ <properties>
+ <uid>
+ <text>KOrganizer-396756838.184</text>
+ </uid>
+ <created>
+ <date-time>2009-09-01T13:39:15Z</date-time>
+ </created>
+ <dtstamp>
+ <date-time>2012-05-05T05:05:05Z</date-time>
+ </dtstamp>
+ <sequence>
+ <integer>0</integer>
+ </sequence>
+ <class>
+ <text>PRIVATE</text>
+ </class>
+ <categories>
+ <text>Business</text>
+ <text>Education</text>
+ </categories>
+ <dtstart>
+ <parameters>
+ <tzid>
+ <text>/kolab.org/Europe/Berlin</text>
+ </tzid>
+ </parameters>
+ <date-time>2009-09-01T16:00:00</date-time>
+ </dtstart>
+ <due>
+ <parameters>
+ <tzid>
+ <text>/kolab.org/Europe/Berlin</text>
+ </tzid>
+ </parameters>
+ <date-time>2009-09-08T16:00:00</date-time>
+ </due>
+ <recurrence-id>
+ <parameters>
+ <tzid>
+ <text>/kolab.org/Europe/Berlin</text>
+ </tzid>
+ </parameters>
+ <date-time>2009-09-08T16:00:00</date-time>
+ </recurrence-id>
+ <summary>
+ <text>Complex Task</text>
+ </summary>
+ <description>
+ <text>Some notes on this task.</text>
+ </description>
+ <priority>
+ <integer>1</integer>
+ </priority>
+ <percent-complete>
+ <integer>50</integer>
+ </percent-complete>
+ <location>
+ <text>Here</text>
+ </location>
+ <attendee>
+ <parameters>
+ <cn>
+ <text>Attendee1</text>
+ </cn>
+ <partstat>
+ <text>NEEDS-ACTION</text>
+ </partstat>
+ <role>
+ <text>REQ-PARTICIPANT</text>
+ </role>
+ <rsvp>
+ <boolean>true</boolean>
+ </rsvp>
+ </parameters>
+ <cal-address>mailto:%3Ca1%40example%2Ecom%3E</cal-address>
+ </attendee>
+ <attendee>
+ <parameters>
+ <cn>
+ <text>Attendee2</text>
+ </cn>
+ <partstat>
+ <text>TENTATIVE</text>
+ </partstat>
+ <role>
+ <text>REQ-PARTICIPANT</text>
+ </role>
+ <rsvp>
+ <boolean>true</boolean>
+ </rsvp>
+ </parameters>
+ <cal-address>mailto:%3Ca2%40example%2Ecom%3E</cal-address>
+ </attendee>
+ <attendee>
+ <parameters>
+ <cn>
+ <text>Attendee3</text>
+ </cn>
+ <partstat>
+ <text>ACCEPTED</text>
+ </partstat>
+ <role>
+ <text>OPT-PARTICIPANT</text>
+ </role>
+ </parameters>
+ <cal-address>mailto:%3Ca3%40example%2Ecom%3E</cal-address>
+ </attendee>
+ <attach>
+ <parameters>
+ <fmttype>
+ <text>image/png</text>
+ </fmttype>
+ <x-label>
+ <text>akonadi.png</text>
+ </x-label>
+ </parameters>
+ <uri>cid:2838853.9Y25si6h6e at kolab.resource.akonadi</uri>
+ </attach>
+ </properties>
+ <components>
+ <valarm>
+ <properties>
+ <action>
+ <text>DISPLAY</text>
+ </action>
+ <description>
+ <text/>
+ </description>
+ <trigger>
+ <parameters>
+ <related>
+ <text>END</text>
+ </related>
+ </parameters>
+ <duration>-PT900S</duration>
+ </trigger>
+ <duration>
+ <duration>PT5S</duration>
+ </duration>
+ <repeat>
+ <integer>0</integer>
+ </repeat>
+ </properties>
+ </valarm>
+ </components>
+ </vtodo>
+ </components>
+ </vcalendar>
+
+</icalendar>
+
+--nextPart1676922.i4WXLoZAWe
+Content-ID: <2838853.9Y25si6h6e at kolab.resource.akonadi>
+Content-Type: image/png; name="akonadi.png"
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment; filename="akonadi.png"
+
+iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A
+/wD/oL2nkwAAAAlwSFlzAAAbrwAAG68BXhqRHAAAAAd0SU1FB9gFEQkdFPibCIYAAAMrSURBVDjL
+pZNLaBx1AMZ/M/P/78zOzO7ObDbvNUnTxsUUm6YmaulNxN70UKEIRTyIBy8KHrypRUTw4Ek8CqKn
+XuyhHgQRFTRNAvVFbOnDNO/EfWZmdmczszPrwcdBvPnBd/ng98F3+OB/Svl3cPbSx5mZ+ZkXjKx+
+setHs4cHbaW+7d2s79SvhK29j+6vvXH0nwVPfLh1WsTptdnxuDDxoGv3NZWuf4S3G1C722BrrcrO
+nY1f/ebO05s337n3N6cBLLy1bI7njr4uD4nJhx4by5SGLQYcAzWnI6SGVFUkQKwMRqH/jGHNfXJY
+XwoBBMDc/MhLThpOJ6ZEMzM4moquQpIVxI5Br5QlHrEImw5xuzRJ0n4beBlABRgwxcXhUp5Ww6OX
+QvCXo/TPjUJq6FmJldPJOTZ2znj++HOfnwQQ0y9+e67X6iykpmTCNTnY9xBjeTQVelFC0u3RjxNI
++6iaQiajYtmGlXa6NxZe/f4pobv24/X9thBSYebUEHc26zT6kLMkaZTQ84+IvYioE9PrRvTTCBSF
+2PczUTxyVuiOsXHju58Y0XTaQcTJM0OsXt9kaqqIrinEQUTYCPGrAR2vRbcbELS7ZGWEj72hzL+5
+MqS0uzvBys/CzbsUxx0KJROvnTBZLtCPU/y6j1erE/g1wrBNdqREWKwktdB4QP3h8qO/K6Z2RR8b
+JmjtUx7KMDtd4MSozuatXX5Zus3tH29Rre7S18GtjFNanAMpr37w2ti+ABAyeT0eLJ7vtWoDX1z9
+BiXV0DRJmqakSRfd1iiMOmSPjeKeqVC/H3oPT8r3ZNyzVID3L1V2nDzPqsPlQ2PiGKoJCQFJ4qPI
+FH0gh3P6ONlHKlQ3ve6EEb57fl7GSh9DAVjaqmrNRsv97Kv1xeurjcthkCyqURs7JzBdE6NokQgJ
+SbQ+O65+euqEszo4UPytWMhvCwBUkSqq1jk356xNDUevLK/sPbl+L7jQ8ZLyUaepGE1xMDZhfDlb
+KSwPFt1tXcp9qWk1VWjhP2e6dneLvhdqLc/L7B3UzfX1qttsdfKKguo4ZlguO36xWAgLth3mbSsy
+TatnyFz6B+BnWV0A/UiAAAAAAElFTkSuQmCC
+
+--nextPart1676922.i4WXLoZAWe--
diff --git a/tests/testfiles/v3/task/simple.ics b/tests/testfiles/v3/task/simple.ics
new file mode 100644
index 0000000..827f2a2
--- /dev/null
+++ b/tests/testfiles/v3/task/simple.ics
@@ -0,0 +1,15 @@
+BEGIN:VCALENDAR
+PRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN
+VERSION:2.0
+BEGIN:VTODO
+DTSTAMP:20090901T131703Z
+CREATED:20090901T131703Z
+UID:KOrganizer-2105012348.490
+LAST-MODIFIED:20090901T131703Z
+SUMMARY:Simple Task
+PERCENT-COMPLETE:0
+PRIORITY:7
+END:VTODO
+
+END:VCALENDAR
+
diff --git a/tests/testfiles/v3/task/simple.ics.mime b/tests/testfiles/v3/task/simple.ics.mime
new file mode 100644
index 0000000..aa0afc0
--- /dev/null
+++ b/tests/testfiles/v3/task/simple.ics.mime
@@ -0,0 +1,70 @@
+Date: Fri, 27 Apr 2012 16:56:44 +0200
+X-Kolab-Type: application/x-vnd.kolab.task
+X-Kolab-Version: v3
+User-Agent: Libkolab-0.2.0
+Content-Type: multipart/mixed; boundary="nextPart7341281.t3AojKazdB"
+Subject: KOrganizer-2105012348.490
+MIME-Version: 1.0
+
+
+--nextPart7341281.t3AojKazdB
+Content-Type: text/plain; charset="us-ascii"
+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
+
+--nextPart7341281.t3AojKazdB
+Content-Type: application/calendar+xml; name="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"no" ?>
+<icalendar xmlns=3D"urn:ietf:params:xml:ns:icalendar-2.0">
+
+ <vcalendar>
+ <properties>
+ <prodid>
+ <text>Libkolab-0.2.0 Libkolabxml-0.4.0</text>
+ </prodid>
+ <version>
+ <text>2.0</text>
+ </version>
+ <x-kolab-version>
+ <text>3.0dev1</text>
+ </x-kolab-version>
+ </properties>
+ <components>
+ <vtodo>
+ <properties>
+ <uid>
+ <text>KOrganizer-2105012348.490</text>
+ </uid>
+ <created>
+ <date-time>2009-09-01T13:17:03Z</date-time>
+ </created>
+ <dtstamp>
+ <date-time>2012-05-05T05:05:05Z</date-time>
+ </dtstamp>
+ <sequence>
+ <integer>0</integer>
+ </sequence>
+ <class>
+ <text>PUBLIC</text>
+ </class>
+ <summary>
+ <text>Simple Task</text>
+ </summary>
+ <priority>
+ <integer>7</integer>
+ </priority>
+ </properties>
+ </vtodo>
+ </components>
+ </vcalendar>
+
+</icalendar>
+
+--nextPart7341281.t3AojKazdB--
commit b946709a277db3615c62876f4c477340ff85fe65
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 16:37:49 2012 +0200
Fixed some more tests
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 2a8c018..0ad1cb0 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -155,14 +155,15 @@ void FormatTest::testIncidence_data()
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");
+ //The following test just fails because we have a nicer mime message output than horde
// 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( "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( "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");
}
@@ -248,7 +249,7 @@ void FormatTest::testContact_data()
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( "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");
diff --git a/tests/testfiles/v2/contacts/bug238996.vcf.mime b/tests/testfiles/v2/contacts/bug238996.vcf.mime
index c7da09d..2d4c619 100644
--- a/tests/testfiles/v2/contacts/bug238996.vcf.mime
+++ b/tests/testfiles/v2/contacts/bug238996.vcf.mime
@@ -1,9 +1,9 @@
Date: Mon, 31 Aug 2009 18:23:30 +0200
X-Kolab-Type: application/x-vnd.kolab.contact
-User-Agent: Akonadi Kolab Proxy Resource
+User-Agent: Libkolab-x.x.x
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
@@ -44,20 +44,21 @@ Content-Disposition: attachment; filename="kolab.xml"
<assistant>Assistant</assistant>
<nick-name>Nickname</nick-name>
<spouse-name>Partner</spouse-name>
+ <birthday>2009-07-27</birthday>
<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>business2</type>
+ <number>+4930-workphone</number>
+ </phone>
+ <phone>
<type>businessfax</type>
<number>+4930-fax</number>
</phone>
@@ -69,7 +70,6 @@ Content-Disposition: attachment; filename="kolab.xml"
<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>
diff --git a/tests/testfiles/v2/task/complex.ics.mime b/tests/testfiles/v2/task/complex.ics.mime
index 9e91738..87c1cd9 100644
--- a/tests/testfiles/v2/task/complex.ics.mime
+++ b/tests/testfiles/v2/task/complex.ics.mime
@@ -21,7 +21,7 @@ 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" >
+<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>
@@ -65,6 +65,7 @@ Content-Disposition: attachment; filename="kolab.xml"
</alarm>
</advanced-alarms>
<priority>1</priority>
+ <x-kcal-priority>1</x-kcal-priority>
<completed>50</completed>
<status>not-started</status>
<due-date>2009-09-08T14:00:00Z</due-date>
diff --git a/tests/testfiles/v2/task/prioritytest2.ics.mime b/tests/testfiles/v2/task/prioritytest2.ics.mime
index 754c2e9..ad15dbb 100644
--- a/tests/testfiles/v2/task/prioritytest2.ics.mime
+++ b/tests/testfiles/v2/task/prioritytest2.ics.mime
@@ -30,7 +30,7 @@ Content-Disposition: attachment; filename="kolab.xml"
<summary>Simple Task</summary>
<organizer/>
<priority>1</priority>
- <x-kcal-priority>9</x-kcal-priority>
+ <x-kcal-priority>1</x-kcal-priority>
<completed>0</completed>
<status>not-started</status>
</task>
diff --git a/tests/testfiles/v2/task/simple.ics.mime b/tests/testfiles/v2/task/simple.ics.mime
index ec1d02f..f1322ef 100644
--- a/tests/testfiles/v2/task/simple.ics.mime
+++ b/tests/testfiles/v2/task/simple.ics.mime
@@ -30,6 +30,7 @@ Content-Disposition: attachment; filename="kolab.xml"
<summary>Simple Task</summary>
<organizer/>
<priority>4</priority>
+ <x-kcal-priority>7</x-kcal-priority>
<completed>0</completed>
<status>not-started</status>
</task>
commit 0465f57f9f679f4702bd8cc287bb8806461cebef
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 02:53:43 2012 +0200
comments
diff --git a/tests/formattest.h b/tests/formattest.h
index 7c5520b..92b285f 100644
--- a/tests/formattest.h
+++ b/tests/formattest.h
@@ -31,8 +31,6 @@
* The mime files are of course just a snapshot of how it is thought that the result should be.
* The files may have bugs themselves and will need to be updated to reflect future changes.
*
- * TODO: v2 test fail currently due to the last-modified-date (and some others such as product id) (xml-file text comparsion fails)
- *
* kompare (the kde diff tool) is launched if a test fails to show you the difference between expected and actual conversion.
* Comment the code if you don't want it.
*
@@ -43,8 +41,10 @@
* * Content-ID Header
*
* These are safe to be ignored as they are randomly generated.
- *
- * FIXME: a referenced content using cid (inside the xml) should also be ignored, this leads currently to an error.
+ *
+ * To generate the reference files, you can write the vcf/ics by hand and generate the mime message from that one (using the generateMimefile() function).
+ * You may need to sort some things manually (addresses/phonenumbers), and generally check manually if everything is as it should be.
+ * The test will then remain to ensure the same for future versions.
*
*/
class FormatTest: public QObject
commit 9ee264188e036614b08356dc4facc10e22d98f58
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 02:48:40 2012 +0200
another test passes
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index fc2836d..2a8c018 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -257,7 +257,7 @@ void FormatTest::testContact_data()
// 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( "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)
commit d47819a4d637c1523a9b1fe75a003dd45a7765fa
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 02:48:13 2012 +0200
tests: correct order of phonenumbers
diff --git a/tests/testfiles/v3/contacts/complex.vcf.mime b/tests/testfiles/v3/contacts/complex.vcf.mime
index 07e982e..8814a4e 100644
--- a/tests/testfiles/v3/contacts/complex.vcf.mime
+++ b/tests/testfiles/v3/contacts/complex.vcf.mime
@@ -212,18 +212,18 @@ AhhBBCCPEe8D+b5dDLeP4TXAAAAABJRU5ErkJggg=3D=3D</uri>
<tel>
<parameters>
<type>
- <text>work</text>
+ <text>cell</text>
</type>
</parameters>
- <text>+4930-workphone</text>
+ <text>+4930-mobile</text>
</tel>
<tel>
<parameters>
<type>
- <text>cell</text>
+ <text>work</text>
</type>
</parameters>
- <text>+4930-mobile</text>
+ <text>+4930-workphone</text>
</tel>
<tel>
<parameters>
commit f9cd6aa8bcfbb3df96a6a8cff64ed83ce62b136b
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 02:40:02 2012 +0200
updated reference files
attachments are no longer referenced by name, but by cid.
sound is no longer existing
diff --git a/tests/testfiles/v3/contacts/complex.vcf b/tests/testfiles/v3/contacts/complex.vcf
index e61c6b7..f705101 100644
--- a/tests/testfiles/v3/contacts/complex.vcf
+++ b/tests/testfiles/v3/contacts/complex.vcf
@@ -80,9 +80,6 @@ X-KADDRESSBOOK-X-ManagersName:Manager
X-KADDRESSBOOK-X-Office:Office
X-KADDRESSBOOK-X-Profession:Profession
X-KADDRESSBOOK-X-SpousesName:Partner
-X-KOLAB-PictureAttachmentName:kolab-picture.png
-X-KOLAB-LogoAttachmentName:kolab-logo.png
-X-KOLAB-SoundAttachmentName:sound
END:VCARD
diff --git a/tests/testfiles/v3/contacts/complex.vcf.mime b/tests/testfiles/v3/contacts/complex.vcf.mime
index cb5f588..07e982e 100644
--- a/tests/testfiles/v3/contacts/complex.vcf.mime
+++ b/tests/testfiles/v3/contacts/complex.vcf.mime
@@ -1,23 +1,23 @@
-Date: Mon, 02 Apr 2012 18:06:19 +0200
+Date: Fri, 27 Apr 2012 02:25:38 +0200
X-Kolab-Type: application/x-vnd.kolab.contact
X-Kolab-Version: v3
-User-Agent: Akonadi Kolab Proxy Resource
-Content-Type: multipart/mixed; boundary="nextPart1548719.NT57q08oM1"
+User-Agent: Libkolab-0.2.0
+Content-Type: multipart/mixed; boundary="nextPart38186565.1WqI9LYOEs"
Subject: Huu5X7hfYy
From: Displayname <first at email.org>
MIME-Version: 1.0
---nextPart1548719.NT57q08oM1
+--nextPart38186565.1WqI9LYOEs
Content-Type: text/plain; charset="us-ascii"
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
---nextPart1548719.NT57q08oM1
+--nextPart38186565.1WqI9LYOEs
Content-Type: application/vcard+xml; name="kolab.xml"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="kolab.xml"
@@ -33,7 +33,7 @@ Content-Disposition: attachment; filename="kolab.xml"
<text>3.0dev1</text>
</x-kolab-version>
<prodid>
- <text>libkolabxml-0.2.0</text>
+ <text>Libkolab-0.2.0 Libkolabxml-0.4.0</text>
</prodid>
<rev>
<timestamp>20120505T050505Z</timestamp>
@@ -87,6 +87,22 @@ TezY2+hvK8/WEJ52Ki3d1tyApohZEgIGRJChoSQISFk0K6yPto4gGf/l5cP/N/RaB/n2QaD=
vyT28dIcPvQ2sNnjl9C9vecaCSFDQsiQEDIkhIx/AF4jzh2wCYImAAAAAElFTkSuQmCC</u=
ri>
</logo>
+ <related>
+ <parameters>
+ <type>
+ <text>x-manager</text>
+ </type>
+ </parameters>
+ <text>Manager</text>
+ </related>
+ <related>
+ <parameters>
+ <type>
+ <text>x-assistant</text>
+ </type>
+ </parameters>
+ <text>Assistant</text>
+ </related>
<adr>
<parameters>
<type>
@@ -108,6 +124,14 @@ ri>
<url>
<uri>www.homepage.org</uri>
</url>
+ <url>
+ <parameters>
+ <type>
+ <text>x-blog</text>
+ </type>
+ </parameters>
+ <uri>www.blog.test</uri>
+ </url>
<adr>
<parameters>
<type>
@@ -229,6 +253,12 @@ AhhBBCCPEe8D+b5dDLeP4TXAAAAABJRU5ErkJggg=3D=3D</uri>
<email>
<text>second at email.org</text>
</email>
+ <x-custom>
+ <identifier>X-Profession</identifier>
+ <value>Profession</value>
+ </x-custom>
</vcard>
</vcards>
+
+--nextPart38186565.1WqI9LYOEs--
commit 8b46c700a83c0bf2c40910f74804d2789933e753
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 02:13:01 2012 +0200
tests
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 06131f8..fc2836d 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -253,9 +253,10 @@ void FormatTest::testContact_data()
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");
+ //FIXME the following test fails because the vcard implementation always writes jpeg (which is lossy). The reference vcf file is therefore probably also not really useful
// 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( "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");
}
@@ -308,18 +309,6 @@ void FormatTest::testContact()
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
if (version == Kolab::KolabV2) { //No creation date in xcal
@@ -381,6 +370,40 @@ void FormatTest::generateMimefile()
// kDebug() << result;
}
+void FormatTest::generateVCard()
+{
+// bool ok = false;
+// const KMime::Message::Ptr &msg = readMimeFile( QString::fromLatin1("../")+TESTFILEDIR+QString::fromLatin1("v2/contacts/pictureJPGHorde.vcf.mime"), ok );
+// qDebug() << msg->encodedContent();
+// Kolab::KolabObjectReader reader;
+// Kolab::ObjectType t = reader.parseMimeMessage(msg);
+//
+// KABC::Addressee convertedAddressee = reader.getContact();
+// KABC::VCardConverter converter;
+// qDebug() << converter.createVCard(convertedAddressee);
+}
+
+//Pseudo test to show that JPG is always lossy, even with quality set to 100
+void FormatTest::proveJPGisLossy()
+{
+// QImage img(TESTFILEDIR+QString::fromLatin1("picture.jpg"));
+// QByteArray pic;
+// QBuffer buffer(&pic);
+// buffer.open(QIODevice::WriteOnly);
+// img.save(&buffer, "JPEG");
+// buffer.close();
+// qDebug() << pic.toBase64();
+//
+// QImage img2;
+// QByteArray pic2;
+// QBuffer buffer2(&pic2);
+// img2.loadFromData(pic);
+// img2.save(&buffer2, "JPEG");
+// buffer2.close();
+// qDebug() << pic2.toBase64();
+
+}
+
QTEST_MAIN( FormatTest )
#include "formattest.moc"
diff --git a/tests/formattest.h b/tests/formattest.h
index 1180532..7c5520b 100644
--- a/tests/formattest.h
+++ b/tests/formattest.h
@@ -57,8 +57,12 @@ private slots:
void testContact_data();
void testContact();
-
+
+
+ //Some pseudo tests and helper functions
void generateMimefile();
+ void generateVCard();
+ void proveJPGisLossy();
};
#endif // FORMATTEST_H
diff --git a/tests/testutils.h b/tests/testutils.h
index 71c0de4..ae3dd34 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -64,7 +64,6 @@ static KMime::Message::Ptr readMimeFile( const QString &fileName, bool &ok)
ok = file.open( QFile::ReadOnly );
const QByteArray data = file.readAll();
-
KMime::Message::Ptr msg = KMime::Message::Ptr(new KMime::Message);
msg->setContent( data );
msg->parse();
commit 0d29d35781e39ba4fcca11823587585835725847
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 02:12:50 2012 +0200
read also jpeg but always write png (because it's lossless)
diff --git a/kolabformat/v2helpers.h b/kolabformat/v2helpers.h
index ba92aea..15e6304 100644
--- a/kolabformat/v2helpers.h
+++ b/kolabformat/v2helpers.h
@@ -84,10 +84,30 @@ QImage getPicture(const QString &pictureAttachmentName, const KMime::Message::Pt
QBuffer buffer(&imgData);
buffer.open(QIODevice::ReadOnly);
QImage image;
+ bool success = false;
if (type == "image/jpeg") {
- image.load(&buffer, "JPEG");
+ success = image.load(&buffer, "JPEG");
+ //FIXME I tried getting the code to interpret the picture as PNG, but the VCard implementation writes it as JPEG anyways...
+// if (success) {
+// QByteArray pic;
+// QBuffer b(&pic);
+// b.open(QIODevice::ReadWrite);
+// Q_ASSERT(image.save(&b, "PNG"));
+// b.close();
+// Debug() << pic.toBase64();
+// QBuffer b2(&pic);
+// b2.open(QIODevice::ReadOnly);
+// success = image.load(&b2, "PNG");
+// b2.close();
+// Q_ASSERT(success);
+// }
} else {
- image.load(&buffer, "PNG");
+ type = "image/png";
+ success = image.load(&buffer, "PNG");
+ }
+ buffer.close();
+ if (!success) {
+ Warning() << "failed to load picture";
}
return image;
}
@@ -130,23 +150,24 @@ QByteArray createPicture(const QImage &img, const QString &format, QString &type
QBuffer buffer(&pic);
buffer.open(QIODevice::WriteOnly);
type = "image/png";
- if (format == "image/jpeg") {
- type = "image/jpeg";
- img.save(&buffer, "JPEG");
- } else {
+ //FIXME it's not possible to save jpegs lossless, so we always use png. otherwise we would compress the image on every write.
+// 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
+ KMime::Message::Ptr message = Mime::createMessage( contactKolabType(), false, productId );
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
+ KMime::Content* content = Mime::createMainPart( contactKolabType(), contact.saveXML().toUtf8() );
message->addContent( content );
if ( !contact.picture().isNull() ) {
commit 1c0233c19d67069c1de6d306a2585c62dc6b156d
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 01:57:37 2012 +0200
readability++
diff --git a/kolabformat/kolabobject.cpp b/kolabformat/kolabobject.cpp
index 22bd0b6..aa1b835 100644
--- a/kolabformat/kolabobject.cpp
+++ b/kolabformat/kolabobject.cpp
@@ -99,6 +99,24 @@ Kolab::ObjectType getObjectType(const QString &type)
return Kolab::InvalidObject;
}
+QByteArray getMimeType(Kolab::ObjectType type)
+{
+ switch (type) {
+ case EventObject:
+ case TodoObject:
+ case JournalObject:
+ return xCalMimeType().toLocal8Bit();
+ case ContactObject:
+ case DistlistObject:
+ return xCardMimeType().toLocal8Bit();
+ case NoteObject:
+ return noteMimeType().toLocal8Bit();
+ default:
+ Critical() << "unknown type "<< type;
+ }
+ return QByteArray();
+}
+
ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
{
ErrorHandler::clearErrors();
@@ -159,64 +177,38 @@ ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
Q_ASSERT(d->mIncidence->attachments().size() == attachments.size());
}
} else { //V3
-
+ KMime::Content *xmlContent = Mime::findContentByType( msg, getMimeType(d->mObjectType) );
+ if ( !xmlContent ) {
+ CRITICAL("no part found");
+ return InvalidObject;
+ }
switch (d->mObjectType) {
case EventObject: {
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
- }
const Kolab::Event & event = Kolab::readEvent(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
d->mIncidence = Kolab::Conversion::toKCalCore(event);
}
break;
case TodoObject: {
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
- }
const Kolab::Todo & event = Kolab::readTodo(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
d->mIncidence = Kolab::Conversion::toKCalCore(event);
}
break;
case JournalObject: {
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
- }
const Kolab::Journal & event = Kolab::readJournal(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
d->mIncidence = Kolab::Conversion::toKCalCore(event);
}
break;
case ContactObject: {
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCardMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
- }
const Kolab::Contact &contact = Kolab::readContact(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
d->mAddressee = Kolab::Conversion::toKABC(contact); //TODO extract attachments
}
break;
case DistlistObject: {
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCardMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
- }
const Kolab::DistList &distlist = Kolab::readDistlist(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
d->mContactGroup = Kolab::Conversion::toKABC(distlist);
}
break;
case NoteObject: {
- KMime::Content *xmlContent = Mime::findContentByType( msg, noteMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
- }
const Kolab::Note ¬e = Kolab::readNote(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
d->mNote = Kolab::Conversion::toNote(note);
}
diff --git a/mime/mimeutils.cpp b/mime/mimeutils.cpp
index 6dc0c76..355a3eb 100644
--- a/mime/mimeutils.cpp
+++ b/mime/mimeutils.cpp
@@ -30,6 +30,10 @@ namespace Kolab {
KMime::Content* findContentByType(const KMime::Message::Ptr &data, const QByteArray &type)
{
+ if (type.isEmpty()) {
+ Error() << "Empty type";
+ return 0;
+ }
const KMime::Content::List list = data->contents();
// qDebug() << list.size();
Q_FOREACH(KMime::Content *c, list)
commit d94a710a62a4845461f87e804e092e9331c0965c
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 27 01:47:32 2012 +0200
Handle alternative distlist kolabType, improve type interpretation
diff --git a/kolabformat/kolabdefinitions.h b/kolabformat/kolabdefinitions.h
index 62e1bea..410abb6 100644
--- a/kolabformat/kolabdefinitions.h
+++ b/kolabformat/kolabdefinitions.h
@@ -44,6 +44,7 @@ static QString todoKolabType() { return QString::fromLatin1("application/x-vnd.k
static QString journalKolabType() { return QString::fromLatin1("application/x-vnd.kolab.journal"); };
static QString contactKolabType() { return QString::fromLatin1("application/x-vnd.kolab.contact"); };
static QString distlistKolabType() { return QString::fromLatin1("application/x-vnd.kolab.contact.distlist"); }
+static QString distlistKolabTypeCompat() { return QString::fromLatin1("application/x-vnd.kolab.distribution-list"); }
static QString noteKolabType() { return QString::fromLatin1("application/x-vnd.kolab.note"); }
static QString xCalMimeType() { return QString::fromLatin1("application/calendar+xml"); };
diff --git a/kolabformat/kolabobject.cpp b/kolabformat/kolabobject.cpp
index 0937b2e..22bd0b6 100644
--- a/kolabformat/kolabobject.cpp
+++ b/kolabformat/kolabobject.cpp
@@ -81,6 +81,24 @@ KolabObjectReader::~KolabObjectReader()
delete d;
}
+Kolab::ObjectType getObjectType(const QString &type)
+{
+ if (type == eventKolabType()) {
+ return EventObject;
+ } else if (type == todoKolabType()) {
+ return TodoObject;
+ } else if (type == journalKolabType()) {
+ return JournalObject;
+ } else if (type == contactKolabType()) {
+ return ContactObject;
+ } else if (type == distlistKolabType() || type == distlistKolabTypeCompat()) {
+ return DistlistObject;
+ } else if (type == noteKolabType()) {
+ return NoteObject;
+ }
+ return Kolab::InvalidObject;
+}
+
ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
{
ErrorHandler::clearErrors();
@@ -100,7 +118,7 @@ ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
d->mVersion = KolabV3;
}
}
-
+ d->mObjectType = getObjectType(kolabType);
if (d->mVersion == KolabV2) {
KMime::Content *xmlContent = Mime::findContentByType( msg, kolabType.toLocal8Bit() );
if ( !xmlContent ) {
@@ -110,108 +128,105 @@ ObjectType KolabObjectReader::parseMimeMessage(const KMime::Message::Ptr &msg)
const QByteArray &xmlData = xmlContent->decodedContent();
Q_ASSERT(!xmlData.isEmpty());
QStringList attachments;
-// kDebug() << kolabType;
- if (kolabType == eventKolabType()) { //Event
-// kDebug() << "v2event";
- d->mIncidence = fromXML<KCalCore::Event::Ptr, KolabV2::Event>(xmlData, attachments);
- d->mObjectType = EventObject;
- } else if (kolabType == todoKolabType()) { //Todo
-// kDebug() << "v2todo";
- d->mIncidence = fromXML<KCalCore::Todo::Ptr, KolabV2::Task>(xmlData, attachments);
- d->mObjectType = TodoObject;
- } else if (kolabType == journalKolabType()) { //Journal
-// kDebug() << "v2journal";
- d->mIncidence = fromXML<KCalCore::Journal::Ptr, KolabV2::Journal>(xmlData, attachments);
- d->mObjectType = JournalObject;
- } else if (kolabType == contactKolabType()) { //Contact
-// kDebug() << "v2contact";
- d->mAddressee = addresseeFromKolab(xmlData, msg);
- d->mObjectType = ContactObject;
- } else if (kolabType == distlistKolabType()) { //Distlist
-// kDebug() << "v2distlist";
- d->mContactGroup = contactGroupFromKolab(xmlData);
- d->mObjectType = DistlistObject;
- } else if (kolabType == noteKolabType()) { //Note
-// kDebug() << "v2notes";
- d->mNote = noteFromKolab(xmlData, msg);
- d->mObjectType = NoteObject;
- } else {
- CRITICAL("no kolab object found "+kolabType);
+
+ switch (d->mObjectType) {
+ case EventObject:
+ d->mIncidence = fromXML<KCalCore::Event::Ptr, KolabV2::Event>(xmlData, attachments);
+ break;
+ case TodoObject:
+ d->mIncidence = fromXML<KCalCore::Todo::Ptr, KolabV2::Task>(xmlData, attachments);
+ break;
+ case JournalObject:
+ d->mIncidence = fromXML<KCalCore::Journal::Ptr, KolabV2::Journal>(xmlData, attachments);
+ break;
+ case ContactObject:
+ d->mAddressee = addresseeFromKolab(xmlData, msg);
+ break;
+ case DistlistObject:
+ d->mContactGroup = contactGroupFromKolab(xmlData);
+ break;
+ case NoteObject:
+ d->mNote = noteFromKolab(xmlData, msg);
+ break;
+ default:
+ CRITICAL("no kolab object found "+kolabType);
+ break;
}
- if (d->mIncidence) {
+ if (!d->mIncidence.isNull()) {
// kDebug() << "v2 attachments " << attachments.size() << d->mIncidence->attachments().size();
d->mIncidence->clearAttachments();
Mime::getAttachments(d->mIncidence, attachments, msg);
Q_ASSERT(d->mIncidence->attachments().size() == attachments.size());
}
} else { //V3
-
- if (kolabType == eventKolabType()) { //Event
-// kDebug() << "event";
-// kDebug() << msg->encodedContent();
-
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
+
+ switch (d->mObjectType) {
+ case EventObject: {
+ KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
+ if ( !xmlContent ) {
+ CRITICAL("no part found");
+ return InvalidObject;
+ }
+ const Kolab::Event & event = Kolab::readEvent(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
+ d->mIncidence = Kolab::Conversion::toKCalCore(event);
}
- const Kolab::Event & event = Kolab::readEvent(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
- d->mIncidence = Kolab::Conversion::toKCalCore(event);
- d->mObjectType = EventObject;
- } else if (kolabType == todoKolabType()) { //Todo
-// kDebug() << "todo";
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
+ break;
+ case TodoObject: {
+ KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
+ if ( !xmlContent ) {
+ CRITICAL("no part found");
+ return InvalidObject;
+ }
+ const Kolab::Todo & event = Kolab::readTodo(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
+ d->mIncidence = Kolab::Conversion::toKCalCore(event);
}
- const Kolab::Todo & event = Kolab::readTodo(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
- d->mIncidence = Kolab::Conversion::toKCalCore(event);
- d->mObjectType = TodoObject;
- } else if (kolabType == journalKolabType()) { //Journal
-// kDebug() << "journal";
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
+ break;
+ case JournalObject: {
+ KMime::Content *xmlContent = Mime::findContentByType( msg, xCalMimeType().toLocal8Bit() );
+ if ( !xmlContent ) {
+ CRITICAL("no part found");
+ return InvalidObject;
+ }
+ const Kolab::Journal & event = Kolab::readJournal(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
+ d->mIncidence = Kolab::Conversion::toKCalCore(event);
}
- const Kolab::Journal & event = Kolab::readJournal(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
- d->mIncidence = Kolab::Conversion::toKCalCore(event);
- d->mObjectType = JournalObject;
- } else if (kolabType == contactKolabType()) { //Contact
-// kDebug() << "contact";
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCardMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
+ break;
+ case ContactObject: {
+ KMime::Content *xmlContent = Mime::findContentByType( msg, xCardMimeType().toLocal8Bit() );
+ if ( !xmlContent ) {
+ CRITICAL("no part found");
+ return InvalidObject;
+ }
+ const Kolab::Contact &contact = Kolab::readContact(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
+ d->mAddressee = Kolab::Conversion::toKABC(contact); //TODO extract attachments
}
- const Kolab::Contact &contact = Kolab::readContact(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
- d->mAddressee = Kolab::Conversion::toKABC(contact); //TODO extract attachments
- d->mObjectType = ContactObject;
- } else if (kolabType == distlistKolabType()) { //Distlist
-// kDebug() << "distlist";
- KMime::Content *xmlContent = Mime::findContentByType( msg, xCardMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
+ break;
+ case DistlistObject: {
+ KMime::Content *xmlContent = Mime::findContentByType( msg, xCardMimeType().toLocal8Bit() );
+ if ( !xmlContent ) {
+ CRITICAL("no part found");
+ return InvalidObject;
+ }
+ const Kolab::DistList &distlist = Kolab::readDistlist(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
+ d->mContactGroup = Kolab::Conversion::toKABC(distlist);
}
- const Kolab::DistList &distlist = Kolab::readDistlist(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
- d->mContactGroup = Kolab::Conversion::toKABC(distlist);
- d->mObjectType = DistlistObject;
- } else if (kolabType == noteKolabType()) { //Note
-// kDebug() << "notes";
- KMime::Content *xmlContent = Mime::findContentByType( msg, noteMimeType().toLocal8Bit() );
- if ( !xmlContent ) {
- CRITICAL("no part found");
- return InvalidObject;
+ break;
+ case NoteObject: {
+ KMime::Content *xmlContent = Mime::findContentByType( msg, noteMimeType().toLocal8Bit() );
+ if ( !xmlContent ) {
+ CRITICAL("no part found");
+ return InvalidObject;
+ }
+ const Kolab::Note ¬e = Kolab::readNote(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
+ d->mNote = Kolab::Conversion::toNote(note);
}
- const Kolab::Note ¬e = Kolab::readNote(std::string(xmlContent->decodedContent().data(), xmlContent->decodedContent().size()), false);
- d->mNote = Kolab::Conversion::toNote(note);
- d->mObjectType = NoteObject;
- } else {
- CRITICAL("no kolab object found " + kolabType);
+ break;
+ default:
+ CRITICAL("no kolab object found "+kolabType);
+ break;
}
- if (d->mIncidence) {
+
+ if (!d->mIncidence.isNull()) {
// kDebug() << "getting attachments";
Mime::getAttachmentsById(d->mIncidence, msg);
}
More information about the commits
mailing list