cmmanager/cmmgr/Plugins/cmpluginwlan/src/cmpwlansettingsdlg.cpp
changeset 0 5a93021fdf25
child 24 c45d4fe2ff0a
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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:  Dialog for editing wlan settings for a wlan connection method
       
    15 *
       
    16 */
       
    17 
       
    18 #include <badesca.h>
       
    19 #include <cmcommonui.h>
       
    20 #include <WEPSecuritySettingsUI.h>
       
    21 #include <WPASecuritySettingsUI.h>
       
    22 #include <wapisecuritysettingsui.h>
       
    23 #include <StringLoader.h>
       
    24 #include <akntextsettingpage.h>
       
    25 #include <cmwlanui.rsg>
       
    26 #include <ConnectionUiUtilities.h>
       
    27 #include <csxhelp/cp.hlp.hrh>
       
    28 #include <featmgr.h>
       
    29 #include "cmlogger.h"
       
    30 #include "cmwlancommonconstants.h"
       
    31 #include "cmpwlansettingsdlg.h"
       
    32 #include "cmpwlansettingsdlgadv.h"
       
    33 #include <cmpluginwlandef.h>
       
    34 #include "cmpluginwlan.h"
       
    35 #include "cmpluginmenucommands.hrh"
       
    36 #include <cmcommonconstants.h>
       
    37 #include <cmpsettingsconsts.h>
       
    38 #include "cmmanagerimpl.h"
       
    39 
       
    40 using namespace CMManager;
       
    41 
       
    42 const TUint32 KScanSSIDSelectionItems[] = 
       
    43     {
       
    44     R_QTN_WLAN_SETT_HIDDEN_NETWORK_NO,
       
    45     R_QTN_WLAN_SETT_HIDDEN_NETWORK_YES,
       
    46     0
       
    47     };
       
    48 
       
    49 const TUint32 KSecModeRBSelectionItems[] = 
       
    50     {
       
    51     R_QTN_WLAN_SETT_SECURITY_MODE_OPEN,
       
    52     R_QTN_WLAN_SETT_SECURITY_MODE_WEP,
       
    53     0
       
    54     };
       
    55 
       
    56 const TUint32 KSecModeRBIRSelectionItems[] = 
       
    57     {
       
    58     R_QTN_WLAN_SETT_SECURITY_MODE_OPEN,
       
    59     R_QTN_WLAN_SETT_SECURITY_MODE_WEP,
       
    60     R_QTN_WLAN_SETT_SECURITY_MODE_802_1X,
       
    61     R_QTN_WLAN_SETT_SECURITY_MODE_WPA,
       
    62     0
       
    63     };
       
    64 
       
    65 const TUint32 KSecModeRBIRSelectionItemsWAPI[] = 
       
    66     {
       
    67     R_QTN_WLAN_SETT_SECURITY_MODE_OPEN,
       
    68     R_QTN_WLAN_SETT_SECURITY_MODE_WEP,
       
    69     R_QTN_WLAN_SETT_SECURITY_MODE_802_1X,
       
    70     R_QTN_WLAN_SETT_SECURITY_MODE_WPA,
       
    71     R_QTN_WLAN_SETT_SECURITY_MODE_WAPI,
       
    72     0
       
    73     };
       
    74 
       
    75 const TUint32 KNetworkRBSelectionItems[] = 
       
    76     {
       
    77     R_QTN_WLAN_SETT_NETWORK_MODE_INFRA,
       
    78     R_QTN_WLAN_SETT_NETWORK_MODE_ADHOC,
       
    79     0
       
    80     };
       
    81 
       
    82 const TUint32 KNWNameSelectionItems[] = 
       
    83     {
       
    84     R_QTN_WLAN_SETT_NETWORK_NAME_USER_DEFINED,
       
    85     R_QTN_WLAN_SETT_NETWORK_NAME_SCAN,
       
    86     0
       
    87     };
       
    88     
       
    89 // ================= MEMBER FUNCTIONS =======================================
       
    90 
       
    91 // --------------------------------------------------------------------------
       
    92 // CmPluginWlanSettingsDlg::NewL()
       
    93 // --------------------------------------------------------------------------
       
    94 //
       
    95 CmPluginWlanSettingsDlg* CmPluginWlanSettingsDlg::NewL( 
       
    96                                             CCmPluginBaseEng& aCmPluginBase )
       
    97 	{
       
    98 	CmPluginWlanSettingsDlg* self = 
       
    99 	                new (ELeave) CmPluginWlanSettingsDlg( aCmPluginBase );
       
   100 	return self;
       
   101 	}
       
   102 	
       
   103 // --------------------------------------------------------------------------
       
   104 // CmPluginWlanSettingsDlg::CmPluginWlanSettingsDlg()
       
   105 // --------------------------------------------------------------------------
       
   106 //
       
   107 CmPluginWlanSettingsDlg::CmPluginWlanSettingsDlg(
       
   108                                             CCmPluginBaseEng& aCmPluginBase )
       
   109     : CmPluginBaseSettingsDlg( aCmPluginBase )
       
   110     , iNotifyFromAdv( KCmNotifiedNone )
       
   111     {
       
   112     
       
   113     }
       
   114 
       
   115 // --------------------------------------------------------------------------
       
   116 // CmPluginWlanSettingsDlg::ConstructAndRunLD
       
   117 // --------------------------------------------------------------------------
       
   118 //
       
   119 TInt CmPluginWlanSettingsDlg::ConstructAndRunLD( )
       
   120     {
       
   121     LoadResourceL( KPluginWlanResDirAndFileName );
       
   122     
       
   123     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   124     cmMgr.WatcherRegisterL( this );
       
   125     
       
   126     return CmPluginBaseSettingsDlg::ConstructAndRunLD( );
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------
       
   130 // CmPluginWlanSettingsDlg::~CmPluginWlanSettingsDlg
       
   131 // Destructor
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 CmPluginWlanSettingsDlg::~CmPluginWlanSettingsDlg()
       
   135     {
       
   136     iResourceReader.Close();
       
   137     }
       
   138 
       
   139 // --------------------------------------------------------------------------
       
   140 // CmPluginWlanSettingsDlg::RunAdvancedSettingsL
       
   141 // --------------------------------------------------------------------------
       
   142 //
       
   143 void CmPluginWlanSettingsDlg::RunAdvancedSettingsL()
       
   144     {
       
   145     CmPluginWlanSettingsDlgAdv* AdvDlg = 
       
   146                         CmPluginWlanSettingsDlgAdv::NewL( iCmPluginBaseEng );
       
   147 
       
   148     if (!iHasSettingChanged)
       
   149         {
       
   150         iHasSettingChanged = ETrue;
       
   151         }                      
       
   152     
       
   153     // This view may have to un-register as watcher here
       
   154     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   155     cmMgr.WatcherUnRegister();
       
   156     
       
   157     AdvDlg->RegisterParentView( this );
       
   158     TInt ret = AdvDlg->ConstructAndRunLD();
       
   159 
       
   160     if( iNotifyFromAdv == KCmNotifiedNone )
       
   161         {
       
   162         if( ret == KDialogUserExit )
       
   163             {
       
   164             iExitReason = KDialogUserExit;
       
   165             ExitSettingsL(EFalse);
       
   166             }
       
   167         else
       
   168             {
       
   169             // Re-register as watcher if advanced view comes back or exists normally
       
   170             cmMgr.WatcherRegisterL( this );
       
   171             }
       
   172         }
       
   173     else
       
   174         {
       
   175         HandleCommsDatChangeL();
       
   176         }
       
   177     }
       
   178 
       
   179 // --------------------------------------------------------------------------
       
   180 // CmPluginBaseSettingsDlg::UpdateListBoxContentBearerSpecificL
       
   181 // --------------------------------------------------------------------------
       
   182 //
       
   183 void CmPluginWlanSettingsDlg::UpdateListBoxContentBearerSpecificL( 
       
   184                                                     CDesCArray& aItemArray )
       
   185     {
       
   186     TBool boolSettingVal( EFalse ); // just for helping make code readable
       
   187     TInt valResId(0);
       
   188     
       
   189     // DATA BEARER - only for real bearer types
       
   190     AppendSettingTextsL( aItemArray, ECmBearerSettingName );
       
   191     // NETWORK NAME
       
   192     AppendSettingTextsL( aItemArray, EWlanSSID );
       
   193     // NETWORK STATUS
       
   194     boolSettingVal = iCmPluginBaseEng.GetBoolAttributeL( EWlanScanSSID );
       
   195     AppendSettingTextsL( aItemArray,
       
   196                          EWlanScanSSID,
       
   197                          boolSettingVal ? 
       
   198                             R_QTN_WLAN_SETT_HIDDEN_NETWORK_YES :
       
   199                             R_QTN_WLAN_SETT_HIDDEN_NETWORK_NO );
       
   200     // WLAN NETWORK MODE    
       
   201     switch( iCmPluginBaseEng.GetIntAttributeL( EWlanConnectionMode ) )
       
   202         {
       
   203         case EAdhoc:
       
   204             {
       
   205             valResId = R_QTN_WLAN_SETT_NETWORK_MODE_ADHOC;
       
   206             break;
       
   207             }
       
   208         case EInfra:
       
   209             // fall-through intended here
       
   210         default:
       
   211             {
       
   212             valResId = R_QTN_WLAN_SETT_NETWORK_MODE_INFRA;
       
   213             break;
       
   214             }
       
   215         }
       
   216     
       
   217     AppendSettingTextsL( aItemArray, EWlanConnectionMode, valResId );
       
   218     // WLAN SECURITY MODE
       
   219     switch( iCmPluginBaseEng.GetIntAttributeL( EWlanSecurityMode ) )
       
   220         {
       
   221         case EWlanSecModeWep :
       
   222             {
       
   223             valResId = R_QTN_WLAN_SETT_SECURITY_MODE_WEP;
       
   224             break;
       
   225             }
       
   226         case EWlanSecMode802_1x:
       
   227             {
       
   228             valResId = R_QTN_WLAN_SETT_SECURITY_MODE_802_1X;
       
   229             break;
       
   230             }
       
   231         case EWlanSecModeWpa:
       
   232         case EWlanSecModeWpa2:
       
   233             {
       
   234             valResId = R_QTN_WLAN_SETT_SECURITY_MODE_WPA;
       
   235             break;
       
   236             }
       
   237         case EWlanSecModeWAPI:
       
   238             {
       
   239             valResId = R_QTN_WLAN_SETT_SECURITY_MODE_WAPI;
       
   240             break;
       
   241             }
       
   242         case EWlanSecModeOpen:
       
   243             // fall-through intended here
       
   244         default:
       
   245             {
       
   246             valResId = R_QTN_WLAN_SETT_SECURITY_MODE_OPEN;
       
   247             break;
       
   248             }
       
   249         }
       
   250     AppendSettingTextsL( aItemArray, EWlanSecurityMode, valResId );
       
   251     // WLAN SECURITY SETTINGS
       
   252     AppendSettingTextsL( aItemArray,
       
   253                          EWlanSecuritySettings,
       
   254                          R_QTN_WLAN_SETT_SECURITY_SETTINGS,
       
   255                          0 );
       
   256     // HOMEPAGE
       
   257     AppendSettingTextsL( aItemArray, ECmStartPage );
       
   258     }
       
   259 
       
   260     
       
   261 //---------------------------------------------------------------------------
       
   262 // CmPluginWlanSettingsDlg::ChangeBoolSettingL
       
   263 //---------------------------------------------------------------------------
       
   264 //
       
   265 void CmPluginWlanSettingsDlg::ChangeBoolSettingL( TUint32 aAttribute, 
       
   266                                                   TInt aCommandId )
       
   267     {
       
   268     // Change was selected from menu
       
   269     if ( aCommandId == EPluginBaseCmdChange )
       
   270         {
       
   271         TInt selected = 
       
   272                     iCmPluginBaseEng.GetBoolAttributeL( aAttribute );
       
   273         TInt origVal = selected;
       
   274                     
       
   275         if ( ShowRadioButtonSettingPageL( KScanSSIDSelectionItems, 
       
   276                                           selected,
       
   277                                           R_QTN_WLAN_SETT_HIDDEN_NETWORK ) &&
       
   278              origVal != selected )
       
   279              {
       
   280              iCmPluginBaseEng.SetBoolAttributeL( aAttribute, 
       
   281                                                  selected );
       
   282              UpdateListBoxContentL();
       
   283              }
       
   284         }
       
   285     // Selection key was selected
       
   286     else        
       
   287         {
       
   288         switch ( aAttribute )
       
   289             {
       
   290             case EWlanScanSSID:
       
   291                 {        
       
   292                 TBool boolFromCM = EFalse;
       
   293                 boolFromCM = iCmPluginBaseEng.GetBoolAttributeL( aAttribute );
       
   294                 iCmPluginBaseEng.SetBoolAttributeL( aAttribute , !boolFromCM );
       
   295                 UpdateListBoxContentL();              
       
   296                 break;
       
   297                 }
       
   298             case EWlanConnectionMode:
       
   299                 {        
       
   300                 TInt intFromCM = 0;
       
   301                 intFromCM = iCmPluginBaseEng.GetIntAttributeL( aAttribute );
       
   302                 iCmPluginBaseEng.SetIntAttributeL( aAttribute , !intFromCM );
       
   303                 UpdateListBoxContentL();              
       
   304                 break;
       
   305                 }
       
   306             }
       
   307         }
       
   308     }
       
   309 
       
   310 //---------------------------------------------------------------------------
       
   311 // CmPluginWlanSettingsDlg::ShowSecurityModeRBPageL
       
   312 //---------------------------------------------------------------------------
       
   313 //
       
   314 void CmPluginWlanSettingsDlg::ShowSecurityModeRBPageL()
       
   315     {   
       
   316     TInt selected = 0;
       
   317     TInt secMode = iCmPluginBaseEng.GetIntAttributeL( EWlanSecurityMode );
       
   318     const TUint32* items = NULL;
       
   319     
       
   320     //converting secMode to idex
       
   321     switch ( secMode ) 
       
   322         {
       
   323         case EWlanSecModeOpen:
       
   324             {
       
   325             selected = 0;
       
   326             break;
       
   327             }
       
   328         case EWlanSecModeWep:
       
   329             {
       
   330             selected = 1;
       
   331             break;
       
   332             }
       
   333         case EWlanSecMode802_1x:
       
   334             {
       
   335             selected = 2;
       
   336             break;
       
   337             }
       
   338         case EWlanSecModeWpa:
       
   339             {
       
   340             selected = 3;
       
   341             break;
       
   342             }
       
   343         // is this a real case?
       
   344         case EWlanSecModeWpa2:
       
   345             {
       
   346             selected = 3;
       
   347             break;
       
   348             }
       
   349         case EWlanSecModeWAPI:
       
   350             {
       
   351             selected = 4;
       
   352             break;
       
   353             }
       
   354         default:
       
   355             {
       
   356             User::Leave( KErrNotSupported );
       
   357             break;
       
   358             }
       
   359         }
       
   360         
       
   361     if ( iCmPluginBaseEng.GetIntAttributeL( EWlanConnectionMode ) == EInfra )
       
   362         {
       
   363         if ( !FeatureManager::FeatureSupported( KFeatureIdFfWlanWapi ) )
       
   364             {
       
   365             items = KSecModeRBIRSelectionItems;
       
   366             }
       
   367         else
       
   368             {
       
   369             items = KSecModeRBIRSelectionItemsWAPI;
       
   370             }
       
   371         }
       
   372     else
       
   373         {
       
   374         items = KSecModeRBSelectionItems;
       
   375         }
       
   376 
       
   377     TInt origVal = selected;
       
   378     if ( ShowRadioButtonSettingPageL( items, 
       
   379                                       selected, 
       
   380                                       R_QTN_WLAN_SETT_SECURITY_MODE ) && 
       
   381                                       origVal != selected )
       
   382         {
       
   383         if ( !iHasSettingChanged )
       
   384             {
       
   385             iHasSettingChanged = ETrue;
       
   386             }
       
   387 		
       
   388         switch ( selected )
       
   389             {
       
   390             case 0:
       
   391                 {
       
   392                 secMode = EWlanSecModeOpen;
       
   393                 break;
       
   394                 }
       
   395             case 1:
       
   396                 {
       
   397                 secMode = EWlanSecModeWep;
       
   398                 break;
       
   399                 }
       
   400             case 2:
       
   401                 {
       
   402                 secMode = EWlanSecMode802_1x;
       
   403                 break;
       
   404                 }
       
   405             case 3:
       
   406                 {
       
   407                 secMode = EWlanSecModeWpa;
       
   408                 break;
       
   409                 }
       
   410             case 4:
       
   411                 {
       
   412                 secMode = EWlanSecModeWAPI;
       
   413                 break;
       
   414                 }
       
   415             default:
       
   416                 {
       
   417                 User::Leave( KErrNotSupported );
       
   418                 break;
       
   419                 }
       
   420             }
       
   421         iCmPluginBaseEng.SetIntAttributeL( EWlanSecurityMode , secMode );
       
   422         UpdateListBoxContentL();
       
   423         }
       
   424     }
       
   425 
       
   426 //---------------------------------------------------------------------------
       
   427 // CmPluginWlanSettingsDlg::ShowNetworkModeRBPageL
       
   428 //---------------------------------------------------------------------------
       
   429 //
       
   430 void CmPluginWlanSettingsDlg:: ShowNetworkModeRBPageL()
       
   431     {   
       
   432     const TUint32* items = KNetworkRBSelectionItems;
       
   433     
       
   434     TInt selected;
       
   435     
       
   436     // convert values to indices for UI
       
   437     TInt netMode = iCmPluginBaseEng.GetIntAttributeL( EWlanConnectionMode );
       
   438     switch ( netMode )
       
   439         {
       
   440         case EAdhoc:
       
   441             {
       
   442             selected = 1;
       
   443             break;
       
   444             }
       
   445         case EInfra:
       
   446             {
       
   447             selected = 0;
       
   448             break;
       
   449             }
       
   450         }
       
   451     
       
   452     TInt origVal = selected;
       
   453     if ( ShowRadioButtonSettingPageL( items, 
       
   454                                       selected,
       
   455                                       R_QTN_WLAN_SETT_NETWORK_MODE ) && 
       
   456          origVal != selected )
       
   457         {
       
   458         // convert indices back to proper values
       
   459         switch ( selected )
       
   460             {
       
   461             case 0:
       
   462                 {
       
   463                 netMode = EInfra;
       
   464                 break;
       
   465                 }
       
   466             case 1:
       
   467                 {
       
   468                 netMode = EAdhoc;
       
   469                 TInt secMode = iCmPluginBaseEng.GetIntAttributeL( 
       
   470                                                         EWlanSecurityMode );
       
   471                 if( secMode != EWlanSecModeOpen &&
       
   472                     secMode != EWlanSecModeWep )
       
   473                     {
       
   474                     iCmPluginBaseEng.SetIntAttributeL( EWlanSecurityMode,
       
   475                                                        EWlanSecModeOpen );
       
   476                     }
       
   477                 break;
       
   478                 }
       
   479             default:
       
   480                 {
       
   481                 User::Leave( KErrNotSupported );
       
   482                 break;
       
   483                 }
       
   484             }
       
   485         iCmPluginBaseEng.SetIntAttributeL( EWlanConnectionMode , netMode );
       
   486         UpdateListBoxContentL();
       
   487         }    
       
   488     }  
       
   489 
       
   490 //---------------------------------------------------------------------------
       
   491 // CmPluginWlanSettingsDlg::ShowWlanNWNamePageL
       
   492 //---------------------------------------------------------------------------
       
   493 //
       
   494 void CmPluginWlanSettingsDlg::ShowWlanNWNamePageL()
       
   495     {
       
   496     const TCmAttribConvTable* convItem = 
       
   497                         iCmPluginBaseEng.ConvTableItem( EWlanSSID );
       
   498     
       
   499     const TUint32* items = KNWNameSelectionItems;
       
   500     TInt selected ( EWlanNwNameUserDefined );
       
   501     
       
   502     // Display a radio button page with options: User defined and Scan for Networks
       
   503     if ( ShowRadioButtonSettingPageL( items, 
       
   504                                       selected,
       
   505                                       R_QTN_WLAN_SETT_NETWORK_NAME ) )
       
   506         {
       
   507         if ( selected == EWlanNwNameUserDefined )
       
   508             {
       
   509             HBufC* oldssId = iCmPluginBaseEng.GetStringAttributeL( EWlanSSID );
       
   510             CleanupStack::PushL( oldssId );
       
   511             
       
   512             TBuf<KCmWlanNWNameMaxLength> buf;
       
   513             buf.Copy( *oldssId );
       
   514 
       
   515             if ( TCmCommonUi::ShowConfirmationQueryWithInputL(
       
   516                                            R_QTN_WLAN_PRMPT_NETWORK_NAME,
       
   517                                            buf ) )
       
   518                 {
       
   519                 if( buf.Compare( *oldssId ) )
       
   520                     // SSID is changed
       
   521                     {
       
   522                     iCmPluginBaseEng.SetStringAttributeL( EWlanSSID, buf );
       
   523                     UpdateListBoxContentL();
       
   524                     }
       
   525                 }
       
   526             CleanupStack::PopAndDestroy( oldssId );
       
   527             }
       
   528         else
       
   529             {
       
   530             // Let's search for a WLAN network
       
   531             TWlanSsid ssid;
       
   532             TWlanConnectionMode connectionMode;
       
   533             TWlanConnectionSecurityMode securityMode;
       
   534 
       
   535             CConnectionUiUtilities* uiUtils = CConnectionUiUtilities::NewL();
       
   536             CleanupStack::PushL( uiUtils );
       
   537 
       
   538             if ( uiUtils->SearchWLANNetwork( ssid, connectionMode, securityMode ) )
       
   539                 {
       
   540                 HBufC* temp = HBufC::NewLC( convItem->iMaxLength );
       
   541                 temp->Des().Copy( ssid );
       
   542                 iCmPluginBaseEng.SetStringAttributeL( EWlanSSID, *temp );
       
   543                 CleanupStack::PopAndDestroy( temp );
       
   544                 
       
   545                 UpdateListBoxContentL();
       
   546                 }                
       
   547             CleanupStack::PopAndDestroy( uiUtils );
       
   548             }
       
   549         }
       
   550     }
       
   551 
       
   552 //---------------------------------------------------------------------------
       
   553 // CmPluginWlanSettingsDlg::ShowPopupSettingPageL
       
   554 //---------------------------------------------------------------------------
       
   555 //
       
   556 TBool CmPluginWlanSettingsDlg::ShowPopupSettingPageL( TUint32 aAttribute, 
       
   557                                                       TInt aCommandId )
       
   558     {    
       
   559     TBool retval = EFalse;
       
   560     switch( aAttribute )
       
   561         {
       
   562         // Boolean settings
       
   563         case EWlanScanSSID:            
       
   564             {
       
   565             ChangeBoolSettingL( aAttribute, aCommandId );
       
   566             break;
       
   567             }
       
   568         // Textual Settings
       
   569         case ECmStartPage:                
       
   570             {
       
   571             ShowPopupTextSettingPageL( aAttribute );
       
   572             break;
       
   573             }
       
   574         case EWlanSecurityMode:            
       
   575             {
       
   576             ShowSecurityModeRBPageL();
       
   577             break;
       
   578             }
       
   579         case EWlanSecuritySettings:
       
   580             {
       
   581             TInt secmode = iCmPluginBaseEng.GetIntAttributeL( EWlanSecurityMode );
       
   582             if(  secmode == EWlanSecModeOpen )
       
   583                 {
       
   584                 TCmCommonUi::ShowNoteL( R_QTN_WLAN_INFO_NO_SECURITY_SETTINGS, 
       
   585                                         TCmCommonUi::ECmInfoNote);
       
   586                 }
       
   587             else
       
   588                 {
       
   589                 TInt exitValue = 
       
   590                     STATIC_CAST( CCmPluginWlan*, &iCmPluginBaseEng )->
       
   591                            EditSecuritySettingsL( *( CEikonEnv::Static() ) );
       
   592                 if ( secmode == EWlanSecModeWep )
       
   593                     { // WEP
       
   594                     if ( exitValue & CWEPSecuritySettings::EExitReq )
       
   595                         {
       
   596                         iSecDialExit = ETrue;
       
   597                         iExitReason = KDialogUserExit;
       
   598                         ExitSettingsL(EFalse);
       
   599                         }                    
       
   600                     }
       
   601                 else if ( secmode == EWlanSecModeWAPI )
       
   602                     {
       
   603                     if ( exitValue & CWAPISecuritySettings::EExitReq )
       
   604                         {
       
   605                         iSecDialExit = ETrue;
       
   606                         iExitReason = KDialogUserExit;
       
   607                         ExitSettingsL(EFalse);
       
   608                         }
       
   609                     }
       
   610                 else
       
   611                     {// 802.1x, WPA/WPA2
       
   612                     if ( exitValue & CWPASecuritySettings::EExitReq )
       
   613                         {
       
   614                         iSecDialExit = ETrue;
       
   615                         iExitReason = KDialogUserExit;
       
   616                         ExitSettingsL(EFalse);
       
   617                         }
       
   618                     }
       
   619                 }
       
   620             break;
       
   621             }
       
   622         case EWlanConnectionMode:
       
   623             {
       
   624             if ( aCommandId == EPluginBaseCmdChange )
       
   625                 {
       
   626                 ShowNetworkModeRBPageL();
       
   627                 }
       
   628             else
       
   629                 {
       
   630                 TInt netMode = 
       
   631                     iCmPluginBaseEng.GetIntAttributeL( EWlanConnectionMode );
       
   632                 // OK has been used: switch the value without opening the setting page
       
   633                 if ( netMode == EInfra )
       
   634                     {
       
   635                     netMode = EAdhoc;
       
   636                     TInt secMode = iCmPluginBaseEng.GetIntAttributeL( 
       
   637                                                             EWlanSecurityMode );
       
   638                     if( secMode != EWlanSecModeOpen &&
       
   639                         secMode != EWlanSecModeWep )
       
   640                         {
       
   641                         iCmPluginBaseEng.SetIntAttributeL( EWlanSecurityMode,
       
   642                                                            EWlanSecModeOpen );
       
   643                         }
       
   644                     }
       
   645                 else
       
   646                     {
       
   647                     netMode = EInfra;
       
   648                     }
       
   649                 iCmPluginBaseEng.SetIntAttributeL( EWlanConnectionMode, netMode );
       
   650                 UpdateListBoxContentL();
       
   651                 }
       
   652             break;
       
   653             }
       
   654         case EWlanSSID:
       
   655             {
       
   656             ShowWlanNWNamePageL();
       
   657             break;
       
   658             }
       
   659         default:
       
   660             {
       
   661             CmPluginBaseSettingsDlg::ShowPopupSettingPageL( aAttribute, 
       
   662                                                             aCommandId );
       
   663             break;            
       
   664             }
       
   665         }
       
   666     return retval;
       
   667     }
       
   668     
       
   669         
       
   670 // --------------------------------------------------------------------------
       
   671 // CmPluginWlanSettingsDlg::ExitSettingsL
       
   672 // --------------------------------------------------------------------------
       
   673 //
       
   674 void CmPluginWlanSettingsDlg::ExitSettingsL( TBool aConfirm )
       
   675     {
       
   676      if ( STATIC_CAST( CCmPluginWlan*, &iCmPluginBaseEng )->
       
   677                                             AreSecuritySettingsValidL()  )
       
   678         {
       
   679         if ( iIsPossibleToSaveSetting && iHasSettingChanged )
       
   680             {
       
   681             iCmPluginBaseEng.UpdateL();
       
   682             iHasSettingChanged = EFalse;
       
   683             }
       
   684         TryExitL( iExitReason );
       
   685         }
       
   686      else
       
   687         {
       
   688         HBufC* netwName = iCmPluginBaseEng.GetStringAttributeL( EWlanSSID );
       
   689         TBool noNetwName = ETrue;
       
   690         CleanupStack::PushL( netwName );
       
   691         if ( *netwName != KNullDesC )
       
   692             {
       
   693             noNetwName = EFalse;
       
   694             }
       
   695         CleanupStack::PopAndDestroy( netwName );
       
   696         
       
   697         if ( noNetwName )
       
   698             {
       
   699             if ( aConfirm )
       
   700                 {                    
       
   701                 if ( TCmCommonUi::ShowConfirmationQueryL( 
       
   702                                     R_QTN_WLAN_QUEST_NW_NAME_NOT_DEFINED ) )
       
   703                     {
       
   704                     iExitReason = KDialogUserDelete;
       
   705                     TryExitL( iExitReason );
       
   706                     }
       
   707                 else
       
   708                     {
       
   709                     // Find the index of the EWlanSSID item
       
   710                     for ( TInt i = 0; i < iSettingIndex->Count(); i++ )
       
   711                         {
       
   712                         if ( iSettingIndex->At(i) == EWlanSSID )
       
   713                             {
       
   714                             SelectItem(i);
       
   715                             break;
       
   716                             }
       
   717                         }
       
   718                     }
       
   719                 }
       
   720             else
       
   721                 {
       
   722                 TryExitL( iExitReason );
       
   723                 }
       
   724             }
       
   725         else
       
   726             {
       
   727             if ( iCmPluginBaseEng.GetIntAttributeL( EWlanSecurityMode ) == 
       
   728                                                            EWlanSecModeOpen )
       
   729                 {
       
   730                 if ( iIsPossibleToSaveSetting && iHasSettingChanged)
       
   731                 {
       
   732                     iCmPluginBaseEng.UpdateL();
       
   733                     iHasSettingChanged = EFalse;
       
   734                 }
       
   735                 TryExitL( iExitReason );
       
   736                 }
       
   737             else
       
   738                 {
       
   739                 if ( aConfirm )
       
   740                     {                    
       
   741                     if ( TCmCommonUi::ShowConfirmationQueryL( 
       
   742                             R_QTN_WLAN_QUEST_SECURITY_SETTINGS_EMPTY ) )
       
   743                         {
       
   744                         iExitReason = KDialogUserDeleteConfirmed;
       
   745                         TryExitL( iExitReason );
       
   746                         }
       
   747                      else                    
       
   748                         {
       
   749                         // Show the securitysettings page for WEP, other security mode
       
   750                         // is not supported here(WPA has a default value)...
       
   751                         ShowPopupSettingPageL( EWlanSecuritySettings, EWlanSecModeWep );
       
   752                         }
       
   753                     }
       
   754                 else
       
   755                     {
       
   756                     TryExitL( iExitReason );
       
   757                     }
       
   758                 }
       
   759             }
       
   760         }
       
   761     }
       
   762 
       
   763 
       
   764 // --------------------------------------------------------------------------
       
   765 // CmPluginWlanSettingsDlg::OkToExitL
       
   766 // Good to know : EAknSoftkeyCancel is never called, because
       
   767 // EEikDialogFlagNotifyEsc flag is not set in the resource.
       
   768 // --------------------------------------------------------------------------
       
   769 //
       
   770 TBool CmPluginWlanSettingsDlg::OkToExitL( TInt aButtonId )
       
   771     {
       
   772     // Translate the button presses into commands for the appui & current
       
   773     // view to handle
       
   774     TBool retval( EFalse );
       
   775     
       
   776     switch ( aButtonId )
       
   777         {
       
   778         case EAknSoftkeyOk:
       
   779         case EAknSoftkeyChange:
       
   780             {
       
   781             ProcessCommandL( aButtonId );
       
   782             break;
       
   783             }        
       
   784         case EAknSoftkeyBack:
       
   785             {
       
   786             ProcessCommandL( aButtonId );
       
   787             break;
       
   788             }
       
   789         case EAknSoftkeyOptions:
       
   790             {
       
   791             DisplayMenuL();
       
   792             break;
       
   793             }
       
   794         case KDialogUserExit:
       
   795             {
       
   796             if ( iSecDialExit )
       
   797                 {
       
   798                 iSecDialExit = EFalse;
       
   799                 }
       
   800             retval=ETrue;
       
   801             break;
       
   802             }
       
   803         default:
       
   804             {
       
   805             retval = ETrue;
       
   806             break;
       
   807             }
       
   808         }
       
   809 
       
   810     return retval;
       
   811     }
       
   812 
       
   813 
       
   814 // --------------------------------------------------------------------------
       
   815 // CmPluginWlanSettingsDlg::ProcessCommandL
       
   816 // --------------------------------------------------------------------------
       
   817 //
       
   818 void CmPluginWlanSettingsDlg::ProcessCommandL( TInt aCommandId )
       
   819     {
       
   820     if ( MenuShowing() )
       
   821         {
       
   822         HideMenu();
       
   823         }
       
   824 
       
   825     switch ( aCommandId )
       
   826         {
       
   827         case EPluginBaseCmdExit:
       
   828             {
       
   829             iExitReason = KDialogUserExit;
       
   830             }            
       
   831         case EAknSoftkeyBack:
       
   832             {
       
   833             CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   834             cmMgr.WatcherUnRegister();
       
   835             
       
   836             ExitSettingsL(ETrue);
       
   837             break;
       
   838             }           
       
   839         case EPluginBaseCmdAdvanced:
       
   840             {
       
   841             RunAdvancedSettingsL();
       
   842             break;
       
   843             }
       
   844         case EPluginBaseCmdChange:
       
   845         case EAknSoftkeyOk:
       
   846             {
       
   847             TUint32 attrib = iSettingIndex->At( iListbox->CurrentItemIndex() );
       
   848             ShowPopupSettingPageL( attrib, aCommandId );
       
   849             break;
       
   850             }
       
   851         default:
       
   852             {
       
   853             CmPluginBaseSettingsDlg::ProcessCommandL( aCommandId );
       
   854             break;            
       
   855             }
       
   856         }
       
   857     }
       
   858 
       
   859 // --------------------------------------------------------------------------
       
   860 // CmPluginWlanSettingsDlg::GetHelpContext
       
   861 // --------------------------------------------------------------------------
       
   862 //
       
   863 void CmPluginWlanSettingsDlg::GetHelpContext( TCoeHelpContext& aContext ) const
       
   864     {
       
   865     LOGGER_ENTERFN( "CmPluginWlanSettingsDlg::GetHelpContext" );	
       
   866     aContext.iMajor = KHelpUidPlugin;
       
   867     aContext.iContext = KSET_HLP_AP_SETTING_WLAN;
       
   868     }
       
   869 
       
   870 // --------------------------------------------------------------------------
       
   871 // CmPluginWlanSettingsDlg::CommsDatChangesL
       
   872 // --------------------------------------------------------------------------
       
   873 //
       
   874 void CmPluginWlanSettingsDlg::CommsDatChangesL()
       
   875     {
       
   876     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   877     CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination();
       
   878 
       
   879     if ( parentDest )
       
   880         {
       
   881         if( !cmMgr.DestinationStillExistedL( parentDest ) )
       
   882             {
       
   883             cmMgr.WatcherUnRegister();
       
   884             // If parent destination is deleted by somebody then the dialog must exit back to main view
       
   885             iExitReason = KDialogUserExit;
       
   886             TryExitL( iExitReason );
       
   887             
       
   888             cmMgr.RemoveDestFromPool( parentDest );
       
   889             delete parentDest;
       
   890             return;
       
   891             }
       
   892         
       
   893         if( !cmMgr.IsIapStillInDestL( parentDest, iCmPluginBaseEng ) )
       
   894             {
       
   895             cmMgr.WatcherUnRegister();
       
   896             // In this case, the dialog can go back to the parent view
       
   897             TryExitL( iExitReason );
       
   898             
       
   899             cmMgr.RemoveDestFromPool( parentDest );
       
   900             delete parentDest;
       
   901             return;            
       
   902             }
       
   903 
       
   904         // We may have to go back to parent view even though this Iap is still in CommsDat
       
   905         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   906         // after this call when some Iap is deleted.
       
   907         cmMgr.WatcherUnRegister();
       
   908         TryExitL( iExitReason );
       
   909                 
       
   910         cmMgr.RemoveDestFromPool( parentDest );
       
   911         delete parentDest;
       
   912         }
       
   913     else
       
   914         {
       
   915         if( !cmMgr.IapStillExistedL( iCmPluginBaseEng ) )
       
   916             {
       
   917             cmMgr.WatcherUnRegister();
       
   918             // In this case, the dialog can go back to the parent view
       
   919             TryExitL( iExitReason );
       
   920             return;
       
   921             }
       
   922             
       
   923         // We may have to go back to parent view even though this Iap is still in CommsDat
       
   924         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   925         // after this call when some Iap is deleted.
       
   926         cmMgr.WatcherUnRegister();
       
   927         TryExitL( iExitReason );
       
   928         }
       
   929     }
       
   930 
       
   931 // --------------------------------------------------------------------------
       
   932 // CmPluginWlanSettingsDlg::NotifyParentView
       
   933 // --------------------------------------------------------------------------
       
   934 //
       
   935 void CmPluginWlanSettingsDlg::NotifyParentView( TInt aValue )
       
   936     {
       
   937     iNotifyFromAdv = aValue;
       
   938     }
       
   939 
       
   940 // --------------------------------------------------------------------------
       
   941 // CmPluginWlanSettingsDlg::HandleCommsDatChangeL
       
   942 // --------------------------------------------------------------------------
       
   943 //
       
   944 void CmPluginWlanSettingsDlg::HandleCommsDatChangeL()
       
   945     {
       
   946     //CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   947     
       
   948     if( iNotifyFromAdv == KCmNotifiedIapIsNotInThisDestination || 
       
   949             iNotifyFromAdv == KCmNotifiedIapDisappear )
       
   950         {
       
   951         TryExitL( iExitReason );
       
   952         }
       
   953     else if( iNotifyFromAdv == KCmNotifiedDestinationDisappear )
       
   954         {
       
   955         iExitReason = KDialogUserExit;
       
   956         TryExitL( iExitReason );
       
   957         }
       
   958     }