Attachment

Since: BlackBerry 10.0.0

#include <bb/pim/message/Attachment>

To link against this class, add the following line to your .pro file: LIBS += -lbbpim

The Attachment class represents an attachment to a message.

This class includes information about an attachment to a Message object, such as file path to the attachment on the file system, MIME type, and optional metadata. You can retrieve the list of attachments for a Message by calling Message::attachments().

You can also use the MessageService class to retrieve message attachments. You can download the attachment of a Message by calling MessageService::downloadAttachment().

Each Attachment object has a key, which is represented by an AttachmentKey, and this key uniquely identifies the attachment.


Overview

Public Functions Index

Attachment ()
Attachment (const QString &mimeType, const QString &name, const QUrl &path)
Attachment (const QString &mimeType, const QString &name, const QUrl &path, const QVariantMap &metaData)
Attachment (const QString &mimeType, const QString &name, const QString &textData)
Attachment (const QString &mimeType, const QString &name, const QByteArray &data)
Attachment (const QString &mimeType, const QString &name, const QByteArray &data, const QVariantMap &metaData)
Attachment (AttachmentPrivate *attachmentPrivate)
Attachment (const Attachment &other)
~Attachment ()
intavailableSize () const
qint64availableSize64 () const
QStringcontentId () const
QByteArraydata () const
QByteArrayiconData () const
QUrliconPath () const
AttachmentKeyid () const
boolisInline () const
boolisValid () const
QVariantMapmetaData () const
QStringmimeType () const
QStringname () const
booloperator!= (const Attachment &other) const
Attachment &operator= (const Attachment &other)
booloperator== (const Attachment &other) const
QUrlpath () const
inttotalSize () const
qint64totalSize64 () const

Public Functions

Attachment ()

Constructs an empty, invalid Attachment.

Since:

BlackBerry 10.0.0

