×
Namespaces

Variants
Actions

WLAN access point configuration using CommsDat API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Tested on: Nokia N78,
Nokia N96, Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition, FP2
S60 5th Edition
S60 5th Edition
S60 3rd Edition (initial release)
Article
Keywords: CMDBSession, CMDBGenericRecord, CMDBField
Created: User:Kbwiki (23 Dec 2009)
Last edited: lpvalente (05 Feb 2013)

Description

One of the possible ways of configuring a WLAN access point is by using APIs from the CommsDat namespace. CommsDat is a replacement for the CommDB API from S60 3rd Edition, Feature Pack 2 onwards. This article demonstrates how Internet Access Point (IAP) settings can be configured for a specific WLAN IAP using CommsDat APIs.

Solution

  TUint32 SetAccessPointDataL()
{
if ( !iDBSession )
{
iDBSession = CMDBSession::NewL( CMDBSession::LatestVersion() );
iDBSession->SetAttributeMask( ECDHidden );
}
 
CreateWLANServiceRecordL( 8 ); // Costructs iWLANRecord (of type CMDBGenericRecord)
// 8 is the IAP ID of the WLAN AP
 
// Write WLAN Data
CMDBField<TDesC>* textField;
 
textField = ( CMDBField<TDesC>* )iWLANRecord->GetFieldByIdL( KCDTIdRecordName );
textField->SetMaxLengthL( KMaxMedTextLength );
textField->SetL( _L( "CommsDat IAP" ) );
 
*( ( CMDBField<TUint32>* )iWLANRecord->GetFieldByIdL( KCDTIdWlanConnMode ) ) = Infrastructure;
 
textField = ( CMDBField<TDesC>* )iWLANRecord->GetFieldByIdL( KCDTIdWlanSSID );
textField->SetMaxLengthL( KMaxSSIDLen );
textField->SetL( _L( "WLAN IAP" ) );
 
*( ( CMDBField<TUint32>* )iWLANRecord->GetFieldByIdL( KCDTIdWlanAuthMode ) ) = EWepAuthModeShared;
*( ( CMDBField<TUint32>* )iWLANRecord->GetFieldByIdL( KCDTIdWlanSecMode ) ) = AllowUnsecure;
 
iWLANRecord->ModifyL( *iDBSession );
 
return iWLANRecord->RecordId(); // return the ID of the new record
}
 
 
void CreateWLANServiceRecordL( TUint32 aId )
{
if ( iWLANRecord )
{
delete iWLANRecord; // Object of type CMDBGenericRecord
iWLANRecord = NULL;
}
 
// Load the IAP record and get the service ID that points to the WLAN service table
CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) );
 
CleanupStack::PushL( iapRecord );
iapRecord->SetRecordId( aId );
iapRecord->LoadL( *iDBSession );
 
if ( TPtrC( iapRecord->iServiceType ) != TPtrC( KCDTypeNameLANService )
|| TPtrC( iapRecord->iBearerType ) != TPtrC( KCDTypeNameLANBearer ) )
{
User::Leave( KErrNotFound );
}
 
aId = iapRecord->iService;
CleanupStack::PopAndDestroy( iapRecord );
 
CMDBGenericRecord* const genRec =
static_cast<CMDBGenericRecord*>( CCDRecordBase::RecordFactoryL( 0 ) );
CleanupStack::PushL( genRec );
 
_LIT( KGenericTable, "WLANServiceTable" );
genRec->InitializeL( KGenericTable(), NULL );
genRec->LoadL( *iDBSession );
 
CMDBField<TUint32>* sidField =
static_cast<CMDBField<TUint32>*>( genRec->GetFieldByIdL( KCDTIdWlanServiceId ) );
 
*sidField = aId;
 
if ( !genRec->FindL( *iDBSession ) )
{
User::Leave( KErrNotFound );
}
 
CleanupStack::Pop(); // genRec
iWLANRecord = genRec;
}

This page was last modified on 5 February 2013, at 21:02.
38 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×