data/DavPushSettings.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QString> | ||
| 4 | |||
| 5 | #include "DavPushModels.h" | ||
| 6 | |||
| 7 | // Sprint 96 S96.1.3/S96.1.5: the user's DAV-Push choices, kept in the | ||
| 8 | // profile's QSettings group "davpush/". The settings sync (SettingsCollector) | ||
| 9 | // copies an explicit key list and never this group, and | ||
| 10 | // DavAccountSettings::persist() rewrites only carddav/ and caldav/ arrays, | ||
| 11 | // so neither can drop or distribute these values (ADR-96-4). | ||
| 12 | // | ||
| 13 | // Keys: | ||
| 14 | // davpush/enabled application switch (default true) | ||
| 15 | // davpush/receiver/provider "ntfy" or "" (no push service chosen) | ||
| 16 | // davpush/receiver/server https origin of the push service | ||
| 17 | // davpush/receiver/public true when the user chose a public service | ||
| 18 | // davpush/receiver/hasToken a subscriber token is in the keyring | ||
| 19 | // davpush/policy/<selection key> "interval" (absent = automatic) | ||
| 20 | // davpush/useSystemService use a UnifiedPush D-Bus distributor | ||
| 21 | // (KUnifiedPush) when one runs (default true) | ||
| 22 | namespace DavPushSettings { | ||
| 23 | |||
| 24 | // The system push service (UnifiedPush D-Bus distributor); `server` is | ||
| 25 | // then the distributor's bus name. | ||
| 26 | inline const QString kSystemProvider = QStringLiteral("unifiedpush"); | ||
| 27 | |||
| 28 | struct Receiver { | ||
| 29 | 167 | QString provider; // "ntfy" or kSystemProvider; empty = not configured | |
| 30 | 128 | QString server; // normalised https origin (no path, no credentials) | |
| 31 | 125 | bool publicService = false; | |
| 32 | 125 | bool hasToken = false; | |
| 33 |
3/4✓ Branch 3 → 4 taken 376 times.
✓ Branch 3 → 7 taken 1141 times.
✓ Branch 5 → 6 taken 376 times.
✗ Branch 5 → 7 not taken.
|
1517 | bool isConfigured() const { return !provider.isEmpty() && !server.isEmpty(); } |
| 34 |
7/8✓ Branch 3 → 4 taken 39 times.
✓ Branch 3 → 5 taken 128 times.
✓ Branch 6 → 7 taken 3 times.
✓ Branch 6 → 8 taken 125 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 125 times.
✓ Branch 10 → 11 taken 1 time.
✓ Branch 10 → 12 taken 124 times.
|
167 | bool operator==(const Receiver &) const = default; |
| 35 | }; | ||
| 36 | |||
| 37 | inline const QString kPublicNtfyServer = QStringLiteral("https://ntfy.sh"); | ||
| 38 | |||
| 39 | bool enabled(); | ||
| 40 | void setEnabled(bool enabled); | ||
| 41 | |||
| 42 | bool useSystemService(); | ||
| 43 | void setUseSystemService(bool use); | ||
| 44 | |||
| 45 | Receiver receiver(); | ||
| 46 | // Validates and stores; false with `error` for a non-https or malformed URL. | ||
| 47 | bool setReceiver(const Receiver &receiver, QString *error = nullptr); | ||
| 48 | void clearReceiver(); | ||
| 49 | |||
| 50 | // The https origin of a push service URL ("" when invalid): scheme https, | ||
| 51 | // a host, no user info, no query/fragment; a trailing path is dropped. | ||
| 52 | QString normaliseServer(const QString &url); | ||
| 53 | |||
| 54 | DavPushPolicy policy(const QString &accountId, const QString &path); | ||
| 55 | void setPolicy(const QString &accountId, const QString &path, DavPushPolicy policy); | ||
| 56 | // Removes the policies of an account (account deleted). | ||
| 57 | void forgetAccount(const QString &accountId); | ||
| 58 | |||
| 59 | // "Automatic sync paused" (caldav/syncIntervalMin == 0): no receivers, no | ||
| 60 | // subscriptions and no automatic push syncs; manual sync stays possible. | ||
| 61 | bool backgroundSyncEnabled(); | ||
| 62 | |||
| 63 | } // namespace DavPushSettings | ||
| 64 |