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

Represents a basic mail attachment. More...

Inherits BMailAttachment.

Public Member Functions

 BSimpleMailAttachment ()
 Creates an uninitialized BSimpleMailAttachment object.
 
 BSimpleMailAttachment (BFile *file, bool delete_when_done)
 Creates and initializes an attachment object from a file.
 
 BSimpleMailAttachment (BPositionIO *dataToAttach, mail_encoding encoding=base64)
 Creates and initializes an attachment object from a BPositionIO based data stream.
 
 BSimpleMailAttachment (const void *dataToAttach, size_t lengthOfData, mail_encoding encoding=base64)
 Creates and initializes an attachment object from a buffer.
 
 BSimpleMailAttachment (entry_ref *ref)
 Creates and initializes an attachment object from a filesystem entry.
 
virtual ~BSimpleMailAttachment ()
 Frees all resources associated with this object.
 
virtual status_t InitCheck ()
 Checks whether the object has been properly initialized or not.
 
virtual status_t RenderToRFC822 (BPositionIO *render_to)
 Renders the component into RFC-822 format.
 
virtual status_t SetTo (BFile *file, bool delete_file_when_done=false)
 Initializes the object to the specified file.
 
virtual status_t SetTo (entry_ref *ref)
 Initializes the object to the specified entry_ref.
 
virtual status_t SetToRFC822 (BPositionIO *data, size_t length, bool parse_now=false)
 Sets this object from a data stream in a RFC-822 compliant format.
 
Attachment's filename
virtual void SetFileName (const char *name)
 Changes the attachment's filename.
 
virtual status_t FileName (char *name)
 Returns the attachment's filename.
 
Attachment's data
virtual status_t GetDecodedData (BPositionIO *data)
 Converts the attachment's encoded data back to its unencoded form and writes the result into data.
 
virtual status_t SetDecodedData (BPositionIO *data)
 Sets the attachment's content to data.
 
virtual BPositionIOGetDecodedData ()
 Decodes the attachment's encoded data and returns the result to a BPositionIO based data stream.
 
virtual status_t SetDecodedData (const void *data, size_t length)
 Sets the attachment's content to the contents in the data generic buffer of length.
 
virtual status_t SetDecodedDataAndDeleteWhenDone (BPositionIO *data)
 Sets the attachment's content to the contents contained in data.
 
Encoding
void SetEncoding (mail_encoding encoding=base64)
 Sets the Content-Transfer-Encoding header to encoding.
 
mail_encoding Encoding ()
 Returns the current Content-Transfer-Encoding header value.
 
virtual status_t InitCheck ()=0
 Pure virtual to check if the object was successfully initialized.
 
virtual status_t SetTo (BFile *file, bool deleteFileWhenDone=false)=0
 Pure virtual to initialize the object's attached file.
 
virtual status_t SetTo (entry_ref *ref)=0
 Pure virtual to initialize the object's attached file.
 
Attachment's filename
- 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

Represents a basic mail attachment.

Since
Haiku R1

Constructor & Destructor Documentation

◆ BSimpleMailAttachment() [1/5]

BSimpleMailAttachment::BSimpleMailAttachment ( BPositionIO dataToAttach,
mail_encoding  encoding = base64 
)

Creates and initializes an attachment object from a BPositionIO based data stream.

Parameters
[in]dataToAttachThe data to attach.
[in]encodingThe encoding format to use in the attachment object.
Since
Haiku R1

◆ BSimpleMailAttachment() [2/5]

BSimpleMailAttachment::BSimpleMailAttachment ( const void *  dataToAttach,
size_t  lengthOfData,
mail_encoding  encoding = base64 
)

Creates and initializes an attachment object from a buffer.

This constructor takes ownership of the data. This means that the data is deleted upon new calls of SetDecodedData() and when the object is destroyed as well.

Parameters
[in]dataToAttachA buffer for the attachment data.
[in]lengthOfDataThe buffer length.
[in]encodingThe encoding format to use in the attachment object.
Since
Haiku R1

◆ BSimpleMailAttachment() [3/5]

BSimpleMailAttachment::BSimpleMailAttachment ( BFile file,
bool  delete_when_done 
)

Creates and initializes an attachment object from a file.

Parameters
[in]fileA file for the attachment.
[in]delete_when_doneTells if the file has to be deleted when this object is destroyed.
See also
SetTo(BFile*, bool)
Since
Haiku R1

◆ BSimpleMailAttachment() [4/5]

BSimpleMailAttachment::BSimpleMailAttachment ( entry_ref ref)

Creates and initializes an attachment object from a filesystem entry.

Parameters
[in]refThe filesystem entry from where to retrieve the attachment's data.
See also
SetTo(entry_ref*)
Since
Haiku R1

◆ BSimpleMailAttachment() [5/5]

BSimpleMailAttachment::BSimpleMailAttachment ( )

Creates an uninitialized BSimpleMailAttachment object.

It can be later be initialized with either SetTo(BFile*, bool) or SetTo(entry_ref *).

Since
Haiku R1

