data/DavPushModels.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QByteArray> | ||
| 4 | #include <QString> | ||
| 5 | |||
| 6 | // Sprint 96 S96.1.1: DAV-Push vocabulary shared by discovery, persistence, | ||
| 7 | // the coordinator and the presentation. Plain values, no behaviour. | ||
| 8 | // | ||
| 9 | // A collection is identified by (accountId, path) — the DAV href as the | ||
| 10 | // calendar discovery stores it (calendarSelectionKey()). Server topic, | ||
| 11 | // receiver identity and registration URL are separate from that identity. | ||
| 12 | |||
| 13 | // What the server offers for one collection (SPRINT-96.md §3.1). | ||
| 14 | enum class DavPushCapability { | ||
| 15 | Unknown, // not checked yet, or the account/endpoint changed | ||
| 16 | Supported, // valid topic and a usable Web Push transport | ||
| 17 | Unsupported, // successful discovery without a push offer | ||
| 18 | Incompatible, // offered, but transport/key/trigger unusable | ||
| 19 | ProbeError, // timeout/TLS/auth/broken response: no negative result | ||
| 20 | }; | ||
| 21 | |||
| 22 | // The user's per-calendar choice (§3.2). Automatic is the default. | ||
| 23 | enum class DavPushPolicy { Automatic, IntervalOnly }; | ||
| 24 | |||
| 25 | // Interop profile the offer was recognised as (ADR-96-2). | ||
| 26 | enum class DavPushProfile { None, NextcloudLegacy, Draft }; | ||
| 27 | |||
| 28 | struct DavPushOffer { | ||
| 29 | DavPushCapability capability = DavPushCapability::Unknown; | ||
| 30 | DavPushProfile profile = DavPushProfile::None; | ||
| 31 | QString topic; // opaque; only compared within one account | ||
| 32 | QByteArray vapidPublicKey; // 65-byte uncompressed point ("" = none offered) | ||
| 33 | QString reason; // technical explanation (details/diagnostics) | ||
| 34 | bool operator==(const DavPushOffer &) const = default; | ||
| 35 | }; | ||
| 36 | |||
| 37 | // Lifecycle of the own registration for one collection (§3.3). | ||
| 38 | enum class DavPushRegistrationState { | ||
| 39 | None, // not registered (policy, capability or receiver missing) | ||
| 40 | Registering, // POST in flight | ||
| 41 | Active, // confirmed Location + Expires, not expired | ||
| 42 | Failed, // last attempt failed; retry scheduled | ||
| 43 | Removing, // DELETE in flight / queued | ||
| 44 | }; | ||
| 45 | |||
| 46 | // The receiver (push service connection) of one account (§2.2). | ||
| 47 | enum class DavPushReceiverState { | ||
| 48 | NotConfigured, // no push service chosen: polling only | ||
| 49 | Stopped, // not needed / paused (offline, suspend, background off) | ||
| 50 | Connecting, | ||
| 51 | Connected, // provider stream open (open/keepalive seen) | ||
| 52 | Backoff, // reconnect scheduled after an error | ||
| 53 | Failed, // needs action (credentials, TLS, crypto unavailable) | ||
| 54 | }; | ||
| 55 | |||
| 56 | // Why a collection is synchronised (§4.2); a bit set per dirty mark. | ||
| 57 | enum DavSyncReason : unsigned { | ||
| 58 | DavSyncReasonNone = 0, | ||
| 59 | DavSyncReasonPush = 1u << 0, | ||
| 60 | DavSyncReasonPoll = 1u << 1, | ||
| 61 | DavSyncReasonRecovery = 1u << 2, | ||
| 62 | DavSyncReasonManual = 1u << 3, | ||
| 63 | DavSyncReasonInitial = 1u << 4, | ||
| 64 | }; | ||
| 65 | |||
| 66 | 411 | inline QString davPushCapabilityName(DavPushCapability capability) { | |
| 67 |
3/6✓ Branch 2 → 3 taken 307 times.
✓ Branch 2 → 8 taken 100 times.
✗ Branch 2 → 13 not taken.
✗ Branch 2 → 18 not taken.
✓ Branch 2 → 23 taken 4 times.
✗ Branch 2 → 24 not taken.
|
411 | switch (capability) { |
| 68 | 614 | case DavPushCapability::Supported: return QStringLiteral("supported"); | |
| 69 | 200 | case DavPushCapability::Unsupported: return QStringLiteral("unsupported"); | |
| 70 | ✗ | case DavPushCapability::Incompatible: return QStringLiteral("incompatible"); | |
| 71 | ✗ | case DavPushCapability::ProbeError: return QStringLiteral("probe-error"); | |
| 72 | 4 | case DavPushCapability::Unknown: break; | |
| 73 | } | ||
| 74 | 4 | return QStringLiteral("unknown"); | |
| 75 | } | ||
| 76 | |||
| 77 | 1848 | inline DavPushCapability davPushCapabilityFromName(const QString &name) { | |
| 78 |
2/2✓ Branch 4 → 5 taken 1445 times.
✓ Branch 4 → 6 taken 403 times.
|
1848 | if (name == QLatin1String("supported")) return DavPushCapability::Supported; |
| 79 |
2/2✓ Branch 8 → 9 taken 402 times.
✓ Branch 8 → 10 taken 1 time.
|
403 | if (name == QLatin1String("unsupported")) return DavPushCapability::Unsupported; |
| 80 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 1 time.
|
1 | if (name == QLatin1String("incompatible")) return DavPushCapability::Incompatible; |
| 81 |
1/2✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 1 time.
|
1 | if (name == QLatin1String("probe-error")) return DavPushCapability::ProbeError; |
| 82 | 1 | return DavPushCapability::Unknown; | |
| 83 | } | ||
| 84 |