Christoph Thiede uploaded a new version of Network to project The Trunk: http://source.squeak.org/trunk/Network-ct.278.mcz
==================== Summary ====================
Name: Network-ct.278 Author: ct Time: 4 June 2023, 3:30:53.972153 pm UUID: 066c2a4c-ab52-2a4d-8025-45fbc1de561a Ancestors: Network-pre.277
Adds #bodyTextFormatted:showAttachments: on MIMEDocument and MailMessage for hiding non-inline parts.
=============== Diff against Network-pre.277 ===============
Item was changed: ----- Method: MIMEDocument>>bodyTextFormatted: (in category 'serializing') ----- bodyTextFormatted: shouldPreferRichText + "Answer a string or text representing the content of the receiver."
+ ^ self bodyTextFormatted: shouldPreferRichText showAttachments: true! - self isMultipart ifTrue: [ - self isMultipartAlternative ifTrue: [ - "https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html" - | preferredTypes | - preferredTypes := #('text/plain' 'text/html'). - shouldPreferRichText ifTrue: [preferredTypes := preferredTypes reversed]. - preferredTypes do: [:format | - self parts do: [:part | - (part containsInlineContentType: format) ifTrue: [ - ^ part bodyTextFormatted: shouldPreferRichText]]]. - - "fallback" - ^ self parts first bodyTextFormatted: shouldPreferRichText]. - - self subType = 'related' ifTrue: [ - "RFC2387" - ^ [self parts first bodyTextFormatted: shouldPreferRichText] - on: MIMEContentRequest do: [:request | - (self partWithContentID: request cid) ifNotNil: [:part | - request resume: part]. - request pass]]. - - ^ Text streamContents: [:stream | - self parts - do: [:part | stream nextPutAll: - (part contentDisposition = 'inline' - ifTrue: [part bodyTextFormatted: shouldPreferRichText] - ifFalse: [part attachmentText])] - separatedBy: [stream cr]]]. - - self contentType = 'message/rfc822' ifTrue: [ - "embedded message" - ^ (MailMessage from: self content) bodyTextFormatted: shouldPreferRichText]. - - self isHTML ifTrue: [ - (Smalltalk classNamed: #HtmlReadWriter) ifNotNil: [:readerClass | - ^ (readerClass on: self content readStream) - shallEvaluateResources: false; - nextText]]. - - self isPlaintext ifTrue: [ - ^ self plainTextWithResolvedCIDReferences: shouldPreferRichText]. - - self containsViewableImage ifTrue: [ - | form scaleFactor | - form := self image. - (scaleFactor := RealEstateAgent scaleFactor) = 1.0 - ifFalse: [form := form scaledToSize: form extent * scaleFactor]. - ^ Text string: Character startOfHeader asString attribute: form asTextAnchor]. - - "fallback" - ^ self content!
Item was added: + ----- Method: MIMEDocument>>bodyTextFormatted:showAttachments: (in category 'serializing') ----- + bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments + "Answer a string or text representing the content of the receiver." + + self isMultipart ifTrue: [ + self isMultipartAlternative ifTrue: [ + "https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html" + | preferredTypes | + preferredTypes := #('text/plain' 'text/html'). + shouldPreferRichText ifTrue: [preferredTypes := preferredTypes reversed]. + preferredTypes do: [:format | + self parts do: [:part | + (part containsInlineContentType: format) ifTrue: [ + ^ part bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments]]]. + + "fallback" + ^ self parts first bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments]. + + self subType = 'related' ifTrue: [ + "RFC2387" + ^ [self parts first bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments] + on: MIMEContentRequest do: [:request | + (self partWithContentID: request cid) ifNotNil: [:part | + request resume: part]. + request pass]]. + + ^ Text streamContents: [:stream | + | sep | + sep := false. + self parts do: [:part | + sep := (part contentDisposition = 'inline' + ifTrue: [ + sep ifTrue: [stream cr]. + stream nextPutAll: (part bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments)] + ifFalse: [ + shouldShowAttachments + ifTrue: [ + sep ifTrue: [stream cr]. + stream nextPutAll: part attachmentText]]) notNil]]]. + + self contentType = 'message/rfc822' ifTrue: [ + "embedded message" + ^ (MailMessage from: self content) bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments]. + + self isHTML ifTrue: [ + (Smalltalk classNamed: #HtmlReadWriter) ifNotNil: [:readerClass | + ^ (readerClass on: self content readStream) + shallEvaluateResources: false; + nextText]]. + + self isPlaintext ifTrue: [ + ^ self plainTextWithResolvedCIDReferences: shouldPreferRichText]. + + self containsViewableImage ifTrue: [ + | form scaleFactor | + form := self image. + (scaleFactor := RealEstateAgent scaleFactor) = 1.0 + ifFalse: [form := form scaledToSize: form extent * scaleFactor]. + ^ Text string: Character startOfHeader asString attribute: form asTextAnchor]. + + "fallback" + ^ self content asString!
Item was added: + ----- Method: MailMessage>>bodyTextFormatted:showAttachments: (in category 'printing/formatting') ----- + bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments + + ^ self body bodyTextFormatted: shouldPreferRichText showAttachments: shouldShowAttachments!
packages@lists.squeakfoundation.org