Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'prop' into 'master'
[buteo-sync-plugin-caldav] Use notebook property to store the calendar path.

See merge request mer-core/buteo-sync-plugin-caldav!53
  • Loading branch information
chriadam committed Dec 2, 2019
2 parents 7675ea8 + 5f61a05 commit 61baa2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions rpm/buteo-sync-plugin-caldav.spec
Expand Up @@ -14,13 +14,12 @@ BuildRequires: pkgconfig(Qt5Network)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(libsignon-qt5)
BuildRequires: pkgconfig(libsailfishkeyprovider)
BuildRequires: pkgconfig(libmkcal-qt5)
BuildRequires: pkgconfig(libmkcal-qt5) >= 0.5.9
BuildRequires: pkgconfig(libkcalcoren-qt5)
BuildRequires: pkgconfig(buteosyncfw5)
BuildRequires: pkgconfig(accounts-qt5)
BuildRequires: pkgconfig(signon-oauth2plugin)
Requires: buteo-syncfw-qt5-msyncd
Requires: mkcal-qt5 >= 0.5.6

%description
A Buteo plugin which syncs calendar data from CalDAV services
Expand Down
9 changes: 7 additions & 2 deletions src/notebooksyncagent.cpp
Expand Up @@ -199,6 +199,7 @@ void NotebookSyncAgent::clearRequests()
mRequests.clear();
}

static const QByteArray PATH_PROPERTY = QByteArrayLiteral("remoteCalendarPath");
bool NotebookSyncAgent::setNotebookFromInfo(const QString &notebookName,
const QString &color,
const QString &accountId,
Expand All @@ -210,13 +211,15 @@ bool NotebookSyncAgent::setNotebookFromInfo(const QString &notebookName,
const mKCal::Notebook::List notebooks = mStorage->notebooks();
for (mKCal::Notebook::Ptr notebook : notebooks) {
if (notebook->account() == accountId
&& notebook->syncProfile().endsWith(QStringLiteral(":%1").arg(mRemoteCalendarPath))) {
&& (notebook->customProperty(PATH_PROPERTY) == mRemoteCalendarPath
|| notebook->syncProfile().endsWith(QStringLiteral(":%1").arg(mRemoteCalendarPath)))) {
LOG_DEBUG("found notebook:" << notebook->uid() << "for remote calendar:" << mRemoteCalendarPath);
if (!mStorage->loadNotebookIncidences(notebook->uid()))
return false;
mNotebook = notebook;
mNotebook->setColor(color);
mNotebook->setName(notebookName);
mNotebook->setSyncProfile(syncProfile);
return true;
}
}
Expand All @@ -225,7 +228,7 @@ bool NotebookSyncAgent::setNotebookFromInfo(const QString &notebookName,
mNotebook = mKCal::Notebook::Ptr(new mKCal::Notebook(notebookName, QString()));
mNotebook->setAccount(accountId);
mNotebook->setPluginName(pluginName);
mNotebook->setSyncProfile(syncProfile + ":" + mRemoteCalendarPath); // ugly hack because mkcal API is deficient. I wanted to use uid field but it won't save.
mNotebook->setSyncProfile(syncProfile);
mNotebook->setColor(color);
return true;
}
Expand Down Expand Up @@ -674,6 +677,8 @@ bool NotebookSyncAgent::applyRemoteChanges()
notebook->setSyncDate(mNotebookSyncedDateTime);
notebook->setName(mNotebook->name());
notebook->setColor(mNotebook->color());
notebook->setSyncProfile(mNotebook->syncProfile());
notebook->setCustomProperty(PATH_PROPERTY, mRemoteCalendarPath);
if (!mStorage->updateNotebook(notebook)) {
LOG_WARNING("Cannot update notebook" << notebook->name() << "in storage.");
return false;
Expand Down

0 comments on commit 61baa2a

Please sign in to comment.