cmmanager/cmmgr/Plugins/cmpluginwlan/src/cmpluginwlan.cpp
changeset 20 9c97ad6591ae
parent 18 fcbbe021d614
child 21 b8e8e15e80f2
child 23 7ec726f93df1
child 28 860702281757
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of WLAN Plugin interface implementation 
       
    15 *                for WLAN Bearer
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <commdb.h>
       
    21 #include <ecom/ecom.h>		// For REComSession
       
    22 #include <f32file.h>    // for TParse
       
    23 #include <StringLoader.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <ConnectionUiUtilities.h>
       
    26 
       
    27 #include <cmpluginbaseeng.h>
       
    28 #include <cmpluginlanbase.h>
       
    29 #include <mcmdexec.h>
       
    30 #include <cmpbasesettingsdlg.h>
       
    31 #include <cmpluginwlan.mbg>
       
    32 #include <cmwlanui.rsg>
       
    33 #include <cmmanager.rsg>
       
    34 #include <cmcommonui.h>
       
    35 #include <wlancontainer.h>
       
    36 
       
    37 #include <WEPSecuritySettingsUI.h>
       
    38 #include <WPASecuritySettingsUI.h>
       
    39 #include <featmgr.h>
       
    40 #include <ConeResLoader.h>
       
    41 #include <AknWaitDialog.h>
       
    42 #include <uikon/eiksrvui.h>
       
    43 #include <AknGlobalNote.h>
       
    44 
       
    45 #include "cmwlancommonconstants.h"
       
    46 #include "cmpluginwlan.h"
       
    47 #include "cmwlancoveragecheck.h"
       
    48 #include "cmlogger.h"
       
    49 #include "cmpwlansettingsdlg.h"
       
    50 #include <cmpluginwlandef.h>
       
    51 #include <cmcommonconstants.h>
       
    52 #include "cmmanagerimpl.h"
       
    53 #include "cmpwlanactivewaiter.h"
       
    54 
       
    55 #include <wifiprotuiinprocess.h>
       
    56 
       
    57 using namespace CMManager;
       
    58 
       
    59 #include "wapisecuritysettingsui.h"
       
    60 
       
    61 // CONSTANTS
       
    62 const TUint32 KDefaultPriorityWLan = 0;
       
    63 
       
    64 const TInt KWlanSingleNetwork = 1; // Number of WLAN networks is 1
       
    65 const TInt KWlanMaxKeyLength = 64;
       
    66 const TInt KWlanLastSocketActivityTimeout = -1;
       
    67 const TInt KWlanLastSessionClosedTimeout = 1;
       
    68 const TInt KWlanLastSocketClosedTimeout = -1;
       
    69 const TUint32 KEndOfArray = KMaxTUint;
       
    70 
       
    71 // Daemon manager name for Easy WLAN IAP
       
    72 _LIT( KHotspotDaemonManagerName, "NetCfgExtnHotSpot" );
       
    73 _LIT( KEasyWlanName, "Easy WLAN" );
       
    74 
       
    75 // Modem bearer names for WLAN connection methods
       
    76 _LIT( KModemBearerWLAN, "WLANBearer" );
       
    77 
       
    78 _LIT( KWlanFileIcons, "z:cmpluginwlan.mbm" );
       
    79 _LIT( KWlanBearerName, "WLANBearer" );
       
    80 _LIT( KWlanBearerAgent, "wlanagt.agt" );
       
    81 _LIT( KWlanBearerNif, "wlannif" );
       
    82 
       
    83 _LIT( KWlanLDDName, "not used" );
       
    84 _LIT( KWlanPDDName, "not used" );
       
    85 
       
    86 static const TCmAttribConvTable SWlanConvTbl[] = 
       
    87     {
       
    88     // iAttribId, iCommsDatId, iValidFuncL, 
       
    89     // iTitleId, 
       
    90     // iMaxLength, iAttribFlags, iDefValueResId, iEditorResId, iNotUsed1, iNotUsed2
       
    91     { EWlanServiceId,           EWlanRangeMax,          NULL },        
       
    92     { EWlanServiceId,           KCDTIdWlanServiceId,    NULL },
       
    93     { EWlanConnectionMode,      KCDTIdWlanConnMode,     NULL,
       
    94       R_QTN_WLAN_SETT_NETWORK_MODE,
       
    95        },
       
    96     { EWlanSSID,                KCDTIdWlanSSID,         NULL,
       
    97       R_QTN_WLAN_SETT_NETWORK_NAME,
       
    98       KCmWlanNWNameMaxLength, EConvCompulsory | EConvNoZeroLength, R_QTN_SELEC_SETTING_COMPULSORY, R_TEXT_SETTING_PAGE_NETW_NAME, NULL, NULL },
       
    99     { EWlanUsedSSID,            KCDTIdWlanUsedSSID,     NULL },
       
   100     { EWlanSecurityMode,        KCDTIdWlanSecMode,      NULL,
       
   101       R_QTN_WLAN_SETT_SECURITY_MODE,
       
   102       0, 0, 0, 0, NULL, NULL },
       
   103     { EWlanAuthenticationMode,  KCDTIdWlanAuthMode,     NULL },
       
   104     { EWlanScanSSID,            KCDTIdWlanScanSSID,     NULL,
       
   105       R_QTN_WLAN_SETT_HIDDEN_NETWORK,
       
   106       0, 0, 0, 0, NULL, NULL },
       
   107     { EWlanChannelID,           KCDTIdWlanChannelID,    NULL,
       
   108       R_QTN_WLAN_SETT_ADHOC_CHANNEL,
       
   109       KCmAdhocChannelMaxLength, EConvNumber, R_QTN_WLAN_SETT_ADHOC_CHANNEL_AUTOMATIC, 0, NULL, NULL },   
       
   110     { EWlanAllowSSIDRoaming,  KCDTIdWlanAllowSSIDRoaming,     NULL, 
       
   111       R_QTN_WLAN_SETT_SSID_ROAMING,
       
   112       0, 0, 0, 0, NULL, NULL },
       
   113     { 0,0 }
       
   114     };
       
   115 
       
   116 
       
   117 static const TCmCommonAttrConvArrayItem SCommonConvTbl[] =
       
   118 {
       
   119     { EWlanIfNetworks, ECmIFNetworks },
       
   120     { EWlanIpNetMask, ECmIPNetmask },
       
   121     { EWlanIpGateway, ECmIPGateway },
       
   122     { EWlanIpAddrFromServer, ECmIPAddFromServer },
       
   123     { EWlanIpAddr, ECmIPAddress },
       
   124     { EWlanIpDNSAddrFromServer, ECmIPDNSAddrFromServer },
       
   125     { EWlanIpNameServer1, ECmIPNameServer1 },
       
   126     { EWlanIpNameServer2, ECmIPNameServer2 },
       
   127     { EWlanIp6DNSAddrFromServer, ECmIP6DNSAddrFromServer },
       
   128     { EWlanIp6NameServer1, ECmIP6NameServer1 },
       
   129     { EWlanIp6NameServer2, ECmIP6NameServer2 },
       
   130     { EWlanIpAddrLeaseValidFrom, ECmIPAddrLeaseValidFrom },
       
   131     { EWlanIpAddrLeaseValidTo, ECmIPAddrLeaseValidTo },
       
   132     { EWlanConfigDaemonManagerName, ECmConfigDaemonManagerName },
       
   133     { EWlanConfigDaemonName, ECmConfigDaemonName },
       
   134     { 0, 0 }
       
   135     };
       
   136 
       
   137 
       
   138 /**
       
   139  * struct for security mode conversion table
       
   140  */
       
   141 typedef struct
       
   142     {
       
   143     TUint32 iSecurityMode;
       
   144     TUint32 iNWModeSelectionDlgIndex;
       
   145     TUint32 iRBSettingPageIndex;
       
   146     TUint32 iResId;
       
   147     } TCmSecurityModeConvTable;
       
   148 
       
   149 /**
       
   150  * Conversion table for the correct positioning of WLAN security types 
       
   151  * in WLAN UI components
       
   152  */  
       
   153 const TCmSecurityModeConvTable KWlanSecurityModeConvTable[] =
       
   154     {                              
       
   155         { EWlanSecModeOpen,   0, 0, R_QTN_NETW_CONSET_WLAN_SECURITY_MODE_OPEN   },
       
   156         { EWlanSecModeWep,    1, 1, R_QTN_NETW_CONSET_WLAN_SECURITY_MODE_WEP    },
       
   157         { EWlanSecMode802_1x, 2, 2, R_QTN_NETW_CONSET_WLAN_SECURITY_MODE_802_1X },
       
   158         { EWlanSecModeWpa,    3, 3, R_QTN_NETW_CONSET_WLAN_SECURITY_MODE_WPA    },
       
   159      // { EWlanSecModeWpa2,   3, 3, R_QTN_NETW_CONSET_WLAN_SECURITY_MODE_WPA2   },
       
   160         { EWlanSecModeWAPI,   4, 4, R_QTN_WLAN_SETT_SECURITY_MODE_WAPI   },
       
   161         { KEndOfArray, KEndOfArray, KEndOfArray, KEndOfArray }
       
   162     };
       
   163 
       
   164 /**
       
   165  * struct for the network mode conversion table
       
   166  */
       
   167 typedef struct
       
   168     {
       
   169     TUint32 iNwMode;
       
   170     TBool   iHidden;
       
   171     TUint32 iResId;
       
   172     } TCmNetworkModeConvTable;
       
   173 
       
   174 /**
       
   175  * Conversion table for the correct positioning of WLAN network modes
       
   176  */
       
   177 const TCmNetworkModeConvTable KWlanNetworkModeConvTable[] =
       
   178     {
       
   179         { EInfra, EFalse, R_QTN_WLAN_NETWORK_MODE_INFRA_PUBLIC }, // Infrastructure (public)
       
   180         { EInfra, ETrue,  R_QTN_WLAN_NETWORK_MODE_INFRA_HIDDEN }, // Infrastructure (hidden)
       
   181         { EAdhoc, EFalse, R_QTN_WLAN_NETWORK_MODE_ADHOC_PUBLIC }, // Ad-hoc (public)
       
   182 //        { EAdhoc, ETrue,  R_QTN_WLAN_NETWORK_MODE_ADHOC_HIDDEN }, // Ad-hoc (hidden)
       
   183         { KEndOfArray, EFalse, KEndOfArray }
       
   184     };
       
   185 
       
   186 // ======================= MEMBER FUNCTIONS =================================
       
   187 
       
   188 // --------------------------------------------------------------------------
       
   189 // CCmPluginWlan::NewL
       
   190 // --------------------------------------------------------------------------
       
   191 //
       
   192 CCmPluginWlan* CCmPluginWlan::NewL( TCmPluginInitParam* aInitParam )
       
   193     {
       
   194     if ( !FeatureSupported( KFeatureIdProtocolWlan ) )
       
   195         {
       
   196         User::Leave( KErrNotSupported );
       
   197         }
       
   198         
       
   199     CCmPluginWlan* self = new( ELeave ) CCmPluginWlan( aInitParam );
       
   200     CleanupStack::PushL( self );
       
   201     self->ConstructL();
       
   202     CleanupStack::Pop( self );
       
   203     return self;
       
   204     }
       
   205 
       
   206 // --------------------------------------------------------------------------
       
   207 // CCmPluginWlan::~CCmPluginWlan
       
   208 // --------------------------------------------------------------------------
       
   209 //
       
   210 CCmPluginWlan::~CCmPluginWlan()
       
   211     {
       
   212     AdditionalReset();
       
   213     DestroyWaitDialog();
       
   214     RemoveResourceFile( KPluginWlanResDirAndFileName );    
       
   215     delete iConnUiUtils; iConnUiUtils = NULL;
       
   216     
       
   217     iAdditionalCmsCreated.Close();
       
   218 
       
   219     CLOG_CLOSE;
       
   220     }
       
   221 
       
   222 // --------------------------------------------------------------------------
       
   223 // CCmPluginWlan::CreateInstanceL
       
   224 // --------------------------------------------------------------------------
       
   225 //
       
   226 CCmPluginBaseEng* CCmPluginWlan::CreateInstanceL( TCmPluginInitParam& aInitParam ) const
       
   227     {
       
   228     CCmPluginWlan* self = new( ELeave ) CCmPluginWlan( &aInitParam );
       
   229     CleanupStack::PushL( self );
       
   230     self->ConstructL();
       
   231     CleanupStack::Pop( self );
       
   232 
       
   233     return self;
       
   234     }
       
   235     
       
   236 // --------------------------------------------------------------------------
       
   237 // CCmPluginWlan::CCmPluginWlan
       
   238 // --------------------------------------------------------------------------
       
   239 //
       
   240 CCmPluginWlan::CCmPluginWlan( TCmPluginInitParam* aInitParam )
       
   241     : CCmPluginLanBase( aInitParam )
       
   242     {
       
   243     CLOG_CREATE;
       
   244     iWlanTableId = 0;
       
   245     iBearerType = KUidWlanBearerType;
       
   246     }
       
   247 
       
   248 // --------------------------------------------------------------------------
       
   249 // CCmPluginWlan::ConstructL
       
   250 // --------------------------------------------------------------------------
       
   251 //
       
   252 void CCmPluginWlan::ConstructL()
       
   253     {
       
   254     LOGGER_ENTERFN( "CCmPluginWlan::ConstructL" );
       
   255     
       
   256     CCmPluginLanBase::ConstructL();
       
   257 
       
   258     iBearerRecName = KModemBearerWLAN;
       
   259     
       
   260     // get WLAN table id
       
   261     TRAP_IGNORE( iWlanTableId = CCDWlanServiceRecord::TableIdL( Session() ) );
       
   262 
       
   263     if( !iWlanTableId )
       
   264         {
       
   265         iWlanTableId = CCDWlanServiceRecord::CreateTableL( Session() );
       
   266 
       
   267         TMDBElementId tableId = 0;
       
   268 
       
   269         TRAP_IGNORE( tableId = CCDWlanDeviceSettingsRecord::TableIdL( Session() ) );
       
   270         if( !tableId )
       
   271             {
       
   272             CCDWlanDeviceSettingsRecord::CreateTableL( Session() );
       
   273             }
       
   274         
       
   275         TRAP_IGNORE( tableId = CCDWLANSecSSIDTable::TableIdL( Session() ) );
       
   276         if( !tableId )
       
   277             {
       
   278             CCDWLANSecSSIDTable::CreateTableL( Session() );
       
   279             }
       
   280 
       
   281         TRAP_IGNORE( tableId = CCDDestNWTable::TableIdL( Session() ) );
       
   282         if( !tableId )
       
   283             {
       
   284             CCDDestNWTable::CreateTableL( Session() );
       
   285             }
       
   286         }
       
   287 
       
   288     AddResourceFileL( KPluginWlanResDirAndFileName );
       
   289     
       
   290     AddConverstionTableL( ( CCDRecordBase** )&iWlanServiceRecord, 
       
   291                             NULL, 
       
   292                             SWlanConvTbl );
       
   293     AddCommonConversionTableL( SCommonConvTbl );
       
   294     
       
   295     iIsWAPISupported = FeatureManager::FeatureSupported( KFeatureIdFfWlanWapi );
       
   296     }
       
   297     
       
   298 	
       
   299 // --------------------------------------------------------------------------
       
   300 // CCmPluginWlan::GetIntAttributeL
       
   301 // --------------------------------------------------------------------------
       
   302 //
       
   303 TUint32 CCmPluginWlan::GetIntAttributeL( const TUint32 aAttribute ) const
       
   304     {
       
   305     LOGGER_ENTERFN( "CCmPluginWlan::GetIntAttributeL" );
       
   306     
       
   307     TInt retval;
       
   308     switch ( aAttribute )
       
   309         {
       
   310         case ECmExtensionLevel:
       
   311             {
       
   312     	    retval = CCmPluginLanBase::GetIntAttributeL( aAttribute );
       
   313     	    retval++;
       
   314             break;
       
   315             }        
       
   316         case ECmBearerIcon:
       
   317             {
       
   318             TAknsItemID id;
       
   319             MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   320                    
       
   321             TParse mbmFile;
       
   322             User::LeaveIfError( mbmFile.Set( KWlanFileIcons, 
       
   323                                 &KDC_BITMAP_DIR,
       
   324                                 NULL ) );
       
   325 
       
   326             // default - WLAN icon
       
   327             TInt icon = EMbmCmpluginwlanQgn_prop_wlan_bearer;
       
   328             TInt mask = EMbmCmpluginwlanQgn_prop_wlan_bearer_mask;
       
   329             
       
   330             // Easy WLAN icon
       
   331             TUint32 easyWlanId = iCmMgr.EasyWlanIdL();
       
   332             if ( easyWlanId && GetIntAttributeL( ECmId ) == easyWlanId )
       
   333                 {
       
   334                 icon = EMbmCmpluginwlanQgn_prop_set_conn_wlan_easy;
       
   335                 mask = EMbmCmpluginwlanQgn_prop_set_conn_wlan_easy_mask;
       
   336                 }
       
   337             
       
   338             retval = (TUint32)AknsUtils::CreateGulIconL( 
       
   339                                 skinInstance, 
       
   340                                 id,
       
   341                                 mbmFile.FullName(), 
       
   342                                 icon, 
       
   343                                 mask );
       
   344             break;
       
   345             }  
       
   346         case ECmBearerAvailableIcon:
       
   347             {
       
   348             TAknsItemID id;
       
   349             MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   350                    
       
   351             TParse mbmFile;
       
   352             User::LeaveIfError( mbmFile.Set( KWlanFileIcons, 
       
   353                                 &KDC_BITMAP_DIR,
       
   354                                 NULL ) );
       
   355 
       
   356             retval = (TUint32)AknsUtils::CreateGulIconL( 
       
   357                                 skinInstance, 
       
   358                                 id,
       
   359                                 mbmFile.FullName(), 
       
   360                                 EMbmCmpluginwlanQgn_prop_set_conn_bearer_avail_wlan, 
       
   361                                 EMbmCmpluginwlanQgn_prop_set_conn_bearer_avail_wlan_mask );
       
   362             break;
       
   363             }
       
   364         case ECmCommsDBBearerType:
       
   365             {
       
   366             retval = KCommDbBearerWLAN;
       
   367             break;
       
   368             }
       
   369             
       
   370         case ECmDefaultUiPriority:
       
   371             {
       
   372             retval = GlobalUiBearerPriority( TPtrC(KCDTypeNameWLANServiceExt) );
       
   373             
       
   374             if( retval == KDataMobilitySelectionPolicyPriorityWildCard )
       
   375                 {
       
   376                 retval = KDefaultPriorityWLan;
       
   377                 }
       
   378             }
       
   379             break;
       
   380         case ECmDefaultPriority:
       
   381             {
       
   382             retval = GlobalBearerPriority( TPtrC(KCDTypeNameWLANServiceExt) );
       
   383             
       
   384             if( retval == KDataMobilitySelectionPolicyPriorityWildCard )
       
   385                 {
       
   386                 retval = KDefaultPriorityWLan;
       
   387                 }
       
   388             }
       
   389             break;
       
   390         case EWlanServiceId:
       
   391             {
       
   392             if ( iWlanServiceRecord )
       
   393                 {
       
   394                 retval = iWlanServiceRecord->RecordId();
       
   395                 break;
       
   396                 }
       
   397             }
       
   398         default:
       
   399             {
       
   400     	    retval = CCmPluginBaseEng::GetIntAttributeL( aAttribute );
       
   401             break;
       
   402             }
       
   403         }
       
   404     return retval;
       
   405     }
       
   406 
       
   407 
       
   408 // --------------------------------------------------------------------------
       
   409 // CCmPluginWlan::GetBoolAttributeL
       
   410 // --------------------------------------------------------------------------
       
   411 //
       
   412 TBool CCmPluginWlan::GetBoolAttributeL( const TUint32 aAttribute ) const
       
   413     {
       
   414     LOGGER_ENTERFN( "CCmPluginWlan::GetBoolAttributeL" );
       
   415     
       
   416     TBool retval( EFalse );
       
   417 
       
   418     switch ( aAttribute )
       
   419         {
       
   420         case ECmCoverage:
       
   421             {
       
   422 #ifndef __WINS__
       
   423             TInt& networks = CONST_CAST( TInt&, iWlanNetworks );
       
   424             networks = 0;
       
   425 
       
   426             networks = CheckNetworkCoverageL();
       
   427             
       
   428             // If there's at least one WLAN network around, then there IS
       
   429             // coverage.
       
   430             retval = ( networks ? ETrue : EFalse );
       
   431 #else
       
   432 
       
   433             TInt& networks = CONST_CAST( TInt&, iWlanNetworks );
       
   434             ////networks = 0;
       
   435             ////retval = EFalse;
       
   436 
       
   437             networks = 1;
       
   438             retval = ETrue;
       
   439 
       
   440 
       
   441 
       
   442 #endif
       
   443             }
       
   444             break;
       
   445 
       
   446         case ECmAddToAvailableList:
       
   447             {
       
   448             retval = ETrue;
       
   449             }
       
   450             break;
       
   451             
       
   452         case ECmBearerHasUi:
       
   453             {
       
   454             retval = ETrue;
       
   455             }
       
   456             break;
       
   457             
       
   458         default:
       
   459             {
       
   460             retval = CCmPluginBaseEng::GetBoolAttributeL( aAttribute );
       
   461             break;
       
   462             }
       
   463         }
       
   464     return retval;
       
   465     }
       
   466 
       
   467 
       
   468 // --------------------------------------------------------------------------
       
   469 // CCmPluginWlan::GetStringAttributeL
       
   470 // --------------------------------------------------------------------------
       
   471 //
       
   472 HBufC* CCmPluginWlan::GetStringAttributeL( const TUint32 aAttribute ) const
       
   473     {
       
   474     LOGGER_ENTERFN( "CCmPluginWlan::GetStringAttributeL" );
       
   475 
       
   476 	HBufC* retVal = NULL;
       
   477 	
       
   478 	switch( aAttribute )
       
   479 	    {
       
   480 	    case ECmBearerAvailableName:
       
   481 	        {
       
   482 	        retVal = AllocReadL( R_QTN_NETW_CONSET_BEARER_AVAILABLE_WLAN );
       
   483 	        }
       
   484 	        break;
       
   485 	        
       
   486         case ECmBearerAvailableText:
       
   487             {
       
   488             if ( CEikonEnv::Static() )
       
   489                 {
       
   490                 if ( iWlanNetworks == KWlanSingleNetwork )
       
   491                     {
       
   492                     retVal = AllocReadL( 
       
   493                                     R_QTN_NETW_CONSET_ONE_WLAN_NW_AVAILABLE );
       
   494                     }
       
   495                 else
       
   496                     {
       
   497                     retVal = ReadResourceL( 
       
   498                                     R_QTN_NETW_CONSET_MANY_WLAN_NW_AVAILABLE,
       
   499                                     iWlanNetworks );
       
   500                     }
       
   501                 }
       
   502             else
       
   503                 {   // ReadResourceL does not work without a valid EikonEnv, so
       
   504                     // to have a consistent behaviour when there is one or more
       
   505                     // wlan networks for ECmBearerAvailableText, we always 
       
   506                     // leave when called without valid EikonEnv
       
   507                 User::Leave( KErrNotSupported );
       
   508                 }
       
   509             }
       
   510             break;
       
   511 
       
   512 	    case ECmBearerSupportedName:
       
   513 	        {
       
   514 	        retVal = AllocReadL( R_QTN_NETW_CONSET_BEARER_SUPPORTED_WLAN );
       
   515 	        }
       
   516 	        break;
       
   517 	        
       
   518 	    case ECmBearerNamePopupNote:
       
   519 	        {
       
   520 	        retVal = AllocReadL( R_QTN_NETW_CONSET_POPUP_BEARER_WLAN );
       
   521 	        }
       
   522 	        break;
       
   523 	        
       
   524 	    case ECmBearerSettingName:
       
   525 	        {
       
   526 	        retVal = AllocReadL( R_QTN_WLAN_SETT_BEARER_WLAN );
       
   527 	        }
       
   528 	        break;
       
   529 
       
   530 	    default:
       
   531 	        {
       
   532 	        retVal = CCmPluginBaseEng::GetStringAttributeL( aAttribute );
       
   533 	        }
       
   534 	        break;
       
   535 	    }	    
       
   536     return retVal;
       
   537     }
       
   538 
       
   539 
       
   540 // --------------------------------------------------------------------------
       
   541 // CCmPluginWlan::SetIntAttributeL
       
   542 // --------------------------------------------------------------------------
       
   543 //
       
   544 void CCmPluginWlan::SetIntAttributeL( const TUint32 aAttribute, 
       
   545                                             TUint32 aValue )
       
   546     {
       
   547     LOGGER_ENTERFN( "CCmPluginWlan::SetIntAttributeL" );
       
   548 
       
   549     CCmPluginBaseEng::SetIntAttributeL( aAttribute, aValue );
       
   550     if ( aAttribute == EWlanSecurityMode )
       
   551         {
       
   552         UpdateSecurityModeL();
       
   553         }
       
   554     }
       
   555 
       
   556 
       
   557 
       
   558 // --------------------------------------------------------------------------
       
   559 // CCmPluginWlan::SetBoolAttributeL
       
   560 // --------------------------------------------------------------------------
       
   561 //
       
   562 void CCmPluginWlan::SetBoolAttributeL( const TUint32 aAttribute, 
       
   563                                              TBool aValue )
       
   564     {
       
   565     LOGGER_ENTERFN( "CCmPluginWlan::SetBoolAttributeL" );
       
   566     
       
   567     CCmPluginBaseEng::SetBoolAttributeL( aAttribute, aValue );
       
   568     }
       
   569 
       
   570 
       
   571 
       
   572 // --------------------------------------------------------------------------
       
   573 // CCmPluginWlan::SetStringAttributeL
       
   574 // --------------------------------------------------------------------------
       
   575 //
       
   576 void CCmPluginWlan::SetStringAttributeL( const TUint32 aAttribute, 
       
   577                                                const TDesC16& aValue )
       
   578     {
       
   579     LOGGER_ENTERFN( "CCmPluginWlan::SetStringAttributeL" );
       
   580         
       
   581     switch( aAttribute )
       
   582         {
       
   583         case ECmName:
       
   584             {
       
   585             CCmPluginLanBase::SetStringAttributeL( aAttribute, aValue );
       
   586             break;
       
   587             }
       
   588         case EWlanIpNameServer1:
       
   589         case EWlanIpNameServer2:
       
   590             {
       
   591             // when setting nameservers, must set EWlanIpDNSAddrFromServer
       
   592             // according to current nameserver settings
       
   593             CCmPluginBaseEng::SetStringAttributeL( aAttribute, aValue );
       
   594             break;
       
   595             }
       
   596         case EWlanIp6NameServer1:
       
   597         case EWlanIp6NameServer2:
       
   598             {
       
   599             // when setting nameservers, must set EWlanIpDNSAddrFromServer
       
   600             // according to current nameserver settings
       
   601             CCmPluginBaseEng::SetStringAttributeL( aAttribute, aValue );
       
   602             break;
       
   603             }
       
   604         default:
       
   605             {
       
   606             CCmPluginBaseEng::SetStringAttributeL( aAttribute, aValue );
       
   607             break;
       
   608             }
       
   609         }
       
   610     }
       
   611 
       
   612 
       
   613 // --------------------------------------------------------------------------
       
   614 // CCmPluginWlan::UpdateAdditionalRecordsL
       
   615 // --------------------------------------------------------------------------
       
   616 //     
       
   617 void CCmPluginWlan::UpdateAdditionalRecordsL()
       
   618     {
       
   619     LOGGER_ENTERFN( "CCmPluginWlan::UpdateAdditionalRecordsL" );
       
   620     
       
   621     CheckIfNameModifiedL( iWlanServiceRecord );
       
   622 
       
   623     iWlanServiceRecord->iWlanServiceId.SetL( iIapRecord->iService );
       
   624     
       
   625     if ( !iWlanServiceRecord->RecordId() )
       
   626         {
       
   627         iWlanServiceRecord->SetRecordId( KCDNewRecordRequest );
       
   628         iWlanServiceRecord->StoreL( Session() );
       
   629         }
       
   630     else
       
   631         {
       
   632         iWlanServiceRecord->ModifyL( Session() );
       
   633         }
       
   634     UpdateSecuritySettingsL();        
       
   635     }
       
   636 
       
   637 
       
   638 // --------------------------------------------------------------------------
       
   639 // CCmPluginWlan::CanHandleIapIdL
       
   640 // --------------------------------------------------------------------------
       
   641 //
       
   642 TBool CCmPluginWlan::CanHandleIapIdL( TUint32 aIapId ) const
       
   643     {
       
   644     LOGGER_ENTERFN( "CCmPluginWlan::CanHandleIapIdL1" );
       
   645     CLOG_WRITE_1( "IapId: [%d]", aIapId );
       
   646     
       
   647     TBool retVal( EFalse );
       
   648     
       
   649     CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
       
   650                         ( CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord) );
       
   651         
       
   652     CleanupStack::PushL( iapRecord );
       
   653     iapRecord->SetRecordId( aIapId );
       
   654     
       
   655     TRAPD( err, iapRecord->LoadL( Session() ) );
       
   656 
       
   657     if( !err )
       
   658         {
       
   659         CanHandleIapIdL( iapRecord );
       
   660         }
       
   661     
       
   662     CleanupStack::PopAndDestroy( iapRecord );
       
   663     return retVal;
       
   664     }
       
   665 
       
   666 
       
   667 // --------------------------------------------------------------------------
       
   668 // CCmPluginWlan::CanHandleIapIdL
       
   669 // --------------------------------------------------------------------------
       
   670 //
       
   671 TBool CCmPluginWlan::CanHandleIapIdL( CCDIAPRecord *aIapRecord ) const
       
   672     {
       
   673     LOGGER_ENTERFN( "CCmPluginWlan::CanHandleIapIdL2" );
       
   674 
       
   675     CLOG_WRITE_1( "IapId: [%d]", aIapRecord->RecordId() );
       
   676    
       
   677     
       
   678     TBool retVal( EFalse );
       
   679     
       
   680     CLOG_WRITE_2( "IAP record: [%S][%S]",
       
   681                     &FIELD_TO_TDESC( aIapRecord->iServiceType ),
       
   682                     &FIELD_TO_TDESC( aIapRecord->iBearerType ) 
       
   683                 );
       
   684     
       
   685     if( (TPtrC(aIapRecord->iServiceType) == TPtrC(KCDTypeNameLANService) ) &&
       
   686         TPtrC(aIapRecord->iBearerType) == TPtrC(KCDTypeNameLANBearer) )
       
   687         {
       
   688         // check if there is a WLAN record with 
       
   689         // an iServiceId == iIapRecord->iService;
       
   690         CCDWlanServiceRecord* tmprec = new ( ELeave ) 
       
   691                                        CCDWlanServiceRecord ( iWlanTableId );
       
   692         CleanupStack::PushL( tmprec );
       
   693 
       
   694         TInt service = aIapRecord->iService;
       
   695         
       
   696         tmprec->iWlanServiceId.SetL( (TUint32)service );
       
   697         if ( tmprec->FindL( Session() ) )
       
   698             {
       
   699             // we found at least one WLAN using this IAP, 
       
   700             retVal = ETrue;
       
   701             tmprec->LoadL( Session() );
       
   702             CLOG_WRITE( "I can." );
       
   703             }
       
   704         else
       
   705             {
       
   706             // not found -> not our
       
   707             CLOG_WRITE_1( "Wlan with Service ID: [%d] NOT found ", 
       
   708                           service );
       
   709             }
       
   710         CleanupStack::PopAndDestroy(tmprec);        
       
   711         }
       
   712     return retVal;
       
   713     }
       
   714 
       
   715 
       
   716 // --------------------------------------------------------------------------
       
   717 // CCmPluginWlan::DeleteAdditionalRecordsL
       
   718 // --------------------------------------------------------------------------
       
   719 //
       
   720 void CCmPluginWlan::DeleteAdditionalRecordsL()
       
   721     {
       
   722     LOGGER_ENTERFN( "CCmPluginWlan::DeleteAdditionalRecordsL" );    
       
   723     
       
   724     // as base class deletes service record, in this case LAN, 
       
   725     // only WLAN related stuff needs to be deleted
       
   726     // also security settings, too!
       
   727     DeleteSecuritySettingsL();
       
   728     iWlanServiceRecord->DeleteL( Session() );
       
   729     }      
       
   730     
       
   731         
       
   732 // --------------------------------------------------------------------------
       
   733 // CCmPluginWlan::RunSettingsL
       
   734 // --------------------------------------------------------------------------
       
   735 //        
       
   736 TInt CCmPluginWlan::RunSettingsL()
       
   737     {
       
   738     LOGGER_ENTERFN( "CCmPluginWlan::RunSettingsL" );
       
   739     
       
   740     CmPluginWlanSettingsDlg* cmDlg = CmPluginWlanSettingsDlg::NewL( *this );
       
   741     return cmDlg->ConstructAndRunLD( );       
       
   742     }
       
   743 
       
   744 	
       
   745 // --------------------------------------------------------------------------
       
   746 // CCmPluginWlan::LoadServiceSettingL
       
   747 // --------------------------------------------------------------------------
       
   748 //        
       
   749 void CCmPluginWlan::LoadServiceSettingL()
       
   750     {
       
   751     LOGGER_ENTERFN( "CCmPluginWlan::LoadServiceSettingL" );
       
   752         
       
   753     if( TPtrC(KCDTypeNameLANService) == iIapRecord->iServiceType  )
       
   754         {
       
   755         iServiceRecord = static_cast<CCDServiceRecordBase *>
       
   756                     (CCDRecordBase::RecordFactoryL(KCDTIdLANServiceRecord));
       
   757         iServiceRecord->SetRecordId( iIapRecord->iService );
       
   758         CLOG_WRITE_1( "ID: [%d]", iServiceRecord->RecordId() );
       
   759         iServiceRecord->LoadL(Session());        
       
   760         }
       
   761     else
       
   762         // this IAP service is not supported by this plugin.
       
   763         {
       
   764         User::Leave( KErrNotSupported );
       
   765         }
       
   766     }
       
   767 
       
   768 
       
   769 // --------------------------------------------------------------------------
       
   770 // CCmPluginWlan::LoadAdditionalRecordsL
       
   771 // --------------------------------------------------------------------------
       
   772 //        
       
   773 void CCmPluginWlan::LoadAdditionalRecordsL()
       
   774     {
       
   775     LOGGER_ENTERFN( "CCmPluginWlan::LoadAdditionalRecordsL" );
       
   776     
       
   777     if (!iWlanServiceRecord) 
       
   778         {
       
   779         iWlanServiceRecord = 
       
   780                         new ( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
       
   781         }
       
   782     iWlanServiceRecord->SetRecordId( 0 );
       
   783 
       
   784     iWlanServiceRecord->iWlanServiceId.SetL( ( TUint32 )
       
   785                                                 ( iIapRecord->iService ) );
       
   786     
       
   787     if ( iWlanServiceRecord->FindL( Session() ) )
       
   788         {
       
   789         iWlanServiceRecord->LoadL( Session() );
       
   790         LoadSecuritySettingsL();
       
   791         }
       
   792     else
       
   793         {
       
   794         // not found -> error
       
   795         CLOG_WRITE_1( "Wlan with Service ID: [%d] NOT found ", 
       
   796                       iServiceRecord->RecordId() );
       
   797         User::Leave(KErrNotFound);
       
   798         }
       
   799     }
       
   800 
       
   801 
       
   802 // --------------------------------------------------------------------------
       
   803 // CCmPluginWlan::CreateNewServiceRecordL
       
   804 // --------------------------------------------------------------------------
       
   805 //        
       
   806 void CCmPluginWlan::CreateNewServiceRecordL()
       
   807     {
       
   808     LOGGER_ENTERFN( "CCmPluginWlan::CreateNewServiceRecordL" );
       
   809         
       
   810     // create base (LAN) service record:
       
   811     CCmPluginLanBase::CreateNewServiceRecordL();
       
   812     CCDLANServiceRecord* tmp = 
       
   813                 static_cast<CCDLANServiceRecord *>(iServiceRecord);
       
   814     if( FeatureSupported( KFeatureIdIPv6 ) )
       
   815         {
       
   816         tmp->iIfNetworks.SetL( KDefIspIfNetworksIPv4IPv6 );
       
   817         }
       
   818     else
       
   819         {
       
   820         tmp->iIfNetworks.SetL( KDefIspIfNetworksIPv4 );
       
   821         }
       
   822 
       
   823     // create WLAN service record:
       
   824     CreateWlanServiceRecordL();
       
   825     
       
   826     // In case of WLan 'show progress' is the default value
       
   827     SetIntAttributeL( ECmSeamlessnessLevel, ESeamlessnessShowprogress );
       
   828     }
       
   829 
       
   830 
       
   831 // --------------------------------------------------------------------------
       
   832 // CCmPluginWlan::CreateWlanServiceRecordL
       
   833 // --------------------------------------------------------------------------
       
   834 //        
       
   835 void CCmPluginWlan::CreateWlanServiceRecordL()
       
   836     {
       
   837     LOGGER_ENTERFN( "CCmPluginWlan::CreateWlanServiceRecordL" );
       
   838 
       
   839     delete iWlanServiceRecord; 
       
   840     iWlanServiceRecord = NULL;
       
   841     
       
   842     iWlanServiceRecord = new ( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
       
   843     iWlanServiceRecord->SetRecordId( KCDNewRecordRequest );
       
   844 
       
   845 	iWlanServiceRecord->iRecordTag.SetL( 1 );
       
   846 	iWlanServiceRecord->iRecordName.SetL( iIapRecord->iRecordName );
       
   847     iWlanServiceRecord->iWlanConnMode.SetL( EInfra );
       
   848     iWlanServiceRecord->iWlanSecMode.SetL( EWlanSecModeOpen );
       
   849     iWlanServiceRecord->iWlanScanSSID.SetL( EFalse );
       
   850     }
       
   851 
       
   852 
       
   853 // ----------------------------------------------------------------------------
       
   854 // CCmPluginWlan::PrepareToUpdateRecordsL()
       
   855 // ----------------------------------------------------------------------------
       
   856 //
       
   857 void CCmPluginWlan::PrepareToUpdateRecordsL()
       
   858     {
       
   859     CCDLANServiceRecord* tmprec = static_cast<CCDLANServiceRecord*>(iServiceRecord);
       
   860 
       
   861     CheckDNSServerAddressL( ETrue, 
       
   862                             tmprec->iIp6NameServer1,
       
   863                             tmprec->iIp6NameServer2,
       
   864                             tmprec->iIp6DnsAddrFromServer );
       
   865                             
       
   866     CheckDNSServerAddressL( EFalse,
       
   867                             tmprec->iIpNameServer1,
       
   868                             tmprec->iIpNameServer2,
       
   869                             tmprec->iIpDnsAddrFromServer );
       
   870     SetDaemonNameL();
       
   871     }
       
   872 
       
   873 
       
   874 // --------------------------------------------------------------------------
       
   875 // CCmPluginWlan::LoadSecuritySettingsL
       
   876 // --------------------------------------------------------------------------
       
   877 //        
       
   878 void CCmPluginWlan::LoadSecuritySettingsL()
       
   879     {
       
   880     LOGGER_ENTERFN( "CCmPluginWlan::LoadSecuritySettingsL" );
       
   881 
       
   882     TUint32 secmode = iWlanServiceRecord->iWlanSecMode;
       
   883     TUint32 iapid = iIapRecord->iService;
       
   884                    
       
   885     switch ( secmode )
       
   886         {
       
   887         case EWlanSecModeOpen:
       
   888             {
       
   889             break;
       
   890             }
       
   891         case EWlanSecModeWep:
       
   892             {
       
   893             if ( !iWepSecSettings )
       
   894                 {
       
   895                 iWepSecSettings = CWEPSecuritySettings::NewL();
       
   896                 }
       
   897                 iWepSecSettings->LoadL( iapid, Session() );
       
   898             break;
       
   899             }
       
   900         case EWlanSecMode802_1x:
       
   901             {
       
   902             if ( !iWpaSecSettings )
       
   903                 {
       
   904                 iWpaSecSettings = 
       
   905                     CWPASecuritySettings::NewL( ESecurityMode8021x );
       
   906                 }
       
   907             iWpaSecSettings->LoadL( iapid, Session() );
       
   908             break;
       
   909             }
       
   910         case EWlanSecModeWpa:
       
   911         case EWlanSecModeWpa2:
       
   912             {
       
   913             if ( !iWpaSecSettings )
       
   914                 {
       
   915                 iWpaSecSettings = 
       
   916                     CWPASecuritySettings::NewL( ESecurityModeWpa );
       
   917                 }
       
   918 			iWpaSecSettings->LoadL( iapid, Session() );
       
   919             break;
       
   920             }
       
   921         case EWlanSecModeWAPI:
       
   922             {
       
   923             if ( iIsWAPISupported )
       
   924                 {
       
   925                 if ( !iWAPISecSettings )
       
   926                     {
       
   927                     iWAPISecSettings = CWAPISecuritySettings::NewL();
       
   928                     }
       
   929                 iWAPISecSettings->LoadL( iIapRecord->RecordId(), Session() );
       
   930                 }
       
   931             else
       
   932                 {
       
   933                 User::Leave( KErrCorrupt );
       
   934                 }
       
   935             break;
       
   936             }
       
   937         default:
       
   938             {
       
   939             User::Leave( KErrNotSupported );
       
   940             // do nothing in urel
       
   941             break;
       
   942             }
       
   943         }
       
   944     }
       
   945     
       
   946 
       
   947 // ----------------------------------------------------------------------------
       
   948 // CCmPluginWlan::EditSecuritySettingsL
       
   949 // ----------------------------------------------------------------------------
       
   950 //        
       
   951 TInt CCmPluginWlan::EditSecuritySettingsL( CEikonEnv& aEikonEnv )
       
   952     {
       
   953     LOGGER_ENTERFN( "CCmPluginWlan::EditSecuritySettingsL" );
       
   954 
       
   955     TInt ret = KErrNotFound;
       
   956 
       
   957     TUint32 secmode = iWlanServiceRecord->iWlanSecMode;
       
   958 
       
   959     HBufC* title = GetStringAttributeL(ECmName);
       
   960     CleanupStack::PushL( title );   
       
   961     switch ( secmode )
       
   962         {
       
   963         case EWlanSecModeOpen:
       
   964             {
       
   965             break;
       
   966             }
       
   967         case EWlanSecModeWep:
       
   968             {
       
   969             CWEPSecuritySettingsUi* ui = 
       
   970                             CWEPSecuritySettingsUi::NewL(aEikonEnv);
       
   971             CleanupStack::PushL( ui );
       
   972             if ( !iWepSecSettings )
       
   973                 {
       
   974                 iWepSecSettings = CWEPSecuritySettings::NewL();
       
   975                 }            
       
   976             ret = iWepSecSettings->EditL( *ui, *title );
       
   977             CleanupStack::PopAndDestroy( ui );
       
   978             break;
       
   979             }
       
   980         case EWlanSecMode802_1x:
       
   981             {
       
   982             CWPASecuritySettingsUi* ui = 
       
   983                             CWPASecuritySettingsUi::NewL(aEikonEnv);
       
   984             CleanupStack::PushL(ui);
       
   985             if ( !iWpaSecSettings )
       
   986                 {
       
   987                 iWpaSecSettings = 
       
   988                             CWPASecuritySettings::NewL( ESecurityMode8021x );
       
   989                 }                        
       
   990             ret = iWpaSecSettings->EditL( *ui, *title );
       
   991             CleanupStack::PopAndDestroy( ui );
       
   992             break;
       
   993             }
       
   994         case EWlanSecModeWpa:
       
   995         case EWlanSecModeWpa2:
       
   996             {
       
   997             CWPASecuritySettingsUi* ui = 
       
   998                             CWPASecuritySettingsUi::NewL(aEikonEnv);
       
   999             CleanupStack::PushL( ui );
       
  1000             if ( !iWpaSecSettings )
       
  1001                 {
       
  1002                 iWpaSecSettings = 
       
  1003                     CWPASecuritySettings::NewL( ESecurityModeWpa );
       
  1004                 }                        
       
  1005             ret = iWpaSecSettings->EditL( *ui, *title );
       
  1006             CleanupStack::PopAndDestroy( ui );
       
  1007             break;
       
  1008             }            
       
  1009         case EWlanSecModeWAPI:
       
  1010             {
       
  1011             if ( iIsWAPISupported )
       
  1012                 {
       
  1013                 CWAPISecuritySettingsUi* ui =
       
  1014                             CWAPISecuritySettingsUi::NewL( aEikonEnv );
       
  1015                 CleanupStack::PushL( ui );
       
  1016                 if ( !iWAPISecSettings )
       
  1017                     {
       
  1018                     iWAPISecSettings = CWAPISecuritySettings::NewL();
       
  1019                     }
       
  1020                 ret = iWAPISecSettings->EditL( *ui, *title );
       
  1021                 CleanupStack::PopAndDestroy( ui );
       
  1022                 }
       
  1023             else
       
  1024                 {
       
  1025                 User::Leave( KErrCorrupt );
       
  1026                 }
       
  1027             break;
       
  1028             }
       
  1029         default:
       
  1030             {
       
  1031             // do nothing in urel
       
  1032             break;
       
  1033             }
       
  1034         }
       
  1035     CleanupStack::PopAndDestroy( title );
       
  1036     return ret;
       
  1037     }
       
  1038 
       
  1039 // --------------------------------------------------------------------------
       
  1040 // CCmPluginWlan::AreSecuritySettingsValidL
       
  1041 // --------------------------------------------------------------------------
       
  1042 //        
       
  1043 TBool CCmPluginWlan::AreSecuritySettingsValidL()
       
  1044     {
       
  1045     LOGGER_ENTERFN( "CCmPluginWlan::AreSecuritySettingsValidL" );
       
  1046   
       
  1047     TBool ret = EFalse;
       
  1048 
       
  1049     TUint32 secmode = iWlanServiceRecord->iWlanSecMode;
       
  1050                 
       
  1051     switch ( secmode )
       
  1052         {
       
  1053         case EWlanSecModeOpen:
       
  1054             {
       
  1055             break;
       
  1056             }
       
  1057         case EWlanSecModeWep:
       
  1058             {
       
  1059             if ( !iWepSecSettings )
       
  1060                 {
       
  1061                 iWepSecSettings = CWEPSecuritySettings::NewL();
       
  1062                 }            
       
  1063             ret = iWepSecSettings->IsValid();
       
  1064             break;
       
  1065             }
       
  1066         case EWlanSecMode802_1x:
       
  1067             {
       
  1068             if ( !iWpaSecSettings )
       
  1069                 {
       
  1070                 iWpaSecSettings = 
       
  1071                     CWPASecuritySettings::NewL( ESecurityMode8021x );
       
  1072                 }
       
  1073             ret = iWpaSecSettings->IsValid();
       
  1074             break;
       
  1075             }
       
  1076         case EWlanSecModeWpa:
       
  1077         case EWlanSecModeWpa2:
       
  1078             {
       
  1079             if ( !iWpaSecSettings )
       
  1080                 {
       
  1081                 iWpaSecSettings = 
       
  1082                     CWPASecuritySettings::NewL( ESecurityModeWpa );
       
  1083                 }
       
  1084             ret = iWpaSecSettings->IsValid();
       
  1085             break;
       
  1086             }
       
  1087         case EWlanSecModeWAPI:
       
  1088             {
       
  1089             if ( iIsWAPISupported )
       
  1090                 {
       
  1091                 if ( !iWAPISecSettings )
       
  1092                     {
       
  1093                     iWAPISecSettings = CWAPISecuritySettings::NewL();
       
  1094                     }
       
  1095                 ret = iWAPISecSettings->IsValid();
       
  1096                 }
       
  1097             else
       
  1098                 {
       
  1099                 User::Leave( KErrCorrupt );
       
  1100                 }
       
  1101             break;
       
  1102             }
       
  1103         default:
       
  1104             {
       
  1105             // do nothing in urel
       
  1106             break;
       
  1107             }
       
  1108         }        
       
  1109     return ret;
       
  1110     }
       
  1111 
       
  1112     
       
  1113 // --------------------------------------------------------------------------
       
  1114 // CCmPluginWlan::UpdateSecuritySettingsL()
       
  1115 // --------------------------------------------------------------------------
       
  1116 //        
       
  1117 void CCmPluginWlan::UpdateSecuritySettingsL()
       
  1118     {
       
  1119     LOGGER_ENTERFN( "CCmPluginWlan::UpdateSecuritySettingsL" );
       
  1120 
       
  1121     TUint32 oldwlaniapid(0);
       
  1122     TUint32 wlaniapid = iIapRecord->iService;
       
  1123     
       
  1124     TUint32 secmode = iWlanServiceRecord->iWlanSecMode;    
       
  1125     CLOG_WRITE_1( "Sec mode: [%d]", secmode );
       
  1126 
       
  1127     TTypeOfSaving savetype( ESavingBrandNewAP );
       
  1128     
       
  1129     if (iWlanServiceRecord->RecordId())
       
  1130         {
       
  1131         savetype = ESavingEditedAP;
       
  1132         oldwlaniapid = wlaniapid;
       
  1133         }
       
  1134 
       
  1135     if ( iIsCopy )
       
  1136         {
       
  1137         oldwlaniapid = iCopiedFromIapId;
       
  1138         savetype = ESavingNewAPAsACopy;
       
  1139         
       
  1140         switch ( secmode )
       
  1141             {
       
  1142             case EWlanSecModeOpen:
       
  1143                 {
       
  1144                 break;
       
  1145                 }
       
  1146             case EWlanSecModeWep:
       
  1147                 {
       
  1148                 // this is a brand new copy of another CM
       
  1149                 // we have to load the settings for the old wlan
       
  1150                 // and save with the new one.
       
  1151                 // first delete possibly existing other settings
       
  1152                 if ( iWepSecSettings )
       
  1153                     {
       
  1154                     delete iWepSecSettings;
       
  1155                     iWepSecSettings = NULL;
       
  1156                     }
       
  1157                 break;
       
  1158                 }
       
  1159             case EWlanSecMode802_1x:
       
  1160                 {
       
  1161                 // this is a brand new copy of another CM
       
  1162                 // we have to load the settings for the old wlan
       
  1163                 // and save with the new one.
       
  1164                 // first delete possibly existing other settings
       
  1165                 if ( iWpaSecSettings )
       
  1166                     {
       
  1167                     delete iWpaSecSettings;
       
  1168                     iWpaSecSettings = NULL;
       
  1169                     }
       
  1170                 break;
       
  1171                 }
       
  1172             case EWlanSecModeWpa:
       
  1173             case EWlanSecModeWpa2:
       
  1174                 {
       
  1175                 // this is a brand new copy of another CM
       
  1176                 // we have to load the settings for the old wlan
       
  1177                 // and save with the new one.
       
  1178                 // first delete possibly existing other settings
       
  1179                 if ( iWpaSecSettings )
       
  1180                     {
       
  1181                     delete iWpaSecSettings;
       
  1182                     iWpaSecSettings = NULL;
       
  1183                     }
       
  1184                 break;
       
  1185                 }
       
  1186             case EWlanSecModeWAPI:
       
  1187                 {
       
  1188                 if ( iIsWAPISupported )
       
  1189                     {
       
  1190                     if ( iWAPISecSettings )
       
  1191                         {
       
  1192                         delete iWAPISecSettings;
       
  1193                         iWAPISecSettings = NULL;
       
  1194                         }
       
  1195                     }
       
  1196                 else
       
  1197                     {
       
  1198                     User::Leave( KErrCorrupt );
       
  1199                     }
       
  1200                 break;
       
  1201                 }
       
  1202             default:
       
  1203                 {
       
  1204                 CLOG_WRITE( "Unknown secmode" );
       
  1205                 // do nothing in urel
       
  1206                 break;
       
  1207                 }
       
  1208             }
       
  1209         }
       
  1210     // now save, & load if still needed
       
  1211     switch ( secmode )
       
  1212         {
       
  1213         case EWlanSecModeOpen:
       
  1214             {
       
  1215             // Extra fileds are deleted from WLANServiceTable
       
  1216             // when security mode is changed from WPA to Open
       
  1217             if ( iWpaSecSettings )
       
  1218                 {
       
  1219                 iWpaSecSettings->DeleteL( wlaniapid );
       
  1220                 }
       
  1221             break;
       
  1222             }
       
  1223         case EWlanSecModeWep:
       
  1224             {
       
  1225             // Extra fileds are deleted from WLANServiceTable
       
  1226             // when security mode is changed from WPA to WEP
       
  1227             if ( iWpaSecSettings )
       
  1228                 {
       
  1229                 iWpaSecSettings->DeleteL( wlaniapid );
       
  1230                 }
       
  1231 
       
  1232             // we have to try to save if:
       
  1233             // 1. it is a changed AP, it is possible that only 
       
  1234             // sec. settings have been changed. 
       
  1235             // In this case, iWepSecSettings might be NULL!!
       
  1236             // 2. it's sec. settings had been edited
       
  1237             
       
  1238             if ( !iWepSecSettings )
       
  1239                 {
       
  1240                 iWepSecSettings = CWEPSecuritySettings::NewL();
       
  1241                 iWepSecSettings->LoadL( oldwlaniapid, Session() );
       
  1242                 }
       
  1243             // save WEP settings, too, into same transaction...
       
  1244             iWepSecSettings->SaveL( wlaniapid, Session() );
       
  1245             break;
       
  1246             }
       
  1247         case EWlanSecMode802_1x:
       
  1248             {
       
  1249             if ( !iWpaSecSettings )
       
  1250                 {
       
  1251                 iWpaSecSettings = 
       
  1252                     CWPASecuritySettings::NewL( ESecurityMode8021x );
       
  1253                 iWpaSecSettings->LoadL( oldwlaniapid, Session() );
       
  1254                 }                            
       
  1255             // save WPA settings, too, into same transaction...
       
  1256             iWpaSecSettings->SaveL( wlaniapid, Session(), savetype, oldwlaniapid );
       
  1257             break;
       
  1258             }
       
  1259         case EWlanSecModeWpa:
       
  1260         case EWlanSecModeWpa2:
       
  1261             {
       
  1262             if ( !iWpaSecSettings )
       
  1263                 {
       
  1264                 iWpaSecSettings = 
       
  1265                       CWPASecuritySettings::NewL( ESecurityModeWpa );
       
  1266                 iWpaSecSettings->LoadL( oldwlaniapid, Session() );
       
  1267                 }
       
  1268             
       
  1269             // save WPA settings, too, into same transaction...
       
  1270             iWpaSecSettings->SaveL( wlaniapid, Session(), savetype, oldwlaniapid );
       
  1271             break;
       
  1272             }
       
  1273         case EWlanSecModeWAPI:
       
  1274             {
       
  1275             if ( iIsWAPISupported )
       
  1276                 {
       
  1277                 if ( !iWAPISecSettings )
       
  1278                     {
       
  1279                     iWAPISecSettings = CWAPISecuritySettings::NewL();
       
  1280                     iWAPISecSettings->LoadL( iIapRecord->RecordId(), Session() );
       
  1281                     }
       
  1282                 // save WAPI settings
       
  1283                 TRAPD( err, iWAPISecSettings->SaveL( iIapRecord->RecordId(), Session() ) );
       
  1284                 if ( err )
       
  1285                     {
       
  1286                     if ( err != KErrArgument )
       
  1287                         {
       
  1288                         User::Leave( err );
       
  1289                         }
       
  1290                     }
       
  1291                 }
       
  1292             else
       
  1293                 {
       
  1294                 User::Leave( KErrCorrupt );
       
  1295                 }
       
  1296             break;
       
  1297             }
       
  1298         default:
       
  1299             {
       
  1300             CLOG_WRITE( "Unknown secmode" );
       
  1301             // do nothing in urel
       
  1302             break;
       
  1303             }
       
  1304         }
       
  1305     // clean up copy flags
       
  1306     if ( iIsCopy )
       
  1307         {
       
  1308         iIsCopy = EFalse;
       
  1309         iCopiedFromIapId = 0;
       
  1310         }
       
  1311     }
       
  1312     
       
  1313     
       
  1314 // --------------------------------------------------------------------------
       
  1315 // CCmPluginWlan::AdditionalReset()
       
  1316 // --------------------------------------------------------------------------
       
  1317 //        
       
  1318 void CCmPluginWlan::AdditionalReset()
       
  1319     {
       
  1320     LOGGER_ENTERFN( "CCmPluginWlan::AdditionalReset" );
       
  1321     
       
  1322     delete iWlanServiceRecord;
       
  1323     iWlanServiceRecord = NULL;
       
  1324     
       
  1325     delete iWepSecSettings;
       
  1326     iWepSecSettings = NULL;
       
  1327     
       
  1328     delete iWpaSecSettings;
       
  1329     iWpaSecSettings = NULL;
       
  1330 
       
  1331     if ( iIsWAPISupported )
       
  1332         {
       
  1333         delete iWAPISecSettings;
       
  1334         iWAPISecSettings = NULL;
       
  1335         }
       
  1336     }
       
  1337 
       
  1338 // --------------------------------------------------------------------------
       
  1339 // CCmPluginWlan::BearerRecordIdLC()
       
  1340 // --------------------------------------------------------------------------
       
  1341 //        
       
  1342 void CCmPluginWlan::BearerRecordIdLC( HBufC* &aBearerName, 
       
  1343                                                   TUint32& aRecordId )
       
  1344     {
       
  1345     LOGGER_ENTERFN( "CCmPluginWlan::BearerRecordIdLC" );
       
  1346 
       
  1347 	CCDLANBearerRecord* tmprec = static_cast<CCDLANBearerRecord*>
       
  1348                 ( CCDRecordBase::RecordFactoryL( KCDTIdLANBearerRecord ) );
       
  1349     CleanupStack::PushL( tmprec );
       
  1350 
       
  1351     tmprec->iRecordName.SetL( TPtrC( iBearerRecName ) );
       
  1352     if ( !tmprec->FindL( Session() ) )
       
  1353         { // bearer not found -> create dummy values
       
  1354         CLOG_WRITE( "No bearer found" );
       
  1355         
       
  1356         tmprec->SetRecordId( KCDNewRecordRequest );
       
  1357         
       
  1358         tmprec->iBearerAgent.SetL( KWlanBearerAgent );
       
  1359         tmprec->iRecordName.SetL( KWlanBearerName );
       
  1360         tmprec->iLanBearerNifName.SetL( KWlanBearerNif );
       
  1361         tmprec->iLanBearerLddName.SetL( KWlanLDDName );
       
  1362         tmprec->iLanBearerPddName.SetL( KWlanPDDName );
       
  1363         tmprec->iLastSocketActivityTimeout.SetL(
       
  1364                                 ( TUint32 )KWlanLastSocketActivityTimeout );
       
  1365         tmprec->iLastSessionClosedTimeout.SetL(
       
  1366                                 (TUint32 )KWlanLastSessionClosedTimeout );
       
  1367         tmprec->iLastSocketClosedTimeout.SetL(
       
  1368                                 ( TUint32 )KWlanLastSocketClosedTimeout );
       
  1369         tmprec->StoreL( Session() );
       
  1370         }
       
  1371 
       
  1372     aRecordId = tmprec->RecordId();
       
  1373     
       
  1374     CLOG_WRITE_2( "Name: [%S], id: [%d]", 
       
  1375                   &tmprec->iRecordName.GetL(),
       
  1376                   aRecordId );
       
  1377 
       
  1378     CleanupStack::PopAndDestroy( tmprec );
       
  1379 
       
  1380     aBearerName = TPtrC(KCDTypeNameLANBearer).AllocLC();
       
  1381     }
       
  1382 
       
  1383 
       
  1384 // --------------------------------------------------------------------------
       
  1385 // CCmPluginWlan::ReadResourceL()
       
  1386 // --------------------------------------------------------------------------
       
  1387 //        
       
  1388 HBufC* CCmPluginWlan::ReadResourceL( TInt aResId, TInt aInt ) const
       
  1389     {
       
  1390     LOGGER_ENTERFN( "CCmPluginWlan::ReadResourceL" );
       
  1391     
       
  1392     HBufC* retval = NULL;
       
  1393 
       
  1394     RConeResourceLoader resourceLoader( *CEikonEnv::Static() );
       
  1395     LoadResourceLC( resourceLoader );
       
  1396     retval = StringLoader::LoadL( aResId, aInt );
       
  1397 
       
  1398     // Clean-up
       
  1399     CleanupStack::PopAndDestroy();
       
  1400 
       
  1401     return retval;
       
  1402     }
       
  1403 
       
  1404 
       
  1405 // --------------------------------------------------------------------------
       
  1406 // CCmPluginWlan::LoadResourceL()
       
  1407 // --------------------------------------------------------------------------
       
  1408 //  
       
  1409 void CCmPluginWlan::LoadResourceLC( 
       
  1410                                 RConeResourceLoader& aResourceLoader ) const
       
  1411     {
       
  1412     LOGGER_ENTERFN( "CCmPluginWlan::LoadResourceLC" );
       
  1413     
       
  1414     // Add resource file.
       
  1415     TParse fp;
       
  1416     User::LeaveIfError( fp.Set( KPluginWlanResDirAndFileName, 
       
  1417                         &KDC_RESOURCE_FILES_DIR, 
       
  1418                         NULL ) );
       
  1419     TFileName resourceFileNameBuf = fp.FullName();
       
  1420 
       
  1421     CleanupClosePushL( aResourceLoader );
       
  1422     aResourceLoader.OpenL( resourceFileNameBuf );
       
  1423     }
       
  1424 
       
  1425 
       
  1426 // --------------------------------------------------------------------------
       
  1427 // CCmPluginWlan::InitializeWithUiL
       
  1428 // --------------------------------------------------------------------------
       
  1429 //        
       
  1430 TBool CCmPluginWlan::InitializeWithUiL( TBool aManuallyConfigure )
       
  1431     {
       
  1432     LOGGER_ENTERFN( "CCmPluginWlan::InitializeWithUiL" );
       
  1433     
       
  1434     TBool retVal ( EFalse );
       
  1435     RConeResourceLoader resourceLoader( *CEikonEnv::Static() );
       
  1436     LoadResourceLC( resourceLoader );
       
  1437     if ( aManuallyConfigure )
       
  1438         {
       
  1439         retVal = ManuallyConfigureL();
       
  1440         }
       
  1441     else
       
  1442         {
       
  1443         retVal = AutomaticallyConfigureL();
       
  1444         }
       
  1445     // Clean-up
       
  1446     CleanupStack::PopAndDestroy();
       
  1447     return retVal;
       
  1448     }
       
  1449 
       
  1450 // --------------------------------------------------------------------------
       
  1451 // CCmPluginWlan::ProtectedSetupL
       
  1452 // --------------------------------------------------------------------------
       
  1453 //
       
  1454 WiFiProt::TWiFiReturn CCmPluginWlan::ProtectedSetupL( TWlanSsid& aSsid )
       
  1455     {
       
  1456     RCmManagerExt packedCmManager;
       
  1457     iCmMgr.WrapCmManager( packedCmManager );
       
  1458     CWifiProtUiInProcess* wifi = CWifiProtUiInProcess::NewL(
       
  1459                              &packedCmManager );
       
  1460     CleanupStack::PushL( wifi );
       
  1461     WiFiProt::TWiFiReturn wifiret = wifi->StartFromUiL( aSsid, EFalse, iAdditionalCmsCreated);                         
       
  1462     CleanupStack::PopAndDestroy( wifi );                                         
       
  1463     switch ( wifiret )
       
  1464         {
       
  1465         case WiFiProt::EWiFiCancel:
       
  1466             {
       
  1467             break;
       
  1468             }
       
  1469         case WiFiProt::EWiFiOK:
       
  1470             {
       
  1471             if (iAdditionalCmsCreated.Count())
       
  1472                 {
       
  1473                 // Loading the first item in the array
       
  1474                 // to the actual plugin
       
  1475                 Reset();
       
  1476                 AdditionalReset();
       
  1477                 LoadL( iAdditionalCmsCreated[0] );
       
  1478                 iAdditionalCmsCreated.Remove(0);
       
  1479                 }
       
  1480              else 
       
  1481                 {//no settings configured, do the same as cancel case
       
  1482                 return WiFiProt::EWiFiCancel;
       
  1483                 }
       
  1484                 
       
  1485             break;
       
  1486             }
       
  1487         case WiFiProt::EWifiNoAuto:
       
  1488             {
       
  1489             break;
       
  1490             }  
       
  1491         default:
       
  1492             {
       
  1493             User::Leave( KErrNotSupported );
       
  1494             break;
       
  1495             }                                              
       
  1496         }    
       
  1497     return wifiret;
       
  1498     }
       
  1499 
       
  1500 // --------------------------------------------------------------------------
       
  1501 // CCmPluginWlan::AutomaticallyConfigureL
       
  1502 // --------------------------------------------------------------------------
       
  1503 //
       
  1504 TBool CCmPluginWlan::AutomaticallyConfigureL()
       
  1505     {
       
  1506     LOGGER_ENTERFN( "CCmPluginWlan::AutomaticallyConfigureL" );
       
  1507     
       
  1508     TBool retval ( ETrue );
       
  1509     
       
  1510     if ( !iConnUiUtils )
       
  1511         {
       
  1512         iConnUiUtils = CConnectionUiUtilities::NewL();
       
  1513         }
       
  1514 
       
  1515     // Let's search for a WLAN network
       
  1516     TWlanSsid ssid;
       
  1517     TWlanConnectionMode connectionMode;
       
  1518     TWlanConnectionExtentedSecurityMode securityMode;
       
  1519 
       
  1520     TUint32 secmode( EWlanSecModeOpen );
       
  1521     
       
  1522     // Fortunately user will not see WLAN networks with empty ssid in the list
       
  1523     // shown by next call.
       
  1524     CCmPluginWlanActiveWaiter* waiter = CCmPluginWlanActiveWaiter::NewL();
       
  1525     CleanupStack::PushL( waiter );
       
  1526 
       
  1527     TBool isProtectedSetupSupported;
       
  1528     iConnUiUtils->SearchWLANNetworkAsync( waiter->iStatus, ssid, connectionMode, securityMode, isProtectedSetupSupported );
       
  1529 
       
  1530     TInt searchWlanReturn = waiter->WaitForRequest();
       
  1531     CleanupStack::PopAndDestroy( waiter );
       
  1532 
       
  1533     if ( searchWlanReturn == KErrNone)
       
  1534         {
       
  1535         if ( isProtectedSetupSupported )
       
  1536             {
       
  1537             TBool wifiret = ProtectedSetupL( ssid );
       
  1538             switch ( wifiret )
       
  1539                 {
       
  1540                 case WiFiProt::EWiFiCancel: //cancel pressed, cancel process
       
  1541                     {
       
  1542                     return EFalse;
       
  1543                     //break;
       
  1544                     }
       
  1545                 case WiFiProt::EWiFiOK: //settings configured already, we can return
       
  1546                     {
       
  1547                     return ETrue;
       
  1548                     //break;
       
  1549                     }
       
  1550                 case WiFiProt::EWifiNoAuto://proceed with normal setup
       
  1551                     {
       
  1552                     break;
       
  1553                     }  
       
  1554                 default:
       
  1555                     {
       
  1556                     User::Leave( KErrNotSupported );
       
  1557                     break;
       
  1558                     }                                              
       
  1559                 }    
       
  1560             }
       
  1561         switch( securityMode )
       
  1562             {
       
  1563             case EWlanConnectionExtentedSecurityModeOpen:
       
  1564                 {
       
  1565                 secmode = EWlanSecModeOpen;
       
  1566                 }
       
  1567                 break;
       
  1568                 
       
  1569             case EWlanConnectionExtentedSecurityModeWepOpen:
       
  1570             case EWlanConnectionExtentedSecurityModeWepShared:
       
  1571                 {
       
  1572                 secmode = EWlanSecModeWep;
       
  1573                 }
       
  1574                 break;
       
  1575                 
       
  1576             case EWlanConnectionExtentedSecurityMode802d1x:
       
  1577                 {
       
  1578                 secmode = EWlanSecMode802_1x;
       
  1579                 }
       
  1580                 break;
       
  1581                 
       
  1582             case EWlanConnectionExtentedSecurityModeWpa:
       
  1583             case EWlanConnectionExtentedSecurityModeWpaPsk:
       
  1584                 {
       
  1585                 secmode = EWlanSecModeWpa;
       
  1586                 }
       
  1587                 break;
       
  1588                 
       
  1589             case EWlanConnectionExtentedSecurityModeWpa2:
       
  1590             case EWlanConnectionExtentedSecurityModeWpa2Psk:
       
  1591                 {
       
  1592                 secmode = EWlanSecModeWpa2;
       
  1593                 }
       
  1594                 break;
       
  1595             case EWlanConnectionExtentedSecurityModeWapi:
       
  1596             case EWlanConnectionExtentedSecurityModeWapiPsk:
       
  1597                 {
       
  1598                 if ( iIsWAPISupported )
       
  1599                     {
       
  1600                     secmode = EWlanSecModeWAPI;
       
  1601                     }
       
  1602                 else
       
  1603                     {
       
  1604                     User::Leave( KErrCorrupt );
       
  1605                     }
       
  1606                 }
       
  1607                 break;
       
  1608             default:
       
  1609                 {
       
  1610                 User::Leave( KErrNotSupported );
       
  1611                 }
       
  1612             }
       
  1613 
       
  1614         // Let's check the security mode and if it's other than "none", then
       
  1615         // ask for the key.
       
  1616         HBufC* key = HBufC::NewLC( KWlanMaxKeyLength );    // security key
       
  1617         TPtr keyPtr( key->Des() );
       
  1618         TBool wepKeyInAsciiFormat;
       
  1619         switch( securityMode )
       
  1620             {
       
  1621             case EWlanConnectionExtentedSecurityModeWepOpen:
       
  1622             case EWlanConnectionExtentedSecurityModeWepShared:
       
  1623                 {
       
  1624     	          retval = iConnUiUtils->EasyWepDlg( &keyPtr, wepKeyInAsciiFormat );
       
  1625                 break;
       
  1626                 }
       
  1627             case EWlanConnectionExtentedSecurityModeWpaPsk:
       
  1628             case EWlanConnectionExtentedSecurityModeWpa2Psk:
       
  1629                 {
       
  1630             	  retval = iConnUiUtils->EasyWpaDlg( &keyPtr );
       
  1631                 break;
       
  1632                 }
       
  1633             case EWlanConnectionExtentedSecurityModeWapiPsk:
       
  1634                 {
       
  1635                 retval = iConnUiUtils->EasyWapiDlg( &keyPtr );
       
  1636                 break;
       
  1637                 }
       
  1638             case EWlanConnectionExtentedSecurityModeOpen:
       
  1639             case EWlanConnectionExtentedSecurityMode802d1x:
       
  1640             case EWlanConnectionExtentedSecurityModeWpa:
       
  1641             case EWlanConnectionExtentedSecurityModeWpa2:
       
  1642             case EWlanConnectionExtentedSecurityModeWapi:
       
  1643             default:
       
  1644                 {
       
  1645                 break;
       
  1646                 }
       
  1647             }
       
  1648 
       
  1649         // If retval is not ETrue here, then most probably the user has
       
  1650         // cancelled the password dialog ==> she has cancelled the whole
       
  1651         // process.
       
  1652         if ( retval )
       
  1653             {
       
  1654             // We have to convert the 8-bit SSID to 16-bit for CommsDat.
       
  1655             HBufC* ssid16 = HBufC::NewLC( ssid.Length() );
       
  1656             TPtr ssid16Ptr( ssid16->Des() );
       
  1657             ssid16Ptr.Copy( ssid );
       
  1658 
       
  1659             SetStringAttributeL( ECmName, *ssid16 );
       
  1660             SetStringAttributeL( EWlanSSID, *ssid16 );
       
  1661             // ConvertWLANConnectionStatesL( )converts WLAN connection state 
       
  1662             // (TWlanConnectionMode) into EInfra or EAdhoc (TWlanNetMode)
       
  1663             SetIntAttributeL( EWlanConnectionMode, 
       
  1664                     (TUint32) ConvertWLANConnectionStatesL( connectionMode ) );
       
  1665             SetIntAttributeL( EWlanSecurityMode, secmode );
       
  1666 
       
  1667             // Check if the network is hidden
       
  1668             TBool hidden( EFalse );
       
  1669 
       
  1670             // These values we already have so we are not interested of
       
  1671             // them
       
  1672             TWlanNetMode tempNetworkMode;
       
  1673             TWlanConnectionExtentedSecurityMode tempSecurityMode;
       
  1674 
       
  1675             TBool tempProtectedSetupSupported;
       
  1676 
       
  1677             TInt retVal( KErrNone );
       
  1678 
       
  1679             CCmWlanCoverageCheck* coverage = new( ELeave )CCmWlanCoverageCheck;
       
  1680             CleanupStack::PushL( coverage );
       
  1681 
       
  1682 	          // We need to catch leave value of Wlan scanning
       
  1683 	          TRAPD( err, retVal = coverage->ScanForPromptedSsidL( ssid, ETrue, 
       
  1684                    tempNetworkMode, 
       
  1685                    tempSecurityMode,
       
  1686                    tempProtectedSetupSupported ) );
       
  1687             if ( !retVal || err != KErrNone)
       
  1688                 {
       
  1689                 TRAPD( err, retVal = coverage->ScanForPromptedSsidL( ssid,
       
  1690 								     EFalse,
       
  1691 								     tempNetworkMode, 
       
  1692 								     tempSecurityMode,
       
  1693 								     tempProtectedSetupSupported ) );
       
  1694                 if ( err == KErrNone && retVal )
       
  1695                     {
       
  1696                     hidden = ETrue;
       
  1697                     }
       
  1698                 else // direct scan is ok, but network could not found with given ssid
       
  1699 		            {
       
  1700                 CleanupStack::PopAndDestroy( coverage ); // coverage
       
  1701                 CleanupStack::PopAndDestroy( ssid16 );
       
  1702                 CleanupStack::PopAndDestroy( key );
       
  1703 			
       
  1704                 TCmCommonUi::ShowNoteL( R_QTN_NETW_QUEST_IAP_INCOMPLETE_DELETE, TCmCommonUi::ECmOkNote );
       
  1705                 return EFalse;
       
  1706 		            }
       
  1707             }
       
  1708 
       
  1709             CleanupStack::PopAndDestroy( coverage ); // coverage
       
  1710             
       
  1711             SetBoolAttributeL( EWlanScanSSID, hidden );
       
  1712             CLOG_WRITE_1( "Is hidden[%d]", (TInt) hidden );
       
  1713 
       
  1714             // We have to store the security key as well.
       
  1715             if ( securityMode == EWlanConnectionExtentedSecurityModeWepOpen )
       
  1716                 {
       
  1717                 if ( !iWepSecSettings )
       
  1718                     {
       
  1719                     iWepSecSettings = CWEPSecuritySettings::NewL();
       
  1720                     }
       
  1721                 iWepSecSettings->SetKeyDataL( 0, *key,
       
  1722                                              wepKeyInAsciiFormat );
       
  1723                 // Note that the key will NOT be persisted at this very
       
  1724                 // point, but only after SaveL, which will be called
       
  1725                 // later on.
       
  1726                 }
       
  1727             else if ( securityMode == EWlanConnectionExtentedSecurityModeWpaPsk
       
  1728                       || securityMode == EWlanConnectionExtentedSecurityModeWpa2Psk )
       
  1729                 {
       
  1730                 if ( !iWpaSecSettings )
       
  1731                     {
       
  1732                     iWpaSecSettings = CWPASecuritySettings::NewL( ESecurityModeWpa );
       
  1733                     }
       
  1734                 iWpaSecSettings->SetWPAPreSharedKey( *key );
       
  1735 
       
  1736                 // Note that the key will NOT be persisted at this very
       
  1737                 // point, but only after SaveL, which will be called
       
  1738                 // later on.
       
  1739                 }
       
  1740             else if ( securityMode == EWlanConnectionExtentedSecurityModeWapiPsk )
       
  1741                 {
       
  1742                 if ( !iWAPISecSettings )
       
  1743                     {
       
  1744                     iWAPISecSettings = CWAPISecuritySettings::NewL();
       
  1745                     }
       
  1746                 
       
  1747                 iWAPISecSettings->SetPreSharedKeyL( CWAPISecuritySettings::EWapiKeyAscii, *key );
       
  1748                 // Note that the key will NOT be persisted at this very
       
  1749                 // point, but only after SaveL, which will be called
       
  1750                 // later on.
       
  1751                 }
       
  1752 
       
  1753             CLOG_WRITE( "InitializeWithUiL stored everything successfully" );
       
  1754 
       
  1755             CleanupStack::PopAndDestroy( ssid16 );
       
  1756             }
       
  1757         CleanupStack::PopAndDestroy( key );
       
  1758         }
       
  1759     else
       
  1760         {
       
  1761         if ( searchWlanReturn == KErrNotFound )
       
  1762             {
       
  1763             // no Wlan network found, continuing process...
       
  1764             HBufC* ssid16 = HBufC::NewLC( ssid.Length() );
       
  1765             TPtr ssid16Ptr( ssid16->Des() );
       
  1766             ssid16Ptr.Copy( ssid );
       
  1767             // write ssid and go on...
       
  1768             SetStringAttributeL( ECmName, *ssid16 );
       
  1769             SetStringAttributeL( EWlanSSID, *ssid16 );
       
  1770             CleanupStack::PopAndDestroy( ssid16 );
       
  1771             retval = ProceedWithManualL( ETrue ); // revert to fully manual...
       
  1772             }
       
  1773         else
       
  1774             {
       
  1775             retval = EFalse;
       
  1776             }
       
  1777         }
       
  1778     return retval;
       
  1779     }
       
  1780 
       
  1781 
       
  1782 // --------------------------------------------------------------------------
       
  1783 // CCmPluginWlan::ManuallyConfigureL
       
  1784 // --------------------------------------------------------------------------
       
  1785 //
       
  1786 TBool CCmPluginWlan::ManuallyConfigureL()
       
  1787     {
       
  1788     LOGGER_ENTERFN( "CCmPluginWlan::ManuallyConfigureL" );
       
  1789     
       
  1790     TBool proceed ( EFalse );
       
  1791     TBool askNWModeAndSec ( EFalse );
       
  1792     
       
  1793     // Step 1 - WLAN Network Name query (SSID)
       
  1794     // sets: ECmName, EWlanSSID
       
  1795     RBuf nwName;
       
  1796     nwName.CreateL( KCmWlanNWNameMaxLength );
       
  1797     CleanupClosePushL( nwName );
       
  1798 
       
  1799     proceed = ShowNWNameQueryL( nwName );
       
  1800     
       
  1801     TWlanConnectionExtentedSecurityMode securityMode =
       
  1802                                         EWlanConnectionExtentedSecurityModeOpen;
       
  1803             
       
  1804     TWpaMode wpaMode = EWpaModeUndefined;
       
  1805 
       
  1806     if ( proceed )
       
  1807         {
       
  1808         TWlanNetMode nwMode( EInfra );
       
  1809 
       
  1810         // Step 2 - SSID scan ( first broadcast, then direct )
       
  1811         // sets: EWlanConnectionMode
       
  1812         //       EWlanScanSSID
       
  1813         //       EWlanSecurityMode
       
  1814 
       
  1815         TWlanSsid ssid;
       
  1816         ssid.Copy( nwName );       
       
  1817         
       
  1818         TBool protectedSetupSupported = EFalse;
       
  1819         if ( ScanForWlanNwL( ssid, nwMode, securityMode, protectedSetupSupported ) )
       
  1820             {
       
  1821             if ( protectedSetupSupported )
       
  1822                 {
       
  1823                 TBool wifiret = ProtectedSetupL( ssid );
       
  1824                 switch ( wifiret )
       
  1825                     {
       
  1826                     case WiFiProt::EWiFiCancel: //cancel pressed, cancel process
       
  1827                         {
       
  1828                         CleanupStack::PopAndDestroy( &nwName ); //cleanup and return 
       
  1829                         return EFalse;
       
  1830                         //break;
       
  1831                         }
       
  1832                     case WiFiProt::EWiFiOK:
       
  1833                         {
       
  1834                         CleanupStack::PopAndDestroy( &nwName );//cleanup and return 
       
  1835                         //UpdateSecuritySettingsL();
       
  1836                         return ETrue;
       
  1837                         //break;
       
  1838                         }
       
  1839                     case WiFiProt::EWifiNoAuto://proceed with normal setup
       
  1840                         {
       
  1841                         break;
       
  1842                         }  
       
  1843                     default:
       
  1844                         {
       
  1845                         User::Leave( KErrNotSupported );
       
  1846                         break;
       
  1847                         }                                              
       
  1848                     }    
       
  1849                 }
       
  1850 
       
  1851             if ( securityMode == EWlanConnectionExtentedSecurityModeWpaPsk
       
  1852                  || securityMode == EWlanConnectionExtentedSecurityModeWpa2Psk )
       
  1853                 {
       
  1854                 wpaMode = EWpaModePreSharedKey;
       
  1855                 }
       
  1856             else if ( securityMode == EWlanConnectionExtentedSecurityModeWpa
       
  1857                       || securityMode == EWlanConnectionExtentedSecurityMode802d1x
       
  1858                       || securityMode == EWlanConnectionExtentedSecurityModeWpa2 )
       
  1859                 {
       
  1860                 wpaMode = EWpaModeEap;
       
  1861                 }
       
  1862             }
       
  1863         else
       
  1864             {
       
  1865             askNWModeAndSec = ETrue;
       
  1866             }
       
  1867         proceed = ProceedWithManualL ( askNWModeAndSec, nwMode, securityMode, wpaMode  );
       
  1868         }
       
  1869     CleanupStack::PopAndDestroy( &nwName );
       
  1870 
       
  1871     return proceed;
       
  1872     }
       
  1873 
       
  1874 
       
  1875 // --------------------------------------------------------------------------
       
  1876 // CCmPluginWlan::ProceedWithManualL
       
  1877 // --------------------------------------------------------------------------
       
  1878 //
       
  1879 TBool CCmPluginWlan::ProceedWithManualL( TBool aAskNWModeAndSec,
       
  1880                                          TWlanNetMode aNwMode, 
       
  1881                                          TWlanConnectionExtentedSecurityMode aSecurityMode,
       
  1882                                          TWpaMode aWpaMode )
       
  1883     {
       
  1884     LOGGER_ENTERFN( "CCmPluginWlan::ProceedWithManualL" );
       
  1885 
       
  1886     TInt proceed = ETrue;
       
  1887     if ( aAskNWModeAndSec )
       
  1888         {
       
  1889         // Step 3 - Network Mode
       
  1890         // sets: EWlanConnectionMode
       
  1891         //       EWlanScanSSID
       
  1892         proceed = SelectNWModeL( aNwMode );
       
  1893 
       
  1894         // Step 4 - Network security
       
  1895         // sets: EWlanSecurityMode
       
  1896         // Open       - finished
       
  1897         // WEP        - go to step 5
       
  1898         // WPA/802.1x - go to step 6
       
  1899         // WAPI       - go to step 9
       
  1900         if ( proceed )
       
  1901             {
       
  1902             proceed = ShowNWSecurityDlgL( aNwMode, aSecurityMode );
       
  1903             }
       
  1904         }
       
  1905         
       
  1906     // Security settings - Steps 5-8
       
  1907     if ( proceed && aSecurityMode != EWlanConnectionExtentedSecurityModeOpen )
       
  1908         {
       
  1909         switch ( aSecurityMode )
       
  1910             {
       
  1911             // Step 5 - Enter WEP key
       
  1912             // sets: wep key
       
  1913             // finished
       
  1914             case EWlanConnectionExtentedSecurityModeWepOpen:
       
  1915             case EWlanConnectionExtentedSecurityModeWepShared:
       
  1916                 {
       
  1917                 proceed = EnterWEPKeyL();
       
  1918                 break;
       
  1919                 }
       
  1920             // Step 6 - WPA/WPA2 mode
       
  1921             // sets: wpa/802.1x keys
       
  1922             // Pre-shared - go to step 7
       
  1923             // EAP        - go to step 8
       
  1924             case EWlanConnectionExtentedSecurityMode802d1x:
       
  1925                 TCmCommonUi::ShowNoteL( *( StringLoader::LoadLC( 
       
  1926                     R_QTN_NETW_CONSET_INFO_EAP_SETTINGS_DEFAULT ) ),
       
  1927                     TCmCommonUi::ECmInfoNote );
       
  1928                 CleanupStack::PopAndDestroy();
       
  1929                 break;
       
  1930                 
       
  1931             case EWlanConnectionExtentedSecurityModeWpa:
       
  1932             case EWlanConnectionExtentedSecurityModeWpaPsk:
       
  1933             case EWlanConnectionExtentedSecurityModeWpa2:
       
  1934             case EWlanConnectionExtentedSecurityModeWpa2Psk:
       
  1935                 {
       
  1936                 if ( aWpaMode == EWpaModeUndefined )
       
  1937                     {
       
  1938                     proceed = SelectWpaModeDialogL( aWpaMode );
       
  1939                     }
       
  1940 
       
  1941                 if ( proceed )
       
  1942                     {
       
  1943                     // Step 7 - Pre-shared key
       
  1944                     // sets: pre-shared key
       
  1945                     // finished
       
  1946                     if ( aWpaMode == EWpaModePreSharedKey )
       
  1947                         {
       
  1948                         proceed = EnterWpaPreSharedKeyL();
       
  1949                         }
       
  1950                     // Step 8 - EAP selection note
       
  1951                     else
       
  1952                         {
       
  1953                         TCmCommonUi::ShowNoteL( *( StringLoader::LoadLC( 
       
  1954                             R_QTN_NETW_CONSET_INFO_EAP_SETTINGS_DEFAULT ) ),
       
  1955                             TCmCommonUi::ECmInfoNote );
       
  1956                         CleanupStack::PopAndDestroy();
       
  1957                         }
       
  1958                     }
       
  1959                 break;
       
  1960                 }
       
  1961             // Step 9
       
  1962             case EWlanConnectionExtentedSecurityModeWapi:
       
  1963             case EWlanConnectionExtentedSecurityModeWapiPsk:
       
  1964                 {
       
  1965                 if ( iIsWAPISupported )
       
  1966                     {
       
  1967                     if ( aSecurityMode == EWlanConnectionExtentedSecurityModeWapiPsk )
       
  1968                         {
       
  1969                         proceed = EnterWAPIPreSharedKeyL();
       
  1970                         }
       
  1971                     }
       
  1972                 else
       
  1973                     {
       
  1974                     User::Leave( KErrCorrupt );
       
  1975                     }
       
  1976                 break;
       
  1977                 }
       
  1978             default:
       
  1979                 {
       
  1980                 User::Leave( KErrNotSupported );
       
  1981                 break;
       
  1982                 }
       
  1983             }
       
  1984         }
       
  1985         
       
  1986     // Store all the unsaved settings
       
  1987   /* if ( proceed )
       
  1988         {
       
  1989         UpdateSecuritySettingsL();
       
  1990         }*/
       
  1991     return proceed;
       
  1992     }
       
  1993     
       
  1994 // --------------------------------------------------------------------------
       
  1995 // CCmPluginWlan::ShowNWNameQueryL
       
  1996 // --------------------------------------------------------------------------
       
  1997 //
       
  1998 TBool CCmPluginWlan::ShowNWNameQueryL( TDes& aNwName )
       
  1999     {
       
  2000     LOGGER_ENTERFN( "CCmPluginWlan::ShowNWNameQueryL" );
       
  2001     
       
  2002     TBool retVal ( EFalse );
       
  2003     
       
  2004     retVal = TCmCommonUi::ShowConfirmationQueryWithInputL( 
       
  2005                                             R_QTN_WLAN_PRMPT_NETWORK_NAME,
       
  2006                                             aNwName );
       
  2007     if ( retVal )
       
  2008         {
       
  2009         SetStringAttributeL( ECmName, aNwName );
       
  2010         SetStringAttributeL( EWlanSSID, aNwName );
       
  2011         
       
  2012         retVal = ETrue;
       
  2013         }
       
  2014     return retVal;
       
  2015     }
       
  2016 
       
  2017 
       
  2018 // --------------------------------------------------------------------------
       
  2019 // CCmPluginWlan::ScanForWlanNwL
       
  2020 // --------------------------------------------------------------------------
       
  2021 //
       
  2022 TBool CCmPluginWlan::ScanForWlanNwL( 
       
  2023 #ifdef __WINS__
       
  2024                          TWlanSsid& /*aSsid*/, TWlanNetMode& /*aNetworkMode*/,
       
  2025                          TWlanConnectionExtentedSecurityMode& /*aSecurityMode*/,
       
  2026                          TBool& /*aProtectedSetupSupported*/ )
       
  2027 #else
       
  2028                          TWlanSsid& aSsid, TWlanNetMode& aNetworkMode,
       
  2029                          TWlanConnectionExtentedSecurityMode& aSecurityMode,
       
  2030                          TBool& aProtectedSetupSupported )
       
  2031 #endif  // __WINS__
       
  2032     {
       
  2033     LOGGER_ENTERFN( "CCmPluginWlan::ScanForWlanNwL" );
       
  2034     
       
  2035     TBool retVal ( EFalse );
       
  2036 
       
  2037     DestroyWaitDialog();
       
  2038 
       
  2039     iWaitDialog = new( ELeave )CAknWaitDialog
       
  2040                     ( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ), ETrue );
       
  2041     iWaitDialog->ExecuteLD( R_SEARCHING_WLAN_WAIT_NOTE ); 
       
  2042 
       
  2043 #ifndef __WINS__
       
  2044     TBool hidden ( EFalse );
       
  2045     
       
  2046     CCmWlanCoverageCheck* coverage = new( ELeave )CCmWlanCoverageCheck;
       
  2047     CleanupStack::PushL( coverage );
       
  2048 
       
  2049     CLOG_WRITE( "Coverage created, calling ScanForPromptedSsidL, broadcast" );
       
  2050     retVal = coverage->ScanForPromptedSsidL( aSsid, ETrue, aNetworkMode, 
       
  2051                                              aSecurityMode,
       
  2052                                              aProtectedSetupSupported );
       
  2053     CLOG_WRITE( "ScanForPromptedSsidL returned" );
       
  2054     
       
  2055     if ( !retVal )
       
  2056         {
       
  2057         CLOG_WRITE( "Calling ScanForPromptedSsidL, direct" );
       
  2058         retVal = coverage->ScanForPromptedSsidL( aSsid, EFalse, aNetworkMode, 
       
  2059                                                  aSecurityMode,
       
  2060                                                  aProtectedSetupSupported );
       
  2061         CLOG_WRITE( "ScanForPromptedSsidL returned" );
       
  2062 
       
  2063         if ( retVal )
       
  2064             {
       
  2065             hidden = ETrue;
       
  2066             }
       
  2067         }
       
  2068 
       
  2069     CleanupStack::PopAndDestroy( coverage );
       
  2070 
       
  2071     if ( retVal )
       
  2072         {
       
  2073         CLOG_WRITE( "Ssid has been found" );
       
  2074 
       
  2075         // Network mode
       
  2076         SetIntAttributeL( EWlanConnectionMode, aNetworkMode );
       
  2077         // Security mode
       
  2078         SetIntAttributeL( EWlanSecurityMode, 
       
  2079                           ConvertConnectionSecurityModeToSecModeL( 
       
  2080                           aSecurityMode ) );
       
  2081         // Hidden
       
  2082         SetBoolAttributeL( EWlanScanSSID, hidden );    
       
  2083         }
       
  2084     else    
       
  2085 #else   // __WINS
       
  2086   if ( !retVal )  
       
  2087 #endif  // __WINS
       
  2088         {
       
  2089         HBufC* stringLabel = StringLoader::LoadLC( 
       
  2090                                         R_INFO_NO_NETWORKS_FOUND );
       
  2091 
       
  2092         CAknGlobalNote * note = CAknGlobalNote::NewL();
       
  2093         CleanupStack::PushL(note);
       
  2094         note->ShowNoteL(EAknGlobalInformationNote, *stringLabel);
       
  2095         CleanupStack::PopAndDestroy(note);
       
  2096         CleanupStack::PopAndDestroy( stringLabel );        
       
  2097         }
       
  2098 
       
  2099 
       
  2100     DestroyWaitDialog();
       
  2101 
       
  2102     return retVal;
       
  2103     }
       
  2104 
       
  2105 
       
  2106 // --------------------------------------------------------------------------
       
  2107 // CCmPluginWlan::SelectNWModeL
       
  2108 // --------------------------------------------------------------------------
       
  2109 //
       
  2110 TBool CCmPluginWlan::SelectNWModeL( TWlanNetMode& aNwMode )
       
  2111     {
       
  2112     LOGGER_ENTERFN( "CCmPluginWlan::SelectNWModeL" );
       
  2113     
       
  2114     TBool retVal ( EFalse );
       
  2115     
       
  2116     // Title
       
  2117     HBufC* title = StringLoader::LoadLC( 
       
  2118                         R_QTN_NETW_CONSET_PRMPT_WLAN_NW_MODE_AND_STATUS );
       
  2119     TPtr ptrTitle ( title->Des() );
       
  2120     
       
  2121     // Items
       
  2122     CDesCArrayFlat* items = 
       
  2123 	            new ( ELeave ) CDesCArrayFlat( KCmArrayMediumGranularity );
       
  2124     CleanupStack::PushL( items );
       
  2125     
       
  2126     TInt i = 0;
       
  2127     while ( KWlanNetworkModeConvTable[i].iResId != KEndOfArray )
       
  2128         {
       
  2129         items->AppendL( 
       
  2130             *StringLoader::LoadLC( KWlanNetworkModeConvTable[i].iResId ) );
       
  2131         CleanupStack::PopAndDestroy(); 
       
  2132         i++;
       
  2133         }
       
  2134         
       
  2135     // Show the dialog
       
  2136     TInt selection(0);
       
  2137     if ( TCmCommonUi::ShowPopupListL( ptrTitle , 
       
  2138                                       items,
       
  2139                                       NULL,
       
  2140                                       R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT,
       
  2141                                       selection ) )
       
  2142         {
       
  2143         // result:        
       
  2144         i = 0;
       
  2145         
       
  2146         aNwMode = 
       
  2147             ( TWlanNetMode ) KWlanNetworkModeConvTable[selection].iNwMode;
       
  2148         
       
  2149         // Network mode
       
  2150         SetIntAttributeL( EWlanConnectionMode, aNwMode );
       
  2151         
       
  2152         // Network status
       
  2153         SetBoolAttributeL( EWlanScanSSID, 
       
  2154                            KWlanNetworkModeConvTable[selection].iHidden );
       
  2155                            
       
  2156         retVal = ETrue;
       
  2157         }
       
  2158                                       
       
  2159     CleanupStack::Pop( items );
       
  2160     CleanupStack::PopAndDestroy( title );
       
  2161     return retVal;
       
  2162     }
       
  2163 
       
  2164 
       
  2165 // --------------------------------------------------------------------------
       
  2166 // CCmPluginWlan::ShowNWSecurityDlgL
       
  2167 // --------------------------------------------------------------------------
       
  2168 //
       
  2169 TBool CCmPluginWlan::ShowNWSecurityDlgL( TWlanNetMode aNwMode, 
       
  2170                                 TWlanConnectionExtentedSecurityMode& aSecurityMode )
       
  2171     {
       
  2172     LOGGER_ENTERFN( "CCmPluginWlan::ShowNWSecurityDlgL" );
       
  2173 
       
  2174     TBool retVal ( EFalse );    
       
  2175 
       
  2176     // Collect NW Security Mode items
       
  2177 	CDesCArrayFlat* items = 
       
  2178 	            new ( ELeave ) CDesCArrayFlat( KCmArrayMediumGranularity );
       
  2179     
       
  2180     TInt i = 0;
       
  2181     while ( KWlanSecurityModeConvTable[i].iResId != KEndOfArray )
       
  2182         {
       
  2183         TWlanSecMode secMode = 
       
  2184                 ( TWlanSecMode ) KWlanSecurityModeConvTable[i].iSecurityMode;
       
  2185         
       
  2186         if ( ( secMode == EWlanSecModeOpen || secMode == EWlanSecModeWep )
       
  2187                 || aNwMode == EInfra )
       
  2188              {
       
  2189             items->AppendL( *StringLoader::LoadLC( 
       
  2190                                 KWlanSecurityModeConvTable[i].iResId ) );
       
  2191             CleanupStack::PopAndDestroy(); 
       
  2192             }
       
  2193         i++;
       
  2194         // don't show WAPI if it's not supported
       
  2195         if ( !iIsWAPISupported )
       
  2196             {
       
  2197             if ( KWlanSecurityModeConvTable[i].iSecurityMode == EWlanSecModeWAPI )
       
  2198                 {
       
  2199                 break;
       
  2200                 }
       
  2201             }
       
  2202         }
       
  2203    
       
  2204     // Title
       
  2205     HBufC* title = StringLoader::LoadLC( 
       
  2206                             R_QTN_NETW_CONSET_PRMPT_WLAN_NW_SECURITY_MODE );
       
  2207     TPtr ptrTitle ( title->Des() );
       
  2208     
       
  2209     TInt selection = 0;
       
  2210     
       
  2211     // Show the dialog
       
  2212     if ( TCmCommonUi::ShowPopupListL( ptrTitle , 
       
  2213                                       items,
       
  2214                                       NULL,
       
  2215                                       R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT,
       
  2216                                       selection ) )
       
  2217         {
       
  2218         // result:
       
  2219         aSecurityMode = 
       
  2220                 ConvertSecModeToConnectionSecurityModeL( ( TWlanSecMode )
       
  2221                         KWlanSecurityModeConvTable[selection].iSecurityMode );
       
  2222         SetIntAttributeL( EWlanSecurityMode, 
       
  2223                         KWlanSecurityModeConvTable[selection].iSecurityMode );
       
  2224         retVal = ETrue;
       
  2225         }
       
  2226     CleanupStack::PopAndDestroy( title );
       
  2227     return retVal;
       
  2228     }
       
  2229 
       
  2230 
       
  2231 // --------------------------------------------------------------------------
       
  2232 // CCmPluginWlan::EnterWEPKeyL
       
  2233 // --------------------------------------------------------------------------
       
  2234 //
       
  2235 TBool CCmPluginWlan::EnterWEPKeyL()
       
  2236     {
       
  2237     LOGGER_ENTERFN( "CCmPluginWlan::EnterWEPKeyL" );
       
  2238     
       
  2239     TBool retVal ( EFalse );
       
  2240     
       
  2241     // Security key
       
  2242     HBufC* key = HBufC::NewLC( KWlanMaxKeyLength );
       
  2243     TPtr keyPtr( key->Des() );
       
  2244     TBool wepKeyInAsciiFormat ( EFalse );
       
  2245     
       
  2246     if ( !iConnUiUtils )
       
  2247         {
       
  2248         iConnUiUtils = CConnectionUiUtilities::NewL();
       
  2249         }
       
  2250     
       
  2251     if ( iConnUiUtils->EasyWepDlg( &keyPtr, wepKeyInAsciiFormat ) )
       
  2252         {
       
  2253         if ( !iWepSecSettings )
       
  2254             {
       
  2255             iWepSecSettings = CWEPSecuritySettings::NewL();
       
  2256             }       
       
  2257         iWepSecSettings->SetKeyDataL( 0, 
       
  2258                                       *key,
       
  2259                                       wepKeyInAsciiFormat );
       
  2260         retVal = ETrue;
       
  2261         }
       
  2262     CleanupStack::PopAndDestroy( key );    
       
  2263     return retVal;
       
  2264     }
       
  2265 
       
  2266 
       
  2267 // --------------------------------------------------------------------------
       
  2268 // CCmPluginWlan::EnterWpaPreSharedKeyL
       
  2269 // --------------------------------------------------------------------------
       
  2270 //
       
  2271 TBool CCmPluginWlan::EnterWpaPreSharedKeyL()
       
  2272     {
       
  2273     LOGGER_ENTERFN( "CCmPluginWlan::EnterWpaPreSharedKeyL" );
       
  2274     
       
  2275     TBool retVal ( EFalse );
       
  2276     
       
  2277     HBufC* key = HBufC::NewLC( KWlanMaxKeyLength );
       
  2278     TPtr keyPtr( key->Des() );
       
  2279 
       
  2280     if ( !iConnUiUtils )
       
  2281         {
       
  2282         iConnUiUtils = CConnectionUiUtilities::NewL();
       
  2283         }
       
  2284     
       
  2285     if ( iConnUiUtils->EasyWpaDlg( &keyPtr ) )
       
  2286         {
       
  2287         if ( !iWpaSecSettings )
       
  2288             {
       
  2289             iWpaSecSettings = CWPASecuritySettings::NewL( ESecurityModeWpa );
       
  2290             }
       
  2291         iWpaSecSettings->SetWPAPreSharedKey( *key );
       
  2292         retVal = ETrue;
       
  2293         }
       
  2294     CleanupStack::PopAndDestroy( key );  
       
  2295     return retVal;
       
  2296     }
       
  2297 
       
  2298 
       
  2299 // --------------------------------------------------------------------------
       
  2300 // CCmPluginWlan::SelectWpaModeDialogL
       
  2301 // --------------------------------------------------------------------------
       
  2302 //
       
  2303 TBool CCmPluginWlan::SelectWpaModeDialogL( TWpaMode& aWpaMode )
       
  2304     {
       
  2305     LOGGER_ENTERFN( "CCmPluginWlan::SelectWpaModeDialogL" );
       
  2306     
       
  2307     TBool retVal ( EFalse );
       
  2308     
       
  2309     // Collect NW Security Mode items
       
  2310     CDesCArrayFlat* items = 
       
  2311 	            new ( ELeave ) CDesCArrayFlat( KCmArrayMediumGranularity );
       
  2312    
       
  2313     // Title
       
  2314     HBufC* title = 
       
  2315             StringLoader::LoadLC( R_QTN_NETW_CONSET_PRMPT_WLAN_WPA_MODE );
       
  2316     TPtr ptrTitle ( title->Des() );
       
  2317     
       
  2318     TInt selection = 0;
       
  2319     
       
  2320     // EWpaModeEap
       
  2321     items->AppendL( *StringLoader::LoadLC(
       
  2322                                     R_QTN_NETW_CONSET_PRMPT_WPA_MODE_EAP ) );
       
  2323     CleanupStack::PopAndDestroy(); 
       
  2324     
       
  2325     // EWpaModePreSharedKey
       
  2326     items->AppendL( *StringLoader::LoadLC( 
       
  2327                                     R_QTN_NETW_CONSET_PRMPT_WPA_MODE_PSK ) );
       
  2328     CleanupStack::PopAndDestroy(); 
       
  2329         
       
  2330     // Show the dialog    
       
  2331     if( TCmCommonUi::ShowPopupListL( ptrTitle, 
       
  2332                                      items,
       
  2333                                      NULL,
       
  2334                                      R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT,
       
  2335                                      selection ) )
       
  2336         {
       
  2337         aWpaMode = ( TWpaMode ) selection;
       
  2338         retVal = ETrue;
       
  2339         }
       
  2340     
       
  2341     CleanupStack::PopAndDestroy( title );
       
  2342     
       
  2343     return retVal;
       
  2344     }
       
  2345 
       
  2346 
       
  2347 // --------------------------------------------------------------------------
       
  2348 // CCmPluginWlan::UpdateSecurityModeL
       
  2349 // --------------------------------------------------------------------------
       
  2350 //
       
  2351 void CCmPluginWlan::UpdateSecurityModeL( )
       
  2352     {
       
  2353     LOGGER_ENTERFN( "CCmPluginWlan::UpdateSecurityModeL" );
       
  2354     
       
  2355     TUint32 secmode = GetIntAttributeL( EWlanSecurityMode );
       
  2356 
       
  2357     TUint32 wlaniapid = iIapRecord->iService;
       
  2358 
       
  2359     switch ( secmode )
       
  2360         {
       
  2361         case EWlanSecModeOpen:
       
  2362             {
       
  2363             break;
       
  2364             }
       
  2365         case EWlanSecModeWep:
       
  2366             {
       
  2367             if ( iWepSecSettings )
       
  2368                 {
       
  2369                 delete iWepSecSettings;
       
  2370                 iWepSecSettings = NULL;
       
  2371                 }
       
  2372             iWepSecSettings = CWEPSecuritySettings::NewL();
       
  2373             iWepSecSettings->LoadL( wlaniapid, Session() );
       
  2374             break;
       
  2375             }
       
  2376         case EWlanSecMode802_1x:
       
  2377             {
       
  2378             if ( iWpaSecSettings )
       
  2379                 {
       
  2380                 delete iWpaSecSettings;
       
  2381                 iWpaSecSettings = NULL;
       
  2382                 }
       
  2383             iWpaSecSettings = 
       
  2384                 CWPASecuritySettings::NewL( ESecurityMode8021x );
       
  2385             iWpaSecSettings->LoadL( wlaniapid, Session() );
       
  2386             break;
       
  2387             }
       
  2388         case EWlanSecModeWpa:
       
  2389         case EWlanSecModeWpa2:
       
  2390             {
       
  2391             if ( iWpaSecSettings )
       
  2392                 {
       
  2393                 delete iWpaSecSettings;
       
  2394                 iWpaSecSettings = NULL;
       
  2395                 }
       
  2396             iWpaSecSettings = 
       
  2397                   CWPASecuritySettings::NewL( ESecurityModeWpa );
       
  2398             iWpaSecSettings->LoadL( wlaniapid, Session() );
       
  2399             break;
       
  2400             }
       
  2401         case EWlanSecModeWAPI:
       
  2402             {
       
  2403             if ( iIsWAPISupported )
       
  2404                 {
       
  2405                 if ( iWAPISecSettings )
       
  2406                     {
       
  2407                     delete iWAPISecSettings;
       
  2408                     iWAPISecSettings = NULL;
       
  2409                     }
       
  2410                 iWAPISecSettings = CWAPISecuritySettings::NewL();
       
  2411                 if ( iIapRecord->RecordId() )
       
  2412                     {
       
  2413                     iWAPISecSettings->LoadL( iIapRecord->RecordId(), Session() );
       
  2414                     }
       
  2415                 }
       
  2416             else
       
  2417                 {
       
  2418                 User::Leave( KErrCorrupt );
       
  2419                 }
       
  2420             break;
       
  2421             }
       
  2422         default:
       
  2423             {
       
  2424             User::Leave( KErrNotSupported );
       
  2425             break;
       
  2426             }
       
  2427         }
       
  2428     }
       
  2429 
       
  2430 // --------------------------------------------------------------------------
       
  2431 // CCmPluginWlan::CopyAdditionalDataL
       
  2432 // --------------------------------------------------------------------------
       
  2433 //
       
  2434 void CCmPluginWlan::CopyAdditionalDataL( CCmPluginBaseEng& aDestInst ) const
       
  2435     {
       
  2436     LOGGER_ENTERFN( "CCmPluginWlan::CopyAdditionalDataL" );
       
  2437     
       
  2438     STATIC_CAST( CCmPluginWlan*, &aDestInst )->
       
  2439                     SetAsCopyOf( iIapRecord->iService );
       
  2440     }
       
  2441     
       
  2442 
       
  2443 // --------------------------------------------------------------------------
       
  2444 // CCmPluginWlan::SetAsCopyOf
       
  2445 // --------------------------------------------------------------------------
       
  2446 //
       
  2447 void CCmPluginWlan::SetAsCopyOf( TUint32 aBaseIapID )
       
  2448     {
       
  2449     LOGGER_ENTERFN( "CCmPluginWlan::SetAsCopyOf" );
       
  2450     
       
  2451     iIsCopy = ETrue;
       
  2452     
       
  2453     iCopiedFromIapId = aBaseIapID;    
       
  2454     }
       
  2455 
       
  2456 // ---------------------------------------------------------
       
  2457 // CCmPluginWlan::DeleteSecuritySettingsL
       
  2458 // ---------------------------------------------------------
       
  2459 //    
       
  2460 void CCmPluginWlan::DeleteSecuritySettingsL()
       
  2461     {
       
  2462     LOGGER_ENTERFN( "CCmPluginWlan::DeleteSecuritySettingsL" );
       
  2463 
       
  2464     TUint32 wlaniapid = iIapRecord->iService;
       
  2465     
       
  2466     // check security mode and existence of sec.settings
       
  2467     if (iWlanServiceRecord->RecordId() )
       
  2468         {// ha sat least WLAN service record, may start to wonder...
       
  2469         // wlan service record will be deleted separatelly!
       
  2470         // get current security mode
       
  2471         TUint32 secmode = iWlanServiceRecord->iWlanSecMode;
       
  2472      
       
  2473         switch ( secmode )
       
  2474             {     
       
  2475             case EWlanSecModeOpen:
       
  2476             case EWlanSecModeWep:
       
  2477                 {
       
  2478                 // nothing to do here
       
  2479                 break;
       
  2480                 }
       
  2481             case EWlanSecMode802_1x:
       
  2482                 {                
       
  2483                 if ( !iWpaSecSettings )
       
  2484                     {
       
  2485                     iWpaSecSettings = 
       
  2486                         CWPASecuritySettings::NewL( ESecurityMode8021x );
       
  2487                     }
       
  2488                 iWpaSecSettings->DeleteL( wlaniapid );
       
  2489                 break;
       
  2490                 }
       
  2491             case EWlanSecModeWpa:
       
  2492             case EWlanSecModeWpa2:
       
  2493                 {
       
  2494                 if ( !iWpaSecSettings )
       
  2495                     {
       
  2496                     iWpaSecSettings = 
       
  2497                         CWPASecuritySettings::NewL( ESecurityModeWpa );
       
  2498                     }
       
  2499                 iWpaSecSettings->DeleteL( wlaniapid );
       
  2500                 break;
       
  2501                 }
       
  2502             case EWlanSecModeWAPI:
       
  2503                 if ( iIsWAPISupported )
       
  2504                     {
       
  2505                     if ( !iWAPISecSettings )
       
  2506                         {
       
  2507                         iWAPISecSettings = CWAPISecuritySettings::NewL();
       
  2508                         }
       
  2509                     TUint32 serviceId = iWlanServiceRecord->RecordId();
       
  2510                     iWAPISecSettings->DeleteAPSpecificDataL( serviceId );
       
  2511                     }
       
  2512                 else
       
  2513                     {
       
  2514                     User::Leave( KErrCorrupt );
       
  2515                     }
       
  2516                 break;
       
  2517             default:
       
  2518                 {
       
  2519                 User::Leave( KErrNotSupported );
       
  2520                 // do nothing in urel
       
  2521                 break;
       
  2522                 }
       
  2523             }
       
  2524         }
       
  2525     // if there is no wlan service record, 
       
  2526     // then there can be no security settings, skipping...
       
  2527     }
       
  2528 
       
  2529 
       
  2530 // ---------------------------------------------------------
       
  2531 // CCmPluginWlan::SetDnsIpFromServer
       
  2532 // ---------------------------------------------------------
       
  2533 //    
       
  2534 void CCmPluginWlan::SetDnsIpFromServerL()
       
  2535     {
       
  2536     LOGGER_ENTERFN( "CCmPluginWlan::SetDnsIpFromServer" );
       
  2537     
       
  2538     HBufC* ip1 = GetStringAttributeL( EWlanIpNameServer1 );
       
  2539     CleanupStack::PushL( ip1 );
       
  2540 
       
  2541     HBufC* ip2 = GetStringAttributeL( EWlanIpNameServer2 );
       
  2542     CleanupStack::PushL( ip2 );
       
  2543     
       
  2544 
       
  2545     if ( ( ip1->Compare( KDynIpAddress ) == 0 ) &&
       
  2546          ( ip2->Compare( KDynIpAddress ) == 0 ) )
       
  2547         {
       
  2548         SetBoolAttributeL( EWlanIpDNSAddrFromServer, ETrue );
       
  2549         }
       
  2550     else
       
  2551         {
       
  2552         SetBoolAttributeL( EWlanIpDNSAddrFromServer, EFalse );
       
  2553         }
       
  2554     CleanupStack::PopAndDestroy( 2,ip1 );
       
  2555     }
       
  2556 
       
  2557 
       
  2558 // ---------------------------------------------------------
       
  2559 // CCmPluginWlan::SetDns6IpFromServer
       
  2560 // ---------------------------------------------------------
       
  2561 //
       
  2562 void CCmPluginWlan::SetDns6IpFromServerL()
       
  2563     {
       
  2564     LOGGER_ENTERFN( "CCmPluginWlan::SetDns6IpFromServer" );
       
  2565 
       
  2566     HBufC* ip1 = GetStringAttributeL( EWlanIp6NameServer1 );
       
  2567     CleanupStack::PushL( ip1 );
       
  2568 
       
  2569     HBufC* ip2 = GetStringAttributeL( EWlanIp6NameServer2 );
       
  2570     CleanupStack::PushL( ip2 );
       
  2571 
       
  2572     if ( ( ip1->Compare( KDynIpv6Address ) == 0 ) &&
       
  2573          ( ip2->Compare( KDynIpv6Address ) == 0 ) )
       
  2574         {
       
  2575         SetBoolAttributeL( EWlanIp6DNSAddrFromServer, ETrue );
       
  2576         }
       
  2577     else
       
  2578         {
       
  2579         SetBoolAttributeL( EWlanIp6DNSAddrFromServer, EFalse );
       
  2580         }
       
  2581     CleanupStack::PopAndDestroy( 2,ip1 );
       
  2582     }
       
  2583 
       
  2584 
       
  2585 // ----------------------------------------------------------------------------
       
  2586 // CCmPluginWlan::CheckNetworkCoverageL()
       
  2587 // ----------------------------------------------------------------------------
       
  2588 //        
       
  2589 TInt CCmPluginWlan::CheckNetworkCoverageL() const
       
  2590     {
       
  2591     LOGGER_ENTERFN("CCmPluginWlan::CheckNetworkCoverageL");
       
  2592     
       
  2593     TInt retVal( 0 ); 
       
  2594     
       
  2595 #ifdef __WINS__
       
  2596     retVal = 1;
       
  2597 #else
       
  2598     CCmWlanCoverageCheck* coverage = new (ELeave) CCmWlanCoverageCheck;
       
  2599     CleanupStack::PushL( coverage );
       
  2600 
       
  2601     CLOG_WRITE( "Coverage created, calling GetCoverageL" );
       
  2602     retVal = coverage->GetCoverageL();
       
  2603     CLOG_WRITE( "GetCoverageL returned" );
       
  2604     
       
  2605     CleanupStack::PopAndDestroy( coverage );
       
  2606 #endif  // __WINS
       
  2607     return retVal;
       
  2608     }
       
  2609 
       
  2610 
       
  2611 // ----------------------------------------------------------------------------
       
  2612 // CCmPluginWlan::ConvertConnectionSecurityModeToSecModeL()
       
  2613 // ----------------------------------------------------------------------------
       
  2614 //        
       
  2615 TWlanSecMode CCmPluginWlan::ConvertConnectionSecurityModeToSecModeL(
       
  2616                                     TWlanConnectionExtentedSecurityMode aSecurityMode )
       
  2617     {
       
  2618     LOGGER_ENTERFN( "CCmPluginWlan::ConvertConnectionSecurityModeToSecModeL " );
       
  2619 
       
  2620     switch( aSecurityMode )
       
  2621         {
       
  2622         case EWlanConnectionExtentedSecurityModeOpen:
       
  2623             {
       
  2624             return EWlanSecModeOpen;
       
  2625             }
       
  2626         
       
  2627         case EWlanConnectionExtentedSecurityModeWepOpen:
       
  2628         case EWlanConnectionExtentedSecurityModeWepShared:
       
  2629             {
       
  2630             return EWlanSecModeWep;
       
  2631             }
       
  2632         
       
  2633         case EWlanConnectionExtentedSecurityMode802d1x:
       
  2634             {
       
  2635             return EWlanSecMode802_1x;
       
  2636             }
       
  2637         
       
  2638         case EWlanConnectionExtentedSecurityModeWpa:
       
  2639         case EWlanConnectionExtentedSecurityModeWpaPsk:
       
  2640         case EWlanConnectionExtentedSecurityModeWpa2:
       
  2641         case EWlanConnectionExtentedSecurityModeWpa2Psk:
       
  2642             {
       
  2643             return EWlanSecModeWpa;
       
  2644             }
       
  2645         case EWlanConnectionExtentedSecurityModeWapi:
       
  2646         case EWlanConnectionExtentedSecurityModeWapiPsk:
       
  2647             {
       
  2648             if ( iIsWAPISupported )
       
  2649                 {
       
  2650                 return EWlanSecModeWAPI;
       
  2651                 }
       
  2652             else
       
  2653                 {
       
  2654                 User::Leave( KErrCorrupt );
       
  2655                 }
       
  2656             }
       
  2657         default:
       
  2658             {
       
  2659             User::Leave( KErrNotSupported );
       
  2660             }
       
  2661         }
       
  2662 
       
  2663     return EWlanSecModeOpen;
       
  2664     }
       
  2665 
       
  2666 
       
  2667 // ----------------------------------------------------------------------------
       
  2668 // CCmPluginWlan::ConvertSecModeToConnectionSecurityModeL()
       
  2669 // ----------------------------------------------------------------------------
       
  2670 //        
       
  2671 TWlanConnectionExtentedSecurityMode 
       
  2672         CCmPluginWlan::ConvertSecModeToConnectionSecurityModeL(
       
  2673                                                         TWlanSecMode aSecMode )
       
  2674     {
       
  2675     LOGGER_ENTERFN( "CCmPluginWlan::ConvertSecModeToConnectionSecurityModeL " );
       
  2676 
       
  2677     switch( aSecMode )
       
  2678         {
       
  2679         case EWlanSecModeOpen:
       
  2680             {
       
  2681             return EWlanConnectionExtentedSecurityModeOpen;
       
  2682             }
       
  2683         
       
  2684         case EWlanSecModeWep:
       
  2685             {
       
  2686             return EWlanConnectionExtentedSecurityModeWepOpen;
       
  2687             }
       
  2688         
       
  2689         case EWlanSecMode802_1x:
       
  2690             {
       
  2691             return EWlanConnectionExtentedSecurityMode802d1x;
       
  2692             }
       
  2693         
       
  2694         case EWlanSecModeWpa:
       
  2695         case EWlanSecModeWpa2:
       
  2696             {
       
  2697             return EWlanConnectionExtentedSecurityModeWpa;
       
  2698             }
       
  2699         case EWlanSecModeWAPI:
       
  2700             {
       
  2701             if ( iIsWAPISupported )
       
  2702                 {
       
  2703                 return EWlanConnectionExtentedSecurityModeWapi;
       
  2704                 }
       
  2705             else
       
  2706                 {
       
  2707                 User::Leave( KErrCorrupt );
       
  2708                 }
       
  2709             }
       
  2710         
       
  2711         default:
       
  2712             {
       
  2713             User::Leave( KErrNotSupported );
       
  2714             }
       
  2715         }
       
  2716 
       
  2717     return EWlanConnectionExtentedSecurityModeOpen;
       
  2718     }
       
  2719 
       
  2720 
       
  2721 // ---------------------------------------------------------
       
  2722 // CCmPluginWlan::DestroyWaitDialog()
       
  2723 // ---------------------------------------------------------
       
  2724 //
       
  2725 void CCmPluginWlan::DestroyWaitDialog()
       
  2726     {
       
  2727     LOGGER_ENTERFN( "CCmPluginWlan::DestroyWaitDialog " );
       
  2728 
       
  2729     delete iWaitDialog;
       
  2730     iWaitDialog = NULL;
       
  2731     }
       
  2732 
       
  2733 // ---------------------------------------------------------------------------
       
  2734 // CCmPluginWlan::SetDaemonNameL
       
  2735 // ---------------------------------------------------------------------------
       
  2736 //
       
  2737 void CCmPluginWlan::SetDaemonNameL()
       
  2738     {
       
  2739     LOGGER_ENTERFN( "CCmPluginWlan::SetDaemonNameL" );
       
  2740 
       
  2741     // we have to check first that these values has not been 
       
  2742     // set(or changed) by any 3rd party sw to ensure that
       
  2743     // we don't break their settings
       
  2744     HBufC* daemonName = GetStringAttributeL( ECmConfigDaemonManagerName );
       
  2745     if ( daemonName )
       
  2746         {
       
  2747         if ( daemonName->Compare( KDaemonManagerName ) != 0 )
       
  2748     	    {
       
  2749     	    delete daemonName;
       
  2750             return;
       
  2751     	    }
       
  2752         delete daemonName;
       
  2753         }
       
  2754        
       
  2755     // check if Easy WLAN IAP since it has different config daemon
       
  2756     // manager name
       
  2757     HBufC* iapName = GetStringAttributeL( ECmName );
       
  2758     if ( iapName )
       
  2759         {
       
  2760         CleanupStack::PushL( iapName );
       
  2761         if ( iapName->Compare( KEasyWlanName ) == 0 )
       
  2762             {
       
  2763             SetStringAttributeL( ECmConfigDaemonManagerName, 
       
  2764                                   KHotspotDaemonManagerName );
       
  2765             SetStringAttributeL( ECmConfigDaemonName, 
       
  2766                                    KConfigDaemonName );
       
  2767             CleanupStack::PopAndDestroy( iapName );
       
  2768             return;
       
  2769             }
       
  2770         CleanupStack::PopAndDestroy( iapName );
       
  2771         }
       
  2772         
       
  2773     // use DHCP if we can
       
  2774     TBool ipfromSrv = GetBoolAttributeL( ECmIPAddFromServer );
       
  2775     if ( ipfromSrv )
       
  2776         {
       
  2777         SetStringAttributeL( ECmConfigDaemonManagerName, 
       
  2778                            KDaemonManagerName );
       
  2779         SetStringAttributeL( ECmConfigDaemonName, 
       
  2780                            KConfigDaemonName );
       
  2781         }
       
  2782     else
       
  2783         {
       
  2784         if ( FeatureSupported( KFeatureIdIPv6 ) )
       
  2785             {
       
  2786             SetStringAttributeL( ECmConfigDaemonManagerName, 
       
  2787                                KDaemonManagerName );
       
  2788             SetStringAttributeL( ECmConfigDaemonName, 
       
  2789                                KConfigDaemonName );
       
  2790             }
       
  2791         else
       
  2792             {
       
  2793             SetStringAttributeL( ECmConfigDaemonManagerName, 
       
  2794                                KNullDesC() );
       
  2795             SetStringAttributeL( ECmConfigDaemonName, 
       
  2796                                KNullDesC() );
       
  2797             }
       
  2798         }
       
  2799     }
       
  2800     
       
  2801     
       
  2802 // --------------------------------------------------------------------------
       
  2803 // CCmPluginWlan::ConvertWLANConnectionStatesL
       
  2804 // --------------------------------------------------------------------------
       
  2805 //
       
  2806 TWlanNetMode CCmPluginWlan::ConvertWLANConnectionStatesL(
       
  2807                                     TWlanConnectionMode aConnectionMode )
       
  2808     {
       
  2809     LOGGER_ENTERFN( "CCmPluginWlan::ConvertWLANConnectionStatesL " );
       
  2810     
       
  2811     switch ( aConnectionMode )
       
  2812         {
       
  2813         /** Values for possible WLAN connection states. */
       
  2814         /** Connection to an infrastructure network is active. */
       
  2815         case EWlanConnectionModeInfrastructure:    
       
  2816             {
       
  2817             return EInfra;
       
  2818             }
       
  2819         /** Connection to an ad-hoc network is active. */
       
  2820         case EWlanConnectionModeAdhoc:
       
  2821             {
       
  2822             return EAdhoc;
       
  2823             }
       
  2824         default:
       
  2825         	/**
       
  2826         	 * The connection mode. This can be either Ad-hoc or infrastructure.
       
  2827         	 * TWlanNetMode enum is to be used.
       
  2828         	 * ( TUint32 - default: EInfra )
       
  2829         	 */
       
  2830             {
       
  2831             return EInfra;
       
  2832             }
       
  2833         }
       
  2834     }
       
  2835   
       
  2836 // ---------------------------------------------------------------------------
       
  2837 // CCmPluginWlan::GetAdditionalUids
       
  2838 // ---------------------------------------------------------------------------
       
  2839 //
       
  2840 void CCmPluginWlan::GetAdditionalUids( RArray<TUint32>& aIapIds )
       
  2841     {
       
  2842     for (TInt i = 0; i<iAdditionalCmsCreated.Count(); i++ )
       
  2843         {
       
  2844         aIapIds.Append(iAdditionalCmsCreated[i]);
       
  2845         }
       
  2846     }
       
  2847     
       
  2848 // --------------------------------------------------------------------------
       
  2849 // CCmPluginWlan::EnterWAPIPreSharedKeyL
       
  2850 // --------------------------------------------------------------------------
       
  2851 //
       
  2852 TBool CCmPluginWlan::EnterWAPIPreSharedKeyL()
       
  2853     {
       
  2854     LOGGER_ENTERFN( "CCmPluginWlan::EnterWAPIPreSharedKeyL" );
       
  2855     
       
  2856     TBool retVal ( EFalse );
       
  2857     
       
  2858     HBufC* key = HBufC::NewLC( KWlanMaxKeyLength );
       
  2859     TPtr keyPtr( key->Des() );
       
  2860 
       
  2861     if ( !iConnUiUtils )
       
  2862         {
       
  2863         iConnUiUtils = CConnectionUiUtilities::NewL();
       
  2864         }
       
  2865     
       
  2866     if ( iConnUiUtils->EasyWapiDlg( &keyPtr ) )
       
  2867         {
       
  2868         if ( !iWAPISecSettings )
       
  2869             {
       
  2870             iWAPISecSettings = CWAPISecuritySettings::NewL();
       
  2871             }
       
  2872         iWAPISecSettings->SetPreSharedKeyL( CWAPISecuritySettings::EWapiKeyAscii, *key );
       
  2873         retVal = ETrue;
       
  2874         }
       
  2875     CleanupStack::PopAndDestroy( key );
       
  2876     
       
  2877     return retVal;
       
  2878     }
       
  2879