MCSmtpRepository.st
changeset 116 c1ae9aaf5d5b
child 220 7ef561a05e48
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCSmtpRepository.st	Wed Nov 22 14:22:53 2006 +0100
@@ -0,0 +1,71 @@
+"{ Package: 'stx:goodies/monticello' }"
+
+MCWriteOnlyRepository subclass:#MCSmtpRepository
+	instanceVariableNames:'email'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Monticello-Repositories'
+!
+
+
+!MCSmtpRepository class methodsFor:'as yet unclassified'!
+
+description
+	^ 'SMTP'
+!
+
+morphicConfigure
+	| address |
+	address _ FillInTheBlankMorph request: 'Email address:'.
+	^ address isEmpty ifFalse: [self new emailAddress: address]
+! !
+
+!MCSmtpRepository methodsFor:'as yet unclassified'!
+
+basicStoreVersion: aVersion
+	MailSender sendMessage: (self messageForVersion: aVersion)
+!
+
+bodyForVersion: aVersion
+	^ String streamContents:
+		[ :s |
+		s nextPutAll: 'from version info:'; cr; cr.
+		s nextPutAll:  aVersion info summary]
+!
+
+description
+	^ 'mailto://', email
+!
+
+emailAddress: aString
+	email _ aString	
+!
+
+messageForVersion: aVersion
+	| message data |
+	message := MailMessage empty.
+	message setField: 'from' toString: MailSender userName.
+	message setField: 'to' toString: email.
+	message setField: 'subject' toString: (self subjectForVersion: aVersion). 
+
+	message body:
+		(MIMEDocument
+			contentType: 'text/plain'
+			content: (self bodyForVersion: aVersion)).
+
+	"Prepare the gzipped data"
+	data _ RWBinaryOrTextStream on: String new.
+	aVersion fileOutOn: data.
+	message addAttachmentFrom: data reset withName: aVersion fileName.
+	^ message
+!
+
+subjectForVersion: aVersion
+	^ '[Package] ', aVersion info name
+! !
+
+!MCSmtpRepository class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCSmtpRepository.st,v 1.1 2006-11-22 13:22:53 cg Exp $'
+! !