Branch 'kolab/integration/4.13.0' - 2 commits - kcalcore/icalformat_p.cpp kcalcore/tests

Sandro Knauß knauss at kolabsys.com
Wed Mar 11 18:16:04 CET 2015


 kcalcore/icalformat_p.cpp               |   21 +++++++++++++++++++++
 kcalcore/tests/testreadrecurrenceid.cpp |   11 ++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit bf1bf6b71f7bbc363f289dd63a195fc604dacd6f
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Mar 11 18:10:07 2015 +0100

    workaround for libical #185 (recurrenceid with multiple parameters)
    
    if a recurrenceid has range and tzid parameter than libical read it
    like this:
    
    tzid="Europe/Berlin;RANGE=THISANDFUTURE"
    range=None
    
    KOLAB: 4835

diff --git a/kcalcore/icalformat_p.cpp b/kcalcore/icalformat_p.cpp
index 03ea0ad..e698cee 100644
--- a/kcalcore/icalformat_p.cpp
+++ b/kcalcore/icalformat_p.cpp
@@ -1855,6 +1855,19 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,
                     icalproperty_get_first_parameter(p, ICAL_RANGE_PARAMETER);
                 if (param && icalparameter_get_range(param) == ICAL_RANGE_THISANDFUTURE) {
                     incidence->setThisAndFuture(true);
+                } else {
+                    // A workaround for a bug in libical (https://github.com/libical/libical/issues/185)
+                    // read recurrenceID with timezone and range parameter get both as read as tzid
+                    const icalparameter *param =
+                        icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER);
+                    QString tzid = QString::fromAscii(icalparameter_get_tzid(param));
+                    QStringList parts = tzid.toLower().split(QLatin1Char(';'));
+                    foreach (const QString &part, parts) {
+                        if (part == QLatin1String("range=thisandfuture")) {
+                            incidence->setThisAndFuture(true);
+                            break;
+                        }
+                    }
                 }
             }
             break;
@@ -2500,6 +2513,14 @@ KDateTime ICalFormatImpl::readICalDateTime(icalproperty *p,
         icalparameter *param =
             p ? icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER) : 0;
         const char *tzid = param ? icalparameter_get_tzid(param) : 0;
+
+        // A workaround for a bug in libical (https://github.com/libical/libical/issues/185)
+        // read recurrenceID with timezone and range parameter get both as read as tzid
+        QStringList parts = QString::fromAscii(tzid).split(QLatin1Char(';'));
+        if (parts.count() > 1) {
+            tzid = parts.first().toAscii();
+        }
+
         if (!tzid) {
             timeSpec = KDateTime::ClockTime;
         } else {


commit 88a49c86ec3c4983ec01236475c8272d512e8123
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Mar 11 18:08:59 2015 +0100

    Added test for recurrenceid with range and tzid parameter
    
    make sure that also a recurrenceid with range and tzid parameter is
    written and read correctly.

diff --git a/kcalcore/tests/testreadrecurrenceid.cpp b/kcalcore/tests/testreadrecurrenceid.cpp
index 56e537a..af81368 100644
--- a/kcalcore/tests/testreadrecurrenceid.cpp
+++ b/kcalcore/tests/testreadrecurrenceid.cpp
@@ -21,6 +21,7 @@
 
 #include "memorycalendar.h"
 #include "icalformat.h"
+#include "icaltimezones.h"
 #include "exceptions.h"
 
 #include <qtest_kde.h>
@@ -57,11 +58,14 @@ void TestReadRecurrenceId::testReadSingleExceptionWithThisAndFuture()
 
 void TestReadRecurrenceId::testReadWriteSingleExceptionWithThisAndFuture()
 {
-    KCalCore::MemoryCalendar::Ptr cal(new KCalCore::MemoryCalendar("UTC"));
+    KCalCore::MemoryCalendar::Ptr cal(new KCalCore::MemoryCalendar(KDateTime::UTC));
     KCalCore::ICalFormat format;
     KCalCore::Incidence::Ptr inc(new KCalCore::Event);
-    inc->setDtStart(KDateTime::currentUtcDateTime());
-    inc->setRecurrenceId(KDateTime::currentUtcDateTime());
+    KCalCore::ICalTimeZoneSource tzsource;
+    KDateTime::Spec spec(tzsource.standardZone(QLatin1String("Europe/Berlin")));
+    KDateTime startDate = KDateTime(QDate(2015,1,2), QTime(3,4,5), spec);
+    inc->setDtStart(startDate);
+    inc->setRecurrenceId(startDate);
     inc->setThisAndFuture(true);
     cal->addIncidence(inc);
     const QString result = format.toString(cal, QString());
@@ -71,6 +75,7 @@ void TestReadRecurrenceId::testReadWriteSingleExceptionWithThisAndFuture()
     QVERIFY(i);
     QVERIFY(i->hasRecurrenceId());
     QVERIFY(i->thisAndFuture());
+    QCOMPARE(i->recurrenceId(), startDate);
 }
 
 void TestReadRecurrenceId::testReadExceptionWithMainEvent()




More information about the commits mailing list