Symbian 网络接入点常用编程方法总结
2010-03-18 21:02:00 来源:WEB开发网User::LeaveIfError(iConnection.Start(connectPref));
...
}
完全可以把上面的代码分成两个部分来实现选择接入点和建立连接的分离。即建立连接的代码如下:
// IAP Selected,根据选择的接入点进行连接
// Open socket server and start the connection
User::LeaveIfError(iSocketServ.Connect());
User::LeaveIfError(iConnection.Open(iSocketServ));
// Now we have the iap Id. Use it to connect for the connection
TCommDbConnPref connectPref;
// Setup preferences
connectPref.SetDialogPreference(ECommDbDialogPrefPrompt);
// Sets the CommDb ID of the IAP to use for this connection
connectPref.SetIapId(iSelectedIap);
// Start connection
User::LeaveIfError(iConnection.Start(connectPref));
MTM方式下屏蔽系统接入点的做法
TImIAPChoice apChoice;
apChoice.iIAP = 0; // //store IAP id
apChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;//prompt dialog
CImIAPPreferences* apPref = CImIAPPreferences::NewLC();
apPref->AddIAPL(apChoice);
mailAccount->SavePopIapSettingsL(popAccount,*apPref);
CleanupStack::PopAndDestroy(apPref);
void GetCMWAPID()
{
iCmwapId = 0;
CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(commDb);
commDb->BeginTransaction();
CCommsDbTableView* commView = commDb->OpenTableLC( TPtrC( OUTGOING_GPRS ) );
TInt ret = commView->GotoFirstRecord();
TBool find = EFalse;
while( ret == KErrNone )
{
TBuf8<50> name;
commView->ReadTextL( TPtrC(GPRS_APN), name );
TRAPD(leaveCode,commView->ReadUintL( TPtrC( COMMDB_ID), iCmwapId ) );
if( name.CompareF(_L8("CMWAP") ) == 0 )
{
更多精彩
赞助商链接