summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2014-10-03 12:01:39 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2014-10-03 12:07:44 (GMT)
commit67b9e58b437b4d69322c3aaf56d57176916ed931 (patch)
tree41d4ed8718e01eff172ac406dd34e6b36cef3457
parent318ddeee3c030f908935ab782afc5c4668b24156 (diff)
downloadlibkolabxml-67b9e58b437b4d69322c3aaf56d57176916ed931.tar.gz
Added support for the FileDriver Configuration object.
Conflicts: schemas/kolabformat.xsd src/containers/kolabconfiguration.cpp src/containers/kolabconfiguration.h src/kolabconversions.h tests/bindingstest.cpp tests/bindingstest.h
-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 d12134b..9ff933f 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="file_driver"/>
</xs:restriction>
</xs:simpleType>
@@ -156,6 +157,11 @@
<!-- Snippets -->
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="snippet" type="Snippet" 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 afe8a7d..e71c209 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;
+ FileDriver fileDriver;
ConfigurationType type;
std::string uid;
cDateTime created;
@@ -57,6 +58,13 @@ Configuration::Configuration(const SnippetsCollection &snippets)
d->type = TypeSnippet;
}
+Configuration::Configuration(const FileDriver &fileDriver)
+: d(new Configuration::Private)
+{
+ d->fileDriver = fileDriver;
+ d->type = TypeFileDriver;
+}
+
Configuration::Configuration(const Configuration &other)
: d(new Configuration::Private)
{
@@ -129,4 +137,9 @@ SnippetsCollection Configuration::snippets() const
return d->snippets;
}
+FileDriver Configuration::fileDriver() const
+{
+ return d->fileDriver;
+}
+
} //Namespace
diff --git a/src/containers/kolabconfiguration.h b/src/containers/kolabconfiguration.h
index 330167c..6a27be6 100644
--- a/src/containers/kolabconfiguration.h
+++ b/src/containers/kolabconfiguration.h
@@ -109,12 +109,43 @@ private:
std::vector<Snippet> mSnippets;
};
+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();
Configuration(const std::vector<CategoryColor> &);
Configuration(const Dictionary &);
Configuration(const SnippetsCollection &);
+ Configuration(const FileDriver &);
Configuration(const Configuration &);
~Configuration();
void operator=(const Configuration &);
@@ -134,12 +165,15 @@ public:
Invalid,
TypeDictionary,
TypeCategoryColor,
- TypeSnippet
+ TypeSnippet,
+ TypeFileDriver
};
ConfigurationType type() const;
std::vector<CategoryColor> categoryColor() const;
Dictionary dictionary() const;
SnippetsCollection snippets() const;
+ FileDriver fileDriver() const;
+
private:
struct Private;
boost::scoped_ptr<Private> d;
diff --git a/src/kolabconversions.h b/src/kolabconversions.h
index 39afc05..20e91c1 100644
--- a/src/kolabconversions.h
+++ b/src/kolabconversions.h
@@ -129,6 +129,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::TypeFileDriver:
+ return KolabXSD::Configuration::type_type::file_driver;
default:
CRITICAL("Invalid configuration type");
}
@@ -189,6 +191,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();
@@ -515,6 +525,20 @@ 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::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 2aad2b9..ed7f203 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -105,6 +105,29 @@ void BindingsTest::snippetConfigurationCompletness()
QCOMPARE(re.snippets(), snippets);
}
+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 18a33a7..2d85a72 100644
--- a/tests/bindingstest.h
+++ b/tests/bindingstest.h
@@ -25,6 +25,7 @@ class BindingsTest : public QObject
void categorycolorConfigurationCompletness();
void dictionaryConfigurationCompletness();
void snippetConfigurationCompletness();
+ void fileDriverConfigurationCompletness();
void noteCompletness();
void fileCompletness();
void eventCompletness();