You Are Here:

Community: Wiki

This page was last modified on 31 March 2009, at 06:46.

How to retrive SSID used in WLAN IAP and IAP used by VPN IAP programmatically

From Forum Nokia Wiki


We can retrieve IAP used by VPN IAP by retrieving VPN_SERVICE_IAP value in VPN_SERVICE table.

We can use the following two approaches to retrieve SSID-

1.First one is to use CApDataHandler and CApAccessPointItem -ReadTextL with EApWlanNetworkName as parameter to get SSID.

2.Second approach is to read WLAN_SSID from WLAN_SERVICE Table.

The following code snippet is tested in E61i.

Example Code

Headers required:

#include <apdatahandler.h>
#include <apaccesspointitem.h>
#include <apselect.h>
#include <COMMDB.H>
#include <aputils.h>

Libraries needed:

LIBRARY  Commdb.lib 
LIBRARY apengine.lib

Source:

//Code to retrieve IAP used by VPN IAP
CCommsDbTableView* view = commsdb->OpenTableLC(TPtrC(VPN_SERVICE));//VPN_SERVICE
TInt retval = view->GotoFirstRecord();
CApUtils *aputil = CApUtils::NewLC(*commsdb);
 
TUint32 vpnId,cmId,nwId;
TBuf<50> vpnIdB,cmIdB,nwIdB,name;
 
while (retval == KErrNone)
{
//Read IAP used by VPN IAP
view->ReadUintL(TPtrC(VPN_SERVICE_IAP),vpnId);
view->ReadTextL(TPtrC(COMMDB_NAME),commName);
vpnIdB.AppendNum(vpnId);
CEikonEnv::InfoWinL(_L("COMMDB_NAME"),commName);
CEikonEnv::InfoWinL(_L("VpnIapID"),vpnIdB);
//Gives the name of a given access point from IAP ID
aputil->NameL(vpnId,name);
CEikonEnv::InfoWinL(_L("AP in VAP"),name);
name.Zero();
commName.Zero();
vpnIdB.Zero();
retval = view->GotoNextRecord();
}
 
//First approach to retrieve SSID used in WLAN IAP
 
 
TUint32 APuid;
TBuf<50> ssidBuf,name;
TInt count = 0;
CCommsDatabase *commsdb= CCommsDatabase::NewL();
 
//Filter only WLAN APS with bearer type EApBearerTypeWLAN
CApSelect * select=CApSelect::NewLC (*commsdb,KEApIspTypeAll,EApBearerTypeWLAN,KEApSortUidAscending);
CApDataHandler* datHand = CApDataHandler::NewLC(*commsdb);
CApAccessPointItem* ap = CApAccessPointItem::NewLC();
 
TBool move = select->MoveToFirst();
 
while(count<select->Count())
{
if(move==TRUE)
name =select->Name();
 
//Get AP Id
APuid =select->Uid();
name.AppendNum(APuid);
 
CEikonEnv::InfoWinL(_L("AP Name & ID"),name);//Displays AccessPoint Name and its ID
datHand->AccessPointDataL(APuid, *ap); // Pass APuid as param
 
//Read SSID
ap->ReadTextL(EApWlanNetworkName, ssidBuf);
CEikonEnv::InfoWinL(_L("SSID"),ssidBuf);
ssidBuf.Zero();
name.Zero();
TBool move = select->MoveNext();
count=count+1;
}
CleanupStack::PopAndDestroy(3);
 
//Second approach to retrieve SSID
 
TBuf<100> ssid;
 
// Open WLAN SERVICE table
CCommsDbTableView* view = commsdb->OpenTableLC(TPtrC(WLAN_SERVICE));
TInt retval = view->GotoFirstRecord();
 
while (retval == KErrNone)
{
//Read SSID value
view->ReadTextL(TPtrC(WLAN_SSID),ssid);
CEikonEnv::InfoWinL(_L("SSID"),ssid);
ssid.Zero();
retval = view->GotoNextRecord();
}
CleanupStack::PopAndDestroy(view);

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia