Changeset View
Changeset View
Standalone View
Standalone View
framework/domain/mimetreeparser/thoughts.txt
- This file was added.
1 | Usecases: | ||||
---|---|---|---|---|---|
2 | | ||||
3 | # plaintext msg + attachment | ||||
4 | * ContentPart => cp1 | ||||
5 | * AttachmentPart => ap1 | ||||
6 | | ||||
7 | (cp1) == collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
8 | (ap1) == collect<AttachmentParts>(select=NoEncapsulatedMessages) | ||||
9 | | ||||
10 | (PlainText) == cp1.availableContent() | ||||
11 | | ||||
12 | # html msg + related attachment + normal attachment | ||||
13 | * ContentPart => cp1 | ||||
14 | * AttachmentPart(mimetype="*/related", cid="12345678") => ap1 | ||||
15 | * AttachmentPart => ap2 | ||||
16 | | ||||
17 | (cp1) == collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
18 | (ap1, ap2) == collect<AttachmentParts>(select=NoEncapsulatedMessages) | ||||
19 | (ap2) == collect<AttachmentParts>(select=NoEncapsulatedMessages, filter=filterelated) | ||||
20 | | ||||
21 | ap1 == getPart("cid:12345678") | ||||
22 | | ||||
23 | (Html) == cp1.availableContent() | ||||
24 | | ||||
25 | # alternative msg + attachment | ||||
26 | * ContentPart(html=[Content("HTML"),], plaintext=[Content("Text"),]) => cp1 | ||||
27 | * AttachmentPart => ap1 | ||||
28 | | ||||
29 | (cp1) == collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
30 | (ap1) == collect<AttachmentParts>(select=NoEncapsulatedMessages) | ||||
31 | | ||||
32 | (Html, PlainText) == cp1.availableContent() | ||||
33 | [Content("HTML"),] == cp1.content(Html) | ||||
34 | [Content("Text"),] == cp1.content(Plaintext) | ||||
35 | | ||||
36 | # alternative msg with GPGInlin | ||||
37 | * ContentPart( | ||||
38 | plaintext=[Content("Text"), Content("foo", encryption=(enc1))], | ||||
39 | html=[Content("HTML"),] | ||||
40 | ) => cp1 | ||||
41 | | ||||
42 | (Html, PlainText) == cp1.availableContent() | ||||
43 | | ||||
44 | [Content("HTML"),] == cp1.content(Html) | ||||
45 | [Content("Text"),Content("foo", encryption=(enc1))] == cp1.content(Plaintext) | ||||
46 | | ||||
47 | | ||||
48 | # encrypted msg (not encrypted/error) with unencrypted attachment | ||||
49 | * EncryptionErrorPart => cp1 | ||||
50 | * AttachmentPart => ap1 | ||||
51 | | ||||
52 | (cp1) == collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
53 | (ap1) == collect<AttachmentParts>(select=NoEncapsulatedMessages) | ||||
54 | | ||||
55 | #encrypted msg (decrypted with attachment) + unencrypted attachment | ||||
56 | * encrytion=(rec1,rec2) => enc1 | ||||
57 | * ContentPart(encrytion = (enc1,)) => cp1 | ||||
58 | * AttachmentPart(encryption = (enc1,)) => ap1 | ||||
59 | * AttachmentPart => ap2 | ||||
60 | | ||||
61 | (cp1) == collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
62 | (ap1, ap2) == collect<AttachmentParts>(select=NoEncapsulatedMessages) | ||||
63 | | ||||
64 | #INLINE GPG encrypted msg + attachment | ||||
65 | * ContentPart => cp1 with | ||||
66 | plaintext=[Content, Content(encrytion = (enc1(rec1,rec2),)), Content(signed = (sig1,)), Content] | ||||
67 | * AttachmentPart => ap1 | ||||
68 | | ||||
69 | (cp1) == collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
70 | (ap1) == collect<AttachmentParts>(select=NoEncapsulatedMessages) | ||||
71 | | ||||
72 | [Content, Content(encrytion = (enc1(rec1,rec2),)), Content(signed = (sig1,)), Content] == cp1.content(Plaintext) | ||||
73 | | ||||
74 | #forwared encrypted msg + attachments | ||||
75 | * ContentPart => cp1 | ||||
76 | * EncapsulatedPart => ep1 | ||||
77 | * Encrytion=(rec1,rec2) => enc1 | ||||
78 | * Signature => sig1 | ||||
79 | * ContentPart(encrytion = (enc1,), signature = (sig1,)) => cp2 | ||||
80 | * Content(encrytion = (enc1,), signature = (sig1,)) | ||||
81 | * Content(encrytion = (enc1, enc2(rec3,rec4),), signature = (sig1,)) | ||||
82 | * AttachmentPart(encrytion = (enc1,), signature = (sig1,)) => ap1 | ||||
83 | * AttachmentPart => ap2 | ||||
84 | | ||||
85 | (cp1) = collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
86 | (ap2) = collect<AttachmentParts>(select=NoEncapsulatedMessages) | ||||
87 | | ||||
88 | (cp2) = collect<ContentPart>(ep1, select=NoEncapsulatedMessages) | ||||
89 | (ap1) = collect<AttachmentParts>(ep1, select=NoEncapsulatedMessages) | ||||
90 | | ||||
91 | (cp1, cp2) == collect<ContentPart>() | ||||
92 | (ap1, ap2) == collect<AttachmentParts>()[Content, Content(encrytion = (enc1(rec1,rec2),)), Content(signed = (sig1,)), Content] | ||||
93 | | ||||
94 | | ||||
95 | # plaintext msg + attachment + cert | ||||
96 | * ContentPart => cp1 | ||||
97 | * AttachmentPart => ap1 | ||||
98 | * CertPart => cep1 | ||||
99 | | ||||
100 | (cp1) == collect<ContentPart>(select=NoEncapsulatedMessages) | ||||
101 | (ap1, cep1) == collect<AttachmentPart>(select=NoEncapsulatedMessages) | ||||
102 | (ap1) == collect<AttachmentPart>(select=NoEncapsulatedMessages, filter=filterSubAttachmentParts) | ||||
103 | | ||||
104 | (cep1) == collect<CertPart>(select=NoEncapsulatedMessages) | ||||
105 | | ||||
106 | | ||||
107 | collect function: | ||||
108 | | ||||
109 | bool noEncapsulatedMessages(Part part) | ||||
110 | { | ||||
111 | if (is<EncapsulatedPart>(part)) { | ||||
112 | return false; | ||||
113 | } | ||||
114 | return true; | ||||
115 | } | ||||
116 | | ||||
117 | bool filterRelated(T part) | ||||
118 | { | ||||
119 | if (part.mimetype == related && !part.cid.isEmpty()) { | ||||
120 | return false; //filter out related parts | ||||
121 | } | ||||
122 | return true; | ||||
123 | } | ||||
124 | | ||||
125 | bool filterSubAttachmentParts(AttachmentPart part) | ||||
126 | { | ||||
127 | if (isSubPart<AttachmentPart>(part)) { | ||||
128 | return false; // filter out CertPart f.ex. | ||||
129 | } | ||||
130 | return true; | ||||
131 | } | ||||
132 | | ||||
133 | List<T> collect<T>(Part start, std::function<bool(const Part &)> select, std::function<bool(const std::shared_ptr<T> &)> filter) { | ||||
134 | List<T> col; | ||||
135 | if (!select(start)) { | ||||
136 | return col; | ||||
137 | } | ||||
138 | | ||||
139 | if(isOrSubTypeIs<T>(start) && filter(start.staticCast<T>)){ | ||||
140 | col.append(p); | ||||
141 | } | ||||
142 | foreach(childs as child) { | ||||
143 | if (select(child)) { | ||||
144 | col.expand(collect(child,select,filter); | ||||
145 | } | ||||
146 | } | ||||
147 | return col; | ||||
148 | } | ||||
149 | No newline at end of file |