Commit b496bf23 authored by David Faure's avatar David Faure
Browse files

DAV resource: propagate color changes to the server

The resource didn't implement collectionChanged at all.

Now it does; saving colors work. I realized this meant renaming
folders didn't work either. But that's for another commit because
there are dragons due to the tree structure being flattened.

Depends on D28937 to actually trigger the collection modify job.

Test Plan:
Change color in korganizer, refresh roundcube, it shows the new color.

What I'm not sure about is what "Disable color" is supposed to do.
The code says "save an invalid color". OK... but what does it mean for the user?
Right now the calendar just gets some random color instead. What purpose does this serve?
Why not remove this action, which would remove a submenu i.e. improve usability?

Reviewers: dvratil, ochurlaud, vkrause, winterz, mlaurent

Reviewed By: dvratil

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision:
parent 29ebcd60
......@@ -30,6 +30,7 @@
#include <KDAV/DavCollection>
#include <KDAV/DavCollectionDeleteJob>
#include <KDAV/DavCollectionModifyJob>
#include <KDAV/DavCollectionsFetchJob>
#include <KDAV/DavCollectionsMultiFetchJob>
#include <KDAV/DavItem>
......@@ -591,6 +592,42 @@ void DavGroupwareResource::doItemRemoval(const Akonadi::Item &item)
void DavGroupwareResource::collectionChanged(const Collection &collection)
qCDebug(DAVRESOURCE_LOG) << "Collection changed" << collection.remoteId();
const KDAV::DavUrl davUrl = Settings::self()->davUrlFromCollectionUrl(collection.remoteId());
QColor color;
if (collection.hasAttribute<Akonadi::CollectionColorAttribute>()) {
const Akonadi::CollectionColorAttribute *colorAttr
= collection.attribute<Akonadi::CollectionColorAttribute>();
if (colorAttr) {
color = colorAttr->color();
KDAV::DavCollectionModifyJob *job = new KDAV::DavCollectionModifyJob(davUrl);
// TODO fix renaming calendars with parent folders, right now it makes a bit of a mess
//job->setProperty(QStringLiteral("displayname"), collection.displayName());
if (color.isValid()) {
job->setProperty(QStringLiteral("calendar-color"),, QStringLiteral(""));
connect(job, &KDAV::DavCollectionModifyJob::result, this, [=](KJob *job) {
onCollectionChangedFinished(job, collection);
void DavGroupwareResource::onCollectionChangedFinished(KJob *job, const Collection &collection)
if (job->error()) {
cancelTask(i18n("Unable to modify collection: %1", job->errorText()));
void DavGroupwareResource::doSetOnline(bool online)
qCDebug(DAVRESOURCE_LOG) << "Resource changed online status to" << online;
......@@ -70,6 +70,7 @@ protected:
void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override;
void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) override;
void itemRemoved(const Akonadi::Item &item) override;
void collectionChanged(const Akonadi::Collection &collection) override;
void doSetOnline(bool online) override;
......@@ -82,6 +83,7 @@ private:
KJob *createRetrieveCollectionsJob();
void onReloadConfig();
void onCollectionRemovedFinished(KJob *);
void onCollectionChangedFinished(KJob *job, const Akonadi::Collection &collection);
void onHandlesFreeBusy(const QString &email, bool handles);
void onFreeBusyRetrieved(const QString &email, const QString &freeBusy, bool success, const QString &errorText);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment