Skip to content

Commit 9c2659f

Browse files
TimBo93jstedfast
andauthored
Update HtmlPreviewVisitor to handle text/calender scheduling events (#1119)
* Update HtmlPreviewVisitor to handle text/calender scheduling events * Fix text/calendar handling in HtmlPreviewVisitor --------- Co-authored-by: Jeffrey Stedfast <[email protected]>
1 parent 2b375b9 commit 9c2659f

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

FAQ.md

+15
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ class HtmlPreviewVisitor : MimeVisitor
264264
{
265265
List<MultipartRelated> stack = new List<MultipartRelated> ();
266266
List<MimeEntity> attachments = new List<MimeEntity> ();
267+
List<MimeEntity> calenderAttachments = new List<MimeEntity> ();
268+
267269
readonly string tempDir;
268270
string body;
269271

@@ -283,6 +285,13 @@ class HtmlPreviewVisitor : MimeVisitor
283285
get { return attachments; }
284286
}
285287

288+
/// <summary>
289+
/// The list of text/calender entries that were in the MimeMessage.
290+
/// </summary>
291+
public IList<MimeEntity> CalenderAttachments {
292+
get { return calenderAttachments; }
293+
}
294+
286295
/// <summary>
287296
/// The HTML string that can be set on the BrowserControl.
288297
/// </summary>
@@ -459,6 +468,12 @@ class HtmlPreviewVisitor : MimeVisitor
459468
{
460469
TextConverter converter;
461470

471+
// treat text/calendar parts as attachments rather than message bodies
472+
if (entity.ContentType.IsMimeType ("text", "calendar")) {
473+
calendarAattachments.Add (entity);
474+
return;
475+
}
476+
462477
if (body != null) {
463478
// since we've already found the body, treat this as an attachment
464479
attachments.Add (entity);

samples/MessageReader.Android/MessageReader.Android/HtmlPreviewVisitor.cs

+15
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class HtmlPreviewVisitor : MimeVisitor
4242
{
4343
readonly List<MultipartRelated> stack = new List<MultipartRelated> ();
4444
readonly List<MimeEntity> attachments = new List<MimeEntity> ();
45+
readonly List<MimeEntity> calenderAttachments = new List<MimeEntity> ();
46+
4547
readonly WebView webView;
4648
bool renderedBody;
4749

@@ -60,6 +62,13 @@ public IList<MimeEntity> Attachments {
6062
get { return attachments; }
6163
}
6264

65+
/// <summary>
66+
/// The list of text/calender entries that were in the MimeMessage.
67+
/// </summary>
68+
public IList<MimeEntity> CalenderAttachments {
69+
get { return calenderAttachments; }
70+
}
71+
6372
protected override void VisitMultipartAlternative (MultipartAlternative alternative)
6473
{
6574
// walk the multipart/alternative children backwards from greatest level of faithfulness to the least faithful
@@ -127,6 +136,12 @@ protected override void VisitTextPart (TextPart entity)
127136
{
128137
TextConverter converter;
129138

139+
// treat text/calendar parts as attachments rather than message bodies
140+
if (entity.ContentType.IsMimeType ("text", "calendar")) {
141+
calenderAttachments.Add (entity);
142+
return;
143+
}
144+
130145
if (renderedBody) {
131146
// since we've already found the body, treat this as an attachment
132147
attachments.Add (entity);

samples/MessageReader.iOS/MessageReader.iOS/HtmlPreviewVisitor.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// HtmlPreviewVisitor.cs
33
//
44
// Author: Jeffrey Stedfast <[email protected]>
@@ -42,6 +42,8 @@ class HtmlPreviewVisitor : MimeVisitor
4242
{
4343
readonly List<MultipartRelated> stack = new List<MultipartRelated> ();
4444
readonly List<MimeEntity> attachments = new List<MimeEntity> ();
45+
readonly List<MimeEntity> calenderAttachments = new List<MimeEntity> ();
46+
4547
readonly UIWebView webView;
4648
bool renderedBody;
4749

@@ -60,6 +62,13 @@ public IList<MimeEntity> Attachments {
6062
get { return attachments; }
6163
}
6264

65+
/// <summary>
66+
/// The list of text/calender entries that were in the MimeMessage.
67+
/// </summary>
68+
public IList<MimeEntity> CalenderAttachments {
69+
get { return calenderAttachments; }
70+
}
71+
6372
protected override void VisitMultipartAlternative (MultipartAlternative alternative)
6473
{
6574
// walk the multipart/alternative children backwards from greatest level of faithfulness to the least faithful
@@ -127,6 +136,12 @@ protected override void VisitTextPart (TextPart entity)
127136
{
128137
TextConverter converter;
129138

139+
// treat text/calendar parts as attachments rather than message bodies
140+
if (entity.ContentType.IsMimeType ("text", "calendar")) {
141+
calenderAttachments.Add (entity);
142+
return;
143+
}
144+
130145
if (renderedBody) {
131146
// since we've already found the body, treat this as an attachment
132147
attachments.Add (entity);

samples/MessageReader/MessageReader/HtmlPreviewVisitor.cs

+15
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class HtmlPreviewVisitor : MimeVisitor
4141
{
4242
readonly List<MultipartRelated> stack = new List<MultipartRelated> ();
4343
readonly List<MimeEntity> attachments = new List<MimeEntity> ();
44+
readonly List<MimeEntity> calenderAttachments = new List<MimeEntity> ();
45+
4446
string body;
4547

4648
/// <summary>
@@ -57,6 +59,13 @@ public IList<MimeEntity> Attachments {
5759
get { return attachments; }
5860
}
5961

62+
/// <summary>
63+
/// The list of text/calender entries that were in the MimeMessage.
64+
/// </summary>
65+
public IList<MimeEntity> CalenderAttachments {
66+
get { return calenderAttachments; }
67+
}
68+
6069
/// <summary>
6170
/// The HTML string that can be set on the BrowserControl.
6271
/// </summary>
@@ -206,6 +215,12 @@ protected override void VisitTextPart (TextPart entity)
206215
{
207216
TextConverter converter;
208217

218+
// treat text/calendar parts as attachments rather than message bodies
219+
if (entity.ContentType.IsMimeType ("text", "calendar")) {
220+
calenderAttachments.Add (entity);
221+
return;
222+
}
223+
209224
if (body != null) {
210225
// since we've already found the body, treat this as an attachment
211226
attachments.Add (entity);

0 commit comments

Comments
 (0)