MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Messaging

The Qt Messaging API enables access to messaging services to search and sort messages, send messages, retrieve message data, and launch the preferred messaging client on the system to either display an existing message, compose a new message, or respond to an existing message.

Namespace

The QtMobility APIs are placed into the QtMobility namespace. This is done to facilitate the future migration of QtMobility APIs into Qt. See the Quickstart guide for an example on how the namespace impacts on application development.

Overview

The messaging library provides a set of APIs for accessing messaging data. Interfaces are provided to retrieve and query messages, folders and accounts, also interfaces to create, modify, and store messages are provided. A unified interface for manipulation and storage of SMS, MMS, MIME Email and TNEF Email messages is provided. Handling of messages that have only been partially retrieved is supported.

An API to access messaging services to send messages and retrieve message data is provided, as well as messaging services to compose, reply to, forward and show messages using a native application.

Notifications of addition, removal and updating of stored messages can be enabled.

The library provides unified access to the messaging data on a device including concurrent access to messaging data by multiple applications, and independence from the mechanism used to store the messaging data on the device.

On Microsoft Windows, MAPI header files are required to be installed, we recommend installing Visual Studio Express for this purpose.

On Linux QMF 2010W41 or newer is required to be installed and the QMF_INCLUDEDIR and QMF_LIBDIR environment variables set to the messagingframework/src/libraries/qmfclient and build/messagingframework/image/lib directories respectively, and for the LD_LIBRARY_PATH to include the build/messagingframework/image/lib directory.

Reference documentation

Main classes

QMessage

Convenient interface for working with messages

QMessageAccount

Represents a messaging account in the messaging store

QMessageAccountFilter

Defines the parameters used for querying a subset of all available accounts from the messaging store

QMessageAccountId

Unique identifier for a QMessageAccount messaging account, within the scope of the messaging store

QMessageAccountSortOrder

Defines the parameters used for sorting a subset of queried accounts from the messaging store

QMessageAddress

Interface for a message address

QMessageContentContainer

Interface for internet media (MIME) and Transport Neutral Encapsulation Format (TNEF) content that is possibly only partially retrieved

QMessageContentContainerId

Unique identifier for QMessageContentContainer internet media (MIME) type entities, within the scope of the containing message

QMessageDataComparator

Contains types used in specifying the comparison of MessageStore objects with user-defined values

QMessageFilter

Defines the parameters used for querying a subset of all available messages from the messaging store

QMessageFolder

Interface for folders containing messages in the messaging store

QMessageFolderFilter

Defines the parameters used for querying a subset of all available folders from the messaging store

QMessageFolderId

Unique identifier for a QMessageFolder message folder, within the scope of the messaging store

QMessageFolderSortOrder

Defines the parameters used for sorting a subset of queried folders from the messaging store

QMessageId

Unique identifier for a QMessage message within the scope of the messaging store

QMessageManager

Represents the main interface for storage and retrieval of messages, folders and accounts in the system message store

QMessageService

The interface for requesting messaging service operations

QMessageSortOrder

Defines the parameters used for sorting a subset of queried messages from the messaging store

Composition and Manipulation of Messages

The library provides a number of classes to assist with the composition and manipulation of message data. Messages of all supported types are represented uniformly. Messages can be composed of multiple parts.

Classes to assist with composition and manipulation of messages:

Class Description
QMessageId Represents the messaging store identifiers for messages.
QMessage Convenient interface for working with messages.
QMessageContentContainer Interface for an internet media (MIME) entity.
QMessageAddress Interface for manipulating message address strings.

Message Accounts

The library provides classes for accessing information about messaging accounts both outgoing and incoming.

Classes relating to messaging accounts:

Class Description
QMessageAccountId Represents the messaging store identifiers for accounts.
QMessageAccount Stores attributes for a messaging account.
QMessageFolderId Represents the messaging store identifiers for folders.
QMessageFolder Represents a folder of messages on the messaging store.

Sorting and Filtering Functionality

The library provides a number of sort and filter functions to aid in selecting a useful view of data. This reduces the burden on the client of the library for managing the messaging data, as well as allowing better use of the underlying storage mechanism.

Sorting is accomplished by providing a sorting object, specifying the sort order, and the message property upon which to order.

Filtering is accomplished by providing a filtering condition, specifying a value, the property to match, and the desired relation between the value and the property.

Filters can be combined using boolean operators to produce filters of arbitrary complexity.

Classes to assist with sorting and filtering messages:

Class Description
QMessageManager Represents the main interface for storage and retrieval of messages, folders and accounts from the messaging store.
QMessageFilter Defines the parameters used for querying a subset of all available messages from the messaging store.
QMessageSortOrder Defines the parameters used for sorting messages queried from the messaging store.
QMessageFolderFilter Defines the parameters used for querying a subset of all available message folders from the messaging store.
QMessageFolderSortOrder Defines the parameters used for sorting message folders queried from the messaging store.
QMessageAccountFilter Defines the parameters used for querying a subset of all available accounts from the messaging store.
QMessageAccountSortOrder Defines the parameters used for sorting accounts queried from the messaging store.

Using the Ordering Functions

An example of the use of Ordering functions can be found in the Send Message example.

 QMessageIdList ids = QMessageManager().queryMessages(QMessageFilter(),
     QMessageSortOrder::byReceptionTimeStamp(Qt::DescendingOrder), 100, 0);

Using the Filter Functions

The following code is taken from the Keep In Touch example, it demonstrates the use of filters to achieve desired effects. You can also see how the filters once constructed can be operated on by typical boolean operators, in the same way you would manipulate bit settings in C. In this way we can build more complex conditions.

 QMessageFilter includeFilter(QMessageFilter::byTimeStamp(minimumDate,
         QMessageDataComparator::GreaterThanEqual));
 QMessageFilter excludeFilter(QMessageFilter::byTimeStamp(maximumDate,
         QMessageDataComparator::GreaterThanEqual));
 QMessageFilter outgoingFilter(QMessageFilter::byStatus(QMessage::Incoming,
         QMessageDataComparator::Excludes));

 // Search for messages containing addresses to exclude
 service.queryMessages(outgoingFilter & excludeFilter);

 // Create the filter needed to locate messages to search for addresses
 inclusionFilter = (outgoingFilter & includeFilter & ~excludeFilter);

Messaging Services

The library provides the QMessageService class, which provides an interface to communicate with the system's native messaging services, including sending messages, retrieving message data, and composing or showing a message using a native application.

Service actions communciate their operational status by emitting signals.

Functions outside the QMessageService class should not invoke network activity. That is, only QMessageService functions should be responsible for initiating network activity (Note: this is not true for the Windows desktop and mobile platforms, where network activity can occur outside the client's control).

Concurrent Access to Messaging Data

The library provides a level of concurrent access to messaging data by multiple clients.

The concurrent access does guarantee that data won't be corrupted by concurrent access, however it does not give any guarantees as to performance of messaging data access if accessed concurrently by multiple clients.

A single client may access the messaging data from multiple threads, but only one thread may access the data concurrently.

Abstraction of Messaging Data Storage Mechanism

The library abstracts the storage method used to store messaging data.

QML Messaging Elements

Examples

Keep In Touch

The Keep In Touch example shows how to extract useful information from the messages stored by the system.

Service Actions

The Service Actions example is a program to demonstrate how to compose, send, show, query and retrieve messages, and also react to message store events using the QtMobility Messaging API.