summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-06-24 20:41:22 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-06-24 20:41:22 (GMT)
commitfa555615bd732cdc7fef56bf617e57d1bcf174fd (patch)
tree2bd171fff8cb72b31c4f2008730caa0c8164604e
parent01fb120923cbedca87b5d8a38716b3dc4dd57e50 (diff)
parenteb457503f0fbabdf40538db19b8597409602d790 (diff)
downloadlibkolabxml-fa555615bd732cdc7fef56bf617e57d1bcf174fd.tar.gz
Merge branch 'master' of ssh://git.kolabsys.com/git/libkolabxml
-rw-r--r--schemas/kolabformat.xsd6
-rw-r--r--src/containers/kolabconfiguration.cpp12
-rw-r--r--src/containers/kolabconfiguration.h14
-rw-r--r--src/containers/kolabcontainers.cpp6
-rw-r--r--src/csharp/CMakeLists.txt12
-rw-r--r--src/java/CMakeLists.txt15
-rw-r--r--src/kolabconversions.h56
-rw-r--r--src/kolabformat.cpp82
-rw-r--r--src/kolabformat.i6
-rw-r--r--src/objectvalidation.cpp6
-rw-r--r--src/utils.cpp11
-rw-r--r--src/utils.h14
-rw-r--r--src/xcalconversions.h20
-rw-r--r--tests/bindingstest.cpp20
-rw-r--r--tests/bindingstest.h2
-rw-r--r--tests/validationtest.cpp4
16 files changed, 188 insertions, 98 deletions
diff --git a/schemas/kolabformat.xsd b/schemas/kolabformat.xsd
index 58af080..508e9c3 100644
--- a/schemas/kolabformat.xsd
+++ b/schemas/kolabformat.xsd
@@ -102,7 +102,7 @@
<xs:enumeration value="dictionary"/>
<xs:enumeration value="categorycolor"/>
<xs:enumeration value="snippets"/>
- <xs:enumeration value="tag"/>
+ <xs:enumeration value="relation"/>
</xs:restriction>
</xs:simpleType>
@@ -157,9 +157,9 @@
<!-- Snippets -->
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="snippet" type="Snippet" minOccurs="0" maxOccurs="unbounded"/>
- <!-- Tag -->
+ <!-- Relation -->
<!-- xs:element name="name" type="xs:string" minOccurs="0"/ -->
- <xs:element name="tagType" type="xs:string" minOccurs="0"/>
+ <xs:element name="relationType" type="xs:string" minOccurs="0"/>
<xs:element name="color" type="xs:string" minOccurs="0"/>
<xs:element name="iconName" type="xs:string" minOccurs="0"/>
<xs:element name="priority" type="xs:integer" minOccurs="0"/>
diff --git a/src/containers/kolabconfiguration.cpp b/src/containers/kolabconfiguration.cpp
index 0e777b9..e6a26ee 100644
--- a/src/containers/kolabconfiguration.cpp
+++ b/src/containers/kolabconfiguration.cpp
@@ -25,7 +25,7 @@ struct Configuration::Private {
std::vector<CategoryColor> categoryColor;
Dictionary dictionary;
SnippetsCollection snippets;
- Tag tag;
+ Relation relation;
ConfigurationType type;
std::string uid;
cDateTime created;
@@ -58,11 +58,11 @@ Configuration::Configuration(const SnippetsCollection &snippets)
d->type = TypeSnippet;
}
-Configuration::Configuration(const Tag &tag)
+Configuration::Configuration(const Relation &relation)
: d(new Configuration::Private)
{
- d->tag = tag;
- d->type = TypeTag;
+ d->relation = relation;
+ d->type = TypeRelation;
}
Configuration::Configuration(const Configuration &other)
@@ -137,9 +137,9 @@ SnippetsCollection Configuration::snippets() const
return d->snippets;
}
-Tag Configuration::tag() const
+Relation Configuration::relation() const
{
- return d->tag;
+ return d->relation;
}
} //Namespace
diff --git a/src/containers/kolabconfiguration.h b/src/containers/kolabconfiguration.h
index 4d38367..2d8f9e8 100644
--- a/src/containers/kolabconfiguration.h
+++ b/src/containers/kolabconfiguration.h
@@ -109,11 +109,11 @@ private:
std::vector<Snippet> mSnippets;
};
-struct Tag {
- Tag(){}
- Tag(const std::string &name, const std::string &type): mName(name), mType(type) {}
+struct Relation {
+ Relation(){}
+ Relation(const std::string &name, const std::string &type): mName(name), mType(type) {}
- bool operator==(const Tag &other) const {
+ bool operator==(const Relation &other) const {
return mName == other.mName &&
mType == other.mType &&
mColor == other.mColor &&
@@ -156,7 +156,7 @@ public:
Configuration(const std::vector<CategoryColor> &);
Configuration(const Dictionary &);
Configuration(const SnippetsCollection &);
- Configuration(const Tag &);
+ Configuration(const Relation &);
Configuration(const Configuration &);
~Configuration();
void operator=(const Configuration &);
@@ -177,13 +177,13 @@ public:
TypeDictionary,
TypeCategoryColor,
TypeSnippet,
- TypeTag
+ TypeRelation
};
ConfigurationType type() const;
std::vector<CategoryColor> categoryColor() const;
Dictionary dictionary() const;
SnippetsCollection snippets() const;
- Tag tag() const;
+ Relation relation() const;
private:
struct Private;
boost::scoped_ptr<Private> d;
diff --git a/src/containers/kolabcontainers.cpp b/src/containers/kolabcontainers.cpp
index 47c76e3..fc241a1 100644
--- a/src/containers/kolabcontainers.cpp
+++ b/src/containers/kolabcontainers.cpp
@@ -536,11 +536,13 @@ struct Attachment::Private
std::string data;
std::string mimetype;
std::string label;
+ bool isValid;
};
Attachment::Attachment()
: d(new Attachment::Private)
{
+ d->isValid = false;
}
Attachment::Attachment(const Kolab::Attachment &other)
@@ -568,6 +570,7 @@ bool Attachment::operator==(const Kolab::Attachment &other) const
void Attachment::setUri(const std::string &uri, const std::string& mimetype)
{
+ d->isValid = true;
d->uri = uri;
d->mimetype = mimetype;
}
@@ -594,6 +597,7 @@ std::string Attachment::label() const
void Attachment::setData(const std::string &data, const std::string& mimetype)
{
+ d->isValid = true;
d->data = data;
d->mimetype = mimetype;
}
@@ -605,7 +609,7 @@ std::string Attachment::data() const
bool Attachment::isValid() const
{
- return !d->mimetype.empty(); //TODO use isValid variable
+ return d->isValid;
}
diff --git a/src/csharp/CMakeLists.txt b/src/csharp/CMakeLists.txt
index 17a1e8a..35b1d93 100644
--- a/src/csharp/CMakeLists.txt
+++ b/src/csharp/CMakeLists.txt
@@ -33,6 +33,8 @@ set(KOLAB_SWIG_CSHARP_FILES
${CMAKE_CURRENT_BINARY_DIR}/Email.cs
${CMAKE_CURRENT_BINARY_DIR}/Event.cs
${CMAKE_CURRENT_BINARY_DIR}/File.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/Freebusy.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/FreebusyPeriod.cs
${CMAKE_CURRENT_BINARY_DIR}/Geo.cs
${CMAKE_CURRENT_BINARY_DIR}/Journal.cs
${CMAKE_CURRENT_BINARY_DIR}/Key.cs
@@ -40,17 +42,15 @@ set(KOLAB_SWIG_CSHARP_FILES
${CMAKE_CURRENT_BINARY_DIR}/NameComponents.cs
${CMAKE_CURRENT_BINARY_DIR}/Note.cs
${CMAKE_CURRENT_BINARY_DIR}/PartStatus.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/Period.cs
${CMAKE_CURRENT_BINARY_DIR}/RecurrenceRule.cs
${CMAKE_CURRENT_BINARY_DIR}/Related.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/Relation.cs
${CMAKE_CURRENT_BINARY_DIR}/Relative.cs
${CMAKE_CURRENT_BINARY_DIR}/Role.cs
${CMAKE_CURRENT_BINARY_DIR}/Snippet.cs
${CMAKE_CURRENT_BINARY_DIR}/SnippetsCollection.cs
${CMAKE_CURRENT_BINARY_DIR}/Status.cs
- ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_Kolab__Freebusy.cs
- ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_std__vectorT_Kolab__Snippet_t.cs
- ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_std__vectorT_Kolab__Todo_t.cs
- ${CMAKE_CURRENT_BINARY_DIR}/Tag.cs
${CMAKE_CURRENT_BINARY_DIR}/Telephone.cs
${CMAKE_CURRENT_BINARY_DIR}/Todo.cs
${CMAKE_CURRENT_BINARY_DIR}/Url.cs
@@ -66,12 +66,16 @@ set(KOLAB_SWIG_CSHARP_FILES
${CMAKE_CURRENT_BINARY_DIR}/vectordaypos.cs
${CMAKE_CURRENT_BINARY_DIR}/vectoremail.cs
${CMAKE_CURRENT_BINARY_DIR}/vectorevent.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/vectorfreebusyperiod.cs
${CMAKE_CURRENT_BINARY_DIR}/vectorgeo.cs
${CMAKE_CURRENT_BINARY_DIR}/vectori.cs
${CMAKE_CURRENT_BINARY_DIR}/vectorkey.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/vectorperiod.cs
${CMAKE_CURRENT_BINARY_DIR}/vectorrelated.cs
${CMAKE_CURRENT_BINARY_DIR}/vectors.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/vectorsnippet.cs
${CMAKE_CURRENT_BINARY_DIR}/vectortelephone.cs
+ ${CMAKE_CURRENT_BINARY_DIR}/vectortodo.cs
${CMAKE_CURRENT_BINARY_DIR}/vectorurl.cs
${CMAKE_CURRENT_BINARY_DIR}/Weekday.cs
)
diff --git a/src/java/CMakeLists.txt b/src/java/CMakeLists.txt
index 0cf1596..3c0f01b 100644
--- a/src/java/CMakeLists.txt
+++ b/src/java/CMakeLists.txt
@@ -23,6 +23,9 @@ set(KOLAB_SWIG_JAVA_FILES
${CMAKE_CURRENT_BINARY_DIR}/Duration.java
${CMAKE_CURRENT_BINARY_DIR}/ErrorSeverity.java
${CMAKE_CURRENT_BINARY_DIR}/Event.java
+ ${CMAKE_CURRENT_BINARY_DIR}/File.java
+ ${CMAKE_CURRENT_BINARY_DIR}/Freebusy.java
+ ${CMAKE_CURRENT_BINARY_DIR}/FreebusyPeriod.java
${CMAKE_CURRENT_BINARY_DIR}/Geo.java
${CMAKE_CURRENT_BINARY_DIR}/Journal.java
${CMAKE_CURRENT_BINARY_DIR}/Key.java
@@ -32,17 +35,15 @@ set(KOLAB_SWIG_JAVA_FILES
${CMAKE_CURRENT_BINARY_DIR}/NameComponents.java
${CMAKE_CURRENT_BINARY_DIR}/Note.java
${CMAKE_CURRENT_BINARY_DIR}/PartStatus.java
+ ${CMAKE_CURRENT_BINARY_DIR}/Period.java
${CMAKE_CURRENT_BINARY_DIR}/RecurrenceRule.java
+ ${CMAKE_CURRENT_BINARY_DIR}/Relation.java
${CMAKE_CURRENT_BINARY_DIR}/Related.java
${CMAKE_CURRENT_BINARY_DIR}/Relative.java
${CMAKE_CURRENT_BINARY_DIR}/Role.java
${CMAKE_CURRENT_BINARY_DIR}/Status.java
${CMAKE_CURRENT_BINARY_DIR}/Snippet.java
${CMAKE_CURRENT_BINARY_DIR}/SnippetsCollection.java
- ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_Kolab__Freebusy.java
- ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_std__vectorT_Kolab__Snippet_t.java
- ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_std__vectorT_Kolab__Todo_t.java
- ${CMAKE_CURRENT_BINARY_DIR}/Tag.java
${CMAKE_CURRENT_BINARY_DIR}/Telephone.java
${CMAKE_CURRENT_BINARY_DIR}/Todo.java
${CMAKE_CURRENT_BINARY_DIR}/Url.java
@@ -56,12 +57,18 @@ set(KOLAB_SWIG_JAVA_FILES
${CMAKE_CURRENT_BINARY_DIR}/vectorcs.java
${CMAKE_CURRENT_BINARY_DIR}/vectordatetime.java
${CMAKE_CURRENT_BINARY_DIR}/vectordaypos.java
+ ${CMAKE_CURRENT_BINARY_DIR}/vectoremail.java
+ ${CMAKE_CURRENT_BINARY_DIR}/vectorevent.java
+ ${CMAKE_CURRENT_BINARY_DIR}/vectorfreebusyperiod.java
${CMAKE_CURRENT_BINARY_DIR}/vectorgeo.java
${CMAKE_CURRENT_BINARY_DIR}/vectori.java
${CMAKE_CURRENT_BINARY_DIR}/vectorkey.java
+ ${CMAKE_CURRENT_BINARY_DIR}/vectorperiod.java
${CMAKE_CURRENT_BINARY_DIR}/vectorrelated.java
${CMAKE_CURRENT_BINARY_DIR}/vectors.java
+ ${CMAKE_CURRENT_BINARY_DIR}/vectorsnippet.java
${CMAKE_CURRENT_BINARY_DIR}/vectortelephone.java
+ ${CMAKE_CURRENT_BINARY_DIR}/vectortodo.java
${CMAKE_CURRENT_BINARY_DIR}/vectorurl.java
${CMAKE_CURRENT_BINARY_DIR}/Weekday.java
)
diff --git a/src/kolabconversions.h b/src/kolabconversions.h
index 158ee2b..cfd0e7b 100644
--- a/src/kolabconversions.h
+++ b/src/kolabconversions.h
@@ -127,7 +127,7 @@ std::vector<CategoryColor> readColors(const KolabXSD::Configuration::categorycol
return colors;
}
-KolabXSD::Configuration::type_type getConfiguratinoType(Kolab::Configuration::ConfigurationType t)
+KolabXSD::Configuration::type_type getConfigurationType(Kolab::Configuration::ConfigurationType t)
{
switch (t) {
case Kolab::Configuration::TypeDictionary:
@@ -136,8 +136,8 @@ KolabXSD::Configuration::type_type getConfiguratinoType(Kolab::Configuration::Co
return KolabXSD::Configuration::type_type::categorycolor;
case Kolab::Configuration::TypeSnippet:
return KolabXSD::Configuration::type_type::snippets;
- case Kolab::Configuration::TypeTag:
- return KolabXSD::Configuration::type_type::tag;
+ case Kolab::Configuration::TypeRelation:
+ return KolabXSD::Configuration::type_type::relation;
default:
CRITICAL("Invalid configuration type");
}
@@ -168,7 +168,7 @@ std::string serializeObject <Kolab::Configuration> (const Kolab::Configuration &
// WARNING("missing last_modification_date, fallback to current timestamp");
lastModificationDate = fromDateTime(timestamp());
}
- KolabXSD::Configuration n(uid, getProductId(prod), created, lastModificationDate, getConfiguratinoType(configuration.type()));
+ KolabXSD::Configuration n(uid, getProductId(prod), created, lastModificationDate, getConfigurationType(configuration.type()));
switch (configuration.type()) {
case Kolab::Configuration::TypeDictionary: {
@@ -198,25 +198,25 @@ std::string serializeObject <Kolab::Configuration> (const Kolab::Configuration &
}
}
break;
- case Kolab::Configuration::TypeTag: {
- const Kolab::Tag &tag = configuration.tag();
- n.name(tag.name());
- if (!tag.type().empty()) {
- n.tagType(tag.type());
+ case Kolab::Configuration::TypeRelation: {
+ const Kolab::Relation &relation = configuration.relation();
+ n.name(relation.name());
+ if (!relation.type().empty()) {
+ n.relationType(relation.type());
}
- if (!tag.color().empty()) {
- n.color(tag.color());
+ if (!relation.color().empty()) {
+ n.color(relation.color());
}
- if (!tag.iconName().empty()) {
- n.iconName(tag.iconName());
+ if (!relation.iconName().empty()) {
+ n.iconName(relation.iconName());
}
- if (!tag.parent().empty()) {
- n.parent(tag.parent());
+ if (!relation.parent().empty()) {
+ n.parent(relation.parent());
}
- if (!tag.priority() != 0) {
- n.priority(fromInt<KolabXSD::Configuration::priority_type>(tag.priority()));
+ if (!relation.priority() != 0) {
+ n.priority(fromInt<KolabXSD::Configuration::priority_type>(relation.priority()));
}
- BOOST_FOREACH(const std::string &s, tag.members()) {
+ BOOST_FOREACH(const std::string &s, relation.members()) {
n.member().push_back(s);
}
}
@@ -547,31 +547,31 @@ boost::shared_ptr<Kolab::Configuration> deserializeObject <Kolab::Configuration>
collection.setSnippets(snippets);
n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(collection));
- } else if (configuration->type() == KolabXSD::ConfigurationType::tag) {
+ } else if (configuration->type() == KolabXSD::ConfigurationType::relation) {
std::string name;
if (configuration->name()) {
name = *configuration->name();
}
std::string type;
- if (configuration->tagType()) {
- type = *configuration->tagType();
+ if (configuration->relationType()) {
+ type = *configuration->relationType();
}
- Tag tag(name, type);
+ Relation relation(name, type);
if (configuration->color()) {
- tag.setColor(*configuration->color());
+ relation.setColor(*configuration->color());
}
if (configuration->iconName()) {
- tag.setIconName(*configuration->iconName());
+ relation.setIconName(*configuration->iconName());
}
if (configuration->parent()) {
- tag.setParent(*configuration->parent());
+ relation.setParent(*configuration->parent());
}
if (configuration->priority()) {
- tag.setPriority(convertToInt(*configuration->priority()));
+ relation.setPriority(convertToInt(*configuration->priority()));
}
- tag.setMembers(toStringList(configuration->member()));
+ relation.setMembers(toStringList(configuration->member()));
- n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(tag));
+ n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(relation));
} else {
CRITICAL("No valid configuration type");
}
diff --git a/src/kolabformat.cpp b/src/kolabformat.cpp
index bb0a418..ac2f6c0 100644
--- a/src/kolabformat.cpp
+++ b/src/kolabformat.cpp
@@ -49,7 +49,7 @@ std::string productId()
std::string xCalVersion()
{
- return XCAL::global_xCalVersion;
+ return Utils::xCalVersion();
}
std::string xKolabVersion()
@@ -79,6 +79,7 @@ Kolab::Event readEvent(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::Event();
}
+ validate(*ptr);
return *ptr;
}
@@ -86,7 +87,13 @@ std::string writeEvent(const Kolab::Event &event, const std::string& productId)
{
Utils::clearErrors();
validate(event);
- return XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(event, productId);
+ const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(event, productId);
+ //Validate
+ XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
Kolab::Todo readTodo(const std::string& s, bool isUrl)
@@ -96,6 +103,7 @@ Kolab::Todo readTodo(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::Todo();
}
+ validate(*ptr);
return *ptr;
}
@@ -103,7 +111,13 @@ std::string writeTodo(const Kolab::Todo &event, const std::string& productId)
{
Utils::clearErrors();
validate(event);
- return XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(event, productId);
+ const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(event, productId);
+ //Validate
+ XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
Journal readJournal(const std::string& s, bool isUrl)
@@ -113,6 +127,7 @@ Journal readJournal(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::Journal();
}
+ validate(*ptr);
return *ptr;
}
@@ -120,7 +135,13 @@ std::string writeJournal(const Kolab::Journal &j, const std::string& productId)
{
Utils::clearErrors();
validate(j);
- return XCAL::serializeIncidence<XCAL::IncidenceTrait<Kolab::Journal> >(j, productId);
+ const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Journal> >(j, productId);
+ //Validate
+ XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Journal> >(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
Kolab::Freebusy readFreebusy(const std::string& s, bool isUrl)
@@ -130,6 +151,7 @@ Kolab::Freebusy readFreebusy(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::Freebusy();
}
+ validate(*ptr);
return *ptr;
}
@@ -137,7 +159,12 @@ std::string writeFreebusy(const Freebusy &f, const std::string& productId)
{
Utils::clearErrors();
validate(f);
- return XCAL::serializeFreebusy<XCAL::IncidenceTrait<Kolab::Freebusy> >(f, productId);
+ const std::string result = XCAL::serializeFreebusy<XCAL::IncidenceTrait<Kolab::Freebusy> >(f, productId);
+ XCAL::deserializeIncidence<XCAL::IncidenceTrait<Kolab::Freebusy> >(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
Kolab::Contact readContact(const std::string& s, bool isUrl)
@@ -147,6 +174,7 @@ Kolab::Contact readContact(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::Contact();
}
+ validate(*ptr);
return *ptr;
}
@@ -154,7 +182,13 @@ std::string writeContact(const Contact &contact, const std::string& productId)
{
Utils::clearErrors();
validate(contact);
- return XCARD::serializeCard(contact, productId);
+ const std::string result = XCARD::serializeCard(contact, productId);
+ //Validate
+ XCARD::deserializeCard<Kolab::Contact>(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
DistList readDistlist(const std::string& s, bool isUrl)
@@ -164,6 +198,7 @@ DistList readDistlist(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::DistList();
}
+ validate(*ptr);
return *ptr;
}
@@ -171,7 +206,13 @@ std::string writeDistlist(const DistList &list, const std::string& productId)
{
Utils::clearErrors();
validate(list);
- return XCARD::serializeCard(list, productId);
+ const std::string result = XCARD::serializeCard(list, productId);
+ //Validate
+ XCARD::deserializeCard<Kolab::DistList>(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
Note readNote(const std::string& s, bool isUrl)
@@ -181,6 +222,7 @@ Note readNote(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::Note();
}
+ validate(*ptr);
return *ptr;
}
@@ -188,7 +230,13 @@ std::string writeNote(const Note &note, const std::string& productId)
{
Utils::clearErrors();
validate(note);
- return Kolab::KolabObjects::serializeObject<Kolab::Note>(note, productId);
+ const std::string result = Kolab::KolabObjects::serializeObject<Kolab::Note>(note, productId);
+ //Validate
+ Kolab::KolabObjects::deserializeObject<Kolab::Note>(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
File readFile(const std::string& s, bool isUrl)
@@ -198,6 +246,7 @@ File readFile(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::File();
}
+ validate(*ptr);
return *ptr;
}
@@ -205,7 +254,13 @@ std::string writeFile(const File &file, const std::string& productId)
{
Utils::clearErrors();
validate(file);
- return Kolab::KolabObjects::serializeObject<Kolab::File>(file, productId);
+ const std::string result = Kolab::KolabObjects::serializeObject<Kolab::File>(file, productId);
+ //Validate
+ Kolab::KolabObjects::deserializeObject<Kolab::File>(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
Configuration readConfiguration(const std::string& s, bool isUrl)
@@ -215,6 +270,7 @@ Configuration readConfiguration(const std::string& s, bool isUrl)
if (!ptr.get()) {
return Kolab::Configuration();
}
+ validate(*ptr);
return *ptr;
}
@@ -222,7 +278,13 @@ std::string writeConfiguration(const Configuration &config, const std::string& p
{
Utils::clearErrors();
validate(config);
- return Kolab::KolabObjects::serializeObject< Kolab::Configuration >(config, productId);
+ const std::string result = Kolab::KolabObjects::serializeObject<Kolab::Configuration>(config, productId);
+ //Validate
+ Kolab::KolabObjects::deserializeObject<Kolab::Configuration>(result, false);
+ if (errorOccurred()) {
+ LOG("Error occurred while writing.")
+ }
+ return result;
}
diff --git a/src/kolabformat.i b/src/kolabformat.i
index f2ffd6c..da41b08 100644
--- a/src/kolabformat.i
+++ b/src/kolabformat.i
@@ -15,6 +15,7 @@
#include "containers/kolabnote.h"
#include "containers/kolabconfiguration.h"
#include "containers/kolabfile.h"
+ #include "containers/kolabfreebusy.h"
%}
%include "std_string.i"
@@ -39,11 +40,15 @@ namespace std {
%template(vectorevent) vector<Kolab::Event>;
%template(vectorrelated) vector<Kolab::Related>;
%template(vectortelephone) vector<Kolab::Telephone>;
+ %template(vectortodo) vector<Kolab::Todo>;
%template(vectoremail) vector<Kolab::Email>;
%template(vectordatetime) vector<Kolab::cDateTime>;
%template(vectorurl) vector<Kolab::Url>;
%template(vectorkey) vector<Kolab::Key>;
%template(vectorcategorycolor) vector<Kolab::CategoryColor>;
+ %template(vectorsnippet) vector<Kolab::Snippet>;
+ %template(vectorfreebusyperiod) vector<Kolab::FreebusyPeriod>;
+ %template(vectorperiod) vector<Kolab::Period>;
};
%rename(readKolabFile) Kolab::readFile;
@@ -59,3 +64,4 @@ namespace std {
%include "containers/kolabnote.h"
%include "containers/kolabconfiguration.h"
%include "containers/kolabfile.h"
+%include "containers/kolabfreebusy.h"
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/utils.cpp b/src/utils.cpp
index 170f6b1..5ece8cb 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -47,6 +47,7 @@ struct Global {
std::string createdUID;
std::string productId;
std::string xKolabVersion;
+ std::string xCalVersion;
ErrorSeverity errorBit;
std::string errorMessage;
@@ -80,6 +81,16 @@ std::string kolabVersion()
return ThreadLocal::inst().xKolabVersion;
}
+void setXCalVersion(const std::string &s)
+{
+ ThreadLocal::inst().xCalVersion = s;
+}
+
+std::string xCalVersion()
+{
+ return ThreadLocal::inst().xCalVersion;
+}
+
void setProductId(const std::string &s)
{
ThreadLocal::inst().productId = s;
diff --git a/src/utils.h b/src/utils.h
index 7ed26b9..2688af4 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -33,10 +33,10 @@ std::string getUID(const std::string & = std::string());
void logMessage(const std::string &,const std::string &, int, ErrorSeverity s);
-#define LOG(message) logMessage(message,__FILE__, __LINE__, NoError);
-#define WARNING(message) logMessage(message,__FILE__, __LINE__, Warning);
-#define ERROR(message) logMessage(message,__FILE__, __LINE__, Error);
-#define CRITICAL(message) logMessage(message,__FILE__, __LINE__, Critical);
+#define LOG(message) Utils::logMessage(message,__FILE__, __LINE__, NoError);
+#define WARNING(message) Utils::logMessage(message,__FILE__, __LINE__, Warning);
+#define ERROR(message) Utils::logMessage(message,__FILE__, __LINE__, Error);
+#define CRITICAL(message) Utils::logMessage(message,__FILE__, __LINE__, Critical);
void logMessage(const std::string &, ErrorSeverity s = Warning);
@@ -72,6 +72,12 @@ void setKolabVersion(const std::string &);
std::string kolabVersion();
/**
+ * The xCal Version of the last deserialized object
+ */
+void setXCalVersion(const std::string &);
+std::string xCalVersion();
+
+/**
* A timestamp which overrides the one normally used.
*/
void setOverrideTimestamp(const cDateTime &);
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index a0489a8..85d98ed 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -47,8 +47,6 @@
namespace Kolab {
namespace XCAL {
-std::string global_xCalVersion;
-
const char* const XCAL_VERSION = "2.0";
const char* const XCAL_NAMESPACE = "urn:ietf:params:xml:ns:icalendar-2.0";
@@ -59,7 +57,8 @@ const char* const THISANDFUTURE = "THISANDFUTURE";
const char* const BASE64 = "BASE64";
const char* const NEEDSACTION = "NEEDS-ACTION";
-const char* const COMPLETED = "OPAQUE";
+const char* const COMPLETED = "COMPLETED";
+const char* const COMPLETED_COMPAT = "OPAQUE";
const char* const INPROCESS = "IN-PROCESS";
const char* const CANCELLED = "CANCELLED";
const char* const TENTATIVE = "TENTATIVE";
@@ -419,16 +418,13 @@ Kolab::Attachment toAttachment(T aProp)
}
}
}
- if (mimetype.empty()) {
- ERROR("no mimetype");
- }
if (aProp.uri()) {
a.setUri(*aProp.uri(), mimetype);
} else if (aProp.binary()) {
a.setData(base64_decode(*aProp.binary()), mimetype);
} else {
- ERROR("not uri and no data available");
+ ERROR("no uri and no data available");
}
return a;
}
@@ -567,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()) {
@@ -851,7 +846,7 @@ void setIncidenceProperties(I &inc, const T &prop)
const std::string &status = toString(*prop.status());
if (status == NEEDSACTION) {
inc.setStatus(StatusNeedsAction);
- } else if (status == COMPLETED) {
+ } else if (status == COMPLETED || status == COMPLETED_COMPAT) {
inc.setStatus(StatusCompleted);
} else if (status == INPROCESS) {
inc.setStatus(StatusInProcess);
@@ -1495,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()));
}
@@ -1948,7 +1938,7 @@ typename T::IncidencePtr deserializeIncidence(const std::string& s, bool isUrl)
}
setProductId( vcalendar.properties().prodid().text() );
- global_xCalVersion = vcalendar.properties().version().text();
+ setXCalVersion(vcalendar.properties().version().text());
setKolabVersion( vcalendar.properties().x_kolab_version().text() );
if (incidences.empty()) {
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index 6391666..ec56712 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -105,19 +105,19 @@ void BindingsTest::snippetConfigurationCompletness()
QCOMPARE(re.snippets(), snippets);
}
-void BindingsTest::tagConfigurationCompletness()
+void BindingsTest::relationConfigurationCompletness()
{
- Kolab::Tag tag("name1", "type1");
- tag.setColor("color");
- tag.setIconName("icon");
- tag.setParent("parent");
- tag.setPriority(3);
+ Kolab::Relation relation("name1", "type1");
+ relation.setColor("color");
+ relation.setIconName("icon");
+ relation.setParent("parent");
+ relation.setPriority(3);
std::vector<std::string> members;
members.push_back("member1");
members.push_back("member2");
- tag.setMembers(members);
+ relation.setMembers(members);
- Kolab::Configuration configuration(tag);
+ Kolab::Configuration configuration(relation);
configuration.setUid("uid");
configuration.setCreated(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
configuration.setLastModified(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
@@ -130,8 +130,8 @@ void BindingsTest::tagConfigurationCompletness()
QCOMPARE(re.uid(), configuration.uid());
QCOMPARE(re.created(), configuration.created());
QCOMPARE(re.lastModified(), configuration.lastModified());
- QCOMPARE(re.type(), Kolab::Configuration::TypeTag);
- QCOMPARE(re.tag(), tag);
+ QCOMPARE(re.type(), Kolab::Configuration::TypeRelation);
+ QCOMPARE(re.relation(), relation);
}
void BindingsTest::noteCompletness()
diff --git a/tests/bindingstest.h b/tests/bindingstest.h
index a262817..5d04e11 100644
--- a/tests/bindingstest.h
+++ b/tests/bindingstest.h
@@ -25,7 +25,7 @@ class BindingsTest : public QObject
void categorycolorConfigurationCompletness();
void dictionaryConfigurationCompletness();
void snippetConfigurationCompletness();
- void tagConfigurationCompletness();
+ void relationConfigurationCompletness();
void noteCompletness();
void fileCompletness();
void eventCompletness();
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()