Loading...
Searching...
No Matches
Public Member Functions | List of all members
BTextMailComponent Class Reference

A component that stores plain text. More...

Inherits BMailComponent.

Public Member Functions

 BTextMailComponent (const char *text=NULL, uint32 defaultCharSet=B_MAIL_NULL_CONVERSION)
 Initializes the component and sets its content to text.
 
virtual ~BTextMailComponent ()
 Destructor.
 
void AppendText (const char *text)
 Appends the UTF8 string text to the current contents of this component.
 
BStringBStringText ()
 Returns the internal UTF8 format BString used by this component.
 
virtual status_t GetDecodedData (BPositionIO *data)
 Retrieves the data contained in this component as a UTF8 string into data.
 
void Quote (const char *message=NULL, const char *quote_style="> ")
 Quotes the contents of this component.
 
virtual status_t RenderToRFC822 (BPositionIO *render_to)
 Renders the component into RFC-822 format.
 
virtual status_t SetDecodedData (BPositionIO *data)
 Sets the contents of this component to the UTF8 format data.
 
void SetEncoding (mail_encoding encoding, int32 charset)
 Sets the encoding and charset used by Render().
 
void SetText (const char *text)
 Sets the contents of this component to the UTF8 string text.
 
virtual status_t SetToRFC822 (BPositionIO *data, size_t length, bool parse_now=false)
 Sets this object from a component in RFC-822 format.
 
const char * Text ()
 Returns the contents of this component as a UTF8 string.
 
- Public Member Functions inherited from BMailComponent
 BMailComponent (uint32 defaultCharSet=B_MAIL_NULL_CONVERSION)
 Initializes a new BMailComponent with the specified character set.
 
virtual ~BMailComponent ()
 Destructor.
 
uint32 ComponentType ()
 Returns the component_type of this object.
 
virtual status_t GetDecodedData (BPositionIO *data)
 Retrieves the data contained in this component in canonical format and places it into data.
 
const char * HeaderAt (int32 index) const
 Returns the key of the header at index.
 
status_t HeaderField (const char *key, BMessage *structured_header, int32 index=0) const
 Returns the header key.
 
const char * HeaderField (const char *key, int32 index=0) const
 Returns the header key.
 
bool IsAttachment ()
 Employs simple heuristics such as the MIME type and the Content-Disposition: header to determine whether this component is an attachment.
 
virtual status_t MIMEType (BMimeType *mime)
 Places the MIME type of the data into mime.
 
status_t RemoveHeader (const char *key)
 Removes all headers with the key key.
 
virtual status_t RenderToRFC822 (BPositionIO *render_to)
 Renders the component into RFC-822 format.
 
virtual status_t SetDecodedData (BPositionIO *data)
 Sets the content of this component to the canonical format data contained in data.
 
void SetHeaderField (const char *key, BMessage *structured_header, bool replace_existing=true)
 Adds a structured header of type key to the component.
 
void SetHeaderField (const char *key, const char *value, uint32 charset=B_MAIL_NULL_CONVERSION, mail_encoding encoding=null_encoding, bool replace_existing=true)
 Adds the specified header of type key and with the value to the component.
 
virtual status_t SetToRFC822 (BPositionIO *data, size_t length, bool parse_now=false)
 Sets this object from a component in RFC-822 format.
 
BMailComponentWhatIsThis ()
 Employs simple heuristics such as the MIME type to present you with an instance of a useful subclass.
 

Detailed Description

A component that 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.

Since
Haiku R1

Constructor & Destructor Documentation

◆ BTextMailComponent()

BTextMailComponent::BTextMailComponent ( const char *  text = NULL,
uint32  defaultCharSet = B_MAIL_NULL_CONVERSION 
)

Initializes the component and sets its content to text.

text can be NULL. The argument is a UTF-8 null-terminated string. Encoding defaults to quoted_printable with the ISO-15 charset.

Since
Haiku R1

Member Function Documentation

◆ AppendText()

void BTextMailComponent::AppendText ( const char *  text)

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

Since
Haiku R1

◆ BStringText()

BString * BTextMailComponent::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.

Since
Haiku R1

◆ GetDecodedData()

status_t BTextMailComponent::GetDecodedData ( BPositionIO data)
virtual

Retrieves the data contained in this component as a UTF8 string into data.

Since
Haiku R1

Reimplemented from BMailComponent.

◆ Quote()

void BTextMailComponent::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.

Since
Haiku R1

◆ RenderToRFC822()

status_t BTextMailComponent::RenderToRFC822 ( BPositionIO render_to)
virtual

Renders the component into RFC-822 format.

It places the result in data, starting at data->Position(). Encodes and translates charsets according to the arguments passed to SetEncoding(), or the defaults set in BTextMailComponent::BTextMailComponent() otherwise.

Since
Haiku R1

Reimplemented from BMailComponent.

◆ SetDecodedData()

status_t BTextMailComponent::SetDecodedData ( BPositionIO data)
virtual

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

Since
Haiku R1

Reimplemented from BMailComponent.

◆ SetEncoding()

void BTextMailComponent::SetEncoding ( mail_encoding  encoding,
int32  charset 
)

Sets the encoding and charset used by Render().

Use the conversion constants from UTF8.h for charset. We strongly reccomend that you always use the defaults (and strongly recommend against using base64) for the reasons outlined in RFC 2047.

Since
Haiku R1

◆ SetText()

void BTextMailComponent::SetText ( const char *  text)

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

Since
Haiku R1

◆ SetToRFC822()

status_t BTextMailComponent::SetToRFC822 ( BPositionIO data,
size_t  length,
bool  parse_now = false 
)
virtual

Sets this object from a component in RFC-822 format.

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.

If parse_now is false, then the data will not be parsed until RenderToRFC822 is called.

Since
Haiku R1

Reimplemented from BMailComponent.

◆ Text()

const char * BTextMailComponent::Text ( )

Returns the contents of this component as a UTF8 string.

Since
Haiku R1