コード例 #1
0
void CSymTorrentIAPSelectView::GetGPRSIAPsFromIAPTableL()
{ 
	TBuf<52> iapfromtable;
	TBuf<53> listItem;
	TInt err = KErrNone;
	
	CCommsDatabase* commsDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(commsDB);

	// Open IAP table using the GPRS as the bearer.
	CCommsDbTableView* gprsTable = commsDB->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerGPRS,
		ECommDbConnectionDirectionOutgoing);
	// Point to the first entry
	User::LeaveIfError(gprsTable->GotoFirstRecord());
	gprsTable->ReadTextL(TPtrC(COMMDB_NAME), iapfromtable);
	listItem.SetLength(0);
	listItem.Append(_L("\t"));
	listItem.Append(iapfromtable);
	iContainer->AppendItemL(listItem);	
	
	TUint32 id;
	gprsTable->ReadUintL(TPtrC(COMMDB_ID), id);
	User::LeaveIfError(iIAPIDs.Append(id));

	while (err = gprsTable->GotoNextRecord(), err == KErrNone)
	{
		gprsTable->ReadTextL(TPtrC(COMMDB_NAME), iapfromtable);
		listItem.SetLength(0);
		listItem.Append(_L("\t"));
		listItem.Append(iapfromtable);
		iContainer->AppendItemL(listItem);
			
		TUint32 id;
		gprsTable->ReadUintL(TPtrC(COMMDB_ID), id);
		User::LeaveIfError(iIAPIDs.Append(id));
	}

	CleanupStack::PopAndDestroy(); // gprsTable
	CleanupStack::PopAndDestroy(); // commsDB
}
コード例 #2
0
// -----------------------------------------------------------------------------
// COMASuplSettings::ConvertIAPNameToIdL
// 
// -----------------------------------------------------------------------------
TBool COMASuplSettings::ConvertIAPNameToIdL(const TDesC& aIAPName, TUint32& aIAPId)
	{
		TBool result = EFalse;
	
		CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
		CleanupStack::PushL(commDb);
		CCommsDbTableView* tableView = commDb->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerCSD|ECommDbBearerGPRS,
											ECommDbConnectionDirectionOutgoing);
	   	TInt retval = tableView->GotoFirstRecord();
	   	while ((retval == KErrNone) && (!result))
	   	{
	      HBufC * iap_name = tableView->ReadLongTextLC( TPtrC( COMMDB_NAME) );

	      if (iap_name && (iap_name->Compare(aIAPName) == 0))
	        {
	           	tableView->ReadUintL(TPtrC(COMMDB_ID), aIAPId);
	            result = ETrue;
	       	}
	       CleanupStack::PopAndDestroy(); // iap_name
	       retval = tableView->GotoNextRecord();
	   	}
		CleanupStack::PopAndDestroy(2);//delete tableView and commDb
		return result;
	}