summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2014-05-16 16:23:13 (GMT)
committerChristian Mollekopf <chrigi_1@fastmail.fm>2014-05-16 16:23:13 (GMT)
commit89ed52ffb04b17501b9f6840763c99cf757922a3 (patch)
tree2943c8f574a3dfd33e7a18d640550be7302bf09f
parent07fce53d00a2bb32de2096b6b80ba20b76dec2cb (diff)
downloadlibkolabxml-89ed52ffb04b17501b9f6840763c99cf757922a3.tar.gz
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.
-rw-r--r--src/kolabformat.cpp9
-rw-r--r--src/objectvalidation.cpp6
-rw-r--r--src/xcalconversions.h6
-rw-r--r--tests/validationtest.cpp4
4 files changed, 14 insertions, 11 deletions
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()