Code
·
131 lines
·
4890 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131namespace MailSharp.MailClient.Models;
public enum FolderSyncMode
{
NotSynchronized,
NewHeaders,
AllHeaders,
NewMessages,
AllMessages,
Direct
}
// Per-account override of a folder's sync mode/subscription, keyed by (account, folder full
// name) - see IFolderSettingsStore. Not stored on MailFolder itself since MailFolder is rebuilt
// fresh from IMAP on every fetch.
public class FolderSetting
{
public string Id { get; set; } = "";
public FolderSyncMode SyncMode { get; set; } = FolderSyncMode.Direct;
public bool Subscribed { get; set; } = true;
}
// Display-only ordering of an account's folders in the main menu (Settings > Mappen beheren) -
// see IFolderSettingsStore.GetOrder/SaveOrder. Never affects the real IMAP folder structure.
public class FolderOrder
{
public int Id { get; set; }
public List<string> Names { get; set; } = [];
}
public class MailFolder
{
public string FullName { get; set; } = "";
public string DisplayName { get; set; } = "";
public int UnreadCount { get; set; }
public bool IsSelectable { get; set; } = true;
// Folder-management-page fields (see Settings > Mappen beheren). MessageCount comes cheaply
// from the IMAP STATUS/SELECT response already fetched for UnreadCount. SizeBytes is a
// best-effort estimate, not an exact total - see IImapService.GetFoldersAsync for how it's
// derived (real IMAP STATUS SIZE where the server supports it, otherwise summed from
// whatever of the folder's messages happen to already be in the local message-list cache).
// IsSizeEstimated tells the UI which case applied, so it can show e.g. "~" for the estimate.
public int MessageCount { get; set; }
public long SizeBytes { get; set; }
public bool IsSizeEstimated { get; set; }
public int Depth { get; set; }
public FolderSyncMode SyncMode { get; set; } = FolderSyncMode.Direct;
public bool Subscribed { get; set; } = true;
// INBOX, and the folders serving IMAP's other special roles (Sent/Trash/Drafts/Junk) - these
// can't be deleted (see IImapService.DeleteFoldersAsync) since core app features (send,
// delete-to-trash, save-draft, contacts' "sent" scan) assume they exist.
public bool IsProtected { get; set; }
}
public class MessageListItem
{
public uint Uid { get; set; }
public string Subject { get; set; } = "";
public string From { get; set; } = "";
public DateTimeOffset Date { get; set; }
public long SizeBytes { get; set; }
public bool IsRead { get; set; }
public bool IsFlagged { get; set; }
public bool HasAttachments { get; set; }
public MessagePriority Priority { get; set; } = MessagePriority.Normal;
public double SizeKb => Math.Round(SizeBytes / 1024.0, 1);
}
public class MessageDetail
{
public uint Uid { get; set; }
public string Subject { get; set; } = "";
public string From { get; set; } = "";
public string SenderEmail { get; set; } = "";
public string To { get; set; } = "";
public string Cc { get; set; } = "";
public DateTimeOffset Date { get; set; }
public string HtmlBody { get; set; } = "";
public string TextBody { get; set; } = "";
public List<AttachmentInfo> Attachments { get; set; } = [];
public bool HasExternalImages { get; set; }
public bool ImagesAllowed { get; set; }
public MessagePriority Priority { get; set; } = MessagePriority.Normal;
public MessageSensitivity Sensitivity { get; set; } = MessageSensitivity.Nothing;
// The folder's unread count immediately after this message got marked read (from the local
// index, which GetMessageAsync already just updated) - lets the client patch its folder sidebar
// badge for free instead of re-fetching every folder's live IMAP STATUS just to refresh one
// number. Null for folders that aren't indexed (NotSynchronized), where there's no local count
// to report and the client should leave the badge alone.
public int? FolderUnreadCount { get; set; }
}
public class AttachmentInfo
{
public string FileName { get; set; } = "";
public string ContentType { get; set; } = "application/octet-stream";
public long SizeBytes { get; set; }
public int PartIndex { get; set; }
}
public class ContactAddress
{
public string Email { get; set; } = "";
public string Name { get; set; } = "";
}
public class MessageSearchResult
{
public string Folder { get; set; } = "";
public uint Uid { get; set; }
public string Subject { get; set; } = "";
public string From { get; set; } = "";
public DateTimeOffset Date { get; set; }
}
public class ComposeModel
{
public int AccountId { get; set; }
public string To { get; set; } = "";
public string Cc { get; set; } = "";
public string Bcc { get; set; } = "";
public string Subject { get; set; } = "";
public string HtmlBody { get; set; } = "";
public MessagePriority Priority { get; set; } = MessagePriority.Normal;
public MessageSensitivity Sensitivity { get; set; } = MessageSensitivity.Nothing;
public bool RequestReadReceipt { get; set; }
}