cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlan.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *        Implementation of WLAN Plugin interface implementation
       
    16 *        for WLAN Bearer
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include <ecom/ecom.h>      // For REComSession
       
    22 #include <wlancontainer.h>
       
    23 #include <wlanmgmtcommon.h>
       
    24 #include <cmpluginwlandef.h>
       
    25 #include <cmcommonconstants.h>
       
    26 #include <featmgr.h>
       
    27 #include <EapGeneralSettings.h>
       
    28 
       
    29 #include "datamobilitycommsdattypes.h"
       
    30 #include "cmpluginwlan.h"
       
    31 #include "cmwlancoveragecheck.h"
       
    32 #include "cmmanagerdef.h"
       
    33 
       
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "cmpluginwlanTraces.h"
       
    37 #endif
       
    38 
       
    39 using namespace CMManager;
       
    40 
       
    41 enum TWlanWepKeyFormat
       
    42     {
       
    43     EWlanWepKeyFormatAscii = 0,
       
    44     EWlanWepKeyFormatHex
       
    45     };
       
    46 
       
    47 // default values for fields...
       
    48 // CONSTANTS
       
    49 _LIT( KEmpty, "");
       
    50 
       
    51 const TBool KDefIpAddrFromServer = ETrue;
       
    52 const TBool KDefIpDnsAddrFromServer = ETrue;
       
    53 const TBool KDefIp6DnsAddrFromServer = ETrue;
       
    54 
       
    55 const TInt KWlanServiceRecordIndex = 0;
       
    56 
       
    57 const TInt KWlanLastSocketActivityTimeout = -1;
       
    58 const TInt KWlanLastSessionClosedTimeout = 1;
       
    59 const TInt KWlanLastSocketClosedTimeout = -1;
       
    60 
       
    61 /// Modem bearer names for WLAN connection methods.
       
    62 _LIT( KModemBearerWLAN, "WLANBearer" );
       
    63 
       
    64 _LIT( KWlanBearerName, "WLANBearer" );
       
    65 _LIT( KWlanBearerAgent, "wlanagt.agt" );
       
    66 _LIT( KWlanBearerNif, "wlannif" );
       
    67 
       
    68 _LIT( KWlanLDDName, "not used" );
       
    69 _LIT( KWlanPDDName, "not used" );
       
    70 
       
    71 
       
    72 // --------------------------------------------------------------------------
       
    73 // CCmPluginWlan::NewL
       
    74 // --------------------------------------------------------------------------
       
    75 //
       
    76 CCmPluginWlan* CCmPluginWlan::NewL( TCmPluginInitParam* aInitParam )
       
    77     {
       
    78     OstTraceFunctionEntry0( CCMPLUGINWLAN_NEWL_ENTRY );
       
    79 
       
    80     CCmPluginWlan* self = new( ELeave ) CCmPluginWlan( aInitParam );
       
    81     CleanupStack::PushL( self );
       
    82     self->ConstructL();
       
    83     CleanupStack::Pop( self );
       
    84 
       
    85     OstTraceFunctionExit0( CCMPLUGINWLAN_NEWL_EXIT );
       
    86     return self;
       
    87     }
       
    88 
       
    89 // --------------------------------------------------------------------------
       
    90 // CCmPluginWlan::~CCmPluginWlan
       
    91 // --------------------------------------------------------------------------
       
    92 //
       
    93 CCmPluginWlan::~CCmPluginWlan()
       
    94     {
       
    95     OstTraceFunctionEntry0( CCMPLUGINWLAN_CCMPLUGINWLAN_ENTRY );
       
    96 
       
    97     ResetBearerRecords();
       
    98 
       
    99     OstTraceFunctionExit0( CCMPLUGINWLAN_CCMPLUGINWLAN_EXIT );
       
   100     }
       
   101 
       
   102 // --------------------------------------------------------------------------
       
   103 // CCmPluginWlan::CreateInstanceL
       
   104 // --------------------------------------------------------------------------
       
   105 //
       
   106 CCmPluginBaseEng* CCmPluginWlan::CreateInstanceL( TCmPluginInitParam& aInitParam ) const
       
   107     {
       
   108     OstTraceFunctionEntry0( CCMPLUGINWLAN_CREATEINSTANCEL_ENTRY );
       
   109 
       
   110     CCmPluginWlan* self = new( ELeave ) CCmPluginWlan( &aInitParam );
       
   111     CleanupStack::PushL( self );
       
   112     self->ConstructL();
       
   113     CleanupStack::Pop( self );
       
   114 
       
   115     OstTraceFunctionExit0( CCMPLUGINWLAN_CREATEINSTANCEL_EXIT );
       
   116     return self;
       
   117     }
       
   118 
       
   119 // --------------------------------------------------------------------------
       
   120 // CCmPluginWlan::CCmPluginWlan
       
   121 // --------------------------------------------------------------------------
       
   122 //
       
   123 CCmPluginWlan::CCmPluginWlan( TCmPluginInitParam* aInitParam )
       
   124         :
       
   125         CCmPluginBaseEng( aInitParam )
       
   126     {
       
   127     OstTraceFunctionEntry0( DUP1_CCMPLUGINWLAN_CCMPLUGINWLAN_ENTRY );
       
   128 
       
   129     iBearerType = KUidWlanBearerType;
       
   130     iWlanServiceRecord = NULL;
       
   131     iWlanTableId = 0;
       
   132     iWAPISupported = EFalse;
       
   133     iBearerPriorityTableId = 0;
       
   134 
       
   135     OstTraceFunctionExit0( DUP1_CCMPLUGINWLAN_CCMPLUGINWLAN_EXIT );
       
   136     }
       
   137 
       
   138 // --------------------------------------------------------------------------
       
   139 // CCmPluginWlan::ConstructL
       
   140 // --------------------------------------------------------------------------
       
   141 //
       
   142 void CCmPluginWlan::ConstructL()
       
   143     {
       
   144     OstTraceFunctionEntry0( CCMPLUGINWLAN_CONSTRUCTL_ENTRY );
       
   145 
       
   146     // Feature Manager is initialized by the CmmServer, so no need to do it here.
       
   147 
       
   148     if ( ! FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) )
       
   149         {
       
   150         User::Leave( KErrNotSupported );
       
   151         }
       
   152 
       
   153     CCmPluginBaseEng::ConstructL();
       
   154 
       
   155     // Get bearer priority table ID.
       
   156     TRAP_IGNORE( iBearerPriorityTableId =
       
   157             CCDGlobalBearerTypePriorizationRecord::TableIdL( iSession ) );
       
   158 
       
   159     if ( !iBearerPriorityTableId )
       
   160         {
       
   161         iBearerPriorityTableId =
       
   162                 CCDGlobalBearerTypePriorizationRecord::CreateTableL( iSession );
       
   163         }
       
   164 
       
   165     TMDBElementId tableId( 0 );
       
   166 
       
   167     TRAP_IGNORE( tableId = CCDWlanDeviceSettingsRecord::TableIdL( iSession ) );
       
   168     if ( !tableId )
       
   169         {
       
   170         CCDWlanDeviceSettingsRecord::CreateTableL( iSession );
       
   171         }
       
   172 
       
   173     // Get WLAN table ID.
       
   174     TRAP_IGNORE( iWlanTableId = CCDWlanServiceRecord::TableIdL( iSession ) );
       
   175     if ( !iWlanTableId )
       
   176         {
       
   177         iWlanTableId = CCDWlanServiceRecord::CreateTableL( iSession );
       
   178         }
       
   179 
       
   180     TRAP_IGNORE( tableId = CCDWLANSecSSIDTable::TableIdL( iSession ) );
       
   181     if ( !tableId )
       
   182         {
       
   183         CCDWLANSecSSIDTable::CreateTableL( iSession );
       
   184         }
       
   185 
       
   186     TRAP_IGNORE( tableId = CCDDestNWTable::TableIdL( iSession ) );
       
   187     if ( !tableId )
       
   188         {
       
   189         CCDDestNWTable::CreateTableL( iSession );
       
   190         }
       
   191 
       
   192     iWAPISupported = FeatureManager::FeatureSupported( KFeatureIdFfWlanWapi );
       
   193 
       
   194     OstTraceFunctionExit0( CCMPLUGINWLAN_CONSTRUCTL_EXIT );
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CCmPluginWlan::ServiceRecord()
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 CCDLANServiceRecord& CCmPluginWlan::ServiceRecord() const
       
   202     {
       
   203     return *static_cast<CCDLANServiceRecord*>( iServiceRecord );
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // CCmPluginWlan::ServiceRecordId
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 TUint32 CCmPluginWlan::ServiceRecordId() const
       
   211     {
       
   212     OstTraceFunctionEntry0( CCMPLUGINWLAN_SERVICERECORDID_ENTRY );
       
   213 
       
   214     return ServiceRecord().RecordId();
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // CCmPluginWlan::ServiceRecordIdLC
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 void CCmPluginWlan::ServiceRecordNameLC( HBufC* &aName )
       
   222     {
       
   223     OstTraceFunctionEntry0( CCMPLUGINWLAN_SERVICERECORDNAMELC_ENTRY );
       
   224 
       
   225     aName = TPtrC( KCDTypeNameLANService ).AllocLC();
       
   226 
       
   227     OstTraceFunctionExit0( CCMPLUGINWLAN_SERVICERECORDNAMELC_EXIT );
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // CCmPluginWlan::BearerRecordIdL()
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 void CCmPluginWlan::BearerRecordIdL( TUint32& aRecordId )
       
   235     {
       
   236     OstTraceFunctionEntry0( CCMPLUGINWLAN_BEARERRECORDIDL_ENTRY );
       
   237 
       
   238     CCDLANBearerRecord* lanBearerRecord = static_cast<CCDLANBearerRecord*>
       
   239                         (CCDRecordBase::RecordFactoryL( KCDTIdLANBearerRecord ));
       
   240     CleanupStack::PushL( lanBearerRecord );
       
   241 
       
   242     lanBearerRecord->iRecordName.SetL( TPtrC( KModemBearerWLAN ) );
       
   243     if ( !lanBearerRecord->FindL( iSession ) )
       
   244         { // bearer not found -> create dummy values
       
   245         lanBearerRecord->SetRecordId( KCDNewRecordRequest );
       
   246         lanBearerRecord->iBearerAgent = KWlanBearerAgent;
       
   247         lanBearerRecord->iRecordName = KWlanBearerName;
       
   248         lanBearerRecord->iLanBearerNifName = KWlanBearerNif;
       
   249         lanBearerRecord->iLanBearerLddName = KWlanLDDName;
       
   250         lanBearerRecord->iLanBearerPddName = KWlanPDDName;
       
   251         lanBearerRecord->iLastSocketActivityTimeout =
       
   252                                         (TUint32)KWlanLastSocketActivityTimeout;
       
   253         lanBearerRecord->iLastSessionClosedTimeout =
       
   254                                         (TUint32)KWlanLastSessionClosedTimeout;
       
   255         lanBearerRecord->iLastSocketClosedTimeout =
       
   256                                         (TUint32)KWlanLastSocketClosedTimeout;
       
   257 
       
   258         lanBearerRecord->StoreL( iSession );
       
   259         }
       
   260 
       
   261     aRecordId = lanBearerRecord->RecordId();
       
   262 
       
   263     CleanupStack::PopAndDestroy( lanBearerRecord );
       
   264 
       
   265     OstTraceFunctionExit0( CCMPLUGINWLAN_BEARERRECORDIDL_EXIT );
       
   266     }
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // CCmPluginWlan::BearerRecordNameLC()
       
   270 // ---------------------------------------------------------------------------
       
   271 //
       
   272 void CCmPluginWlan::BearerRecordNameLC( HBufC* &aBearerName )
       
   273     {
       
   274     OstTraceFunctionEntry0( CCMPLUGINWLAN_BEARERRECORDNAMELC_ENTRY );
       
   275 
       
   276     aBearerName = TPtrC( KCDTypeNameLANBearer ).AllocLC();
       
   277 
       
   278     OstTraceFunctionExit0( CCMPLUGINWLAN_BEARERRECORDNAMELC_EXIT );
       
   279     }
       
   280 
       
   281 // --------------------------------------------------------------------------
       
   282 // CCmPluginWlan::GetBearerIntAttributeL
       
   283 // --------------------------------------------------------------------------
       
   284 //
       
   285 TUint32 CCmPluginWlan::GetBearerIntAttributeL(
       
   286         TUint32 aAttribute,
       
   287         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
   288         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
   289     {
       
   290     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERINTATTRIBUTEL_ENTRY );
       
   291 
       
   292     TUint32 retVal( 0 );
       
   293 
       
   294     CCDLANServiceRecord* serviceRecord =
       
   295             static_cast<CCDLANServiceRecord*>(
       
   296                     aGenRecordArray[KServiceRecordIndex] );
       
   297 
       
   298     CCDWlanServiceRecord* wlanServiceRecord =
       
   299             static_cast<CCDWlanServiceRecord*>(
       
   300                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
   301 
       
   302     switch ( aAttribute )
       
   303         {
       
   304         case ECmInvalidAttribute:
       
   305             {
       
   306             // This attribute has been deprecated since Symbian^4.
       
   307             User::Leave( KErrNotSupported );
       
   308             }
       
   309             break;
       
   310         case ECmExtensionLevel:
       
   311             {
       
   312             // This is extension from LAN plugin
       
   313             retVal = KExtensionBaseLevel + 1;
       
   314             }
       
   315             break;
       
   316         case ECmCommsDBBearerType:
       
   317             {
       
   318             retVal = KCommDbBearerWLAN;
       
   319             }
       
   320             break;
       
   321         case ECmDefaultUiPriority:
       
   322             {
       
   323             retVal = GetDefPriorityL( aAttribute );
       
   324             }
       
   325             break;
       
   326         case ECmDefaultPriority:
       
   327             {
       
   328             retVal = GetDefPriorityL( aAttribute );
       
   329             }
       
   330             break;
       
   331         case EWlanServiceId:
       
   332             {
       
   333             retVal = wlanServiceRecord->iWlanServiceId;
       
   334             }
       
   335             break;
       
   336         case EWlanConnectionMode:
       
   337             {
       
   338             retVal = wlanServiceRecord->iWlanConnMode;
       
   339             }
       
   340             break;
       
   341         case EWlanSecurityMode:
       
   342             {
       
   343             retVal = wlanServiceRecord->iWlanSecMode;
       
   344             }
       
   345             break;
       
   346         case EWlanAuthenticationMode:
       
   347             {
       
   348             retVal = wlanServiceRecord->iWlanAuthMode;
       
   349             }
       
   350             break;
       
   351         case EWlanChannelID:
       
   352             {
       
   353             retVal = wlanServiceRecord->iWlanChannelID;
       
   354             }
       
   355             break;
       
   356         case EWlanServiceExtensionTableRecordId:
       
   357             {
       
   358             retVal = serviceRecord->iServiceExtensionTableRecordId;
       
   359             }
       
   360             break;
       
   361         case EWlanWepKeyIndex:
       
   362             {
       
   363             retVal = wlanServiceRecord->iWlanWepIndex;
       
   364             }
       
   365             break;
       
   366         case EWlanWapiPskFormat:
       
   367             {
       
   368             retVal = wlanServiceRecord->iWlanFormatKey1;
       
   369             }
       
   370             break;
       
   371         default:
       
   372             {
       
   373             User::Leave( KErrNotSupported );
       
   374             }
       
   375             break;
       
   376         }
       
   377 
       
   378     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERINTATTRIBUTEL_EXIT );
       
   379     return retVal;
       
   380     }
       
   381 
       
   382 // --------------------------------------------------------------------------
       
   383 // CCmPluginWlan::GetBearerBoolAttributeL
       
   384 // --------------------------------------------------------------------------
       
   385 //
       
   386 TBool CCmPluginWlan::GetBearerBoolAttributeL(
       
   387         TUint32 aAttribute,
       
   388         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
   389         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
   390     {
       
   391     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERBOOLATTRIBUTEL_ENTRY );
       
   392 
       
   393     TBool retVal( EFalse );
       
   394 
       
   395     CCDWlanServiceRecord* wlanServiceRecord =
       
   396             static_cast<CCDWlanServiceRecord*>(
       
   397                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
   398 
       
   399     CCDLANServiceRecord* serviceRecord =
       
   400             static_cast<CCDLANServiceRecord*>(
       
   401                     aGenRecordArray[KServiceRecordIndex] );
       
   402 
       
   403     switch ( aAttribute )
       
   404         {
       
   405         case ECmCoverage:
       
   406             {
       
   407 #ifndef __WINS__
       
   408             retVal = CheckNetworkCoverageL();
       
   409 #else
       
   410             retVal = ETrue;
       
   411 #endif
       
   412             }
       
   413             break;
       
   414         case ECmDestination:
       
   415             {
       
   416             retVal = EFalse;
       
   417             }
       
   418             break;
       
   419         case ECmBearerHasUi:
       
   420             {
       
   421             retVal = ETrue;
       
   422             }
       
   423             break;
       
   424         case ECmIPv6Supported:
       
   425             {
       
   426             retVal = FeatureManager::FeatureSupported( KFeatureIdIPv6 );
       
   427             }
       
   428             break;
       
   429         case EWlanScanSSID:
       
   430             {
       
   431             retVal = wlanServiceRecord->iWlanScanSSID;
       
   432             }
       
   433             break;
       
   434         case EWlanAllowSSIDRoaming:
       
   435             {
       
   436             retVal = wlanServiceRecord->iWlanAllowSSIDRoaming;
       
   437             }
       
   438             break;
       
   439         case ECmIPAddFromServer:
       
   440         case EWlanIpAddrFromServer:
       
   441             {
       
   442             retVal = serviceRecord->iIpAddrFromServer;
       
   443             }
       
   444             break;
       
   445         case ECmIPDNSAddrFromServer:
       
   446         case EWlanIpDNSAddrFromServer:
       
   447             {
       
   448             retVal = serviceRecord->iIpDnsAddrFromServer;
       
   449             }
       
   450             break;
       
   451         case ECmIP6DNSAddrFromServer:
       
   452         case EWlanIp6DNSAddrFromServer:
       
   453             {
       
   454             retVal = serviceRecord->iIp6DnsAddrFromServer;
       
   455             }
       
   456             break;
       
   457         case EWlanEnableWpaPsk:
       
   458             {
       
   459             retVal = static_cast<TBool>( wlanServiceRecord->iWlanEnableWpaPsk );
       
   460             }
       
   461             break;
       
   462         case EWlan802_1xAllowUnencrypted:
       
   463             {
       
   464             retVal = static_cast<TBool>( wlanServiceRecord->iWlanWpaKeyLength );//TODO, change typecast to if-else structure?
       
   465             }
       
   466             break;
       
   467         default:
       
   468             {
       
   469             User::Leave( KErrNotSupported );
       
   470             break;
       
   471             }
       
   472         }
       
   473 
       
   474     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERBOOLATTRIBUTEL_EXIT );
       
   475     return retVal;
       
   476     }
       
   477 
       
   478 // --------------------------------------------------------------------------
       
   479 // CCmPluginWlan::GetBearerStringAttributeL
       
   480 // --------------------------------------------------------------------------
       
   481 //
       
   482 HBufC* CCmPluginWlan::GetBearerStringAttributeL(
       
   483         TUint32 aAttribute,
       
   484         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
   485         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
   486     {
       
   487     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERSTRINGATTRIBUTEL_ENTRY );
       
   488 
       
   489     HBufC* retVal = NULL;
       
   490 
       
   491     CCDWlanServiceRecord* wlanServiceRecord =
       
   492             static_cast<CCDWlanServiceRecord*>(
       
   493                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
   494 
       
   495     CCDLANServiceRecord* serviceRecord =
       
   496             static_cast<CCDLANServiceRecord*>(
       
   497                     aGenRecordArray[KServiceRecordIndex] );
       
   498 
       
   499     switch ( aAttribute )
       
   500         {
       
   501         case ECmIFNetworks:
       
   502         case EWlanIfNetworks:
       
   503             {
       
   504             if ( !serviceRecord->iIfNetworks.IsNull() )
       
   505                 {
       
   506                 retVal = ( serviceRecord->iIfNetworks.GetL() ).AllocL();
       
   507                 }
       
   508             }
       
   509             break;
       
   510         case ECmIPNetmask:
       
   511         case EWlanIpNetMask:
       
   512             {
       
   513             if ( !serviceRecord->iIpNetmask.IsNull() )
       
   514                 {
       
   515                 retVal = ( serviceRecord->iIpNetmask.GetL() ).AllocL();
       
   516                 }
       
   517             }
       
   518             break;
       
   519         case ECmIPGateway:
       
   520         case EWlanIpGateway:
       
   521             {
       
   522             if ( !serviceRecord->iIpGateway.IsNull() )
       
   523                 {
       
   524                 retVal = ( serviceRecord->iIpGateway.GetL() ).AllocL();
       
   525                 }
       
   526             }
       
   527             break;
       
   528         case ECmIPAddress:
       
   529         case EWlanIpAddr:
       
   530             {
       
   531             if ( !serviceRecord->iIpAddr.IsNull() )
       
   532                 {
       
   533                 retVal = ( serviceRecord->iIpAddr.GetL() ).AllocL();
       
   534                 }
       
   535             }
       
   536             break;
       
   537         case ECmIPNameServer1:
       
   538         case EWlanIpNameServer1:
       
   539             {
       
   540             if ( !serviceRecord->iIpNameServer1.IsNull() )
       
   541                 {
       
   542                 retVal = ( serviceRecord->iIpNameServer1.GetL() ).AllocL();
       
   543                 }
       
   544             }
       
   545             break;
       
   546         case ECmIPNameServer2:
       
   547         case EWlanIpNameServer2:
       
   548             {
       
   549             if ( !serviceRecord->iIpNameServer2.IsNull() )
       
   550                 {
       
   551                 retVal = ( serviceRecord->iIpNameServer2.GetL() ).AllocL();
       
   552                 }
       
   553             }
       
   554             break;
       
   555         case ECmIP6NameServer1:
       
   556         case EWlanIp6NameServer1:
       
   557             {
       
   558             if ( !serviceRecord->iIp6NameServer1.IsNull() )
       
   559                 {
       
   560                 retVal = ( serviceRecord->iIp6NameServer1.GetL() ).AllocL();
       
   561                 }
       
   562             }
       
   563             break;
       
   564         case ECmIP6NameServer2:
       
   565         case EWlanIp6NameServer2:
       
   566             {
       
   567             if ( !serviceRecord->iIp6NameServer2.IsNull() )
       
   568                 {
       
   569                 retVal = ( serviceRecord->iIp6NameServer2.GetL() ).AllocL();
       
   570                 }
       
   571             }
       
   572             break;
       
   573         case ECmIPAddrLeaseValidFrom:
       
   574         case EWlanIpAddrLeaseValidFrom:
       
   575             {
       
   576             if ( !serviceRecord->iIpAddrLeaseValidFrom.IsNull() )
       
   577                 {
       
   578                 retVal = ( serviceRecord->iIpAddrLeaseValidFrom.GetL() ).AllocL();
       
   579                 }
       
   580             }
       
   581             break;
       
   582         case ECmIPAddrLeaseValidTo:
       
   583         case EWlanIpAddrLeaseValidTo:
       
   584             {
       
   585             if ( !serviceRecord->iIpAddrLeaseValidTo.IsNull() )
       
   586                 {
       
   587                 retVal = ( serviceRecord->iIpAddrLeaseValidTo.GetL() ).AllocL();
       
   588                 }
       
   589             }
       
   590             break;
       
   591         case ECmConfigDaemonManagerName:
       
   592         case EWlanConfigDaemonManagerName:
       
   593             {
       
   594             if ( !serviceRecord->iConfigDaemonManagerName.IsNull() )
       
   595                 {
       
   596                 retVal = ( serviceRecord->iConfigDaemonManagerName.GetL() ).AllocL();
       
   597                 }
       
   598             }
       
   599             break;
       
   600         case ECmConfigDaemonName:
       
   601         case EWlanConfigDaemonName:
       
   602             {
       
   603             if ( !serviceRecord->iConfigDaemonName.IsNull() )
       
   604                 {
       
   605                 retVal = ( serviceRecord->iConfigDaemonName.GetL() ).AllocL();
       
   606                 }
       
   607             }
       
   608             break;
       
   609         case EWlanServiceExtensionTableName:
       
   610             {
       
   611             if ( !serviceRecord->iServiceExtensionTableName.IsNull() )
       
   612                 {
       
   613                 retVal = ( serviceRecord->iServiceExtensionTableName.GetL() ).AllocL();
       
   614                 }
       
   615             }
       
   616             break;
       
   617         case EWlanSSID:
       
   618             {
       
   619             if ( !wlanServiceRecord->iWLanSSID.IsNull() )
       
   620                 {
       
   621                 retVal = ( wlanServiceRecord->iWLanSSID.GetL() ).AllocL();
       
   622                 }
       
   623             }
       
   624             break;
       
   625         case EWlanUsedSSID:
       
   626             {
       
   627             if ( !wlanServiceRecord->iWLanUsedSSID.IsNull() )
       
   628                 {
       
   629                 retVal = ( wlanServiceRecord->iWLanUsedSSID.GetL() ).AllocL();
       
   630                 }
       
   631             }
       
   632             break;
       
   633         default:
       
   634             {
       
   635             User::Leave( KErrNotSupported );
       
   636             }
       
   637             break;
       
   638         }
       
   639 
       
   640     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERSTRINGATTRIBUTEL_EXIT );
       
   641     return retVal;
       
   642     }
       
   643 
       
   644 // --------------------------------------------------------------------------
       
   645 // CCmPluginWlan::GetBearerString8AttributeL
       
   646 // --------------------------------------------------------------------------
       
   647 //
       
   648 HBufC8* CCmPluginWlan::GetBearerString8AttributeL(
       
   649         TUint32 aAttribute,
       
   650         RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
       
   651         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
   652     {
       
   653     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERSTRING8ATTRIBUTEL_ENTRY );
       
   654 
       
   655     HBufC8* retVal( NULL );
       
   656 
       
   657     CCDWlanServiceRecord* wlanServiceRecord =
       
   658             static_cast<CCDWlanServiceRecord*>(
       
   659                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
   660 
       
   661     switch ( aAttribute )
       
   662         {
       
   663         case EWlanWpaPreSharedKey:
       
   664             {
       
   665             if ( !wlanServiceRecord->iWLanWpaPreSharedKey.IsNull() )
       
   666                 {
       
   667                 retVal = ( wlanServiceRecord->iWLanWpaPreSharedKey.GetL() ).AllocL();
       
   668                 }
       
   669             }
       
   670             break;
       
   671         case EWlanWepKey1InHex:
       
   672             {
       
   673             if ( !wlanServiceRecord->iWlanFormatKey1.IsNull() &&
       
   674                     !wlanServiceRecord->iWLanWepKey1.IsNull() )
       
   675                 {
       
   676                 if ( wlanServiceRecord->iWlanFormatKey1 == EWlanWepKeyFormatAscii )
       
   677                     {
       
   678                     // Format is ascii.
       
   679                     retVal = ConvertAsciiToHexL( wlanServiceRecord->iWLanWepKey1.GetL() );
       
   680                     }
       
   681                 else
       
   682                     {
       
   683                     // Format is hex.
       
   684                     retVal = ( wlanServiceRecord->iWLanWepKey1.GetL() ).AllocL();
       
   685                     }
       
   686                 }
       
   687             }
       
   688             break;
       
   689         case EWlanWepKey2InHex:
       
   690             {
       
   691             if ( !wlanServiceRecord->iWlanFormatKey2.IsNull() &&
       
   692                     !wlanServiceRecord->iWLanWepKey2.IsNull() )
       
   693                 {
       
   694                 if ( wlanServiceRecord->iWlanFormatKey2 == EWlanWepKeyFormatAscii )
       
   695                     {
       
   696                     // Format is ascii.
       
   697                     retVal = ConvertAsciiToHexL( wlanServiceRecord->iWLanWepKey2.GetL() );
       
   698                     }
       
   699                 else
       
   700                     {
       
   701                     // Format is hex.
       
   702                     retVal = ( wlanServiceRecord->iWLanWepKey2.GetL() ).AllocL();
       
   703                     }
       
   704                 }
       
   705             }
       
   706             break;
       
   707         case EWlanWepKey3InHex:
       
   708             {
       
   709             if ( !wlanServiceRecord->iWlanFormatKey3.IsNull() &&
       
   710                     !wlanServiceRecord->iWLanWepKey3.IsNull() )
       
   711                 {
       
   712                 if ( wlanServiceRecord->iWlanFormatKey3 == EWlanWepKeyFormatAscii )
       
   713                     {
       
   714                     // Format is ascii.
       
   715                     retVal = ConvertAsciiToHexL( wlanServiceRecord->iWLanWepKey3.GetL() );
       
   716                     }
       
   717                 else
       
   718                     {
       
   719                     // Format is hex.
       
   720                     retVal = ( wlanServiceRecord->iWLanWepKey3.GetL() ).AllocL();
       
   721                     }
       
   722                 }
       
   723             }
       
   724             break;
       
   725         case EWlanWepKey4InHex:
       
   726             {
       
   727             if ( !wlanServiceRecord->iWlanFormatKey4.IsNull() &&
       
   728                     !wlanServiceRecord->iWLanWepKey4.IsNull() )
       
   729                 {
       
   730                 if ( wlanServiceRecord->iWlanFormatKey4 == EWlanWepKeyFormatAscii )
       
   731                     {
       
   732                     // Format is ascii.
       
   733                     retVal = ConvertAsciiToHexL( wlanServiceRecord->iWLanWepKey4.GetL() );
       
   734                     }
       
   735                 else
       
   736                     {
       
   737                     // Format is hex.
       
   738                     retVal = ( wlanServiceRecord->iWLanWepKey4.GetL() ).AllocL();
       
   739                     }
       
   740                 }
       
   741             }
       
   742             break;
       
   743         case EWlanWepKey1InAscii:
       
   744             {
       
   745             if ( !wlanServiceRecord->iWlanFormatKey1.IsNull() &&
       
   746                     !wlanServiceRecord->iWLanWepKey1.IsNull() )
       
   747                 {
       
   748                 if ( wlanServiceRecord->iWlanFormatKey1 == EWlanWepKeyFormatAscii )
       
   749                     {
       
   750                     // Format is ascii.
       
   751                     retVal = ( wlanServiceRecord->iWLanWepKey1.GetL() ).AllocL();
       
   752                     }
       
   753                 else
       
   754                     {
       
   755                     // Format is hex.
       
   756                     retVal = ConvertHexToAsciiL( wlanServiceRecord->iWLanWepKey1.GetL() );
       
   757                     }
       
   758                 }
       
   759             }
       
   760             break;
       
   761         case EWlanWepKey2InAscii:
       
   762             {
       
   763             if ( !wlanServiceRecord->iWlanFormatKey2.IsNull() &&
       
   764                     !wlanServiceRecord->iWLanWepKey2.IsNull() )
       
   765                 {
       
   766                 if ( wlanServiceRecord->iWlanFormatKey2 == EWlanWepKeyFormatAscii )
       
   767                     {
       
   768                     // Format is ascii.
       
   769                     retVal = ( wlanServiceRecord->iWLanWepKey2.GetL() ).AllocL();
       
   770                     }
       
   771                 else
       
   772                     {
       
   773                     // Format is hex.
       
   774                     retVal = ConvertHexToAsciiL( wlanServiceRecord->iWLanWepKey2.GetL() );
       
   775                     }
       
   776                 }
       
   777             }
       
   778             break;
       
   779         case EWlanWepKey3InAscii:
       
   780             {
       
   781             if ( !wlanServiceRecord->iWlanFormatKey3.IsNull() &&
       
   782                     !wlanServiceRecord->iWLanWepKey3.IsNull() )
       
   783                 {
       
   784                 if ( wlanServiceRecord->iWlanFormatKey3 == EWlanWepKeyFormatAscii )
       
   785                     {
       
   786                     // Format is ascii.
       
   787                     retVal = ( wlanServiceRecord->iWLanWepKey3.GetL() ).AllocL();
       
   788                     }
       
   789                 else
       
   790                     {
       
   791                     // Format is hex.
       
   792                     retVal = ConvertHexToAsciiL( wlanServiceRecord->iWLanWepKey3.GetL() );
       
   793                     }
       
   794                 }
       
   795             }
       
   796             break;
       
   797         case EWlanWepKey4InAscii:
       
   798             {
       
   799             if ( !wlanServiceRecord->iWlanFormatKey4.IsNull() &&
       
   800                     !wlanServiceRecord->iWLanWepKey4.IsNull() )
       
   801                 {
       
   802                 if ( wlanServiceRecord->iWlanFormatKey4 == EWlanWepKeyFormatAscii )
       
   803                     {
       
   804                     // Format is ascii.
       
   805                     retVal = ( wlanServiceRecord->iWLanWepKey4.GetL() ).AllocL();
       
   806                     }
       
   807                 else
       
   808                     {
       
   809                     // Format is hex.
       
   810                     retVal = ConvertHexToAsciiL( wlanServiceRecord->iWLanWepKey4.GetL() );
       
   811                     }
       
   812                 }
       
   813             }
       
   814             break;
       
   815         case EWlanWapiPsk:
       
   816             {
       
   817             if ( !wlanServiceRecord->iWLanWpaPreSharedKey.IsNull() )
       
   818                 {
       
   819                 retVal = ( wlanServiceRecord->iWLanWpaPreSharedKey.GetL() ).AllocL();
       
   820                 }
       
   821             }
       
   822             break;
       
   823 
       
   824         default:
       
   825             {
       
   826             User::Leave( KErrNotSupported );
       
   827             }
       
   828             break;
       
   829         }
       
   830 
       
   831     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERSTRING8ATTRIBUTEL_EXIT );
       
   832     return retVal;
       
   833     }
       
   834 
       
   835 // --------------------------------------------------------------------------
       
   836 // CCmPluginWlan::SetBearerIntAttributeL
       
   837 // --------------------------------------------------------------------------
       
   838 //
       
   839 void CCmPluginWlan::SetBearerIntAttributeL(
       
   840         TUint32 aAttribute,
       
   841         TUint32 aValue,
       
   842         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
   843         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
   844     {
       
   845     OstTraceFunctionEntry0( CCMPLUGINWLAN_SETBEARERINTATTRIBUTEL_ENTRY );
       
   846 
       
   847     CCDLANServiceRecord* serviceRecord =
       
   848             static_cast<CCDLANServiceRecord*>(
       
   849                     aGenRecordArray[KServiceRecordIndex] );
       
   850 
       
   851     CCDWlanServiceRecord* wlanServiceRecord =
       
   852             static_cast<CCDWlanServiceRecord*>(
       
   853                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
   854 
       
   855     switch ( aAttribute )
       
   856         {
       
   857         case ECmExtensionLevel:
       
   858         case ECmCommsDBBearerType:
       
   859         case ECmDefaultUiPriority:
       
   860         case ECmDefaultPriority:
       
   861             {
       
   862             User::Leave( KErrArgument );
       
   863             }
       
   864             break;
       
   865         case EWlanServiceId:
       
   866             {
       
   867             wlanServiceRecord->iWlanServiceId.SetL( aValue );
       
   868             }
       
   869             break;
       
   870         case EWlanConnectionMode:
       
   871             {
       
   872             wlanServiceRecord->iWlanConnMode.SetL( aValue );
       
   873             }
       
   874             break;
       
   875         case EWlanSecurityMode:
       
   876             {
       
   877             CheckSecurityAttributeValidityL( aAttribute, aValue );
       
   878             wlanServiceRecord->iWlanSecMode.SetL( aValue );
       
   879             // When setting security mode, also reset authentication mode to open.
       
   880             wlanServiceRecord->iWlanAuthMode.SetL( CMManager::EWlanAuthModeOpen );
       
   881             if ( aValue == EWlanSecMode802_1x )
       
   882                 {
       
   883                 // By default, do not allow unencrypted mode for 802.1x (Korea).
       
   884                 wlanServiceRecord->iWlanWpaKeyLength.SetL( 0 );
       
   885                 }
       
   886             }
       
   887             break;
       
   888         case EWlanAuthenticationMode:
       
   889             {
       
   890             CheckSecurityAttributeValidityL( aAttribute, aValue );
       
   891             wlanServiceRecord->iWlanAuthMode.SetL( aValue );
       
   892             }
       
   893             break;
       
   894         case EWlanChannelID:
       
   895             {
       
   896             wlanServiceRecord->iWlanChannelID.SetL( aValue );
       
   897             }
       
   898             break;
       
   899         case EWlanServiceExtensionTableRecordId:
       
   900             {
       
   901             serviceRecord->iServiceExtensionTableRecordId.SetL( aValue );
       
   902             }
       
   903             break;
       
   904         case EWlanWepKeyIndex:
       
   905             {
       
   906             CheckSecurityAttributeValidityL( aAttribute, aValue );
       
   907             wlanServiceRecord->iWlanWepIndex.SetL( aValue );
       
   908             }
       
   909             break;
       
   910         case EWlanWapiPskFormat:
       
   911             {
       
   912             CheckSecurityAttributeValidityL( aAttribute, aValue );
       
   913             wlanServiceRecord->iWlanFormatKey1.SetL( aValue );
       
   914             }
       
   915             break;
       
   916         default:
       
   917             {
       
   918             User::Leave( KErrNotSupported );
       
   919             }
       
   920             break;
       
   921         }
       
   922 
       
   923     OstTraceFunctionExit0( CCMPLUGINWLAN_SETBEARERINTATTRIBUTEL_EXIT );
       
   924     }
       
   925 
       
   926 // --------------------------------------------------------------------------
       
   927 // CCmPluginWlan::SetBearerBoolAttributeL
       
   928 // --------------------------------------------------------------------------
       
   929 //
       
   930 void CCmPluginWlan::SetBearerBoolAttributeL(
       
   931         TUint32 aAttribute,
       
   932         TBool aValue,
       
   933         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
   934         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
   935     {
       
   936     OstTraceFunctionEntry0( CCMPLUGINWLAN_SETBEARERBOOLATTRIBUTEL_ENTRY );
       
   937 
       
   938     CCDWlanServiceRecord* wlanServiceRecord =
       
   939             static_cast<CCDWlanServiceRecord*>(
       
   940                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
   941 
       
   942     CCDLANServiceRecord* serviceRecord =
       
   943             static_cast<CCDLANServiceRecord*>(
       
   944                     aGenRecordArray[KServiceRecordIndex] );
       
   945 
       
   946     switch ( aAttribute )
       
   947         {
       
   948         case EWlanScanSSID:
       
   949             {
       
   950             wlanServiceRecord->iWlanScanSSID.SetL( aValue );
       
   951             }
       
   952             break;
       
   953         case EWlanAllowSSIDRoaming:
       
   954             {
       
   955             wlanServiceRecord->iWlanAllowSSIDRoaming.SetL( aValue );
       
   956             }
       
   957             break;
       
   958         case ECmIPAddFromServer:
       
   959         case EWlanIpAddrFromServer:
       
   960             {
       
   961             serviceRecord->iIpAddrFromServer.SetL( aValue );
       
   962             }
       
   963             break;
       
   964         case ECmIPDNSAddrFromServer:
       
   965         case EWlanIpDNSAddrFromServer:
       
   966             {
       
   967             serviceRecord->iIpDnsAddrFromServer.SetL( aValue );
       
   968             }
       
   969             break;
       
   970         case ECmIP6DNSAddrFromServer:
       
   971         case EWlanIp6DNSAddrFromServer:
       
   972             {
       
   973             serviceRecord->iIp6DnsAddrFromServer.SetL( aValue );
       
   974             }
       
   975             break;
       
   976         case EWlanEnableWpaPsk:
       
   977             {
       
   978             wlanServiceRecord->iWlanEnableWpaPsk.SetL( static_cast<TUint>( aValue ) );
       
   979             }
       
   980             break;
       
   981         case EWlan802_1xAllowUnencrypted:
       
   982             {
       
   983             wlanServiceRecord->iWlanWpaKeyLength.SetL( static_cast<TUint>( aValue ) );
       
   984             }
       
   985             break;
       
   986         default:
       
   987             {
       
   988             User::Leave( KErrNotSupported );
       
   989             }
       
   990             break;
       
   991         }
       
   992 
       
   993     OstTraceFunctionExit0( CCMPLUGINWLAN_SETBEARERBOOLATTRIBUTEL_EXIT );
       
   994     }
       
   995 
       
   996 // --------------------------------------------------------------------------
       
   997 // CCmPluginWlan::SetBearerStringAttributeL
       
   998 // --------------------------------------------------------------------------
       
   999 //
       
  1000 void CCmPluginWlan::SetBearerStringAttributeL(
       
  1001         TUint32 aAttribute,
       
  1002         const TDesC16& aValue,
       
  1003         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
  1004         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
  1005     {
       
  1006     OstTraceFunctionEntry0( CCMPLUGINWLAN_SETBEARERSTRINGATTRIBUTEL_ENTRY );
       
  1007 
       
  1008     CCDWlanServiceRecord* wlanServiceRecord =
       
  1009             static_cast<CCDWlanServiceRecord*>(
       
  1010                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
  1011 
       
  1012     CCDLANServiceRecord* serviceRecord =
       
  1013             static_cast<CCDLANServiceRecord*>(
       
  1014                     aGenRecordArray[KServiceRecordIndex] );
       
  1015 
       
  1016     switch ( aAttribute )
       
  1017         {
       
  1018         case ECmIFNetworks:
       
  1019         case EWlanIfNetworks:
       
  1020             {
       
  1021             serviceRecord->iIfNetworks.SetL( aValue );
       
  1022             }
       
  1023             break;
       
  1024         case ECmIPNetmask:
       
  1025         case EWlanIpNetMask:
       
  1026             {
       
  1027             serviceRecord->iIpNetmask.SetL( aValue );
       
  1028             }
       
  1029             break;
       
  1030         case ECmIPGateway:
       
  1031         case EWlanIpGateway:
       
  1032             {
       
  1033             serviceRecord->iIpGateway.SetL( aValue );
       
  1034             }
       
  1035             break;
       
  1036         case ECmIPAddress:
       
  1037         case EWlanIpAddr:
       
  1038             {
       
  1039             if ( ( aValue.Compare( KUnspecifiedIPv4 ) == 0 ) ||
       
  1040                     ( aValue.Compare( KNullDesC ) == 0 ) )
       
  1041                 {
       
  1042                 // If unspecified or NULL address is set dynamic
       
  1043                 // IP must be enabled.
       
  1044                 SetBearerBoolAttributeL( EWlanIpAddrFromServer,
       
  1045                                          ETrue,
       
  1046                                          aGenRecordArray,
       
  1047                                          aBearerSpecRecordArray );
       
  1048                 }
       
  1049             else
       
  1050                 {
       
  1051                 // If valid address is set dynamic IP is disabled.
       
  1052                 SetBearerBoolAttributeL( EWlanIpAddrFromServer,
       
  1053                                          EFalse,
       
  1054                                          aGenRecordArray,
       
  1055                                          aBearerSpecRecordArray );
       
  1056                 }
       
  1057             serviceRecord->iIpAddr.SetL( aValue );
       
  1058             }
       
  1059             break;
       
  1060         case ECmIPNameServer1:
       
  1061         case EWlanIpNameServer1:
       
  1062             {
       
  1063             serviceRecord->iIpNameServer1.SetL( aValue );
       
  1064             }
       
  1065             break;
       
  1066         case ECmIPNameServer2:
       
  1067         case EWlanIpNameServer2:
       
  1068             {
       
  1069             serviceRecord->iIpNameServer2.SetL( aValue );
       
  1070             }
       
  1071             break;
       
  1072         case ECmIP6NameServer1:
       
  1073         case EWlanIp6NameServer1:
       
  1074             {
       
  1075             serviceRecord->iIp6NameServer1.SetL( aValue );
       
  1076             }
       
  1077             break;
       
  1078         case ECmIP6NameServer2:
       
  1079         case EWlanIp6NameServer2:
       
  1080             {
       
  1081             serviceRecord->iIp6NameServer2.SetL( aValue );
       
  1082             }
       
  1083             break;
       
  1084         case ECmIPAddrLeaseValidFrom:
       
  1085         case EWlanIpAddrLeaseValidFrom:
       
  1086             {
       
  1087             serviceRecord->iIpAddrLeaseValidFrom.SetL( aValue );
       
  1088             }
       
  1089             break;
       
  1090         case ECmIPAddrLeaseValidTo:
       
  1091         case EWlanIpAddrLeaseValidTo:
       
  1092             {
       
  1093             serviceRecord->iIpAddrLeaseValidTo.SetL( aValue );
       
  1094             }
       
  1095             break;
       
  1096         case ECmConfigDaemonManagerName:
       
  1097         case EWlanConfigDaemonManagerName:
       
  1098             {
       
  1099             serviceRecord->iConfigDaemonManagerName.SetL( aValue );
       
  1100             }
       
  1101             break;
       
  1102         case ECmConfigDaemonName:
       
  1103         case EWlanConfigDaemonName:
       
  1104             {
       
  1105             serviceRecord->iConfigDaemonName.SetL( aValue );
       
  1106             }
       
  1107             break;
       
  1108         case EWlanServiceExtensionTableName:
       
  1109             {
       
  1110             serviceRecord->iServiceExtensionTableName.SetL( aValue );
       
  1111             }
       
  1112             break;
       
  1113         case EWlanSSID:
       
  1114             {
       
  1115             wlanServiceRecord->iWLanSSID.SetL( aValue );
       
  1116             }
       
  1117             break;
       
  1118         case EWlanUsedSSID:
       
  1119             {
       
  1120             wlanServiceRecord->iWLanUsedSSID.SetL( aValue );
       
  1121             }
       
  1122             break;
       
  1123         default:
       
  1124             {
       
  1125             User::Leave( KErrNotSupported );
       
  1126             }
       
  1127             break;
       
  1128         }
       
  1129 
       
  1130     OstTraceFunctionExit0( CCMPLUGINWLAN_SETBEARERSTRINGATTRIBUTEL_EXIT );
       
  1131     }
       
  1132 
       
  1133 // --------------------------------------------------------------------------
       
  1134 // CCmPluginWlan::SetBearerString8AttributeL
       
  1135 // --------------------------------------------------------------------------
       
  1136 //
       
  1137 void CCmPluginWlan::SetBearerString8AttributeL(
       
  1138         TUint32 aAttribute,
       
  1139         const TDesC8& aValue,
       
  1140         RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
       
  1141         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
  1142     {
       
  1143     OstTraceFunctionEntry0( CCMPLUGINWLAN_SETBEARERSTRING8ATTRIBUTEL_ENTRY );
       
  1144 
       
  1145     CCDWlanServiceRecord* wlanServiceRecord =
       
  1146             static_cast<CCDWlanServiceRecord*>(
       
  1147                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
  1148 
       
  1149     switch ( aAttribute )
       
  1150         {
       
  1151         case EWlanWpaPreSharedKey:
       
  1152             {
       
  1153             wlanServiceRecord->iWLanWpaPreSharedKey.SetL( aValue );
       
  1154             wlanServiceRecord->iWlanWpaKeyLength.SetL( static_cast<TUint>( aValue.Length() ) );
       
  1155             }
       
  1156             break;
       
  1157         case EWlanWepKey1InHex:
       
  1158             {
       
  1159             wlanServiceRecord->iWLanWepKey1.SetL( aValue );
       
  1160             wlanServiceRecord->iWlanFormatKey1.SetL( EWlanWepKeyFormatHex );
       
  1161             }
       
  1162             break;
       
  1163         case EWlanWepKey2InHex:
       
  1164             {
       
  1165             wlanServiceRecord->iWLanWepKey2.SetL( aValue );
       
  1166             wlanServiceRecord->iWlanFormatKey2.SetL( EWlanWepKeyFormatHex );
       
  1167             }
       
  1168             break;
       
  1169         case EWlanWepKey3InHex:
       
  1170             {
       
  1171             wlanServiceRecord->iWLanWepKey3.SetL( aValue );
       
  1172             wlanServiceRecord->iWlanFormatKey3.SetL( EWlanWepKeyFormatHex );
       
  1173             }
       
  1174             break;
       
  1175         case EWlanWepKey4InHex:
       
  1176             {
       
  1177             wlanServiceRecord->iWLanWepKey4.SetL( aValue );
       
  1178             wlanServiceRecord->iWlanFormatKey4.SetL( EWlanWepKeyFormatHex );
       
  1179             }
       
  1180             break;
       
  1181         case EWlanWepKey1InAscii:
       
  1182             {
       
  1183             HBufC8* valueInHex = ConvertAsciiToHexL( aValue );
       
  1184             CleanupStack::PushL( valueInHex );
       
  1185             wlanServiceRecord->iWLanWepKey1.SetL( *valueInHex );
       
  1186             wlanServiceRecord->iWlanFormatKey1.SetL( EWlanWepKeyFormatHex );
       
  1187             CleanupStack::PopAndDestroy( valueInHex );
       
  1188             }
       
  1189             break;
       
  1190         case EWlanWepKey2InAscii:
       
  1191             {
       
  1192             HBufC8* valueInHex = ConvertAsciiToHexL( aValue );
       
  1193             CleanupStack::PushL( valueInHex );
       
  1194             wlanServiceRecord->iWLanWepKey2.SetL( *valueInHex );
       
  1195             wlanServiceRecord->iWlanFormatKey2.SetL( EWlanWepKeyFormatHex );
       
  1196             CleanupStack::PopAndDestroy( valueInHex );
       
  1197             }
       
  1198             break;
       
  1199         case EWlanWepKey3InAscii:
       
  1200             {
       
  1201             HBufC8* valueInHex = ConvertAsciiToHexL( aValue );
       
  1202             CleanupStack::PushL( valueInHex );
       
  1203             wlanServiceRecord->iWLanWepKey3.SetL( *valueInHex );
       
  1204             wlanServiceRecord->iWlanFormatKey3.SetL( EWlanWepKeyFormatHex );
       
  1205             CleanupStack::PopAndDestroy( valueInHex );
       
  1206             }
       
  1207             break;
       
  1208         case EWlanWepKey4InAscii:
       
  1209             {
       
  1210             HBufC8* valueInHex = ConvertAsciiToHexL( aValue );
       
  1211             CleanupStack::PushL( valueInHex );
       
  1212             wlanServiceRecord->iWLanWepKey4.SetL( *valueInHex );
       
  1213             wlanServiceRecord->iWlanFormatKey4.SetL( EWlanWepKeyFormatHex );
       
  1214             CleanupStack::PopAndDestroy( valueInHex );
       
  1215             }
       
  1216             break;
       
  1217         case EWlanWapiPsk:
       
  1218             {
       
  1219             wlanServiceRecord->iWLanWpaPreSharedKey.SetL( aValue );
       
  1220             }
       
  1221             break;
       
  1222 
       
  1223         default:
       
  1224             {
       
  1225             User::Leave( KErrNotSupported );
       
  1226             }
       
  1227             break;
       
  1228         }
       
  1229 
       
  1230     OstTraceFunctionExit0( CCMPLUGINWLAN_SETBEARERSTRING8ATTRIBUTEL_EXIT );
       
  1231     }
       
  1232 
       
  1233 // --------------------------------------------------------------------------
       
  1234 // CCmPluginWlan::CanHandleIapIdL
       
  1235 // --------------------------------------------------------------------------
       
  1236 //
       
  1237 TBool CCmPluginWlan::CanHandleIapIdL( TUint32 aIapId ) const
       
  1238     {
       
  1239     OstTraceFunctionEntry0( CCMPLUGINWLAN_CANHANDLEIAPIDL_ENTRY );
       
  1240 
       
  1241     TBool retVal( EFalse );
       
  1242 
       
  1243     CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>(
       
  1244             CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord) );
       
  1245 
       
  1246     CleanupStack::PushL( iapRecord );
       
  1247     iapRecord->SetRecordId( aIapId );
       
  1248 
       
  1249     TRAPD( err, iapRecord->LoadL( iSession ) );
       
  1250 
       
  1251     if ( !err )
       
  1252         {
       
  1253         retVal = CanHandleIapIdL( iapRecord );
       
  1254         }
       
  1255 
       
  1256     CleanupStack::PopAndDestroy( iapRecord );
       
  1257 
       
  1258     OstTraceFunctionExit0( CCMPLUGINWLAN_CANHANDLEIAPIDL_EXIT );
       
  1259     return retVal;
       
  1260     }
       
  1261 
       
  1262 // --------------------------------------------------------------------------
       
  1263 // CCmPluginWlan::CanHandleIapIdL
       
  1264 // --------------------------------------------------------------------------
       
  1265 //
       
  1266 TBool CCmPluginWlan::CanHandleIapIdL( CCDIAPRecord *aIapRecord ) const
       
  1267     {
       
  1268     OstTraceFunctionEntry0( DUP1_CCMPLUGINWLAN_CANHANDLEIAPIDL_ENTRY );
       
  1269 
       
  1270     TBool retVal( EFalse );
       
  1271 
       
  1272     if ( ( TPtrC( aIapRecord->iServiceType ) == TPtrC( KCDTypeNameLANService ) ) &&
       
  1273             TPtrC( aIapRecord->iBearerType ) == TPtrC( KCDTypeNameLANBearer ) )
       
  1274         {
       
  1275         // Check if there is a WLAN record with an iServiceId == iIapRecord->iService.
       
  1276         CCDWlanServiceRecord* tmprec = new( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
       
  1277         CleanupStack::PushL( tmprec );
       
  1278 
       
  1279         tmprec->iWlanServiceId.SetL( ( TUint32 )( aIapRecord->iService ) );
       
  1280         if ( tmprec->FindL( iSession ) )
       
  1281             {
       
  1282             // Found at least one WLAN using this IAP.
       
  1283             retVal = ETrue;
       
  1284             }
       
  1285 
       
  1286         CleanupStack::PopAndDestroy( tmprec );
       
  1287         }
       
  1288 
       
  1289     OstTraceFunctionExit0( DUP1_CCMPLUGINWLAN_CANHANDLEIAPIDL_EXIT );
       
  1290     return retVal;
       
  1291     }
       
  1292 
       
  1293 // --------------------------------------------------------------------------
       
  1294 // CCmPluginWlan::DeleteBearerRecordsL
       
  1295 // --------------------------------------------------------------------------
       
  1296 //
       
  1297 void CCmPluginWlan::DeleteBearerRecordsL()
       
  1298     {
       
  1299     OstTraceFunctionEntry0( CCMPLUGINWLAN_DELETEBEARERRECORDSL_ENTRY );
       
  1300 
       
  1301     // Save the wlan service record id for the EAP settings deletion.
       
  1302     TUint wlanServiceRecordId = iWlanServiceRecord->RecordId();
       
  1303 
       
  1304     // As base class deletes service record, in this case LAN, only WLAN
       
  1305     // related stuff needs to be deleted.
       
  1306     iWlanServiceRecord->DeleteL( iSession );
       
  1307 
       
  1308     // Delete EAP specific.
       
  1309     CEapGeneralSettings* eapSettings( NULL );
       
  1310     TRAPD( err, eapSettings = CEapGeneralSettings::NewL( ELan, wlanServiceRecordId ) );
       
  1311     if ( err == KErrNone )
       
  1312         {
       
  1313         eapSettings->DeleteAllEapSettings();
       
  1314         delete eapSettings;
       
  1315         }
       
  1316 
       
  1317     OstTraceFunctionExit0( CCMPLUGINWLAN_DELETEBEARERRECORDSL_EXIT );
       
  1318     }
       
  1319 
       
  1320 // --------------------------------------------------------------------------
       
  1321 // CCmPluginWlan::LoadServiceRecordL
       
  1322 // --------------------------------------------------------------------------
       
  1323 //
       
  1324 void CCmPluginWlan::LoadServiceRecordL()
       
  1325     {
       
  1326     OstTraceFunctionEntry0( CCMPLUGINWLAN_LOADSERVICERECORDL_ENTRY );
       
  1327 
       
  1328     if ( TPtrC( KCDTypeNameLANService ) == iIapRecord->iServiceType )
       
  1329         {
       
  1330         iServiceRecord = static_cast<CCDLANServiceRecord*>(
       
  1331                 CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
       
  1332 
       
  1333         ServiceRecord().SetRecordId( iIapRecord->iService );
       
  1334         ServiceRecord().LoadL( iSession );
       
  1335         }
       
  1336     else
       
  1337         // this IAP service is not supported by this plugin.
       
  1338         {
       
  1339         User::Leave( KErrNotSupported );
       
  1340         }
       
  1341 
       
  1342     OstTraceFunctionExit0( CCMPLUGINWLAN_LOADSERVICERECORDL_EXIT );
       
  1343     }
       
  1344 
       
  1345 // --------------------------------------------------------------------------
       
  1346 // CCmPluginWlan::LoadBearerRecordsL
       
  1347 // --------------------------------------------------------------------------
       
  1348 //
       
  1349 void CCmPluginWlan::LoadBearerRecordsL()
       
  1350     {
       
  1351     OstTraceFunctionEntry0( CCMPLUGINWLAN_LOADBEARERRECORDSL_ENTRY );
       
  1352 
       
  1353     if ( !iWlanServiceRecord )
       
  1354         {
       
  1355         iWlanServiceRecord = new( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
       
  1356         }
       
  1357     iWlanServiceRecord->SetRecordId( 0 );
       
  1358 
       
  1359     iWlanServiceRecord->iWlanServiceId.SetL( ( TUint32 )( iIapRecord->iService ) );
       
  1360 
       
  1361     if ( iWlanServiceRecord->FindL( iSession ) )
       
  1362         {
       
  1363         iWlanServiceRecord->LoadL( iSession );
       
  1364         }
       
  1365     else
       
  1366         {
       
  1367         // not found -> error
       
  1368         User::Leave( KErrNotFound );
       
  1369         }
       
  1370 
       
  1371     OstTraceFunctionExit0( CCMPLUGINWLAN_LOADBEARERRECORDSL_EXIT );
       
  1372     }
       
  1373 
       
  1374 // --------------------------------------------------------------------------
       
  1375 // CCmPluginWlan::CreateServiceRecordL
       
  1376 // --------------------------------------------------------------------------
       
  1377 //
       
  1378 void CCmPluginWlan::CreateServiceRecordL()
       
  1379     {
       
  1380     OstTraceFunctionEntry0( CCMPLUGINWLAN_CREATESERVICERECORDL_ENTRY );
       
  1381 
       
  1382     delete iServiceRecord;
       
  1383     iServiceRecord = NULL;
       
  1384 
       
  1385     iServiceRecord = static_cast<CCDLANServiceRecord*>(
       
  1386             CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
       
  1387 
       
  1388     CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord*>( iServiceRecord );
       
  1389 
       
  1390     if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
       
  1391         {
       
  1392         lanServiceRecord->iIfNetworks.SetL( KDefIspIfNetworksIPv4IPv6 );
       
  1393         }
       
  1394     else
       
  1395         {
       
  1396         lanServiceRecord->iIfNetworks.SetL( KDefIspIfNetworksIPv4 );
       
  1397         }
       
  1398 
       
  1399     lanServiceRecord->iIpGateway.SetL( KUnspecifiedIPv4 );
       
  1400     lanServiceRecord->iIpAddrFromServer.SetL( KDefIpAddrFromServer );
       
  1401 
       
  1402     lanServiceRecord->iIpAddr.SetL( KUnspecifiedIPv4 );
       
  1403 
       
  1404     lanServiceRecord->iIpDnsAddrFromServer.SetL( KDefIpDnsAddrFromServer );
       
  1405 
       
  1406     lanServiceRecord->iIpNameServer1.SetL( KUnspecifiedIPv4 );
       
  1407     lanServiceRecord->iIpNameServer2.SetL( KUnspecifiedIPv4 );
       
  1408     lanServiceRecord->iIp6DnsAddrFromServer.SetL( KDefIp6DnsAddrFromServer );
       
  1409     lanServiceRecord->iIp6NameServer1.SetL( KDynamicIpv6Address );
       
  1410     lanServiceRecord->iIp6NameServer2.SetL( KDynamicIpv6Address );
       
  1411 
       
  1412     if ( KDefIpAddrFromServer )
       
  1413         {
       
  1414         lanServiceRecord->iConfigDaemonManagerName.SetL( KDaemonManagerName );
       
  1415         lanServiceRecord->iConfigDaemonName.SetL( KConfigDaemonName );
       
  1416         }
       
  1417     else
       
  1418         {
       
  1419         lanServiceRecord->iConfigDaemonManagerName.SetL( KEmpty );
       
  1420         lanServiceRecord->iConfigDaemonName.SetL( KEmpty );
       
  1421         }
       
  1422 
       
  1423     // Create WLAN service record.
       
  1424     CreateWlanServiceRecordL();
       
  1425 
       
  1426     OstTraceFunctionExit0( CCMPLUGINWLAN_CREATESERVICERECORDL_EXIT );
       
  1427     }
       
  1428 
       
  1429 // --------------------------------------------------------------------------
       
  1430 // CCmPluginWlan::CreateWlanServiceRecordL
       
  1431 // --------------------------------------------------------------------------
       
  1432 //
       
  1433 void CCmPluginWlan::CreateWlanServiceRecordL()
       
  1434     {
       
  1435     OstTraceFunctionEntry0( CCMPLUGINWLAN_CREATEWLANSERVICERECORDL_ENTRY );
       
  1436 
       
  1437     delete iWlanServiceRecord;
       
  1438 
       
  1439     iWlanServiceRecord = NULL;
       
  1440 
       
  1441     iWlanServiceRecord = new( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
       
  1442     iWlanServiceRecord->SetRecordId( KCDNewRecordRequest );
       
  1443 
       
  1444     // Some attributes need to have default values set.
       
  1445     iWlanServiceRecord->iRecordName.SetL( iIapRecord->iRecordName );
       
  1446     iWlanServiceRecord->iWlanConnMode.SetL( CMManager::EInfra );
       
  1447     iWlanServiceRecord->iWlanSecMode.SetL( CMManager::EWlanSecModeOpen );
       
  1448     iWlanServiceRecord->iWlanAuthMode.SetL( CMManager::EWlanAuthModeOpen );
       
  1449     iWlanServiceRecord->iWlanScanSSID.SetL( EFalse );
       
  1450 
       
  1451     OstTraceFunctionExit0( CCMPLUGINWLAN_CREATEWLANSERVICERECORDL_EXIT );
       
  1452     }
       
  1453 
       
  1454 // ----------------------------------------------------------------------------
       
  1455 // CCmPluginWlan::PreparePluginToUpdateRecordsL()
       
  1456 // ----------------------------------------------------------------------------
       
  1457 //
       
  1458 void CCmPluginWlan::PreparePluginToLoadRecordsL()
       
  1459     {
       
  1460     OstTraceFunctionEntry0( CCMPLUGINWLAN_PREPAREPLUGINTOLOADRECORDSL_ENTRY );
       
  1461 
       
  1462     OstTraceFunctionExit0( CCMPLUGINWLAN_PREPAREPLUGINTOLOADRECORDSL_EXIT );
       
  1463     }
       
  1464 
       
  1465 // ----------------------------------------------------------------------------
       
  1466 // CCmPluginWlan::PreparePluginToUpdateRecordsL()
       
  1467 // ----------------------------------------------------------------------------
       
  1468 //
       
  1469 void CCmPluginWlan::PreparePluginToUpdateRecordsL(
       
  1470         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
  1471         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
  1472     {
       
  1473     OstTraceFunctionEntry0( CCMPLUGINWLAN_PREPAREPLUGINTOUPDATERECORDSL_ENTRY );
       
  1474 
       
  1475     CCDWlanServiceRecord* wlanServiceRecord =
       
  1476             static_cast<CCDWlanServiceRecord*>(
       
  1477                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
  1478 
       
  1479     CCDIAPRecord* iapRecord =
       
  1480             static_cast<CCDIAPRecord*>(
       
  1481                     aGenRecordArray[KIapRecordIndex] );
       
  1482 
       
  1483     CheckIfNameModifiedL( iapRecord, wlanServiceRecord );
       
  1484     wlanServiceRecord->iWlanServiceId.SetL( ( TUint32 )( iapRecord->iService ) );
       
  1485 
       
  1486     CCDLANServiceRecord* serviceRecord =
       
  1487             static_cast<CCDLANServiceRecord*>(
       
  1488                     aGenRecordArray[KServiceRecordIndex] );
       
  1489 
       
  1490     CheckIfNameModifiedL( iapRecord, serviceRecord );
       
  1491 
       
  1492     CheckDNSServerAddressL( ETrue,
       
  1493                             serviceRecord->iIp6NameServer1,
       
  1494                             serviceRecord->iIp6NameServer2,
       
  1495                             serviceRecord->iIp6DnsAddrFromServer );
       
  1496 
       
  1497     CheckDNSServerAddressL( EFalse,
       
  1498                             serviceRecord->iIpNameServer1,
       
  1499                             serviceRecord->iIpNameServer2,
       
  1500                             serviceRecord->iIpDnsAddrFromServer );
       
  1501 
       
  1502     SetDaemonNameL( aGenRecordArray, aBearerSpecRecordArray );
       
  1503 
       
  1504     OstTraceFunctionExit0( CCMPLUGINWLAN_PREPAREPLUGINTOUPDATERECORDSL_EXIT );
       
  1505     }
       
  1506 
       
  1507 // ----------------------------------------------------------------------------
       
  1508 // CCmPluginWlan::UpdateServiceRecordL()
       
  1509 // ----------------------------------------------------------------------------
       
  1510 //
       
  1511 void CCmPluginWlan::UpdateServiceRecordL(
       
  1512         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
  1513         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
  1514     {
       
  1515     OstTraceFunctionEntry0( CCMPLUGINWLAN_UPDATESERVICERECORDL_ENTRY );
       
  1516 
       
  1517     // Delete the original record and create a copy from the client's copy.
       
  1518     delete iServiceRecord;
       
  1519     iServiceRecord = NULL;
       
  1520 
       
  1521     iServiceRecord = static_cast<CCDLANServiceRecord *>(
       
  1522             CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
       
  1523 
       
  1524     // Plugin's commsdat copy.
       
  1525     CCDLANServiceRecord* origServiceRecord =
       
  1526             static_cast<CCDLANServiceRecord*>( iServiceRecord );
       
  1527 
       
  1528     // Client's copy of lan service record.
       
  1529     CCDLANServiceRecord* clientServiceRecordCopy =
       
  1530             static_cast<CCDLANServiceRecord*>( aGenRecordArray[KServiceRecordIndex] );
       
  1531 
       
  1532     CopyRecordFieldsL( *clientServiceRecordCopy, *origServiceRecord );
       
  1533 
       
  1534     origServiceRecord->SetElementId( clientServiceRecordCopy->ElementId() );
       
  1535 
       
  1536     if ( !origServiceRecord->RecordId() )
       
  1537         {
       
  1538         origServiceRecord->SetRecordId( KCDNewRecordRequest );
       
  1539         origServiceRecord->StoreL( iSession );
       
  1540         // Have to be "reloaded" to get possible default values from template records.
       
  1541         origServiceRecord->LoadL( iSession );
       
  1542 
       
  1543         // Update received element ID to client's copy too.
       
  1544         clientServiceRecordCopy->SetElementId( origServiceRecord->ElementId() );
       
  1545 
       
  1546         // Copy record back to client's copy to be exactly same as in database.
       
  1547         CCmPluginBaseEng::CopyRecordFieldsL( *origServiceRecord,
       
  1548                 *clientServiceRecordCopy );
       
  1549 
       
  1550         // Update needed values to other table records too (wlanservice).
       
  1551         CCDWlanServiceRecord* wlanServiceRecord =
       
  1552                 static_cast<CCDWlanServiceRecord *>(
       
  1553                         aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
  1554         wlanServiceRecord->iWlanServiceId.SetL( origServiceRecord->RecordId() );
       
  1555         }
       
  1556     else
       
  1557         {
       
  1558         origServiceRecord->ModifyL( iSession );
       
  1559 
       
  1560         CCmPluginBaseEng::CopyRecordFieldsL( *origServiceRecord,
       
  1561                 *clientServiceRecordCopy );
       
  1562         }
       
  1563 
       
  1564     OstTraceFunctionExit0( CCMPLUGINWLAN_UPDATESERVICERECORDL_EXIT );
       
  1565     }
       
  1566 
       
  1567 // ----------------------------------------------------------------------------
       
  1568 // CCmPluginWlan::UpdateBearerRecordsL()
       
  1569 // ----------------------------------------------------------------------------
       
  1570 //
       
  1571 void CCmPluginWlan::UpdateBearerRecordsL(
       
  1572         RPointerArray<CommsDat::CCDRecordBase>& /*aGenRecordArray*/,
       
  1573         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
  1574     {
       
  1575     OstTraceFunctionEntry0( CCMPLUGINWLAN_UPDATEBEARERRECORDSL_ENTRY );
       
  1576 
       
  1577     // Delete the original record and create a copy from the client's copy.
       
  1578     delete iWlanServiceRecord;
       
  1579     iWlanServiceRecord = NULL;
       
  1580 
       
  1581     iWlanServiceRecord = new( ELeave ) CCDWlanServiceRecord( iWlanTableId );
       
  1582 
       
  1583     // Client's copy of wlan service record.
       
  1584     CCDWlanServiceRecord* clientWlanServiceRecord =
       
  1585             static_cast<CCDWlanServiceRecord*>(
       
  1586                     aBearerSpecRecordArray[KWlanServiceRecordIndex] );
       
  1587 
       
  1588     CopyRecordFieldsL( *clientWlanServiceRecord, *iWlanServiceRecord );
       
  1589 
       
  1590     iWlanServiceRecord->SetElementId( clientWlanServiceRecord->ElementId() );
       
  1591 
       
  1592     if ( !iWlanServiceRecord->RecordId() )
       
  1593         {
       
  1594         iWlanServiceRecord->SetRecordId( KCDNewRecordRequest );
       
  1595         iWlanServiceRecord->StoreL( iSession );
       
  1596         // Have to be "reloaded" to get possible default values from template records.
       
  1597         iWlanServiceRecord->LoadL( iSession );
       
  1598 
       
  1599         // Update received element ID to client's copy too.
       
  1600         clientWlanServiceRecord->SetElementId( iWlanServiceRecord->ElementId() );
       
  1601         }
       
  1602     else
       
  1603         {
       
  1604         iWlanServiceRecord->ModifyL( iSession );
       
  1605         }
       
  1606 
       
  1607     // Copy record back to client's copy to be exactly same as in database.
       
  1608     CCmPluginBaseEng::CopyRecordFieldsL( *iWlanServiceRecord,
       
  1609             *clientWlanServiceRecord );
       
  1610 
       
  1611     OstTraceFunctionExit0( CCMPLUGINWLAN_UPDATEBEARERRECORDSL_EXIT );
       
  1612     }
       
  1613 
       
  1614 // ---------------------------------------------------------------------------
       
  1615 // CCmPluginWlan::GetBearerSpecificRecordsL
       
  1616 // ---------------------------------------------------------------------------
       
  1617 //
       
  1618 void CCmPluginWlan::GetBearerSpecificRecordsL(
       
  1619         RPointerArray<CommsDat::CCDRecordBase>& aRecordArray )
       
  1620     {
       
  1621     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERSPECIFICRECORDSL_ENTRY );
       
  1622 
       
  1623     if ( !iWlanServiceRecord )
       
  1624         {
       
  1625         // IAP not yet in CommsDat.
       
  1626         GetDefaultWlanServiceRecordL( aRecordArray );
       
  1627         }
       
  1628     else
       
  1629         {
       
  1630         CCDWlanServiceRecord* wlanServiceRecord = new( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
       
  1631         CleanupStack::PushL( wlanServiceRecord );
       
  1632         CopyWlanServiceRecordL( iWlanServiceRecord, wlanServiceRecord );
       
  1633         wlanServiceRecord->SetElementId( iWlanServiceRecord->ElementId() );
       
  1634         aRecordArray.AppendL( wlanServiceRecord );
       
  1635         CleanupStack::Pop( wlanServiceRecord );
       
  1636         }
       
  1637 
       
  1638     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERSPECIFICRECORDSL_EXIT );
       
  1639     }
       
  1640 
       
  1641 // ---------------------------------------------------------------------------
       
  1642 // CCmPluginWlan::CopyServiceRecordL
       
  1643 // ---------------------------------------------------------------------------
       
  1644 //
       
  1645 CommsDat::CCDRecordBase* CCmPluginWlan::CopyServiceRecordL()
       
  1646     {
       
  1647     OstTraceFunctionEntry0( CCMPLUGINWLAN_COPYSERVICERECORDL_ENTRY );
       
  1648 
       
  1649     // New service record to be returned.
       
  1650     CCDRecordBase* serviceRecord = static_cast<CCDLANServiceRecord*>(
       
  1651             CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
       
  1652     CleanupStack::PushL( serviceRecord );
       
  1653 
       
  1654     CCDLANServiceRecord* tempServiceRecordPtrToNew =
       
  1655             static_cast<CCDLANServiceRecord*>( serviceRecord );
       
  1656 
       
  1657     // CommsDat version of service record.
       
  1658     CCDLANServiceRecord* origServiceRecord =
       
  1659             static_cast<CCDLANServiceRecord*>( iServiceRecord );
       
  1660 
       
  1661     if ( !origServiceRecord->iRecordTag.IsNull() )
       
  1662         {
       
  1663         tempServiceRecordPtrToNew->iRecordTag.SetL(
       
  1664                 origServiceRecord->iRecordTag );
       
  1665         }
       
  1666     if ( !origServiceRecord->iRecordName.IsNull() )
       
  1667         {
       
  1668         tempServiceRecordPtrToNew->iRecordName.SetL(
       
  1669                 origServiceRecord->iRecordName );
       
  1670         }
       
  1671     if ( !origServiceRecord->iServiceEnableLlmnr.IsNull() )
       
  1672         {
       
  1673         tempServiceRecordPtrToNew->iServiceEnableLlmnr.SetL(
       
  1674                 origServiceRecord->iServiceEnableLlmnr );
       
  1675         }
       
  1676     if ( !origServiceRecord->iIfNetworks.IsNull() )
       
  1677         {
       
  1678         tempServiceRecordPtrToNew->iIfNetworks.SetL(
       
  1679                 origServiceRecord->iIfNetworks );
       
  1680         }
       
  1681     if ( !origServiceRecord->iIpNetmask.IsNull() )
       
  1682         {
       
  1683         tempServiceRecordPtrToNew->iIpNetmask.SetL(
       
  1684                 origServiceRecord->iIpNetmask );
       
  1685         }
       
  1686     if ( !origServiceRecord->iIpGateway.IsNull() )
       
  1687         {
       
  1688         tempServiceRecordPtrToNew->iIpGateway.SetL(
       
  1689                 origServiceRecord->iIpGateway );
       
  1690         }
       
  1691     if ( !origServiceRecord->iIpAddrFromServer.IsNull() )
       
  1692         {
       
  1693         tempServiceRecordPtrToNew->iIpAddrFromServer.SetL(
       
  1694                 origServiceRecord->iIpAddrFromServer );
       
  1695         }
       
  1696     if ( !origServiceRecord->iIpAddr.IsNull() )
       
  1697         {
       
  1698         tempServiceRecordPtrToNew->iIpAddr.SetL(
       
  1699                 origServiceRecord->iIpAddr );
       
  1700         }
       
  1701     if ( !origServiceRecord->iIpDnsAddrFromServer.IsNull() )
       
  1702         {
       
  1703         tempServiceRecordPtrToNew->iIpDnsAddrFromServer.SetL(
       
  1704                 origServiceRecord->iIpDnsAddrFromServer );
       
  1705         }
       
  1706     if ( !origServiceRecord->iIpNameServer1.IsNull() )
       
  1707         {
       
  1708         tempServiceRecordPtrToNew->iIpNameServer1.SetL(
       
  1709                 origServiceRecord->iIpNameServer1 );
       
  1710         }
       
  1711     if ( !origServiceRecord->iIpNameServer2.IsNull() )
       
  1712         {
       
  1713         tempServiceRecordPtrToNew->iIpNameServer2.SetL(
       
  1714                 origServiceRecord->iIpNameServer2 );
       
  1715         }
       
  1716     if ( !origServiceRecord->iIp6DnsAddrFromServer.IsNull() )
       
  1717         {
       
  1718         tempServiceRecordPtrToNew->iIp6DnsAddrFromServer.SetL(
       
  1719                 origServiceRecord->iIp6DnsAddrFromServer );
       
  1720         }
       
  1721     if ( !origServiceRecord->iIp6NameServer1.IsNull() )
       
  1722         {
       
  1723         tempServiceRecordPtrToNew->iIp6NameServer1.SetL(
       
  1724                 origServiceRecord->iIp6NameServer1 );
       
  1725         }
       
  1726     if ( !origServiceRecord->iIp6NameServer2.IsNull() )
       
  1727         {
       
  1728         tempServiceRecordPtrToNew->iIp6NameServer2.SetL(
       
  1729                 origServiceRecord->iIp6NameServer2 );
       
  1730         }
       
  1731     if ( !origServiceRecord->iIpAddrLeaseValidFrom.IsNull() )
       
  1732         {
       
  1733         tempServiceRecordPtrToNew->iIpAddrLeaseValidFrom.SetL(
       
  1734                 origServiceRecord->iIpAddrLeaseValidFrom );
       
  1735         }
       
  1736     if ( !origServiceRecord->iIpAddrLeaseValidTo.IsNull() )
       
  1737         {
       
  1738         tempServiceRecordPtrToNew->iIpAddrLeaseValidTo.SetL(
       
  1739                 origServiceRecord->iIpAddrLeaseValidTo );
       
  1740         }
       
  1741     if ( !origServiceRecord->iConfigDaemonManagerName.IsNull() )
       
  1742         {
       
  1743         tempServiceRecordPtrToNew->iConfigDaemonManagerName.SetL(
       
  1744                 origServiceRecord->iConfigDaemonManagerName );
       
  1745         }
       
  1746     if ( !origServiceRecord->iConfigDaemonName.IsNull() )
       
  1747         {
       
  1748         tempServiceRecordPtrToNew->iConfigDaemonName.SetL(
       
  1749                 origServiceRecord->iConfigDaemonName );
       
  1750         }
       
  1751     if ( !origServiceRecord->iServiceExtensionTableName.IsNull() )
       
  1752         {
       
  1753         tempServiceRecordPtrToNew->iServiceExtensionTableName.SetL(
       
  1754                 origServiceRecord->iServiceExtensionTableName );
       
  1755         }
       
  1756     if ( !origServiceRecord->iServiceExtensionTableRecordId.IsNull() )
       
  1757         {
       
  1758         tempServiceRecordPtrToNew->iServiceExtensionTableRecordId.SetL(
       
  1759                 origServiceRecord->iServiceExtensionTableRecordId );
       
  1760         }
       
  1761 
       
  1762     CleanupStack::Pop( serviceRecord );
       
  1763 
       
  1764     OstTraceFunctionExit0( CCMPLUGINWLAN_COPYSERVICERECORDL_EXIT );
       
  1765     return serviceRecord;
       
  1766     }
       
  1767 
       
  1768 // ----------------------------------------------------------------------------
       
  1769 // CCmPluginWlan::CheckNetworkCoverageL()
       
  1770 // ----------------------------------------------------------------------------
       
  1771 //
       
  1772 TBool CCmPluginWlan::CheckNetworkCoverageL() const
       
  1773     {
       
  1774     OstTraceFunctionEntry0( CCMPLUGINWLAN_CHECKNETWORKCOVERAGEL_ENTRY );
       
  1775 
       
  1776 #ifdef __WINS__
       
  1777     OstTraceFunctionExit0( CCMPLUGINWLAN_CHECKNETWORKCOVERAGEL_EXIT );
       
  1778 
       
  1779     return ETrue;
       
  1780 #else
       
  1781     CCmWlanCoverageCheck* coverage = new (ELeave) CCmWlanCoverageCheck;
       
  1782     CleanupStack::PushL( coverage );
       
  1783 
       
  1784     TBool retVal( EFalse );
       
  1785     retVal = coverage->GetCoverageL();
       
  1786 
       
  1787     CleanupStack::PopAndDestroy( coverage );
       
  1788 
       
  1789     OstTraceFunctionExit0( DUP1_CCMPLUGINWLAN_CHECKNETWORKCOVERAGEL_EXIT );
       
  1790 
       
  1791     return retVal;
       
  1792 #endif  // __WINS
       
  1793     }
       
  1794 
       
  1795 // ---------------------------------------------------------------------------
       
  1796 // CCmPluginWlan::SetDaemonNameL
       
  1797 // ---------------------------------------------------------------------------
       
  1798 //
       
  1799 void CCmPluginWlan::SetDaemonNameL(
       
  1800         RPointerArray<CommsDat::CCDRecordBase>& aGenRecordArray,
       
  1801         RPointerArray<CommsDat::CCDRecordBase>& aBearerSpecRecordArray )
       
  1802     {
       
  1803     OstTraceFunctionEntry0( CCMPLUGINWLAN_SETDAEMONNAMEL_ENTRY );
       
  1804 
       
  1805     // we have to check first that these values has not been
       
  1806     // set(or changed) by any 3rd party sw to ensure that
       
  1807     // we don't break their settings
       
  1808     HBufC* daemonName = GetBearerStringAttributeL( ECmConfigDaemonManagerName,
       
  1809                                                    aGenRecordArray,
       
  1810                                                    aBearerSpecRecordArray );
       
  1811     if ( daemonName )
       
  1812         {
       
  1813         if ( daemonName->Compare( KDaemonManagerName ) != 0 )
       
  1814             {
       
  1815             delete daemonName;
       
  1816 
       
  1817             OstTraceFunctionExit0( CCMPLUGINWLAN_SETDAEMONNAMEL_EXIT );
       
  1818 
       
  1819             return;
       
  1820             }
       
  1821         delete daemonName;
       
  1822         }
       
  1823 
       
  1824     // use DHCP if we can
       
  1825     TBool ipfromSrv = GetBearerBoolAttributeL( ECmIPAddFromServer,
       
  1826                                                aGenRecordArray,
       
  1827                                                aBearerSpecRecordArray );
       
  1828     if ( ipfromSrv )
       
  1829         {
       
  1830         SetBearerStringAttributeL( ECmConfigDaemonManagerName,
       
  1831                                    KDaemonManagerName,
       
  1832                                    aGenRecordArray,
       
  1833                                    aBearerSpecRecordArray );
       
  1834 
       
  1835         SetBearerStringAttributeL( ECmConfigDaemonName,
       
  1836                                    KConfigDaemonName,
       
  1837                                    aGenRecordArray,
       
  1838                                    aBearerSpecRecordArray );
       
  1839 
       
  1840         }
       
  1841     else
       
  1842         {
       
  1843         if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
       
  1844             {
       
  1845             SetBearerStringAttributeL( ECmConfigDaemonManagerName,
       
  1846                                        KDaemonManagerName,
       
  1847                                        aGenRecordArray,
       
  1848                                        aBearerSpecRecordArray );
       
  1849 
       
  1850             SetBearerStringAttributeL( ECmConfigDaemonName,
       
  1851                                        KConfigDaemonName,
       
  1852                                        aGenRecordArray,
       
  1853                                        aBearerSpecRecordArray );
       
  1854             }
       
  1855         else
       
  1856             {
       
  1857             SetBearerStringAttributeL( ECmConfigDaemonManagerName,
       
  1858                                        KNullDesC(),
       
  1859                                        aGenRecordArray,
       
  1860                                        aBearerSpecRecordArray );
       
  1861 
       
  1862             SetBearerStringAttributeL( ECmConfigDaemonName,
       
  1863                                        KNullDesC(),
       
  1864                                        aGenRecordArray,
       
  1865                                        aBearerSpecRecordArray );
       
  1866             }
       
  1867         }
       
  1868 
       
  1869     OstTraceFunctionExit0( DUP1_CCMPLUGINWLAN_SETDAEMONNAMEL_EXIT );
       
  1870     }
       
  1871 
       
  1872 // ---------------------------------------------------------------------------
       
  1873 // CCmPluginWlan::ResetBearerRecords
       
  1874 // ---------------------------------------------------------------------------
       
  1875 //
       
  1876 void CCmPluginWlan::ResetBearerRecords()
       
  1877     {
       
  1878     OstTraceFunctionEntry0( CCMPLUGINWLAN_RESETBEARERRECORDS_ENTRY );
       
  1879 
       
  1880     delete iWlanServiceRecord;
       
  1881     iWlanServiceRecord = NULL;
       
  1882 
       
  1883     OstTraceFunctionExit0( CCMPLUGINWLAN_RESETBEARERRECORDS_EXIT );
       
  1884     }
       
  1885 
       
  1886 // ---------------------------------------------------------------------------
       
  1887 // CCmPluginWlan::CopyWlanServiceRecordL
       
  1888 // ---------------------------------------------------------------------------
       
  1889 //
       
  1890 void CCmPluginWlan::CopyWlanServiceRecordL(
       
  1891         CCDWlanServiceRecord* aSourceRecord,
       
  1892         CCDWlanServiceRecord* aDestRecord )
       
  1893     {
       
  1894     OstTraceFunctionEntry0( CCMPLUGINWLAN_COPYWLANSERVICERECORDL_ENTRY );
       
  1895 
       
  1896     if ( !( aSourceRecord && aDestRecord ) )
       
  1897         {
       
  1898         User::Leave( KErrArgument );
       
  1899         }
       
  1900 
       
  1901     if ( !aSourceRecord->iRecordTag.IsNull() )
       
  1902         {
       
  1903         aDestRecord->iRecordTag.SetL( aSourceRecord->iRecordTag );
       
  1904         }
       
  1905     if ( !aSourceRecord->iRecordName.IsNull() )
       
  1906         {
       
  1907         aDestRecord->iRecordName.SetL( aSourceRecord->iRecordName );
       
  1908         }
       
  1909 
       
  1910     if ( !aSourceRecord->iWlanServiceId.IsNull() )
       
  1911         {
       
  1912         aDestRecord->iWlanServiceId.SetL( aSourceRecord->iWlanServiceId );
       
  1913         }
       
  1914     if ( !aSourceRecord->iWlanConnMode.IsNull() )
       
  1915         {
       
  1916         aDestRecord->iWlanConnMode.SetL( aSourceRecord->iWlanConnMode );
       
  1917         }
       
  1918     if ( !aSourceRecord->iWLanSSID.IsNull() )
       
  1919         {
       
  1920         aDestRecord->iWLanSSID.SetL( aSourceRecord->iWLanSSID );
       
  1921         }
       
  1922     if ( !aSourceRecord->iWLanUsedSSID.IsNull() )
       
  1923         {
       
  1924         aDestRecord->iWLanUsedSSID.SetL( aSourceRecord->iWLanUsedSSID );
       
  1925         }
       
  1926     if ( !aSourceRecord->iWLanWepKey1.IsNull() )
       
  1927         {
       
  1928         aDestRecord->iWLanWepKey1.SetL( aSourceRecord->iWLanWepKey1 );
       
  1929         }
       
  1930     if ( !aSourceRecord->iWLanWepKey2.IsNull() )
       
  1931         {
       
  1932         aDestRecord->iWLanWepKey2.SetL( aSourceRecord->iWLanWepKey2 );
       
  1933         }
       
  1934     if ( !aSourceRecord->iWLanWepKey3.IsNull() )
       
  1935         {
       
  1936         aDestRecord->iWLanWepKey3.SetL( aSourceRecord->iWLanWepKey3 );
       
  1937         }
       
  1938     if ( !aSourceRecord->iWLanWepKey4.IsNull() )
       
  1939         {
       
  1940         aDestRecord->iWLanWepKey4.SetL( aSourceRecord->iWLanWepKey4 );
       
  1941         }
       
  1942     if ( !aSourceRecord->iWlanWepIndex.IsNull() )
       
  1943         {
       
  1944         aDestRecord->iWlanWepIndex.SetL( aSourceRecord->iWlanWepIndex );
       
  1945         }
       
  1946     if ( !aSourceRecord->iWlanSecMode.IsNull() )
       
  1947         {
       
  1948         aDestRecord->iWlanSecMode.SetL( aSourceRecord->iWlanSecMode );
       
  1949         }
       
  1950     if ( !aSourceRecord->iWlanAuthMode.IsNull() )
       
  1951         {
       
  1952         aDestRecord->iWlanAuthMode.SetL( aSourceRecord->iWlanAuthMode );
       
  1953         }
       
  1954     if ( !aSourceRecord->iWlanEnableWpaPsk.IsNull() )
       
  1955         {
       
  1956         aDestRecord->iWlanEnableWpaPsk.SetL( aSourceRecord->iWlanEnableWpaPsk );
       
  1957         }
       
  1958     if ( !aSourceRecord->iWLanWpaPreSharedKey.IsNull() )
       
  1959         {
       
  1960         aDestRecord->iWLanWpaPreSharedKey.SetL( aSourceRecord->iWLanWpaPreSharedKey );
       
  1961         }
       
  1962     if ( !aSourceRecord->iWlanWpaKeyLength.IsNull() )
       
  1963         {
       
  1964         aDestRecord->iWlanWpaKeyLength.SetL( aSourceRecord->iWlanWpaKeyLength );
       
  1965         }
       
  1966     if ( !aSourceRecord->iWLanEaps.IsNull() )
       
  1967         {
       
  1968         aDestRecord->iWLanEaps.SetL( aSourceRecord->iWLanEaps );
       
  1969         }
       
  1970     if ( !aSourceRecord->iWlanScanSSID.IsNull() )
       
  1971         {
       
  1972         aDestRecord->iWlanScanSSID.SetL( aSourceRecord->iWlanScanSSID );
       
  1973         }
       
  1974     if ( !aSourceRecord->iWlanChannelID.IsNull() )
       
  1975         {
       
  1976         aDestRecord->iWlanChannelID.SetL( aSourceRecord->iWlanChannelID );
       
  1977         }
       
  1978     if ( !aSourceRecord->iWlanFormatKey1.IsNull() )
       
  1979         {
       
  1980         aDestRecord->iWlanFormatKey1.SetL( aSourceRecord->iWlanFormatKey1 );
       
  1981         }
       
  1982     if ( !aSourceRecord->iWlanFormatKey2.IsNull() )
       
  1983         {
       
  1984         aDestRecord->iWlanFormatKey2.SetL( aSourceRecord->iWlanFormatKey2 );
       
  1985         }
       
  1986     if ( !aSourceRecord->iWlanFormatKey3.IsNull() )
       
  1987         {
       
  1988         aDestRecord->iWlanFormatKey3.SetL( aSourceRecord->iWlanFormatKey3 );
       
  1989         }
       
  1990     if ( !aSourceRecord->iWlanFormatKey4.IsNull() )
       
  1991         {
       
  1992         aDestRecord->iWlanFormatKey4.SetL( aSourceRecord->iWlanFormatKey4 );
       
  1993         }
       
  1994     if ( !aSourceRecord->iWlanAllowSSIDRoaming.IsNull() )
       
  1995         {
       
  1996         aDestRecord->iWlanAllowSSIDRoaming.SetL( aSourceRecord->iWlanAllowSSIDRoaming );
       
  1997         }
       
  1998     if ( !aSourceRecord->iWLanEnabledEaps.IsNull() )
       
  1999         {
       
  2000         aDestRecord->iWLanEnabledEaps.SetL( aSourceRecord->iWLanEnabledEaps );
       
  2001         }
       
  2002     if ( !aSourceRecord->iWLanDisabledEaps.IsNull() )
       
  2003         {
       
  2004         aDestRecord->iWLanDisabledEaps.SetL( aSourceRecord->iWLanDisabledEaps );
       
  2005         }
       
  2006 
       
  2007     OstTraceFunctionExit0( CCMPLUGINWLAN_COPYWLANSERVICERECORDL_EXIT );
       
  2008     }
       
  2009 
       
  2010 // ---------------------------------------------------------------------------
       
  2011 // CCmPluginWlan::GetDefaultWlanServiceRecordL
       
  2012 // ---------------------------------------------------------------------------
       
  2013 //
       
  2014 void CCmPluginWlan::GetDefaultWlanServiceRecordL(
       
  2015         RPointerArray<CommsDat::CCDRecordBase>& aRecordArray )
       
  2016     {
       
  2017     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETDEFAULTWLANSERVICERECORDL_ENTRY );
       
  2018 
       
  2019     CCDWlanServiceRecord* wlanServiceRecord = new( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
       
  2020     CleanupStack::PushL( wlanServiceRecord );
       
  2021 
       
  2022     wlanServiceRecord->SetRecordId( KCDNewRecordRequest );
       
  2023 
       
  2024     wlanServiceRecord->iRecordTag.SetL( 1 );
       
  2025     wlanServiceRecord->iRecordName.SetL( iIapRecord->iRecordName );
       
  2026     wlanServiceRecord->iWlanConnMode.SetL( CMManager::EInfra );
       
  2027     wlanServiceRecord->iWlanSecMode.SetL( CMManager::EWlanSecModeOpen );
       
  2028     wlanServiceRecord->iWlanScanSSID.SetL( EFalse );
       
  2029 
       
  2030     aRecordArray.AppendL( wlanServiceRecord );
       
  2031 
       
  2032     CleanupStack::Pop( wlanServiceRecord );
       
  2033 
       
  2034     OstTraceFunctionExit0( CCMPLUGINWLAN_GETDEFAULTWLANSERVICERECORDL_EXIT );
       
  2035     }
       
  2036 
       
  2037 // ---------------------------------------------------------------------------
       
  2038 // CCmPluginWlan::GetBearerInfoIntL
       
  2039 // ---------------------------------------------------------------------------
       
  2040 //
       
  2041 TUint32 CCmPluginWlan::GetBearerInfoIntL( TUint32 aAttribute ) const
       
  2042     {
       
  2043     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERINFOINTL_ENTRY );
       
  2044 
       
  2045     TUint32 retVal( 0 );
       
  2046     switch ( aAttribute )
       
  2047         {
       
  2048         case ECmBearerType:
       
  2049             {
       
  2050             retVal = iBearerType;
       
  2051             }
       
  2052             break;
       
  2053         case ECmCommsDBBearerType:
       
  2054             {
       
  2055             retVal = KCommDbBearerWLAN;
       
  2056             }
       
  2057             break;
       
  2058         case ECmDefaultUiPriority:
       
  2059             {
       
  2060             retVal = GetDefPriorityL( aAttribute );
       
  2061             }
       
  2062             break;
       
  2063         case ECmDefaultPriority:
       
  2064             {
       
  2065             retVal = GetDefPriorityL( aAttribute );
       
  2066             }
       
  2067             break;
       
  2068         case ECmExtensionLevel:
       
  2069             {
       
  2070             // This is extension from LAN plugin.
       
  2071             retVal = KExtensionBaseLevel + 1;
       
  2072             }
       
  2073             break;
       
  2074         case ECmSeamlessnessLevel:
       
  2075             {
       
  2076             retVal = ESeamlessnessShowprogress;
       
  2077             }
       
  2078             break;
       
  2079         default:
       
  2080             {
       
  2081             User::Leave( KErrNotSupported );
       
  2082             }
       
  2083             break;
       
  2084         }
       
  2085 
       
  2086     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERINFOINTL_EXIT );
       
  2087     return retVal;
       
  2088     }
       
  2089 
       
  2090 // ---------------------------------------------------------------------------
       
  2091 // CCmPluginWlan::GetBearerInfoBoolL
       
  2092 // ---------------------------------------------------------------------------
       
  2093 //
       
  2094 TBool CCmPluginWlan::GetBearerInfoBoolL( TUint32 aAttribute ) const
       
  2095     {
       
  2096     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERINFOBOOLL_ENTRY );
       
  2097 
       
  2098     TBool retVal( EFalse );
       
  2099 
       
  2100     switch ( aAttribute )
       
  2101         {
       
  2102         case ECmCoverage:
       
  2103             {
       
  2104 #ifndef __WINS__
       
  2105             retVal = CheckNetworkCoverageL();
       
  2106 #else
       
  2107             retVal = ETrue;
       
  2108 #endif
       
  2109             }
       
  2110             break;
       
  2111         case ECmDestination:
       
  2112             {
       
  2113             retVal = EFalse;
       
  2114             }
       
  2115             break;
       
  2116         case ECmBearerHasUi:
       
  2117             {
       
  2118             retVal = EFalse;
       
  2119             }
       
  2120             break;
       
  2121         case ECmIPv6Supported:
       
  2122             {
       
  2123             retVal = FeatureManager::FeatureSupported( KFeatureIdIPv6 );
       
  2124             }
       
  2125             break;
       
  2126         case ECmVirtual:
       
  2127             {
       
  2128             retVal = EFalse;
       
  2129             }
       
  2130             break;
       
  2131         default:
       
  2132             {
       
  2133             User::Leave( KErrNotSupported );
       
  2134             }
       
  2135             break;
       
  2136         }
       
  2137 
       
  2138     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERINFOBOOLL_EXIT );
       
  2139     return retVal;
       
  2140     }
       
  2141 
       
  2142 // ---------------------------------------------------------------------------
       
  2143 // CCmPluginWlan::GetBearerInfoStringL
       
  2144 // ---------------------------------------------------------------------------
       
  2145 //
       
  2146 HBufC* CCmPluginWlan::GetBearerInfoStringL( TUint32 aAttribute ) const
       
  2147     {
       
  2148     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERINFOSTRINGL_ENTRY );
       
  2149 
       
  2150     HBufC* retVal( NULL );
       
  2151     switch ( aAttribute )
       
  2152         {
       
  2153         default:
       
  2154             {
       
  2155             User::Leave( KErrNotSupported );
       
  2156             }
       
  2157         break;
       
  2158         }
       
  2159 
       
  2160     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERINFOSTRINGL_EXIT );
       
  2161     return retVal;
       
  2162     }
       
  2163 
       
  2164 // ---------------------------------------------------------------------------
       
  2165 // CCmPluginWlan::GetBearerInfoString8L
       
  2166 // ---------------------------------------------------------------------------
       
  2167 //
       
  2168 HBufC8* CCmPluginWlan::GetBearerInfoString8L( TUint32 aAttribute ) const
       
  2169     {
       
  2170     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERINFOSTRING8L_ENTRY );
       
  2171 
       
  2172     HBufC8* retVal( NULL );
       
  2173     switch ( aAttribute )
       
  2174         {
       
  2175         default:
       
  2176             {
       
  2177             User::Leave( KErrNotSupported );
       
  2178             }
       
  2179         break;
       
  2180         }
       
  2181 
       
  2182     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERINFOSTRING8L_EXIT );
       
  2183     return retVal;
       
  2184     }
       
  2185 
       
  2186 // ---------------------------------------------------------------------------
       
  2187 // CCmPluginWlan::CheckSecurityAttributeValidityL
       
  2188 // ---------------------------------------------------------------------------
       
  2189 //
       
  2190 void CCmPluginWlan::CheckSecurityAttributeValidityL(
       
  2191         const TUint32 aAttribute,
       
  2192         const TUint32 aValue )
       
  2193     {
       
  2194     OstTraceFunctionEntry0( CCMPLUGINWLAN_CHECKSECURITYATTRIBUTEVALIDITYL_ENTRY );
       
  2195 
       
  2196     switch ( aAttribute )
       
  2197         {
       
  2198         case CMManager::EWlanConnectionMode:
       
  2199             {
       
  2200             switch ( aValue )
       
  2201                 {
       
  2202                 case CMManager::EAdhoc:
       
  2203                 case CMManager::EInfra:
       
  2204                     break;
       
  2205                 default:
       
  2206                     User::Leave( KErrArgument );
       
  2207                     break;
       
  2208                 }
       
  2209             }
       
  2210             break;
       
  2211 
       
  2212         case CMManager::EWlanSecurityMode:
       
  2213             {
       
  2214             switch ( aValue )
       
  2215                 {
       
  2216                 case CMManager::EWlanSecModeOpen:
       
  2217                 case CMManager::EWlanSecModeWep:
       
  2218                 case CMManager::EWlanSecMode802_1x:
       
  2219                 case CMManager::EWlanSecModeWpa:
       
  2220                 case CMManager::EWlanSecModeWpa2:
       
  2221                 case CMManager::EWlanSecModeWAPI:
       
  2222                     break;
       
  2223                 default:
       
  2224                     User::Leave( KErrArgument );
       
  2225                     break;
       
  2226                 }
       
  2227             }
       
  2228             break;
       
  2229 
       
  2230         case CMManager::EWlanAuthenticationMode:
       
  2231             {
       
  2232             switch ( aValue )
       
  2233                 {
       
  2234                 case CMManager::EWlanAuthModeOpen:
       
  2235                 case CMManager::EWlanAuthModeShared:
       
  2236                     break;
       
  2237                 default:
       
  2238                     User::Leave( KErrArgument );
       
  2239                     break;
       
  2240                 }
       
  2241             }
       
  2242             break;
       
  2243 
       
  2244         case CMManager::EWlanEnableWpaPsk:     // Boolean
       
  2245         case CMManager::EWlanWpaPreSharedKey:  // Valid values: 0, 1, 8-64
       
  2246             break;
       
  2247 
       
  2248         case CMManager::EWlanWepKey1InHex:     // Length should be 10 or 26.
       
  2249         case CMManager::EWlanWepKey2InHex:
       
  2250         case CMManager::EWlanWepKey3InHex:
       
  2251         case CMManager::EWlanWepKey4InHex:
       
  2252         case CMManager::EWlanWepKey1InAscii:   // Length should be 5 or 13.
       
  2253         case CMManager::EWlanWepKey2InAscii:
       
  2254         case CMManager::EWlanWepKey3InAscii:
       
  2255         case CMManager::EWlanWepKey4InAscii:
       
  2256             break;
       
  2257 
       
  2258         case CMManager::EWlanWepKeyIndex:
       
  2259             {
       
  2260             switch ( aValue )
       
  2261                 {
       
  2262                 case CMManager::EWepKeyIndex1:
       
  2263                 case CMManager::EWepKeyIndex2:
       
  2264                 case CMManager::EWepKeyIndex3:
       
  2265                 case CMManager::EWepKeyIndex4:
       
  2266                     break;
       
  2267                 default:
       
  2268                     User::Leave( KErrArgument );
       
  2269                     break;
       
  2270                 }
       
  2271             }
       
  2272             break;
       
  2273 
       
  2274         case CMManager::EWlanWapiPsk:
       
  2275             break;
       
  2276 
       
  2277         case CMManager::EWlanWapiPskFormat:
       
  2278             {
       
  2279             switch ( aValue )
       
  2280                 {
       
  2281                 case CMManager::EWlanWapiPskFormatAscii:
       
  2282                 case CMManager::EWlanWapiPskFormatHex:
       
  2283                     break;
       
  2284                 default:
       
  2285                     User::Leave( KErrArgument );
       
  2286                     break;
       
  2287                 }
       
  2288             }
       
  2289             break;
       
  2290 
       
  2291         case CMManager::EWlan802_1xAllowUnencrypted:   // Boolean
       
  2292             break;
       
  2293 
       
  2294         default:
       
  2295             User::Leave( KErrArgument );
       
  2296             break;
       
  2297         }
       
  2298 
       
  2299     OstTraceFunctionExit0( CCMPLUGINWLAN_CHECKSECURITYATTRIBUTEVALIDITYL_EXIT );
       
  2300     }
       
  2301 
       
  2302 // ---------------------------------------------------------------------------
       
  2303 // CCmPluginWlan::CopyBearerRecordsL
       
  2304 // ---------------------------------------------------------------------------
       
  2305 //
       
  2306 void CCmPluginWlan::CopyBearerRecordsL( CCmPluginBaseEng* aCopyInstance )
       
  2307     {
       
  2308     OstTraceFunctionEntry0( CCMPLUGINWLAN_COPYBEARERRECORDSL_ENTRY );
       
  2309 
       
  2310     CCmPluginWlan* plugin = static_cast<CCmPluginWlan*>( aCopyInstance );
       
  2311     plugin->iWlanServiceRecord = new( ELeave ) CCDWlanServiceRecord( iWlanTableId );
       
  2312 
       
  2313     CopyWlanServiceRecordL( iWlanServiceRecord, plugin->iWlanServiceRecord );
       
  2314     plugin->iWlanServiceRecord->iWlanServiceId.SetL( 0 );
       
  2315     plugin->iWAPISupported = iWAPISupported;
       
  2316 
       
  2317     OstTraceFunctionExit0( CCMPLUGINWLAN_COPYBEARERRECORDSL_EXIT );
       
  2318     }
       
  2319 
       
  2320 // ---------------------------------------------------------------------------
       
  2321 // CCmPluginWlan::PrepareToCopyDataL
       
  2322 // ---------------------------------------------------------------------------
       
  2323 //
       
  2324 void CCmPluginWlan::PrepareToCopyDataL( CCmPluginBaseEng* /*aCopyInstance*/ )
       
  2325     {
       
  2326     OstTraceFunctionEntry0( CCMPLUGINWLAN_PREPARETOCOPYDATAL_ENTRY );
       
  2327 
       
  2328     OstTraceFunctionExit0( CCMPLUGINWLAN_PREPARETOCOPYDATAL_EXIT );
       
  2329     }
       
  2330 
       
  2331 // ---------------------------------------------------------------------------
       
  2332 // CCmPluginWlan::GetBearerTableIdsToBeObserved
       
  2333 // ---------------------------------------------------------------------------
       
  2334 //
       
  2335 void CCmPluginWlan::GetBearerTableIdsToBeObservedL(
       
  2336         RArray<TUint32>& aTableIdArray ) const
       
  2337     {
       
  2338     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETBEARERTABLEIDSTOBEOBSERVEDL_ENTRY );
       
  2339 
       
  2340     aTableIdArray.AppendL( KCDTIdLANServiceRecord );
       
  2341     aTableIdArray.AppendL( iWlanTableId );
       
  2342 
       
  2343     OstTraceFunctionExit0( CCMPLUGINWLAN_GETBEARERTABLEIDSTOBEOBSERVEDL_EXIT );
       
  2344     }
       
  2345 
       
  2346 // ---------------------------------------------------------------------------
       
  2347 // CCmPluginWlan::ConvertAsciiToHexL
       
  2348 // ---------------------------------------------------------------------------
       
  2349 //
       
  2350 HBufC8* CCmPluginWlan::ConvertAsciiToHexL( const TDesC8& aSource )
       
  2351     {
       
  2352     // Characters used in hex-format.
       
  2353     _LIT( hex, "0123456789ABCDEF" );
       
  2354 
       
  2355     // Length of ascii-format source string.
       
  2356     TInt length = aSource.Length();
       
  2357     //TInt length = aSource.Size();
       
  2358 
       
  2359     if ( length <= 0 )
       
  2360         {
       
  2361         HBufC8* result = KNullDesC8().AllocL();
       
  2362         return result;
       
  2363         }
       
  2364 
       
  2365     HBufC8* result = HBufC8::NewLC( length * 2 );
       
  2366     TPtr8 ptr = result->Des();
       
  2367 
       
  2368     // Iterate for each character in ascii-format source string.
       
  2369     for ( TInt i = 0; i < length; i++ )
       
  2370         {
       
  2371         // Next character in ascii-format source string to be converted.
       
  2372         TText8 ch = aSource[i];
       
  2373 
       
  2374         // Convert and append the higher 4 bits of the character.
       
  2375         ptr.Append( hex()[ ( ch / 16 ) & 0x0f ] );
       
  2376 
       
  2377         // Convert and append the lower 4 bits of the character.
       
  2378         ptr.Append( hex()[ ch & 0x0f ] );
       
  2379         }
       
  2380 
       
  2381     CleanupStack::Pop( result );
       
  2382     return result; // Ownership is transfered.
       
  2383     }
       
  2384 
       
  2385 // ---------------------------------------------------------------------------
       
  2386 // CCmPluginWlan::ConvertHexToAsciiL
       
  2387 // ---------------------------------------------------------------------------
       
  2388 //
       
  2389 HBufC8* CCmPluginWlan::ConvertHexToAsciiL( const TDesC8& aSource )
       
  2390     {
       
  2391     // Length of hex-format source string.
       
  2392     TInt length = aSource.Length();
       
  2393 
       
  2394     if ( length <= 0 )
       
  2395         {
       
  2396         HBufC8* result = KNullDesC8().AllocL();
       
  2397         return result;
       
  2398         }
       
  2399 
       
  2400     HBufC8* result = HBufC8::NewLC( ( length + 1 ) / 2 );
       
  2401     TPtr8 ptr = result->Des();
       
  2402 
       
  2403     TInt i( 0 );
       
  2404     TUint8 ch( 0 );
       
  2405     if ( length % 2 )
       
  2406         {
       
  2407         ch = ConvertHexCharToNumberL( aSource[i] );
       
  2408         ptr.Append( ch );
       
  2409         i++;
       
  2410         }
       
  2411     for ( ; i < length; )
       
  2412         {
       
  2413         ch = ConvertHexCharToNumberL( aSource[i] ) << 4;
       
  2414         i++;
       
  2415         ch += ConvertHexCharToNumberL( aSource[i] );
       
  2416         i++;
       
  2417         ptr.Append( ch );
       
  2418         }
       
  2419 
       
  2420     CleanupStack::Pop( result );
       
  2421     return result; // Ownership is transfered.
       
  2422     }
       
  2423 
       
  2424 // ---------------------------------------------------------------------------
       
  2425 // CCmPluginWlan::ConvertHexCharToNumberL
       
  2426 // ---------------------------------------------------------------------------
       
  2427 //
       
  2428 TUint8 CCmPluginWlan::ConvertHexCharToNumberL( const TUint8 aHexChar )
       
  2429     {
       
  2430     TUint8 result( 0 );
       
  2431     if ( '0' <= aHexChar && aHexChar <= '9' )
       
  2432         {
       
  2433         result = aHexChar - '0';
       
  2434         }
       
  2435     else if ( 'a' <= aHexChar && aHexChar <= 'f' )
       
  2436         {
       
  2437         result = aHexChar - 'a' + 10u;
       
  2438         }
       
  2439     else if ( 'A' <= aHexChar && aHexChar <= 'F' )
       
  2440         {
       
  2441         result = aHexChar - 'A' + 10u;
       
  2442         }
       
  2443     else
       
  2444         {
       
  2445         User::Leave( KErrArgument );
       
  2446         }
       
  2447     return result;
       
  2448     }
       
  2449 
       
  2450 // ---------------------------------------------------------------------------
       
  2451 // CCmPluginWlan::GetDefPriorityL
       
  2452 // ---------------------------------------------------------------------------
       
  2453 //
       
  2454 TUint32 CCmPluginWlan::GetDefPriorityL( const TUint32 aAttribute ) const
       
  2455     {
       
  2456     OstTraceFunctionEntry0( CCMPLUGINWLAN_GETDEFPRIORITYL_ENTRY );
       
  2457 
       
  2458     TUint32 retVal( KDataMobilitySelectionPolicyPriorityWildCard );
       
  2459 
       
  2460     CCDGlobalBearerTypePriorizationRecord* priorityRecord =
       
  2461             new( ELeave ) CCDGlobalBearerTypePriorizationRecord( iBearerPriorityTableId );
       
  2462     CleanupStack::PushL( priorityRecord );
       
  2463 
       
  2464     priorityRecord->iServiceType.SetL( TPtrC( KCDTypeNameLANService ) );
       
  2465 
       
  2466     if ( priorityRecord->FindL( iSession ) )
       
  2467         {
       
  2468         priorityRecord->LoadL( iSession );
       
  2469         switch ( aAttribute )
       
  2470             {
       
  2471             case ECmDefaultPriority:
       
  2472                 {
       
  2473                 retVal = priorityRecord->iPriority;
       
  2474                 }
       
  2475                 break;
       
  2476             case ECmDefaultUiPriority:
       
  2477                 {
       
  2478                 retVal = priorityRecord->iUIPriority;
       
  2479                 }
       
  2480                 break;
       
  2481             default:
       
  2482                 break;
       
  2483             }
       
  2484         }
       
  2485     CleanupStack::PopAndDestroy( priorityRecord );
       
  2486 
       
  2487     OstTraceFunctionExit0( CCMPLUGINWLAN_GETDEFPRIORITYL_EXIT );
       
  2488     return retVal;
       
  2489     }
       
  2490 
       
  2491 // End of File