The Trunk: Network-ar.62.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Network-ar.62.mcz

commits-2
Andreas Raab uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-ar.62.mcz

==================== Summary ====================

Name: Network-ar.62
Author: ar
Time: 5 March 2010, 9:00:48.926 pm
UUID: b7608bd2-0db4-e643-8da7-b47ce55d37c9
Ancestors: Network-ar.61

Avoid dictionary protocol in Smalltalk.

=============== Diff against Network-ar.61 ===============

Item was changed:
  ----- Method: MailMessage>>bodyTextFormatted (in category 'printing/formatting') -----
  bodyTextFormatted
  "Answer a version of the text in my body suitable for display.  This will parse multipart forms, decode HTML, and other such things"
 
  "check for multipart"
  self body isMultipart ifTrue: [
  "check for alternative forms"
  self body isMultipartAlternative ifTrue: [
  "it's multipart/alternative.  search for a part that we can display, biasing towards nicer formats"
  #('text/html' 'text/plain') do: [ :format |
  self parts do: [ :part |
  part body contentType = format ifTrue: [ ^part bodyTextFormatted ] ] ].
 
  "couldn't find a desirable part to display; just display the first part"
  ^self parts first bodyTextFormatted ].
 
  "not alternative parts.  put something for each part"
  ^Text streamContents: [ :str |
  self parts do: [ :part |
  ((#('text' 'multipart') includes: part body mainType) or:
  [ part body contentType = 'message/rfc822'])
  ifTrue: [
  "try to inline the message part"
  str nextPutAll: part bodyTextFormatted. ]
  ifFalse: [
  |descript |
  str cr.
  descript := part name ifNil: [ 'attachment' ].
  str nextPutAll: (Text string: '[', descript, ']'  attribute: (TextMessageLink message: part)). ] ] ]. ].
 
 
  "check for HTML"
  (self body contentType = 'text/html') ifTrue: [
+ Smalltalk at: #HtmlParser ifPresent: [ :htmlParser |
- Smalltalk at: #HtmlParser ifPresentAndInMemory: [ :htmlParser |
  ^(htmlParser parse: (ReadStream on: body content)) formattedText
  ]
  ].
 
  "check for an embedded message"
  self body contentType = 'message/rfc822' ifTrue: [
  ^(MailMessage from: self body content) formattedText ].
 
  "nothing special--just return the text"
  ^body content.
 
  !