summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2014-10-02 21:17:15 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2014-10-02 21:17:15 (GMT)
commitd6a1909b71df2940c232efc4a1747659088d9543 (patch)
treee005cc994d1d7bbde613ac88a22e26cd81bfe08e
parent26da268b0ec94e1c3c1e0c3f71aef617d8e90400 (diff)
downloadlibkolabxml-d6a1909b71df2940c232efc4a1747659088d9543.tar.gz
Added support for the FileDriver Configuration object.
-rw-r--r--schemas/kolabformat.xsd6
-rw-r--r--src/containers/kolabconfiguration.cpp13
-rw-r--r--src/containers/kolabconfiguration.h36
-rw-r--r--src/kolabconversions.h24
-rw-r--r--tests/bindingstest.cpp23
-rw-r--r--tests/bindingstest.h1
6 files changed, 102 insertions, 1 deletions
diff --git a/schemas/kolabformat.xsd b/schemas/kolabformat.xsd
index 9604b2e..46697f6 100644
--- a/schemas/kolabformat.xsd
+++ b/schemas/kolabformat.xsd
@@ -103,6 +103,7 @@
<xs:enumeration value="categorycolor"/>
<xs:enumeration value="snippets"/>
<xs:enumeration value="relation"/>
+ <xs:enumeration value="file_driver"/>
</xs:restriction>
</xs:simpleType>
@@ -165,6 +166,11 @@
<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"/>
+ <!-- FileDriver -->
+ <xs:element name="driver" type="xs:string" minOccurs="0"/>
+ <xs:element name="title" type="xs:string" minOccurs="0"/>
+ <xs:element name="enabled" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="settings" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
diff --git a/src/containers/kolabconfiguration.cpp b/src/containers/kolabconfiguration.cpp
index e6a26ee..2605544 100644
--- a/src/containers/kolabconfiguration.cpp
+++ b/src/containers/kolabconfiguration.cpp
@@ -26,6 +26,7 @@ struct Configuration::Private {
Dictionary dictionary;
SnippetsCollection snippets;
Relation relation;
+ FileDriver fileDriver;
ConfigurationType type;
std::string uid;
cDateTime created;
@@ -65,6 +66,13 @@ Configuration::Configuration(const Relation &relation)
d->type = TypeRelation;
}
+Configuration::Configuration(const FileDriver &fileDriver)
+: d(new Configuration::Private)
+{
+ d->fileDriver = fileDriver;
+ d->type = TypeFileDriver;
+}
+
Configuration::Configuration(const Configuration &other)
: d(new Configuration::Private)
{
@@ -142,4 +150,9 @@ Relation Configuration::relation() const
return d->relation;
}
+FileDriver Configuration::fileDriver() const
+{
+ return d->fileDriver;
+}
+
} //Namespace
diff --git a/src/containers/kolabconfiguration.h b/src/containers/kolabconfiguration.h
index 2d8f9e8..7b5c106 100644
--- a/src/containers/kolabconfiguration.h
+++ b/src/containers/kolabconfiguration.h
@@ -150,6 +150,36 @@ private:
std::vector<std::string> mMembers;
};
+struct FileDriver {
+ FileDriver(): mEnabled(false) {}
+ FileDriver(const std::string &driver, const std::string &title): mDriver(driver), mTitle(title), mEnabled(true) {}
+
+ bool operator==(const FileDriver &other) const {
+ return mDriver == other.mDriver
+ && mTitle == other.mTitle
+ && mEnabled == other.mEnabled
+ && mSettings == other.mSettings;
+ }
+
+ void setDriver(const std::string &driver) { mDriver = driver; }
+ std::string driver() const { return mDriver; }
+
+ void setTitle(const std::string &title) { mTitle = title; }
+ std::string title() const { return mTitle; }
+
+ void setEnabled(bool enabled) { mEnabled = enabled; }
+ bool enabled() const { return mEnabled; }
+
+ void setSettings(const std::string &settings) { mSettings = settings; }
+ std::string settings() const { return mSettings; }
+
+private:
+ std::string mDriver;
+ std::string mTitle;
+ bool mEnabled;
+ std::string mSettings;
+};
+
class Configuration {
public:
Configuration();
@@ -157,6 +187,7 @@ public:
Configuration(const Dictionary &);
Configuration(const SnippetsCollection &);
Configuration(const Relation &);
+ Configuration(const FileDriver &);
Configuration(const Configuration &);
~Configuration();
void operator=(const Configuration &);
@@ -177,13 +208,16 @@ public:
TypeDictionary,
TypeCategoryColor,
TypeSnippet,
- TypeRelation
+ TypeRelation,
+ TypeFileDriver
};
ConfigurationType type() const;
std::vector<CategoryColor> categoryColor() const;
Dictionary dictionary() const;
SnippetsCollection snippets() const;
Relation relation() const;
+ FileDriver fileDriver() const;
+
private:
struct Private;
boost::scoped_ptr<Private> d;
diff --git a/src/kolabconversions.h b/src/kolabconversions.h
index cfd0e7b..05e3064 100644
--- a/src/kolabconversions.h
+++ b/src/kolabconversions.h
@@ -138,6 +138,8 @@ KolabXSD::Configuration::type_type getConfigurationType(Kolab::Configuration::Co
return KolabXSD::Configuration::type_type::snippets;
case Kolab::Configuration::TypeRelation:
return KolabXSD::Configuration::type_type::relation;
+ case Kolab::Configuration::TypeFileDriver:
+ return KolabXSD::Configuration::type_type::file_driver;
default:
CRITICAL("Invalid configuration type");
}
@@ -221,6 +223,14 @@ std::string serializeObject <Kolab::Configuration> (const Kolab::Configuration &
}
}
break;
+ case Kolab::Configuration::TypeFileDriver: {
+ const Kolab::FileDriver &fileDriver = configuration.fileDriver();
+ n.driver(fileDriver.driver());
+ n.title(fileDriver.title());
+ n.enabled(fileDriver.enabled());
+ n.settings(fileDriver.settings());
+ }
+ break;
default:
CRITICAL("Invalid configuration type");
return std::string();
@@ -572,6 +582,20 @@ boost::shared_ptr<Kolab::Configuration> deserializeObject <Kolab::Configuration>
relation.setMembers(toStringList(configuration->member()));
n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(relation));
+ } else if (configuration->type() == KolabXSD::ConfigurationType::file_driver) {
+ std::string driver;
+ if (configuration->driver()) {
+ driver = *configuration->driver();
+ }
+ std::string title;
+ if (configuration->title()) {
+ title = *configuration->title();
+ }
+ Kolab::FileDriver fileDriver(driver, title);
+ fileDriver.setEnabled(*configuration->enabled());
+ fileDriver.setSettings(*configuration->settings());
+
+ n = boost::shared_ptr<Kolab::Configuration>(new Kolab::Configuration(fileDriver));
} else {
CRITICAL("No valid configuration type");
}
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index 8dd2bd5..5b5718e 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -134,6 +134,29 @@ void BindingsTest::relationConfigurationCompletness()
QCOMPARE(re.relation(), relation);
}
+void BindingsTest::fileDriverConfigurationCompletness()
+{
+ Kolab::FileDriver fileDriver("driver", "title");
+ fileDriver.setEnabled(false);
+ fileDriver.setSettings("settings");
+
+ Kolab::Configuration configuration(fileDriver);
+ 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::TypeFileDriver);
+ QCOMPARE(re.fileDriver(), fileDriver);
+}
+
void BindingsTest::noteCompletness()
{
Kolab::Note note;
diff --git a/tests/bindingstest.h b/tests/bindingstest.h
index b2dfd43..6560882 100644
--- a/tests/bindingstest.h
+++ b/tests/bindingstest.h
@@ -26,6 +26,7 @@ class BindingsTest : public QObject
void dictionaryConfigurationCompletness();
void snippetConfigurationCompletness();
void relationConfigurationCompletness();
+ void fileDriverConfigurationCompletness();
void noteCompletness();
void fileCompletness();
void eventCompletness();