Messaging API 文档
| Line 24: | Line 24: | ||
=='''参考文档'''== | =='''参考文档'''== | ||
==='''主要的类'''=== | ==='''主要的类'''=== | ||
| − | {|Border= | + | {|Border="1" |
|QMessage | |QMessage | ||
|提供信息相关服务的接口类 | |提供信息相关服务的接口类 | ||
Revision as of 10:33, 5 January 2011
Contents |
Messaging
Qt Messaging API 使我们可以处理信息(短信,彩信,邮件等),搜索信息,排列信息,发送信息,提取信息数据,可以调用平台对应的信息客户端来显示已有的信息,合成新信息,或回复已有信息。
命名空间
QtMobility API 放在 QtMobility 的命名空间. 这是为以后Mobility APIs 集成到 Qt做准备. 参考Quickstart guide中的例子体会这个命名空间如何影响使用QtMobility的开发development.
简介
Messaging库提供了一系列API来获取信息数据。提供了查询检索信息,文件夹和账号的接口,也有创建,修改和存储信息的接口。提供了一个统一处理和储存短信(sms),彩信(MMS),邮件(MIME Email,TNEF Email)的接口。能处理 不完整提取的信息。
Messaging库提供了接口来发送信息,提取信息包含的数据,合并,回复,转发信息,调用本地应用来显示信息。
当存储的信息,增加,移除和更新的时候可以获得通知。
Messaging库提供了信息数据的统一访问,支持多个应用的并行访问,并不依赖于具体设备上数据的存储方式。
在 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 | 定义排序的参数,用来排列信息检索结果 |
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
* 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.

