indexing
	description: "Email Object"
	author: "david s"
	date: "$Date$"
	revision: "$Revision$"

class interface
	EMAIL

create 

	make
			-- Initialize the headers table.

	make_with_entry (header_from, header_to: STRING)
			-- Create an email with the 'header_from' and the 'header_to'.
		require
			needed_info: header_from /= void and then header_to /= void

feature -- Initialization

	make
			-- Initialize the headers table.

	make_with_entry (header_from, header_to: STRING)
			-- Create an email with the 'header_from' and the 'header_to'.
		require
			needed_info: header_from /= void and then header_to /= void
	
feature -- Access

	header (h: STRING): HEADER
			-- Retrieve the content of the header 'h'
			-- (from EMAIL_RESOURCE)

	headers: HASH_TABLE [HEADER, STRING]
			-- All information concerning each headers
			-- (from EMAIL_RESOURCE)

	mail_message: STRING
			-- Email message
			-- (from MEMORY_RESOURCE)

	mail_signature: STRING
			-- Email signature
			-- (from MEMORY_RESOURCE)
	
feature -- Status report

	error: BOOLEAN
			-- Is there an error?
			-- (from EMAIL_RESOURCE)

	is_header_valid: BOOLEAN
			-- Is the email resource's header valid?
			-- (from EMAIL_RESOURCE)

	is_initiated: BOOLEAN
			-- Has the connection has been initiated?
			-- (from EMAIL_RESOURCE)

	transfer_error: TRANSFER_ERROR
			-- Transfer error handling
			-- (from EMAIL_RESOURCE)
	
feature -- Status setting

	disable_initiated
			-- Unset is_initiated.
			-- (from EMAIL_RESOURCE)

	disable_transfer_error
			-- Disable transfer error.
			-- (from EMAIL_RESOURCE)

	enable_initiated
			-- Set is_initiated.
			-- (from EMAIL_RESOURCE)

	enable_transfer_error
			-- Enable transfer error.
			-- (from EMAIL_RESOURCE)

	set_transfer_error_message (s: STRING)
			-- Set transfer error message to 's'.
			-- (from EMAIL_RESOURCE)
	
feature -- Basic operations

	add_header_entries (header_key: STRING; header_entries: ARRAY [STRING])
			-- Add multiple 'header_entries' at once  to 'header_key',
			-- If not such header exists. create it.

	add_header_entry (header_key, header_entry: STRING)
			-- Add 'header_entry' to header 'header_key',
			-- If no such header exists, create it.
		require
			not_void: header_entry /= void and then header_key /= void

	has_header_entry (header_key: STRING): BOOLEAN

	receive
			-- Receive email.

	remove_header_entries (header_key: STRING)
		require
			header_exists: headers.has (header_key)

	remove_header_entry (header_key, header_entry: STRING)
			-- Remove 'header_entry' from header 'header_key'.
		require
			header_exists: headers.has (header_key)
			header_entry_exists: (headers.item (header_key)).entries.has (header_entry)
		ensure
			header_entry_no_longer_exists: not (headers.item (header_key)).entries.has (header_entry)

	send
			-- Send email.
	
feature -- Constants for SMTP Protocol

	Ack_begin_connection: INTEGER is 220
			-- (from EMAIL_CONSTANTS)

	Ack_end_connection: INTEGER is 221
			-- (from EMAIL_CONSTANTS)

	Data: STRING is "DATA"
			-- (from EMAIL_CONSTANTS)

	Data_code: INTEGER is 354
			-- (from EMAIL_CONSTANTS)

	Ehlo: STRING is "EHLO "
			-- (from EMAIL_CONSTANTS)

	Helo: STRING is "HELO "
			-- (from EMAIL_CONSTANTS)

	Mail_bcc: STRING is "RCPT BCC:"
			-- (from EMAIL_CONSTANTS)

	Mail_cc: STRING is "RCPT CC:"
			-- (from EMAIL_CONSTANTS)

	Mail_from: STRING is "MAIL FROM: "
			-- (from EMAIL_CONSTANTS)

	Mail_reply_to: STRING is "RCPT REPLY TO:"
			-- (from EMAIL_CONSTANTS)

	Mail_to: STRING is "RCPT TO: "
			-- (from EMAIL_CONSTANTS)

	No_valid_recipient: INTEGER is 554
			-- (from EMAIL_CONSTANTS)

	Ok: INTEGER is 250
			-- (from EMAIL_CONSTANTS)

	Quit: STRING is "QUIT"
			-- (from EMAIL_CONSTANTS)

	Remote_error: INTEGER is 550
			-- (from EMAIL_CONSTANTS)

	Size_error: INTEGER is 500
			-- (from EMAIL_CONSTANTS)

	Struct_error: INTEGER is 552
			-- (from EMAIL_CONSTANTS)
	
feature -- Constants for email headers (Authorized keys for the Hashtables)

	default_headers: ARRAY [STRING]
			-- (from EMAIL_CONSTANTS)

	H_bcc: STRING is "Bcc"
			-- (from EMAIL_CONSTANTS)

	H_cc: STRING is "Cc"
			-- (from EMAIL_CONSTANTS)

	H_from: STRING is "From"
			-- (from EMAIL_CONSTANTS)

	H_reply_to: STRING is "Reply-to"
			-- (from EMAIL_CONSTANTS)

	H_subject: STRING is "Subject"
			-- (from EMAIL_CONSTANTS)

	H_to: STRING is "To"
			-- (from EMAIL_CONSTANTS)
	
feature -- Implementation (EMAIL_RESOURCE)

	Can_be_received: BOOLEAN is True
			-- Can an email received?

	Can_be_sent: BOOLEAN is True
			-- Can an email be send?

	Can_receive: BOOLEAN is False
			-- Can memory resource receive?
			-- (from MEMORY_RESOURCE)

	Can_send: BOOLEAN is False
			-- Can memory resource send?
			-- (from MEMORY_RESOURCE)
	
feature -- Settings

	set_message (s: STRING)
			-- Set mail_message to 's'.
			-- (from MEMORY_RESOURCE)

	set_signature (s: STRING)
			-- Set mail_signature to 's'.
			-- (from MEMORY_RESOURCE)
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class EMAIL