越来越多的应用软件需要使用手机连接。发送短信(SMS)许可,利用彩信(MMS)传输图片,管理邮件(Pop3, IMAP 和 SMTP)或是简单地使用http客户端口或是利用GPRS, CSD或 WCDMA(UMTS).自定义基于TCP/IP 的协议。以上只是简单的概述功能,操作系统需要访问内部数据库来获取关于如何操作协议栈的信息。该数据库就称为CommDB。
在SDK文档中查询“Using CommDB”,连接其他主题,会发现很多关于“communications database”的基本信息。
在上次的symbian项目中,我想和大家共享一下新添的一些见解(Symbian OS versions 6.1, 7.0, 7.0s)并欢迎大家评论。我不想过多展示程序代码,因为在SDK文档、Symbian FAQ和一些新闻组中已经有了很多解释。本文的目标是介绍如何理解 CommmDD设计和访问它时的基本性质。
1.基本术语
CommDB 是一种文件,在Symbian OS 6.1 (Series 60 v0.9, v1.0, v1.2) 中名为cdbv2.dat ,在Symbian OS 7.0s/7.0 (Series 60 2.0 / UIQ 2.0, UIQ 2.1)名为 cdbv3.dat 。
可以在手机中两个位置找到该文件: C:\system\data\ -RAM-Version ,用来存储当时数据。 Z:\system\data\ - ROM-Version,如果不能找到RAM-version,则该文件被拷贝到RAM中(从未检测过该性质)。
该文件可以通过通信数据库服务器访问到(DBMS上的一层)。该服务器提供一个逻辑访问到存在于以连接表中的(外部)数据库。每个关于如何通过特殊协议获得连接访问或传输类型的逻辑概要被称为Internet Access Point (IAP)。Series 60 和 UIQ 都提供用户界面来管理IAP并改变CommDB:
  每个手机网络提供商都需要自己独立的配置。因此大部分手机来自手机提供商普通IAP的一个子集,已经配置的有SMS, WAP, WWW ,它们利用不同的传输系统传输,如GSM, GPRS或 GPRS。用户可以通过以上对话框或是BIO messaging手动增加新的访问节点。BIO messaging是一种来自提供商的SMS系统,用于配置手机。
