Commit 126af928 authored by chriadam's avatar chriadam

[buteo-sync-plugins-social] Use SyncToken for Google Calendar delta sync. Contributes to JB#44316

Previously, we used updatedMin timestamp "since" anchor to fetch
changes since last sync.  This commit updates the plugin so that
it uses the "sync token" which Google provides, so that we can
more accurately fetch changes since the last sync, and avoid
the "updatedMin too far in the past" problem which can be hit in
certain circumstances.

We store the sync tokens as account settings, as mkcal doesn't
allow arbitrary metadata to be stored for notebooks.
parent 83cc4294
......@@ -83,7 +83,7 @@ private:
void requestCalendars(int accountId, const QString &accessToken,
bool needCleanSync, const QString &pageToken = QString());
void requestEvents(int accountId, const QString &accessToken,
const QString &calendarId, bool needCleanSync,
const QString &calendarId, const QString &syncToken,
const QString &pageToken = QString());
void updateLocalCalendarNotebooks(int accountId, const QString &accessToken, bool needCleanSync);
QList<UpsyncChange> determineSyncDelta(int accountId, const QString &accessToken,
......@@ -97,7 +97,10 @@ private:
void updateLocalCalendarNotebookEvents(int accountId, const QString &calendarId);
mKCal::Notebook::Ptr notebookForCalendarId(int accountId, const QString &calendarId) const;
void finishedRequestingRemoteEvents(int accountId, const QString &accessToken, const QString &calendarId, const QDateTime &since, const QString &updateTimestampStr);
void finishedRequestingRemoteEvents(int accountId, const QString &accessToken,
const QString &calendarId, const QString &syncToken,
const QString &nextSyncToken, const QDateTime &since,
const QString &updateTimestampStr);
private Q_SLOTS:
void calendarsFinishedHandler();
......@@ -124,6 +127,8 @@ private:
QStringList m_calendarsBeingRequested; // calendarIds
QMap<QString, QString> m_calendarsFinishedRequested; // calendarId to updated timestamp string
QMap<QString, QString> m_calendarsThisSyncTokens; // calendarId to sync token used during this sync cycle
QMap<QString, QString> m_calendarsNextSyncTokens; // calendarId to sync token to use during next sync cycle
QMultiMap<QString, QPair<GoogleCalendarSyncAdaptor::ChangeType, QJsonObject> > m_changesFromDownsync; // calendarId to change
QMultiMap<QString, QPair<KCalCore::Event::Ptr, QJsonObject> > m_changesFromUpsync; // calendarId to event+upsyncResponse
......
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