MCSmtpRepository.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Nov 2006 14:22:53 +0100
changeset 116 c1ae9aaf5d5b
child 220 7ef561a05e48
permissions -rw-r--r--
initial checkin

"{ 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 $'
! !