Thursday, September 27, 2007

Easiest way to query Access Point (IAP)

void CAppView::AccessPointL()
{
iConnOK=EFalse;

CApSettingsHandler* settingsHandler = CApSettingsHandler::NewLC(
ETrue,
EApSettingsSelListIsPopUp ,
EApSettingsSelMenuSelectNormal,
KEApIspTypeAll,
EApBearerTypeAll,
KEApSortNameAscending);

TUint32 originallyFocused(0);
// 0 is not valid IAP id. Failed if 0 after RunSettingsL().
TUint32 selectedIap(0);

// Show the dialog
settingsHandler->RunSettingsL(originallyFocused, selectedIap);

// The CApUtils API is deprecated/removed, the following code can be
used
// to convert the WapAP Id to IAP Id
if (selectedIap)
{
CCommsDatabase* db = CCommsDatabase::NewL();
CleanupStack::PushL(db);

CCommsDbTableView* wapTable;
wapTable = db->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
TPtrC(COMMDB_ID), selectedIap );
User::LeaveIfError( wapTable->GotoFirstRecord() );

TBuf<100> wapBearer;
wapTable->ReadTextL(TPtrC(WAP_CURRENT_BEARER), wapBearer);

if ( wapBearer == TPtrC(WAP_IP_BEARER) )
{
CCommsDbTableView* bearerTable;
bearerTable = db->OpenViewMatchingUintLC( TPtrC(wapBearer),
TPtrC(WAP_ACCESS_POINT_ID),
selectedIap );
User::LeaveIfError( bearerTable->GotoFirstRecord() );
bearerTable->ReadUintL(TPtrC(WAP_IAP), iIap );
CleanupStack::PopAndDestroy( bearerTable ); // bearerTable
}
else
{
User::Leave( KErrInvalidBearerType );
}
CleanupStack::PopAndDestroy(2); // db, wapTable,
}
else
{
iIap = 0;
}

CleanupStack::PopAndDestroy(settingsHandler);

if(!iIap)
{
iConnOK=EFalse;
}
else
{
iConnOK=ETrue;
}
}


Header Files : ApSettingsHandlerUI.h
Link against : apsettingshandlerui.lib

2 comments:

Unknown said...

ciao
i tryed the code, but i don't know where i put in? the appview.cpp, it seems missing some car declaration, no?

Sunil kumar said...

What is the Error you got ?

stats counter