注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Simon

 
 
 

日志

 
 

Symbian (Create IAP)创建接入点  

2010-10-16 21:38:35|  分类: Symbian C++ |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
前篇blog文我们介绍了如何选择接入点
今天我们来看看如何创建接入点吧

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

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

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测试通过
  评论这张
 
阅读(299)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018