×
Namespaces

Variants
Actions

Easiest way to query Access Point (IAP)

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: rathodavinash (29 Jun 2007)
Last edited: hamishwillee (23 Jul 2012)

Lots of applications need user input for the Access point to use. The easiest way to query for an IAP is as follows:

Header required:

#include <commdb.h>
#include <ApSettingsHandlerUI.h>


Link against:

LIBRARY apsettingshandlerui.lib
LIBRARY commdb.lib

Source file:

void CMyAppView::AccessPointGetterL()
{
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 file:

TBool iConnOK;		//< Is connection set?
TUint32 iIap; //< Current IAP
This page was last modified on 23 July 2012, at 10:53.
55 page views in the last 30 days.
×