src/kolabformat.cpp src/objectvalidation.cpp src/xcalconversions.h tests/validationtest.cpp

Christian Mollekopf mollekopf at kolabsys.com
Fri May 16 18:23:24 CEST 2014


 src/kolabformat.cpp      |    9 +++++++++
 src/objectvalidation.cpp |    6 +++---
 src/xcalconversions.h    |    6 ------
 tests/validationtest.cpp |    4 ++--
 4 files changed, 14 insertions(+), 11 deletions(-)

New commits:
commit 89ed52ffb04b17501b9f6840763c99cf757922a3
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Fri May 16 18:23:13 2014 +0200

    Allow different timezones and validate objects after reading.
    
    The wrong interpretation came from the rfc saying that dtstart and dtend
    must be of the same "type". I'm only sure that we cannot mix full day and
    date-time, but different timezones should be ok.

diff --git a/src/kolabformat.cpp b/src/kolabformat.cpp
index 4ab8ed1..ac2f6c0 100644
--- a/src/kolabformat.cpp
+++ b/src/kolabformat.cpp
@@ -79,6 +79,7 @@ Kolab::Event readEvent(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::Event();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -102,6 +103,7 @@ Kolab::Todo readTodo(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::Todo();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -125,6 +127,7 @@ Journal readJournal(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::Journal();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -148,6 +151,7 @@ Kolab::Freebusy readFreebusy(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::Freebusy();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -170,6 +174,7 @@ Kolab::Contact readContact(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::Contact();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -193,6 +198,7 @@ DistList readDistlist(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::DistList();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -216,6 +222,7 @@ Note readNote(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::Note();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -239,6 +246,7 @@ File readFile(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::File();
     }
+    validate(*ptr);
     return *ptr;
 }
 
@@ -262,6 +270,7 @@ Configuration readConfiguration(const std::string& s, bool isUrl)
     if (!ptr.get()) {
         return Kolab::Configuration();
     }
+    validate(*ptr);
     return *ptr;
 }
 
diff --git a/src/objectvalidation.cpp b/src/objectvalidation.cpp
index cd3a104..2ed2933 100644
--- a/src/objectvalidation.cpp
+++ b/src/objectvalidation.cpp
@@ -91,8 +91,8 @@ void validate(const Event &event)
     ASSERTEXISTING(event.start());
     ASSERTVALID(event.start());
     ASSERTVALID(event.end());
-    if (event.end().isValid()) {
-        ASSERTEQUAL(event.start().timezone(), event.end().timezone());
+    if (event.start().isValid() && event.end().isValid()) {
+        ASSERTEQUAL(event.start().isDateOnly(), event.end().isDateOnly());
     }
 }
 
@@ -101,7 +101,7 @@ void validate(const Todo& todo)
     ASSERTVALID(todo.start());
     ASSERTVALID(todo.due());
     if (todo.start().isValid() && todo.due().isValid()) {
-        ASSERTEQUAL(todo.start().timezone(), todo.due().timezone());
+        ASSERTEQUAL(todo.start().isDateOnly(), todo.due().isDateOnly());
     }
 }
 
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index 3fd982d..85d98ed 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -563,7 +563,6 @@ std::auto_ptr<I> fromDateTimeList(const std::vector<cDateTime> &dtlist)
             ptr->date_time().push_back(Shared::fromDateTime(dt));
         }
         //TODO handle utc
-        //TODO check for equality of timezones?
     }
     
     if (!dtlist.empty() && !dtlist.at(0).timezone().empty()) {
@@ -1491,11 +1490,6 @@ template < > struct IncidenceTrait <Kolab::Event>
 
         if (prop.dtend()) {
             event.setEnd(*toDate(*prop.dtend()));
-            if (event.end().isUTC() != event.end().isUTC() && 
-                event.end().timezone() != event.end().timezone() &&
-                event.end().isDateOnly() != event.end().isDateOnly()) {
-                ERROR("dtEnd has wrong timespec");
-            }
         } else if (prop.duration()) {
             event.setDuration(toDuration((*prop.duration()).duration()));
         }
diff --git a/tests/validationtest.cpp b/tests/validationtest.cpp
index a1a1c04..0273646 100644
--- a/tests/validationtest.cpp
+++ b/tests/validationtest.cpp
@@ -76,13 +76,13 @@ void ValidationTest::testDifferentTimezones()
     event.setStart(cDateTime("Europe/Zurich",2013,1,1,1,1,1));
     event.setEnd(cDateTime("Europe/London",2013,1,1,1,1,1));
     writeEvent(event);
-    QCOMPARE(Kolab::error(), Kolab::Error);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
 
     Todo todo;
     todo.setStart(cDateTime("Europe/Zurich",2013,1,1,1,1,1));
     todo.setDue(cDateTime("Europe/London",2013,1,1,1,1,1));
     writeTodo(todo);
-    QCOMPARE(Kolab::error(), Kolab::Error);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
 }
 
 void ValidationTest::testUTCwithTimezone()




More information about the commits mailing list