[Pkg] The Trunk: Network-pre.199.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jun 6 13:01:15 UTC 2017


Patrick Rein uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-pre.199.mcz

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

Name: Network-pre.199
Author: pre
Time: 6 June 2017, 3:01:07.472664 pm
UUID: d694f71a-20fb-4eea-b1d5-aea8038ff383
Ancestors: Network-eem.198

Updates the MailMessage intialization methods and changes the date methods of mailMessage

=============== Diff against Network-eem.198 ===============

Item was changed:
  ----- Method: MailMessage class>>from: (in category 'instance creation') -----
  from: aString
  	"Initialize a new instance from the given string."
  
+ 	^ self new 
+ 		setText: aString;
+ 		yourself!
- 	^(self new) from: aString!

Item was changed:
  ----- Method: MailMessage>>date (in category 'access') -----
  date
+ 	
+ 	^ DateAndTime fromSeconds: self time + (Date newDay: 1 year: 1980) asSeconds!
- 	"Answer a date string for this message."
- 
- 	^(Date fromSeconds: self time + (Date newDay: 1 year: 1980) asSeconds) 
- 		printFormat: #(2 1 3 47 1 2)!

Item was added:
+ ----- Method: MailMessage>>dateString (in category 'access') -----
+ dateString
+ 	"Answer a date string for this message."
+ 
+ 	^ self date asDate printFormat: #(2 1 3 47 1 2)!

Item was added:
+ ----- Method: MailMessage>>readFrom: (in category 'parsing') -----
+ readFrom: parseStream
+ 	
+ 	| bodyText contentTransferEncoding contentType |
+ 	contentType := 'text/plain'.
+ 	contentTransferEncoding := nil.
+ 	fields := Dictionary new.
+ 
+ 	"Extract information out of the header fields"
+ 	self fieldsFrom: parseStream do: 
+ 		[:fName :fValue | 
+ 		"NB: fName is all lowercase"
+ 
+ 		fName = 'content-type' ifTrue: [contentType := fValue asLowercase].
+ 		fName = 'content-transfer-encoding' ifTrue: [contentTransferEncoding := fValue asLowercase].
+ 
+ 		(fields at: fName ifAbsentPut: [OrderedCollection new: 1])
+ 			add: (MIMEHeaderValue forField: fName fromString: fValue)].
+ 
+ 	"Extract the body of the message"
+ 	bodyText := parseStream upToEnd.
+ 	contentTransferEncoding = 'base64' ifTrue: [
+ 			bodyText := Base64MimeConverter mimeDecodeToChars: (ReadStream on: bodyText).
+ 			bodyText := bodyText contents].
+ 	contentTransferEncoding = 'quoted-printable' ifTrue: [
+ 			bodyText := bodyText decodeQuotedPrintable].
+ 	
+ 	body := MIMEDocument contentType: contentType content: bodyText!

Item was added:
+ ----- Method: MailMessage>>setText: (in category 'access') -----
+ setText: aString 
+ 
+ 	text := aString withoutTrailingBlanks, String cr, String cr.
+ 	self readFrom: text readStream.
+ 	!



More information about the Packages mailing list