summaryrefslogtreecommitdiff
path: root/src/kolabconversions.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/kolabconversions.h')
-rw-r--r--src/kolabconversions.h57
1 files changed, 57 insertions, 0 deletions
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");
}