this repo has no description
1(** Demo of message flags and mailbox attributes functionality *)
2
3open Jmap_mail.Types
4
5(** Demonstrate flag color functionality *)
6let demo_flag_colors () =
7 Printf.printf "Flag Color Demo:\n";
8 Printf.printf "================\n";
9
10 (* Show all flag colors and their bit patterns *)
11 let colors = [Red; Orange; Yellow; Green; Blue; Purple; Gray] in
12 List.iter (fun color ->
13 let (bit0, bit1, bit2) = bits_of_flag_color color in
14 Printf.printf "Color: %-7s Bits: %d%d%d\n"
15 (match color with
16 | Red -> "Red"
17 | Orange -> "Orange"
18 | Yellow -> "Yellow"
19 | Green -> "Green"
20 | Blue -> "Blue"
21 | Purple -> "Purple"
22 | Gray -> "Gray")
23 (if bit0 then 1 else 0)
24 (if bit1 then 1 else 0)
25 (if bit2 then 1 else 0)
26 ) colors;
27
28 Printf.printf "\n"
29
30(** Demonstrate message keyword functionality *)
31let demo_message_keywords () =
32 Printf.printf "Message Keywords Demo:\n";
33 Printf.printf "=====================\n";
34
35 (* Show all standard message keywords and their string representations *)
36 let keywords = [
37 Notify; Muted; Followed; Memo; HasMemo; HasAttachment; HasNoAttachment;
38 AutoSent; Unsubscribed; CanUnsubscribe; Imported; IsTrusted;
39 MaskedEmail; New; MailFlagBit0; MailFlagBit1; MailFlagBit2
40 ] in
41
42 List.iter (fun kw ->
43 Printf.printf "%-15s -> %s\n"
44 (match kw with
45 | Notify -> "Notify"
46 | Muted -> "Muted"
47 | Followed -> "Followed"
48 | Memo -> "Memo"
49 | HasMemo -> "HasMemo"
50 | HasAttachment -> "HasAttachment"
51 | HasNoAttachment -> "HasNoAttachment"
52 | AutoSent -> "AutoSent"
53 | Unsubscribed -> "Unsubscribed"
54 | CanUnsubscribe -> "CanUnsubscribe"
55 | Imported -> "Imported"
56 | IsTrusted -> "IsTrusted"
57 | MaskedEmail -> "MaskedEmail"
58 | New -> "New"
59 | MailFlagBit0 -> "MailFlagBit0"
60 | MailFlagBit1 -> "MailFlagBit1"
61 | MailFlagBit2 -> "MailFlagBit2"
62 | OtherKeyword s -> "Other: " ^ s)
63 (string_of_message_keyword kw)
64 ) keywords;
65
66 Printf.printf "\n"
67
68(** Demonstrate mailbox attribute functionality *)
69let demo_mailbox_attributes () =
70 Printf.printf "Mailbox Attributes Demo:\n";
71 Printf.printf "=======================\n";
72
73 (* Show all standard mailbox attributes and their string representations *)
74 let attributes = [Snoozed; Scheduled; Memos] in
75
76 List.iter (fun attr ->
77 Printf.printf "%-10s -> %s\n"
78 (match attr with
79 | Snoozed -> "Snoozed"
80 | Scheduled -> "Scheduled"
81 | Memos -> "Memos"
82 | OtherAttribute s -> "Other: " ^ s)
83 (string_of_mailbox_attribute attr)
84 ) attributes;
85
86 Printf.printf "\n"
87
88(** Demonstrate formatting functionality *)
89let demo_formatting () =
90 Printf.printf "Keyword Formatting Demo:\n";
91 Printf.printf "======================\n";
92
93 (* Create a sample email with various keywords *)
94 let sample_keywords = [
95 (Flagged, true); (* Standard flag *)
96 (Custom "$MailFlagBit0", true); (* Flag color bit *)
97 (Custom "$MailFlagBit2", true); (* Flag color bit *)
98 (Custom "$notify", true); (* Message keyword *)
99 (Custom "$followed", true); (* Message keyword *)
100 (Custom "$hasattachment", true); (* Message keyword *)
101 (Seen, false); (* Inactive keyword *)
102 (Custom "$random", true); (* Unknown keyword *)
103 ] in
104
105 (* Test formatted output *)
106 let formatted = format_email_keywords sample_keywords in
107 Printf.printf "Formatted keywords: %s\n\n" formatted
108
109(** Main entry point *)
110let () =
111 demo_flag_colors ();
112 demo_message_keywords ();
113 demo_mailbox_attributes ();
114 demo_formatting ()