From 761328989492db9bd603c2d7f1134d20e485d2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Nicole?= Date: Tue, 27 Mar 2018 18:26:11 +0200 Subject: Add CalDAV support Summary: Notes: - Add a `webdavcommon` folder for WebDAV generic resource code - Move `davresource` to `carddaveresource` and make it use the WebDAV code - For now it tests the CalDAV resource directly on KolabNow (to be changed) - Only synchronization, not adding / changing / removing WebDAV collections or items (to be implemented) - Only events are currently supported (todo, freebusy, etc. are to be implemented but should be straightforward) Fixes T8224 Reviewers: cmollekopf Tags: #sink Maniphest Tasks: T8224 Differential Revision: https://phabricator.kde.org/D11741 --- common/CMakeLists.txt | 1 + common/domain/applicationdomaintype.cpp | 10 +++++++++- common/domain/applicationdomaintype.h | 24 ++++++++++++++++++------ common/domain/applicationdomaintype_p.h | 2 ++ common/domain/calendar.fbs | 8 ++++++++ common/domain/event.fbs | 3 ++- common/domain/typeimplementations.cpp | 25 ++++++++++++++++++++++++- common/domain/typeimplementations.h | 12 ++++++++++++ 8 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 common/domain/calendar.fbs (limited to 'common') diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 76579dd..9c4d4f1 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -104,6 +104,7 @@ generate_flatbuffers( domain/contact domain/addressbook domain/event + domain/calendar domain/mail domain/folder domain/dummy diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index ff2990d..9a213dd 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -395,7 +395,15 @@ SinkResource ImapResource::create(const QByteArray &account) SinkResource CardDavResource::create(const QByteArray &account) { auto &&resource = ApplicationDomainType::createEntity(); - resource.setResourceType("sink.dav"); + resource.setResourceType("sink.carddav"); + resource.setAccount(account); + return resource; +} + +SinkResource CalDavResource::create(const QByteArray &account) +{ + auto &&resource = ApplicationDomainType::createEntity(); + resource.setResourceType("sink.caldav"); resource.setAccount(account); return resource; } diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index d05e981..e05acaa 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -389,22 +389,24 @@ struct SINK_EXPORT Contact : public Entity { SINK_REFERENCE_PROPERTY(Addressbook, Addressbook, addressbook); }; +struct SINK_EXPORT Calendar : public Entity { + SINK_ENTITY(Calendar, calendar); + SINK_PROPERTY(QString, Name, name); +}; + struct SINK_EXPORT Event : public Entity { SINK_ENTITY(Event, event); SINK_PROPERTY(QString, Uid, uid); SINK_PROPERTY(QString, Summary, summary); SINK_PROPERTY(QString, Description, description); - SINK_PROPERTY(QByteArray, Attachment, attachment); + SINK_PROPERTY(QDateTime, StartTime, startTime); + SINK_REFERENCE_PROPERTY(Calendar, Calendar, calendar); }; struct SINK_EXPORT Todo : public Entity { SINK_ENTITY(Todo, todo); }; -struct SINK_EXPORT Calendar : public Entity { - SINK_ENTITY(Calendar, calendar); -}; - struct SINK_EXPORT Folder : public Entity { SINK_ENTITY(Folder, folder); SINK_REFERENCE_PROPERTY(Folder, Parent, parent); @@ -477,6 +479,10 @@ struct SINK_EXPORT CardDavResource { static SinkResource create(const QByteArray &account); }; +struct SINK_EXPORT CalDavResource { + static SinkResource create(const QByteArray &account); +}; + namespace ResourceCapabilities { namespace Mail { static constexpr const char *mail = "mail"; @@ -493,6 +499,11 @@ namespace Contact { static constexpr const char *addressbook = "addressbook"; static constexpr const char *storage = "contact.storage"; }; +namespace Event { + static constexpr const char *event = "event"; + static constexpr const char *calendar = "calendar"; + static constexpr const char *storage = "event.storage"; +}; }; namespace SpecialPurpose { @@ -522,7 +533,7 @@ bool SINK_EXPORT isGlobalType(const QByteArray &type); /** * Type implementation. - * + * * Needs to be implemented for every application domain type. * Contains all non-resource specific, but type-specific code. */ @@ -545,6 +556,7 @@ class SINK_EXPORT TypeImplementation; REGISTER_TYPE(Sink::ApplicationDomain::Contact) \ REGISTER_TYPE(Sink::ApplicationDomain::Addressbook) \ REGISTER_TYPE(Sink::ApplicationDomain::Event) \ + REGISTER_TYPE(Sink::ApplicationDomain::Calendar) \ REGISTER_TYPE(Sink::ApplicationDomain::Mail) \ REGISTER_TYPE(Sink::ApplicationDomain::Folder) \ REGISTER_TYPE(Sink::ApplicationDomain::SinkResource) \ diff --git a/common/domain/applicationdomaintype_p.h b/common/domain/applicationdomaintype_p.h index a60df38..734ac3e 100644 --- a/common/domain/applicationdomaintype_p.h +++ b/common/domain/applicationdomaintype_p.h @@ -38,6 +38,8 @@ struct TypeHelper { return Func{}(std::forward(args...)); } else if (type == Sink::ApplicationDomain::getTypeName()) { return Func{}(std::forward(args...)); + } else if (type == Sink::ApplicationDomain::getTypeName()) { + return Func{}(std::forward(args...)); } else if (type == Sink::ApplicationDomain::getTypeName()) { return Func{}(std::forward(args...)); } else if (type == Sink::ApplicationDomain::getTypeName()) { diff --git a/common/domain/calendar.fbs b/common/domain/calendar.fbs new file mode 100644 index 0000000..9788539 --- /dev/null +++ b/common/domain/calendar.fbs @@ -0,0 +1,8 @@ +namespace Sink.ApplicationDomain.Buffer; + +table Calendar { + name:string; +} + +root_type Calendar; +file_identifier "AKFB"; diff --git a/common/domain/event.fbs b/common/domain/event.fbs index 69148ef..68c8608 100644 --- a/common/domain/event.fbs +++ b/common/domain/event.fbs @@ -4,7 +4,8 @@ table Event { uid:string; summary:string; description:string; - attachment:[ubyte]; + startTime:string; + calendar:string; } root_type Event; diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp index 29da7ea..fe70d74 100644 --- a/common/domain/typeimplementations.cpp +++ b/common/domain/typeimplementations.cpp @@ -67,6 +67,11 @@ typedef IndexConfig > EventIndexConfig; +typedef IndexConfig + > CalendarIndexConfig; + + void TypeImplementation::configure(TypeIndex &index) { @@ -201,7 +206,8 @@ void TypeImplementation::configure(PropertyMapper &propertyMapper) SINK_REGISTER_SERIALIZER(propertyMapper, Event, Summary, summary); SINK_REGISTER_SERIALIZER(propertyMapper, Event, Description, description); SINK_REGISTER_SERIALIZER(propertyMapper, Event, Uid, uid); - SINK_REGISTER_SERIALIZER(propertyMapper, Event, Attachment, attachment); + SINK_REGISTER_SERIALIZER(propertyMapper, Event, StartTime, startTime); + SINK_REGISTER_SERIALIZER(propertyMapper, Event, Calendar, calendar); } void TypeImplementation::configure(IndexPropertyMapper &) @@ -209,3 +215,20 @@ void TypeImplementation::configure(IndexPropertyMapper &) } + +void TypeImplementation::configure(TypeIndex &index) +{ + CalendarIndexConfig::configure(index); +} + +QMap TypeImplementation::typeDatabases() +{ + return merge(QMap{{QByteArray{Calendar::name} + ".main", 0}}, CalendarIndexConfig::databases()); +} + +void TypeImplementation::configure(PropertyMapper &propertyMapper) +{ + SINK_REGISTER_SERIALIZER(propertyMapper, Calendar, Name, name); +} + +void TypeImplementation::configure(IndexPropertyMapper &) {} diff --git a/common/domain/typeimplementations.h b/common/domain/typeimplementations.h index d36dfc1..7a8a602 100644 --- a/common/domain/typeimplementations.h +++ b/common/domain/typeimplementations.h @@ -23,6 +23,7 @@ #include "mail_generated.h" #include "folder_generated.h" #include "event_generated.h" +#include "calendar_generated.h" #include "contact_generated.h" #include "addressbook_generated.h" @@ -94,5 +95,16 @@ public: static QMap typeDatabases(); }; +template<> +class TypeImplementation { +public: + typedef Sink::ApplicationDomain::Buffer::Calendar Buffer; + typedef Sink::ApplicationDomain::Buffer::CalendarBuilder BufferBuilder; + static void configure(TypeIndex &); + static void configure(PropertyMapper &); + static void configure(IndexPropertyMapper &indexPropertyMapper); + static QMap typeDatabases(); +}; + } } -- cgit v1.2.3