void SetDefaultIap(TInt aIapType, TUint32 &aIapId) { TInt ret = KErrNone; TBuf<KCommsDbSvrMaxColumnNameLength> apnName; TBuf<10> defApn; TUint32 fakeIapId; aIapId = 0; if (aIapType == 0) defApn = _L("cmnet"); else if (aIapType == 1) defApn = _L("cmwap"); else if (aIapType == 2) //模拟器 defApn = _L("Winsock"); CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP); CleanupStack::PushL(commDb); CCommsDbTableView* commView = commDb->OpenTableLC(TPtrC(OUTGOING_WCDMA)); if (commView->GotoFirstRecord() == KErrNone) { do { commView->ReadTextL((TPtrC) GPRS_APN, apnName); commView->ReadUintL(TPtrC(COMMDB_ID), fakeIapId); if (apnName.Find(defApn) >= 0) //不区分大小写 { CCommsDbTableView* pIAPView = commDb->OpenViewMatchingUintLC( TPtrC(IAP), TPtrC(IAP_SERVICE), fakeIapId); TInt nErr = pIAPView->GotoFirstRecord(); if (nErr == KErrNone) { pIAPView->ReadUintL(TPtrC(COMMDB_ID), fakeIapId); aIapId = fakeIapId; CleanupStack::PopAndDestroy(); //pIAPView break; } CleanupStack::PopAndDestroy(); //pIAPView } } while (commView->GotoNextRecord() == KErrNone); } CleanupStack::PopAndDestroy(2); } Symbian的接入点参数真多,真复杂~~记录之,以防忘记~ |