Branch data Line data Source code
1 : : #pragma once
2 : :
3 : : #include <QDateTime>
4 : : #include <QString>
5 : : #include <QStringList>
6 : :
7 : : // FolderInfo represents a single IMAP mailbox from the LIST response.
8 : : // Used to populate the FolderTree UI.
9 : : struct FolderInfo {
10 : : QString name; // Display name, UTF-8 decoded (e.g. "Entwürfe")
11 : : QString path; // Raw IMAP path (e.g. "INBOX.Entw&APw-rfe")
12 : : QStringList flags; // IMAP flags: \HasChildren, \Noselect, \Sent, etc.
13 : : QString delimiter; // Hierarchy delimiter: "." or "/"
14 : :
15 : : // Convenience: check for common flags
16 : 3 : bool hasChildren() const {
17 [ + - ]: 3 : return flags.contains("\\HasChildren", Qt::CaseInsensitive);
18 : : }
19 : 130 : bool isNoselect() const {
20 [ + - + + : 387 : return flags.contains("\\Noselect", Qt::CaseInsensitive) ||
+ + - - ]
21 [ + - + + : 387 : flags.contains("\\NonExistent", Qt::CaseInsensitive);
+ - - - ]
22 : : }
23 [ + - ]: 475 : bool isSent() const { return flags.contains("\\Sent", Qt::CaseInsensitive); }
24 : 457 : bool isDrafts() const {
25 [ + - ]: 457 : return flags.contains("\\Drafts", Qt::CaseInsensitive);
26 : : }
27 : 454 : bool isTrash() const {
28 [ + - ]: 454 : return flags.contains("\\Trash", Qt::CaseInsensitive);
29 : : }
30 : 444 : bool isArchive() const {
31 [ + - ]: 444 : return flags.contains("\\Archive", Qt::CaseInsensitive);
32 : : }
33 [ + - ]: 442 : bool isJunk() const { return flags.contains("\\Junk", Qt::CaseInsensitive); }
34 : : };
35 : :
36 : : // Flag bitmask constants for MailHeader::flags.
37 : : // Values match IMAP system flag semantics.
38 : : namespace MailFlag {
39 : : constexpr quint32 None = 0;
40 : : constexpr quint32 Seen = 1 << 0; // \Seen
41 : : constexpr quint32 Answered = 1 << 1; // \Answered
42 : : constexpr quint32 Flagged = 1 << 2; // \Flagged
43 : : constexpr quint32 Deleted = 1 << 3; // \Deleted
44 : : constexpr quint32 Draft = 1 << 4; // \Draft
45 : : } // namespace MailFlag
46 : :
47 : : // MailHeader represents the envelope data of a single email.
48 : : // Stored in SQLite cache for offline access and fast listing.
49 : : struct MailHeader {
50 : : qint64 uid = 0; // IMAP UID (unique within a folder's UIDVALIDITY)
51 : : qint64 folderId = 0; // FK to MailCache folders table
52 : : QString subject;
53 : : QString from;
54 : : QString to;
55 : : QDateTime date;
56 : : quint32 flags = MailFlag::None; // Bitmask of MailFlag constants
57 : : qint64 size = 0; // RFC822.SIZE in bytes
58 : : QStringList labels; // IMAP keywords (non-system flags)
59 : : bool hasAttachments = false; // Cached: has body attachments?
60 : : bool isSpam = false; // T-231: X-Spam: Yes header detected
61 : : QString messageId; // Message-ID header (without <>)
62 : : QString inReplyTo; // In-Reply-To header (without <>)
63 : : QStringList references; // References header (list of message-ids)
64 : :
65 : : // Flag convenience methods
66 : 185835 : bool isSeen() const { return flags & MailFlag::Seen; }
67 : 6873 : bool isAnswered() const { return flags & MailFlag::Answered; }
68 : 8457 : bool isFlagged() const { return flags & MailFlag::Flagged; }
69 : 6 : bool isDraft() const { return flags & MailFlag::Draft; }
70 : : };
71 : :
72 : : struct MailIdentity {
73 : : QString account;
74 : : qint64 folderId = -1;
75 : : qint64 uid = -1;
76 : :
77 [ + + + + ]: 9 : bool isValid() const { return folderId > 0 && uid >= 0; }
78 : : };
79 : :
80 : : // Attachment metadata for a single email attachment.
81 : : // BLOB data is loaded on-demand from MailCache (lazy loading).
82 : : struct Attachment {
83 : : qint64 id = 0; // DB primary key (0 = not yet stored)
84 : : QString filename; // e.g. "report.pdf"
85 : : QString contentType; // e.g. "application/pdf"
86 : : qint64 size = 0; // Decoded size in bytes
87 : : QString contentId; // Content-ID for inline attachments (without <>)
88 : : };
89 : :
90 : : // MailBody holds the content of a single email.
91 : : // textHtml contains decoded HTML if the message had a text/html part.
92 : : struct MailBody {
93 : : qint64 uid = 0;
94 : : QString textPlain; // Decoded text/plain body (UTF-8)
95 : : QString textHtml; // Decoded text/html body (UTF-8), empty if none
96 : : QByteArray rawSource; // Original raw MIME source (headers + body)
97 : : QList<Attachment> attachments; // Attachment metadata (no BLOB data)
98 : : };
99 : :
100 : : // Result of an IMAP STATUS command (MESSAGES, UNSEEN, RECENT counts).
101 : : struct StatusResult {
102 : : QString folderPath;
103 : : int messages = 0;
104 : : int unseen = 0;
105 : : int recent = 0;
106 : : };
107 : :
108 : : // T-154: Contact entry for the local contact store.
109 : : // Used for autocomplete, @-mentions, and CardDAV sync.
110 : : struct Contact {
111 : : qint64 id = 0; // DB primary key
112 : : QString displayName; // "Max Mustermann"
113 : : QString email; // "max@example.com"
114 : : QString source; // "local" or "carddav"
115 : : QString cardDavUid; // CardDAV UID (empty for local contacts)
116 : : QString cardDavEtag; // CardDAV ETag for sync
117 : : QDateTime lastUsed; // Last time used as recipient
118 : : int useCount = 0; // How often used as recipient
119 : : QDateTime createdAt;
120 : : QDateTime updatedAt;
121 : : };
|