作为开发者,不需要解决为所需的连接类型选择适当的IAP问题-操作系统会提供给用户选择对话框。但是如果想利用特别的IAP,例如专用WAP或企业网网关,就需要插入新的IAP并选中。这个可以通过直接改变CommDB表格或如果是开发Series 60,可用Nokia的访问点到引擎库(ApEngine)。
2.Nokia的 ApEngine (概括调查)
该库压缩了CommDB-API并提供了几个可嵌入到程序中的对话和视图。 一下这些类可以有效帮助程序员。(连接到apengine.lib)
| Classname |
Headerfile |
Description (taken from SDK)
|
CApSelect
|
<apselect.h> |
This class is used to help client’s access point selection. Selection can be tailored with specific filters, rules and sort order. Provides methods for setting and getting filters and sort order.
|
ApListItem |
<aplistitem.h> |
This class is used to hold the main information of an access point. It is used in CApSelect.
|
CApDatahandler |
<apdatahandler.h> |
Representation of the access point handler. Encapsulates a session with the CommsDB Provides a way to access the database and manipulate its data.
|
CApAccessPointItem |
<apaccesspointitem.h> |
CApAccessPointItem is used to exchange data between engine and client. It holds the information for an access point including WAP, IAP, ISP (if present & applies). This class uses the same approach as CommDB to read and write data: it has functions for each data type implemented. To read or write the data, we have to know the data type and the enum name of the ’column’. The column values has the names of the database columns with the ’EAp’ prefix. The reason for this (not using the database column descriptors) is performance. It is much faster to compare enum values than literals.
|
CApUtils
|
<aputils.h> |
Representation of access point utilities. Provides utilities to access points for clients. Encapsulates database handling. This class provides utility functions for clients that need some specific information or parameters from (maybe more than one) AP. It is provided for ease of use so clients do not have to work with CApDataHandler’s concept (one object-one Uid). | 头文件中有许多其余的信息。主要观察,有些头文件不存在于OS 7.0s。可从 6.1中拷贝过来,并可用于我的需要
以下有两个关于如何使用的小例子:
/*Ex1: Show a list of all IAPs (Series 60 only) */
CApSettingsHandler* settingsHandler = CApSettingsHandler::NewLC( EFalse, EApSettingsSelListIsListPane, EApSettingsSelMenuNormal, KEApIspTypeAll, EApBearerTypeAll, KEApSortNameAscending); TUint32 originallyFocused(uid); TUint32 selectedIap(uid);
// Show the dialog settingsHandler->RunSettingsL(originallyFocused, selectedIap);
CleanupStack::PopAndDestroy(settingsHandler);
/*Ex2: Iterate over a list of IAPs (Series 60 only) */
CCommsDatabase* CommDb = CCommsDatabase::NewL(EDatabaseTypeIAP); CleanupStack::PushL(CommDb);
CApSelect* ApSelect = CApSelect::NewLC(*CommDb, KEApIspTypeAll ,EApBearerTypeAll ,KEApSortUidAscending);
if (ApSelect->MoveToFirst()) { do { TUint uid = ApSelect->Uid(); //put here your IAP stuff
} while(ApSelect->MoveNext()); }
CleanupStack::PopAndDestroy(ApSelect); CleanupStack::PopAndDestroy(CommDb);
当使用ApEngine (或是Series 60 GUI)来增加新的IAP,总要在表格WAP_ACCESS_POINT,中寻找一入口,即使这样,IAP也不是针对无线连接-它的网关是“0.0.0.0”!
3.UiQ-缺少访问点引擎
在UiQ’的SDK 中,不会找到apengine.dll。如果想要选择或创建IAP就必须使用“原始”CommDB-API -查看SDK文档“How to access tables in the database”。
SDK文档列出所有关于其内容简单描述的表格,但对于他们之间的关系阐述的不明确。所以我为Symbian OS 6.1, 7.0 和7.0s.创建了CommDB-datamodel,虽不完美,但也可以帮助你增长见识。
CommDB v2 - Symbian OS v6.1 CommDB v3 - Symbian v7.0 CommDB v3 - Symbian v7.0s (截图)
 图例:每个表和列都拥有名字(查看<cdbcols.h> )。例如表IAP 有一列COMMDB_ID,这是表的主键(PK)。列COMMDB_ID 和 COMMDB_NAME是默认列,几乎在每个表中都可见。如果有一个或更多的外键(IAP_SERVICE 为 FK2, FK3),可发现这个值在另一表中自然为主键。这个关系就是一个名称OUTGOING_GPRS_IAP_FK2。可选择一个或多个外键(FK2, FK3)到一个或多个表格,访问表被定义在IAP_SERVICE_TYPE (包含外表的名字)。
一些例子代码: //Get all existing IAPs CCommsDatabase* CommDb = CCommsDatabase::NewL(EDatabaseTypeIAP); CleanupStack::PushL(CommDb); CCommsDbTableView* tableIAP = CommDb->OpenTableLC(TPtrC(IAP)); if (tableIAP->GotoFirstRecord()==KErrNone) { do { TUint32 uid(0); tableIAP->ReadUintL(TPtrC(COMMDB_ID),uid); ... tableIAP->ReadTextL(TPtrC(COMMDB_NAME),CommDBNamePtr); ... } while(tableIAP->GotoNextRecord()==KErrNone); } CleanupStack::PopAndDestroy(tableIAP); CleanupStack::PopAndDestroy(CommDb); 4.Symbian 工具
这里介绍一些可用于编辑并堆存储CommDB的工具-CEDDUMP, CED, CommDb Editor 。读Symbians FAQ-1071 可获得更多信息。
此文为开发视界翻译转载者请注明出处否则追究法律责任 |