◆ ~BSimpleMailAttachment()

BSimpleMailAttachment::~BSimpleMailAttachment ( )
virtual

Frees all resources associated with this object.

Since
Haiku R1

Member Function Documentation

◆ Encoding()

mail_encoding BSimpleMailAttachment::Encoding ( )

Returns the current Content-Transfer-Encoding header value.

Since
Haiku R1

◆ FileName()

status_t BSimpleMailAttachment::FileName ( char *  name)
virtual

Returns the attachment's filename.

Parameters
[out]nameA pre-allocated variable of B_FILE_NAME_LENGTH length where to write the filename.
Return values
B_OKThe filename was retrieved successfully.
B_NAME_NOT_FOUNDThe filename could not be found.
Since
Haiku R1

Implements BMailAttachment.

◆ GetDecodedData() [1/2]

BPositionIO * BSimpleMailAttachment::GetDecodedData ( )
virtual

Decodes the attachment's encoded data and returns the result to a BPositionIO based data stream.

Since
Haiku R1

◆ GetDecodedData() [2/2]

status_t BSimpleMailAttachment::GetDecodedData ( BPositionIO data)
virtual

Converts the attachment's encoded data back to its unencoded form and writes the result into data.

Parameters
[out]dataA BPositionIO based data stream where to write the output data.
Return values
B_OKThe attachment's data was written into data successfully.
B_IO_ERRORThere is internally no data associated with this attachment.
B_BAD_VALUEdata is invalid.
Since
Haiku R1

Reimplemented from BMailComponent.

◆ InitCheck()

status_t BSimpleMailAttachment::InitCheck ( )
virtual

Checks whether the object has been properly initialized or not.

Returns
B_OK if the object has been properly initialized, or B_NO_INIT otherwise.
Since
Haiku R1

Implements BMailAttachment.

◆ RenderToRFC822()

status_t BSimpleMailAttachment::RenderToRFC822 ( BPositionIO render_to)
virtual

Renders the component into RFC-822 format.

Returns
B_OK if everything was performed successfully, or an error code otherwise.
Since
Haiku R1

Reimplemented from BMailComponent.

◆ SetDecodedData() [1/2]

status_t BSimpleMailAttachment::SetDecodedData ( BPositionIO data)
virtual

Sets the attachment's content to data.

Parameters
[in]dataThe data stream from where the data will be copied.
Return values
B_OKNo error.
Since
Haiku R1

Reimplemented from BMailComponent.

◆ SetDecodedData() [2/2]

status_t BSimpleMailAttachment::SetDecodedData ( const void *  data,
size_t  length 
)
virtual

Sets the attachment's content to the contents in the data generic buffer of length.

This overloaded version takes ownership of the data buffer, so the data is deleted upon new calls of SetDecodedData() and when the object is destroyed as well.

Parameters
[in]dataThe buffer from where obtain the new contents of the attachment.
[in]lengthThe buffer's length.
Return values
B_OKNo error.
Since
Haiku R1

◆ SetDecodedDataAndDeleteWhenDone()

status_t BSimpleMailAttachment::SetDecodedDataAndDeleteWhenDone ( BPositionIO data)
virtual

Sets the attachment's content to the contents contained in data.

This method takes ownership of the data buffer, so the data is deleted upon new calls of SetDecodedData() and when the object is destroyed as well.

Parameters
[in]dataThe source from where obtain the new contents of the attachment.
Return values
B_OKNo error.
Since
Haiku R1

◆ SetEncoding()

void BSimpleMailAttachment::SetEncoding ( mail_encoding  encoding = base64)

Sets the Content-Transfer-Encoding header to encoding.

Since
Haiku R1

◆ SetFileName()

void BSimpleMailAttachment::SetFileName ( const char *  name)
virtual

Changes the attachment's filename.

Parameters
[in]nameThe new filename string for the attachment.
Since
Haiku R1

Implements BMailAttachment.

◆ SetTo() [1/2]

status_t BSimpleMailAttachment::SetTo ( BFile file,
bool  delete_file_when_done = false 
)
virtual

Initializes the object to the specified file.

Parameters
[in]fileA file for the attachment.
[in]delete_file_when_doneTells if the file has to be deleted when this object is destroyed.
Returns
B_OK on success or an error code otherwise.
Since
Haiku R1

Implements BMailAttachment.

◆ SetTo() [2/2]

status_t BSimpleMailAttachment::SetTo ( entry_ref ref)
virtual

Initializes the object to the specified entry_ref.

Parameters
[in]refThe entry_ref for the attachment's data.
Returns
B_OK on success or an error code otherwise.
Since
Haiku R1

Implements BMailAttachment.

◆ SetToRFC822()

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

Sets this object from a data stream in a RFC-822 compliant format.

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

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

Parameters
[in]dataThe data source.
[in]lengthThe data's length.
[in]parse_nowWhether the data will be parsed now or not.
Return values
B_OKThe operation was performed successfully.
B_ERRORError in MIME headers' length.
Since
Haiku R1

Reimplemented from BMailComponent.