summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-02-27 14:42:12 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-02-27 14:42:12 (GMT)
commit01fb120923cbedca87b5d8a38716b3dc4dd57e50 (patch)
treeb0b0b288a12089d91cedcdf2cd77b9196d598a51
parentbc341515687bce404b2bb9aedecf1d4caa314f59 (diff)
parent8d558ddfb088f817773d0aa214d047bbbf8fcede (diff)
downloadlibkolabxml-01fb120923cbedca87b5d8a38716b3dc4dd57e50.tar.gz
Merge branch 'master' of ssh://git.kolabsys.com/git/libkolabxml
-rw-r--r--schemas/kolabformat.xsd9
-rw-r--r--src/containers/kolabconfiguration.cpp13
-rw-r--r--src/containers/kolabconfiguration.h46
-rw-r--r--src/csharp/CMakeLists.txt1
-rw-r--r--src/java/CMakeLists.txt5
-rw-r--r--src/kolabconversions.h57
-rw-r--r--src/objectvalidation.cpp16
-rw-r--r--tests/bindingstest.cpp29
-rw-r--r--tests/bindingstest.h1
-rw-r--r--tztable.h2
10 files changed, 169 insertions, 10 deletions
diff --git a/schemas/kolabformat.xsd b/schemas/kolabformat.xsd
index f65c96e..58af080 100644
--- a/schemas/kolabformat.xsd
+++ b/schemas/kolabformat.xsd
@@ -102,6 +102,7 @@
<xs:enumeration value="dictionary"/>
<xs:enumeration value="categorycolor"/>
<xs:enumeration value="snippets"/>
+ <xs:enumeration value="tag"/>
</xs:restriction>
</xs:simpleType>
@@ -156,6 +157,14 @@
<!-- Snippets -->
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="snippet" type="Snippet" minOccurs="0" maxOccurs="unbounded"/>
+ <!-- Tag -->
+ <!-- xs:element name="name" type="xs:string" minOccurs="0"/ -->
+ <xs:element name="tagType" 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"/>
+ <xs:element name="parent" type="xs:string" minOccurs="0"/>
+ <xs:element name="member" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
diff --git a/src/containers/kolabconfiguration.cpp b/src/containers/kolabconfiguration.cpp
index afe8a7d..0e777b9 100644
--- a/src/containers/kolabconfiguration.cpp
+++ b/src/containers/kolabconfiguration.cpp
@@ -25,6 +25,7 @@ struct Configuration::Private {
std::vector<CategoryColor> categoryColor;
Dictionary dictionary;
SnippetsCollection snippets;
+ Tag tag;
ConfigurationType type;
std::string uid;
cDateTime created;
@@ -57,6 +58,13 @@ Configuration::Configuration(const SnippetsCollection &snippets)
d->type = TypeSnippet;
}
+Configuration::Configuration(const Tag &tag)
+: d(new Configuration::Private)
+{
+ d->tag = tag;
+ d->type = TypeTag;
+}
+
Configuration::Configuration(const Configuration &other)
: d(new Configuration::Private)
{
@@ -129,4 +137,9 @@ SnippetsCollection Configuration::snippets() const
return d->snippets;
}
+Tag Configuration::tag() const
+{
+ return d->tag;
+}
+
} //Namespace
diff --git a/src/containers/kolabconfiguration.h b/src/containers/kolabconfiguration.h
index 330167c..4d38367 100644
--- a/src/containers/kolabconfiguration.h
+++ b/src/containers/kolabconfiguration.h
@@ -109,12 +109,54 @@ private:
std::vector<Snippet> mSnippets;
};
+struct Tag {
+ Tag(){}
+ Tag(const std::string &name, const std::string &type): mName(name), mType(type) {}
+
+ bool operator==(const Tag &other) const {
+ return mName == other.mName &&
+ mType == other.mType &&
+ mColor == other.mColor &&
+ mIconName == other.mIconName &&
+ mParent == other.mParent &&
+ mMembers == other.mMembers;
+ }
+
+ std::string name() const { return mName; }
+ std::string type() const { return mType; }
+
+ void setColor(const std::string &color) { mColor = color; }
+ std::string color() const { return mColor; }
+
+ void setIconName(const std::string &icon) { mIconName = icon; }
+ std::string iconName() const { return mIconName; }
+
+ void setParent(const std::string &parent) { mParent = parent; }
+ std::string parent() const { return mParent; }
+
+ void setPriority(int priority) { mPriority = priority; }
+ int priority() const { return mPriority; }
+
+ void setMembers(const std::vector<std::string> &members) { mMembers = members; }
+ std::vector<std::string> members() const { return mMembers; }
+
+private:
+ std::string mName;
+ std::string mType;
+ std::string mColor;
+ std::string mIconName;
+ std::string mParent;
+ int mPriority;
+ std::vector<std::string> mMembers;
+};
+
class Configuration {
public:
Configuration();
Configuration(const std::vector<CategoryColor> &);
Configuration(const Dictionary &);
Configuration(const SnippetsCollection &);
+ Configuration(const Tag &);
Configuration(const Configuration &);
~Configuration();
void operator=(const Configuration &);
@@ -134,12 +176,14 @@ public:
Invalid,
TypeDictionary,
TypeCategoryColor,
- TypeSnippet
+ TypeSnippet,
+ TypeTag
};
ConfigurationType type() const;
std::vector<CategoryColor> categoryColor() const;
Dictionary dictionary() const;
SnippetsCollection snippets() const;
+ Tag tag() const;
private:
struct Private;
boost::scoped_ptr<Private> d;
diff --git a/src/csharp/CMakeLists.txt b/src/csharp/CMakeLists.txt
index 4d377cb..17a1e8a 100644
--- a/src/csharp/CMakeLists.txt
+++ b/src/csharp/CMakeLists.txt
@@ -50,6 +50,7 @@ set(KOLAB_SWIG_CSHARP_FILES
${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
diff --git a/src/java/CMakeLists.txt b/src/java/CMakeLists.txt
index cdc63f5..0cf1596 100644
--- a/src/java/CMakeLists.txt
+++ b/src/java/CMakeLists.txt
@@ -37,7 +37,12 @@ set(KOLAB_SWIG_JAVA_FILES
${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
diff --git a/src/kolabconversions.h b/src/kolabconversions.h
index 39afc05..158ee2b 100644
--- a/src/kolabconversions.h
+++ b/src/kolabconversions.h
@@ -45,6 +45,13 @@ const char* const BASE64 = "BASE64";
using namespace Kolab::Utils;
using namespace Kolab::Shared;
+template <typename T>
+std::vector<std::string> toStringList(const xsd::cxx::tree::sequence<T> &s)
+{
+ std::vector<std::string> d;
+ std::copy(s.begin(), s.end(), std::back_inserter(d));
+ return d;
+}
Kolab::Attachment toAttachment(KolabXSD::attachmentPropType aProp)
{
@@ -129,6 +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;
default:
CRITICAL("Invalid configuration type");
}
@@ -189,6 +198,29 @@ 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());
+ }
+ if (!tag.color().empty()) {
+ n.color(tag.color());
+ }
+ if (!tag.iconName().empty()) {
+ n.iconName(tag.iconName());
+ }
+ if (!tag.parent().empty()) {
+ n.parent(tag.parent());
+ }
+ if (!tag.priority() != 0) {
+ n.priority(fromInt<KolabXSD::Configuration::priority_type>(tag.priority()));
+ }
+ BOOST_FOREACH(const std::string &s, tag.members()) {
+ n.member().push_back(s);
+ }
+ }
+ break;
default:
CRITICAL("Invalid configuration type");
return std::string();
@@ -515,6 +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) {
+ std::string name;
+ if (configuration->name()) {
+ name = *configuration->name();
+ }
+ std::string type;
+ if (configuration->tagType()) {
+ type = *configuration->tagType();
+ }
+ Tag tag(name, type);
+ if (configuration->color()) {
+ tag.setColor(*configuration->color());
+ }
+ if (configuration->iconName()) {
+ tag.setIconName(*configuration->iconName());
+ }
+ if (configuration->parent()) {
+ tag.setParent(*configuration->parent());
+ }
+ if (configuration->priority()) {
+ tag.setPriority(convertToInt(*configuration->priority()));
+ }
+ tag.setMembers(toStringList(configuration->member()));
+
+ n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(tag));
} else {
CRITICAL("No valid configuration type");
}
diff --git a/src/objectvalidation.cpp b/src/objectvalidation.cpp
index e6a1464..cd3a104 100644
--- a/src/objectvalidation.cpp
+++ b/src/objectvalidation.cpp
@@ -31,7 +31,7 @@ namespace Kolab {
static boost::unordered_set<std::string> initializeTzSet() {
boost::unordered_set<std::string> set;
- for (int i = 0; i < numOlsonTimezones; i++) {
+ for (unsigned int i = 0; i < numOlsonTimezones; i++) {
set.insert(olsonTimezones[i]);
}
return set;
@@ -51,7 +51,7 @@ bool isValid(const cDateTime &datetime)
return false;
}
if (tzSet.find(tz) == tzSet.end()) {
- Utils::logMessage("not a valid olson timezone.", "", 0, Error);
+ Utils::logMessage("Not a valid olson timezone: " + tz, "", 0, Error);
return false;
}
}
@@ -110,32 +110,32 @@ void validate(const Journal& journal)
ASSERTVALID(journal.start());
}
-void validate(const Contact& contact)
+void validate(const Contact& /* contact */)
{
}
-void validate(const DistList& distlist)
+void validate(const DistList& /* distlist */)
{
}
-void validate(const Freebusy& freebusy)
+void validate(const Freebusy& /* freebusy */)
{
}
-void validate(const Note& note)
+void validate(const Note& /* note */)
{
}
-void validate(const Configuration& configuration)
+void validate(const Configuration& /* configuration */)
{
}
-void validate(const File& file)
+void validate(const File& /* file */)
{
}
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index b742ac5..6391666 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -105,6 +105,35 @@ void BindingsTest::snippetConfigurationCompletness()
QCOMPARE(re.snippets(), snippets);
}
+void BindingsTest::tagConfigurationCompletness()
+{
+ Kolab::Tag tag("name1", "type1");
+ tag.setColor("color");
+ tag.setIconName("icon");
+ tag.setParent("parent");
+ tag.setPriority(3);
+ std::vector<std::string> members;
+ members.push_back("member1");
+ members.push_back("member2");
+ tag.setMembers(members);
+
+ Kolab::Configuration configuration(tag);
+ 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);
+ QCOMPARE(Kolab::error(), Kolab::NoError);
+// std::cout << result << std::endl;
+ const Kolab::Configuration &re = Kolab::readConfiguration(result, false);
+ QCOMPARE(Kolab::error(), Kolab::NoError);
+ 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);
+}
+
void BindingsTest::noteCompletness()
{
Kolab::Note note;
diff --git a/tests/bindingstest.h b/tests/bindingstest.h
index 18a33a7..a262817 100644
--- a/tests/bindingstest.h
+++ b/tests/bindingstest.h
@@ -25,6 +25,7 @@ class BindingsTest : public QObject
void categorycolorConfigurationCompletness();
void dictionaryConfigurationCompletness();
void snippetConfigurationCompletness();
+ void tagConfigurationCompletness();
void noteCompletness();
void fileCompletness();
void eventCompletness();
diff --git a/tztable.h b/tztable.h
index f59eb1a..2b788c9 100644
--- a/tztable.h
+++ b/tztable.h
@@ -420,5 +420,5 @@ static const char* olsonTimezones[] = {
"Africa/Harare"
};
-static const int numOlsonTimezones = sizeof olsonTimezones / sizeof *olsonTimezones;
+static const long unsigned int numOlsonTimezones = sizeof olsonTimezones / sizeof *olsonTimezones;