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

Represents an mail attachment compatible with Be File System attributes. More...

Inherits BMailAttachment.

Public Member Functions

 BAttributedMailAttachment ()
 Creates an uninitialized BAttributedMailAttachment object.
 
 BAttributedMailAttachment (BFile *file, bool delete_when_done)
 Creates and initializes an attachment object from a file.
 
 BAttributedMailAttachment (entry_ref *ref)
 Creates and initializes an attachment object from a filesystem entry.
 
virtual ~BAttributedMailAttachment ()
 Frees all resources associated with this object.
 
virtual status_t InitCheck ()
 Checks whether the object has been properly initialized or not.
 
virtual status_t MIMEType (BMimeType *mime)
 Places the MIME type of the data into mime.
 
virtual status_t RenderToRFC822 (BPositionIO *render_to)
 Renders the component into RFC-822 format.
 
void SaveToDisk (BEntry *entry)
 Stores the attachment's decoded data in a temporary file on disk.
 
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.
 
Encoding
void SetEncoding (mail_encoding encoding)
 Sets the Content-Transfer-Encoding header to encoding.
 
mail_encoding Encoding ()
 Returns the current Content-Transfer-Encoding header value.
 
Attachment's filename
virtual status_t FileName (char *name)
 Returns the attachment's filename.
 
virtual void SetFileName (const char *name)
 Changes the attachment's filename.
 
Attachment's data
virtual status_t GetDecodedData (BPositionIO *data)
 Retrieves the attachment's decoded data with its attributes and writes them into data.
 
virtual status_t SetDecodedData (BPositionIO *data)
 Sets the attachment's attributes and data to data.
 
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 an mail attachment compatible with Be File System attributes.

This class builds a multipart container where the attached file is copied alongside its Be File System attributes, allowing to send or receive files without losing those filesystem attributes.

Since
Haiku R1

Constructor & Destructor Documentation

◆ BAttributedMailAttachment() [1/3]

BAttributedMailAttachment::BAttributedMailAttachment ( BFile file,
bool  delete_when_done 
)

Creates and initializes an attachment object from a file.

Parameters
[in]fileA file to be used 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

◆ BAttributedMailAttachment() [2/3]

BAttributedMailAttachment::BAttributedMailAttachment ( 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

◆ BAttributedMailAttachment() [3/3]

BAttributedMailAttachment::BAttributedMailAttachment ( )

Creates an uninitialized BAttributedMailAttachment object.

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

Since
Haiku R1

◆ ~BAttributedMailAttachment()

BAttributedMailAttachment::~BAttributedMailAttachment ( )
virtual

Frees all resources associated with this object.

Since
Haiku R1

Member Function Documentation

◆ Encoding()

mail_encoding BAttributedMailAttachment::Encoding ( )

Returns the current Content-Transfer-Encoding header value.

Since
Haiku R1

◆ FileName()

status_t BAttributedMailAttachment::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()

status_t BAttributedMailAttachment::GetDecodedData ( BPositionIO data)
virtual

Retrieves the attachment's decoded data with its attributes and writes them into data.

Parameters
[out]dataA BPositionIO based data stream where to write the output data.
Return values
B_OKThe decoded data and attributes were retrieved 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 BAttributedMailAttachment::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.

◆ MIMEType()

status_t BAttributedMailAttachment::MIMEType ( BMimeType mime)
virtual

Places the MIME type of the data into mime.

Parameters
[out]mimeA pre-allocated BMimeType variable where to write the mimetype.
Since
Haiku R1

Reimplemented from BMailComponent.

◆ RenderToRFC822()

status_t BAttributedMailAttachment::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.

◆ SaveToDisk()

void BAttributedMailAttachment::SaveToDisk ( BEntry entry)

Stores the attachment's decoded data in a temporary file on disk.

The file path will be saved to entry.

Parameters
[out]entryA pre-allocated BEntry where to write the temporary file path.
Since
Haiku R1

◆ SetDecodedData()

status_t BAttributedMailAttachment::SetDecodedData ( BPositionIO data)
virtual

Sets the attachment's attributes and data to data.

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

Reimplemented from BMailComponent.

◆ SetEncoding()

void BAttributedMailAttachment::SetEncoding ( mail_encoding  encoding)

Sets the Content-Transfer-Encoding header to encoding.

Since
Haiku R1

◆ SetFileName()

void BAttributedMailAttachment::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 BAttributedMailAttachment::SetTo ( BFile file,
bool  delete_file_when_done = false 
)
virtual

Initializes the object to the specified file.

Parameters
[in]fileA file to be used 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 BAttributedMailAttachment::SetTo ( entry_ref ref)
virtual

Initializes the object to the specified entry_ref.

Parameters
[in]refAn 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 BAttributedMailAttachment::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 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_BAD_TYPEThe underlying multipart container mimetype is invalid.
B_BAD_VALUEThe data and attributes are NULL.
B_NO_MEMORYNot enough memory to decode the attachment's attributes.
B_IO_ERRORInput/output error retrieving the attributes' data.
Since
Haiku R1

Reimplemented from BMailComponent.