Symbian 网络接入点常用编程方法
2010-03-15 15:48:00 来源:WEB开发网 闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧綊鏌熼梻瀵割槮缁惧墽鎳撻—鍐偓锝庝簻椤掋垺銇勯幇顖毿撻柟渚垮妼椤粓宕卞Δ鈧獮濠勭磽閸屾艾鈧懓顫濋妸鈺佺疅缂佸顑欓崥瀣煕椤愵偅绶氱紓鍐╂礋濮婂宕掑▎鎴М濠电姭鍋撻梺顒€绉甸幆鐐哄箹濞n剙濡肩紒鎰殜閺屸€愁吋鎼粹€茬敖婵炴垶鎸哥粔鐢稿Φ閸曨垰鍐€妞ゆ劦婢€濞岊亪姊虹紒妯诲蔼闁稿海鏁诲濠氭晲婢跺﹤宓嗛梺缁樺姈缁佹挳宕戦幘璇叉嵍妞ゆ挻绋戞禍鐐叏濡厧浜鹃悗姘炬嫹

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 )
{
更多精彩
赞助商链接