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 BPositionIO * | GetDecodedData () |
| 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. | |
| BMailComponent * | WhatIsThis () |
| Employs simple heuristics such as the MIME type to present you with an instance of a useful subclass. | |
Represents a basic mail attachment.
| BSimpleMailAttachment::BSimpleMailAttachment | ( | BPositionIO * | dataToAttach, |
| mail_encoding | encoding = base64 |
||
| ) |
Creates and initializes an attachment object from a BPositionIO based data stream.
| [in] | dataToAttach | The data to attach. |
| [in] | encoding | The encoding format to use in the attachment object. |
| 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.
| [in] | dataToAttach | A buffer for the attachment data. |
| [in] | lengthOfData | The buffer length. |
| [in] | encoding | The encoding format to use in the attachment object. |
| BSimpleMailAttachment::BSimpleMailAttachment | ( | BFile * | file, |
| bool | delete_when_done | ||
| ) |
Creates and initializes an attachment object from a file.
| [in] | file | A file for the attachment. |
| [in] | delete_when_done | Tells if the file has to be deleted when this object is destroyed. |
| BSimpleMailAttachment::BSimpleMailAttachment | ( | entry_ref * | ref | ) |
Creates and initializes an attachment object from a filesystem entry.
| [in] | ref | The filesystem entry from where to retrieve the attachment's data. |
| BSimpleMailAttachment::BSimpleMailAttachment | ( | ) |
Creates an uninitialized BSimpleMailAttachment object.
It can be later be initialized with either SetTo(BFile*, bool) or SetTo(entry_ref *).
|
virtual |
Frees all resources associated with this object.
| mail_encoding BSimpleMailAttachment::Encoding | ( | ) |
Returns the current Content-Transfer-Encoding header value.
|
virtual |
Returns the attachment's filename.
| [out] | name | A pre-allocated variable of B_FILE_NAME_LENGTH length where to write the filename. |
| B_OK | The filename was retrieved successfully. |
| B_NAME_NOT_FOUND | The filename could not be found. |
Implements BMailAttachment.
|
virtual |
Decodes the attachment's encoded data and returns the result to a BPositionIO based data stream.
|
virtual |
Converts the attachment's encoded data back to its unencoded form and writes the result into data.
| [out] | data | A BPositionIO based data stream where to write the output data. |
| B_OK | The attachment's data was written into data successfully. |
| B_IO_ERROR | There is internally no data associated with this attachment. |
| B_BAD_VALUE | data is invalid. |
Reimplemented from BMailComponent.
|
virtual |
Checks whether the object has been properly initialized or not.
B_OK if the object has been properly initialized, or B_NO_INIT otherwise.Implements BMailAttachment.
|
virtual |
Renders the component into RFC-822 format.
B_OK if everything was performed successfully, or an error code otherwise.Reimplemented from BMailComponent.
|
virtual |
Sets the attachment's content to data.
| [in] | data | The data stream from where the data will be copied. |
| B_OK | No error. |
Reimplemented from BMailComponent.
|
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.
| [in] | data | The buffer from where obtain the new contents of the attachment. |
| [in] | length | The buffer's length. |
| B_OK | No error. |
|
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.
| [in] | data | The source from where obtain the new contents of the attachment. |
| B_OK | No error. |
| void BSimpleMailAttachment::SetEncoding | ( | mail_encoding | encoding = base64 | ) |
Sets the Content-Transfer-Encoding header to encoding.
|
virtual |
Changes the attachment's filename.
| [in] | name | The new filename string for the attachment. |
Implements BMailAttachment.
Initializes the object to the specified file.
| [in] | file | A file for the attachment. |
| [in] | delete_file_when_done | Tells if the file has to be deleted when this object is destroyed. |
B_OK on success or an error code otherwise.Implements BMailAttachment.
Initializes the object to the specified entry_ref.
| [in] | ref | The entry_ref for the attachment's data. |
B_OK on success or an error code otherwise.Implements BMailAttachment.
|
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.
| [in] | data | The data source. |
| [in] | length | The data's length. |
| [in] | parse_now | Whether the data will be parsed now or not. |
| B_OK | The operation was performed successfully. |
| B_ERROR | Error in MIME headers' length. |
Reimplemented from BMailComponent.