MailJDTourDownloadDocsQualityTestsCoverage

Which source lines and branches the tests execute. Lines 91.5 %, branches 75.0 % (minimum 85 % and 72 %). main @ 399ffe3d · 21 October 2026 · pipeline 7238.

GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 2 / 0 / 2
Functions: 100.0% 2 / 0 / 2
Branches: -% 0 / 0 / 0

data/IdentityStore.h
Line Branch Exec Source
1 #pragma once
2
3 #include <QJsonObject>
4 #include <QList>
5 #include <QString>
6 #include <optional>
7 #include <vector>
8
9 struct AccountConfig;
10
11 // Sprint 108 S108.5.4 (D-15, D-16): sender identities and their signatures.
12 //
13 // Every mail account has one or more identities (name, address — the
14 // account's own or an alias —, optional Reply-To, default format, always-Bcc
15 // and plain-text wrapping), each with any number of named signatures. One
16 // signature is the default for new mails and one for replies/forwards (the
17 // same, or none).
18 //
19 // Stored in <profile>/identities.json (owner-only, atomic, bounded): a file
20 // of its own instead of the account files, so the credential migration of
21 // AccountConfig stays untouched. Identities name their account by id for
22 // this installation and by account address + server for settings sync
23 // (ids differ between installations).
24 struct Signature {
25 QString id;
26 QString name; // "Formal", "Short", …
27 QString html; // body fragment written by MailHtmlWriter (images as cid: of embedded parts)
28 QString text; // the plain version (generated unless overridden)
29 bool textOverridden = false;
30 };
31
32 struct Identity {
33 QString id;
34 QString accountId;
35 QString accountAddress; // the account's own address (sync matching)
36 QString accountServer; // the account's IMAP host (sync matching)
37 QString accountName; // the account's "Your name" when last seen: the
38 // default identity's name follows it until edited
39 QString name; // shown to receivers
40 QString email;
41 QString replyTo;
42 bool formattedByDefault = false; // D-4: the shipped default is plain text
43 bool bccSelf = false;
44 bool wrapPlainText = false; // D-10: wrap at 72 characters when sending
45 QList<Signature> signatures;
46 QString newMailSignatureId; // "" = none
47 QString replySignatureId; // "" = none
48 bool isDefault = false; // the account's default identity
49 };
50
51 class IdentityStore {
52 public:
53 static constexpr qint64 MaxFileBytes = 4 * 1024 * 1024;
54 static constexpr int MaxIdentities = 200;
55 static constexpr int MaxSignaturesPerIdentity = 20;
56 static constexpr qint64 MaxSignatureBytes = 512 * 1024;
57
58 1601 explicit IdentityStore(QString path = {}) : m_path(std::move(path)) {}
59 static QString pathFor(const QString &profileDirectory);
60
61 // Reads the file (missing file = no identities). A malformed or oversized
62 // file is refused as a whole and reported through `error`.
63 bool load(QString *error = nullptr);
64 bool save(QString *error = nullptr) const;
65
66 // D-15 migration: every account without an identity gets one from its
67 // address and name; identities of removed accounts are dropped. Returns
68 // whether anything changed.
69 bool reconcile(const std::vector<AccountConfig> &accounts);
70
71 5615 const QList<Identity> &identities() const { return m_identities; }
72 QList<Identity> identitiesFor(const QString &accountId) const;
73 std::optional<Identity> find(const QString &identityId) const;
74 std::optional<Identity> defaultFor(const QString &accountId) const;
75 // Inserts or replaces by id; a new default demotes the account's others.
76 bool upsert(const Identity &identity);
77 bool remove(const QString &identityId);
78
79 static QJsonObject toJson(const Identity &identity);
80 static std::optional<Identity> fromJson(const QJsonObject &object);
81
82 private:
83 QString m_path;
84 QList<Identity> m_identities;
85 };
86