(Difference between revisions)

Messaging API 文档

From Nokia Developer Wiki
Jump to: navigation, search
flycarl (Talk | contribs)
flycarl (Talk | contribs)
Line 79: Line 79:
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
Represents the messaging store identifiers for messages.
Convenient interface for working with messages.
Interface for an internet media (MIME) entity.
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:
Classes relating to messaging accounts:

Revision as of 10:48, 5 January 2011



Qt Messaging API 使我们可以处理信息(短信,彩信,邮件等),搜索信息,排列信息,发送信息,提取信息数据,可以调用平台对应的信息客户端来显示已有的信息,合成新信息,或回复已有信息。


QtMobility API 放在 QtMobility 的命名空间. 这是为以后Mobility APIs 集成到 Qt做准备. 参考Quickstart guide中的例子体会这个命名空间如何影响使用QtMobility的开发development.


Messaging库提供了一系列API来获取信息数据。提供了查询检索信息,文件夹和账号的接口,也有创建,修改和存储信息的接口。提供了一个统一处理和储存短信(sms),彩信(MMS),邮件(MIME Email,TNEF Email)的接口。能处理 不完整提取的信息。




在 Microsoft Windows上,需要安装MAPI头文件,建议通过安装Visual Studio Express来做这件事。

在Linux上,需要安装QMF,同时设置两个环境变量,QMF_INCLUDEDIR设为messagingframework/src/libraries/qtopiamail , QMF_LIBDIR设为build/messagingframework/image/lib。



QMessage 提供信息相关服务的接口类
QMessageAccount 表示一个账号
QMessageAccountFilter 定义检索参数, 用来检索符合条件的账号
QMessageAccountId QMessageAccount 的唯一标识UID
QMessageAccountSortOrder 定义排序的参数, 用来排列账号检索结果
QMessageAddress 表示信息地址的接口
QMessageContentContainer 表示信息内容的接口,支持互联网格式(MIME)和传送中性封装格式(TNEF)的内容,并支持不完整的内容。
QMessageContentContainerId 互联网格式的QMessageContentContainer条目的唯一标识
QMessageDataComparator 包含一些类型,使用这些类型的自定义值来匹配信息。
QMessageFilter 定义查找参数,用来查找信息。
QMessageFolder 表示信息文件夹的接口
QMessageFolderFilter 定义查询参数,用来查找文件夹
QMessageFolderId 信息文件夹的唯一标识UID
QMessageFolderSortOrder 定义排序的参数,用来排列文件夹检索结果
QMessageId 信息的的唯一标识UID
QMessageManager 存储,检索信息,文件夹和账号的主要接口
QMessageService 调用信息服务操作的接口
QMessageSortOrder 定义排序的参数,用来排列信息检索结果


Messaging库提供了一系列类来组合和操作信息数据。所有信息类型表示成统一的格式。信息可以由多个部分组成。 用以组合和操作的信息的类如下:

Class Description
QMessageId 信息的UID
QMessage 一个设计的当的操作信息的接口
QMessageContentContainer 处理互联网媒质(MIME)的接口
QMessageAddress 操作信息地址字符串的接口



Classes relating to messaging accounts: Class Description


Represents the messaging store identifiers for accounts.


Stores attributes for a messaging account.


Represents the messaging store identifiers for folders.


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


Represents the main interface for storage and retrieval of messages, folders and accounts from the messaging store.


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


Defines the parameters used for sorting messages queried from the messaging store.


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


Defines the parameters used for sorting message folders queried from the messaging store.


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


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,
QMessageFilter excludeFilter(QMessageFilter::byTimeStamp(maximumDate,
QMessageFilter outgoingFilter(QMessageFilter::byStatus(QMessage::Incoming,
// 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

   * MessageModel
   * MessageFilter
   * MessageUnionFilter
   * MessageIntersectionFilter

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 Qt Mobility Messaging API.

173 page views in the last 30 days.