cmmanager/cmmgr/Plugins/cmpluginwlan/src/cmpwlansettingsdlgipv4.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:  WLAN Ipv4 settings dialog
       
    15 *
       
    16 */
       
    17 
       
    18 #include <StringLoader.h>
       
    19 #include <akntitle.h>
       
    20 #include <akntextsettingpage.h>
       
    21 #include <aknmfnesettingpage.h>  // for IP dialog
       
    22 #include <cmcommonui.h>
       
    23 #include <cmwlanui.rsg>
       
    24 #include <cmmanager.rsg>
       
    25 #include <csxhelp/cp.hlp.hrh>
       
    26 
       
    27 #include <cmpluginbaseeng.h>
       
    28 #include <cmpluginwlandef.h>
       
    29 #include "cmpwlansettingsdlgipv4.h"
       
    30 #include "cmwlancommonconstants.h"
       
    31 #include "cmpluginmenucommands.hrh"
       
    32 #include "cmpluginmultilinedialog.h"
       
    33 #include <cmcommonconstants.h>
       
    34 #include <cmpsettingsconsts.h>
       
    35 #include "cmmanagerimpl.h"
       
    36 
       
    37 using namespace CMManager;
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =========================================
       
    40 
       
    41 // --------------------------------------------------------------------------
       
    42 // CmPluginWlanSettingsDlgIpv4::NewL
       
    43 // Two-phase dconstructor, second phase is ConstructAndRunLD
       
    44 // --------------------------------------------------------------------------
       
    45 //
       
    46 CmPluginWlanSettingsDlgIpv4* CmPluginWlanSettingsDlgIpv4::NewL(
       
    47                                             CCmPluginBaseEng& aCmPluginBase )
       
    48 	{
       
    49 	CmPluginWlanSettingsDlgIpv4* self = 
       
    50 	            new ( ELeave ) CmPluginWlanSettingsDlgIpv4( aCmPluginBase );
       
    51 	return self;
       
    52 	}
       
    53 	
       
    54 // --------------------------------------------------------------------------
       
    55 // CmPluginWlanSettingsDlgIpv4::CmPluginWlanSettingsDlgIpv4
       
    56 // --------------------------------------------------------------------------
       
    57 //
       
    58 CmPluginWlanSettingsDlgIpv4::CmPluginWlanSettingsDlgIpv4( 
       
    59                                         CCmPluginBaseEng& aCmPluginBase ) :
       
    60     CmPluginBaseSettingsDlgIp( aCmPluginBase ) ,
       
    61     iParent( NULL )
       
    62     {
       
    63     iHelpContext = KSET_HLP_AP_WLAN_AS_IPV4;
       
    64     }
       
    65 
       
    66 // --------------------------------------------------------------------------
       
    67 // CmPluginWlanSettingsDlgIpv4::ConstructAndRunLD
       
    68 // --------------------------------------------------------------------------
       
    69 //
       
    70 TInt CmPluginWlanSettingsDlgIpv4::ConstructAndRunLD()
       
    71     {
       
    72     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
    73     cmMgr.WatcherRegisterL( this );
       
    74     
       
    75     return CmPluginBaseSettingsDlgIp::ConstructAndRunLD();
       
    76     }
       
    77     
       
    78 // ---------------------------------------------------------
       
    79 // CmPluginWlanSettingsDlgIpv4::~CmPluginWlanSettingsDlgIpv4
       
    80 // Destructor
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 CmPluginWlanSettingsDlgIpv4::~CmPluginWlanSettingsDlgIpv4()
       
    84     {
       
    85     }
       
    86 
       
    87 
       
    88 // --------------------------------------------------------------------------
       
    89 // CmPluginWlanSettingsDlgIpv4::UpdateListBoxContentBearerSpecificL
       
    90 // --------------------------------------------------------------------------
       
    91 //
       
    92 void CmPluginWlanSettingsDlgIpv4::UpdateListBoxContentBearerSpecificL( 
       
    93                                                     CDesCArray& aItemArray )
       
    94     {
       
    95     // PHONE IP ADDRESS
       
    96     AppendSettingTextsL( aItemArray, EWlanIpAddr );
       
    97     HBufC* ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpAddr );
       
    98     TBool isUnspec = IsUnspecifiedIPv4Address( *ipAddr );
       
    99     delete ipAddr; ipAddr = NULL;
       
   100     
       
   101     if ( !isUnspec )
       
   102         {
       
   103         // SUBNET MASK
       
   104         AppendSettingTextsL( aItemArray, EWlanIpNetMask );
       
   105         // DEFAULT GATEWAY
       
   106         AppendSettingTextsL( aItemArray, EWlanIpGateway );
       
   107         }
       
   108 
       
   109     // DNS SERVERS IP ADDRESS
       
   110     TBool boolValue = iCmPluginBaseEng.GetBoolAttributeL( 
       
   111                                                 EWlanIpDNSAddrFromServer );
       
   112     AppendSettingTextsL( aItemArray,
       
   113                          EWlanIpDNSAddrFromServer,
       
   114                          boolValue ? 
       
   115                                 R_QTN_SET_DNS_SERVERS_AUTOMATIC : 
       
   116                                 R_QTN_SET_IP_USER_DEFINED );
       
   117     }
       
   118     
       
   119 //---------------------------------------------------------------------------
       
   120 // CmPluginWlanSettingsDlgIpv4::ShowPopupSettingPageL
       
   121 //---------------------------------------------------------------------------
       
   122 //
       
   123 TBool CmPluginWlanSettingsDlgIpv4::ShowPopupSettingPageL( TUint32 aAttribute, 
       
   124                                                           TInt aCommandId )
       
   125     {
       
   126     TBool retval = EFalse;
       
   127     switch ( aAttribute )
       
   128         {
       
   129         case EWlanIpDNSAddrFromServer:
       
   130             {
       
   131             ShowPopupIPv4DNSEditorL( EWlanIpDNSAddrFromServer, 
       
   132                                      EWlanIpNameServer1,
       
   133                                      EWlanIpNameServer2 );
       
   134             break;
       
   135             }
       
   136         case EWlanIpAddr:
       
   137         case EWlanIpNetMask:
       
   138         case EWlanIpGateway:
       
   139             {
       
   140             ShowPopupIpSettingPageL( aAttribute );
       
   141             break;
       
   142             }
       
   143         default:
       
   144             {
       
   145             CmPluginBaseSettingsDlgIp::ShowPopupSettingPageL( aAttribute, 
       
   146                                                                aCommandId );
       
   147             break;            
       
   148             }
       
   149         }
       
   150     return retval;
       
   151     }
       
   152 
       
   153 
       
   154 //---------------------------------------------------------------------------
       
   155 // CmPluginWlanSettingsDlgIpv4::ProcessCommandL
       
   156 //---------------------------------------------------------------------------
       
   157 //
       
   158 void CmPluginWlanSettingsDlgIpv4::ProcessCommandL( TInt aCommandId )
       
   159     {
       
   160     if ( MenuShowing() )
       
   161         {
       
   162         HideMenu();
       
   163         }
       
   164     switch ( aCommandId )
       
   165         {
       
   166         case EPluginBaseCmdExit:
       
   167             {
       
   168             if ( ValidateAttribsL() )
       
   169                 {
       
   170                 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   171                 cmMgr.WatcherUnRegister();
       
   172                 
       
   173                 iExitReason = KDialogUserExit;
       
   174                 TryExitL( iExitReason );
       
   175                 }
       
   176             break;
       
   177             }       
       
   178         case EPluginBaseCmdChange:
       
   179             {
       
   180             ShowPopupSettingPageL( 
       
   181                         iSettingIndex->At( iListbox->CurrentItemIndex() ),
       
   182                         aCommandId );
       
   183             break;
       
   184             }
       
   185         default:
       
   186             {
       
   187             CmPluginBaseSettingsDlgIp::ProcessCommandL( aCommandId );
       
   188             break;            
       
   189             }
       
   190        }
       
   191    }
       
   192 
       
   193 // --------------------------------------------------------------------------
       
   194 // CmPluginWlanSettingsDlgIpv4::OkToExitL
       
   195 // --------------------------------------------------------------------------
       
   196 //
       
   197 TBool CmPluginWlanSettingsDlgIpv4::OkToExitL( TInt aButtonId )
       
   198     {
       
   199     TBool retval( EFalse );
       
   200     
       
   201     switch ( aButtonId )
       
   202         {
       
   203         case EAknSoftkeyOk:
       
   204         case EAknSoftkeyChange:
       
   205             {
       
   206             ProcessCommandL( EPluginBaseCmdChange );
       
   207             break;
       
   208             }
       
   209         case EAknSoftkeyBack:
       
   210             {
       
   211             if ( ValidateAttribsL() )
       
   212                 {
       
   213                 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   214                 cmMgr.WatcherUnRegister();
       
   215                 
       
   216                 iExitReason = KDialogUserBack;
       
   217                 retval = ETrue;
       
   218                 }
       
   219             break;
       
   220             }
       
   221         default:
       
   222             {
       
   223             retval = CmPluginBaseSettingsDlgIp::OkToExitL( aButtonId );
       
   224             break;
       
   225             }
       
   226         }
       
   227     return retval;
       
   228     }
       
   229 
       
   230 // --------------------------------------------------------------------------
       
   231 // CmPluginWlanSettingsDlgIpv4::ValidateAttribsL
       
   232 // --------------------------------------------------------------------------
       
   233 //
       
   234 TBool CmPluginWlanSettingsDlgIpv4::ValidateAttribsL()
       
   235     {
       
   236     TBool retVal ( EFalse );
       
   237     HBufC* ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpAddr );
       
   238     TBool isUnspec = IsUnspecifiedIPv4Address( *ipAddr );
       
   239     delete ipAddr; ipAddr = NULL;
       
   240     
       
   241     if ( !isUnspec )
       
   242         {
       
   243         ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpNetMask );
       
   244         TBool isUnspec1 = IsUnspecifiedIPv4Address( *ipAddr );
       
   245         delete ipAddr;
       
   246         ipAddr = iCmPluginBaseEng.GetStringAttributeL( EWlanIpGateway );
       
   247         TBool isUnspec2 = IsUnspecifiedIPv4Address( *ipAddr );
       
   248         delete ipAddr;
       
   249         
       
   250         if ( isUnspec1 || isUnspec2 )
       
   251             {
       
   252             if ( TCmCommonUi::ShowConfirmationQueryL(
       
   253                     R_QTN_NETW_QUEST_IAP_INCOMPLETE_DELETE ) )
       
   254                 {
       
   255                 // quit without saving, so restore attributes
       
   256                 iCmPluginBaseEng.RestoreAttributeL( EWlanIpAddr );
       
   257                 iCmPluginBaseEng.RestoreAttributeL( EWlanIpNetMask );
       
   258                 iCmPluginBaseEng.RestoreAttributeL( EWlanIpGateway );
       
   259                 iCmPluginBaseEng.RestoreAttributeL( EWlanIpDNSAddrFromServer );
       
   260                 retVal = ETrue;
       
   261                 }
       
   262             }
       
   263          else
       
   264             {
       
   265             retVal = ETrue;
       
   266             }
       
   267         }
       
   268     else
       
   269         {
       
   270         retVal = ETrue;
       
   271         }
       
   272 
       
   273     return retVal;
       
   274     }
       
   275 
       
   276 // --------------------------------------------------------------------------
       
   277 // CmPluginWlanSettingsDlgIpv4::InitTextsL
       
   278 // --------------------------------------------------------------------------
       
   279 //
       
   280 void CmPluginWlanSettingsDlgIpv4::InitTextsL()
       
   281     {
       
   282     // set pane text if neccessary...
       
   283     // pane text needed if not pop-up...
       
   284     if ( iEikonEnv )
       
   285         {
       
   286         iStatusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   287         iTitlePane =
       
   288             ( CAknTitlePane* )iStatusPane->ControlL(
       
   289                                 TUid::Uid( EEikStatusPaneUidTitle ) );
       
   290 
       
   291         iOldTitleText = iTitlePane->Text()->AllocL();
       
   292         HBufC* title = StringLoader::LoadLC ( R_QTN_SET_IPV4_SETTINGS );
       
   293         iTitlePane->SetTextL( *title ) ;
       
   294         CleanupStack::PopAndDestroy(title);                         
       
   295         iNaviPane = ( CAknNavigationControlContainer* ) 
       
   296                         iStatusPane->ControlL( 
       
   297                                 TUid::Uid( EEikStatusPaneUidNavi ) );
       
   298         iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC );
       
   299         iNaviPane->PushL( *iNaviDecorator );
       
   300         }
       
   301     }
       
   302 
       
   303 // --------------------------------------------------------------------------
       
   304 // CmPluginWlanSettingsDlgIpv4::RegisterParentView
       
   305 // --------------------------------------------------------------------------
       
   306 //
       
   307 void CmPluginWlanSettingsDlgIpv4::RegisterParentView( CCmParentViewNotifier* aParent )
       
   308     {
       
   309     iParent = aParent;
       
   310     }
       
   311 
       
   312 // --------------------------------------------------------------------------
       
   313 // CmPluginWlanSettingsDlgIpv4::CommsDatChangesL
       
   314 // --------------------------------------------------------------------------
       
   315 //
       
   316 void CmPluginWlanSettingsDlgIpv4::CommsDatChangesL()
       
   317     {
       
   318     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   319     CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination();
       
   320     
       
   321     if ( parentDest )
       
   322         {
       
   323         if( !cmMgr.DestinationStillExistedL( parentDest ) )
       
   324             {
       
   325             if( iParent )
       
   326                 {
       
   327                 iParent->NotifyParentView( KCmNotifiedDestinationDisappear );
       
   328                 }
       
   329             
       
   330             cmMgr.WatcherUnRegister();
       
   331             // If parent destination is deleted by somebody then the dialog must exit back to main view
       
   332             iExitReason = KDialogUserExit;
       
   333             TryExitL( iExitReason );
       
   334                 
       
   335             cmMgr.RemoveDestFromPool( parentDest );
       
   336             delete parentDest;
       
   337             return;
       
   338             }
       
   339             
       
   340         if( !cmMgr.IsIapStillInDestL( parentDest, iCmPluginBaseEng ) )
       
   341             {
       
   342             if( iParent )
       
   343                 {
       
   344                 iParent->NotifyParentView( KCmNotifiedIapIsNotInThisDestination );
       
   345                 }
       
   346             
       
   347             cmMgr.WatcherUnRegister();
       
   348             // In this case, the dialog can go back to the parent view
       
   349             TryExitL( iExitReason );
       
   350             
       
   351             cmMgr.RemoveDestFromPool( parentDest );
       
   352             delete parentDest;
       
   353             return;
       
   354             }
       
   355         
       
   356         // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat
       
   357         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   358         // after this call when some Iap is deleted.
       
   359         if( iParent )
       
   360             {
       
   361             iParent->NotifyParentView( KCmNotifiedIapDisappear );
       
   362             }
       
   363         cmMgr.WatcherUnRegister();
       
   364         TryExitL( iExitReason );
       
   365             
       
   366         cmMgr.RemoveDestFromPool( parentDest );
       
   367         delete parentDest;
       
   368         }
       
   369     else
       
   370         {
       
   371         if( !cmMgr.IapStillExistedL( iCmPluginBaseEng ) )
       
   372             {
       
   373             if( iParent )
       
   374             {
       
   375             iParent->NotifyParentView( KCmNotifiedIapDisappear );
       
   376             }
       
   377             
       
   378             cmMgr.WatcherUnRegister();
       
   379             // In this case, the dialog can go back to the parent view
       
   380             TryExitL( iExitReason );
       
   381             return;
       
   382             }
       
   383         
       
   384         // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat
       
   385         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   386         // after this call when some Iap is deleted.
       
   387         if( iParent )
       
   388             {
       
   389             iParent->NotifyParentView( KCmNotifiedIapDisappear );
       
   390             }
       
   391         cmMgr.WatcherUnRegister();
       
   392         TryExitL( iExitReason );
       
   393         }
       
   394     }