calendaring/event.h icalendar/icalendar.cpp icalendar/icalendar.h tests/icalendartest.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Fri Jun 1 11:22:24 CEST 2012
calendaring/event.h | 11 +++++++++++
icalendar/icalendar.cpp | 18 +++++++++++-------
icalendar/icalendar.h | 1 +
tests/icalendartest.cpp | 11 ++++++-----
4 files changed, 29 insertions(+), 12 deletions(-)
New commits:
commit 2713e56e5d45f449e171ef9a9fd9236ca2d4cc0a
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Jun 1 11:02:45 2012 +0200
timezone test (currently scheduled events are always utc)
diff --git a/calendaring/event.h b/calendaring/event.h
index 5775b84..76efd7f 100644
--- a/calendaring/event.h
+++ b/calendaring/event.h
@@ -38,9 +38,17 @@ public:
~Event();
bool read(const std::string &);
+ /**
+ * Convert to kolab xml format.
+ */
std::string write() const;
+
bool fromMime(const std::string &);
+
+ /**
+ * Convert to kolab mime format.
+ */
std::string toMime() const;
enum ITipMethod {
@@ -61,6 +69,9 @@ public:
bool fromIMip(const std::string &);
std::string toIMip(ITipMethod method) const;
+ /**
+ * Returns the scheduling method from the last fromIMip call
+ */
ITipMethod getSchedulingMethod() const;
diff --git a/icalendar/icalendar.cpp b/icalendar/icalendar.cpp
index aca1c58..a8fdbeb 100644
--- a/icalendar/icalendar.cpp
+++ b/icalendar/icalendar.cpp
@@ -29,6 +29,7 @@
#include <kmime/kmime_message.h>
#include <klocalizedstring.h>
#include <kdebug.h>
+#include <iostream>
namespace Kolab {
@@ -59,6 +60,12 @@ std::vector< Event > fromICalEvents(const std::string &input)
return events;
}
+ITipHandler::ITipHandler()
+: mMethod(iTIPNoMethod)
+{
+}
+
+
ITipHandler::ITipMethod mapFromKCalCore(KCalCore::iTIPMethod method)
{
Q_ASSERT(KCalCore::iTIPPublish == ITipHandler::iTIPPublish);
@@ -96,15 +103,14 @@ std::string ITipHandler::toITip(const Event &event, ITipHandler::ITipMethod meth
}
-
-
std::vector< Event > ITipHandler::fromITip(const std::string &string)
{
- KCalCore::Calendar::Ptr calendar(new KCalCore::MemoryCalendar(Kolab::Conversion::getTimeSpec(true, std::string())));
+ KCalCore::Calendar::Ptr calendar(new KCalCore::MemoryCalendar(KDateTime::Spec(KDateTime::UTC)));
KCalCore::ICalFormat format;
KCalCore::ScheduleMessage::Ptr msg= format.parseScheduleMessage(calendar, QString::fromStdString(string));
+ KCalCore::Event::Ptr event = msg->event().dynamicCast<KCalCore::Event>();
std::vector< Event > events;
- events.push_back(Conversion::fromKCalCore(*(msg->event().dynamicCast<KCalCore::Event>())));
+ events.push_back(Conversion::fromKCalCore(*event));
mMethod = mapFromKCalCore(msg->method());
return events;
}
@@ -114,13 +120,11 @@ ITipHandler::ITipMethod ITipHandler::method() const
return mMethod;
}
-
std::string ITipHandler::toIMip(const Event &event , ITipHandler::ITipMethod m, std::string from, bool bccMe) const
{
KCalCore::Event::Ptr e = Conversion::toKCalCore(event);
-
+// e->recurrence()->addRDateTime(e->dtStart()); //FIXME The createScheduleMessage converts everything to utc without a recurrence.
KCalCore::ICalFormat format;
-
KCalCore::iTIPMethod method = mapToKCalCore(m);
const QString &messageText = format.createScheduleMessage( e, method );
//This code is mostly from MailScheduler::performTransaction
diff --git a/icalendar/icalendar.h b/icalendar/icalendar.h
index 11db800..10f1267 100644
--- a/icalendar/icalendar.h
+++ b/icalendar/icalendar.h
@@ -44,6 +44,7 @@ namespace Kolab {
class KOLAB_EXPORT ITipHandler {
public:
+ ITipHandler();
enum ITipMethod {
iTIPPublish, /**< Event, to-do, journal or freebusy posting */
iTIPRequest, /**< Event, to-do or freebusy scheduling request */
diff --git a/tests/icalendartest.cpp b/tests/icalendartest.cpp
index d3273a7..40830db 100644
--- a/tests/icalendartest.cpp
+++ b/tests/icalendartest.cpp
@@ -67,7 +67,7 @@ void ICalendarTest::testToIMip()
{
Kolab::ITipHandler handler;
Kolab::Event ev1;
- ev1.setStart(Kolab::cDateTime(2011,10,10,12,1,1,true));
+ ev1.setStart(Kolab::cDateTime("Europe/Zurich",2011,10,10,12,1,1));
ev1.setEnd(Kolab::cDateTime("Europe/Zurich",2012,5,5,3,4,4));
ev1.setLastModified(Kolab::cDateTime(2011,10,11,12,1,2,true));
ev1.setCreated(Kolab::cDateTime(2011,10,11,12,1,3,true));
@@ -78,18 +78,19 @@ void ICalendarTest::testToIMip()
ev1.setAttendees(attendees);
ev1.setOrganizer(Kolab::ContactReference("organizer at test.org", "organizer", "uid3"));
-
+ ev1.setSummary("summary");
+
const std::string mimeResult = handler.toIMip(ev1, Kolab::ITipHandler::iTIPRequest, "test at test.com");
qDebug() << QString::fromStdString(mimeResult);
qDebug() << QString::fromStdString(handler.toIMip(ev1, Kolab::ITipHandler::iTIPReply, "test at test.com"));
const std::vector<Kolab::Event> &eventResult = handler.fromIMip(mimeResult);
- qDebug() << QString::fromStdString(Kolab::toICal(eventResult));
+// qDebug() << QString::fromStdString(Kolab::toICal(eventResult));
QCOMPARE((int)eventResult.size(), 1);
- QCOMPARE(ev1.start(), eventResult.front().start());
- QCOMPARE(ev1.end(), eventResult.front().end());
+ QCOMPARE(eventResult.front().start(), ev1.start());
+ QCOMPARE(eventResult.front().end(), ev1.end());
}
More information about the commits
mailing list