Symbian (Create IAP)创建接入点

我们在选择接入点的时候知道需要在数据库相应的表中取数据
那么要创建接入点当然需要在数据库中相应的表中添加数据字段了.

好让我们来看看需要怎么处理.

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测试通过

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值