Select Access Point

来源:互联网 发布:重庆精财软件 编辑:程序博客网 时间:2024/05/08 21:57

 // ====>> [Ver 3.01] by Figo.Yang ==========2007/11/14 19:31 ===>>>
 TUint32 cmnetIapId;
 _LIT(APN_CMNET, "cmnet");
 CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
 CleanupStack::PushL(commsDb);
 CCommsDbTableView *tableView = commsDb->OpenTableLC(TPtrC(OUTGOING_GPRS));
 TInt err = tableView->GotoFirstRecord();
 while (err == KErrNone)
 {
  TBuf<KCommsDbSvrMaxColumnNameLength> apn;
  tableView->ReadTextL(TPtrC(GPRS_APN), apn);
  apn.LowerCase();
  if (apn.Compare(APN_CMNET) == 0)
  {
   tableView->ReadUintL(TPtrC(COMMDB_ID), cmnetIapId);
   break;
  }
  err = tableView->GotoNextRecord();
 }
 CleanupStack::PopAndDestroy(2, commsDb); // tableView, commsDb

 //////////////////////////////////////////////////////////////////////////
 // some time the iap id is not right. we need to convert it again.
 CCommsDatabase* commDb2 = CCommsDatabase::NewL(EDatabaseTypeIAP);
 CleanupStack::PushL(commDb2);
 CCommsDbTableView* pIAPView = commDb2->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(IAP_SERVICE), cmnetIapId);
 TInt nErr = pIAPView->GotoFirstRecord();
 if(nErr == KErrNone) {
  TRAPD(err, pIAPView->ReadUintL(TPtrC(COMMDB_ID), cmnetIapId));
  if(err != KErrNone)
   cmnetIapId = 0;
 }
 else
  cmnetIapId = 0;
 CleanupStack::PopAndDestroy(2);
// ====<< [Ver 3.01] by Figo.Yang ==========2007/11/14 19:31 ===<<<

// ====>> [Ver 3.01] by Figo.Yang ==========2007/11/14 20:07 ===>>>
 if( !iConnection.SubSessionHandle() )
  {
  User::LeaveIfError( iConnection.Open( iSocketServ ) );
  }
 
 TCommDbConnPref prefs;
 prefs.SetDialogPreference (ECommDbDialogPrefDoNotPrompt);
 prefs.SetDirection (ECommDbConnectionDirectionOutgoing);
 prefs.SetIapId (cmnetIapId);

 // Start an Outgoing Connection with overrides
 iConnection.Start(prefs);
// ====<< [Ver 3.01] by Figo.Yang ==========2007/11/14 20:07 ===<<< 

原创粉丝点击