Mail Kit 2 Root

The Public API


PlainTextBodyComponent

Derived from: MailComponent
Declared in:  include/public/MailComponent.h
Library: libmail.so


PlainTextBodyComponent stores plain text. It uses UTF8 text as its canonical format and reads and writes RFC 2047 style text. As such, it handles accents and other 8 bit characters with ease. If you want to send text, this is the way to go.


Constructor and Destructor


PlainTextBodyComponent()

 

PlainTextBodyComponent(const char*text = NULL)

Initializes the component and sets its content to text, which can be NULL. The argument is a UTF8 null-terminated string. Encoding defaults to quoted printable with the ISO-8859-1 charset.

 


~PlainTextBodyComponent()

 

virtual ~PlainTextBodyComponent()

Destroys the component and frees internal buffers. Does nothing of interest.


Member Functions


GetDecodedData ()

 

virtual status_t GetDecodedData(BPositionIO *data)

Retrieves the data contained in this component as a UTF8 string and places the contents of this string in data.

Return Value:

- B_OK if everything succeeds.

- B_ERROR if something goes wrong.


Text ()

 

const char * Text()

Returns the contents of this component as a UTF8 string.


BStringText ()

 

BString * BStringText()

Returns the internal UTF8 format BString used by this component. As such, you can do raw text operations on the content of the message. The use of this function is not reccomended.


Quote ()

 

void Quote( const char *message = NULL, const char *quote_style = "> " )

Quotes the contents of this component. Inserts quote_style at the start of every line, and prefaces the content with message, if it is not NULL. message should be something like "On September 30, 2001, John Smith said:", or something in that vein. Note that the new line after message is supplied for you, so you do not need to add it.


SetDecodedData ()

 

virtual status_t SetDecodedData(BPositionIO *data)

Sets the contents of this component to the UTF8 format data contained in data.

Return Value:

- B_OK if everything succeeds.

- B_ERROR if something goes wrong.


SetText ()

 

void SetText(const char *text)

Sets the contents of this component to the UTF8 string contained in text.


AppendText ()

 

void AppendText(const char *text)

Appends text to the current contents of this component. text should be a UTF8 string.


SetEncoding ()

 

void SetEncoding(mail_encoding encoding, int32 charset)

Sets the encoding and charset used by Render() to encoding and charset, respectively. Use the conversion constants from UTF8.h for charset. We strongly reccomend that you always use the defaults for the reasons outlined in RFC 2047.


Instantiate ()

 

virtual status_t Instantiate(BPositionIO *data, size_t length)

Initializes this component to the RFC 822 format data in data, starting at data ->Position(), for up to length bytes. Handles encoded data according to RFC 2047

Return Value:

- B_OK if everything succeeds.

- B_BAD_TYPE if data does not seem to be plain text.


Render ()

 

virtual status_t Render(BPositionIO *data)

Renders the component into RFC 822 format and places the result in data, starting at data ->Position(). Encodes and translates charsets according to the arguments passed to SetEncoding(). Encoding defaults to quoted printable and charset to ISO-8859-1.

Return Value:

- B_OK if everything succeeds.


Mail Kit 2 Root

The Public API


Mail Daemon 2 API Documentation

©2001 Dr. Zoidberg Enterprises