Symbian (Create IAP)创建接入点
2010-06-21 10:25
429 查看
我们在选择接入点的时候知道需要在数据库相应的表中取数据
那么要创建接入点当然需要在数据库中相应的表中添加数据字段了.
好让我们来看看需要怎么处理.
TCommDbOpeningMethod OpeningMethod;
TInt error;
TUint32 GPRSId;
//打开数据库
CCommsDatabase* commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP,OpeningMethod);
//先打开表OUTGOING_GPRS在表中添加相应字段
CCommsDbTableView* commsView = commsDb->OpenTableLC(TPtrC(OUTGOING_GPRS));
//插入数据
TRAP(error,commsView->InsertRecord(GPRSId));
// 这里是写入这个接入点的设置
commsView->WriteTextL(TPtrC(COMMDB_NAME), KDefaultIapName);
commsView->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), ETrue);
commsView->WriteBoolL(TPtrC(GPRS_IP_ADDR_FROM_SERVER), ETrue);
commsView->WriteBoolL(TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER), ETrue);
commsView->WriteTextL(TPtrC(GPRS_IP_GATEWAY), _L("0.0.0.0"));
commsView->WriteTextL(TPtrC(GPRS_IF_AUTH_NAME), _L(""));
commsView->WriteTextL(TPtrC(GPRS_IF_AUTH_PASS), _L(""));
commsView->WriteTextL(TPtrC(GPRS_APN), _L("cmwap"));
commsView->WriteUintL(TPtrC(GPRS_PDP_TYPE), 0);
commsView->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), EFalse);
commsView->WriteTextL(TPtrC(GPRS_IF_NETWORKS), _L("ip"));
commsView->WriteBoolL(TPtrC(GPRS_HEADER_COMPRESSION), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_DATA_COMPRESSION), EFalse);
commsView->WriteUintL(TPtrC(GPRS_REQ_PRECEDENCE), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_DELAY), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_RELIABILITY), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_PEAK_THROUGHPUT), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_MEAN_THROUGHPUT), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_PRECEDENCE), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_DELAY), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_RELIABILITY), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_PEAK_THROUGHPUT), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_MEAN_THROUGHPUT), 0);
commsView->WriteBoolL(TPtrC(GPRS_ANONYMOUS_ACCESS), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_USE_EDGE), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_ENABLE_LCP_EXTENSIONS), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_DISABLE_PLAIN_TEXT_AUTH), EFalse);
commsView->WriteUintL(TPtrC(GPRS_AP_TYPE), 0);
commsView->WriteUintL(TPtrC(GPRS_QOS_WARNING_TIMEOUT), -1);
commsView->WriteUintL(TPtrC(GPRS_PDP_TYPE), 0);
commsView->WriteTextL(TPtrC(GPRS_PDP_ADDRESS), _L(""));
commsView->WriteTextL(TPtrC(GPRS_IF_PARAMS), _L(""));
commsView->WriteUintL(TPtrC(GPRS_IF_AUTH_RETRIES), 0);
commsView->WriteTextL(TPtrC(GPRS_IP_NETMASK), _L(""));
commsView->WriteTextL(TPtrC(GPRS_IP_ADDR), _L("0.0.0.0"));
commsView->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER1), _L("0.0.0.0"));
commsView->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER2), _L("0.0.0.0"));
//添加完成后记得保存,否则白忙活了
TRAP(error,commsView->PutRecordChanges());
// 在NETWORK表中添加记录
commsView = commsDb->OpenTableLC(TPtrC(NETWORK));
TRAP(error,commsView->InsertRecord(networkId));
commsView->WriteTextL(TPtrC(COMMDB_NAME), _L("WayneNETWORK"));
// 保存设置,并使添加操作生效
TRAP(error,commsView->PutRecordChanges(EFalse, EFalse));
// 查找手机的LOCATION ID
//根据查找的LOCATION表的ID写到IAP表中
TInt result;
TUint32 locationId;
TUint32 mobileLocationId;
commsView = commsDb->OpenTableLC(TPtrC(LOCATION));
result = commsView->GotoFirstRecord();
TBuf<128> locationName;
while (result == KErrNone)
{
commsView->ReadTextL(TPtrC(COMMDB_NAME), locationName);
commsView->ReadUintL(TPtrC(LOCATION_MOBILE), locationId);
if (locationName.Match(_L("Mobile")) != KErrNotFound)
mobileLocationId = locationId;
result = commsView->GotoNextRecord();
}
CleanupStack::PopAndDestroy(commsView);
//利用刚刚找到的LOCATION ID在IAP表中添加记录
TUint32 iapId;
commsView = commsDb->OpenTableLC(TPtrC(IAP));
TRAP(error,commsView->InsertRecord(iapId));
// 设置记录的内容
commsView->WriteTextL(TPtrC(COMMDB_NAME), KDefaultIapName);
commsView->WriteTextL(TPtrC(IAP_SERVICE_TYPE), TPtrC(OUTGOING_GPRS));
commsView->WriteUintL(TPtrC(IAP_SERVICE), GPRSId);
commsView->WriteUintL(TPtrC(IAP_NETWORK_WEIGHTING), 0);
commsView->WriteUintL(TPtrC(IAP_NETWORK), networkId);
commsView->WriteUintL(TPtrC(IAP_BEARER), 2);
commsView->WriteTextL(TPtrC(IAP_BEARER_TYPE), TPtrC(MODEM_BEARER));
commsView->WriteUintL(TPtrC(IAP_LOCATION), mobileLocationId);
// 添加这条新的记录
TRAP(error,commsView->PutRecordChanges());
//如果需要添加WAP接入点,需要在下列表中添加记录
//WAP接入点分二种,一种是彩信接入点,一种是常规WAP接入点
//二种区别在于,接入点的主页不同
// 在WAP_ACCESS_POINT表中添加记录
TUint32 wapId;
commsView = commsDb->OpenTableLC(TPtrC(WAP_ACCESS_POINT));
TRAP(error,commsView->InsertRecord(wapId));
commsView->WriteTextL(TPtrC(COMMDB_NAME), KDefaultIapName);
commsView->WriteTextL(TPtrC(WAP_CURRENT_BEARER), TPtrC(WAP_IP_BEARER));
commsView->WriteLongTextL(TPtrC(WAP_START_PAGE), _L("http://mmsc.monternet.com"));
// 使添加操作生效
TRAP(error,commsView->PutRecordChanges());
CleanupStack::PopAndDestroy(commsView);
// 在WAP_IP_BEARER表中添加记录
TUint32 wapIPId;
commsView = commsDb->OpenTableLC(TPtrC(WAP_IP_BEARER));
TRAP(error,commsView->InsertRecord(wapIPId));
// 属性记录设置
commsView->WriteUintL(TPtrC(WAP_ACCESS_POINT_ID), wapId);
commsView->WriteTextL(TPtrC(WAP_GATEWAY_ADDRESS), _L("0.0.0.0"));
commsView->WriteUintL(TPtrC(WAP_WSP_OPTION),EWapWspOptionConnectionOriented);
commsView->WriteBoolL(TPtrC(WAP_SECURITY), EFalse);
commsView->WriteUintL(TPtrC(WAP_IAP), iapId);
commsView->WriteUintL(TPtrC(WAP_PROXY_PORT), 0);
commsView->WriteTextL(TPtrC(WAP_PROXY_LOGIN_NAME), _L(""));
commsView->WriteTextL(TPtrC(WAP_PROXY_LOGIN_PASS), _L(""));
// 添加完成
TRAP(error,commsView->PutRecordChanges(EFalse, EFalse));
//不要忘记了设置代理网关(中国特色)
TUint32 proxiesId;
CCommsDbTableView* view7 = commsDb->OpenTableLC(TPtrC(PROXIES));
User::LeaveIfError(view7->InsertRecord(proxiesId));
view7->WriteUintL(TPtrC(PROXY_ISP), GPRSId);
view7->WriteTextL(TPtrC(PROXY_SERVICE_TYPE), TPtrC(OUTGOING_GPRS));
view7->WriteBoolL(TPtrC(PROXY_USE_PROXY_SERVER), ETrue);
view7->WriteLongTextL(TPtrC(PROXY_SERVER_NAME), _L("10.0.0.172"));
view7->WriteTextL(TPtrC(PROXY_PROTOCOL_NAME), _L("http"));
view7->WriteUintL(TPtrC(PROXY_PORT_NUMBER), 80);
error = view7->PutRecordChanges(EFalse, EFalse);
CleanupStack::PopAndDestroy(view7);
以上代码在N73,N95,N78测试通过
那么要创建接入点当然需要在数据库中相应的表中添加数据字段了.
好让我们来看看需要怎么处理.
TCommDbOpeningMethod OpeningMethod;
TInt error;
TUint32 GPRSId;
//打开数据库
CCommsDatabase* commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP,OpeningMethod);
//先打开表OUTGOING_GPRS在表中添加相应字段
CCommsDbTableView* commsView = commsDb->OpenTableLC(TPtrC(OUTGOING_GPRS));
//插入数据
TRAP(error,commsView->InsertRecord(GPRSId));
// 这里是写入这个接入点的设置
commsView->WriteTextL(TPtrC(COMMDB_NAME), KDefaultIapName);
commsView->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), ETrue);
commsView->WriteBoolL(TPtrC(GPRS_IP_ADDR_FROM_SERVER), ETrue);
commsView->WriteBoolL(TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER), ETrue);
commsView->WriteTextL(TPtrC(GPRS_IP_GATEWAY), _L("0.0.0.0"));
commsView->WriteTextL(TPtrC(GPRS_IF_AUTH_NAME), _L(""));
commsView->WriteTextL(TPtrC(GPRS_IF_AUTH_PASS), _L(""));
commsView->WriteTextL(TPtrC(GPRS_APN), _L("cmwap"));
commsView->WriteUintL(TPtrC(GPRS_PDP_TYPE), 0);
commsView->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), EFalse);
commsView->WriteTextL(TPtrC(GPRS_IF_NETWORKS), _L("ip"));
commsView->WriteBoolL(TPtrC(GPRS_HEADER_COMPRESSION), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_DATA_COMPRESSION), EFalse);
commsView->WriteUintL(TPtrC(GPRS_REQ_PRECEDENCE), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_DELAY), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_RELIABILITY), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_PEAK_THROUGHPUT), 0);
commsView->WriteUintL(TPtrC(GPRS_REQ_MEAN_THROUGHPUT), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_PRECEDENCE), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_DELAY), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_RELIABILITY), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_PEAK_THROUGHPUT), 0);
commsView->WriteUintL(TPtrC(GPRS_MIN_MEAN_THROUGHPUT), 0);
commsView->WriteBoolL(TPtrC(GPRS_ANONYMOUS_ACCESS), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_USE_EDGE), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_ENABLE_LCP_EXTENSIONS), EFalse);
commsView->WriteBoolL(TPtrC(GPRS_DISABLE_PLAIN_TEXT_AUTH), EFalse);
commsView->WriteUintL(TPtrC(GPRS_AP_TYPE), 0);
commsView->WriteUintL(TPtrC(GPRS_QOS_WARNING_TIMEOUT), -1);
commsView->WriteUintL(TPtrC(GPRS_PDP_TYPE), 0);
commsView->WriteTextL(TPtrC(GPRS_PDP_ADDRESS), _L(""));
commsView->WriteTextL(TPtrC(GPRS_IF_PARAMS), _L(""));
commsView->WriteUintL(TPtrC(GPRS_IF_AUTH_RETRIES), 0);
commsView->WriteTextL(TPtrC(GPRS_IP_NETMASK), _L(""));
commsView->WriteTextL(TPtrC(GPRS_IP_ADDR), _L("0.0.0.0"));
commsView->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER1), _L("0.0.0.0"));
commsView->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER2), _L("0.0.0.0"));
//添加完成后记得保存,否则白忙活了
TRAP(error,commsView->PutRecordChanges());
// 在NETWORK表中添加记录
commsView = commsDb->OpenTableLC(TPtrC(NETWORK));
TRAP(error,commsView->InsertRecord(networkId));
commsView->WriteTextL(TPtrC(COMMDB_NAME), _L("WayneNETWORK"));
// 保存设置,并使添加操作生效
TRAP(error,commsView->PutRecordChanges(EFalse, EFalse));
// 查找手机的LOCATION ID
//根据查找的LOCATION表的ID写到IAP表中
TInt result;
TUint32 locationId;
TUint32 mobileLocationId;
commsView = commsDb->OpenTableLC(TPtrC(LOCATION));
result = commsView->GotoFirstRecord();
TBuf<128> locationName;
while (result == KErrNone)
{
commsView->ReadTextL(TPtrC(COMMDB_NAME), locationName);
commsView->ReadUintL(TPtrC(LOCATION_MOBILE), locationId);
if (locationName.Match(_L("Mobile")) != KErrNotFound)
mobileLocationId = locationId;
result = commsView->GotoNextRecord();
}
CleanupStack::PopAndDestroy(commsView);
//利用刚刚找到的LOCATION ID在IAP表中添加记录
TUint32 iapId;
commsView = commsDb->OpenTableLC(TPtrC(IAP));
TRAP(error,commsView->InsertRecord(iapId));
// 设置记录的内容
commsView->WriteTextL(TPtrC(COMMDB_NAME), KDefaultIapName);
commsView->WriteTextL(TPtrC(IAP_SERVICE_TYPE), TPtrC(OUTGOING_GPRS));
commsView->WriteUintL(TPtrC(IAP_SERVICE), GPRSId);
commsView->WriteUintL(TPtrC(IAP_NETWORK_WEIGHTING), 0);
commsView->WriteUintL(TPtrC(IAP_NETWORK), networkId);
commsView->WriteUintL(TPtrC(IAP_BEARER), 2);
commsView->WriteTextL(TPtrC(IAP_BEARER_TYPE), TPtrC(MODEM_BEARER));
commsView->WriteUintL(TPtrC(IAP_LOCATION), mobileLocationId);
// 添加这条新的记录
TRAP(error,commsView->PutRecordChanges());
//如果需要添加WAP接入点,需要在下列表中添加记录
//WAP接入点分二种,一种是彩信接入点,一种是常规WAP接入点
//二种区别在于,接入点的主页不同
// 在WAP_ACCESS_POINT表中添加记录
TUint32 wapId;
commsView = commsDb->OpenTableLC(TPtrC(WAP_ACCESS_POINT));
TRAP(error,commsView->InsertRecord(wapId));
commsView->WriteTextL(TPtrC(COMMDB_NAME), KDefaultIapName);
commsView->WriteTextL(TPtrC(WAP_CURRENT_BEARER), TPtrC(WAP_IP_BEARER));
commsView->WriteLongTextL(TPtrC(WAP_START_PAGE), _L("http://mmsc.monternet.com"));
// 使添加操作生效
TRAP(error,commsView->PutRecordChanges());
CleanupStack::PopAndDestroy(commsView);
// 在WAP_IP_BEARER表中添加记录
TUint32 wapIPId;
commsView = commsDb->OpenTableLC(TPtrC(WAP_IP_BEARER));
TRAP(error,commsView->InsertRecord(wapIPId));
// 属性记录设置
commsView->WriteUintL(TPtrC(WAP_ACCESS_POINT_ID), wapId);
commsView->WriteTextL(TPtrC(WAP_GATEWAY_ADDRESS), _L("0.0.0.0"));
commsView->WriteUintL(TPtrC(WAP_WSP_OPTION),EWapWspOptionConnectionOriented);
commsView->WriteBoolL(TPtrC(WAP_SECURITY), EFalse);
commsView->WriteUintL(TPtrC(WAP_IAP), iapId);
commsView->WriteUintL(TPtrC(WAP_PROXY_PORT), 0);
commsView->WriteTextL(TPtrC(WAP_PROXY_LOGIN_NAME), _L(""));
commsView->WriteTextL(TPtrC(WAP_PROXY_LOGIN_PASS), _L(""));
// 添加完成
TRAP(error,commsView->PutRecordChanges(EFalse, EFalse));
//不要忘记了设置代理网关(中国特色)
TUint32 proxiesId;
CCommsDbTableView* view7 = commsDb->OpenTableLC(TPtrC(PROXIES));
User::LeaveIfError(view7->InsertRecord(proxiesId));
view7->WriteUintL(TPtrC(PROXY_ISP), GPRSId);
view7->WriteTextL(TPtrC(PROXY_SERVICE_TYPE), TPtrC(OUTGOING_GPRS));
view7->WriteBoolL(TPtrC(PROXY_USE_PROXY_SERVER), ETrue);
view7->WriteLongTextL(TPtrC(PROXY_SERVER_NAME), _L("10.0.0.172"));
view7->WriteTextL(TPtrC(PROXY_PROTOCOL_NAME), _L("http"));
view7->WriteUintL(TPtrC(PROXY_PORT_NUMBER), 80);
error = view7->PutRecordChanges(EFalse, EFalse);
CleanupStack::PopAndDestroy(view7);
以上代码在N73,N95,N78测试通过
相关文章推荐
- Symbian (Create IAP)创建接入点
- symbian openc socket 接入点 iap
- 【转】Symbian IAP 浅谈(Symbian网络接入点常用编程)
- Symbian S60 访问IAP表中的接入点信息
- symbian 2nd中从屏蔽接入点选择以及创建新的接入点
- symbian 2nd中从屏蔽接入点选择以及创建新的接入点
- Symbian IAP的选择以及接入点的隐藏
- Symbian S60 访问IAP表中的接入点信息
- symbian 2nd中从屏蔽接入点选择以及创建新的接入点
- symbian 2nd中从屏蔽接入点选择以及创建新的接入点 --------------牛人的作品啊!
- Symbian(Create sub menu)如何创建二级菜单
- Symbian (Choice IAP)选择接入点
- symbian创建新的接入点
- symbian 2nd中从屏蔽接入点选择以及创建新的接入点
- Symbian IAP的选择以及接入点的隐藏
- 【转】Symbian IAP 浅谈(Symbian网络接入点常用编程)
- symbian 创建cmwap接入点
- Symbian IAP的选择以及接入点的隐藏
- 创建Server(tomcat)时候报Cannot create a server using the selected type
- ArcGIS For JavaScript API Dynamically create layer list(动态创建图层列表)