presentation/AccountOverview.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | #include <QCoreApplication> | ||
| 3 | #include <QList> | ||
| 4 | #include <QString> | ||
| 5 | #include <QVariantList> | ||
| 6 | |||
| 7 | // Sprint 100 S100.1.5 (D-4, SF-03, SF-06): one entry per account for the | ||
| 8 | // Accounts page — a mail account with its linked calendar/contact (DAV) | ||
| 9 | // account, or a DAV-only account — with one status per service. Pure: the | ||
| 10 | // caller collects the facts, build() decides grouping and wording, so the | ||
| 11 | // rules are unit-tested without a session. | ||
| 12 | class AccountOverview final { | ||
| 13 | 8409 | Q_DECLARE_TR_FUNCTIONS(AccountOverview) | |
| 14 | public: | ||
| 15 | struct Mail { | ||
| 16 | QString id, name, email, imapHost, imapUsername, sieveMode; | ||
| 17 | }; | ||
| 18 | struct Dav { | ||
| 19 | QString id, serverUrl, username, mailAccountId; | ||
| 20 | int calendars = 0; // selected calendars and task lists | ||
| 21 | int books = 0; // selected address books | ||
| 22 | QString state; // QuickCalendarSync state: idle, running, error, unconfigured | ||
| 23 | QString error; // the sync error text when state == "error" | ||
| 24 | bool needsCredentials = false; | ||
| 25 | bool requiresAuthorization = false; // settings sync created it, no local password yet | ||
| 26 | int fresh = 0; // S100.4.8: collections new on the server (D-22) | ||
| 27 | }; | ||
| 28 | // State of the active account's mail connection and rule server. | ||
| 29 | struct Active { | ||
| 30 | QString accountId; | ||
| 31 | QString mailState; // "connected", "connecting", "offline", "needs-password", "error", "" | ||
| 32 | QString mailError; | ||
| 33 | QString rulesState; // QuickRulesBackend state | ||
| 34 | int enabledRules = 0; | ||
| 35 | bool vacation = false; | ||
| 36 | }; | ||
| 37 | static QVariantList build(const QList<Mail> &mails, const QList<Dav> &davs, const Active &active); | ||
| 38 | // A DAV account that is not linked but belongs to a mail account: same | ||
| 39 | // host family or the same login (D-4 "Belongs to …?"). Returns the mail id. | ||
| 40 | static QString linkSuggestion(const Dav &dav, const QList<Mail> &mails); | ||
| 41 | // Registrable domain of a host ("imap.mailbox.org" → "mailbox.org"). | ||
| 42 | static QString baseDomain(const QString &host); | ||
| 43 | private: | ||
| 44 | static QVariantMap mailService(const Mail &mail, const Active &active); | ||
| 45 | static QVariantMap rulesService(const Mail &mail, const Active &active); | ||
| 46 | static QVariantMap davService(const Dav *dav); | ||
| 47 | }; | ||
| 48 |