app/core/ContactPushSource.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QElapsedTimer> | ||
| 4 | #include <QHash> | ||
| 5 | #include <QTimer> | ||
| 6 | |||
| 7 | #include "DavPushSource.h" | ||
| 8 | |||
| 9 | class ContactSyncCoordinator; | ||
| 10 | |||
| 11 | // Sprint 96 S96.6.2 (DAVPUSH-CARDDAV): address books as a DAV-Push source. | ||
| 12 | // Adapts ContactSyncCoordinator (Sprint 97 incremental CardDAV sync): push | ||
| 13 | // notices become runs of just the announced books, offers are read with | ||
| 14 | // the books' properties in every run, own vCard writes name the book's | ||
| 15 | // registration. Fallback after a push failure: one immediate catch-up run | ||
| 16 | // of the account, then every fallbackPollMs within fallbackWindowMs (the | ||
| 17 | // same 60 s / 15 min as the calendar scheduler), then the normal interval. | ||
| 18 | class ContactPushSource final : public DavPushSource { | ||
| 19 | Q_OBJECT | ||
| 20 | public: | ||
| 21 | struct Timing { | ||
| 22 | int fallbackPollMs = 60000; | ||
| 23 | int fallbackWindowMs = 15 * 60000; | ||
| 24 | }; | ||
| 25 | |||
| 26 | explicit ContactPushSource(ContactSyncCoordinator *contacts, QObject *parent = nullptr); | ||
| 27 | |||
| 28 | 188 | QString kind() const override { return QStringLiteral("addressbook"); } | |
| 29 | QList<DavPushSourceCollection> collections(const QString &accountId) const override; | ||
| 30 | int intervalMinutes() const override; | ||
| 31 | void requestSync(const QString &accountId, const QStringList &paths, unsigned reasons) override; | ||
| 32 | void requestAll(unsigned reasons) override; | ||
| 33 | QString storedToken(const QString &accountId, const QString &path) const override; | ||
| 34 | void setPushDontNotifyProvider(std::function<QString(const QString &, const QString &)> provider) override; | ||
| 35 | void setFallback(const QString &accountId, bool failing) override; | ||
| 36 | bool inFallback(const QString &accountId) const override; | ||
| 37 | bool syncRunning(const QString &accountId) const override; | ||
| 38 | |||
| 39 | 3 | void setTiming(Timing timing) { m_timing = timing; } | |
| 40 | |||
| 41 | private: | ||
| 42 | void pollFallback(); | ||
| 43 | |||
| 44 | ContactSyncCoordinator *m_contacts = nullptr; | ||
| 45 | Timing m_timing; | ||
| 46 | QTimer m_fallbackTimer; | ||
| 47 | QElapsedTimer m_clock; | ||
| 48 | QHash<QString, qint64> m_fallbackUntil; // account -> monotonic ms | ||
| 49 | }; | ||
| 50 |