CMakeLists.txt schemas/kolabformat.xsd src/CMakeLists.txt src/kolabconfiguration.cpp src/kolabconfiguration.h src/kolabcontainers.h src/kolabconversions.h src/kolabformat.cpp src/kolabformat.h tests/bindingstest.cpp tests/bindingstest.h
Christian Mollekopf
mollekopf at kolabsys.com
Wed May 23 19:45:08 CEST 2012
CMakeLists.txt | 2
schemas/kolabformat.xsd | 43 ++++++++++
src/CMakeLists.txt | 3
src/kolabconfiguration.cpp | 121 ++++++++++++++++++++++++++++++
src/kolabconfiguration.h | 100 +++++++++++++++++++++++++
src/kolabcontainers.h | 9 --
src/kolabconversions.h | 176 +++++++++++++++++++++++++++++++++++++++++++--
src/kolabformat.cpp | 19 ++--
src/kolabformat.h | 1
tests/bindingstest.cpp | 52 +++++++++++++
tests/bindingstest.h | 2
11 files changed, 502 insertions(+), 26 deletions(-)
New commits:
commit 279e4d76e8a708a91aa07a2e722242c7cb876a4e
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Wed May 23 19:45:01 2012 +0200
Configuration objects, handling of lastmodification date for notes.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2015e5f..8366000 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,7 +134,7 @@ set( SCHEMA_SOURCEFILES
# --generate-inline --extern-xml-schema xml-schema.xsd
# --cxx-suffix .cpp --hxx-suffix .h
add_custom_command(OUTPUT ${SCHEMA_SOURCEFILES}
- COMMAND ${XSDCXX} cxx-tree --generate-polymorphic --generate-serialization --namespace-map http://kolab.org=KolabXSD --root-element icalendar --root-element vcards --root-element note --output-dir ${CMAKE_BINARY_DIR}/bindings ${SCHEMAS}
+ COMMAND ${XSDCXX} cxx-tree --generate-polymorphic --generate-serialization --namespace-map http://kolab.org=KolabXSD --root-element icalendar --root-element vcards --root-element note --root-element configuration --output-dir ${CMAKE_BINARY_DIR}/bindings ${SCHEMAS}
COMMENT "Generating XSD bindings"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${SCHEMAS}
diff --git a/schemas/kolabformat.xsd b/schemas/kolabformat.xsd
index 4549ed8..4edaafb 100644
--- a/schemas/kolabformat.xsd
+++ b/schemas/kolabformat.xsd
@@ -77,4 +77,47 @@
<xs:element name="note" type="Note"/>
+ <xs:simpleType name="ConfigurationType">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="dictionary"/>
+ <xs:enumeration value="categorycolor"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="type" type="Configuration"/>
+
+
+ <xs:complexType name="CategoryColor" mixed="true" >
+ <xs:sequence>
+ <xs:element name="category" type="xs:string"/>
+ <xs:element name="categorycolor" type="CategoryColor" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="color" type="xs:string" />
+ </xs:complexType>
+
+ <xs:element name="categorycolor" type="CategoryColor"/>
+
+
+ <xs:complexType name="Configuration">
+ <xs:complexContent mixed="false">
+ <xs:extension base="KolabBase">
+ <xs:sequence>
+ <xs:element name="uid" type="xs:string"/>
+ <xs:element name="prodid" type="xs:string"/>
+ <xs:element name="creation-date" type="xs:dateTime"/>
+ <xs:element name="last-modification-date" type="xs:dateTime"/>
+ <xs:element name="type" type="ConfigurationType"/>
+ <!-- Dictionary -->
+ <xs:element name="language" type="xs:string" minOccurs="0"/>
+ <xs:element name="e" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ <!-- Categorycolor -->
+ <xs:element name="categorycolor" type="CategoryColor" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:element name="configuration" type="Configuration"/>
+
+
</xs:schema>
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ff2dd08..6bbed10 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,7 +5,7 @@ SET_SOURCE_FILES_PROPERTIES(${SCHEMA_SOURCEFILES} PROPERTIES GENERATED 1)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wp,-D_FORTIFY_SOURCE=2 -O2" ) #always generate shared libraries with -fPIC, -D_FORTIFY_SOURCE=2 enables some extra checking
# Library with serialization/deserialization code and kolab-containers
-add_library(kolabxml SHARED kolabformat.cpp kolabcontainers.cpp kolabnote.cpp kolabevent.cpp kolabtodo.cpp kolabjournal.cpp kolabcontact.cpp utils.cpp base64.cpp ../compiled/XMLParserWrapper.cpp ../compiled/grammar-input-stream.cxx ${SCHEMA_SOURCEFILES})
+add_library(kolabxml SHARED kolabformat.cpp kolabcontainers.cpp kolabnote.cpp kolabevent.cpp kolabtodo.cpp kolabjournal.cpp kolabcontact.cpp kolabconfiguration.cpp utils.cpp base64.cpp ../compiled/XMLParserWrapper.cpp ../compiled/grammar-input-stream.cxx ${SCHEMA_SOURCEFILES})
add_dependencies(kolabxml generate_bindings)
target_link_libraries(kolabxml ${XERCES_C} ${Boost_LIBRARIES} ${UUID})
@@ -36,6 +36,7 @@ install( FILES
kolabcontact.h
kolabnote.h
kolabcontainers.h
+ kolabconfiguration.h
global_definitions.h
DESTINATION ${INCLUDE_INSTALL_DIR})
diff --git a/src/kolabconfiguration.cpp b/src/kolabconfiguration.cpp
new file mode 100644
index 0000000..2129371
--- /dev/null
+++ b/src/kolabconfiguration.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "kolabconfiguration.h"
+
+namespace Kolab {
+
+struct Configuration::Private {
+ Private(): type(Invalid){}
+
+ std::vector<CategoryColor> categoryColor;
+ Dictionary dictionary;
+ ConfigurationType type;
+ std::string uid;
+ cDateTime created;
+ cDateTime lastModified;
+};
+
+Configuration::Configuration()
+: d(new Configuration::Private)
+{
+}
+
+Configuration::Configuration(const std::vector<CategoryColor> &c)
+: d(new Configuration::Private)
+{
+ d->categoryColor = c;
+ d->type = TypeCategoryColor;
+}
+
+Configuration::Configuration(const Dictionary &dict)
+: d(new Configuration::Private)
+{
+ d->dictionary = dict;
+ d->type = TypeDictionary;
+}
+
+Configuration::Configuration(const Configuration &other)
+: d(new Configuration::Private)
+{
+ *d = *other.d;
+}
+
+Configuration::~Configuration()
+{
+
+}
+
+void Configuration::operator=(const Configuration &other)
+{
+ *d = *other.d;
+}
+
+bool Configuration::isValid() const
+{
+ return d->type != Invalid;
+}
+
+void Configuration::setUid(const std::string &uid)
+{
+ d->uid = uid;
+}
+
+std::string Configuration::uid() const
+{
+ return d->uid;
+}
+
+void Configuration::setCreated(const cDateTime &created)
+{
+ d->created = created;
+}
+
+cDateTime Configuration::created() const
+{
+ return d->created;
+}
+
+void Configuration::setLastModified(const cDateTime &lastModified)
+{
+ d->lastModified = lastModified;
+}
+
+cDateTime Configuration::lastModified() const
+{
+ return d->lastModified;
+}
+
+
+Configuration::ConfigurationType Configuration::type() const
+{
+ return d->type;
+}
+
+std::vector<CategoryColor> Configuration::categoryColor() const
+{
+ return d->categoryColor;
+}
+
+Dictionary Configuration::dictionary() const
+{
+ return d->dictionary;
+}
+
+
+
+} //Namespace
diff --git a/src/kolabconfiguration.h b/src/kolabconfiguration.h
new file mode 100644
index 0000000..d29ff1e
--- /dev/null
+++ b/src/kolabconfiguration.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf at kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KOLABCONFIGURATION_H
+#define KOLABCONFIGURATION_H
+#include <string>
+#include <vector>
+#include <boost/scoped_ptr.hpp>
+#include "kolabcontainers.h"
+
+namespace Kolab {
+
+struct Dictionary {
+ Dictionary(){}
+ Dictionary(const std::string &c): mLanguage(c){}
+
+ bool operator==(const Dictionary &other) const {
+ return mLanguage == other.mLanguage && mEntries == other.mEntries;
+ }
+
+ std::string language() const { return mLanguage; }
+
+ void setEntries(const std::vector<std::string> &e){ mEntries = e; }
+ std::vector<std::string> entries() const { return mEntries; }
+private:
+ std::string mLanguage;
+ std::vector<std::string> mEntries;
+};
+
+struct CategoryColor {
+ CategoryColor(){}
+ CategoryColor(const std::string &c): mCategory(c) {}
+
+ bool operator==(const CategoryColor &other) const {
+ return mCategory == other.mCategory && mColor == other.mColor && mSubcategories == other.mSubcategories;
+ }
+
+ std::string category() const { return mCategory; }
+
+ void setColor(const std::string &c) { mColor = c; }
+ std::string color() const { return mColor; }
+
+ void setSubcategories(const std::vector<CategoryColor> &c) { mSubcategories = c; }
+ std::vector<CategoryColor> subcategories() const { return mSubcategories; }
+private:
+ std::string mCategory;
+ std::string mColor;
+ std::vector<CategoryColor> mSubcategories;
+};
+
+class Configuration {
+public:
+ Configuration();
+ Configuration(const std::vector<CategoryColor> &);
+ Configuration(const Dictionary &);
+ Configuration(const Configuration &);
+ ~Configuration();
+ void operator=(const Configuration &);
+
+ bool isValid() const;
+
+ void setUid(const std::string &);
+ std::string uid() const;
+
+ void setCreated(const cDateTime &);
+ cDateTime created() const;
+
+ void setLastModified(const cDateTime &);
+ cDateTime lastModified() const;
+
+ enum ConfigurationType {
+ Invalid,
+ TypeDictionary,
+ TypeCategoryColor
+ };
+ ConfigurationType type() const;
+ std::vector<CategoryColor> categoryColor() const;
+ Dictionary dictionary() const;
+private:
+ struct Private;
+ boost::scoped_ptr<Private> d;
+};
+
+} //Namespace
+
+#endif // KOLABCONFIGURATION_H
diff --git a/src/kolabcontainers.h b/src/kolabcontainers.h
index f2a5018..5e9df0c 100644
--- a/src/kolabcontainers.h
+++ b/src/kolabcontainers.h
@@ -403,15 +403,6 @@ std::vector<T> operator<< ( std::vector<T> v, const T &s)
return v;
}
-
-//Prepared Kolab Objects
-
-
-class Configuration {
- //TODO
-};
-
-
}
diff --git a/src/kolabconversions.h b/src/kolabconversions.h
index 08f0ee0..5fd7edd 100644
--- a/src/kolabconversions.h
+++ b/src/kolabconversions.h
@@ -32,6 +32,7 @@
#include "utils.h"
#include "kolabnote.h"
#include "shared_conversions.h"
+#include "kolabconfiguration.h"
namespace Kolab {
namespace KolabObjects {
@@ -41,8 +42,102 @@ const char* const KOLAB_NAMESPACE = "http://kolab.org";
using namespace Kolab::Utils;
using namespace Kolab::Shared;
+
+void writeColors(KolabXSD::Configuration::categorycolor_sequence &colors, const std::vector<CategoryColor> &input)
+{
+ BOOST_FOREACH (const CategoryColor &entry, input) {
+ KolabXSD::Configuration::categorycolor_type c(entry.category());
+ c.color(entry.color());
+ writeColors(c.categorycolor(), entry.subcategories());
+ colors.push_back(c);
+ }
+}
+
+std::vector<CategoryColor> readColors(const KolabXSD::Configuration::categorycolor_sequence &list)
+{
+ std::vector<CategoryColor> colors ;
+ BOOST_FOREACH (const KolabXSD::Configuration::categorycolor_type &entry, list) {
+ if (!entry.color()) {
+ ERROR("Color is missing");
+ continue;
+ }
+ CategoryColor color(entry.category());
+ color.setColor(*entry.color());
+ color.setSubcategories(readColors(entry.categorycolor()));
+ colors.push_back(color);
+ }
+ return colors;
+}
+
+KolabXSD::Configuration::type_type getConfiguratinoType(Kolab::Configuration::ConfigurationType t)
+{
+ switch (t) {
+ case Kolab::Configuration::TypeDictionary:
+ return KolabXSD::Configuration::type_type::dictionary;
+ case Kolab::Configuration::TypeCategoryColor:
+ return KolabXSD::Configuration::type_type::categorycolor;
+ default:
+ CRITICAL("Invalid configuration type");
+ }
+ return KolabXSD::Configuration::type_type::dictionary;
+}
+
+
template <typename T>
-std::string serializeObject(const Kolab::Note ¬e, const std::string prod = std::string())
+std::string serializeObject(const T &, const std::string prod = std::string());
+
+template <>
+std::string serializeObject <Kolab::Configuration> (const Kolab::Configuration ¬e, const std::string prod)
+{
+ clearErrors();
+ try {
+
+ const std::string &uid = getUID(note.uid());
+ setCreatedUid(uid);
+
+ KolabXSD::Configuration::creation_date_type created = fromDateTime(note.created());
+ if (!note.created().isValid()) {
+ created = fromDateTime(timestamp());
+ }
+
+ KolabXSD::Configuration n(getUID(note.uid()), getProductId(prod), created, fromDateTime(timestamp()), getConfiguratinoType(note.type()));
+ if (note.lastModified().isValid()) {
+ n.last_modification_date(fromDateTime(note.lastModified()));
+ } else {
+ WARNING("missing last_modification_date, fallback to current timestamp");
+ n.last_modification_date(fromDateTime(timestamp()));
+ }
+ switch (note.type()) {
+ case Kolab::Configuration::TypeDictionary: {
+ const Kolab::Dictionary &dict = note.dictionary();
+ n.language(dict.language());
+ BOOST_FOREACH(const std::string &e, dict.entries()) {
+ n.e().push_back(e);
+ }
+ }
+ break;
+ case Kolab::Configuration::TypeCategoryColor:
+ writeColors(n.categorycolor(), note.categoryColor());
+ break;
+ default:
+ CRITICAL("Invalid configuration type");
+ return std::string();
+ }
+
+ xml_schema::namespace_infomap map;
+ map[""].name = KOLAB_NAMESPACE;
+
+ std::ostringstream ostringstream;
+ KolabXSD::configuration(ostringstream, n, map);
+ return ostringstream.str();
+ } catch (const xml_schema::exception& e) {
+ CRITICAL("Unknown Exception: failed to write Note");
+ }
+ return std::string();
+}
+
+template <>
+std::string serializeObject <Kolab::Note> (const Kolab::Note ¬e, const std::string prod)
{
clearErrors();
try {
@@ -56,7 +151,12 @@ std::string serializeObject(const Kolab::Note ¬e, const std::string prod = st
}
KolabXSD::Note n(getUID(note.uid()), getProductId(prod), created, fromDateTime(timestamp()));
-
+ if (note.lastModified().isValid()) {
+ n.last_modification_date(fromDateTime(note.lastModified()));
+ } else {
+ WARNING("missing last_modification_date, fallback to current timestamp");
+ n.last_modification_date(fromDateTime(timestamp()));
+ }
if (!note.categories().empty()) {
KolabXSD::Note::categories_sequence categories;
const std::vector<std::string> &l = note.categories();
@@ -104,7 +204,10 @@ std::string serializeObject(const Kolab::Note ¬e, const std::string prod = st
}
template <typename T>
-boost::shared_ptr<Kolab::Note> deserializeObject(const std::string& s, bool isUrl)
+boost::shared_ptr<T> deserializeObject(const std::string& s, bool isUrl);
+
+template <>
+boost::shared_ptr<Kolab::Note> deserializeObject <Kolab::Note> (const std::string& s, bool isUrl)
{
clearErrors();
try {
@@ -178,7 +281,72 @@ boost::shared_ptr<Kolab::Note> deserializeObject(const std::string& s, bool isUr
CRITICAL("Failed to read note!");
}
- return boost::shared_ptr<T>();
+ return boost::shared_ptr<Kolab::Note>();
+}
+
+
+
+template <>
+boost::shared_ptr<Kolab::Configuration> deserializeObject <Kolab::Configuration> (const std::string& s, bool isUrl)
+{
+ clearErrors();
+ try {
+ std::auto_ptr<KolabXSD::Configuration> configuration;
+ if (isUrl) {
+ xsd::cxx::xml::dom::auto_ptr <xercesc::DOMDocument > doc = XMLParserWrapper::inst().parseFile(s);
+ if (doc.get()) {
+ configuration = KolabXSD::configuration(doc);
+ }
+ } else {
+ xsd::cxx::xml::dom::auto_ptr <xercesc::DOMDocument > doc = XMLParserWrapper::inst().parseString(s);
+ if (doc.get()) {
+ configuration = KolabXSD::configuration(doc);
+ }
+ }
+
+ if (!configuration.get()) {
+ CRITICAL("failed to parse configuration!");
+ return boost::shared_ptr<Kolab::Configuration>();
+ }
+
+ boost::shared_ptr<Kolab::Configuration> n;
+ if (configuration->type() == KolabXSD::ConfigurationType::dictionary) {
+ std::string lang("XX");
+ if (configuration->language()) {
+ lang = *configuration->language();
+ } else {
+ WARNING("missing dictionary language, default to special value XX");
+ }
+ Dictionary dict(lang);
+
+ std::vector<std::string> entries;
+ BOOST_FOREACH (const KolabXSD::Configuration::e_type &entry, configuration->e()) {
+ entries.push_back(entry);
+ }
+ dict.setEntries(entries);
+
+ n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(dict));
+ } else if (configuration->type() == KolabXSD::ConfigurationType::categorycolor) {
+ n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(readColors(configuration->categorycolor())));
+ } else {
+ CRITICAL("No valid configuration type");
+ }
+
+ n->setUid(configuration->uid());
+ n->setCreated(*toDate(configuration->creation_date()));
+ n->setLastModified(*toDate(configuration->last_modification_date()));
+
+ setProductId( configuration->prodid() );
+ // setFormatVersion( vcards->vcard().version().text() );
+ // global_xCardVersion = vcalendar.properties().version().text();
+ setKolabVersion( configuration->version() );
+ return n;
+ } catch (const xml_schema::exception& e) {
+ std::cerr << e << std::endl;
+ CRITICAL("Failed to read configuration!");
+ }
+
+ return boost::shared_ptr<Kolab::Configuration>();
}
}//Namespace
diff --git a/src/kolabformat.cpp b/src/kolabformat.cpp
index 192b48d..e2b69cc 100644
--- a/src/kolabformat.cpp
+++ b/src/kolabformat.cpp
@@ -139,7 +139,6 @@ Note readNote(const std::string& s, bool isUrl)
return Kolab::Note();
}
return *ptr;
- return Note();
}
std::string writeNote(const Note ¬e, const std::string& productId)
@@ -147,20 +146,18 @@ std::string writeNote(const Note ¬e, const std::string& productId)
return Kolab::KolabObjects::serializeObject<Kolab::Note>(note, productId);
}
-Configuration readConfiguration(const std::string& /*s*/, bool /*isUrl*/)
+Configuration readConfiguration(const std::string& s, bool isUrl)
{
-// boost::shared_ptr <Kolab::Configuration> ptr = deserializeConfiguration(s, isUrl);
-// if (!ptr.get()) {
-// return Kolab::Configuration();
-// }
-// return *ptr;
- return Configuration();
+ boost::shared_ptr <Kolab::Configuration> ptr = Kolab::KolabObjects::deserializeObject<Kolab::Configuration>(s, isUrl);
+ if (!ptr.get()) {
+ return Kolab::Configuration();
+ }
+ return *ptr;
}
-std::string writeConfiguration(const Configuration &/*config*/, const std::string& /*productId*/)
+std::string writeConfiguration(const Configuration &config, const std::string& productId)
{
-// return serializeConfiguration(config);
-return std::string();
+ return Kolab::KolabObjects::serializeObject< Kolab::Configuration >(config, productId);
}
diff --git a/src/kolabformat.h b/src/kolabformat.h
index d419a33..221b7fd 100644
--- a/src/kolabformat.h
+++ b/src/kolabformat.h
@@ -25,6 +25,7 @@
#include "kolabjournal.h"
#include "kolabcontact.h"
#include "kolabnote.h"
+#include "kolabconfiguration.h"
#include "global_definitions.h"
namespace Kolab {
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index 9832ed8..f823e9d 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -21,6 +21,56 @@
#include "libkolabxml-version.h"
+void BindingsTest::categorycolorConfigurationCompletness()
+{
+ Kolab::CategoryColor color("name");
+ color.setColor("color");
+ std::vector<Kolab::CategoryColor> entries;
+ entries.push_back(color);
+ color.setSubcategories(entries);
+ entries.push_back(color);
+ color.setSubcategories(entries);
+ entries.push_back(color);
+
+ Kolab::Configuration configuration(entries);
+ 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
+
+ const std::string &result = Kolab::writeConfiguration(configuration);
+// std::cout << result << std::endl;
+ const Kolab::Configuration &re = Kolab::readConfiguration(result, false);
+ QCOMPARE(re.uid(), configuration.uid());
+ QCOMPARE(re.created(), configuration.created());
+ QCOMPARE(re.lastModified(), configuration.lastModified());
+ QCOMPARE(re.type(), Kolab::Configuration::TypeCategoryColor);
+ QCOMPARE(re.categoryColor(), entries);
+}
+
+
+void BindingsTest::dictionaryConfigurationCompletness()
+{
+ Kolab::Dictionary dict("en");
+ std::vector<std::string> entries;
+ entries.push_back("entry1");
+ entries.push_back("entry2");
+ entries.push_back("entry3");
+ dict.setEntries(entries);
+
+ Kolab::Configuration configuration(dict);
+ 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
+
+ const std::string &result = Kolab::writeConfiguration(configuration);
+// std::cout << result << std::endl;
+ const Kolab::Configuration &re = Kolab::readConfiguration(result, false);
+ QCOMPARE(re.uid(), configuration.uid());
+ QCOMPARE(re.created(), configuration.created());
+ QCOMPARE(re.lastModified(), configuration.lastModified());
+ QCOMPARE(re.type(), Kolab::Configuration::TypeDictionary);
+ QCOMPARE(re.dictionary(), dict);
+}
void BindingsTest::noteCompletness()
@@ -28,6 +78,7 @@ void BindingsTest::noteCompletness()
Kolab::Note note;
note.setUid("UID");
note.setCreated(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
+ note.setLastModified(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
note.setClassification(Kolab::ClassConfidential);
note.addCategory("Category");
note.setSummary("summary");
@@ -39,6 +90,7 @@ void BindingsTest::noteCompletness()
const Kolab::Note &re = Kolab::readNote(result, false);
QCOMPARE(re.uid(), note.uid());
QCOMPARE(re.created(), note.created());
+ QCOMPARE(re.lastModified(), note.lastModified());
QCOMPARE(re.classification(), note.classification());
QCOMPARE(re.categories(), note.categories());
QCOMPARE(re.summary(), note.summary());
diff --git a/tests/bindingstest.h b/tests/bindingstest.h
index 16c933c..c58ff9f 100644
--- a/tests/bindingstest.h
+++ b/tests/bindingstest.h
@@ -22,6 +22,8 @@ class BindingsTest : public QObject
private slots:
//Kolabformat
+ void categorycolorConfigurationCompletness();
+ void dictionaryConfigurationCompletness();
void noteCompletness();
void eventCompletness();
void eventDuration();
More information about the commits
mailing list