Attachment (

Constructs an Attachment with the provided MIME type, name, and file path.

This constructor creates an attachment object with the provided MIME type and name by using the data that's contained in the file at the provided file path.

Parameters
mimeType

The MIME type of the attachment to construct.

name

The name of the attachment to construct.

path

The URL that specifies the file path of the data to use to construct the attachment. The file:// schema is the only supported schema for the URL. If you want the file at this file path to be deleted if and when the associated message is removed from the messages database, you should listen for storage deletions and delete file yourself. NOTE: It's important to note that a QUrl is passed and not a QString / QByteArray. An implicit conversion will not be performed. Instead, one of the other constructors will be called.

Since:

BlackBerry 10.0.0

Attachment (

Constructs an Attachment with the provided MIME type, name, path, and metadata.

This constructor creates an attachment object with the provided MIME type, name, and metadata by using the data that's contained in the file at the provided file path.

Parameters
mimeType

The MIME type of the attachment to construct.

name

The name of the attachment to construct.

path

The URL that specifies the file path of the data to use to construct the attachment. The file:// schema is the only supported schema for the URL. If you want the file at this file path to be deleted if and when the associated message is removed from the messages database, you should listen for storage deletions and delete file yourself. NOTE: It's important to note that a QUrl is passed and not a QString / QByteArray. An implicit conversion will not be performed. Instead, one of the other constructors will be called.

metaData

A QVariantMap that contains additional metadata associated with this attachment. The interpretation and use of its keys and values are implementation-specific.

Since:

BlackBerry 10.0.0

Attachment (

Constructs an Attachment with the provided MIME type, name, and text data.

This constructor creates an attachment object with the provided MIME type, name, and text data. The text data is assumed to be encoded in UTF-8.

Parameters
mimeType

The MIME type of the attachment to construct.

name

The name of the attachment to construct.

textData

The UTF-8 text data for the attachment to construct. NOTE: It's important to note that a QString is passed and not a QUrl / QByteArray. An implicit conversion will not be performed. Instead, one of the other constructors will be called.

Since:

BlackBerry 10.0.0

Attachment (

Construct an Attachment with the provided MIME type, name, and binary data.

This constructor creates an attachment object with the provided MIME type, name, and binary data (which is represented by a QByteArray).

Parameters
mimeType

The MIME type of the attachment to construct.

name

The name of the attachment to construct.

data

The data for the attachment to construct. NOTE: It's important to note that a QByteArray is passed and not a QUrl / QString. An implicit conversion will not be performed. Instead, one of the other constructors will be called.

Since:

BlackBerry 10.0.0

Attachment (

Construct an Attachment with the provided MIME type, name, binary data, and metadata.

This constructor creates an attachment object with the provided MIME type, name, binary data (which is represented by a QByteArray), and metadata.

Parameters
mimeType

The MIME type of the attachment to construct.

name

The name of the attachment to construct.

data

The data for the attachment to construct. NOTE: It's important to note that a QByteArray is passed and not a QUrl / QString. An implicit conversion will not be performed. Instead, one of the other constructors will be called.

metaData

A QVariantMap that contains additional metadata associated with this attachment. The interpretation and use of its keys and values are implementation-specific.

Since:

BlackBerry 10.0.0

Attachment (
  • AttachmentPrivate *attachmentPrivate)

Constructs an Attachment from the provided private data.

Parameters
attachmentPrivate

The private data to construct the attachment from.

Since:

BlackBerry 10.0.0

Attachment (

Copy constructor.

This function constructs an Attachment containing exactly the same values as the provided Attachment.

Parameters
other

The Attachment to be copied.

Since:

BlackBerry 10.0.0

~Attachment ()

Destructor.

This function cleans up and frees the attachment's data and resources.

Since:

BlackBerry 10.0.0

int availableSize ()

Retrieves the available size (in bytes) of this Attachment.

This function returns the available size (in bytes) of the attachment. The available size is typically the same as the total size but may be different for some services. For example, the messaging service uses the available size to determine how much of the attachment has actually been downloaded.

Return:

The attachment's available size (in bytes). Returns -1 for size values greater than 2^31-1

Since:

BlackBerry 10.0.0

qint64 availableSize64 ()

Retrieves the available size (in bytes) of this Attachment.

This function returns, as a uint64, the available size (in bytes) of the attachment. The available size is typically the same as the total size but may be different for some services. For example, the messaging service uses the available size to determine how much of the attachment has actually been downloaded.

Return:

The attachment's available size (in bytes) as a qint64.

Since:

BlackBerry 10.3.0

QString contentId ()

Retrieves the content ID for this Attachment.

Return:

The attachment's content ID.

Since:

BlackBerry 10.0.0

QByteArray data ()

Retrieves the data of this Attachment.

This function returns the attachment's data. If the attachment was constructed with a path, the data from the file at the path is lazily loaded and then returned. If the data is text data, it is encoded in UTF-8.

Return:

The attachment's data.

Since:

BlackBerry 10.0.0

QByteArray iconData ()

Retrieves the icon data of this Attachment.

This function returns the data of any icon associated with the attachment. If the attachment icon was specified using a path, the data from the file at the path is lazily loaded and then returned.

Return:

The attachment's icon data.

Since:

BlackBerry 10.0.0

QUrl iconPath ()

Retrieves the file path of the icon of this Attachment.

This function returns the path of any icon associated with the attachment, as a URL using the file::// schema. If the icon was set using data instead of a path, the internal path used to store the icon data is returned, if it exists. Otherwise, an empty QUrl is returned.

Return:

The attachment's icon path as a file:// URL, if it exists, and an empty QUrl otherwise.

Since:

BlackBerry 10.0.0

AttachmentKey id ()

Retrieves the attachment ID of this Attachment.

This function returns the ID that's associated with the attachment.

Return:

The attachment's ID.

Since:

BlackBerry 10.0.0

bool isInline ()

Indicates whether this Attachment is an inline attachment.

Return:

true if this Attachment is an inline attachment, false otherwise.

Since:

BlackBerry 10.0.0

bool isValid ()

Indicates whether this Attachment is valid.

Return:

true if this Attachment is valid, false otherwise.

Since:

BlackBerry 10.0.0

QVariantMap metaData ()

Retrieves the metadata of this Attachment.

This function returns any metadata that's associated with the attachment. Metadata is returned as a QVariantMap. The interpretation and use of its keys and values are implementation-specific.

Return:

The attachment's metadata.

Since:

BlackBerry 10.0.0

QString mimeType ()

Retrieves the MIME type of this Attachment.

Return:

The attachment's MIME type.

Since:

BlackBerry 10.0.0

QString name ()

Retrieves the name of this Attachment.

Return:

The attachment's name.

Since:

BlackBerry 10.0.0

bool operator!= (

Inequality operator.

This function indicates whether this Attachment does not have exactly the same values as the provided Attachment.

Parameters
other

The Attachment to compare values with.

Return:

true if the attachments are not considered equal, false otherwise.

Since:

BlackBerry 10.0.0

Attachment & operator= (

Assignment operator.

This operator copies all values from the provided Attachment into this Attachment.

Parameters
other

The Attachment from which to copy all values.

Return:

An Attachment with all copied data.

Since:

BlackBerry 10.0.0

bool operator== (

Equality operator.

This function indicates whether this Attachment has exactly the same values as the provided Attachment.

Parameters
other

The Attachment to compare values with.

Return:

true if the attachments are considered equal, false otherwise.

Since:

BlackBerry 10.0.0

QUrl path ()

Retrieves the file path of this Attachment on the file system.

This function returns the path to the attachment's data as a URL using the file:// schema. If the attachment was constructed with data instead of a path, the internal path used to store the data is returned, if it exists. Otherwise, an empty QUrl is returned.

Return:

The attachment's path as a file:// URL, if it exists, and an empty QUrl otherwise.

Since:

BlackBerry 10.0.0

int totalSize ()

Retrieves the total size (in bytes) of this Attachment.

Return:

The attachment's total size (in bytes). Returns -1 for size values greater than 2^31-1

Since:

BlackBerry 10.0.0

qint64 totalSize64 ()

Retrieves the total size (in bytes) of this Attachment.

Return:

The attachment's total size (in bytes) as a qint64.

Since:

BlackBerry 10.3.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus