app/core/DavPushSource.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QList> | ||
| 4 | #include <QObject> | ||
| 5 | #include <QString> | ||
| 6 | #include <QStringList> | ||
| 7 | #include <functional> | ||
| 8 | |||
| 9 | #include "data/DavPushModels.h" | ||
| 10 | |||
| 11 | // Sprint 96 S96.6.2: one kind of DAV collection that push keeps fresh | ||
| 12 | // (calendars and task lists, address books). DavPushCoordinator owns the | ||
| 13 | // receiver, the registrations and the statistics of every kind; a source | ||
| 14 | // owns the data sync of its collections and reports what it discovered and | ||
| 15 | // synchronised. Collections are identified by (accountId, path); the paths | ||
| 16 | // of different kinds never collide (they are distinct DAV hrefs). | ||
| 17 | |||
| 18 | // One collection the user selected for sync. | ||
| 19 | struct DavPushSourceCollection { | ||
| 20 | QString path; | ||
| 21 | QString displayName; | ||
| 22 | bool readOnly = false; | ||
| 23 | }; | ||
| 24 | |||
| 25 | // The push offer read during a source's discovery. | ||
| 26 | struct DavPushDiscovery { | ||
| 27 | QString path; | ||
| 28 | DavPushOffer offer; | ||
| 29 | }; | ||
| 30 | |||
| 31 | // The end of one account run of a source. | ||
| 32 | struct DavPushSyncReport { | ||
| 33 | QString accountId; | ||
| 34 | QStringList syncedPaths; // completely synchronised (or unchanged) | ||
| 35 | QStringList failedPaths; // requested, but not completely synchronised | ||
| 36 | unsigned reasons = 0; // DavSyncReason bits of the run | ||
| 37 | }; | ||
| 38 | |||
| 39 | class DavPushSource : public QObject { | ||
| 40 | Q_OBJECT | ||
| 41 | public: | ||
| 42 | using QObject::QObject; | ||
| 43 | 1682 | ~DavPushSource() override = default; | |
| 44 | |||
| 45 | // "calendar" or "addressbook" (statistics, diagnostics, presentation). | ||
| 46 | virtual QString kind() const = 0; | ||
| 47 | // Collections selected for sync in this account, in display order. | ||
| 48 | virtual QList<DavPushSourceCollection> collections(const QString &accountId) const = 0; | ||
| 49 | // Background sync interval in minutes (0 = automatic sync paused). | ||
| 50 | virtual int intervalMinutes() const = 0; | ||
| 51 | // Read request: the given collections regardless of cached CTags, or the | ||
| 52 | // whole account including discovery when paths is empty. | ||
| 53 | virtual void requestSync(const QString &accountId, const QStringList &paths, unsigned reasons) = 0; | ||
| 54 | // Every configured account (resume, network back). | ||
| 55 | virtual void requestAll(unsigned reasons) = 0; | ||
| 56 | // Committed RFC 6578 token of a collection (push token no-op check). | ||
| 57 | virtual QString storedToken(const QString &accountId, const QString &path) const = 0; | ||
| 58 | // Own writes name our registration in Push-Dont-Notify (S96.3.7). | ||
| 59 | virtual void setPushDontNotifyProvider(std::function<QString(const QString &accountId, const QString &path)> provider) = 0; | ||
| 60 | // Known push failure: read this account more often until push is healthy. | ||
| 61 | virtual void setFallback(const QString &accountId, bool failing) = 0; | ||
| 62 | virtual bool inFallback(const QString &accountId) const = 0; | ||
| 63 | virtual bool syncRunning(const QString &accountId) const = 0; | ||
| 64 | |||
| 65 | signals: | ||
| 66 | void discovered(const QString &accountId, const QList<DavPushDiscovery> &collections); | ||
| 67 | // A read batch started with these explicitly requested collections. | ||
| 68 | void batchStarted(const QString &accountId, const QStringList &forcedPaths); | ||
| 69 | void syncFinished(const DavPushSyncReport &report); | ||
| 70 | }; | ||
| 71 |